diff --git a/Makefile b/Makefile index 24a7c094..50527581 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 a8a2b5dd..394df674 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 df201aec..072b77f4 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 21957e72..0933b01f 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 8355aae0..f23cd07d 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 aeaf6be6..e1ccded7 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 08dfa42b..b958a486 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 df0d3e76..c5d48c5a 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 369ed477..51dc38d1 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 772ed265..bd897c48 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