History

final adjustments for release

- configure/Makefiles: minor adjustments - build-tcc.bat: add -static to gcc options (avoids libgcc_s*.dll dependency with some mingw versions) - tccpe.c/tcctools.c: eliminate MAX_PATH (not available for cross compilers) - tccasm.c: use uint64_t/strtoull in unary() (unsigned long sometimes is only uint32_t, as always on windows) - tccgen.c: Revert (f077d16c) "tccgen: gen_cast: cast FLOAT to DOUBLE" Was a rather experimental, tentative commit, not really necessary and somewhat ugly too. - cleanup recent osx support: - Makefile/libtcc.c: cleanup copy&paste code - tccpp.c: restore deleted function

grischka committed 9 years ago

Commit 7acf9aa1 parent fb4f57613 files · +158 −159Browse files

Unified · Split

13 files
  1. Makefile +53 −61
  2. configure +19 −15
  3. lib/Makefile +8 −10
  4. libtcc.c +10 −17
  5. tccasm.c +2 −2
  6. tccgen.c +0 −9
  7. tccpe.c +1 −5
  8. tccpp.c +31 −1
  9. tcctools.c +3 −3
  10. tests/Makefile +13 −18
  11. tests/tests2/Makefile +16 −17
  12. win32/build-tcc.bat +1 −1
  13. win32/include/_mingw.h +1 −0
