- 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
Unified · Split
| @@ -4,8 +4,8 @@ · 3 unmodified lines | ||
| 4 | 4 | # |
| 5 | 5 | |
| 6 | 6 | ifndef TOP |
| 7 | −TOP = . | |
| 8 | −INCLUDED = no | |
| 7 | + TOP = . | |
| 8 | + INCLUDED = no | |
| 9 | 9 | endif |
| 10 | 10 | |
| 11 | 11 | include $(TOP)/config.mak |
| @@ -31,26 +31,11 @@ VPATH = $(TOPSRC) · 19 unmodified lines | ||
| 31 | 31 | |
| 32 | 32 | ifdef CONFIG_WIN32 |
| 33 | 33 | ifneq ($(DISABLE_STATIC),no) |
| 34 | − LIBTCC = libtcc.dll | |
| 34 | + LIBTCC = libtcc$(DLLSUF) | |
| 35 | 35 | LIBTCCDEF = libtcc.def |
| 36 | 36 | endif |
| 37 | 37 | 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) | |
| 54 | 39 | else |
| 55 | 40 | LIBS=-lm |
| 56 | 41 | ifndef CONFIG_NOLDL |
| @@ -58,19 +43,19 @@ else · 1 unmodified line | ||
| 58 | 43 | endif |
| 59 | 44 | # make libtcc as static or dynamic library? |
| 60 | 45 | ifeq ($(DISABLE_STATIC),yes) |
| 61 | − LIBTCC=libtcc.so | |
| 46 | + LIBTCC=libtcc$(DLLSUF) | |
| 47 | + export LD_LIBRARY_PATH := $(CURDIR)/$(TOP) | |
| 62 | 48 | ifndef DISABLE_RPATH |
| 63 | 49 | LINK_LIBTCC += -Wl,-rpath,"$(libdir)" |
| 64 | − export LD_LIBRARY_PATH := $(CURDIR)/$(TOP) | |
| 65 | 50 | endif |
| 66 | 51 | endif |
| 67 | 52 | CFGWIN =-unx |
| 68 | 53 | 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 | |
| 74 | 59 | endif |
| 75 | 60 | |
| 76 | 61 | # 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 | ||
| 78 | 63 | TCCFLAGS-win = -B$(TOPSRC)/win32 -I$(TOPSRC)/include -I$(TOPSRC) -I$(TOP) -L$(TOP) |
| 79 | 64 | TCCFLAGS = $(TCCFLAGS$(CFGWIN)) |
| 80 | 65 | TCC = $(TOP)/tcc$(EXESUF) $(TCCFLAGS) |
| 66 | +ifdef CONFIG_OSX | |
| 67 | + TCCFLAGS += -D_ANSI_SOURCE | |
| 68 | +endif | |
| 81 | 69 | |
| 82 | 70 | CFLAGS_P = $(CFLAGS) -pg -static -DCONFIG_TCC_STATIC -DTCC_PROFILE |
| 83 | −LIBS_P= $(LIBS) | |
| 71 | +LIBS_P = $(LIBS) | |
| 84 | 72 | LDFLAGS_P = $(LDFLAGS) |
| 85 | 73 | |
| 86 | 74 | CONFIG_$(ARCH) = yes |
| 87 | 75 | NATIVE_DEFINES_$(CONFIG_i386) += -DTCC_TARGET_I386 |
| 88 | 76 | NATIVE_DEFINES_$(CONFIG_x86_64) += -DTCC_TARGET_X86_64 |
| 89 | 77 | 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 | |
| 91 | 79 | NATIVE_DEFINES_$(CONFIG_uClibc) += -DTCC_UCLIBC |
| 92 | 80 | NATIVE_DEFINES_$(CONFIG_musl) += -DTCC_MUSL |
| 93 | 81 | 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 | ||
| 117 | 105 | PROGS_CROSS = $(foreach X,$(TCC_X),$X-tcc$(EXESUF)) |
| 118 | 106 | LIBTCC1_CROSS = $(foreach X,$(LIBTCC1_X),libtcc1-$X.a) |
| 119 | 107 | |
| 120 | −ifdef CONFIG_CROSS | |
| 121 | −all : $(LIBTCC1_CROSS) $(PROGS_CROSS) | |
| 122 | −endif | |
| 123 | − | |
| 124 | 108 | # build cross compilers & libs |
| 125 | −cross: all $(LIBTCC1_CROSS) $(PROGS_CROSS) | |
| 109 | +cross: $(LIBTCC1_CROSS) $(PROGS_CROSS) | |
| 126 | 110 | |
| 127 | 111 | # build specific cross compiler & lib |
| 128 | 112 | cross-%: %-tcc$(EXESUF) libtcc1-%.a ; |
| @@ -130,6 +114,10 @@ cross-%: %-tcc$(EXESUF) libtcc1-%.a ; · 1 unmodified line | ||
| 130 | 114 | install: install$(CFGWIN) |
| 131 | 115 | uninstall: uninstall$(CFGWIN) |
| 132 | 116 | |
| 117 | +ifdef CONFIG_CROSS | |
| 118 | +all : cross | |
| 119 | +endif | |
| 120 | + | |
| 133 | 121 | # -------------------------------------------- |
| 134 | 122 | |
| 135 | 123 | T = $(or $(CROSS_TARGET),$(NATIVE_TARGET),unknown) |
| @@ -206,7 +194,7 @@ $(X)tcc.o : tcctools.c · 70 unmodified lines | ||
| 206 | 194 | $(X)arm-gen.o : arm-asm.c |
| 207 | 195 | |
| 208 | 196 | # Host Tiny C Compiler |
| 209 | −tcc$(EXESUF): $(X)tcc.o $(LIBTCC) | |
| 197 | +tcc$(EXESUF): tcc.o $(LIBTCC) | |
| 210 | 198 | $(CC) -o $@ $^ $(DEFINES) $(CFLAGS) $(LIBS) $(LDFLAGS) $(LINK_LIBTCC) |
| 211 | 199 | |
| 212 | 200 | # Cross Tiny C Compilers |
| @@ -218,7 +206,7 @@ $(CROSS_TARGET)-tcc$(EXESUF): $(TCC_FILES) · 5 unmodified lines | ||
| 218 | 206 | |
| 219 | 207 | # profiling version |
| 220 | 208 | 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) | |
| 222 | 210 | |
| 223 | 211 | # static libtcc library |
| 224 | 212 | libtcc.a: $(LIBTCC_OBJ) |
| @@ -226,13 +214,13 @@ libtcc.a: $(LIBTCC_OBJ) · 1 unmodified line | ||
| 226 | 214 | |
| 227 | 215 | # dynamic libtcc library |
| 228 | 216 | libtcc.so: $(LIBTCC_OBJ) |
| 229 | − $(CC) -shared -Wl,-soname,$@ -o $@ $^ $(LDFLAGS) | |
| 217 | + $(CC) -shared -Wl,-soname,$@ -o $@ $^ $(CFLAGS) $(LDFLAGS) | |
| 230 | 218 | |
| 231 | 219 | libtcc.so: CFLAGS+=-fPIC |
| 232 | 220 | |
| 233 | 221 | # windows dynamic libtcc library |
| 234 | 222 | libtcc.dll : $(LIBTCC_OBJ) |
| 235 | − $(CC) -shared $(LIBTCC_OBJ) -o $@ $(LDFLAGS) | |
| 223 | + $(CC) -shared -o $@ $^ $(CFLAGS) $(LDFLAGS) | |
| 236 | 224 | |
| 237 | 225 | libtcc.def : libtcc.dll tcc$(EXESUF) |
| 238 | 226 | ./tcc$(EXESUF) -impdef $< -o $@ |
| @@ -241,11 +229,11 @@ libtcc.dll : DEFINES += -DLIBTCC_AS_DLL · 2 unmodified lines | ||
| 241 | 229 | |
| 242 | 230 | # TinyCC runtime libraries |
| 243 | 231 | libtcc1.a : tcc$(EXESUF) FORCE |
| 244 | − @$(MAKE) -f lib/Makefile BIN=$@ $@ TOP=. --no-print-directory | |
| 232 | + @$(MAKE) -C lib | |
| 245 | 233 | |
| 246 | 234 | # Cross libtcc1.a |
| 247 | 235 | libtcc1-%.a : %-tcc$(EXESUF) FORCE |
| 248 | − @$(MAKE) -f lib/Makefile BIN=$@ $@ CROSS_TARGET=$* TOP=. --no-print-directory | |
| 236 | + @$(MAKE) -C lib CROSS_TARGET=$* | |
| 249 | 237 | |
| 250 | 238 | FORCE: |
| 251 | 239 | |
| @@ -290,19 +278,21 @@ install-unx: · 38 unmodified lines | ||
| 290 | 278 | $(call TRY-INSTALL,tcc.1,"$(mandir)/man1") |
| 291 | 279 | $(call TRY-INSTALL,tcc-doc.info,"$(infodir)") |
| 292 | 280 | $(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)" "" | |
| 296 | 282 | mkdir -p "$(tccdir)/win32/lib" |
| 297 | 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" | |
| 287 | +endif | |
| 298 | 288 | |
| 299 | 289 | # uninstall |
| 300 | 290 | 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)" | |
| 306 | 296 | |
| 307 | 297 | # install progs & libs on windows |
| 308 | 298 | install-win: |
| @@ -310,12 +300,10 @@ install-win: · 1 unmodified line | ||
| 310 | 300 | $(INSTALL) $(PROGS) $(subst libtcc.a,,$(LIBTCC)) $(PROGS_X) "$(tccdir)" |
| 311 | 301 | mkdir -p "$(tccdir)/lib" |
| 312 | 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 | 304 | mkdir -p "$(tccdir)/include" |
| 315 | 305 | cp -r $(TOPSRC)/win32/include/. "$(tccdir)/include" |
| 316 | 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 | 307 | mkdir -p "$(tccdir)/examples" |
| 320 | 308 | cp -r $(TOPSRC)/win32/examples/. "$(tccdir)/examples" |
| 321 | 309 | $(INSTALL) $(TOPSRC)/tests/libtcc_test.c "$(tccdir)/examples" |
| @@ -323,13 +311,18 @@ install-win: · 1 unmodified line | ||
| 323 | 311 | $(INSTALL) $(TOPSRC)/libtcc.h $(subst .dll,.def,$(LIBTCC)) "$(tccdir)/libtcc" |
| 324 | 312 | mkdir -p "$(tccdir)/doc" |
| 325 | 313 | $(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 | |
| 326 | 319 | |
| 327 | 320 | # the msys-git shell works to configure && make except it does not have install |
| 328 | 321 | install-win : INSTALL = cp |
| 329 | 322 | |
| 330 | 323 | # uninstall on windows |
| 331 | 324 | uninstall-win: |
| 332 | − rm -rfv "$(tccdir)/"* | |
| 325 | + rm -r "$(tccdir)/"* | |
| 333 | 326 | |
| 334 | 327 | # -------------------------------------------------------------------------- |
| 335 | 328 | # other stuff |
| @@ -341,7 +334,7 @@ ETAGS : ; etags $(TAGFILES) · 5 unmodified lines | ||
| 341 | 334 | |
| 342 | 335 | # create release tarball from *current* git branch (including tcc-doc.html |
| 343 | 336 | # and converting two files to CRLF) |
| 344 | −TCC-VERSION = $(VERSION) | |
| 337 | +TCC-VERSION = tcc-$(VERSION) | |
| 345 | 338 | tar: tcc-doc.html |
| 346 | 339 | mkdir $(TCC-VERSION) |
| 347 | 340 | ( cd $(TCC-VERSION) && git --git-dir ../.git checkout -f ) |
| @@ -361,11 +354,10 @@ test: · 13 unmodified lines | ||
| 361 | 354 | $(MAKE) -C tests |
| 362 | 355 | |
| 363 | 356 | 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 $@ | |
| 369 | 361 | |
| 370 | 362 | distclean: clean |
| 371 | 363 | 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 | 381 | @echo "Cross compiler configuration:" |
| 390 | 382 | @echo " make will read custom configuration for cross compilers from a file" |
| 391 | 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 | 385 | @echo "" |
| 394 | 386 | @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" | |
| 398 | 390 | @echo " DEF-i386 += -D__linux__" |
| 399 | 391 | @echo "" |
| 400 | 392 | @echo "Other supported make targets:" |
| @@ -33,7 +33,7 @@ cross_prefix="" · 32 unmodified lines | ||
| 33 | 33 | cc="gcc" |
| 34 | 34 | ar="ar" |
| 35 | 35 | strip="strip" |
| 36 | −cygwin="no" | |
| 36 | +noldl="no" | |
| 37 | 37 | gprof="no" |
| 38 | 38 | bigendian="no" |
| 39 | 39 | mingw32="no" |
| @@ -53,28 +53,26 @@ cpu= · 13 unmodified lines | ||
| 53 | 53 | # OS specific |
| 54 | 54 | targetos=`uname` |
| 55 | 55 | 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 | + ;; | |
| 65 | 67 | esac |
| 66 | 68 | |
| 67 | 69 | # find source path |
| 68 | −# XXX: we assume an absolute path is given when launching configure, | |
| 69 | −# except in './configure' case. | |
| 70 | 70 | source_path=${0%configure} |
| 71 | 71 | source_path=${source_path%/} |
| 72 | 72 | source_path_used="yes" |
| 73 | 73 | if test -z "$source_path" -o "$source_path" = "." ; then |
| 74 | 74 | source_path=`pwd` |
| 75 | 75 | source_path_used="no" |
| 76 | − # mingw compilers might not understand cygwin paths | |
| 77 | − if test $cygwin = "yes"; then source_path="."; fi | |
| 78 | 76 | fi |
| 79 | 77 | |
| 80 | 78 | for opt do |
| @@ -130,7 +128,7 @@ for opt do · 49 unmodified lines | ||
| 130 | 128 | ;; |
| 131 | 129 | --enable-gprof) gprof="yes" |
| 132 | 130 | ;; |
| 133 | − --enable-mingw32) mingw32="yes" ; cross_prefix="i686-pc-mingw32-" ; cpu=x86 | |
| 131 | + --enable-mingw32) mingw32="yes" | |
| 134 | 132 | ;; |
| 135 | 133 | --enable-cross) build_cross="yes" |
| 136 | 134 | ;; |
| @@ -211,6 +209,12 @@ if test -z "$CFLAGS"; then · 74 unmodified lines | ||
| 211 | 209 | fi |
| 212 | 210 | |
| 213 | 211 | 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 | |
| 214 | 218 | if test x"$tccdir" = x""; then |
| 215 | 219 | tccdir="tcc" |
| 216 | 220 | fi |
| @@ -7,6 +7,7 @@ include $(TOP)/Makefile · 6 unmodified lines | ||
| 7 | 7 | VPATH = $(TOPSRC)/lib $(TOPSRC)/win32/lib |
| 8 | 8 | T = $(or $(CROSS_TARGET),$(NATIVE_TARGET),unknown) |
| 9 | 9 | X = $(if $(CROSS_TARGET),$(CROSS_TARGET)-) |
| 10 | +BIN = $(TOP)/libtcc1$(if $(CROSS_TARGET),-$(CROSS_TARGET)).a | |
| 10 | 11 | |
| 11 | 12 | TCC = $(TOP)/$(X)tcc$(EXESUF) |
| 12 | 13 | XCC = $(TCC) |
| @@ -25,25 +26,24 @@ ifeq ($(X),) · 12 unmodified lines | ||
| 25 | 26 | endif |
| 26 | 27 | endif |
| 27 | 28 | |
| 28 | −ifeq ($(TARGETOS),Darwin) | |
| 29 | +ifdef CONFIG_OSX | |
| 29 | 30 | XFLAGS += -D_ANSI_SOURCE |
| 30 | − BCHECK_O = | |
| 31 | 31 | endif |
| 32 | 32 | |
| 33 | 33 | ifeq ($(CONFIG_musl),yes) |
| 34 | 34 | BCHECK_O = |
| 35 | 35 | endif |
| 36 | 36 | |
| 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 | |
| 39 | 39 | ARM_O = libtcc1.o armeabi.o alloca-arm.o |
| 40 | 40 | ARM64_O = lib-arm64.o |
| 41 | 41 | WIN_O = crt1.o crt1w.o wincrt1.o wincrt1w.o dllcrt1.o dllmain.o |
| 42 | 42 | |
| 43 | −OBJ-i386 = $(I386_O) | |
| 43 | +OBJ-i386 = $(I386_O) $(BCHECK_O) | |
| 44 | 44 | TGT-i386 = -DTCC_TARGET_I386 |
| 45 | 45 | |
| 46 | −OBJ-x86_64 = $(X86_64_O) | |
| 46 | +OBJ-x86_64 = $(X86_64_O) $(BCHECK_O) | |
| 47 | 47 | TGT-x86_64 = -DTCC_TARGET_X86_64 |
| 48 | 48 | |
| 49 | 49 | OBJ-x86_64-osx = $(X86_64_O) |
| @@ -55,17 +55,15 @@ TGT-arm = -DTCC_TARGET_ARM · 5 unmodified lines | ||
| 55 | 55 | OBJ-arm64 = $(ARM64_O) |
| 56 | 56 | TGT-arm64 = -DTCC_TARGET_ARM64 |
| 57 | 57 | |
| 58 | −OBJ-i386-win32 = $(I386_O) chkstk.o $(WIN_O) | |
| 58 | +OBJ-i386-win32 = $(I386_O) chkstk.o bcheck.o $(WIN_O) | |
| 59 | 59 | TGT-i386-win32 = -DTCC_TARGET_I386 -DTCC_TARGET_PE |
| 60 | 60 | |
| 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) | |
| 62 | 62 | TGT-x86_64-win32 = -DTCC_TARGET_X86_64 -DTCC_TARGET_PE |
| 63 | 63 | |
| 64 | 64 | OBJ-arm-wince = $(ARM_O) $(WIN_O) |
| 65 | 65 | TGT-arm-wince = -DTCC_TARGET_ARM -DTCC_TARGET_PE |
| 66 | 66 | |
| 67 | −all : $(BIN) | |
| 68 | − | |
| 69 | 67 | $(BIN) : $(patsubst %.o,$(X)%.o,$(OBJ-$T)) |
| 70 | 68 | $(XAR) rcs $@ $^ |
| 71 | 69 | |
| @@ -1054,6 +1054,11 @@ ST_FUNC int tcc_add_file_internal(TCCState *s1, const char *filename, int flags) · 1053 unmodified lines | ||
| 1054 | 1054 | /* do not display line number if error */ |
| 1055 | 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 | 1062 | switch (obj_type) { |
| 1058 | 1063 | case AFF_BINTYPE_REL: |
| 1059 | 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 | 1086 | break; |
| 1082 | 1087 | #endif |
| 1083 | 1088 | 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 | |
| 1097 | 1090 | ret = pe_load_file(s1, filename, fd); |
| 1098 | 1091 | #else |
| 1099 | 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 | 1148 | /* the library name is the same as the argument of the '-l' option */ |
| 1156 | 1149 | LIBTCCAPI int tcc_add_library(TCCState *s, const char *libraryname) |
| 1157 | 1150 | { |
| 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 | |
| 1162 | 1152 | const char *libs[] = { "%s/%s.def", "%s/lib%s.def", "%s/%s.dll", "%s/lib%s.dll", "%s/lib%s.a", NULL }; |
| 1163 | 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 | 1157 | #else |
| 1165 | 1158 | const char *libs[] = { "%s/lib%s.so", "%s/lib%s.a", NULL }; |
| 1166 | 1159 | const char **pp = s->static_link ? libs + 1 : libs; |
| @@ -87,13 +87,13 @@ static void asm_expr_unary(TCCState *s1, ExprValue *pe) · 86 unmodified lines | ||
| 87 | 87 | { |
| 88 | 88 | Sym *sym; |
| 89 | 89 | int op, label; |
| 90 | − unsigned long n; | |
| 90 | + uint64_t n; | |
| 91 | 91 | const char *p; |
| 92 | 92 | |
| 93 | 93 | switch(tok) { |
| 94 | 94 | case TOK_PPNUM: |
| 95 | 95 | p = tokc.str.data; |
| 96 | − n = strtoul(p, (char **)&p, 0); | |
| 96 | + n = strtoull(p, (char **)&p, 0); | |
| 97 | 97 | if (*p == 'b' || *p == 'f') { |
| 98 | 98 | /* backward or forward label */ |
| 99 | 99 | label = asm_get_local_label_name(s1, n); |
| @@ -906,10 +906,6 @@ ST_FUNC void save_reg_upstack(int r, int n) · 905 unmodified lines | ||
| 906 | 906 | #else |
| 907 | 907 | type = &int_type; |
| 908 | 908 | #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 | 909 | size = type_size(type, &align); |
| 914 | 910 | loc = (loc - size) & -align; |
| 915 | 911 | sv.type.t = type->t; |
| @@ -2383,11 +2379,6 @@ static void gen_cast(CType *type) · 1467 unmodified lines | ||
| 2383 | 2379 | vpushi(0); |
| 2384 | 2380 | gen_op(TOK_NE); |
| 2385 | 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 | 2382 | /* we handle char/short/etc... with generic code */ |
| 2392 | 2383 | if (dbt != (VT_INT | VT_UNSIGNED) && |
| 2393 | 2384 | dbt != (VT_LLONG | VT_UNSIGNED) && |
| @@ -28,10 +28,6 @@ · 27 unmodified lines | ||
| 28 | 28 | #define strnicmp strncasecmp |
| 29 | 29 | #endif |
| 30 | 30 | |
| 31 | −#ifndef MAX_PATH | |
| 32 | −#define MAX_PATH 260 | |
| 33 | −#endif | |
| 34 | − | |
| 35 | 31 | #ifdef TCC_TARGET_X86_64 |
| 36 | 32 | # define ADDR3264 ULONGLONG |
| 37 | 33 | # 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 | 903 | struct pe_sort_sym **sorted, *p; |
| 908 | 904 | |
| 909 | 905 | FILE *op; |
| 910 | − char buf[MAX_PATH]; | |
| 906 | + char buf[260]; | |
| 911 | 907 | const char *dllname; |
| 912 | 908 | const char *name; |
| 913 | 909 | |
| @@ -1021,8 +1021,38 @@ ST_FUNC void restore_parse_state(ParseState *s) · 1020 unmodified lines | ||
| 1021 | 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 */ | |
| 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 | |
| 1025 | 1054 | |
| 1055 | +/* token string handling */ | |
| 1026 | 1056 | ST_INLN void tok_str_new(TokenString *s) |
| 1027 | 1057 | { |
| 1028 | 1058 | s->str = NULL; |
| @@ -304,15 +304,15 @@ the_end: · 303 unmodified lines | ||
| 304 | 304 | ST_FUNC int tcc_tool_impdef(TCCState *s1, int argc, char **argv) |
| 305 | 305 | { |
| 306 | 306 | int ret, v, i; |
| 307 | − char infile[MAX_PATH]; | |
| 308 | − char outfile[MAX_PATH]; | |
| 307 | + char infile[260]; | |
| 308 | + char outfile[260]; | |
| 309 | 309 | |
| 310 | 310 | const char *file; |
| 311 | 311 | char *p, *q; |
| 312 | 312 | FILE *fp, *op; |
| 313 | 313 | |
| 314 | 314 | #ifdef _WIN32 |
| 315 | − char path[MAX_PATH]; | |
| 315 | + char path[260]; | |
| 316 | 316 | #endif |
| 317 | 317 | |
| 318 | 318 | infile[0] = outfile[0] = 0; |
| @@ -5,7 +5,7 @@ · 4 unmodified lines | ||
| 5 | 5 | TOP = .. |
| 6 | 6 | include $(TOP)/Makefile |
| 7 | 7 | 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) | |
| 9 | 9 | |
| 10 | 10 | # what tests to run |
| 11 | 11 | TESTS = \ |
| @@ -34,8 +34,8 @@ endif · 22 unmodified lines | ||
| 34 | 34 | ifdef CONFIG_WIN32 |
| 35 | 35 | TESTS := $(filter-out $(BTESTS),$(TESTS)) |
| 36 | 36 | 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 | |
| 39 | 39 | endif |
| 40 | 40 | ifeq (,$(filter arm64 i386 x86_64,$(ARCH))) |
| 41 | 41 | TESTS := $(filter-out vla_test-run,$(TESTS)) |
| @@ -51,28 +51,23 @@ ifndef CONFIG_CROSS · 9 unmodified lines | ||
| 51 | 51 | endif |
| 52 | 52 | |
| 53 | 53 | 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 | |
| 61 | 56 | endif |
| 62 | 57 | |
| 63 | 58 | RUN_TCC = $(NATIVE_DEFINES) -DONE_SOURCE -run $(TOPSRC)/tcc.c $(TCCFLAGS) |
| 64 | − | |
| 65 | 59 | DISAS = objdump -d |
| 60 | +DUMPTCC = (set -x; $(TOP)/tcc -vv; ldd $(TOP)/tcc; exit 1) | |
| 66 | 61 | |
| 67 | 62 | all test : clean-s $(TESTS) |
| 68 | 63 | |
| 69 | 64 | hello-exe: ../examples/ex1.c |
| 70 | 65 | @echo ------------ $@ ------------ |
| 71 | − $(TCC) $< -o hello$(EXESUF) || ($(TOP)/tcc -vv; exit 1) && ./hello$(EXESUF) | |
| 66 | + $(TCC) $< -o hello$(EXESUF) && ./hello$(EXESUF) || $(DUMPTCC) | |
| 72 | 67 | |
| 73 | 68 | hello-run: ../examples/ex1.c |
| 74 | 69 | @echo ------------ $@ ------------ |
| 75 | − $(TCC) -run $< | |
| 70 | + $(TCC) -run $< || $(DUMPTCC) | |
| 76 | 71 | |
| 77 | 72 | libtest: libtcc_test$(EXESUF) |
| 78 | 73 | @echo ------------ $@ ------------ |
| @@ -263,11 +258,11 @@ cache: tcc_g · 184 unmodified lines | ||
| 263 | 258 | |
| 264 | 259 | # clean |
| 265 | 260 | 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 $@ | |
| 271 | 266 | |
| 272 | 267 | # silent clean, used before running tests |
| 273 | 268 | clean-s: |
| @@ -5,23 +5,6 @@ VPATH = $(SRC) · 4 unmodified lines | ||
| 5 | 5 | |
| 6 | 6 | TESTS = $(patsubst %.c,%.test,$(sort $(notdir $(wildcard $(SRC)/*.c)))) |
| 7 | 7 | |
| 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 | − | |
| 25 | 8 | # Some tests might need arguments |
| 26 | 9 | ARGS = |
| 27 | 10 | 31_args.test : ARGS = arg1 arg2 arg3 arg4 arg5 |
| @@ -42,6 +25,22 @@ ifeq (-$(findstring arm,$(ARCH))-,-arm-) · 14 unmodified lines | ||
| 42 | 25 | FILTER += 2>&1 | grep -v 'warning: soft float ABI currently not supported' |
| 43 | 26 | endif |
| 44 | 27 | |
| 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 | + | |
| 45 | 44 | all test: $(filter-out $(SKIP),$(TESTS)) |
| 46 | 45 | |
| 47 | 46 | %.test: %.c %.expect |
| @@ -5,7 +5,7 @@ · 4 unmodified lines | ||
| 5 | 5 | @echo off |
| 6 | 6 | setlocal |
| 7 | 7 | |
| 8 | −set CC=gcc -Os -s | |
| 8 | +set CC=gcc -Os -s -static | |
| 9 | 9 | set /p VERSION= < ..\VERSION |
| 10 | 10 | set INST= |
| 11 | 11 | set DOC=no |
| @@ -165,5 +165,6 @@ typedef struct localeinfo_struct _locale_tstruct,*_locale_t; · 164 unmodified lines | ||
| 165 | 165 | #define __C89_NAMELESS |
| 166 | 166 | #define __MINGW_EXTENSION |
| 167 | 167 | #define WINAPI_FAMILY_PARTITION(X) 1 |
| 168 | +#define MINGW_HAS_SECURE_API | |
| 168 | 169 | |
| 169 | 170 | #endif /* __MINGW_H */ |