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
4#4#
5 5
6ifndef TOP6ifndef TOP
7TOP = .7 TOP = .
8INCLUDED = no8 INCLUDED = no
9endif9endif
10 10
11include $(TOP)/config.mak11include $(TOP)/config.mak
@@ -31,26 +31,11 @@ VPATH = $(TOPSRC) · 19 unmodified lines
31 31
32ifdef CONFIG_WIN3232ifdef CONFIG_WIN32
33 ifneq ($(DISABLE_STATIC),no)33 ifneq ($(DISABLE_STATIC),no)
34 LIBTCC = libtcc.dll34 LIBTCC = libtcc$(DLLSUF)
35 LIBTCCDEF = libtcc.def35 LIBTCCDEF = libtcc.def
36 endif36 endif
37 CFGWIN = -win37 CFGWIN = -win
38 NATIVE_TARGET = $(ARCH)-$(if $(eq $(ARCH),arm),wince,win32)38 NATIVE_TARGET = $(ARCH)-win$(if $(findstring arm,$(ARCH)),ce,32)
39else 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
54else39else
55 LIBS=-lm40 LIBS=-lm
56 ifndef CONFIG_NOLDL41 ifndef CONFIG_NOLDL
@@ -58,19 +43,19 @@ else · 1 unmodified line
58 endif43 endif
59 # make libtcc as static or dynamic library?44 # make libtcc as static or dynamic library?
60 ifeq ($(DISABLE_STATIC),yes)45 ifeq ($(DISABLE_STATIC),yes)
61 LIBTCC=libtcc.so46 LIBTCC=libtcc$(DLLSUF)
47 export LD_LIBRARY_PATH := $(CURDIR)/$(TOP)
62 ifndef DISABLE_RPATH48 ifndef DISABLE_RPATH
63 LINK_LIBTCC += -Wl,-rpath,"$(libdir)"49 LINK_LIBTCC += -Wl,-rpath,"$(libdir)"
64 export LD_LIBRARY_PATH := $(CURDIR)/$(TOP)
65 endif50 endif
66 endif51 endif
67 CFGWIN =-unx52 CFGWIN =-unx
68 NATIVE_TARGET = $(ARCH)53 NATIVE_TARGET = $(ARCH)
69endif54 ifdef CONFIG_OSX
70 55 NATIVE_TARGET = $(ARCH)-osx
71ifeq ($(TARGETOS),Darwin)56 LDFLAGS += -flat_namespace -undefined warning
72 LDFLAGS += -flat_namespace -undefined warning57 export MACOSX_DEPLOYMENT_TARGET := 10.2
73 export MACOSX_DEPLOYMENT_TARGET:=10.258 endif
74endif59endif
75 60
76# run local version of tcc with local libraries and includes61# 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
78TCCFLAGS-win = -B$(TOPSRC)/win32 -I$(TOPSRC)/include -I$(TOPSRC) -I$(TOP) -L$(TOP)63TCCFLAGS-win = -B$(TOPSRC)/win32 -I$(TOPSRC)/include -I$(TOPSRC) -I$(TOP) -L$(TOP)
79TCCFLAGS = $(TCCFLAGS$(CFGWIN))64TCCFLAGS = $(TCCFLAGS$(CFGWIN))
80TCC = $(TOP)/tcc$(EXESUF) $(TCCFLAGS)65TCC = $(TOP)/tcc$(EXESUF) $(TCCFLAGS)
66ifdef CONFIG_OSX
67 TCCFLAGS += -D_ANSI_SOURCE
68endif
81 69
82CFLAGS_P = $(CFLAGS) -pg -static -DCONFIG_TCC_STATIC -DTCC_PROFILE70CFLAGS_P = $(CFLAGS) -pg -static -DCONFIG_TCC_STATIC -DTCC_PROFILE
83LIBS_P= $(LIBS)71LIBS_P = $(LIBS)
84LDFLAGS_P = $(LDFLAGS)72LDFLAGS_P = $(LDFLAGS)
85 73
86CONFIG_$(ARCH) = yes74CONFIG_$(ARCH) = yes
87NATIVE_DEFINES_$(CONFIG_i386) += -DTCC_TARGET_I38675NATIVE_DEFINES_$(CONFIG_i386) += -DTCC_TARGET_I386
88NATIVE_DEFINES_$(CONFIG_x86_64) += -DTCC_TARGET_X86_6476NATIVE_DEFINES_$(CONFIG_x86_64) += -DTCC_TARGET_X86_64
89NATIVE_DEFINES_$(CONFIG_WIN32) += -DTCC_TARGET_PE77NATIVE_DEFINES_$(CONFIG_WIN32) += -DTCC_TARGET_PE
90NATIVE_DEFINES_$(CONFIG_OSX) += -DTCC_TARGET_X86_64 -DTCC_TARGET_MACHO78NATIVE_DEFINES_$(CONFIG_OSX) += -DTCC_TARGET_MACHO
91NATIVE_DEFINES_$(CONFIG_uClibc) += -DTCC_UCLIBC79NATIVE_DEFINES_$(CONFIG_uClibc) += -DTCC_UCLIBC
92NATIVE_DEFINES_$(CONFIG_musl) += -DTCC_MUSL80NATIVE_DEFINES_$(CONFIG_musl) += -DTCC_MUSL
93NATIVE_DEFINES_$(CONFIG_arm) += -DTCC_TARGET_ARM81NATIVE_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
117PROGS_CROSS = $(foreach X,$(TCC_X),$X-tcc$(EXESUF))105PROGS_CROSS = $(foreach X,$(TCC_X),$X-tcc$(EXESUF))
118LIBTCC1_CROSS = $(foreach X,$(LIBTCC1_X),libtcc1-$X.a)106LIBTCC1_CROSS = $(foreach X,$(LIBTCC1_X),libtcc1-$X.a)
119 107
120ifdef CONFIG_CROSS
121all : $(LIBTCC1_CROSS) $(PROGS_CROSS)
122endif
123
124# build cross compilers & libs108# build cross compilers & libs
125cross: all $(LIBTCC1_CROSS) $(PROGS_CROSS)109cross: $(LIBTCC1_CROSS) $(PROGS_CROSS)
126 110
127# build specific cross compiler & lib111# build specific cross compiler & lib
128cross-%: %-tcc$(EXESUF) libtcc1-%.a ;112cross-%: %-tcc$(EXESUF) libtcc1-%.a ;
@@ -130,6 +114,10 @@ cross-%: %-tcc$(EXESUF) libtcc1-%.a ; · 1 unmodified line
130install: install$(CFGWIN)114install: install$(CFGWIN)
131uninstall: uninstall$(CFGWIN)115uninstall: uninstall$(CFGWIN)
132 116
117ifdef CONFIG_CROSS
118all : cross
119endif
120
133# --------------------------------------------121# --------------------------------------------
134 122
135T = $(or $(CROSS_TARGET),$(NATIVE_TARGET),unknown)123T = $(or $(CROSS_TARGET),$(NATIVE_TARGET),unknown)
@@ -206,7 +194,7 @@ $(X)tcc.o : tcctools.c · 70 unmodified lines
206$(X)arm-gen.o : arm-asm.c194$(X)arm-gen.o : arm-asm.c
207 195
208# Host Tiny C Compiler196# Host Tiny C Compiler
209tcc$(EXESUF): $(X)tcc.o $(LIBTCC)197tcc$(EXESUF): tcc.o $(LIBTCC)
210 $(CC) -o $@ $^ $(DEFINES) $(CFLAGS) $(LIBS) $(LDFLAGS) $(LINK_LIBTCC)198 $(CC) -o $@ $^ $(DEFINES) $(CFLAGS) $(LIBS) $(LDFLAGS) $(LINK_LIBTCC)
211 199
212# Cross Tiny C Compilers200# Cross Tiny C Compilers
@@ -218,7 +206,7 @@ $(CROSS_TARGET)-tcc$(EXESUF): $(TCC_FILES) · 5 unmodified lines
218 206
219# profiling version207# profiling version
220tcc_p$(EXESUF): $($T_FILES)208tcc_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)
222 210
223# static libtcc library211# static libtcc library
224libtcc.a: $(LIBTCC_OBJ)212libtcc.a: $(LIBTCC_OBJ)
@@ -226,13 +214,13 @@ libtcc.a: $(LIBTCC_OBJ) · 1 unmodified line
226 214
227# dynamic libtcc library215# dynamic libtcc library
228libtcc.so: $(LIBTCC_OBJ)216libtcc.so: $(LIBTCC_OBJ)
229 $(CC) -shared -Wl,-soname,$@ -o $@ $^ $(LDFLAGS)217 $(CC) -shared -Wl,-soname,$@ -o $@ $^ $(CFLAGS) $(LDFLAGS)
230 218
231libtcc.so: CFLAGS+=-fPIC219libtcc.so: CFLAGS+=-fPIC
232 220
233# windows dynamic libtcc library221# windows dynamic libtcc library
234libtcc.dll : $(LIBTCC_OBJ)222libtcc.dll : $(LIBTCC_OBJ)
235 $(CC) -shared $(LIBTCC_OBJ) -o $@ $(LDFLAGS)223 $(CC) -shared -o $@ $^ $(CFLAGS) $(LDFLAGS)
236 224
237libtcc.def : libtcc.dll tcc$(EXESUF)225libtcc.def : libtcc.dll tcc$(EXESUF)
238 ./tcc$(EXESUF) -impdef $< -o $@226 ./tcc$(EXESUF) -impdef $< -o $@
@@ -241,11 +229,11 @@ libtcc.dll : DEFINES += -DLIBTCC_AS_DLL · 2 unmodified lines
241 229
242# TinyCC runtime libraries230# TinyCC runtime libraries
243libtcc1.a : tcc$(EXESUF) FORCE231libtcc1.a : tcc$(EXESUF) FORCE
244 @$(MAKE) -f lib/Makefile BIN=$@ $@ TOP=. --no-print-directory232 @$(MAKE) -C lib
245 233
246# Cross libtcc1.a234# Cross libtcc1.a
247libtcc1-%.a : %-tcc$(EXESUF) FORCE235libtcc1-%.a : %-tcc$(EXESUF) FORCE
248 @$(MAKE) -f lib/Makefile BIN=$@ $@ CROSS_TARGET=$* TOP=. --no-print-directory236 @$(MAKE) -C lib CROSS_TARGET=$*
249 237
250FORCE:238FORCE:
251 239
@@ -290,19 +278,21 @@ install-unx: · 38 unmodified lines
290 $(call TRY-INSTALL,tcc.1,"$(mandir)/man1")278 $(call TRY-INSTALL,tcc.1,"$(mandir)/man1")
291 $(call TRY-INSTALL,tcc-doc.info,"$(infodir)")279 $(call TRY-INSTALL,tcc-doc.info,"$(infodir)")
292 $(call TRY-INSTALL,tcc-doc.html,"$(docdir)")280 $(call TRY-INSTALL,tcc-doc.html,"$(docdir)")
293 mkdir -p "$(tccdir)/win32/include"281ifneq "$(LIBTCC1_W)" ""
294 cp -r $(TOPSRC)/include/. "$(tccdir)/win32/include"
295 cp -r $(TOPSRC)/win32/include/. "$(tccdir)/win32/include"
296 mkdir -p "$(tccdir)/win32/lib"282 mkdir -p "$(tccdir)/win32/lib"
297 $(INSTALL) $(TOPSRC)/win32/lib/*.def $(LIBTCC1_W) "$(tccdir)/win32/lib"283 $(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"
287endif
298 288
299# uninstall289# uninstall
300uninstall-unx:290uninstall-unx:
301 rm -fv $(foreach P,$(PROGS) $(PROGS_CROSS),"$(bindir)/$P")291 @rm -fv $(foreach P,$(PROGS) $(PROGS_CROSS),"$(bindir)/$P")
302 rm -fv "$(libdir)/$(LIBTCC)" "$(includedir)/libtcc.h"292 @rm -fv "$(libdir)/libtcc.a" "$(libdir)/libtcc.so" "$(includedir)/libtcc.h"
303 rm -fv "$(mandir)/man1/tcc.1" "$(infodir)/tcc-doc.info"293 @rm -fv "$(mandir)/man1/tcc.1" "$(infodir)/tcc-doc.info"
304 rm -fv "$(docdir)/tcc-doc.html"294 @rm -fv "$(docdir)/tcc-doc.html"
305 rm -rv "$(tccdir)"295 rm -r "$(tccdir)"
306 296
307# install progs & libs on windows297# install progs & libs on windows
308install-win:298install-win:
@@ -310,12 +300,10 @@ install-win: · 1 unmodified line
310 $(INSTALL) $(PROGS) $(subst libtcc.a,,$(LIBTCC)) $(PROGS_X) "$(tccdir)"300 $(INSTALL) $(PROGS) $(subst libtcc.a,,$(LIBTCC)) $(PROGS_X) "$(tccdir)"
311 mkdir -p "$(tccdir)/lib"301 mkdir -p "$(tccdir)/lib"
312 $(INSTALL) $(TOPSRC)/win32/lib/*.def "$(tccdir)/lib"302 $(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"
314 mkdir -p "$(tccdir)/include"304 mkdir -p "$(tccdir)/include"
315 cp -r $(TOPSRC)/win32/include/. "$(tccdir)/include"305 cp -r $(TOPSRC)/win32/include/. "$(tccdir)/include"
316 $(INSTALL) $(TOPSRC)/include/*.h $(TOPSRC)/tcclib.h "$(tccdir)/include"306 $(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"
319 mkdir -p "$(tccdir)/examples"307 mkdir -p "$(tccdir)/examples"
320 cp -r $(TOPSRC)/win32/examples/. "$(tccdir)/examples"308 cp -r $(TOPSRC)/win32/examples/. "$(tccdir)/examples"
321 $(INSTALL) $(TOPSRC)/tests/libtcc_test.c "$(tccdir)/examples"309 $(INSTALL) $(TOPSRC)/tests/libtcc_test.c "$(tccdir)/examples"
@@ -323,13 +311,18 @@ install-win: · 1 unmodified line
323 $(INSTALL) $(TOPSRC)/libtcc.h $(subst .dll,.def,$(LIBTCC)) "$(tccdir)/libtcc"311 $(INSTALL) $(TOPSRC)/libtcc.h $(subst .dll,.def,$(LIBTCC)) "$(tccdir)/libtcc"
324 mkdir -p "$(tccdir)/doc"312 mkdir -p "$(tccdir)/doc"
325 $(INSTALL) $(TOPSRC)/win32/tcc-win32.txt $(wildcard tcc-doc.html) "$(tccdir)/doc"313 $(INSTALL) $(TOPSRC)/win32/tcc-win32.txt $(wildcard tcc-doc.html) "$(tccdir)/doc"
314ifneq "$(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"
318endif
326 319
327# the msys-git shell works to configure && make except it does not have install320# the msys-git shell works to configure && make except it does not have install
328install-win : INSTALL = cp321install-win : INSTALL = cp
329 322
330# uninstall on windows323# uninstall on windows
331uninstall-win:324uninstall-win:
332 rm -rfv "$(tccdir)/"*325 rm -r "$(tccdir)/"*
333 326
334# --------------------------------------------------------------------------327# --------------------------------------------------------------------------
335# other stuff328# other stuff
@@ -341,7 +334,7 @@ ETAGS : ; etags $(TAGFILES) · 5 unmodified lines
341 334
342# create release tarball from *current* git branch (including tcc-doc.html335# create release tarball from *current* git branch (including tcc-doc.html
343# and converting two files to CRLF)336# and converting two files to CRLF)
344TCC-VERSION = $(VERSION)337TCC-VERSION = tcc-$(VERSION)
345tar: tcc-doc.html338tar: tcc-doc.html
346 mkdir $(TCC-VERSION)339 mkdir $(TCC-VERSION)
347 ( cd $(TCC-VERSION) && git --git-dir ../.git checkout -f )340 ( cd $(TCC-VERSION) && git --git-dir ../.git checkout -f )
@@ -361,11 +354,10 @@ test: · 13 unmodified lines
361 $(MAKE) -C tests354 $(MAKE) -C tests
362 355
363clean:356clean:
364 rm -f $(PROGS) $(PROGS_CROSS) tcc_p$(EXESUF) tcc.pod \357 rm -f $(PROGS) $(PROGS_CROSS) tcc_p$(EXESUF) tcc.pod
365 *~ *.o *.a *.so* *.out *.log lib*.def *.exe *.dll a.out \358 rm -f *~ *.o *.a *.so* *.out *.log lib*.def *.exe *.dll a.out tags TAGS
366 tags TAGS libtcc_test$(EXESUF)359 @$(MAKE) -C tests $@
367 $(MAKE) -C tests $@360 @$(MAKE) -C lib $@
368 $(MAKE) -C lib $@
369 361
370distclean: clean362distclean: clean
371 rm -f config.h config.mak config.texi tcc.1 tcc-doc.info tcc-doc.html363 rm -f config.h config.mak config.texi tcc.1 tcc-doc.info tcc-doc.html
@@ -389,12 +381,12 @@ help: · 17 unmodified lines
389 @echo "Cross compiler configuration:"381 @echo "Cross compiler configuration:"
390 @echo " make will read custom configuration for cross compilers from a file"382 @echo " make will read custom configuration for cross compilers from a file"
391 @echo " 'config-cross.mak' if present. For example for a windows->i386-linux"383 @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:"
393 @echo ""385 @echo ""
394 @echo " ROOT-i386 = {B}/i386-linux"386 @echo " ROOT-i386 = {B}/i386-linux"
395 @echo " CRT-i386 = $(ROOT-i386)/usr/lib"387 @echo " CRT-i386 = {B}/i386-linux/usr/lib"
396 @echo " LIB-i386 = $(ROOT-i386)/lib:$(ROOT-i386)/usr/lib"388 @echo " LIB-i386 = {B}/i386-linux/lib:{B}/i386-linux/usr/lib"
397 @echo " INC-i386 = {B}/lib/include:$(ROOT-i386)/usr/include"389 @echo " INC-i386 = {B}/lib/include:{B}/i386-linux/usr/include"
398 @echo " DEF-i386 += -D__linux__"390 @echo " DEF-i386 += -D__linux__"
399 @echo ""391 @echo ""
400 @echo "Other supported make targets:"392 @echo "Other supported make targets:"
configure+19−15
@@ -33,7 +33,7 @@ cross_prefix="" · 32 unmodified lines
33cc="gcc"33cc="gcc"
34ar="ar"34ar="ar"
35strip="strip"35strip="strip"
36cygwin="no"36noldl="no"
37gprof="no"37gprof="no"
38bigendian="no"38bigendian="no"
39mingw32="no"39mingw32="no"
@@ -53,28 +53,26 @@ cpu= · 13 unmodified lines
53# OS specific53# OS specific
54targetos=`uname`54targetos=`uname`
55case $targetos in55case $targetos in
56 Darwin) osx=yes;;56 Darwin)
57 MINGW*) mingw32=yes;;57 osx=yes
58 MSYS*) mingw32=yes;;58 ;;
59 CYGWIN*) mingw32=yes; cygwin=yes; cross_prefix="mingw32-";;59 MINGW*|MSYS*|CYGWIN*)
60 DragonFly) noldl=yes;;60 mingw32=yes
61 OpenBSD) noldl=yes;;61 ;;
62 FreeBSD) noldl=yes;;62 DragonFly|OpenBSD|FreeBSD|NetBSD)
63 NetBSD) noldl=yes;;63 noldl=yes
64 *) ;;64 ;;
65 *)
66 ;;
65esac67esac
66 68
67# find source path69# find source path
68# XXX: we assume an absolute path is given when launching configure,
69# except in './configure' case.
70source_path=${0%configure}70source_path=${0%configure}
71source_path=${source_path%/}71source_path=${source_path%/}
72source_path_used="yes"72source_path_used="yes"
73if test -z "$source_path" -o "$source_path" = "." ; then73if test -z "$source_path" -o "$source_path" = "." ; then
74 source_path=`pwd`74 source_path=`pwd`
75 source_path_used="no"75 source_path_used="no"
76 # mingw compilers might not understand cygwin paths
77 if test $cygwin = "yes"; then source_path="."; fi
78fi76fi
79 77
80for opt do78for opt do
@@ -130,7 +128,7 @@ for opt do · 49 unmodified lines
130 ;;128 ;;
131 --enable-gprof) gprof="yes"129 --enable-gprof) gprof="yes"
132 ;;130 ;;
133 --enable-mingw32) mingw32="yes" ; cross_prefix="i686-pc-mingw32-" ; cpu=x86131 --enable-mingw32) mingw32="yes"
134 ;;132 ;;
135 --enable-cross) build_cross="yes"133 --enable-cross) build_cross="yes"
136 ;;134 ;;
@@ -211,6 +209,12 @@ if test -z "$CFLAGS"; then · 74 unmodified lines
211fi209fi
212 210
213if test "$mingw32" = "yes" ; then211if 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
214 if test x"$tccdir" = x""; then218 if test x"$tccdir" = x""; then
215 tccdir="tcc"219 tccdir="tcc"
216 fi220 fi
lib/Makefile+8−10
@@ -7,6 +7,7 @@ include $(TOP)/Makefile · 6 unmodified lines
7VPATH = $(TOPSRC)/lib $(TOPSRC)/win32/lib7VPATH = $(TOPSRC)/lib $(TOPSRC)/win32/lib
8T = $(or $(CROSS_TARGET),$(NATIVE_TARGET),unknown)8T = $(or $(CROSS_TARGET),$(NATIVE_TARGET),unknown)
9X = $(if $(CROSS_TARGET),$(CROSS_TARGET)-)9X = $(if $(CROSS_TARGET),$(CROSS_TARGET)-)
10BIN = $(TOP)/libtcc1$(if $(CROSS_TARGET),-$(CROSS_TARGET)).a
10 11
11TCC = $(TOP)/$(X)tcc$(EXESUF)12TCC = $(TOP)/$(X)tcc$(EXESUF)
12XCC = $(TCC)13XCC = $(TCC)
@@ -25,25 +26,24 @@ ifeq ($(X),) · 12 unmodified lines
25 endif26 endif
26endif27endif
27 28
28ifeq ($(TARGETOS),Darwin)29ifdef CONFIG_OSX
29 XFLAGS += -D_ANSI_SOURCE30 XFLAGS += -D_ANSI_SOURCE
30 BCHECK_O =
31endif31endif
32 32
33ifeq ($(CONFIG_musl),yes)33ifeq ($(CONFIG_musl),yes)
34 BCHECK_O =34 BCHECK_O =
35endif35endif
36 36
37I386_O = libtcc1.o alloca86.o alloca86-bt.o $(BCHECK_O)37I386_O = libtcc1.o alloca86.o alloca86-bt.o
38X86_64_O = libtcc1.o alloca86_64.o alloca86_64-bt.o $(BCHECK_O)38X86_64_O = libtcc1.o alloca86_64.o alloca86_64-bt.o
39ARM_O = libtcc1.o armeabi.o alloca-arm.o39ARM_O = libtcc1.o armeabi.o alloca-arm.o
40ARM64_O = lib-arm64.o40ARM64_O = lib-arm64.o
41WIN_O = crt1.o crt1w.o wincrt1.o wincrt1w.o dllcrt1.o dllmain.o41WIN_O = crt1.o crt1w.o wincrt1.o wincrt1w.o dllcrt1.o dllmain.o
42 42
43OBJ-i386 = $(I386_O)43OBJ-i386 = $(I386_O) $(BCHECK_O)
44TGT-i386 = -DTCC_TARGET_I38644TGT-i386 = -DTCC_TARGET_I386
45 45
46OBJ-x86_64 = $(X86_64_O)46OBJ-x86_64 = $(X86_64_O) $(BCHECK_O)
47TGT-x86_64 = -DTCC_TARGET_X86_6447TGT-x86_64 = -DTCC_TARGET_X86_64
48 48
49OBJ-x86_64-osx = $(X86_64_O)49OBJ-x86_64-osx = $(X86_64_O)
@@ -55,17 +55,15 @@ TGT-arm = -DTCC_TARGET_ARM · 5 unmodified lines
55OBJ-arm64 = $(ARM64_O)55OBJ-arm64 = $(ARM64_O)
56TGT-arm64 = -DTCC_TARGET_ARM6456TGT-arm64 = -DTCC_TARGET_ARM64
57 57
58OBJ-i386-win32 = $(I386_O) chkstk.o $(WIN_O)58OBJ-i386-win32 = $(I386_O) chkstk.o bcheck.o $(WIN_O)
59TGT-i386-win32 = -DTCC_TARGET_I386 -DTCC_TARGET_PE59TGT-i386-win32 = -DTCC_TARGET_I386 -DTCC_TARGET_PE
60 60
61OBJ-x86_64-win32 = $(X86_64_O) chkstk.o $(WIN_O)61OBJ-x86_64-win32 = $(X86_64_O) chkstk.o bcheck.o $(WIN_O)
62TGT-x86_64-win32 = -DTCC_TARGET_X86_64 -DTCC_TARGET_PE62TGT-x86_64-win32 = -DTCC_TARGET_X86_64 -DTCC_TARGET_PE
63 63
64OBJ-arm-wince = $(ARM_O) $(WIN_O)64OBJ-arm-wince = $(ARM_O) $(WIN_O)
65TGT-arm-wince = -DTCC_TARGET_ARM -DTCC_TARGET_PE65TGT-arm-wince = -DTCC_TARGET_ARM -DTCC_TARGET_PE
66 66
67all : $(BIN)
68
69$(BIN) : $(patsubst %.o,$(X)%.o,$(OBJ-$T))67$(BIN) : $(patsubst %.o,$(X)%.o,$(OBJ-$T))
70 $(XAR) rcs $@ $^68 $(XAR) rcs $@ $^
71 69
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
1054 /* do not display line number if error */1054 /* do not display line number if error */
1055 file->line_num = 0;1055 file->line_num = 0;
1056 1056
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
1057 switch (obj_type) {1062 switch (obj_type) {
1058 case AFF_BINTYPE_REL:1063 case AFF_BINTYPE_REL:
1059 ret = tcc_load_object_file(s1, fd, 0);1064 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
1081 break;1086 break;
1082#endif1087#endif
1083 default:1088 default:
1084#if defined(TCC_TARGET_MACHO)1089#ifdef TCC_TARGET_PE
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)
1097 ret = pe_load_file(s1, filename, fd);1090 ret = pe_load_file(s1, filename, fd);
1098#else1091#else
1099 /* as GNU ld, consider it is an ld script if not recognized */1092 /* 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
1155/* the library name is the same as the argument of the '-l' option */1148/* the library name is the same as the argument of the '-l' option */
1156LIBTCCAPI int tcc_add_library(TCCState *s, const char *libraryname)1149LIBTCCAPI int tcc_add_library(TCCState *s, const char *libraryname)
1157{1150{
1158#if defined(TCC_TARGET_MACHO)1151#if defined TCC_TARGET_PE
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)
1162 const char *libs[] = { "%s/%s.def", "%s/lib%s.def", "%s/%s.dll", "%s/lib%s.dll", "%s/lib%s.a", NULL };1152 const char *libs[] = { "%s/%s.def", "%s/lib%s.def", "%s/%s.dll", "%s/lib%s.dll", "%s/lib%s.a", NULL };
1163 const char **pp = s->static_link ? libs + 4 : libs;1153 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;
1164#else1157#else
1165 const char *libs[] = { "%s/lib%s.so", "%s/lib%s.a", NULL };1158 const char *libs[] = { "%s/lib%s.so", "%s/lib%s.a", NULL };
1166 const char **pp = s->static_link ? libs + 1 : libs;1159 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
87{87{
88 Sym *sym;88 Sym *sym;
89 int op, label;89 int op, label;
90 unsigned long n;90 uint64_t n;
91 const char *p;91 const char *p;
92 92
93 switch(tok) {93 switch(tok) {
94 case TOK_PPNUM:94 case TOK_PPNUM:
95 p = tokc.str.data;95 p = tokc.str.data;
96 n = strtoul(p, (char **)&p, 0);96 n = strtoull(p, (char **)&p, 0);
97 if (*p == 'b' || *p == 'f') {97 if (*p == 'b' || *p == 'f') {
98 /* backward or forward label */98 /* backward or forward label */
99 label = asm_get_local_label_name(s1, n);99 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
906#else906#else
907 type = &int_type;907 type = &int_type;
908#endif908#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 }
913 size = type_size(type, &align);909 size = type_size(type, &align);
914 loc = (loc - size) & -align;910 loc = (loc - size) & -align;
915 sv.type.t = type->t;911 sv.type.t = type->t;
@@ -2383,11 +2379,6 @@ static void gen_cast(CType *type) · 1467 unmodified lines
2383 vpushi(0);2379 vpushi(0);
2384 gen_op(TOK_NE);2380 gen_op(TOK_NE);
2385 } else {2381 } 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 }
2391 /* we handle char/short/etc... with generic code */2382 /* we handle char/short/etc... with generic code */
2392 if (dbt != (VT_INT | VT_UNSIGNED) &&2383 if (dbt != (VT_INT | VT_UNSIGNED) &&
2393 dbt != (VT_LLONG | VT_UNSIGNED) &&2384 dbt != (VT_LLONG | VT_UNSIGNED) &&
tccpe.c+1−5
@@ -28,10 +28,6 @@ · 27 unmodified lines
28#define strnicmp strncasecmp28#define strnicmp strncasecmp
29#endif29#endif
30 30
31#ifndef MAX_PATH
32#define MAX_PATH 260
33#endif
34
35#ifdef TCC_TARGET_X86_6431#ifdef TCC_TARGET_X86_64
36# define ADDR3264 ULONGLONG32# define ADDR3264 ULONGLONG
37# define REL_TYPE_DIRECT R_X86_64_6433# define REL_TYPE_DIRECT R_X86_64_64
@@ -907,7 +903,7 @@ static void pe_build_exports(struct pe_info *pe) · 869 unmodified lines
907 struct pe_sort_sym **sorted, *p;903 struct pe_sort_sym **sorted, *p;
908 904
909 FILE *op;905 FILE *op;
910 char buf[MAX_PATH];906 char buf[260];
911 const char *dllname;907 const char *dllname;
912 const char *name;908 const char *name;
913 909
tccpp.c+31−1
@@ -1021,8 +1021,38 @@ ST_FUNC void restore_parse_state(ParseState *s) · 1020 unmodified lines
1021 tokc = s->tokc;1021 tokc = s->tokc;
1022}1022}
1023 1023
1024/* token string handling */1024#if 0
1025/* return the number of additional 'ints' necessary to store the
1026 token */
1027static 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
1025 1054
1055/* token string handling */
1026ST_INLN void tok_str_new(TokenString *s)1056ST_INLN void tok_str_new(TokenString *s)
1027{1057{
1028 s->str = NULL;1058 s->str = NULL;
tcctools.c+3−3
@@ -304,15 +304,15 @@ the_end: · 303 unmodified lines
304ST_FUNC int tcc_tool_impdef(TCCState *s1, int argc, char **argv)304ST_FUNC int tcc_tool_impdef(TCCState *s1, int argc, char **argv)
305{305{
306 int ret, v, i;306 int ret, v, i;
307 char infile[MAX_PATH];307 char infile[260];
308 char outfile[MAX_PATH];308 char outfile[260];
309 309
310 const char *file;310 const char *file;
311 char *p, *q;311 char *p, *q;
312 FILE *fp, *op;312 FILE *fp, *op;
313 313
314#ifdef _WIN32314#ifdef _WIN32
315 char path[MAX_PATH];315 char path[260];
316#endif316#endif
317 317
318 infile[0] = outfile[0] = 0;318 infile[0] = outfile[0] = 0;
tests/Makefile+13−18
@@ -5,7 +5,7 @@ · 4 unmodified lines
5TOP = ..5TOP = ..
6include $(TOP)/Makefile6include $(TOP)/Makefile
7VPATH = $(TOPSRC)/tests $(TOPSRC) $(TOP)7VPATH = $(TOPSRC)/tests $(TOPSRC) $(TOP)
8CFLAGS := $(filter-out -W% -g% -O%,$(CFLAGS)) -I$(TOPSRC)8CFLAGS := $(filter-out -W% -g% -O%,$(CFLAGS)) -I$(TOPSRC) $(LDFLAGS)
9 9
10# what tests to run10# what tests to run
11TESTS = \11TESTS = \
@@ -34,8 +34,8 @@ endif · 22 unmodified lines
34ifdef CONFIG_WIN3234ifdef CONFIG_WIN32
35 TESTS := $(filter-out $(BTESTS),$(TESTS))35 TESTS := $(filter-out $(BTESTS),$(TESTS))
36endif36endif
37ifeq ($(TARGETOS),Darwin)37ifdef CONFIG_OSX # -run only
38 TESTS := $(filter-out hello-exe test3 $(BTESTS),$(TESTS))38 TESTS := hello-run libtest tests2-dir pp-dir
39endif39endif
40ifeq (,$(filter arm64 i386 x86_64,$(ARCH)))40ifeq (,$(filter arm64 i386 x86_64,$(ARCH)))
41 TESTS := $(filter-out vla_test-run,$(TESTS))41 TESTS := $(filter-out vla_test-run,$(TESTS))
@@ -51,28 +51,23 @@ ifndef CONFIG_CROSS · 9 unmodified lines
51endif51endif
52 52
53ifdef CONFIG_WIN3253ifdef CONFIG_WIN32
54 PATH := $(CURDIR)/$(TOP):$(PATH) # for libtcc_test to find libtcc.dll54 SEP = $(if $(findstring :\,$(PATH)),;,:)
55endif55 PATH := $(CURDIR)/$(TOP)$(SEP)$(PATH) # for libtcc_test to find libtcc.dll
56
57ifeq ($(TARGETOS),Darwin)
58 CFLAGS += -Wl,-flat_namespace,-undefined,warning
59 TCCFLAGS += -D_ANSI_SOURCE
60 export MACOSX_DEPLOYMENT_TARGET:=10.2
61endif56endif
62 57
63RUN_TCC = $(NATIVE_DEFINES) -DONE_SOURCE -run $(TOPSRC)/tcc.c $(TCCFLAGS)58RUN_TCC = $(NATIVE_DEFINES) -DONE_SOURCE -run $(TOPSRC)/tcc.c $(TCCFLAGS)
64
65DISAS = objdump -d59DISAS = objdump -d
60DUMPTCC = (set -x; $(TOP)/tcc -vv; ldd $(TOP)/tcc; exit 1)
66 61
67all test : clean-s $(TESTS)62all test : clean-s $(TESTS)
68 63
69hello-exe: ../examples/ex1.c64hello-exe: ../examples/ex1.c
70 @echo ------------ $@ ------------65 @echo ------------ $@ ------------
71 $(TCC) $< -o hello$(EXESUF) || ($(TOP)/tcc -vv; exit 1) && ./hello$(EXESUF)66 $(TCC) $< -o hello$(EXESUF) && ./hello$(EXESUF) || $(DUMPTCC)
72 67
73hello-run: ../examples/ex1.c68hello-run: ../examples/ex1.c
74 @echo ------------ $@ ------------69 @echo ------------ $@ ------------
75 $(TCC) -run $<70 $(TCC) -run $< || $(DUMPTCC)
76 71
77libtest: libtcc_test$(EXESUF)72libtest: libtcc_test$(EXESUF)
78 @echo ------------ $@ ------------73 @echo ------------ $@ ------------
@@ -263,11 +258,11 @@ cache: tcc_g · 184 unmodified lines
263 258
264# clean259# clean
265clean:260clean:
266 rm -f *~ *.o *.a *.bin *.i *.ref *.out *.out? *.out?b *.cc *.gcc \261 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] \262 rm -f *-cc *-gcc *-tcc *.exe hello libtcc_test vla_test tcctest[1234]
268 ex? tcc_g *.def weaktest.*.txt263 rm -f ex? tcc_g weaktest.*.txt *.def
269 $(MAKE) -C tests2 $@264 @$(MAKE) -C tests2 $@
270 $(MAKE) -C pp $@265 @$(MAKE) -C pp $@
271 266
272# silent clean, used before running tests267# silent clean, used before running tests
273clean-s:268clean-s:
tests/tests2/Makefile+16−17
@@ -5,23 +5,6 @@ VPATH = $(SRC) · 4 unmodified lines
5 5
6TESTS = $(patsubst %.c,%.test,$(sort $(notdir $(wildcard $(SRC)/*.c))))6TESTS = $(patsubst %.c,%.test,$(sort $(notdir $(wildcard $(SRC)/*.c))))
7 7
8# 34_array_assignment.test -- array assignment is not in C standard
9SKIP = 34_array_assignment.test
10
11# some tests do not pass on all platforms, remove them for now
12ifeq ($(CONFIG_arm_eabi),yes) # not ARM soft-float
13 SKIP += 22_floating_point.test
14endif
15ifeq ($(TARGETOS),Darwin)
16 SKIP += 40_stdio.test
17endif
18ifeq ($(ARCH),x86_64)
19 SKIP += 73_arm64.test
20endif
21ifeq (,$(filter i386 x86_64,$(ARCH)))
22 SKIP += 85_asm-outside-function.test
23endif
24
25# Some tests might need arguments8# Some tests might need arguments
26ARGS =9ARGS =
2731_args.test : ARGS = arg1 arg2 arg3 arg4 arg51031_args.test : ARGS = arg1 arg2 arg3 arg4 arg5
@@ -42,6 +25,22 @@ ifeq (-$(findstring arm,$(ARCH))-,-arm-) · 14 unmodified lines
42FILTER += 2>&1 | grep -v 'warning: soft float ABI currently not supported'25FILTER += 2>&1 | grep -v 'warning: soft float ABI currently not supported'
43endif26endif
44 27
28# some tests do not pass on all platforms, remove them for now
29SKIP = 34_array_assignment.test # array assignment is not in C standard
30ifeq ($(CONFIG_arm_eabi),yes) # not ARM soft-float
31 SKIP += 22_floating_point.test
32endif
33ifdef CONFIG_OSX
34 SKIP += 40_stdio.test 42_function_pointer.test
35 FLAGS += -w
36endif
37ifeq ($(ARCH),x86_64)
38 SKIP += 73_arm64.test
39endif
40ifeq (,$(filter i386 x86_64,$(ARCH)))
41 SKIP += 85_asm-outside-function.test
42endif
43
45all test: $(filter-out $(SKIP),$(TESTS))44all test: $(filter-out $(SKIP),$(TESTS))
46 45
47%.test: %.c %.expect46%.test: %.c %.expect
win32/build-tcc.bat+1−1
@@ -5,7 +5,7 @@ · 4 unmodified lines
5@echo off5@echo off
6setlocal6setlocal
7 7
8set CC=gcc -Os -s8set CC=gcc -Os -s -static
9set /p VERSION= < ..\VERSION9set /p VERSION= < ..\VERSION
10set INST=10set INST=
11set DOC=no11set DOC=no
win32/include/_mingw.h+1−0
@@ -165,5 +165,6 @@ typedef struct localeinfo_struct _locale_tstruct,*_locale_t; · 164 unmodified lines
165#define __C89_NAMELESS165#define __C89_NAMELESS
166#define __MINGW_EXTENSION166#define __MINGW_EXTENSION
167#define WINAPI_FAMILY_PARTITION(X) 1167#define WINAPI_FAMILY_PARTITION(X) 1
168#define MINGW_HAS_SECURE_API
168 169
169#endif /* __MINGW_H */170#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