Makefile+53−61
@@ -4,8 +4,8 @@ · 3 unmodified lines
44 #
55
66 ifndef TOP
7−TOP = .
8−INCLUDED = no
7+ TOP = .
8+ INCLUDED = no
99 endif
1010
1111 include $(TOP)/config.mak
@@ -31,26 +31,11 @@ VPATH = $(TOPSRC) · 19 unmodified lines
3131
3232 ifdef CONFIG_WIN32
3333 ifneq ($(DISABLE_STATIC),no)
34− LIBTCC = libtcc.dll
34+ LIBTCC = libtcc$(DLLSUF)
3535 LIBTCCDEF = libtcc.def
3636 endif
3737 CFGWIN = -win
38− NATIVE_TARGET = $(ARCH)-$(if $(eq $(ARCH),arm),wince,win32)
39−else ifdef CONFIG_OSX
40− LIBS=-lm
41− ifndef CONFIG_NOLDL
42− LIBS+=-ldl
43− endif
44− # make libtcc as static or dynamic library?
45− ifeq ($(DISABLE_STATIC),yes)
46− LIBTCC=libtcc.dylib
47− ifndef DISABLE_RPATH
48− LINK_LIBTCC += -Wl,-rpath,"$(libdir)"
49− export LD_LIBRARY_PATH := $(CURDIR)/$(TOP)
50− endif
51− endif
52− CFGWIN =-unx
53− NATIVE_TARGET = $(ARCH)-osx
38+ NATIVE_TARGET = $(ARCH)-win$(if $(findstring arm,$(ARCH)),ce,32)
5439 else
5540 LIBS=-lm
5641 ifndef CONFIG_NOLDL
@@ -58,19 +43,19 @@ else · 1 unmodified line
5843 endif
5944 # make libtcc as static or dynamic library?
6045 ifeq ($(DISABLE_STATIC),yes)
61− LIBTCC=libtcc.so
46+ LIBTCC=libtcc$(DLLSUF)
47+ export LD_LIBRARY_PATH := $(CURDIR)/$(TOP)
6248 ifndef DISABLE_RPATH
6349 LINK_LIBTCC += -Wl,-rpath,"$(libdir)"
64− export LD_LIBRARY_PATH := $(CURDIR)/$(TOP)
6550 endif
6651 endif
6752 CFGWIN =-unx
6853 NATIVE_TARGET = $(ARCH)
69−endif
70−
71−ifeq ($(TARGETOS),Darwin)
72− LDFLAGS += -flat_namespace -undefined warning
73− export MACOSX_DEPLOYMENT_TARGET:=10.2
54+ ifdef CONFIG_OSX
55+ NATIVE_TARGET = $(ARCH)-osx
56+ LDFLAGS += -flat_namespace -undefined warning
57+ export MACOSX_DEPLOYMENT_TARGET := 10.2
58+ endif
7459 endif
7560
7661 # run local version of tcc with local libraries and includes
@@ -78,16 +63,19 @@ TCCFLAGS-unx = -B$(TOP) -I$(TOPSRC)/include -I$(TOPSRC) -I$(TOP) · 1 unmodified line
7863 TCCFLAGS-win = -B$(TOPSRC)/win32 -I$(TOPSRC)/include -I$(TOPSRC) -I$(TOP) -L$(TOP)
7964 TCCFLAGS = $(TCCFLAGS$(CFGWIN))
8065 TCC = $(TOP)/tcc$(EXESUF) $(TCCFLAGS)
66+ifdef CONFIG_OSX
67+ TCCFLAGS += -D_ANSI_SOURCE
68+endif
8169
8270 CFLAGS_P = $(CFLAGS) -pg -static -DCONFIG_TCC_STATIC -DTCC_PROFILE
83−LIBS_P= $(LIBS)
71+LIBS_P = $(LIBS)
8472 LDFLAGS_P = $(LDFLAGS)
8573
8674 CONFIG_$(ARCH) = yes
8775 NATIVE_DEFINES_$(CONFIG_i386) += -DTCC_TARGET_I386
8876 NATIVE_DEFINES_$(CONFIG_x86_64) += -DTCC_TARGET_X86_64
8977 NATIVE_DEFINES_$(CONFIG_WIN32) += -DTCC_TARGET_PE
90−NATIVE_DEFINES_$(CONFIG_OSX) += -DTCC_TARGET_X86_64 -DTCC_TARGET_MACHO
78+NATIVE_DEFINES_$(CONFIG_OSX) += -DTCC_TARGET_MACHO
9179 NATIVE_DEFINES_$(CONFIG_uClibc) += -DTCC_UCLIBC
9280 NATIVE_DEFINES_$(CONFIG_musl) += -DTCC_MUSL
9381 NATIVE_DEFINES_$(CONFIG_arm) += -DTCC_TARGET_ARM
@@ -117,12 +105,8 @@ LIBTCC1_X = i386 x86_64 i386-win32 x86_64-win32 x86_64-osx arm arm64 arm-wince · 23 unmodified lines
117105 PROGS_CROSS = $(foreach X,$(TCC_X),$X-tcc$(EXESUF))
118106 LIBTCC1_CROSS = $(foreach X,$(LIBTCC1_X),libtcc1-$X.a)
119107
120−ifdef CONFIG_CROSS
121−all : $(LIBTCC1_CROSS) $(PROGS_CROSS)
122−endif
123−
124108 # build cross compilers & libs
125−cross: all $(LIBTCC1_CROSS) $(PROGS_CROSS)
109+cross: $(LIBTCC1_CROSS) $(PROGS_CROSS)
126110
127111 # build specific cross compiler & lib
128112 cross-%: %-tcc$(EXESUF) libtcc1-%.a ;
@@ -130,6 +114,10 @@ cross-%: %-tcc$(EXESUF) libtcc1-%.a ; · 1 unmodified line
130114 install: install$(CFGWIN)
131115 uninstall: uninstall$(CFGWIN)
132116
117+ifdef CONFIG_CROSS
118+all : cross
119+endif
120+
133121 # --------------------------------------------
134122
135123 T = $(or $(CROSS_TARGET),$(NATIVE_TARGET),unknown)
@@ -206,7 +194,7 @@ $(X)tcc.o : tcctools.c · 70 unmodified lines
206194 $(X)arm-gen.o : arm-asm.c
207195
208196 # Host Tiny C Compiler
209−tcc$(EXESUF): $(X)tcc.o $(LIBTCC)
197+tcc$(EXESUF): tcc.o $(LIBTCC)
210198 $(CC) -o $@ $^ $(DEFINES) $(CFLAGS) $(LIBS) $(LDFLAGS) $(LINK_LIBTCC)
211199
212200 # Cross Tiny C Compilers
@@ -218,7 +206,7 @@ $(CROSS_TARGET)-tcc$(EXESUF): $(TCC_FILES) · 5 unmodified lines
218206
219207 # profiling version
220208 tcc_p$(EXESUF): $($T_FILES)
221− $(CC) -o $@ $< -$(DEFINES) $(CFLAGS_P) $(LIBS_P) $(LDFLAGS_P)
209+ $(CC) -o $@ $< $(DEFINES) -DONE_SOURCE $(CFLAGS_P) $(LIBS_P) $(LDFLAGS_P)
222210
223211 # static libtcc library
224212 libtcc.a: $(LIBTCC_OBJ)
@@ -226,13 +214,13 @@ libtcc.a: $(LIBTCC_OBJ) · 1 unmodified line
226214
227215 # dynamic libtcc library
228216 libtcc.so: $(LIBTCC_OBJ)
229− $(CC) -shared -Wl,-soname,$@ -o $@ $^ $(LDFLAGS)
217+ $(CC) -shared -Wl,-soname,$@ -o $@ $^ $(CFLAGS) $(LDFLAGS)
230218
231219 libtcc.so: CFLAGS+=-fPIC
232220
233221 # windows dynamic libtcc library
234222 libtcc.dll : $(LIBTCC_OBJ)
235− $(CC) -shared $(LIBTCC_OBJ) -o $@ $(LDFLAGS)
223+ $(CC) -shared -o $@ $^ $(CFLAGS) $(LDFLAGS)
236224
237225 libtcc.def : libtcc.dll tcc$(EXESUF)
238226 ./tcc$(EXESUF) -impdef $< -o $@
@@ -241,11 +229,11 @@ libtcc.dll : DEFINES += -DLIBTCC_AS_DLL · 2 unmodified lines
241229
242230 # TinyCC runtime libraries
243231 libtcc1.a : tcc$(EXESUF) FORCE
244− @$(MAKE) -f lib/Makefile BIN=$@ $@ TOP=. --no-print-directory
232+ @$(MAKE) -C lib
245233
246234 # Cross libtcc1.a
247235 libtcc1-%.a : %-tcc$(EXESUF) FORCE
248− @$(MAKE) -f lib/Makefile BIN=$@ $@ CROSS_TARGET=$* TOP=. --no-print-directory
236+ @$(MAKE) -C lib CROSS_TARGET=$*
249237
250238 FORCE:
251239
@@ -290,19 +278,21 @@ install-unx: · 38 unmodified lines
290278 $(call TRY-INSTALL,tcc.1,"$(mandir)/man1")
291279 $(call TRY-INSTALL,tcc-doc.info,"$(infodir)")
292280 $(call TRY-INSTALL,tcc-doc.html,"$(docdir)")
293− mkdir -p "$(tccdir)/win32/include"
294− cp -r $(TOPSRC)/include/. "$(tccdir)/win32/include"
295− cp -r $(TOPSRC)/win32/include/. "$(tccdir)/win32/include"
281+ifneq "$(LIBTCC1_W)" ""
296282 mkdir -p "$(tccdir)/win32/lib"
297283 $(INSTALL) $(TOPSRC)/win32/lib/*.def $(LIBTCC1_W) "$(tccdir)/win32/lib"
284+ mkdir -p "$(tccdir)/win32/include"
285+ cp -r $(TOPSRC)/win32/include/. "$(tccdir)/win32/include"
286+ $(INSTALL) $(TOPSRC)/include/*.h $(TOPSRC)/tcclib.h "$(tccdir)/win32/include"
287+endif
298288
299289 # uninstall
300290 uninstall-unx:
301− rm -fv $(foreach P,$(PROGS) $(PROGS_CROSS),"$(bindir)/$P")
302− rm -fv "$(libdir)/$(LIBTCC)" "$(includedir)/libtcc.h"
303− rm -fv "$(mandir)/man1/tcc.1" "$(infodir)/tcc-doc.info"
304− rm -fv "$(docdir)/tcc-doc.html"
305− rm -rv "$(tccdir)"
291+ @rm -fv $(foreach P,$(PROGS) $(PROGS_CROSS),"$(bindir)/$P")
292+ @rm -fv "$(libdir)/libtcc.a" "$(libdir)/libtcc.so" "$(includedir)/libtcc.h"
293+ @rm -fv "$(mandir)/man1/tcc.1" "$(infodir)/tcc-doc.info"
294+ @rm -fv "$(docdir)/tcc-doc.html"
295+ rm -r "$(tccdir)"
306296
307297 # install progs & libs on windows
308298 install-win:
@@ -310,12 +300,10 @@ install-win: · 1 unmodified line
310300 $(INSTALL) $(PROGS) $(subst libtcc.a,,$(LIBTCC)) $(PROGS_X) "$(tccdir)"
311301 mkdir -p "$(tccdir)/lib"
312302 $(INSTALL) $(TOPSRC)/win32/lib/*.def "$(tccdir)/lib"
313− $(INSTALL) libtcc1.a $(LIBTCC1_W) $(LIBTCC1_U) "$(tccdir)/lib"
303+ $(INSTALL) libtcc1.a $(LIBTCC1_W) "$(tccdir)/lib"
314304 mkdir -p "$(tccdir)/include"
315305 cp -r $(TOPSRC)/win32/include/. "$(tccdir)/include"
316306 $(INSTALL) $(TOPSRC)/include/*.h $(TOPSRC)/tcclib.h "$(tccdir)/include"
317− mkdir -p "$(tccdir)/lib/include";
318− $(INSTALL) $(TOPSRC)/include/*.h $(TOPSRC)/tcclib.h "$(tccdir)/lib/include"
319307 mkdir -p "$(tccdir)/examples"
320308 cp -r $(TOPSRC)/win32/examples/. "$(tccdir)/examples"
321309 $(INSTALL) $(TOPSRC)/tests/libtcc_test.c "$(tccdir)/examples"
@@ -323,13 +311,18 @@ install-win: · 1 unmodified line
323311 $(INSTALL) $(TOPSRC)/libtcc.h $(subst .dll,.def,$(LIBTCC)) "$(tccdir)/libtcc"
324312 mkdir -p "$(tccdir)/doc"
325313 $(INSTALL) $(TOPSRC)/win32/tcc-win32.txt $(wildcard tcc-doc.html) "$(tccdir)/doc"
314+ifneq "$(LIBTCC1_U)" ""
315+ $(INSTALL) $(LIBTCC1_U) "$(tccdir)/lib"
316+ mkdir -p "$(tccdir)/lib/include";
317+ $(INSTALL) $(TOPSRC)/include/*.h $(TOPSRC)/tcclib.h "$(tccdir)/lib/include"
318+endif
326319
327320 # the msys-git shell works to configure && make except it does not have install
328321 install-win : INSTALL = cp
329322
330323 # uninstall on windows
331324 uninstall-win:
332− rm -rfv "$(tccdir)/"*
325+ rm -r "$(tccdir)/"*
333326
334327 # --------------------------------------------------------------------------
335328 # other stuff
@@ -341,7 +334,7 @@ ETAGS : ; etags $(TAGFILES) · 5 unmodified lines
341334
342335 # create release tarball from *current* git branch (including tcc-doc.html
343336 # and converting two files to CRLF)
344−TCC-VERSION = $(VERSION)
337+TCC-VERSION = tcc-$(VERSION)
345338 tar: tcc-doc.html
346339 mkdir $(TCC-VERSION)
347340 ( cd $(TCC-VERSION) && git --git-dir ../.git checkout -f )
@@ -361,11 +354,10 @@ test: · 13 unmodified lines
361354 $(MAKE) -C tests
362355
363356 clean:
364− rm -f $(PROGS) $(PROGS_CROSS) tcc_p$(EXESUF) tcc.pod \
365− *~ *.o *.a *.so* *.out *.log lib*.def *.exe *.dll a.out \
366− tags TAGS libtcc_test$(EXESUF)
367− $(MAKE) -C tests $@
368− $(MAKE) -C lib $@
357+ rm -f $(PROGS) $(PROGS_CROSS) tcc_p$(EXESUF) tcc.pod
358+ rm -f *~ *.o *.a *.so* *.out *.log lib*.def *.exe *.dll a.out tags TAGS
359+ @$(MAKE) -C tests $@
360+ @$(MAKE) -C lib $@
369361
370362 distclean: clean
371363 rm -f config.h config.mak config.texi tcc.1 tcc-doc.info tcc-doc.html
@@ -389,12 +381,12 @@ help: · 17 unmodified lines
389381 @echo "Cross compiler configuration:"
390382 @echo " make will read custom configuration for cross compilers from a file"
391383 @echo " 'config-cross.mak' if present. For example for a windows->i386-linux"
392− @echo " cross-compiler that expects the linux files in <prefix>/i386-linux:"
384+ @echo " cross-compiler that expects the linux files in <tccdir>/i386-linux:"
393385 @echo ""
394386 @echo " ROOT-i386 = {B}/i386-linux"
395− @echo " CRT-i386 = $(ROOT-i386)/usr/lib"
396− @echo " LIB-i386 = $(ROOT-i386)/lib:$(ROOT-i386)/usr/lib"
397− @echo " INC-i386 = {B}/lib/include:$(ROOT-i386)/usr/include"
387+ @echo " CRT-i386 = {B}/i386-linux/usr/lib"
388+ @echo " LIB-i386 = {B}/i386-linux/lib:{B}/i386-linux/usr/lib"
389+ @echo " INC-i386 = {B}/lib/include:{B}/i386-linux/usr/include"
398390 @echo " DEF-i386 += -D__linux__"
399391 @echo ""
400392 @echo "Other supported make targets:"
configure+19−15
@@ -33,7 +33,7 @@ cross_prefix="" · 32 unmodified lines
3333 cc="gcc"
3434 ar="ar"
3535 strip="strip"
36−cygwin="no"
36+noldl="no"
3737 gprof="no"
3838 bigendian="no"
3939 mingw32="no"
@@ -53,28 +53,26 @@ cpu= · 13 unmodified lines
5353 # OS specific
5454 targetos=`uname`
5555 case $targetos in
56− Darwin) osx=yes;;
57− MINGW*) mingw32=yes;;
58− MSYS*) mingw32=yes;;
59− CYGWIN*) mingw32=yes; cygwin=yes; cross_prefix="mingw32-";;
60− DragonFly) noldl=yes;;
61− OpenBSD) noldl=yes;;
62− FreeBSD) noldl=yes;;
63− NetBSD) noldl=yes;;
64− *) ;;
56+ Darwin)
57+ osx=yes
58+ ;;
59+ MINGW*|MSYS*|CYGWIN*)
60+ mingw32=yes
61+ ;;
62+ DragonFly|OpenBSD|FreeBSD|NetBSD)
63+ noldl=yes
64+ ;;
65+ *)
66+ ;;
6567 esac
6668
6769 # find source path
68−# XXX: we assume an absolute path is given when launching configure,
69−# except in './configure' case.
7070 source_path=${0%configure}
7171 source_path=${source_path%/}
7272 source_path_used="yes"
7373 if test -z "$source_path" -o "$source_path" = "." ; then
7474 source_path=`pwd`
7575 source_path_used="no"
76− # mingw compilers might not understand cygwin paths
77− if test $cygwin = "yes"; then source_path="."; fi
7876 fi
7977
8078 for opt do
@@ -130,7 +128,7 @@ for opt do · 49 unmodified lines
130128 ;;
131129 --enable-gprof) gprof="yes"
132130 ;;
133− --enable-mingw32) mingw32="yes" ; cross_prefix="i686-pc-mingw32-" ; cpu=x86
131+ --enable-mingw32) mingw32="yes"
134132 ;;
135133 --enable-cross) build_cross="yes"
136134 ;;
@@ -211,6 +209,12 @@ if test -z "$CFLAGS"; then · 74 unmodified lines
211209 fi
212210
213211 if test "$mingw32" = "yes" ; then
212+ if test "$source_path_used" = "no"; then
213+ source_path="."
214+ fi
215+ if test "$cc" = gcc; then
216+ test -z "$LDFLAGS" && LDFLAGS="-static"
217+ fi
214218 if test x"$tccdir" = x""; then
215219 tccdir="tcc"
216220 fi
lib/Makefile+8−10
@@ -7,6 +7,7 @@ include $(TOP)/Makefile · 6 unmodified lines
77 VPATH = $(TOPSRC)/lib $(TOPSRC)/win32/lib
88 T = $(or $(CROSS_TARGET),$(NATIVE_TARGET),unknown)
99 X = $(if $(CROSS_TARGET),$(CROSS_TARGET)-)
10+BIN = $(TOP)/libtcc1$(if $(CROSS_TARGET),-$(CROSS_TARGET)).a
1011
1112 TCC = $(TOP)/$(X)tcc$(EXESUF)
1213 XCC = $(TCC)
@@ -25,25 +26,24 @@ ifeq ($(X),) · 12 unmodified lines
2526 endif
2627 endif
2728
28−ifeq ($(TARGETOS),Darwin)
29+ifdef CONFIG_OSX
2930 XFLAGS += -D_ANSI_SOURCE
30− BCHECK_O =
3131 endif
3232
3333 ifeq ($(CONFIG_musl),yes)
3434 BCHECK_O =
3535 endif
3636
37−I386_O = libtcc1.o alloca86.o alloca86-bt.o $(BCHECK_O)
38−X86_64_O = libtcc1.o alloca86_64.o alloca86_64-bt.o $(BCHECK_O)
37+I386_O = libtcc1.o alloca86.o alloca86-bt.o
38+X86_64_O = libtcc1.o alloca86_64.o alloca86_64-bt.o
3939 ARM_O = libtcc1.o armeabi.o alloca-arm.o
4040 ARM64_O = lib-arm64.o
4141 WIN_O = crt1.o crt1w.o wincrt1.o wincrt1w.o dllcrt1.o dllmain.o
4242
43−OBJ-i386 = $(I386_O)
43+OBJ-i386 = $(I386_O) $(BCHECK_O)
4444 TGT-i386 = -DTCC_TARGET_I386
4545
46−OBJ-x86_64 = $(X86_64_O)
46+OBJ-x86_64 = $(X86_64_O) $(BCHECK_O)
4747 TGT-x86_64 = -DTCC_TARGET_X86_64
4848
4949 OBJ-x86_64-osx = $(X86_64_O)
@@ -55,17 +55,15 @@ TGT-arm = -DTCC_TARGET_ARM · 5 unmodified lines
5555 OBJ-arm64 = $(ARM64_O)
5656 TGT-arm64 = -DTCC_TARGET_ARM64
5757
58−OBJ-i386-win32 = $(I386_O) chkstk.o $(WIN_O)
58+OBJ-i386-win32 = $(I386_O) chkstk.o bcheck.o $(WIN_O)
5959 TGT-i386-win32 = -DTCC_TARGET_I386 -DTCC_TARGET_PE
6060
61−OBJ-x86_64-win32 = $(X86_64_O) chkstk.o $(WIN_O)
61+OBJ-x86_64-win32 = $(X86_64_O) chkstk.o bcheck.o $(WIN_O)
6262 TGT-x86_64-win32 = -DTCC_TARGET_X86_64 -DTCC_TARGET_PE
6363
6464 OBJ-arm-wince = $(ARM_O) $(WIN_O)
6565 TGT-arm-wince = -DTCC_TARGET_ARM -DTCC_TARGET_PE
6666
67−all : $(BIN)
68−
6967 $(BIN) : $(patsubst %.o,$(X)%.o,$(OBJ-$T))
7068 $(XAR) rcs $@ $^
7169
libtcc.c+10−17
@@ -1054,6 +1054,11 @@ ST_FUNC int tcc_add_file_internal(TCCState *s1, const char *filename, int flags) · 1053 unmodified lines
10541054 /* do not display line number if error */
10551055 file->line_num = 0;
10561056
1057+#ifdef TCC_TARGET_MACHO
1058+ if (0 == obj_type && 0 == strcmp(tcc_fileextension(filename), "dylib"))
1059+ obj_type = AFF_BINTYPE_DYN;
1060+#endif
1061+
10571062 switch (obj_type) {
10581063 case AFF_BINTYPE_REL:
10591064 ret = tcc_load_object_file(s1, fd, 0);
@@ -1081,19 +1086,7 @@ ST_FUNC int tcc_add_file_internal(TCCState *s1, const char *filename, int flags) · 21 unmodified lines
10811086 break;
10821087 #endif
10831088 default:
1084−#if defined(TCC_TARGET_MACHO)
1085− if (s1->output_type == TCC_OUTPUT_MEMORY) {
1086− ret = 0;
1087−#ifdef TCC_IS_NATIVE
1088− if (NULL == dlopen(filename, RTLD_GLOBAL | RTLD_LAZY)) {
1089− ret = -1;
1090− }
1091−#endif /* TCC_TARGET_MACHO */
1092− } else {
1093− ret = tcc_load_dll(s1, fd, filename,
1094− (flags & AFF_REFERENCED_DLL) != 0);
1095− }
1096−#elif defined(TCC_TARGET_PE)
1089+#ifdef TCC_TARGET_PE
10971090 ret = pe_load_file(s1, filename, fd);
10981091 #else
10991092 /* as GNU ld, consider it is an ld script if not recognized */
@@ -1155,12 +1148,12 @@ ST_FUNC int tcc_add_crt(TCCState *s, const char *filename) · 55 unmodified lines
11551148 /* the library name is the same as the argument of the '-l' option */
11561149 LIBTCCAPI int tcc_add_library(TCCState *s, const char *libraryname)
11571150 {
1158−#if defined(TCC_TARGET_MACHO)
1159− const char *libs[] = { "%s/lib%s.dylib", "%s/lib%s.a", NULL };
1160− const char **pp = s->static_link ? libs + 1 : libs;
1161−#elif defined(TCC_TARGET_PE)
1151+#if defined TCC_TARGET_PE
11621152 const char *libs[] = { "%s/%s.def", "%s/lib%s.def", "%s/%s.dll", "%s/lib%s.dll", "%s/lib%s.a", NULL };
11631153 const char **pp = s->static_link ? libs + 4 : libs;
1154+#elif defined TCC_TARGET_MACHO
1155+ const char *libs[] = { "%s/lib%s.dylib", "%s/lib%s.a", NULL };
1156+ const char **pp = s->static_link ? libs + 1 : libs;
11641157 #else
11651158 const char *libs[] = { "%s/lib%s.so", "%s/lib%s.a", NULL };
11661159 const char **pp = s->static_link ? libs + 1 : libs;
tccasm.c+2−2
@@ -87,13 +87,13 @@ static void asm_expr_unary(TCCState *s1, ExprValue *pe) · 86 unmodified lines
8787 {
8888 Sym *sym;
8989 int op, label;
90− unsigned long n;
90+ uint64_t n;
9191 const char *p;
9292
9393 switch(tok) {
9494 case TOK_PPNUM:
9595 p = tokc.str.data;
96− n = strtoul(p, (char **)&p, 0);
96+ n = strtoull(p, (char **)&p, 0);
9797 if (*p == 'b' || *p == 'f') {
9898 /* backward or forward label */
9999 label = asm_get_local_label_name(s1, n);
tccgen.c+0−9
@@ -906,10 +906,6 @@ ST_FUNC void save_reg_upstack(int r, int n) · 905 unmodified lines
906906 #else
907907 type = &int_type;
908908 #endif
909− if ((type->t & VT_BTYPE) == VT_FLOAT) {
910− /* cast to DOUBLE to avoid precision loss */
911− type->t = (type->t & ~VT_BTYPE) | VT_DOUBLE;
912− }
913909 size = type_size(type, &align);
914910 loc = (loc - size) & -align;
915911 sv.type.t = type->t;
@@ -2383,11 +2379,6 @@ static void gen_cast(CType *type) · 1467 unmodified lines
23832379 vpushi(0);
23842380 gen_op(TOK_NE);
23852381 } else {
2386− if (sbt == VT_FLOAT) {
2387− /* cast to DOUBLE to avoid precision loss */
2388− gen_cvt_ftof(VT_DOUBLE);
2389− vtop->type.t = (vtop->type.t & ~VT_BTYPE) | VT_DOUBLE;
2390− }
23912382 /* we handle char/short/etc... with generic code */
23922383 if (dbt != (VT_INT | VT_UNSIGNED) &&
23932384 dbt != (VT_LLONG | VT_UNSIGNED) &&
tccpe.c+1−5
@@ -28,10 +28,6 @@ · 27 unmodified lines
2828 #define strnicmp strncasecmp
2929 #endif
3030
31−#ifndef MAX_PATH
32−#define MAX_PATH 260
33−#endif
34−
3531 #ifdef TCC_TARGET_X86_64
3632 # define ADDR3264 ULONGLONG
3733 # define REL_TYPE_DIRECT R_X86_64_64
@@ -907,7 +903,7 @@ static void pe_build_exports(struct pe_info *pe) · 869 unmodified lines
907903 struct pe_sort_sym **sorted, *p;
908904
909905 FILE *op;
910− char buf[MAX_PATH];
906+ char buf[260];
911907 const char *dllname;
912908 const char *name;
913909
tccpp.c+31−1
@@ -1021,8 +1021,38 @@ ST_FUNC void restore_parse_state(ParseState *s) · 1020 unmodified lines
10211021 tokc = s->tokc;
10221022 }
10231023
1024−/* token string handling */
1024+#if 0
1025+/* return the number of additional 'ints' necessary to store the
1026+ token */
1027+static inline int tok_size(const int *p)
1028+{
1029+ switch(*p) {
1030+ /* 4 bytes */
1031+ case TOK_CINT:
1032+ case TOK_CUINT:
1033+ case TOK_CCHAR:
1034+ case TOK_LCHAR:
1035+ case TOK_CFLOAT:
1036+ case TOK_LINENUM:
1037+ return 1 + 1;
1038+ case TOK_STR:
1039+ case TOK_LSTR:
1040+ case TOK_PPNUM:
1041+ case TOK_PPSTR:
1042+ return 1 + ((sizeof(CString) + ((CString *)(p+1))->size + 3) >> 2);
1043+ case TOK_CDOUBLE:
1044+ case TOK_CLLONG:
1045+ case TOK_CULLONG:
1046+ return 1 + 2;
1047+ case TOK_CLDOUBLE:
1048+ return 1 + LDOUBLE_SIZE / 4;
1049+ default:
1050+ return 1 + 0;
1051+ }
1052+}
1053+#endif
10251054
1055+/* token string handling */
10261056 ST_INLN void tok_str_new(TokenString *s)
10271057 {
10281058 s->str = NULL;
tcctools.c+3−3
@@ -304,15 +304,15 @@ the_end: · 303 unmodified lines
304304 ST_FUNC int tcc_tool_impdef(TCCState *s1, int argc, char **argv)
305305 {
306306 int ret, v, i;
307− char infile[MAX_PATH];
308− char outfile[MAX_PATH];
307+ char infile[260];
308+ char outfile[260];
309309
310310 const char *file;
311311 char *p, *q;
312312 FILE *fp, *op;
313313
314314 #ifdef _WIN32
315− char path[MAX_PATH];
315+ char path[260];
316316 #endif
317317
318318 infile[0] = outfile[0] = 0;
tests/Makefile+13−18
@@ -5,7 +5,7 @@ · 4 unmodified lines
55 TOP = ..
66 include $(TOP)/Makefile
77 VPATH = $(TOPSRC)/tests $(TOPSRC) $(TOP)
8−CFLAGS := $(filter-out -W% -g% -O%,$(CFLAGS)) -I$(TOPSRC)
8+CFLAGS := $(filter-out -W% -g% -O%,$(CFLAGS)) -I$(TOPSRC) $(LDFLAGS)
99
1010 # what tests to run
1111 TESTS = \
@@ -34,8 +34,8 @@ endif · 22 unmodified lines
3434 ifdef CONFIG_WIN32
3535 TESTS := $(filter-out $(BTESTS),$(TESTS))
3636 endif
37−ifeq ($(TARGETOS),Darwin)
38− TESTS := $(filter-out hello-exe test3 $(BTESTS),$(TESTS))
37+ifdef CONFIG_OSX # -run only
38+ TESTS := hello-run libtest tests2-dir pp-dir
3939 endif
4040 ifeq (,$(filter arm64 i386 x86_64,$(ARCH)))
4141 TESTS := $(filter-out vla_test-run,$(TESTS))
@@ -51,28 +51,23 @@ ifndef CONFIG_CROSS · 9 unmodified lines
5151 endif
5252
5353 ifdef CONFIG_WIN32
54− PATH := $(CURDIR)/$(TOP):$(PATH) # for libtcc_test to find libtcc.dll
55−endif
56−
57−ifeq ($(TARGETOS),Darwin)
58− CFLAGS += -Wl,-flat_namespace,-undefined,warning
59− TCCFLAGS += -D_ANSI_SOURCE
60− export MACOSX_DEPLOYMENT_TARGET:=10.2
54+ SEP = $(if $(findstring :\,$(PATH)),;,:)
55+ PATH := $(CURDIR)/$(TOP)$(SEP)$(PATH) # for libtcc_test to find libtcc.dll
6156 endif
6257
6358 RUN_TCC = $(NATIVE_DEFINES) -DONE_SOURCE -run $(TOPSRC)/tcc.c $(TCCFLAGS)
64−
6559 DISAS = objdump -d
60+DUMPTCC = (set -x; $(TOP)/tcc -vv; ldd $(TOP)/tcc; exit 1)
6661
6762 all test : clean-s $(TESTS)
6863
6964 hello-exe: ../examples/ex1.c
7065 @echo ------------ $@ ------------
71− $(TCC) $< -o hello$(EXESUF) || ($(TOP)/tcc -vv; exit 1) && ./hello$(EXESUF)
66+ $(TCC) $< -o hello$(EXESUF) && ./hello$(EXESUF) || $(DUMPTCC)
7267
7368 hello-run: ../examples/ex1.c
7469 @echo ------------ $@ ------------
75− $(TCC) -run $<
70+ $(TCC) -run $< || $(DUMPTCC)
7671
7772 libtest: libtcc_test$(EXESUF)
7873 @echo ------------ $@ ------------
@@ -263,11 +258,11 @@ cache: tcc_g · 184 unmodified lines
263258
264259 # clean
265260 clean:
266− rm -f *~ *.o *.a *.bin *.i *.ref *.out *.out? *.out?b *.cc *.gcc \
267− *-cc *-gcc *-tcc *.exe hello libtcc_test vla_test tcctest[1234] \
268− ex? tcc_g *.def weaktest.*.txt
269− $(MAKE) -C tests2 $@
270− $(MAKE) -C pp $@
261+ rm -f *~ *.o *.a *.bin *.i *.ref *.out *.out? *.out?b *.cc *.gcc
262+ rm -f *-cc *-gcc *-tcc *.exe hello libtcc_test vla_test tcctest[1234]
263+ rm -f ex? tcc_g weaktest.*.txt *.def
264+ @$(MAKE) -C tests2 $@
265+ @$(MAKE) -C pp $@
271266
272267 # silent clean, used before running tests
273268 clean-s:
tests/tests2/Makefile+16−17
@@ -5,23 +5,6 @@ VPATH = $(SRC) · 4 unmodified lines
55
66 TESTS = $(patsubst %.c,%.test,$(sort $(notdir $(wildcard $(SRC)/*.c))))
77
8−# 34_array_assignment.test -- array assignment is not in C standard
9−SKIP = 34_array_assignment.test
10−
11−# some tests do not pass on all platforms, remove them for now
12−ifeq ($(CONFIG_arm_eabi),yes) # not ARM soft-float
13− SKIP += 22_floating_point.test
14−endif
15−ifeq ($(TARGETOS),Darwin)
16− SKIP += 40_stdio.test
17−endif
18−ifeq ($(ARCH),x86_64)
19− SKIP += 73_arm64.test
20−endif
21−ifeq (,$(filter i386 x86_64,$(ARCH)))
22− SKIP += 85_asm-outside-function.test
23−endif
24−
258 # Some tests might need arguments
269 ARGS =
2710 31_args.test : ARGS = arg1 arg2 arg3 arg4 arg5
@@ -42,6 +25,22 @@ ifeq (-$(findstring arm,$(ARCH))-,-arm-) · 14 unmodified lines
4225 FILTER += 2>&1 | grep -v 'warning: soft float ABI currently not supported'
4326 endif
4427
28+# some tests do not pass on all platforms, remove them for now
29+SKIP = 34_array_assignment.test # array assignment is not in C standard
30+ifeq ($(CONFIG_arm_eabi),yes) # not ARM soft-float
31+ SKIP += 22_floating_point.test
32+endif
33+ifdef CONFIG_OSX
34+ SKIP += 40_stdio.test 42_function_pointer.test
35+ FLAGS += -w
36+endif
37+ifeq ($(ARCH),x86_64)
38+ SKIP += 73_arm64.test
39+endif
40+ifeq (,$(filter i386 x86_64,$(ARCH)))
41+ SKIP += 85_asm-outside-function.test
42+endif
43+
4544 all test: $(filter-out $(SKIP),$(TESTS))
4645
4746 %.test: %.c %.expect
win32/build-tcc.bat+1−1
@@ -5,7 +5,7 @@ · 4 unmodified lines
55 @echo off
66 setlocal
77
8−set CC=gcc -Os -s
8+set CC=gcc -Os -s -static
99 set /p VERSION= < ..\VERSION
1010 set INST=
1111 set DOC=no
win32/include/_mingw.h+1−0
@@ -165,5 +165,6 @@ typedef struct localeinfo_struct _locale_tstruct,*_locale_t; · 164 unmodified lines
165165 #define __C89_NAMELESS
166166 #define __MINGW_EXTENSION
167167 #define WINAPI_FAMILY_PARTITION(X) 1
168+#define MINGW_HAS_SECURE_API
168169
169170 #endif /* __MINGW_H */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t