mirror of
https://github.com/frida/tinycc
synced 2024-11-24 00:29:38 +03:00
make SILENT=yes
This allows to run make more silently. Also, turns off debug info for binaries by default, but adds a switch to get it back easily ./configure --debug
This commit is contained in:
parent
92236bfe1d
commit
7bb5454ef3
140
Makefile
140
Makefile
@ -8,9 +8,11 @@ ifndef TOP
|
||||
INCLUDED = no
|
||||
endif
|
||||
|
||||
include $(TOP)/config.mak
|
||||
ifeq ($(findstring $(MAKECMDGOALS),clean distclean),)
|
||||
include $(TOP)/config.mak
|
||||
endif
|
||||
|
||||
ifeq (-$(CC)-$(GCC_MAJOR)-$(findstring $(GCC_MINOR),56789)-,-gcc-4--)
|
||||
ifeq (-$(GCC_MAJOR)-$(findstring $(GCC_MINOR),56789)-,-4--)
|
||||
CFLAGS += -D_FORTIFY_SOURCE=0
|
||||
endif
|
||||
|
||||
@ -60,6 +62,11 @@ ifdef CONFIG_OSX
|
||||
TCCFLAGS += -D_ANSI_SOURCE
|
||||
endif
|
||||
|
||||
# cross compiler targets to build
|
||||
TCC_X = i386 x86_64 i386-win32 x86_64-win32 x86_64-osx arm arm64 arm-wince c67
|
||||
TCC_X += riscv64
|
||||
# TCC_X += arm-fpa arm-fpa-ld arm-vfp arm-eabi
|
||||
|
||||
CFLAGS_P = $(CFLAGS) -pg -static -DCONFIG_TCC_STATIC -DTCC_PROFILE
|
||||
LIBS_P = $(LIBS)
|
||||
LDFLAGS_P = $(LDFLAGS)
|
||||
@ -86,16 +93,11 @@ ifeq ($(INCLUDED),no)
|
||||
# running top Makefile
|
||||
|
||||
PROGS = tcc$(EXESUF)
|
||||
TCCLIBS = $(LIBTCC1) $(LIBTCC) $(LIBTCCDEF)
|
||||
TCCLIBS = $(LIBTCCDEF) $(LIBTCC) $(LIBTCC1)
|
||||
TCCDOCS = tcc.1 tcc-doc.html tcc-doc.info
|
||||
|
||||
all: $(PROGS) $(TCCLIBS) $(TCCDOCS)
|
||||
|
||||
# cross compiler targets to build
|
||||
TCC_X = i386 x86_64 i386-win32 x86_64-win32 x86_64-osx arm arm64 arm-wince c67
|
||||
TCC_X += riscv64
|
||||
# TCC_X += arm-fpa arm-fpa-ld arm-vfp arm-eabi
|
||||
|
||||
# cross libtcc1.a targets to build
|
||||
LIBTCC1_X = i386 x86_64 i386-win32 x86_64-win32 x86_64-osx arm arm64 arm-wince
|
||||
LIBTCC1_X += riscv64
|
||||
@ -109,8 +111,8 @@ cross: $(LIBTCC1_CROSS) $(PROGS_CROSS)
|
||||
# build specific cross compiler & lib
|
||||
cross-%: %-tcc$(EXESUF) %-libtcc1.a ;
|
||||
|
||||
install: ; @$(MAKE) --no-print-directory install$(CFGWIN)
|
||||
install-strip: ; @$(MAKE) --no-print-directory install$(CFGWIN) CONFIG_strip=yes
|
||||
install: ; @$(MAKE) --no-print-directory install$(CFGWIN)
|
||||
install-strip: ; @$(MAKE) --no-print-directory install$(CFGWIN) CONFIG_strip=yes
|
||||
uninstall: ; @$(MAKE) --no-print-directory uninstall$(CFGWIN)
|
||||
|
||||
ifdef CONFIG_cross
|
||||
@ -193,35 +195,43 @@ TCC_FILES = $(X)tcc.o $(LIBTCC_OBJ)
|
||||
$(TCC_FILES) : DEFINES += -DONE_SOURCE=0
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_strip),no)
|
||||
CFLAGS += -g
|
||||
LDFLAGS += -g
|
||||
else
|
||||
CONFIG_strip = yes
|
||||
LDFLAGS += -s
|
||||
endif
|
||||
|
||||
# target specific object rule
|
||||
$(X)%.o : %.c $(LIBTCC_INC)
|
||||
$(CC) -o $@ -c $< $(DEFINES) $(CFLAGS)
|
||||
$S$(CC) -o $@ -c $< $(DEFINES) $(CFLAGS)
|
||||
|
||||
# additional dependencies
|
||||
$(X)tcc.o : tcctools.c
|
||||
|
||||
# Host Tiny C Compiler
|
||||
tcc$(EXESUF): tcc.o $(LIBTCC)
|
||||
$(CC) -o $@ $^ $(LIBS) $(LDFLAGS) $(LINK_LIBTCC)
|
||||
$S$(CC) -o $@ $^ $(LIBS) $(LDFLAGS) $(LINK_LIBTCC)
|
||||
|
||||
# Cross Tiny C Compilers
|
||||
%-tcc$(EXESUF): FORCE
|
||||
@$(MAKE) --no-print-directory $@ CROSS_TARGET=$* ONE_SOURCE=$(or $(ONE_SOURCE),yes)
|
||||
|
||||
$(CROSS_TARGET)-tcc$(EXESUF): $(TCC_FILES)
|
||||
$(CC) -o $@ $^ $(LIBS) $(LDFLAGS)
|
||||
$S$(CC) -o $@ $^ $(LIBS) $(LDFLAGS)
|
||||
|
||||
# profiling version
|
||||
tcc_p$(EXESUF): $($T_FILES)
|
||||
$(CC) -o $@ $< $(DEFINES) $(CFLAGS_P) $(LIBS_P) $(LDFLAGS_P)
|
||||
$S$(CC) -o $@ $< $(DEFINES) $(CFLAGS_P) $(LIBS_P) $(LDFLAGS_P)
|
||||
|
||||
# static libtcc library
|
||||
libtcc.a: $(LIBTCC_OBJ)
|
||||
$(AR) rcs $@ $^
|
||||
$S$(AR) rcs $@ $^
|
||||
|
||||
# dynamic libtcc library
|
||||
libtcc.so: $(LIBTCC_OBJ)
|
||||
$(CC) -shared -Wl,-soname,$@ -o $@ $^ $(LDFLAGS)
|
||||
$S$(CC) -shared -Wl,-soname,$@ -o $@ $^ $(LDFLAGS)
|
||||
|
||||
libtcc.so: CFLAGS+=-fPIC
|
||||
libtcc.so: LDFLAGS+=-fPIC
|
||||
@ -231,12 +241,12 @@ libtcc.dylib: $(LIBTCC_OBJ)
|
||||
|
||||
# windows dynamic libtcc library
|
||||
libtcc.dll : $(LIBTCC_OBJ)
|
||||
$(CC) -shared -o $@ $^ $(LDFLAGS)
|
||||
$S$(CC) -shared -o $@ $^ $(LDFLAGS)
|
||||
libtcc.dll : DEFINES += -DLIBTCC_AS_DLL
|
||||
|
||||
# import file for windows libtcc.dll
|
||||
libtcc.def : libtcc.dll tcc$(EXESUF)
|
||||
$(XTCC) -impdef $< -o $@
|
||||
$S$(XTCC) -impdef $< -o $@
|
||||
XTCC ?= ./tcc$(EXESUF)
|
||||
|
||||
# TinyCC runtime libraries
|
||||
@ -250,18 +260,22 @@ libtcc1.a : tcc$(EXESUF) FORCE
|
||||
.PRECIOUS: %-libtcc1.a
|
||||
FORCE:
|
||||
|
||||
run-if = $(if $(shell which $1),$S $1 $2)
|
||||
S = $(if $(findstring yes,$(SILENT)),@$(info * $@))
|
||||
|
||||
# --------------------------------------------------------------------------
|
||||
# documentation and man page
|
||||
tcc-doc.html: tcc-doc.texi
|
||||
makeinfo --no-split --html --number-sections -o $@ $< || true
|
||||
|
||||
tcc.1: tcc-doc.texi
|
||||
$(TOPSRC)/texi2pod.pl $< tcc.pod \
|
||||
&& pod2man --section=1 --center="Tiny C Compiler" --release="$(VERSION)" tcc.pod >tmp.1 \
|
||||
&& mv tmp.1 $@ || rm -f tmp.1
|
||||
$(call run-if,makeinfo,--no-split --html --number-sections -o $@ $<)
|
||||
|
||||
tcc-doc.info: tcc-doc.texi
|
||||
makeinfo $< || true
|
||||
$(call run-if,makeinfo,$< || true)
|
||||
|
||||
tcc.1 : tcc-doc.pod
|
||||
$(call run-if,pod2man,--section=1 --center="Tiny C Compiler" \
|
||||
--release="$(VERSION)" $< >$@ && rm -f $<)
|
||||
%.pod : %.texi
|
||||
$(call run-if,perl,$(TOPSRC)/texi2pod.pl $< $@)
|
||||
|
||||
# --------------------------------------------------------------------------
|
||||
# install
|
||||
@ -272,11 +286,13 @@ STRIP_yes = -s
|
||||
|
||||
LIBTCC1_W = $(filter %-win32-libtcc1.a %-wince-libtcc1.a,$(LIBTCC1_CROSS))
|
||||
LIBTCC1_U = $(filter-out $(LIBTCC1_W),$(LIBTCC1_CROSS))
|
||||
IB = $(if $1,mkdir -p $2 && $(INSTALLBIN) $1 $2)
|
||||
IB = $(if $1,$(IM) mkdir -p $2 && $(INSTALLBIN) $1 $2)
|
||||
IBw = $(call IB,$(wildcard $1),$2)
|
||||
IF = $(if $1,mkdir -p $2 && $(INSTALL) $1 $2)
|
||||
IF = $(if $1,$(IM) mkdir -p $2 && $(INSTALL) $1 $2)
|
||||
IFw = $(call IF,$(wildcard $1),$2)
|
||||
IR = mkdir -p $2 && cp -r $1/. $2
|
||||
IR = $(IM) mkdir -p $2 && cp -r $1/. $2
|
||||
IM = $(info -> $2 : $1)@
|
||||
|
||||
B_O = bcheck.o bt-exe.o bt-log.o bt-dll.o
|
||||
|
||||
# install progs & libs
|
||||
@ -301,7 +317,7 @@ uninstall-unx:
|
||||
@rm -fv "$(libdir)/libtcc.a" "$(libdir)/libtcc.so" "$(includedir)/libtcc.h"
|
||||
@rm -fv "$(mandir)/man1/tcc.1" "$(infodir)/tcc-doc.info"
|
||||
@rm -fv "$(docdir)/tcc-doc.html"
|
||||
rm -r "$(tccdir)"
|
||||
@rm -frv "$(tccdir)"
|
||||
|
||||
# install progs & libs on windows
|
||||
install-win:
|
||||
@ -320,17 +336,16 @@ ifneq "$(wildcard $(LIBTCC1_U))" ""
|
||||
endif
|
||||
|
||||
# the msys-git shell works to configure && make except it does not have install
|
||||
ifeq "$(and $(CONFIG_WIN32),$(shell which install >/dev/null 2>&1 || echo no))" "no"
|
||||
ifeq ($(CONFIG_WIN32)-$(shell which install || echo no),yes-no)
|
||||
install-win : INSTALL = cp
|
||||
install-win : INSTALLBIN = cp
|
||||
endif
|
||||
|
||||
# uninstall on windows
|
||||
uninstall-win:
|
||||
@rm -fv $(foreach P,$(PROGS) $(PROGS_CROSS) libtcc.dll,"$(bindir)/$P")
|
||||
@rm -fv $(foreach F,tcc-doc.html tcc-win32.txt,"$(docdir)/$F")
|
||||
@rm -fv $(foreach F,libtcc.h libtcc.def libtcc.a,"$(libdir)/$F")
|
||||
rm -r "$(tccdir)"
|
||||
@rm -fv $(foreach P,libtcc.dll $(PROGS) *-tcc.exe,"$(bindir)/$P")
|
||||
@rm -fr $(foreach P,doc examples include lib libtcc,"$(tccdir)/$P"/*)
|
||||
@rm -frv $(foreach P,doc examples include lib libtcc,"$(tccdir)/$P")
|
||||
|
||||
# --------------------------------------------------------------------------
|
||||
# other stuff
|
||||
@ -343,8 +358,9 @@ ETAGS : ; etags $(TAGFILES)
|
||||
# create release tarball from *current* git branch (including tcc-doc.html
|
||||
# and converting two files to CRLF)
|
||||
TCC-VERSION = tcc-$(VERSION)
|
||||
TCC-VERSION = tinycc-mob-$(shell git rev-parse --short=7 HEAD)
|
||||
tar: tcc-doc.html
|
||||
mkdir $(TCC-VERSION)
|
||||
mkdir -p $(TCC-VERSION)
|
||||
( cd $(TCC-VERSION) && git --git-dir ../.git checkout -f )
|
||||
cp tcc-doc.html $(TCC-VERSION)
|
||||
for f in tcc-win32.txt build-tcc.bat ; do \
|
||||
@ -359,22 +375,22 @@ config.mak:
|
||||
|
||||
# run all tests
|
||||
test:
|
||||
$(MAKE) -C tests
|
||||
@$(MAKE) -C tests
|
||||
# run test(s) from tests2 subdir (see make help)
|
||||
tests2.%:
|
||||
$(MAKE) -C tests/tests2 $@
|
||||
@$(MAKE) -C tests/tests2 $@
|
||||
|
||||
testspp.%:
|
||||
$(MAKE) -C tests/pp $@
|
||||
@$(MAKE) -C tests/pp $@
|
||||
|
||||
clean:
|
||||
rm -f tcc$(EXESUF) tcc_p$(EXESUF) *-tcc$(EXESUF) tcc.pod
|
||||
rm -f *~ *.o *.a *.so* *.out *.log lib*.def *.exe *.dll a.out tags TAGS *.dylib
|
||||
@$(MAKE) -C lib $@
|
||||
@$(MAKE) -C tests $@
|
||||
@rm -f tcc$(EXESUF) tcc_p$(EXESUF) *-tcc$(EXESUF) tcc.pod
|
||||
@rm -f *.o *.a *.so* *.out *.log lib*.def *.exe *.dll a.out tags TAGS *.dylib
|
||||
@$(MAKE) -s -C lib $@
|
||||
@$(MAKE) -s -C tests $@
|
||||
|
||||
distclean: clean
|
||||
rm -f config.h config.mak config.texi tcc.1 tcc-doc.info tcc-doc.html
|
||||
@rm -fv config.h config.mak config.texi tcc.1 tcc-doc.info tcc-doc.html
|
||||
|
||||
.PHONY: all clean test tar tags ETAGS distclean install uninstall FORCE
|
||||
|
||||
@ -385,39 +401,37 @@ help:
|
||||
@echo "make cross"
|
||||
@echo " build cross compilers (from one source)"
|
||||
@echo ""
|
||||
@echo "make ONE_SOURCE=yes / no"
|
||||
@echo " force building from one source / separate objects"
|
||||
@echo "make ONE_SOURCE=no/yes SILENT=no/yes"
|
||||
@echo " force building from separate/one object(s), less/more silently"
|
||||
@echo ""
|
||||
@echo "make cross-TARGET"
|
||||
@echo " build one specific cross compiler for 'TARGET', as in"
|
||||
@echo " $(TCC_X)"
|
||||
@echo ""
|
||||
@echo "Custom configuration:"
|
||||
@echo " The makefile includes a file 'config-extra.mak' if it is present."
|
||||
@echo " This file may contain some custom configuration. For example:"
|
||||
@echo ""
|
||||
@echo " NATIVE_DEFINES += -D..."
|
||||
@echo ""
|
||||
@echo " Or for example to configure the search paths for a cross-compiler"
|
||||
@echo " that expects the linux files in <tccdir>/i386-linux:"
|
||||
@echo ""
|
||||
@echo " ROOT-i386 = {B}/i386-linux"
|
||||
@echo " CRT-i386 = {B}/i386-linux/usr/lib"
|
||||
@echo " LIB-i386 = {B}/i386-linux/lib:{B}/i386-linux/usr/lib"
|
||||
@echo " INC-i386 = {B}/lib/include:{B}/i386-linux/usr/include"
|
||||
@echo " DEF-i386 += -D__linux__"
|
||||
@echo " build one specific cross compiler for 'TARGET'. Currently supported:"
|
||||
@echo " $(wordlist 1,6,$(TCC_X))"
|
||||
@echo " $(wordlist 7,99,$(TCC_X))"
|
||||
@echo ""
|
||||
@echo "make test"
|
||||
@echo " run all tests"
|
||||
@echo ""
|
||||
@echo "make tests2.all / make tests2.37 / make tests2.37+"
|
||||
@echo " run all/single test(s) from tests2, optionally update .expect"
|
||||
@echo ""
|
||||
@echo "make testspp.all / make testspp.17"
|
||||
@echo " run all/single test(s) from tests/pp"
|
||||
@echo ""
|
||||
@echo "Other supported make targets:"
|
||||
@echo " install install-strip tags ETAGS tar clean distclean help"
|
||||
@echo " install install-strip doc clean tags ETAGS tar distclean help"
|
||||
@echo ""
|
||||
@echo "Custom configuration:"
|
||||
@echo " The makefile includes a file 'config-extra.mak' if it is present."
|
||||
@echo " This file may contain some custom configuration. For example:"
|
||||
@echo " NATIVE_DEFINES += -D..."
|
||||
@echo " Or for example to configure the search paths for a cross-compiler"
|
||||
@echo " that expects the linux files in <tccdir>/i386-linux:"
|
||||
@echo " ROOT-i386 = {B}/i386-linux"
|
||||
@echo " CRT-i386 = {B}/i386-linux/usr/lib"
|
||||
@echo " LIB-i386 = {B}/i386-linux/lib:{B}/i386-linux/usr/lib"
|
||||
@echo " INC-i386 = {B}/lib/include:{B}/i386-linux/usr/include"
|
||||
@echo " DEF-i386 += -D__linux__"
|
||||
|
||||
# --------------------------------------------------------------------------
|
||||
endif # ($(INCLUDED),no)
|
||||
|
44
configure
vendored
44
configure
vendored
@ -55,7 +55,7 @@ case $targetos in
|
||||
confvars="$confvars OSX"
|
||||
DLLSUF=".dylib"
|
||||
;;
|
||||
MINGW*|MSYS*|CYGWIN*)
|
||||
Windows_NT|MINGW*|MSYS*|CYGWIN*)
|
||||
mingw32=yes
|
||||
;;
|
||||
DragonFly|OpenBSD|FreeBSD|NetBSD)
|
||||
@ -135,6 +135,8 @@ for opt do
|
||||
;;
|
||||
--strip-binaries) confvars="$confvars strip"
|
||||
;;
|
||||
--debug) confvars="$confvars strip=no"
|
||||
;;
|
||||
--with-libgcc) confvars="$confvars libgcc"
|
||||
;;
|
||||
--with-selinux) confvars="$confvars selinux"
|
||||
@ -154,40 +156,9 @@ cc="${cross_prefix}${cc}"
|
||||
ar="${cross_prefix}${ar}"
|
||||
strip="${cross_prefix}${strip}"
|
||||
|
||||
|
||||
PPIF_TEMPLATE="
|
||||
int ppif(void) {
|
||||
#if %s
|
||||
return 0;
|
||||
#else
|
||||
PPIF_FALSE;
|
||||
#endif
|
||||
}
|
||||
"
|
||||
|
||||
# Succeeds when preprocessor condition `#if $1` is true.
|
||||
# if $2 is not empty, prints to stderr `checking whether $2... <yes/no>`
|
||||
# Works also when $cc is a cross compiler to any foreign platform.
|
||||
# E.g. ppif "defined(__GNUC__) && (GCC_MAJOR >= 3)"
|
||||
# or ppif "defined(_WIN32)" "target is Windows"
|
||||
ppif() {
|
||||
[ -z "${2-}" ] || printf "checking whether %s... " "$2" >&2
|
||||
printf "$PPIF_TEMPLATE" "$1" > ppif.c \
|
||||
&& $cc -o ppif.o -c ppif.c 2>/dev/null
|
||||
ppif_rv=$?
|
||||
rm ppif.c ppif.o 2>/dev/null
|
||||
[ -z "${2-}" ] || { [ 0 = $ppif_rv ] && echo yes || echo no; } >&2
|
||||
return $ppif_rv
|
||||
}
|
||||
|
||||
|
||||
if test -z "$cpu" ; then
|
||||
if test -n "$ARCH" ; then
|
||||
cpu="$ARCH"
|
||||
elif ppif "defined(__x86_64__)"; then
|
||||
cpu="x86_64"
|
||||
elif ppif "defined(__i386__)"; then
|
||||
cpu="i386"
|
||||
else
|
||||
cpu=`uname -m`
|
||||
fi
|
||||
@ -243,14 +214,14 @@ esac
|
||||
|
||||
# Checking for CFLAGS
|
||||
if test -z "$CFLAGS"; then
|
||||
CFLAGS="-Wall -g -O2"
|
||||
CFLAGS="-Wall -O2"
|
||||
fi
|
||||
|
||||
if test "$mingw32" = "yes" ; then
|
||||
if test "$source_path_used" = "no"; then
|
||||
source_path="."
|
||||
fi
|
||||
if test "$cc" = gcc; then
|
||||
if test "${cc%% *}" = "gcc"; then
|
||||
test -z "$LDFLAGS" && LDFLAGS="-static"
|
||||
fi
|
||||
test -z "$prefix" && prefix="C:/Program Files/tcc"
|
||||
@ -324,6 +295,7 @@ Advanced options (experts only):
|
||||
--extra-ldflags= specify linker options []
|
||||
--cpu=CPU CPU [$cpu]
|
||||
--strip-binaries strip symbol tables from resulting binaries
|
||||
--debug include debug info with resulting binaries
|
||||
--disable-static make libtcc.so instead of libtcc.a
|
||||
--enable-static make libtcc.a instead of libtcc.dll (win32)
|
||||
--disable-rpath disable use of -rpath with the above
|
||||
@ -519,6 +491,10 @@ if test "$source_path_used" = "yes" ; then
|
||||
else
|
||||
echo 'TOPSRC=$(TOP)' >>config.mak
|
||||
fi
|
||||
cat >>$TMPH <<EOF
|
||||
#define GCC_MAJOR $gcc_major
|
||||
#define GCC_MINOR $gcc_minor
|
||||
EOF
|
||||
|
||||
diff $TMPH config.h >/dev/null 2>&1
|
||||
if test $? -ne 0 ; then
|
||||
|
@ -15,6 +15,7 @@ XFLAGS-unx = -B$(TOPSRC)
|
||||
XFLAGS-win = -B$(TOPSRC)/win32 -I$(TOPSRC)/include
|
||||
XFLAGS = $(XFLAGS$(XCFG)) -I$(TOP)
|
||||
XCFG = $(or $(findstring -win,$T),-unx)
|
||||
S = $(if $(findstring yes,$(SILENT)),@$(info * $@))
|
||||
|
||||
# in order to use gcc, tyoe: make <target>-libtcc1-usegcc=yes
|
||||
arm-libtcc1-usegcc ?= no
|
||||
@ -66,16 +67,16 @@ ALL = $(addprefix $(TOP)/,$(X)libtcc1.a $(OBJ-extra))
|
||||
all: $(ALL)
|
||||
|
||||
$(TOP)/$(X)libtcc1.a : $(OBJ-libtcc1)
|
||||
$(XAR) rcs $@ $^
|
||||
$S$(XAR) rcs $@ $^
|
||||
|
||||
$(X)%.o : %.c
|
||||
$(XCC) -c $< -o $@ $(XFLAGS)
|
||||
$S$(XCC) -c $< -o $@ $(XFLAGS)
|
||||
|
||||
$(X)%.o : %.S
|
||||
$(XCC) -c $< -o $@ $(XFLAGS)
|
||||
$S$(XCC) -c $< -o $@ $(XFLAGS)
|
||||
|
||||
$(TOP)/%.o : %.c
|
||||
$(XCC) -c $< -o $@ $(XFLAGS)
|
||||
$S$(XCC) -c $< -o $@ $(XFLAGS)
|
||||
|
||||
$(TOP)/bcheck.o : XFLAGS += -g
|
||||
$(TOP)/bt-exe.o : $(TOP)/tccrun.c
|
||||
|
2
tcc.c
2
tcc.c
@ -158,6 +158,8 @@ static const char version[] =
|
||||
"ARM"
|
||||
#elif defined TCC_TARGET_ARM64
|
||||
"AArch64"
|
||||
#elif defined TCC_TARGET_RISCV64
|
||||
"riscv64"
|
||||
#endif
|
||||
#ifdef TCC_ARM_HARDFLOAT
|
||||
" Hard Float"
|
||||
|
1
tcc.h
1
tcc.h
@ -46,6 +46,7 @@ extern long double strtold (const char *__nptr, char **__endptr);
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
# define WIN32_LEAN_AND_MEAN
|
||||
# include <windows.h>
|
||||
# include <io.h> /* open, close etc. */
|
||||
# include <direct.h> /* getcwd */
|
||||
|
@ -23,8 +23,7 @@ TESTS = \
|
||||
tests2-dir \
|
||||
pp-dir
|
||||
|
||||
BTESTS = btest test2b
|
||||
|
||||
BTESTS = btest test1b
|
||||
# test4_static -- Not all relocation types are implemented yet.
|
||||
# asmtest / asmtest2 -- minor differences with gcc
|
||||
|
||||
@ -36,9 +35,6 @@ endif
|
||||
ifeq ($(ARCH),x86_64)
|
||||
TESTS += $(BTESTS)
|
||||
endif
|
||||
ifdef CONFIG_WIN32
|
||||
TESTS += $(BTESTS)
|
||||
endif
|
||||
endif
|
||||
ifdef CONFIG_OSX # -run only
|
||||
TESTS := hello-run libtest tests2-dir pp-dir
|
||||
@ -52,12 +48,9 @@ endif
|
||||
ifeq (,$(filter i386 x86_64,$(ARCH)))
|
||||
TESTS := $(filter-out dlltest asm-c-connect-test,$(TESTS))
|
||||
endif
|
||||
ifndef CONFIG_cross
|
||||
TESTS := $(filter-out cross-%,$(TESTS))
|
||||
endif
|
||||
|
||||
ifeq ($(OS),Windows_NT) # for libtcc_test to find libtcc.dll
|
||||
PATH := $(CURDIR)/$(TOP)$(if $(findstring :\,$(PATH)),;,:)$(PATH)
|
||||
PATH := $(CURDIR)/$(TOP)$(if $(findstring ;,$(PATH)),;,:)$(PATH)
|
||||
endif
|
||||
|
||||
ifeq ($(ARCH),arm)
|
||||
@ -75,11 +68,10 @@ endif
|
||||
RUN_TCC = $(NATIVE_DEFINES) -run $(TOPSRC)/tcc.c $(TCCFLAGS)
|
||||
DISAS = objdump -d
|
||||
DUMPTCC = (set -x; $(TOP)/tcc -vv; ldd $(TOP)/tcc; exit 1)
|
||||
Q = # >/dev/null 2>&1
|
||||
|
||||
all test :
|
||||
$(MAKE) clean-s
|
||||
$(MAKE) $(TESTS)
|
||||
@$(MAKE) --no-print-directory -s clean
|
||||
@$(MAKE) --no-print-directory -s -r $(TESTS)
|
||||
|
||||
hello-exe: ../examples/ex1.c
|
||||
@echo ------------ $@ ------------
|
||||
@ -93,7 +85,10 @@ libtes%: libtcc_tes%$(EXESUF)
|
||||
@echo ------------ $@ ------------
|
||||
./libtcc_tes$*$(EXESUF) $(TOPSRC)/tcc.c $(TCCFLAGS) $(NATIVE_DEFINES)
|
||||
|
||||
libtcc_tes%$(EXESUF): libtcc_tes%.c $(LIBTCC)
|
||||
libtcc_test$(EXESUF): libtcc_test.c $(LIBTCC)
|
||||
$(CC) -o $@ $^ $(CFLAGS) $(LIBS)
|
||||
|
||||
libtcc_test_mt$(EXESUF): libtcc_test_mt.c $(LIBTCC)
|
||||
$(CC) -o $@ $^ $(CFLAGS) $(LIBS)
|
||||
|
||||
%-dir:
|
||||
@ -108,19 +103,19 @@ test.ref: tcctest.c
|
||||
# auto test
|
||||
test1 test1b: tcctest.c test.ref
|
||||
@echo ------------ $@ ------------
|
||||
$(TCC) -w -run $< > test.out1 $Q
|
||||
$(TCC) $(RUN_TCC) -w -run $< > test.out1
|
||||
@diff -u test.ref test.out1 && echo "$(AUTO_TEST) OK"
|
||||
|
||||
# iterated test2 (compile tcc then compile tcctest.c !)
|
||||
test2 test2b: tcctest.c test.ref
|
||||
@echo ------------ $@ ------------
|
||||
$(TCC) $(RUN_TCC) $(RUN_TCC) -w -run $< > test.out2 $Q
|
||||
$(TCC) $(RUN_TCC) $(RUN_TCC) -w -run $< > test.out2
|
||||
@diff -u test.ref test.out2 && echo "$(AUTO_TEST)2 OK"
|
||||
|
||||
# iterated test3 (compile tcc then compile tcc then compile tcctest.c !)
|
||||
test3 test3b: tcctest.c test.ref
|
||||
@echo ------------ $@ ------------
|
||||
$(TCC) $(RUN_TCC) $(RUN_TCC) $(RUN_TCC) -w -run $< > test.out3 $Q
|
||||
$(TCC) $(RUN_TCC) $(RUN_TCC) $(RUN_TCC) -w -run $< > test.out3
|
||||
@diff -u test.ref test.out3 && echo "$(AUTO_TEST)3 OK"
|
||||
|
||||
AUTO_TEST = Auto Test
|
||||
@ -145,6 +140,7 @@ test4: tcctest.c test.ref
|
||||
@if diff -u test.ref test4.out ; then echo "BCheck $(AUTO_TEST) OK"; fi
|
||||
|
||||
test4_static: tcctest.c test.ref
|
||||
@echo ------------ $@ ------------
|
||||
# static output.
|
||||
$(TCC) -static -o tcctest2 $<
|
||||
./tcctest2 > test2.out
|
||||
@ -170,6 +166,7 @@ memtest:
|
||||
$(CC) $(CFLAGS) $(NATIVE_DEFINES) -DMEM_DEBUG=2 $(TOPSRC)/tcc.c $(LIBS) -o memtest-tcc$(EXESUF)
|
||||
./memtest-tcc$(EXESUF) $(TCCFLAGS) $(NATIVE_DEFINES) $(TOPSRC)/tcc.c $(LIBS)
|
||||
./memtest-tcc$(EXESUF) $(TCCFLAGS) $(NATIVE_DEFINES) -run $(TOPSRC)/tcc.c $(TCCFLAGS) -w $(TOPSRC)/tests/tcctest.c
|
||||
@echo OK
|
||||
|
||||
# memory and bound check auto test
|
||||
BOUNDS_OK = 1 4 8 10 14 16
|
||||
@ -178,17 +175,17 @@ BOUNDS_FAIL= 2 5 6 7 9 11 12 13 15 17
|
||||
btest: boundtest.c
|
||||
@echo ------------ $@ ------------
|
||||
@for i in $(BOUNDS_OK); do \
|
||||
if $(TCC) -b -run $< $$i ; then \
|
||||
echo "- Test $$i succeeded as expected" ; \
|
||||
if $(TCC) -b -run $< $$i >/dev/null 2>&1 ; then \
|
||||
echo "Test $$i succeeded as expected" ; \
|
||||
else\
|
||||
echo "- Failed positive test $$i" ; exit 1 ; \
|
||||
echo "Failed positive test $$i" ; exit 1 ; \
|
||||
fi ;\
|
||||
done ;\
|
||||
for i in $(BOUNDS_FAIL); do \
|
||||
if $(TCC) -b -bt1 -run $< $$i ; then \
|
||||
echo "- Failed negative test $$i" ; exit 1 ;\
|
||||
if $(TCC) -b -bt1 -run $< $$i >/dev/null 2>&1 ; then \
|
||||
echo "Failed negative test $$i" ; exit 1 ;\
|
||||
else\
|
||||
echo "- Test $$i failed as expected" ; \
|
||||
echo "Test $$i failed as expected" ; \
|
||||
fi ;\
|
||||
done ;\
|
||||
echo Bound test OK
|
||||
@ -202,6 +199,7 @@ speedtest: ex2 ex3
|
||||
time $(TCC) -run $(TOPSRC)/examples/ex3.c 35
|
||||
|
||||
weaktest: tcctest.c test.ref
|
||||
@echo ------------ $@ ------------
|
||||
$(TCC) -c $< -o weaktest.tcc.o
|
||||
$(CC) -c $< -o weaktest.gcc.o $(NATIVE_DEFINES) $(CFLAGS) -w -O0 -std=gnu99 -fno-omit-frame-pointer
|
||||
objdump -t weaktest.tcc.o | grep ' w ' | sed -e 's/.* \([a-zA-Z0-9_]*\)$$/\1/' | LC_ALL=C sort > weaktest.tcc.o.txt
|
||||
@ -227,22 +225,19 @@ asmtest2: MAYBE_RUN_TCC = $(RUN_TCC)
|
||||
|
||||
# Check that code generated by libtcc is binary compatible with
|
||||
# that generated by CC
|
||||
abitest-cc$(EXESUF): abitest.c $(LIBTCC)
|
||||
abitest-cc.exe: abitest.c $(LIBTCC)
|
||||
$(CC) -o $@ $^ $(CFLAGS) $(LIBS) -w
|
||||
|
||||
abitest-tcc$(EXESUF): abitest.c libtcc.c
|
||||
$(TCC) -o $@ $^ $(NATIVE_DEFINES) $(LIBS)
|
||||
abitest-tcc.exe: abitest.c libtcc.c
|
||||
$(TCC) -o $@ $^ $(LIBS)
|
||||
|
||||
ABITESTS := abitest-cc$(EXESUF)
|
||||
ifneq ($(CONFIG_arm_eabi),yes) # not ARM soft-float
|
||||
ABITESTS += abitest-tcc$(EXESUF)
|
||||
endif
|
||||
|
||||
abitest: $(ABITESTS)
|
||||
abitest-% : abitest-%.exe
|
||||
@echo ------------ $@ ------------
|
||||
./abitest-cc$(EXESUF) $(TCCFLAGS)
|
||||
./$< $(TCCFLAGS)
|
||||
|
||||
abitest: abitest-cc
|
||||
ifneq ($(CONFIG_arm_eabi),yes) # not ARM soft-float
|
||||
./abitest-tcc$(EXESUF) $(TCCFLAGS)
|
||||
abitest: abitest-tcc
|
||||
endif
|
||||
|
||||
vla_test$(EXESUF): vla_test.c
|
||||
@ -265,22 +260,18 @@ asm-c-connect-test: asm-c-connect$(EXESUF) asm-c-connect-sep$(EXESUF)
|
||||
@echo ------------ $@ ------------
|
||||
./asm-c-connect$(EXESUF) > asm-c-connect.out1 && cat asm-c-connect.out1
|
||||
./asm-c-connect-sep$(EXESUF) > asm-c-connect.out2 && cat asm-c-connect.out2
|
||||
@diff -u asm-c-connect.out1 asm-c-connect.out2 && echo "ok"
|
||||
@diff -u asm-c-connect.out1 asm-c-connect.out2 || (echo "error"; exit 1)
|
||||
|
||||
TCC_YY = $(foreach T,$(TCC_X),$(if $(wildcard $(TOP)/$T-tcc$(EXESUF)),$T))
|
||||
|
||||
cross-test :
|
||||
$(if $(strip $(TCC_YY)),\
|
||||
$(MAKE) $(foreach T,$(TCC_YY),cross-$T.test) --no-print-directory,:)
|
||||
|
||||
cross-%.test :
|
||||
@echo ------------ $@ ------------
|
||||
$(TOP)/i386-tcc$(EXESUF) $(TCCFLAGS-unx) -c $(TOPSRC)/examples/ex3.c && echo "ok"
|
||||
$(TOP)/i386-win32-tcc$(EXESUF) $(TCCFLAGS-win) $(TOPSRC)/examples/ex3.c && echo "ok"
|
||||
$(TOP)/x86_64-tcc$(EXESUF) $(TCCFLAGS-unx) -c $(TOPSRC)/examples/ex3.c && echo "ok"
|
||||
$(TOP)/x86_64-win32-tcc$(EXESUF) $(TCCFLAGS-win) $(TOPSRC)/examples/ex3.c && echo "ok"
|
||||
$(TOP)/arm-tcc$(EXESUF) $(TCCFLAGS-unx) -c $(TOPSRC)/examples/ex3.c && echo "ok"
|
||||
$(TOP)/arm-wince-tcc$(EXESUF) $(TCCFLAGS-win) -c $(TOPSRC)/examples/ex3.c && echo "ok"
|
||||
$(TOP)/arm64-tcc$(EXESUF) $(TCCFLAGS-unx) -c $(TOPSRC)/examples/ex3.c && echo "ok"
|
||||
$(TOP)/riscv64-tcc$(EXESUF) $(TCCFLAGS-unx) -c $(TOPSRC)/examples/ex3.c && echo "ok"
|
||||
$(TOP)/c67-tcc$(EXESUF) $(TCCFLAGS-unx) -c $(TOPSRC)/examples/ex3.c && echo "ok"
|
||||
$(TOP)/i386-win32-tcc$(EXESUF) $(TCCFLAGS-win) $(TOPSRC)/win32/examples/hello_win.c && echo "ok"
|
||||
$(TOP)/x86_64-win32-tcc$(EXESUF) $(TCCFLAGS-win) $(TOPSRC)/win32/examples/hello_win.c && echo "ok"
|
||||
$(TOP)/arm-wince-tcc$(EXESUF) $(TCCFLAGS-win) -c $(TOPSRC)/win32/examples/hello_win.c && echo "ok"
|
||||
$(TOP)/$*-tcc$(EXESUF) -v $(TCCFLAGS-$(if $(findstring win,$*),win,unx))\
|
||||
-c $(TOPSRC)/examples/ex3.c
|
||||
|
||||
# targets for development
|
||||
%.bin: %.c tcc
|
||||
@ -306,6 +297,3 @@ clean:
|
||||
@$(MAKE) -C tests2 $@
|
||||
@$(MAKE) -C pp $@
|
||||
|
||||
# silent clean, used before running tests
|
||||
clean-s:
|
||||
@$(MAKE) -s --no-print-directory clean
|
||||
|
@ -264,13 +264,13 @@ int main(int argc, char **argv)
|
||||
}
|
||||
|
||||
#if 1
|
||||
printf("----- libtest : mixed calls -------\n"), fflush(stdout);
|
||||
printf("mixed calls\n "), fflush(stdout);
|
||||
t = getclock_ms();
|
||||
state_test();
|
||||
printf("\n(%u ms)\n", getclock_ms() - t);
|
||||
#endif
|
||||
#if 1
|
||||
printf("----- libtest : threads ------------\n"), fflush(stdout);
|
||||
printf("threads\n "), fflush(stdout);
|
||||
t = getclock_ms();
|
||||
for (n = 0; n < M; ++n)
|
||||
create_thread(thread_test_simple, n);
|
||||
@ -278,7 +278,7 @@ int main(int argc, char **argv)
|
||||
printf("\n(%u ms)\n", getclock_ms() - t);
|
||||
#endif
|
||||
#if 1
|
||||
printf("----- libtest : tcc in threads -----\n"), fflush(stdout);
|
||||
printf("tcc in threads\n "), fflush(stdout);
|
||||
t = getclock_ms();
|
||||
for (n = 0; n < M; ++n)
|
||||
create_thread(thread_test_complex, n);
|
||||
@ -286,7 +286,7 @@ int main(int argc, char **argv)
|
||||
printf("\n(%u ms)\n", getclock_ms() - t);
|
||||
#endif
|
||||
#if 1
|
||||
printf("----- compilation of tcc -----------\n"), fflush(stdout);
|
||||
printf("compiling tcc 10 times\n"), fflush(stdout);
|
||||
t = getclock_ms();
|
||||
time_tcc(10, argv[1]);
|
||||
printf("(%u ms)\n", (getclock_ms() - t) / 10), fflush(stdout);
|
||||
|
@ -2396,7 +2396,11 @@ int fib(int n)
|
||||
return fib(n-1) + fib(n-2);
|
||||
}
|
||||
|
||||
#if __GNUC__ == 3
|
||||
# define aligned_function 0
|
||||
#else
|
||||
void __attribute__((aligned(16))) aligned_function(int i) {}
|
||||
#endif
|
||||
|
||||
void funcptr_test()
|
||||
{
|
||||
|
@ -93,7 +93,8 @@ GEN-ALWAYS =
|
||||
# Filter source directory in warnings/errors (out-of-tree builds)
|
||||
FILTER = 2>&1 | sed -e 's,$(SRC)/,,g'
|
||||
|
||||
all test tests2.all: $(filter-out $(SKIP),$(TESTS)) ;
|
||||
all test tests2.all: $(filter-out $(SKIP),$(TESTS))
|
||||
@$(MAKE) clean --no-print-directory -s
|
||||
|
||||
%.test: %.c %.expect
|
||||
@echo Test: $*...
|
||||
@ -140,5 +141,5 @@ MS-CC = cl
|
||||
$(sort $(GEN-ALWAYS) $(UPDATE)) : force
|
||||
force:
|
||||
|
||||
clean tests2.clean :
|
||||
clean :
|
||||
rm -f fred.txt *.output a.exe *.dll *.so *.def $(GEN-ALWAYS)
|
||||
|
Loading…
Reference in New Issue
Block a user