- 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
Unified · Split
| @@ -362,9 +362,6 @@ tar: tcc-doc.html · 361 unmodified lines | |||
| 362 | rm -rf $(TCC-VERSION) | 362 | rm -rf $(TCC-VERSION) |
| 363 | git reset | 363 | git reset |
| 364 | 364 | ||
| 365 | Makefile: $(top_srcdir)/Makefile | ||
| 366 | cp $< $@ | ||
| 367 | |||
| 368 | .PHONY: all clean tar distclean install uninstall FORCE | 365 | .PHONY: all clean tar distclean install uninstall FORCE |
| 369 | 366 | ||
| 370 | endif # ifeq ($(TOP),.) | 367 | endif # ifeq ($(TOP),.) |
| @@ -111,6 +111,3 @@ $(DIR)/exists : · 110 unmodified lines | |||
| 111 | 111 | ||
| 112 | clean : | 112 | clean : |
| 113 | rm -rfv i386-win32 x86_64-win32 i386 x86_64 | 113 | rm -rfv i386-win32 x86_64-win32 i386 x86_64 |
| 114 | |||
| 115 | Makefile: $(top_srcdir)/lib/Makefile | ||
| 116 | cp $< $@ | ||
| @@ -214,7 +214,7 @@ PUB_FUNC void *tcc_malloc(unsigned long size) · 213 unmodified lines | |||
| 214 | void *ptr; | 214 | void *ptr; |
| 215 | ptr = malloc(size); | 215 | ptr = malloc(size); |
| 216 | if (!ptr && size) | 216 | if (!ptr && size) |
| 217 | tcc_error("memory full"); | 217 | tcc_error("memory full (malloc)"); |
| 218 | #ifdef MEM_DEBUG | 218 | #ifdef MEM_DEBUG |
| 219 | mem_cur_size += malloc_usable_size(ptr); | 219 | mem_cur_size += malloc_usable_size(ptr); |
| 220 | if (mem_cur_size > mem_max_size) | 220 | if (mem_cur_size > mem_max_size) |
| @@ -239,7 +239,7 @@ PUB_FUNC void *tcc_realloc(void *ptr, unsigned long size) · 18 unmodified lines | |||
| 239 | #endif | 239 | #endif |
| 240 | ptr1 = realloc(ptr, size); | 240 | ptr1 = realloc(ptr, size); |
| 241 | if (!ptr1 && size) | 241 | if (!ptr1 && size) |
| 242 | tcc_error("memory full"); | 242 | tcc_error("memory full (realloc)"); |
| 243 | #ifdef MEM_DEBUG | 243 | #ifdef MEM_DEBUG |
| 244 | /* NOTE: count not correct if alloc error, but not critical */ | 244 | /* NOTE: count not correct if alloc error, but not critical */ |
| 245 | mem_cur_size += malloc_usable_size(ptr1); | 245 | mem_cur_size += malloc_usable_size(ptr1); |
| @@ -169,13 +169,18 @@ · 168 unmodified lines | |||
| 169 | #ifndef CONFIG_LDDIR | 169 | #ifndef CONFIG_LDDIR |
| 170 | # define CONFIG_LDDIR "lib" | 170 | # define CONFIG_LDDIR "lib" |
| 171 | #endif | 171 | #endif |
| 172 | #ifndef CONFIG_MULTIARCHDIR | 172 | |
| 173 | #define CONFIG_MULTIARCHDIR | 173 | #ifdef CONFIG_MULTIARCHDIR |
| 174 | # define USE_MUADIR(s) s "/" CONFIG_MULTIARCHDIR | ||
| 175 | # define ALSO_MUADIR(s) s "/" CONFIG_MULTIARCHDIR ":" s | ||
| 176 | #else | ||
| 177 | # define USE_MUADIR(s) s | ||
| 178 | # define ALSO_MUADIR(s) s | ||
| 174 | #endif | 179 | #endif |
| 175 | 180 | ||
| 176 | /* path to find crt1.o, crti.o and crtn.o */ | 181 | /* path to find crt1.o, crti.o and crtn.o */ |
| 177 | #ifndef CONFIG_TCC_CRTPREFIX | 182 | #ifndef CONFIG_TCC_CRTPREFIX |
| 178 | # define CONFIG_TCC_CRTPREFIX CONFIG_SYSROOT "/usr/" CONFIG_LDDIR "/" CONFIG_MULTIARCHDIR | 183 | # define CONFIG_TCC_CRTPREFIX USE_MUADIR(CONFIG_SYSROOT "/usr/" CONFIG_LDDIR) |
| 179 | #endif | 184 | #endif |
| 180 | 185 | ||
| 181 | /* Below: {B} is substituted by CONFIG_TCCDIR (rsp. -B option) */ | 186 | /* Below: {B} is substituted by CONFIG_TCCDIR (rsp. -B option) */ |
| @@ -186,10 +191,8 @@ · 4 unmodified lines | |||
| 186 | # define CONFIG_TCC_SYSINCLUDEPATHS "{B}/include;{B}/include/winapi" | 191 | # define CONFIG_TCC_SYSINCLUDEPATHS "{B}/include;{B}/include/winapi" |
| 187 | # else | 192 | # else |
| 188 | # define CONFIG_TCC_SYSINCLUDEPATHS \ | 193 | # define CONFIG_TCC_SYSINCLUDEPATHS \ |
| 189 | CONFIG_SYSROOT "/usr/local/include/" CONFIG_MULTIARCHDIR \ | 194 | ALSO_MUADIR(CONFIG_SYSROOT "/usr/local/include") \ |
| 190 | ":" CONFIG_SYSROOT "/usr/local/include" \ | 195 | ":" ALSO_MUADIR(CONFIG_SYSROOT "/usr/include") \ |
| 191 | ":" CONFIG_SYSROOT "/usr/include/" CONFIG_MULTIARCHDIR \ | ||
| 192 | ":" CONFIG_SYSROOT "/usr/include" \ | ||
| 193 | ":" "{B}/include" | 196 | ":" "{B}/include" |
| 194 | # endif | 197 | # endif |
| 195 | #endif | 198 | #endif |
| @@ -197,15 +200,12 @@ · 1 unmodified line | |||
| 197 | /* library search paths */ | 200 | /* library search paths */ |
| 198 | #ifndef CONFIG_TCC_LIBPATHS | 201 | #ifndef CONFIG_TCC_LIBPATHS |
| 199 | # ifdef TCC_TARGET_PE | 202 | # ifdef TCC_TARGET_PE |
| 200 | # define CONFIG_TCC_LIBPATHS "{B}/lib;{B}" | 203 | # define CONFIG_TCC_LIBPATHS "{B}/lib" |
| 201 | # else | 204 | # else |
| 202 | # define CONFIG_TCC_LIBPATHS \ | 205 | # define CONFIG_TCC_LIBPATHS \ |
| 203 | CONFIG_SYSROOT "/usr/" CONFIG_LDDIR "/" CONFIG_MULTIARCHDIR \ | 206 | ALSO_MUADIR(CONFIG_SYSROOT "/usr/" CONFIG_LDDIR) \ |
| 204 | ":" CONFIG_SYSROOT "/usr/" CONFIG_LDDIR \ | 207 | ":" ALSO_MUADIR(CONFIG_SYSROOT "/" CONFIG_LDDIR) \ |
| 205 | ":" CONFIG_SYSROOT "/" CONFIG_LDDIR "/" CONFIG_MULTIARCHDIR \ | 208 | ":" ALSO_MUADIR(CONFIG_SYSROOT "/usr/local/" CONFIG_LDDIR) |
| 206 | ":" CONFIG_SYSROOT "/" CONFIG_LDDIR \ | ||
| 207 | ":" CONFIG_SYSROOT "/usr/local/" CONFIG_LDDIR "/" CONFIG_MULTIARCHDIR \ | ||
| 208 | ":" CONFIG_SYSROOT "/usr/local/" CONFIG_LDDIR | ||
| 209 | # endif | 209 | # endif |
| 210 | #endif | 210 | #endif |
| 211 | 211 | ||
| @@ -237,7 +237,7 @@ · 25 unmodified lines | |||
| 237 | #endif | 237 | #endif |
| 238 | 238 | ||
| 239 | /* library to use with CONFIG_USE_LIBGCC instead of libtcc1.a */ | 239 | /* library to use with CONFIG_USE_LIBGCC instead of libtcc1.a */ |
| 240 | #define TCC_LIBGCC CONFIG_SYSROOT "/" CONFIG_LDDIR "/" CONFIG_MULTIARCHDIR "/libgcc_s.so.1" | 240 | #define TCC_LIBGCC USE_MUADIR(CONFIG_SYSROOT "/" CONFIG_LDDIR) "/libgcc_s.so.1" |
| 241 | 241 | ||
| 242 | /* -------------------------------------------- */ | 242 | /* -------------------------------------------- */ |
| 243 | /* include the target specific definitions */ | 243 | /* include the target specific definitions */ |
| @@ -309,7 +309,7 @@ static void vsetc(CType *type, int r, CValue *vc) · 308 unmodified lines | |||
| 309 | int v; | 309 | int v; |
| 310 | 310 | ||
| 311 | if (vtop >= vstack + (VSTACK_SIZE - 1)) | 311 | if (vtop >= vstack + (VSTACK_SIZE - 1)) |
| 312 | tcc_error("memory full"); | 312 | tcc_error("memory full (vstack)"); |
| 313 | /* cannot let cpu flags if other instruction are generated. Also | 313 | /* cannot let cpu flags if other instruction are generated. Also |
| 314 | avoid leaving VT_JMP anywhere except on the top of the stack | 314 | avoid leaving VT_JMP anywhere except on the top of the stack |
| 315 | because it would complicate the code generator. */ | 315 | because it would complicate the code generator. */ |
| @@ -483,7 +483,7 @@ ST_FUNC void vswap(void) · 167 unmodified lines | |||
| 483 | ST_FUNC void vpushv(SValue *v) | 483 | ST_FUNC void vpushv(SValue *v) |
| 484 | { | 484 | { |
| 485 | if (vtop >= vstack + (VSTACK_SIZE - 1)) | 485 | if (vtop >= vstack + (VSTACK_SIZE - 1)) |
| 486 | tcc_error("memory full"); | 486 | tcc_error("memory full (vstack)"); |
| 487 | vtop++; | 487 | vtop++; |
| 488 | *vtop = *v; | 488 | *vtop = *v; |
| 489 | } | 489 | } |
| @@ -2348,8 +2348,8 @@ static void gen_assign_cast(CType *dt) · 1858 unmodified lines | |||
| 2348 | st = &vtop->type; /* source type */ | 2348 | st = &vtop->type; /* source type */ |
| 2349 | dbt = dt->t & VT_BTYPE; | 2349 | dbt = dt->t & VT_BTYPE; |
| 2350 | sbt = st->t & VT_BTYPE; | 2350 | sbt = st->t & VT_BTYPE; |
| 2351 | if (sbt == VT_VOID) | 2351 | if (sbt == VT_VOID || dbt == VT_VOID) |
| 2352 | tcc_error("Cannot assign void value"); | 2352 | tcc_error("cannot cast from/to void"); |
| 2353 | if (dt->t & VT_CONSTANT) | 2353 | if (dt->t & VT_CONSTANT) |
| 2354 | tcc_warning("assignment of read-only location"); | 2354 | tcc_warning("assignment of read-only location"); |
| 2355 | switch(dbt) { | 2355 | switch(dbt) { |
| @@ -197,7 +197,7 @@ static TokenSym *tok_alloc_new(TokenSym **pts, const char *str, int len) · 196 unmodified lines | |||
| 197 | int i; | 197 | int i; |
| 198 | 198 | ||
| 199 | if (tok_ident >= SYM_FIRST_ANOM) | 199 | if (tok_ident >= SYM_FIRST_ANOM) |
| 200 | tcc_error("memory full"); | 200 | tcc_error("memory full (symbols)"); |
| 201 | 201 | ||
| 202 | /* expand token table if needed */ | 202 | /* expand token table if needed */ |
| 203 | i = tok_ident - TOK_IDENT; | 203 | i = tok_ident - TOK_IDENT; |
| @@ -1528,7 +1528,7 @@ include_done: · 1324 unmodified lines | |||
| 1528 | c = (define_find(tok) != 0) ^ c; | 1528 | c = (define_find(tok) != 0) ^ c; |
| 1529 | do_if: | 1529 | do_if: |
| 1530 | if (s1->ifdef_stack_ptr >= s1->ifdef_stack + IFDEF_STACK_SIZE) | 1530 | if (s1->ifdef_stack_ptr >= s1->ifdef_stack + IFDEF_STACK_SIZE) |
| 1531 | tcc_error("memory full"); | 1531 | tcc_error("memory full (ifdef)"); |
| 1532 | *s1->ifdef_stack_ptr++ = c; | 1532 | *s1->ifdef_stack_ptr++ = c; |
| 1533 | goto test_skip; | 1533 | goto test_skip; |
| 1534 | case TOK_ELSE: | 1534 | case TOK_ELSE: |
| @@ -27,7 +27,7 @@ ifneq ($(ARCH),i386) · 26 unmodified lines | |||
| 27 | TESTS := $(filter-out btest,$(TESTS)) | 27 | TESTS := $(filter-out btest,$(TESTS)) |
| 28 | endif | 28 | endif |
| 29 | ifdef CONFIG_WIN32 | 29 | ifdef CONFIG_WIN32 |
| 30 | TESTS := $(filter-out test3,$(TESTS)) | 30 | TESTS := w32-prep $(filter-out test3,$(TESTS)) |
| 31 | endif | 31 | endif |
| 32 | ifeq ($(TARGETOS),Darwin) | 32 | ifeq ($(TARGETOS),Darwin) |
| 33 | TESTS := $(filter-out hello-exe test3 btest,$(TESTS)) | 33 | TESTS := $(filter-out hello-exe test3 btest,$(TESTS)) |
| @@ -84,6 +84,9 @@ moretests: · 50 unmodified lines | |||
| 84 | @echo ------------ $@ ------------ | 84 | @echo ------------ $@ ------------ |
| 85 | $(MAKE) -C tests2 | 85 | $(MAKE) -C tests2 |
| 86 | 86 | ||
| 87 | w32-prep: | ||
| 88 | cp ../libtcc1.a ../lib | ||
| 89 | |||
| 87 | # test.ref - generate using gcc | 90 | # test.ref - generate using gcc |
| 88 | # copy only tcclib.h so GCC's stddef and stdarg will be used | 91 | # copy only tcclib.h so GCC's stddef and stdarg will be used |
| 89 | test.ref: tcctest.c | 92 | test.ref: tcctest.c |
| @@ -91,41 +94,41 @@ test.ref: tcctest.c · 1 unmodified line | |||
| 91 | ./tcctest.gcc > $@ | 94 | ./tcctest.gcc > $@ |
| 92 | 95 | ||
| 93 | # auto test | 96 | # auto test |
| 94 | test1: test.ref | 97 | test1: tcctest.c test.ref |
| 95 | @echo ------------ $@ ------------ | 98 | @echo ------------ $@ ------------ |
| 96 | $(TCC) -run $(SRCDIR)/tcctest.c > test.out1 | 99 | $(TCC) -run $< > test.out1 |
| 97 | @if diff -u test.ref test.out1 ; then echo "Auto Test OK"; fi | 100 | @if diff -u test.ref test.out1 ; then echo "Auto Test OK"; fi |
| 98 | 101 | ||
| 99 | # iterated test2 (compile tcc then compile tcctest.c !) | 102 | # iterated test2 (compile tcc then compile tcctest.c !) |
| 100 | test2: test.ref | 103 | test2: tcctest.c test.ref |
| 101 | @echo ------------ $@ ------------ | 104 | @echo ------------ $@ ------------ |
| 102 | $(TCC) $(RUN_TCC) $(RUN_TCC) -run $(SRCDIR)/tcctest.c > test.out2 | 105 | $(TCC) $(RUN_TCC) $(RUN_TCC) -run $< > test.out2 |
| 103 | @if diff -u test.ref test.out2 ; then echo "Auto Test2 OK"; fi | 106 | @if diff -u test.ref test.out2 ; then echo "Auto Test2 OK"; fi |
| 104 | 107 | ||
| 105 | # iterated test3 (compile tcc then compile tcc then compile tcctest.c !) | 108 | # iterated test3 (compile tcc then compile tcc then compile tcctest.c !) |
| 106 | test3: test.ref | 109 | test3: tcctest.c test.ref |
| 107 | @echo ------------ $@ ------------ | 110 | @echo ------------ $@ ------------ |
| 108 | $(TCC) $(RUN_TCC) $(RUN_TCC) $(RUN_TCC) -run $(SRCDIR)/tcctest.c > test.out3 | 111 | $(TCC) $(RUN_TCC) $(RUN_TCC) $(RUN_TCC) -run $< > test.out3 |
| 109 | @if diff -u test.ref test.out3 ; then echo "Auto Test3 OK"; fi | 112 | @if diff -u test.ref test.out3 ; then echo "Auto Test3 OK"; fi |
| 110 | 113 | ||
| 111 | # binary output test | 114 | # binary output test |
| 112 | test4: test.ref | 115 | test4: tcctest.c test.ref |
| 113 | @echo ------------ $@ ------------ | 116 | @echo ------------ $@ ------------ |
| 114 | # object + link output | 117 | # object + link output |
| 115 | $(TCC) -c -o tcctest3.o $(SRCDIR)/tcctest.c | 118 | $(TCC) -c -o tcctest3.o $< |
| 116 | $(TCC) -o tcctest3 tcctest3.o | 119 | $(TCC) -o tcctest3 tcctest3.o |
| 117 | ./tcctest3 > test3.out | 120 | ./tcctest3 > test3.out |
| 118 | @if diff -u test.ref test3.out ; then echo "Object Auto Test OK"; fi | 121 | @if diff -u test.ref test3.out ; then echo "Object Auto Test OK"; fi |
| 119 | # dynamic output | 122 | # dynamic output |
| 120 | $(TCC) -o tcctest1 $(SRCDIR)/tcctest.c | 123 | $(TCC) -o tcctest1 $< |
| 121 | ./tcctest1 > test1.out | 124 | ./tcctest1 > test1.out |
| 122 | @if diff -u test.ref test1.out ; then echo "Dynamic Auto Test OK"; fi | 125 | @if diff -u test.ref test1.out ; then echo "Dynamic Auto Test OK"; fi |
| 123 | # dynamic output + bound check | 126 | # dynamic output + bound check |
| 124 | $(TCC) -b -o tcctest4 $(SRCDIR)/tcctest.c | 127 | $(TCC) -b -o tcctest4 $< |
| 125 | ./tcctest4 > test4.out | 128 | ./tcctest4 > test4.out |
| 126 | @if diff -u test.ref test4.out ; then echo "BCheck Auto Test OK"; fi | 129 | @if diff -u test.ref test4.out ; then echo "BCheck Auto Test OK"; fi |
| 127 | # static output | 130 | # static output |
| 128 | $(TCC) -static -o tcctest2 $(SRCDIR)/tcctest.c | 131 | $(TCC) -static -o tcctest2 $< |
| 129 | ./tcctest2 > test2.out | 132 | ./tcctest2 > test2.out |
| 130 | @if diff -u test.ref test2.out ; then echo "Static Auto Test OK"; fi | 133 | @if diff -u test.ref test2.out ; then echo "Static Auto Test OK"; fi |
| 131 | 134 | ||
| @@ -161,9 +164,9 @@ speedtest: ex2 ex3 · 29 unmodified lines | |||
| 161 | time ./ex3 35 | 164 | time ./ex3 35 |
| 162 | time $(TCC) -run $(top_srcdir)/examples/ex3.c 35 | 165 | time $(TCC) -run $(top_srcdir)/examples/ex3.c 35 |
| 163 | 166 | ||
| 164 | weaktest: test.ref | 167 | weaktest: tcctest.c test.ref |
| 165 | $(TCC) -c tcctest.c -o weaktest.tcc.o $(CPPFLAGS) $(CFLAGS) | 168 | $(TCC) -c $< -o weaktest.tcc.o $(CPPFLAGS) $(CFLAGS) |
| 166 | $(CC) -c tcctest.c -o weaktest.gcc.o -I. $(CPPFLAGS) -w $(CFLAGS) | 169 | $(CC) -c $< -o weaktest.gcc.o -I. $(CPPFLAGS) -w $(CFLAGS) |
| 167 | objdump -t weaktest.tcc.o | grep ' w ' | sed -e 's/.* \([a-zA-Z0-9_]*\)$$/\1/' | LC_ALL=C sort > weaktest.tcc.o.txt | 170 | objdump -t weaktest.tcc.o | grep ' w ' | sed -e 's/.* \([a-zA-Z0-9_]*\)$$/\1/' | LC_ALL=C sort > weaktest.tcc.o.txt |
| 168 | objdump -t weaktest.gcc.o | grep ' w ' | sed -e 's/.* \([a-zA-Z0-9_]*\)$$/\1/' | LC_ALL=C sort > weaktest.gcc.o.txt | 171 | objdump -t weaktest.gcc.o | grep ' w ' | sed -e 's/.* \([a-zA-Z0-9_]*\)$$/\1/' | LC_ALL=C sort > weaktest.gcc.o.txt |
| 169 | diff weaktest.gcc.o.txt weaktest.tcc.o.txt && echo "Weak Auto Test OK" | 172 | diff weaktest.gcc.o.txt weaktest.tcc.o.txt && echo "Weak Auto Test OK" |
| @@ -220,7 +223,5 @@ cache: tcc_g · 50 unmodified lines | |||
| 220 | clean: | 223 | clean: |
| 221 | $(MAKE) -C tests2 $@ | 224 | $(MAKE) -C tests2 $@ |
| 222 | rm -vf *~ *.o *.a *.bin *.i *.ref *.out *.out? *.out?b *.gcc *.exe \ | 225 | rm -vf *~ *.o *.a *.bin *.i *.ref *.out *.out? *.out?b *.gcc *.exe \ |
| 223 | hello libtcc_test tcctest[1234] ex? tcc_g tcclib.h | 226 | hello libtcc_test tcctest[1234] ex? tcc_g tcclib.h \ |
| 224 | 227 | ../lib/libtcc1.a | |
| 225 | Makefile: $(SRCDIR)/Makefile | ||
| 226 | cp $< $@ | ||
| @@ -6,7 +6,7 @@ struct fred · 5 unmodified lines | |||
| 6 | int natasha; | 6 | int natasha; |
| 7 | }; | 7 | }; |
| 8 | 8 | ||
| 9 | void main() | 9 | int main() |
| 10 | { | 10 | { |
| 11 | struct fred bloggs; | 11 | struct fred bloggs; |
| 12 | 12 | ||
| @@ -96,6 +96,3 @@ all test: $(TESTS) · 95 unmodified lines | |||
| 96 | 96 | ||
| 97 | clean: | 97 | clean: |
| 98 | rm -vf fred.txt *.output | 98 | rm -vf fred.txt *.output |
| 99 | |||
| 100 | Makefile: $(top_srcdir)/tests/tests2/Makefile | ||
| 101 | cp $< $@ | ||
| @@ -63,5 +63,5 @@ del *.o · 62 unmodified lines | |||
| 63 | echo>..\config.texi @set VERSION %VERSION% | 63 | echo>..\config.texi @set VERSION %VERSION% |
| 64 | if not exist doc md doc | 64 | if not exist doc md doc |
| 65 | makeinfo --html --no-split -o doc\tcc-doc.html ../tcc-doc.texi | 65 | makeinfo --html --no-split -o doc\tcc-doc.html ../tcc-doc.texi |
| 66 | if exist tcc-win32.txt move tcc-win32.txt doc\ | 66 | copy tcc-win32.txt doc |
| 67 | copy ..\tests\libtcc_test.c examples\ | 67 | copy ..\tests\libtcc_test.c examples |