From fbb4841606b555311048229cf26de22ea5cf0682 Mon Sep 17 00:00:00 2001 From: Thomas Preud'homme Date: Thu, 28 Feb 2013 16:55:10 +0100 Subject: Add __clear_cache implementation in libtcc1 Add __clear_cache function for flushing caches to libtcc1. --- Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 4a27364..ce151e1 100644 --- a/Makefile +++ b/Makefile @@ -66,7 +66,7 @@ NATIVE_DEFINES_$(CONFIG_i386) += -DTCC_TARGET_I386 NATIVE_DEFINES_$(CONFIG_x86-64) += -DTCC_TARGET_X86_64 NATIVE_DEFINES_$(CONFIG_WIN32) += -DTCC_TARGET_PE NATIVE_DEFINES_$(CONFIG_uClibc) += -DTCC_UCLIBC -NATIVE_DEFINES_$(CONFIG_arm) += -DTCC_TARGET_ARM -DWITHOUT_LIBTCC +NATIVE_DEFINES_$(CONFIG_arm) += -DTCC_TARGET_ARM NATIVE_DEFINES_$(CONFIG_arm_eabihf) += -DTCC_ARM_EABI -DTCC_ARM_HARDFLOAT NATIVE_DEFINES_$(CONFIG_arm_eabi) += -DTCC_ARM_EABI NATIVE_DEFINES_$(CONFIG_arm_vfp) += -DTCC_ARM_VFP @@ -122,6 +122,7 @@ LIBTCC1=libtcc1.a else ifeq ($(ARCH),arm) NATIVE_FILES=$(ARM_FILES) PROGS_CROSS=$(I386_CROSS) $(X64_CROSS) $(WIN32_CROSS) $(WIN64_CROSS) $(C67_CROSS) +LIBTCC1=libtcc1.a endif ifeq ($(TARGETOS),Darwin) -- cgit v1.3.1 From 0382131c6fc7510f664f300ee74d5a97e93d773d Mon Sep 17 00:00:00 2001 From: Thomas Preud'homme Date: Sat, 4 Jan 2014 09:48:15 +0800 Subject: Provide install-strip target in Makefile --- Makefile | 3 +++ 1 file changed, 3 insertions(+) (limited to 'Makefile') diff --git a/Makefile b/Makefile index ce151e1..24a7c09 100644 --- a/Makefile +++ b/Makefile @@ -230,6 +230,9 @@ else INSTALLBIN=$(INSTALL) endif +install-strip: install + strip $(foreach PROG,$(PROGS),"$(bindir)"/$(PROG)) + ifndef CONFIG_WIN32 install: $(PROGS) $(TCCLIBS) $(TCCDOCS) mkdir -p "$(bindir)" -- cgit v1.3.1 From 2bd0daabbe1fc40e65e4a4631e68f5ca093ea1fb Mon Sep 17 00:00:00 2001 From: grischka Date: Mon, 6 Jan 2014 19:56:26 +0100 Subject: misc. fixes - tccgen: error out for cast to void, as in void foo(void) { return 1; } This avoids an assertion failure in x86_64-gen.c, also. also fix tests2/03_struct.c accordingly - Error: "memory full" - be more specific - Makefiles: remove circular dependencies, lookup tcctest.c from VPATH - tcc.h: cleanup lib, include, crt and libgcc search paths" avoid duplication or trailing slashes with no CONFIG_MULTIARCHDIR (as from 9382d6f1a0e2d0104a82ed805207d9e742c6b068) - tcc.h: remove ";{B}" from PE search path in ce5e12c2f950052d8109b6b7a56d900547705c08 James Lyon wrote: "... I'm not sure this is the right way to fix this problem." And the answer is: No, please. (copying libtcc1.a for tests instead) - win32/build_tcc.bat: do not move away a versioned file --- Makefile | 3 --- lib/Makefile | 3 --- libtcc.c | 4 ++-- tcc.h | 30 +++++++++++++++--------------- tccgen.c | 8 ++++---- tccpp.c | 4 ++-- tests/Makefile | 39 ++++++++++++++++++++------------------- tests/tests2/03_struct.c | 2 +- tests/tests2/Makefile | 3 --- win32/build-tcc.bat | 4 ++-- 10 files changed, 46 insertions(+), 54 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 24a7c09..5052758 100644 --- a/Makefile +++ b/Makefile @@ -362,9 +362,6 @@ tar: tcc-doc.html rm -rf $(TCC-VERSION) git reset -Makefile: $(top_srcdir)/Makefile - cp $< $@ - .PHONY: all clean tar distclean install uninstall FORCE endif # ifeq ($(TOP),.) diff --git a/lib/Makefile b/lib/Makefile index a8a2b5d..394df67 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -111,6 +111,3 @@ $(DIR)/exists : clean : rm -rfv i386-win32 x86_64-win32 i386 x86_64 - -Makefile: $(top_srcdir)/lib/Makefile - cp $< $@ diff --git a/libtcc.c b/libtcc.c index df201ae..072b77f 100644 --- a/libtcc.c +++ b/libtcc.c @@ -214,7 +214,7 @@ PUB_FUNC void *tcc_malloc(unsigned long size) void *ptr; ptr = malloc(size); if (!ptr && size) - tcc_error("memory full"); + tcc_error("memory full (malloc)"); #ifdef MEM_DEBUG mem_cur_size += malloc_usable_size(ptr); if (mem_cur_size > mem_max_size) @@ -239,7 +239,7 @@ PUB_FUNC void *tcc_realloc(void *ptr, unsigned long size) #endif ptr1 = realloc(ptr, size); if (!ptr1 && size) - tcc_error("memory full"); + tcc_error("memory full (realloc)"); #ifdef MEM_DEBUG /* NOTE: count not correct if alloc error, but not critical */ mem_cur_size += malloc_usable_size(ptr1); diff --git a/tcc.h b/tcc.h index 21957e7..0933b01 100644 --- a/tcc.h +++ b/tcc.h @@ -169,13 +169,18 @@ #ifndef CONFIG_LDDIR # define CONFIG_LDDIR "lib" #endif -#ifndef CONFIG_MULTIARCHDIR -#define CONFIG_MULTIARCHDIR + +#ifdef CONFIG_MULTIARCHDIR +# define USE_MUADIR(s) s "/" CONFIG_MULTIARCHDIR +# define ALSO_MUADIR(s) s "/" CONFIG_MULTIARCHDIR ":" s +#else +# define USE_MUADIR(s) s +# define ALSO_MUADIR(s) s #endif /* path to find crt1.o, crti.o and crtn.o */ #ifndef CONFIG_TCC_CRTPREFIX -# define CONFIG_TCC_CRTPREFIX CONFIG_SYSROOT "/usr/" CONFIG_LDDIR "/" CONFIG_MULTIARCHDIR +# define CONFIG_TCC_CRTPREFIX USE_MUADIR(CONFIG_SYSROOT "/usr/" CONFIG_LDDIR) #endif /* Below: {B} is substituted by CONFIG_TCCDIR (rsp. -B option) */ @@ -186,10 +191,8 @@ # define CONFIG_TCC_SYSINCLUDEPATHS "{B}/include;{B}/include/winapi" # else # define CONFIG_TCC_SYSINCLUDEPATHS \ - CONFIG_SYSROOT "/usr/local/include/" CONFIG_MULTIARCHDIR \ - ":" CONFIG_SYSROOT "/usr/local/include" \ - ":" CONFIG_SYSROOT "/usr/include/" CONFIG_MULTIARCHDIR \ - ":" CONFIG_SYSROOT "/usr/include" \ + ALSO_MUADIR(CONFIG_SYSROOT "/usr/local/include") \ + ":" ALSO_MUADIR(CONFIG_SYSROOT "/usr/include") \ ":" "{B}/include" # endif #endif @@ -197,15 +200,12 @@ /* library search paths */ #ifndef CONFIG_TCC_LIBPATHS # ifdef TCC_TARGET_PE -# define CONFIG_TCC_LIBPATHS "{B}/lib;{B}" +# define CONFIG_TCC_LIBPATHS "{B}/lib" # else # define CONFIG_TCC_LIBPATHS \ - CONFIG_SYSROOT "/usr/" CONFIG_LDDIR "/" CONFIG_MULTIARCHDIR \ - ":" CONFIG_SYSROOT "/usr/" CONFIG_LDDIR \ - ":" CONFIG_SYSROOT "/" CONFIG_LDDIR "/" CONFIG_MULTIARCHDIR \ - ":" CONFIG_SYSROOT "/" CONFIG_LDDIR \ - ":" CONFIG_SYSROOT "/usr/local/" CONFIG_LDDIR "/" CONFIG_MULTIARCHDIR \ - ":" CONFIG_SYSROOT "/usr/local/" CONFIG_LDDIR + ALSO_MUADIR(CONFIG_SYSROOT "/usr/" CONFIG_LDDIR) \ + ":" ALSO_MUADIR(CONFIG_SYSROOT "/" CONFIG_LDDIR) \ + ":" ALSO_MUADIR(CONFIG_SYSROOT "/usr/local/" CONFIG_LDDIR) # endif #endif @@ -237,7 +237,7 @@ #endif /* library to use with CONFIG_USE_LIBGCC instead of libtcc1.a */ -#define TCC_LIBGCC CONFIG_SYSROOT "/" CONFIG_LDDIR "/" CONFIG_MULTIARCHDIR "/libgcc_s.so.1" +#define TCC_LIBGCC USE_MUADIR(CONFIG_SYSROOT "/" CONFIG_LDDIR) "/libgcc_s.so.1" /* -------------------------------------------- */ /* include the target specific definitions */ diff --git a/tccgen.c b/tccgen.c index 8355aae..f23cd07 100644 --- a/tccgen.c +++ b/tccgen.c @@ -309,7 +309,7 @@ static void vsetc(CType *type, int r, CValue *vc) int v; if (vtop >= vstack + (VSTACK_SIZE - 1)) - tcc_error("memory full"); + tcc_error("memory full (vstack)"); /* cannot let cpu flags if other instruction are generated. Also avoid leaving VT_JMP anywhere except on the top of the stack because it would complicate the code generator. */ @@ -483,7 +483,7 @@ ST_FUNC void vswap(void) ST_FUNC void vpushv(SValue *v) { if (vtop >= vstack + (VSTACK_SIZE - 1)) - tcc_error("memory full"); + tcc_error("memory full (vstack)"); vtop++; *vtop = *v; } @@ -2348,8 +2348,8 @@ static void gen_assign_cast(CType *dt) st = &vtop->type; /* source type */ dbt = dt->t & VT_BTYPE; sbt = st->t & VT_BTYPE; - if (sbt == VT_VOID) - tcc_error("Cannot assign void value"); + if (sbt == VT_VOID || dbt == VT_VOID) + tcc_error("cannot cast from/to void"); if (dt->t & VT_CONSTANT) tcc_warning("assignment of read-only location"); switch(dbt) { diff --git a/tccpp.c b/tccpp.c index aeaf6be..e1ccded 100644 --- a/tccpp.c +++ b/tccpp.c @@ -197,7 +197,7 @@ static TokenSym *tok_alloc_new(TokenSym **pts, const char *str, int len) int i; if (tok_ident >= SYM_FIRST_ANOM) - tcc_error("memory full"); + tcc_error("memory full (symbols)"); /* expand token table if needed */ i = tok_ident - TOK_IDENT; @@ -1528,7 +1528,7 @@ include_done: c = (define_find(tok) != 0) ^ c; do_if: if (s1->ifdef_stack_ptr >= s1->ifdef_stack + IFDEF_STACK_SIZE) - tcc_error("memory full"); + tcc_error("memory full (ifdef)"); *s1->ifdef_stack_ptr++ = c; goto test_skip; case TOK_ELSE: diff --git a/tests/Makefile b/tests/Makefile index 08dfa42..b958a48 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -27,7 +27,7 @@ ifneq ($(ARCH),i386) TESTS := $(filter-out btest,$(TESTS)) endif ifdef CONFIG_WIN32 - TESTS := $(filter-out test3,$(TESTS)) + TESTS := w32-prep $(filter-out test3,$(TESTS)) endif ifeq ($(TARGETOS),Darwin) TESTS := $(filter-out hello-exe test3 btest,$(TESTS)) @@ -84,6 +84,9 @@ moretests: @echo ------------ $@ ------------ $(MAKE) -C tests2 +w32-prep: + cp ../libtcc1.a ../lib + # test.ref - generate using gcc # copy only tcclib.h so GCC's stddef and stdarg will be used test.ref: tcctest.c @@ -91,41 +94,41 @@ test.ref: tcctest.c ./tcctest.gcc > $@ # auto test -test1: test.ref +test1: tcctest.c test.ref @echo ------------ $@ ------------ - $(TCC) -run $(SRCDIR)/tcctest.c > test.out1 + $(TCC) -run $< > test.out1 @if diff -u test.ref test.out1 ; then echo "Auto Test OK"; fi # iterated test2 (compile tcc then compile tcctest.c !) -test2: test.ref +test2: tcctest.c test.ref @echo ------------ $@ ------------ - $(TCC) $(RUN_TCC) $(RUN_TCC) -run $(SRCDIR)/tcctest.c > test.out2 + $(TCC) $(RUN_TCC) $(RUN_TCC) -run $< > test.out2 @if diff -u test.ref test.out2 ; then echo "Auto Test2 OK"; fi # iterated test3 (compile tcc then compile tcc then compile tcctest.c !) -test3: test.ref +test3: tcctest.c test.ref @echo ------------ $@ ------------ - $(TCC) $(RUN_TCC) $(RUN_TCC) $(RUN_TCC) -run $(SRCDIR)/tcctest.c > test.out3 + $(TCC) $(RUN_TCC) $(RUN_TCC) $(RUN_TCC) -run $< > test.out3 @if diff -u test.ref test.out3 ; then echo "Auto Test3 OK"; fi # binary output test -test4: test.ref +test4: tcctest.c test.ref @echo ------------ $@ ------------ # object + link output - $(TCC) -c -o tcctest3.o $(SRCDIR)/tcctest.c + $(TCC) -c -o tcctest3.o $< $(TCC) -o tcctest3 tcctest3.o ./tcctest3 > test3.out @if diff -u test.ref test3.out ; then echo "Object Auto Test OK"; fi # dynamic output - $(TCC) -o tcctest1 $(SRCDIR)/tcctest.c + $(TCC) -o tcctest1 $< ./tcctest1 > test1.out @if diff -u test.ref test1.out ; then echo "Dynamic Auto Test OK"; fi # dynamic output + bound check - $(TCC) -b -o tcctest4 $(SRCDIR)/tcctest.c + $(TCC) -b -o tcctest4 $< ./tcctest4 > test4.out @if diff -u test.ref test4.out ; then echo "BCheck Auto Test OK"; fi # static output - $(TCC) -static -o tcctest2 $(SRCDIR)/tcctest.c + $(TCC) -static -o tcctest2 $< ./tcctest2 > test2.out @if diff -u test.ref test2.out ; then echo "Static Auto Test OK"; fi @@ -161,9 +164,9 @@ speedtest: ex2 ex3 time ./ex3 35 time $(TCC) -run $(top_srcdir)/examples/ex3.c 35 -weaktest: test.ref - $(TCC) -c tcctest.c -o weaktest.tcc.o $(CPPFLAGS) $(CFLAGS) - $(CC) -c tcctest.c -o weaktest.gcc.o -I. $(CPPFLAGS) -w $(CFLAGS) +weaktest: tcctest.c test.ref + $(TCC) -c $< -o weaktest.tcc.o $(CPPFLAGS) $(CFLAGS) + $(CC) -c $< -o weaktest.gcc.o -I. $(CPPFLAGS) -w $(CFLAGS) objdump -t weaktest.tcc.o | grep ' w ' | sed -e 's/.* \([a-zA-Z0-9_]*\)$$/\1/' | LC_ALL=C sort > weaktest.tcc.o.txt objdump -t weaktest.gcc.o | grep ' w ' | sed -e 's/.* \([a-zA-Z0-9_]*\)$$/\1/' | LC_ALL=C sort > weaktest.gcc.o.txt diff weaktest.gcc.o.txt weaktest.tcc.o.txt && echo "Weak Auto Test OK" @@ -220,7 +223,5 @@ cache: tcc_g clean: $(MAKE) -C tests2 $@ rm -vf *~ *.o *.a *.bin *.i *.ref *.out *.out? *.out?b *.gcc *.exe \ - hello libtcc_test tcctest[1234] ex? tcc_g tcclib.h - -Makefile: $(SRCDIR)/Makefile - cp $< $@ + hello libtcc_test tcctest[1234] ex? tcc_g tcclib.h \ + ../lib/libtcc1.a diff --git a/tests/tests2/03_struct.c b/tests/tests2/03_struct.c index df0d3e7..c5d48c5 100644 --- a/tests/tests2/03_struct.c +++ b/tests/tests2/03_struct.c @@ -6,7 +6,7 @@ struct fred int natasha; }; -void main() +int main() { struct fred bloggs; diff --git a/tests/tests2/Makefile b/tests/tests2/Makefile index 369ed47..51dc38d 100644 --- a/tests/tests2/Makefile +++ b/tests/tests2/Makefile @@ -96,6 +96,3 @@ all test: $(TESTS) clean: rm -vf fred.txt *.output - -Makefile: $(top_srcdir)/tests/tests2/Makefile - cp $< $@ diff --git a/win32/build-tcc.bat b/win32/build-tcc.bat index 772ed26..bd897c4 100644 --- a/win32/build-tcc.bat +++ b/win32/build-tcc.bat @@ -63,5 +63,5 @@ del *.o echo>..\config.texi @set VERSION %VERSION% if not exist doc md doc makeinfo --html --no-split -o doc\tcc-doc.html ../tcc-doc.texi -if exist tcc-win32.txt move tcc-win32.txt doc\ -copy ..\tests\libtcc_test.c examples\ +copy tcc-win32.txt doc +copy ..\tests\libtcc_test.c examples -- cgit v1.3.1 From 99851b0d9e0d79994ed490472f44235598ae1c60 Mon Sep 17 00:00:00 2001 From: Vincent Lefevre Date: Tue, 7 Jan 2014 16:05:31 +0100 Subject: fixed permissions for install on Unix Signed-off-by: Vincent Lefevre --- Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 5052758..9a4ae22 100644 --- a/Makefile +++ b/Makefile @@ -242,9 +242,9 @@ else $(INSTALLBIN) -m755 $(PROGS) "$(bindir)" endif mkdir -p "$(mandir)/man1" - -$(INSTALL) tcc.1 "$(mandir)/man1" + -$(INSTALL) -m644 tcc.1 "$(mandir)/man1" mkdir -p "$(infodir)" - -$(INSTALL) tcc-doc.info "$(infodir)" + -$(INSTALL) -m644 tcc-doc.info "$(infodir)" mkdir -p "$(tccdir)" mkdir -p "$(tccdir)/include" ifneq ($(LIBTCC1),) @@ -252,7 +252,7 @@ ifneq ($(LIBTCC1),) endif $(INSTALL) -m644 $(addprefix $(top_srcdir)/include/,$(TCC_INCLUDES)) $(top_srcdir)/tcclib.h "$(tccdir)/include" mkdir -p "$(libdir)" - $(INSTALL) -m755 $(LIBTCC) "$(libdir)" + $(INSTALL) -m644 $(LIBTCC) "$(libdir)" ifdef DISABLE_STATIC ln -sf "$(ln_libdir)/libtcc.so.1.0" "$(libdir)/libtcc.so.1" ln -sf "$(ln_libdir)/libtcc.so.1.0" "$(libdir)/libtcc.so" -- cgit v1.3.1 From 70a088af874076d8db5d7c2067afd8f2bcde0592 Mon Sep 17 00:00:00 2001 From: Thomas Preud'homme Date: Tue, 7 Jan 2014 16:04:12 +0800 Subject: Explicit that EABI only supports VFP for now --- Makefile | 2 +- arm-gen.c | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 9a4ae22..9225d82 100644 --- a/Makefile +++ b/Makefile @@ -169,7 +169,7 @@ $(C67_CROSS): DEFINES = -DTCC_TARGET_C67 $(ARM_FPA_CROSS): DEFINES = -DTCC_TARGET_ARM $(ARM_FPA_LD_CROSS)$(EXESUF): DEFINES = -DTCC_TARGET_ARM -DLDOUBLE_SIZE=12 $(ARM_VFP_CROSS): DEFINES = -DTCC_TARGET_ARM -DTCC_ARM_VFP -$(ARM_EABI_CROSS): DEFINES = -DTCC_TARGET_ARM -DTCC_ARM_EABI +$(ARM_EABI_CROSS): DEFINES = -DTCC_TARGET_ARM -DTCC_ARM_EABI -DTCC_ARM_VFP $(I386_CROSS): $(I386_FILES) $(X64_CROSS): $(X86_64_FILES) diff --git a/arm-gen.c b/arm-gen.c index 9e6c638..05bccb0 100644 --- a/arm-gen.c +++ b/arm-gen.c @@ -23,10 +23,8 @@ #ifdef TARGET_DEFS_ONLY -#ifdef TCC_ARM_EABI -#ifndef TCC_ARM_VFP /* Avoid useless warning */ -#define TCC_ARM_VFP -#endif +#if defined(TCC_ARM_EABI) && !defined(TCC_ARM_VFP) +#error "Currently TinyCC only supports float computation with VFP instructions" #endif /* number of available registers */ -- cgit v1.3.1 From bf2854d2a25718fd52b2162bba46dc01525f0c75 Mon Sep 17 00:00:00 2001 From: Thomas Preud'homme Date: Sat, 4 Jan 2014 21:57:52 +0800 Subject: Use GNU triplet prefix for cross tcc compilers Compatibility symlinks are put in place in case some script were relying on former names except for CMake since it was added after last release. --- CMakeLists.txt | 25 ++++++++++--------------- Makefile | 34 ++++++++++++++++++++++++---------- 2 files changed, 34 insertions(+), 25 deletions(-) (limited to 'Makefile') diff --git a/CMakeLists.txt b/CMakeLists.txt index fb0d968..df3c831 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -195,58 +195,53 @@ macro(make_tcc native_name cross_name cross_enabled definitions tcc_sources libt endif() endmacro() -make_tcc("Win32" i386-win32 TCC_BUILD_WIN32 +make_tcc("Win32" i386-w64-mingw32 TCC_BUILD_WIN32 "TCC_TARGET_I386;TCC_TARGET_PE" "${I386_SOURCES};tccpe.c" tiny_libmaker_32 "${LIBTCC1_I386_SOURCES};${LIBTCC1_WIN_SOURCES}" "win32/include;win32/include/winapi" ) -make_tcc("Win64" x86_64-win32 TCC_BUILD_WIN64 +make_tcc("Win64" x86_64-w64-mingw32 TCC_BUILD_WIN64 "TCC_TARGET_X86_64;TCC_TARGET_PE" "${X86_64_SOURCES};tccpe.c" tiny_libmaker_64 "lib/alloca86_64.S;${LIBTCC1_WIN_SOURCES}" "win32/include;win32/include/winapi" ) -make_tcc("WinCE" arm-win32 TCC_BUILD_WINCE +make_tcc("WinCE" arm-wince-mingw32ce TCC_BUILD_WINCE "TCC_TARGET_ARM;TCC_ARM_VERSION=${TCC_ARM_VERSION};TCC_TARGET_PE" "${ARM_SOURCES};tccpe.c" "" "" "" ) -make_tcc("i386" i386 TCC_BUILD_I386 +make_tcc("i386" i386-linux-gnu TCC_BUILD_I386 TCC_TARGET_I386 "${I386_SOURCES}" tiny_libmaker_32 "${LIBTCC1_I386_SOURCES}" "" ) -make_tcc("x86_64" x86_64 TCC_BUILD_X64 +make_tcc("x86_64" x86_64-linux-gnu TCC_BUILD_X64 TCC_TARGET_X86_64 "${X86_64_SOURCES}" tiny_libmaker_64 "lib/alloca86_64.S" "" ) set(ARM_DEFINITIONS TCC_TARGET_ARM TCC_ARM_VERSION=${TCC_ARM_VERSION}) -make_tcc("ARM" arm TCC_BUILD_ARM - "${ARM_DEFINITIONS};WITHOUT_LIBTCC" - "${ARM_SOURCES}" - "" "" "" -) -make_tcc("" arm-eabihf TCC_BUILD_ARM_EABIHF +make_tcc("" arm-linux-gnueabihf TCC_BUILD_ARM_EABIHF "${ARM_DEFINITIONS};TCC_ARM_EABI;TCC_ARM_HARDFLOAT" "${ARM_SOURCES}" "" "" "" ) -make_tcc("" arm-eabi TCC_BUILD_ARM_EABI +make_tcc("" arm-linux-gnueabi TCC_BUILD_ARM_EABI "${ARM_DEFINITIONS};TCC_ARM_EABI" "${ARM_SOURCES}" "" "" "" ) -make_tcc("" arm-fpa TCC_BUILD_ARM_FPA +make_tcc("" arm-linux-fpa TCC_BUILD_ARM_FPA "${ARM_DEFINITIONS}" "${ARM_SOURCES}" "" "" "" ) -make_tcc("" arm-fpa-ld TCC_BUILD_ARM_FPA_LD +make_tcc("" arm-linux-fpa-ld TCC_BUILD_ARM_FPA_LD "${ARM_DEFINITIONS};LDOUBLE_SIZE=12" "${ARM_SOURCES}" "" "" "" ) -make_tcc("" arm-vfp TCC_BUILD_ARM_VFP +make_tcc("" arm-linux-gnu TCC_BUILD_ARM_VFP "${ARM_DEFINITIONS};TCC_ARM_VFP" "${ARM_SOURCES}" "" "" "" diff --git a/Makefile b/Makefile index 9225d82..df1d198 100644 --- a/Makefile +++ b/Makefile @@ -75,18 +75,30 @@ NATIVE_DEFINES += $(NATIVE_DEFINES_yes) ifeq ($(TOP),.) PROGS=tcc$(EXESUF) -I386_CROSS = i386-tcc$(EXESUF) -WIN32_CROSS = i386-win32-tcc$(EXESUF) -WIN64_CROSS = x86_64-win32-tcc$(EXESUF) -WINCE_CROSS = arm-win32-tcc$(EXESUF) -X64_CROSS = x86_64-tcc$(EXESUF) -ARM_FPA_CROSS = arm-fpa-tcc$(EXESUF) -ARM_FPA_LD_CROSS = arm-fpa-ld-tcc$(EXESUF) -ARM_VFP_CROSS = arm-vfp-tcc$(EXESUF) -ARM_EABI_CROSS = arm-eabi-tcc$(EXESUF) +I386_CROSS = i386-linux-gnu-tcc$(EXESUF) +WIN32_CROSS = i386-w64-mingw32-tcc$(EXESUF) +WIN64_CROSS = x86_64-w64-mingw32-tcc$(EXESUF) +WINCE_CROSS = arm-wince-mingw32ce-tcc$(EXESUF) +X64_CROSS = x86_64-linux-gnu-tcc$(EXESUF) +ARM_FPA_CROSS = arm-linux-fpa-tcc$(EXESUF) +ARM_FPA_LD_CROSS = arm-linux-fpa-ld-tcc$(EXESUF) +ARM_VFP_CROSS = arm-linux-gnu-tcc$(EXESUF) +ARM_EABI_CROSS = arm-linux-gnueabi-tcc$(EXESUF) +ARM_EABIHF_CROSS = arm-linux-gnueabihf-tcc$(EXESUF) ARM_CROSS = $(ARM_FPA_CROSS) $(ARM_FPA_LD_CROSS) $(ARM_VFP_CROSS) $(ARM_EABI_CROSS) C67_CROSS = c67-tcc$(EXESUF) +# Legacy symlinks for cross compilers +$(I386_CROSS)_LINK = i386-tcc$(EXESUF) +$(WIN32_CROSS)_LINK = i386-win32-tcc$(EXESUF) +$(WIN64_CROSS)_LINK = x86_64-win32-tcc$(EXESUF) +$(WINCE_CROSS)_LINK = arm-win32-tcc$(EXESUF) +$(X64_CROSS)_LINK = x86_64-tcc$(EXESUF) +$(ARM_FPA_CROSS)_LINK = arm-fpa-tcc$(EXESUF) +$(ARM_FPA_LD_CROSS)_LINK = arm-fpa-ld-tcc$(EXESUF) +$(ARM_VFP_CROSS)_LINK = arm-vfp-tcc$(EXESUF) +$(ARM_EABI_CROSS)_LINK = arm-eabi-tcc$(EXESUF) + CORE_FILES = tcc.c libtcc.c tccpp.c tccgen.c tccelf.c tccasm.c tccrun.c CORE_FILES += tcc.h config.h libtcc.h tcctok.h I386_FILES = $(CORE_FILES) i386-gen.c i386-asm.c i386-asm.h i386-tok.h @@ -124,6 +136,7 @@ NATIVE_FILES=$(ARM_FILES) PROGS_CROSS=$(I386_CROSS) $(X64_CROSS) $(WIN32_CROSS) $(WIN64_CROSS) $(C67_CROSS) LIBTCC1=libtcc1.a endif +PROGS_CROSS_LINK=$(foreach PROG_CROSS,$(PROGS_CROSS),$($(PROG_CROSS)_LINK)) ifeq ($(TARGETOS),Darwin) PROGS+=tiny_libmaker$(EXESUF) @@ -150,6 +163,7 @@ tcc$(EXESUF): tcc.o $(LIBTCC) # Cross Tiny C Compilers %-tcc$(EXESUF): tcc.c $(CC) -o $@ $< -DONE_SOURCE $(DEFINES) $(CPPFLAGS) $(CFLAGS) $(LIBS) $(LDFLAGS) + $(if $($@_LINK),ln -sf $@ $($@_LINK)) # profiling version tcc_p$(EXESUF): $(NATIVE_FILES) @@ -237,7 +251,7 @@ ifndef CONFIG_WIN32 install: $(PROGS) $(TCCLIBS) $(TCCDOCS) mkdir -p "$(bindir)" ifeq ($(CC),tcc) - $(INSTALL) -m755 $(PROGS) "$(bindir)" + $(INSTALL) -m755 $(PROGS) $(PROGS_CROSS_LINK) "$(bindir)" else $(INSTALLBIN) -m755 $(PROGS) "$(bindir)" endif -- cgit v1.3.1 From 767410b8750b45d63805b45ca1a2cf34d7cb4923 Mon Sep 17 00:00:00 2001 From: Thomas Preud'homme Date: Thu, 9 Jan 2014 17:15:08 +0800 Subject: Various Makefile fixes for cross-compilation - Build libtcc1 for cross-compiler on arm (arm to X cross compilers) - Install libtcc1 and includes for arm to i386 cross compiler - Add basic check of cross-compilers (compile ex1.c) --- Makefile | 9 +++++---- tests/Makefile | 15 ++++++++++++++- 2 files changed, 19 insertions(+), 5 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index df1d198..78e67f7 100644 --- a/Makefile +++ b/Makefile @@ -135,6 +135,7 @@ else ifeq ($(ARCH),arm) NATIVE_FILES=$(ARM_FILES) PROGS_CROSS=$(I386_CROSS) $(X64_CROSS) $(WIN32_CROSS) $(WIN64_CROSS) $(C67_CROSS) LIBTCC1=libtcc1.a +LIBTCC1_CROSS=lib/i386-win32/libtcc1.a lib/x86_64-win32/libtcc1.a lib/i386/libtcc1.a endif PROGS_CROSS_LINK=$(foreach PROG_CROSS,$(PROGS_CROSS),$($(PROG_CROSS)_LINK)) @@ -278,7 +279,7 @@ endif ifdef CONFIG_CROSS mkdir -p "$(tccdir)/win32/lib/32" mkdir -p "$(tccdir)/win32/lib/64" -ifeq ($(ARCH),x86-64) +ifneq ($(ARCH),i386) mkdir -p "$(tccdir)/i386" $(INSTALL) -m644 lib/i386/libtcc1.a "$(tccdir)/i386" cp -r "$(tccdir)/include" "$(tccdir)/i386" @@ -287,7 +288,7 @@ endif $(INSTALL) -m644 lib/i386-win32/libtcc1.a "$(tccdir)/win32/lib/32" $(INSTALL) -m644 lib/x86_64-win32/libtcc1.a "$(tccdir)/win32/lib/64" cp -r $(top_srcdir)/win32/include/. "$(tccdir)/win32/include" - cp -r $(top_srcdir)/include/. "$(tccdir)/win32/include" + cp -r "$(tccdir)/include" "$(tccdir)/win32" endif uninstall: @@ -300,7 +301,7 @@ uninstall: rm -fv "$(libdir)/libtcc.so*" rm -rf "$(tccdir)/win32" -rmdir $(tccdir)/include -ifeq ($(ARCH),x86-64) +ifneq ($(ARCH),i386) rm -rf "$(tccdir)/i386" endif else @@ -346,7 +347,7 @@ tcc-doc.info: tcc-doc.texi export LIBTCC1 %est: - $(MAKE) -C tests $@ + $(MAKE) -C tests $@ "PROGS_CROSS=$(PROGS_CROSS)" clean: rm -vf $(PROGS) tcc_p$(EXESUF) tcc.pod *~ *.o *.a *.so* *.out *.exe libtcc_test$(EXESUF) diff --git a/tests/Makefile b/tests/Makefile index b958a48..62e4f88 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -16,6 +16,9 @@ TESTS = \ abitest \ vla_test-run \ moretests +ifdef CONFIG_CROSS +TESTS += hello-cross +endif # test4 -- problem with -static # asmtest -- minor differences with gcc @@ -50,8 +53,9 @@ endif # run local version of tcc with local libraries and includes TCCFLAGS = -B$(TOP) -I$(TOP) -I$(top_srcdir) -I$(top_srcdir)/include ifdef CONFIG_WIN32 - TCCFLAGS = -B$(top_srcdir)/win32 -I$(top_srcdir) -I$(top_srcdir)/include -I$(TOP) -L$(TOP) + TCCFLAGS = -B$(top_srcdir)/win32 --I$(top_srcdir) -I$(top_srcdir)/include -I$(TOP) -L$(TOP) endif +XTCCFLAGS = -B$(TOP) -B$(top_srcdir)/win32 -I$(TOP) -I$(top_srcdir) -I$(top_srcdir)/include TCC = $(TOP)/tcc $(TCCFLAGS) RUN_TCC = $(NATIVE_DEFINES) -DONE_SOURCE -run $(top_srcdir)/tcc.c $(TCCFLAGS) @@ -69,6 +73,15 @@ hello-exe: ../examples/ex1.c @echo ------------ $@ ------------ $(TCC) $< -o hello$(EXESUF) || ($(TOP)/tcc -vv; exit 1) && ./hello$(EXESUF) +hello-cross: ../examples/ex1.c + @echo ------------ $@ ------------ + for XTCC in $(PROGS_CROSS) ; \ + do echo -n "Test of $$XTCC... "; \ + out=$$($(TOP)/$$XTCC $(XTCCFLAGS) -c $< 2>&1); \ + test $$? -ne 0 && { echo "Failed\n$$out\n" ; $(TOP)/$$XTCC -vv; exit 1; } ; \ + echo "Success"; \ + done + hello-run: ../examples/ex1.c @echo ------------ $@ ------------ $(TCC) -run $< -- cgit v1.3.1 From 32a4962593d6a2006cdd725480124717e7f5377d Mon Sep 17 00:00:00 2001 From: grischka Date: Tue, 21 Jan 2014 13:25:14 +0100 Subject: tcctest: add back testXb (self compile with -b) - Thanks to Kirill "tcc -b itself" should work now (was removed in d5f4df09ff4a84dda5b03525285f03be7723376b) Also: - tests/Makefile: - fix spurious --I from 767410b8750b45d63805b45ca1a2cf34d7cb4923 - lookup boundtest.c via VPATH (for out-of-tree build) - test[123]b?: fail on diff error - Windows: test3 now works (from e31579b0769e1f9c0947d12e83316d1149307b1a) - abitest: a libtcc.a made by gcc is not usable for tcc on WIndows - using source instead (libtcc.c) - tccpe: - avoid gcc warning (x86_64) --- Makefile | 4 ++-- tccpe.c | 2 +- tests/Makefile | 40 ++++++++++++++++++++++------------------ 3 files changed, 25 insertions(+), 21 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 78e67f7..39f10ba 100644 --- a/Makefile +++ b/Makefile @@ -346,8 +346,8 @@ tcc-doc.info: tcc-doc.texi # in tests subdir export LIBTCC1 -%est: - $(MAKE) -C tests $@ "PROGS_CROSS=$(PROGS_CROSS)" +test test% %test : + $(MAKE) -C tests $@ 'PROGS_CROSS=$(PROGS_CROSS)' clean: rm -vf $(PROGS) tcc_p$(EXESUF) tcc.pod *~ *.o *.a *.so* *.out *.exe libtcc_test$(EXESUF) diff --git a/tccpe.c b/tccpe.c index ed7cb82..f4a58f7 100644 --- a/tccpe.c +++ b/tccpe.c @@ -1803,7 +1803,7 @@ static void pe_add_runtime(TCCState *s1, struct pe_info *pe) s1->runtime_main = start_symbol; #endif } else { - pe->start_addr = (DWORD)tcc_get_symbol_err(s1, start_symbol); + pe->start_addr = (DWORD)(uintptr_t)tcc_get_symbol_err(s1, start_symbol); } pe->type = pe_type; diff --git a/tests/Makefile b/tests/Makefile index 62e4f88..4d99a46 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -5,7 +5,7 @@ TOP = .. include $(TOP)/Makefile SRCDIR = $(top_srcdir)/tests -VPATH = $(SRCDIR) +VPATH = $(SRCDIR) $(top_srcdir) # what tests to run TESTS = \ @@ -13,27 +13,30 @@ TESTS = \ hello-run \ libtest \ test3 \ + $(BTESTS) \ abitest \ vla_test-run \ moretests + +BTESTS = test1b test3b btest + ifdef CONFIG_CROSS -TESTS += hello-cross + TESTS += hello-cross endif # test4 -- problem with -static # asmtest -- minor differences with gcc # btest -- works on i386 (including win32) -# test3 -- win32 does not know how to printf long doubles # bounds-checking is supported only on i386 ifneq ($(ARCH),i386) - TESTS := $(filter-out btest,$(TESTS)) + TESTS := $(filter-out $(BTESTS),$(TESTS)) endif ifdef CONFIG_WIN32 - TESTS := w32-prep $(filter-out test3,$(TESTS)) + TESTS := w32-prep $(filter-out $(BTESTS),$(TESTS)) endif ifeq ($(TARGETOS),Darwin) - TESTS := $(filter-out hello-exe test3 btest,$(TESTS)) + TESTS := $(filter-out hello-exe test3 $(BTESTS),$(TESTS)) endif ifeq ($(ARCH),i386) else ifneq ($(ARCH),x86-64) @@ -53,7 +56,7 @@ endif # run local version of tcc with local libraries and includes TCCFLAGS = -B$(TOP) -I$(TOP) -I$(top_srcdir) -I$(top_srcdir)/include ifdef CONFIG_WIN32 - TCCFLAGS = -B$(top_srcdir)/win32 --I$(top_srcdir) -I$(top_srcdir)/include -I$(TOP) -L$(TOP) + TCCFLAGS = -B$(top_srcdir)/win32 -I$(top_srcdir) -I$(top_srcdir)/include -I$(TOP) -L$(TOP) endif XTCCFLAGS = -B$(TOP) -B$(top_srcdir)/win32 -I$(TOP) -I$(top_srcdir) -I$(top_srcdir)/include @@ -101,28 +104,29 @@ w32-prep: cp ../libtcc1.a ../lib # test.ref - generate using gcc -# copy only tcclib.h so GCC's stddef and stdarg will be used test.ref: tcctest.c gcc -o tcctest.gcc $< -I$(top_srcdir) $(CPPFLAGS) -w $(CFLAGS) $(NATIVE_DEFINES) -std=gnu99 -O0 -fno-omit-frame-pointer $(LDFLAGS) ./tcctest.gcc > $@ # auto test -test1: tcctest.c test.ref +test1 test1b: tcctest.c test.ref @echo ------------ $@ ------------ $(TCC) -run $< > test.out1 - @if diff -u test.ref test.out1 ; then echo "Auto Test OK"; fi + @diff -u test.ref test.out1 && echo "Auto Test OK" # iterated test2 (compile tcc then compile tcctest.c !) -test2: tcctest.c test.ref +test2 test2b: tcctest.c test.ref @echo ------------ $@ ------------ $(TCC) $(RUN_TCC) $(RUN_TCC) -run $< > test.out2 - @if diff -u test.ref test.out2 ; then echo "Auto Test2 OK"; fi + @diff -u test.ref test.out2 && echo "Auto Test2 OK" # iterated test3 (compile tcc then compile tcc then compile tcctest.c !) -test3: tcctest.c test.ref +test3 test3b: tcctest.c test.ref @echo ------------ $@ ------------ $(TCC) $(RUN_TCC) $(RUN_TCC) $(RUN_TCC) -run $< > test.out3 - @if diff -u test.ref test.out3 ; then echo "Auto Test3 OK"; fi + @diff -u test.ref test.out3 && echo "Auto Test3 OK" + +test%b : TCCFLAGS += -b # binary output test test4: tcctest.c test.ref @@ -153,7 +157,7 @@ btest: boundtest.c @echo ------------ $@ ------------ @for i in $(BOUNDS_OK); do \ echo ; echo --- boundtest $$i ---; \ - if $(TCC) -b -run boundtest.c $$i ; then \ + if $(TCC) -b -run $< $$i ; then \ echo succeded as expected; \ else\ echo Failed positive test $$i ; exit 1 ; \ @@ -161,7 +165,7 @@ btest: boundtest.c done ;\ for i in $(BOUNDS_FAIL); do \ echo ; echo --- boundtest $$i ---; \ - if $(TCC) -b -run boundtest.c $$i ; then \ + if $(TCC) -b -run $< $$i ; then \ echo Failed negative test $$i ; exit 1 ;\ else\ echo failed as expected; \ @@ -203,8 +207,8 @@ asmtest: asmtest.ref abitest-cc$(EXESUF): abitest.c $(top_builddir)/$(LIBTCC) $(CC) -o $@ $^ $(CPPFLAGS) $(CFLAGS) $(NATIVE_DEFINES) $(LIBS) $(LINK_LIBTCC) $(LDFLAGS) -I$(top_srcdir) -abitest-tcc$(EXESUF): abitest.c $(top_builddir)/$(LIBTCC) - $(TCC) -o $@ $^ $(CPPFLAGS) $(CFLAGS) $(NATIVE_DEFINES) $(LIBS) $(LINK_LIBTCC) $(LDFLAGS) -I$(top_srcdir) +abitest-tcc$(EXESUF): abitest.c libtcc.c + $(TCC) -o $@ $^ $(CPPFLAGS) $(CFLAGS) $(NATIVE_DEFINES) -DONE_SOURCE $(LIBS) $(LDFLAGS) -I$(top_srcdir) abitest: abitest-cc$(EXESUF) abitest-tcc$(EXESUF) @echo ------------ $@ ------------ -- cgit v1.3.1 From fad8e13ccd567512e36a4441688e62c0aa63407e Mon Sep 17 00:00:00 2001 From: Iavael Date: Thu, 23 Jan 2014 21:19:56 +0400 Subject: Ordinary and implicit rules cannot be mixed in the same string in Makefile --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 39f10ba..d116f07 100644 --- a/Makefile +++ b/Makefile @@ -346,7 +346,7 @@ tcc-doc.info: tcc-doc.texi # in tests subdir export LIBTCC1 -test test% %test : +%est: $(MAKE) -C tests $@ 'PROGS_CROSS=$(PROGS_CROSS)' clean: -- cgit v1.3.1 From 078ba241d9c24b15f734b4959f877519d7098140 Mon Sep 17 00:00:00 2001 From: Thomas Preud'homme Date: Tue, 25 Mar 2014 21:18:57 +0800 Subject: Always link libtcc1.a in (useful for va_* on x86) On x86 tcc call to function in libtcc1.a to implement va_* functions. --- Makefile | 4 ---- tccelf.c | 5 +++-- 2 files changed, 3 insertions(+), 6 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index d116f07..4f18567 100644 --- a/Makefile +++ b/Makefile @@ -143,10 +143,6 @@ ifeq ($(TARGETOS),Darwin) PROGS+=tiny_libmaker$(EXESUF) endif -ifdef CONFIG_USE_LIBGCC -LIBTCC1= -endif - TCCLIBS = $(LIBTCC1) $(LIBTCC) $(LIBTCC_EXTRA) TCCDOCS = tcc.1 tcc-doc.html tcc-doc.info diff --git a/tccelf.c b/tccelf.c index ee00b03..5072aca 100644 --- a/tccelf.c +++ b/tccelf.c @@ -1377,9 +1377,10 @@ ST_FUNC void tcc_add_runtime(TCCState *s1) if (!s1->nostdlib) { tcc_add_library(s1, "c"); #ifdef CONFIG_USE_LIBGCC - if (!s1->static_link) + if (!s1->static_link) { tcc_add_file(s1, TCC_LIBGCC); - else + tcc_add_support(s1, "libtcc1.a"); + } else tcc_add_support(s1, "libtcc1.a"); #else tcc_add_support(s1, "libtcc1.a"); -- cgit v1.3.1