History

configury update & bump VERSION to 0.9.28rc

configure: - option --targetos=... for cross build - cleanup win32/build-tcc.bat: - option -b <bindir> - make 'libtcc1.a' and cross-prefix-libtcc1.a (same convention as with makefile) Makefile: - streamline tcov-tests, help, etc. workflow/build.xml: simplify - using "windows-2019" runner (instead of windows-latest) because its msys seems more complete and has no problems with the 96_nodata_wanted.test either. Changelog,TODO,USES,tcc-doc.texi: update

grischka committed 3 years ago

Commit 086870a1 parent 8c5fe8713 files · +432 −363Browse files

Unified · Split

13 files
  1. .github/workflows/build.yml +19 −55
  2. .gitignore +1 −1
  3. Changelog +14 −7
  4. Makefile +50 −62
  5. TODO +2 −1
  6. USES +48 −0
  7. VERSION +1 −1
  8. configure +235 −180
  9. conftest.c +6 −8
  10. tcc-doc.texi +6 −5
  11. tests/pp/Makefile +2 −2
  12. tests/tests2/Makefile +4 −4
  13. win32/build-tcc.bat +44 −37
.github/workflows/build.yml+19−55
@@ -1,68 +1,32 @@
1name: build and run tests1name: build and run tests
2
2on:3on:
3 push:4 push:
4 branches: [ mob ]5 branches: [ mob ]
5 pull_request:6
6 branches: [ mob ]
7jobs:7jobs:
8 build-release-linux-i686-amd64:8 test-x86_64-linux:
9 name: tinycc master linux/amd64
10 runs-on: ubuntu-20.049 runs-on: ubuntu-20.04
11 steps:10 steps:
12 - uses: actions/checkout@v211 - uses: actions/checkout@v3
13 - name: Install dependencies12 - name: make & test tcc
14 run: sudo apt-get install -y13 run: ./configure && make && make test -k
15 gcc
16 # see what's available in /usr/bin
17 - name: see what's available
18 run: ls -l /usr/bin
19 # build project amd64
20 - name: build amd64
21 run: |
22 ./configure
23 make
24 # run tests
25 - name: run test_exs amd64
26 run: |
27 make test
28 14
29 build-release-osx-amd64:15 test-x86_64-osx:
30 name: tinycc master osx/amd64
31 runs-on: macos-1116 runs-on: macos-11
32 steps:17 steps:
33 - uses: actions/checkout@v218 - uses: actions/checkout@v3
34 # see what's available in /usr/bin19 - name: make & test tcc
35 - name: see what's available20 run: ./configure && make && make test -k
36 run: ls -l /usr/bin
37 # build project amd64
38 - name: build amd64
39 run: |
40 ./configure
41 make
42 # run tests
43 - name: run test_exs amd64
44 run: |
45 make test
46 21
47 build-release-windows-amd64-on-windows:22 test-x86_64-win32:
48 name: tinycc master windows/amd64 on Windows23 runs-on: windows-2019
49 runs-on: windows-latest
50 steps:24 steps:
51 - uses: actions/checkout@v225 - uses: actions/checkout@v3
52 - uses: msys2/setup-msys2@v226 - name: make & test tcc
53 # build project amd6427 shell: cmd
54 - name: build amd64
55 run: |
56 msys2 -c './configure'
57 make
58 # silency failing tests
59 - name: silence 96_nodata_wanted
60 run: |
61 pushd .\tests\tests2
62 Get-Content .\96_nodata_wanted.expect -TotalCount 2 | Out-File .\96_nodata_wanted.expect2 -Encoding default
63 mv .\96_nodata_wanted.expect2 .\96_nodata_wanted.expect -force
64 popd
65 # run tests
66 - name: run test_exs amd64
67 run: |28 run: |
68 make test29 set MSYS2_PATH_TYPE=inherit
30 set MSYSTEM=MINGW64
31 set CHERE_INVOKING=yes
32 C:\msys64\usr\bin\bash -l -c "./configure && make && make test -k"
.gitignore+1−1
@@ -31,9 +31,9 @@ tags · 30 unmodified lines
31TAGS31TAGS
32tcc.132tcc.1
33*.pod33*.pod
34*.tcov
34tcc-doc.html35tcc-doc.html
35tcc-doc.info36tcc-doc.info
36tcc_c.tcov
37 37
38win32/doc38win32/doc
39win32/examples/libtcc_test.c39win32/examples/libtcc_test.c
Changelog+14−7
@@ -1,19 +1,26 @@
1version 0.9.28:1version 0.9.28:
2 2
3User interface:3User interface:
4- new tcc -ar x and t flags (herman ten brugge)4- -b : bounds checker much improved (herman ten brugge)
5- -bt : support for standalone backtraces also (grischka)
6- -gdwarf : debug format (herman ten brugge)
7- -M, -MM, and -MMD (Arthur Williams)
8- -W[no-]error=<option> (Steffen Nurpmeso)
5 9
6Platforms:10Platforms:
7- new RISC-V (riscv64) target11- new RISC-V (riscv64) target (Michael Matz)
8- native macOS support for x86_64/arm64 (Herman ten Brugge)12- native macOS support for x86_64 (Michael Matz, Herman ten Brugge)
13- arm and riscv64 assemblers (Danny Milosavljevic)
14- Android support with position independent executables (grischka)
9 15
10Features:16Features:
11- Improved support for C1117- _Static_assert() (matthias)
12- C11 _Static_assert support (matthias)18- __attribute__ ((cleanup(func))) (matthias)
19- stdatomic (Dmitry Selyutin)
20- asm goto ("jmp %l[label]" : : : : label) (Michael Matz)
13 21
14Fixes:22Fixes:
15- fix preprocessor line (#line) directive (Herman ten Brugge)23- ... many, see git shortlog release_0_9_27...release_0_9_27
16Many more! see also git shortlog release_0_9_27...HEAD
17 24
18Version 0.9.27:25Version 0.9.27:
19 26
Makefile+50−62
@@ -30,13 +30,19 @@ ifdef CONFIG_WIN32 · 29 unmodified lines
30 LIBTCC = libtcc$(DLLSUF)30 LIBTCC = libtcc$(DLLSUF)
31 LIBTCCDEF = libtcc.def31 LIBTCCDEF = libtcc.def
32 endif32 endif
33 ifneq ($(CONFIG_debug),yes)
34 LDFLAGS += -s
35 endif
33 NATIVE_TARGET = $(ARCH)-win$(if $(findstring arm,$(ARCH)),ce,32)36 NATIVE_TARGET = $(ARCH)-win$(if $(findstring arm,$(ARCH)),ce,32)
34else37else
35 CFG = -unx38 CFG = -unx
36 LIBS=-lm -lpthread39 LIBS+=-lm
37 ifneq ($(CONFIG_ldl),no)40 ifneq ($(CONFIG_ldl),no)
38 LIBS+=-ldl41 LIBS+=-ldl
39 endif42 endif
43 ifneq ($(CONFIG_pthread),no)
44 LIBS+=-lpthread
45 endif
40 # make libtcc as static or dynamic library?46 # make libtcc as static or dynamic library?
41 ifeq ($(CONFIG_static),no)47 ifeq ($(CONFIG_static),no)
42 LIBTCC=libtcc$(DLLSUF)48 LIBTCC=libtcc$(DLLSUF)
@@ -68,11 +74,8 @@ endif · 25 unmodified lines
68TCCFLAGS-unx = -B$(TOP) -I$(TOPSRC)/include -I$(TOPSRC) -I$(TOP)74TCCFLAGS-unx = -B$(TOP) -I$(TOPSRC)/include -I$(TOPSRC) -I$(TOP)
69TCCFLAGS-win = -B$(TOPSRC)/win32 -I$(TOPSRC)/include -I$(TOPSRC) -I$(TOP) -L$(TOP)75TCCFLAGS-win = -B$(TOPSRC)/win32 -I$(TOPSRC)/include -I$(TOPSRC) -I$(TOP) -L$(TOP)
70TCCFLAGS = $(TCCFLAGS$(CFG))76TCCFLAGS = $(TCCFLAGS$(CFG))
71ifdef USE_TCC_C77TCC_LOCAL = $(TOP)/tcc$(EXESUF)
72TCC = $(TOP)/tcc_c$(EXESUF) $(TCCFLAGS)78TCC = $(TCC_LOCAL) $(TCCFLAGS)
73else
74TCC = $(TOP)/tcc$(EXESUF) $(TCCFLAGS)
75endif
76 79
77CFLAGS_P = $(CFLAGS) -pg -static -DCONFIG_TCC_STATIC -DTCC_PROFILE80CFLAGS_P = $(CFLAGS) -pg -static -DCONFIG_TCC_STATIC -DTCC_PROFILE
78LIBS_P = $(LIBS)81LIBS_P = $(LIBS)
@@ -181,11 +184,8 @@ DEFINES += $(if $(ELF-$T),-DCONFIG_TCC_ELFINTERP="\"$(ELF-$T)\"") · 102 unmodified lines
181DEFINES += $(DEF-$(or $(findstring win,$T),unx))184DEFINES += $(DEF-$(or $(findstring win,$T),unx))
182 185
183ifneq ($(X),)186ifneq ($(X),)
184ifeq ($(CONFIG_WIN32),yes)
185DEF-win += -DCONFIG_TCC_CROSSPREFIX="\"$X\""
186DEF-unx += -DCONFIG_TCC_CROSSPREFIX="\"lib/$X\""
187else
188DEF-all += -DCONFIG_TCC_CROSSPREFIX="\"$X\""187DEF-all += -DCONFIG_TCC_CROSSPREFIX="\"$X\""
188ifneq ($(CONFIG_WIN32),yes)
189DEF-win += -DCONFIG_TCCDIR="\"$(tccdir)/win32\""189DEF-win += -DCONFIG_TCCDIR="\"$(tccdir)/win32\""
190endif190endif
191endif191endif
@@ -249,17 +249,14 @@ endif · 57 unmodified lines
249 249
250GITHASH:=$(shell git rev-parse --abbrev-ref HEAD 2>/dev/null || echo no)250GITHASH:=$(shell git rev-parse --abbrev-ref HEAD 2>/dev/null || echo no)
251ifneq ($(GITHASH),no)251ifneq ($(GITHASH),no)
252GITHASH:=$(shell git log -1 --pretty='format:%cs $(GITHASH)@%h')$(shell git diff --quiet || echo '*')252GITHASH:=$(shell git log -1 --date=short --pretty='format:%cd $(GITHASH)@%h')
253DEF_GITHASH:= -DTCC_GITHASH="\"$(GITHASH)\""253GITMODF:=$(shell git diff --quiet || echo '*')
254DEF_GITHASH:= -DTCC_GITHASH="\"$(GITHASH)$(GITMODF)\""
254endif255endif
255 256
256ifeq ($(CONFIG_debug),yes)257ifeq ($(CONFIG_debug),yes)
257CFLAGS += -g258CFLAGS += -g
258LDFLAGS += -g259LDFLAGS += -g
259else
260ifndef CONFIG_OSX
261LDFLAGS += -s
262endif
263endif260endif
264 261
265# convert "include/tccdefs.h" to "tccdefs_.h"262# convert "include/tccdefs.h" to "tccdefs_.h"
@@ -335,7 +332,11 @@ libtcc1.a : tcc$(EXESUF) FORCE · 69 unmodified lines
335.PRECIOUS: %-libtcc1.a332.PRECIOUS: %-libtcc1.a
336FORCE:333FORCE:
337 334
338run-if = $(if $(shell command -v $1),$S $1 $2)335# WHICH = which $1 2>/dev/null
336# some versions of gnu-make do not recognize 'command' as a shell builtin
337WHICH = sh -c 'command -v $1'
338
339run-if = $(if $(shell $(call WHICH,$1)),$S $1 $2)
339S = $(if $(findstring yes,$(SILENT)),@$(info * $@))340S = $(if $(findstring yes,$(SILENT)),@$(info * $@))
340 341
341# --------------------------------------------------------------------------342# --------------------------------------------------------------------------
@@ -348,7 +349,7 @@ tcc-doc.info: tcc-doc.texi · 6 unmodified lines
348 349
349tcc.1 : tcc-doc.pod350tcc.1 : tcc-doc.pod
350 $(call run-if,pod2man,--section=1 --center="Tiny C Compiler" \351 $(call run-if,pod2man,--section=1 --center="Tiny C Compiler" \
351 --release="$(VERSION)" $< >$@ && rm -f $<)352 --release="$(VERSION)" $< >$@)
352%.pod : %.texi353%.pod : %.texi
353 $(call run-if,perl,$(TOPSRC)/texi2pod.pl $< $@)354 $(call run-if,perl,$(TOPSRC)/texi2pod.pl $< $@)
354 355
@@ -392,8 +393,9 @@ endif · 37 unmodified lines
392 393
393# uninstall394# uninstall
394uninstall-unx:395uninstall-unx:
395 @rm -fv $(foreach P,$(PROGS) $(PROGS_CROSS),"$(bindir)/$P")396 @rm -fv $(addprefix "$(bindir)/",$(PROGS) $(PROGS_CROSS))
396 @rm -fv "$(libdir)/libtcc.a" "$(libdir)/libtcc.so" "$(libdir)/libtcc.dylib" "$(includedir)/libtcc.h"397 @rm -fv $(addprefix "$(libdir)/", libtcc*.a libtcc*.so libtcc.dylib,$P)
398 @rm -fv $(addprefix "$(includedir)/", libtcc.h)
397 @rm -fv "$(mandir)/man1/tcc.1" "$(infodir)/tcc-doc.info"399 @rm -fv "$(mandir)/man1/tcc.1" "$(infodir)/tcc-doc.info"
398 @rm -fv "$(docdir)/tcc-doc.html"400 @rm -fv "$(docdir)/tcc-doc.html"
399 @rm -frv "$(tccdir)"401 @rm -frv "$(tccdir)"
@@ -415,17 +417,19 @@ ifneq "$(wildcard $(LIBTCC1_U))" "" · 15 unmodified lines
415 $(call IF,$(TOPSRC)/include/*.h $(TOPSRC)/tcclib.h,"$(tccdir)/lib/include")417 $(call IF,$(TOPSRC)/include/*.h $(TOPSRC)/tcclib.h,"$(tccdir)/lib/include")
416endif418endif
417 419
418# the msys-git shell works to configure && make except it does not have install
419ifeq ($(CONFIG_WIN32)-$(shell command -v install || echo no),yes-no)
420install-win : INSTALL = cp
421install-win : INSTALLBIN = cp
422endif
423
424# uninstall on windows420# uninstall on windows
425uninstall-win:421uninstall-win:
426 @rm -fv $(foreach P,libtcc.dll $(PROGS) *-tcc.exe,"$(bindir)"/$P)422 @rm -fv $(addprefix "$(bindir)/", libtcc*.dll $(PROGS) *-tcc.exe)
427 @rm -fr $(foreach P,doc examples include lib libtcc,"$(tccdir)/$P"/*)423 @rm -fr $(foreach P,doc examples include lib libtcc,"$(tccdir)/$P/*")
428 @rm -frv $(foreach P,doc examples include lib libtcc,"$(tccdir)/$P")424 @rm -frv $(addprefix "$(tccdir)/", doc examples include lib libtcc)
425
426# the msys-git shell works to configure && make except it does not have install
427ifeq ($(OS),Windows_NT)
428ifeq ($(shell $(call WHICH,install) || echo no),no)
429INSTALL = cp
430INSTALLBIN = cp
431endif
432endif
429 433
430# --------------------------------------------------------------------------434# --------------------------------------------------------------------------
431# other stuff435# other stuff
@@ -459,66 +463,50 @@ test: · 27 unmodified lines
459# run test(s) from tests2 subdir (see make help)463# run test(s) from tests2 subdir (see make help)
460tests2.%:464tests2.%:
461 @$(MAKE) -C tests/tests2 $@465 @$(MAKE) -C tests/tests2 $@
462 466# run test(s) from testspp subdir (see make help)
463testspp.%:467testspp.%:
464 @$(MAKE) -C tests/pp $@468 @$(MAKE) -C tests/pp $@
465 469# run tests with code coverage
466# run all tests with code coverage470tcov-tes% : tcc_c$(EXESUF)
471 @rm -f $<.tcov
472 @$(MAKE) --no-print-directory TCC_LOCAL=$(CURDIR)/$< tes$*
467tcc_c$(EXESUF): $($T_FILES)473tcc_c$(EXESUF): $($T_FILES)
468 @${TCC} -o $@ -ftest-coverage $< $(DEFINES) $(CFLAGS) $(LIBS) $(LDFLAGS)474 $S$(TCC) tcc.c -o $@ -ftest-coverage $(DEFINES)
469testc: tcc_c$(EXESUF)
470 @rm -f tcc_c.tcov
471 @USE_TCC_C=yes $(MAKE) -C tests
472testc2.%: tcc_c$(EXESUF)
473 @rm -f tcc_c.tcov
474 @USE_TCC_C=yes $(MAKE) -C tests/tests2 $@
475testcpp.%: tcc_c$(EXESUF)
476 @rm -f tcc_c.tcov
477 @USE_TCC_C=yes $(MAKE) -C tests/pp $@
478 475
479clean:476clean:
480 @rm -f tcc$(EXESUF) tcc_c$(EXESUF) tcc_p$(EXESUF) *-tcc$(EXESUF) tags ETAGS *.pod477 @rm -f tcc$(EXESUF) tcc_c$(EXESUF) tcc_p$(EXESUF) *-tcc$(EXESUF)
481 @rm -f *.o *.a *.so* *.out *.log lib*.def *.exe *.dll a.out *.dylib *_.h478 @rm -f tags ETAGS *.o *.a *.so* *.out *.log lib*.def *.exe *.dll
479 @rm -f a.out *.dylib *_.h *.pod *.tcov
482 @$(MAKE) -s -C lib $@480 @$(MAKE) -s -C lib $@
483 @$(MAKE) -s -C tests $@481 @$(MAKE) -s -C tests $@
484 482
485distclean: clean483distclean: clean
486 @rm -f config.h config.mak config.texi484 @rm -vf config.h config.mak config.texi
487 @rm -f $(TCCDOCS)485 @rm -vf $(TCCDOCS)
488 486
489.PHONY: all clean test tar tags ETAGS doc distclean install uninstall FORCE487.PHONY: all clean test tar tags ETAGS doc distclean install uninstall FORCE
490 488
491help:489help:
492 @echo "make"490 @echo "make"
493 @echo " build native compiler (from separate objects)"491 @echo " build native compiler (from separate objects)"
494 @echo ""
495 @echo "make cross"492 @echo "make cross"
496 @echo " build cross compilers (from one source)"493 @echo " build cross compilers (from one source)"
497 @echo ""
498 @echo "make ONE_SOURCE=no/yes SILENT=no/yes"494 @echo "make ONE_SOURCE=no/yes SILENT=no/yes"
499 @echo " force building from separate/one object(s), less/more silently"495 @echo " force building from separate/one object(s), less/more silently"
500 @echo ""
501 @echo "make cross-TARGET"496 @echo "make cross-TARGET"
502 @echo " build one specific cross compiler for 'TARGET'. Currently supported:"497 @echo " build one specific cross compiler for 'TARGET'. Currently supported:"
503 @echo " $(wordlist 1,6,$(TCC_X))"498 @echo " $(wordlist 1,8,$(TCC_X))"
504 @echo " $(wordlist 7,99,$(TCC_X))"499 @echo " $(wordlist 9,99,$(TCC_X))"
505 @echo ""
506 @echo "make test"500 @echo "make test"
507 @echo " run all tests"501 @echo " run all tests"
508 @echo ""502 @echo "make tests2.all / make tests2.37 / make tests2.37+"
509 @echo "make tests2.all / make tests2.37 / make tests2.37+ / make tests2.37-"503 @echo " run all/single test(s) from tests2, optionally update .expect"
510 @echo " run all/single test(s) from tests2, optionally update .expect, display"
511 @echo ""
512 @echo "make testspp.all / make testspp.17"504 @echo "make testspp.all / make testspp.17"
513 @echo " run all/single test(s) from tests/pp"505 @echo " run all/single test(s) from tests/pp"
514 @echo ""506 @echo "make tcov-test / tcov-tests2... / tcov-testspp..."
515 @echo "make testc / testc2.all / testc2.37 / testc2.37+ / testc2.37-"507 @echo " run tests as above with code coverage. After test(s) see tcc_c$(EXESUF).tcov"
516 @echo "make testcpp.all / make testcpp.17"
517 @echo " run tests with code coverage. After test(s) see tcc_c.tcov"
518 @echo ""
519 @echo "Other supported make targets:"508 @echo "Other supported make targets:"
520 @echo " install install-strip doc clean tags ETAGS tar distclean help"509 @echo " install install-strip doc clean tags ETAGS tar distclean help"
521 @echo ""
522 @echo "Custom configuration:"510 @echo "Custom configuration:"
523 @echo " The makefile includes a file 'config-extra.mak' if it is present."511 @echo " The makefile includes a file 'config-extra.mak' if it is present."
524 @echo " This file may contain some custom configuration. For example:"512 @echo " This file may contain some custom configuration. For example:"
TODO+2−1
@@ -1,7 +1,8 @@
1TODO list:1TODO list:
2 2
3Releases:3Releases:
4- release tcc on a regular basis (which interval? 3 months?)4
5- release tcc on a regular basis
5 6
6Bugs:7Bugs:
7 8
USES+48−0
@@ -7,6 +7,7 @@ bigz An infinite precision Z & Q library. · 6 unmodified lines
7gawk GNU awk.7gawk GNU awk.
8gmp Library for arbitrary precision arithmetic.8gmp Library for arbitrary precision arithmetic.
9gnumake GNU makefile.9gnumake GNU makefile.
10gnu mes using tinycc to bootstrap a system
10mpfr Multiple-precision floating-point library.11mpfr Multiple-precision floating-point library.
11mpc Complex floating-point library with exact rounding.12mpc Complex floating-point library with exact rounding.
12mpv A free, open source, and cross-platform media player.13mpv A free, open source, and cross-platform media player.
@@ -18,3 +19,50 @@ tcc Tiny CC which compiles itself. · 5 unmodified lines
18zlib Lossless data-compression library.19zlib Lossless data-compression library.
19 20
20(*) This list is ordered by name.21(*) This list is ordered by name.
22
23
24
25Forks & Experiments
26-------------------
27
28arm-thumb target
29 by Erlend Sveen <erlend.sveen@hotmail.com>
30 https://git.erlendjs.no/erlendjs/tinycc.git
31
32riscv32 target
33 by Sam Ellicott <sellicott@cedarville.edu>
34 https://github.com/sellicott/tcc-riscv32.git
35
36Transputer target
37 by David Smith <agentdavo@mac.com>
38 https://github.com/agentdavo/tinycc-transputer
39
40tcc-65816 - Tiny C Compiler for 65816 CPU (based on V0.9.23) from SNES-SDK
41 https://github.com/nArnoSNES/tcc-65816
42
43PE-UEFI arm64
44 by Andrei Warkentin <andrey.warkentin@gmail.com>
45 https://github.com/andreiw/tinycc/
46
47TCCLS - global register allocator (proof of concept)
48 by Sebastian Falbesoner <sebastian.falbesoner@gmail.com>
49 https://bitbucket.org/theStack/tccls_poc.git
50
51softfloat
52 by Giovanni Mascellani <gio@debian.org>
53 https://gitlab.com/giomasce/tinycc.git
54
55optimize 386
56 by Jason Hood <jadoxa@yahoo.com.au>
57
58tcctcl : tcl binding
59 https://code.google.com/archive/p/tcltcc/
60
61tcc4tcl : tcl binding
62 https://chiselapp.com/user/rkeene/repository/tcc4tcl/index
63
64lua-tcc : allows a Lua script to compile C code
65 https://github.com/javierguerragiraldez/lua-tcc
66
67tcclua : semi-high-level bindings for `libtcc`
68 https://github.com/nucular/tcclua/blob/master/tcc.lua
VERSION+1−1
@@ -1 +1 @@
10.9.2710.9.28rc
configure+235−180
@@ -47,70 +47,19 @@ gcc_major=0 · 46 unmodified lines
47gcc_minor=047gcc_minor=0
48cc_name="gcc"48cc_name="gcc"
49ar_set=49ar_set=
50darwin=50cpu=
51cpuver=51cpuver=
52dwarf=52dwarf=
53targetos=
54build_cross=
53 55
54# use CC from environment when set56# use CC/AR from environment when set
55test -n "$CC" && cc="$CC"57test -n "$CC" && cc="$CC"
56 58test -n "$AR" && ar="$AR"
57# OS specific
58cpu=`uname -m`
59cpu_sys="$cpu"
60targetos=`uname`
61if test "$targetos" = "Linux" ; then
62 test "$(uname -o)" = "Android" && targetos=Android
63fi
64
65case $targetos in
66 Darwin)
67 darwin=yes
68 dwarf=4
69 confvars="$confvars OSX"
70 cc=`command -v cc`
71 cc=`readlink $cc || echo clang`
72 tcc_usrinclude="`xcrun --show-sdk-path`/usr/include"
73 DLLSUF=".dylib"
74 case $* in *--config-new_macho*) ;; *)
75 # if new_macho was not specified and (known) ver <= 10, use old (=no)
76 osxver=$(sw_vers -productVersion 2>/dev/null) # X.Y.Z
77 osxver=${osxver%%.*} # major version (or empty on sw_vers error)
78 [ "${osxver:-11}" -ge 11 ] || confvars="$confvars new_macho=no"
79 esac
80 ;;
81 Windows_NT|MINGW*|MSYS*|CYGWIN*)
82 mingw32=yes
83 targetos=WIN32
84 ;;
85 DragonFly|OpenBSD|FreeBSD|NetBSD)
86 confvars="$confvars BSD ldl=no"
87 ;;
88 Android)
89 confvars="$confvars Android pie new-dtags"
90 if test -n "$TERMUX_VERSION"; then
91 prefix="$PREFIX" # "/data/data/com.termux/files/usr"
92 sysroot="$PREFIX"
93 test "$cpu" = "aarch64" -o "$cpu" = "x86_64" && S="64" || S=""
94 tcc_sysincludepaths="{B}/include:{R}/include/\\\"CONFIG_TRIPLET\\\":{R}/include"
95 tcc_libpaths="{B}:{R}/lib:/system/lib${S}"
96 tcc_crtprefix="{R}/lib"
97 tcc_elfinterp="/system/bin/linker${S}"
98 use_triplet="yes"
99 tcc_switches="-Wl,-rpath=$sysroot/lib,-section-alignment=0x1000"
100 fi
101 ;;
102 *)
103 ;;
104esac
105 59
106# find source path60# find source path
107source_path=${0%configure}61source_path=${0%configure}
108source_path=${source_path%/}62source_path=${source_path%/}
109source_path_used="yes"
110if test -z "$source_path" -o "$source_path" = "." ; then
111 source_path=`pwd`
112 source_path_used="no"
113fi
114 63
115for opt do64for opt do
116 eval opt=\"$opt\"65 eval opt=\"$opt\"
@@ -137,6 +86,8 @@ for opt do · 20 unmodified lines
137 ;;86 ;;
138 --sysroot=*) sysroot=`echo $opt | cut -d '=' -f 2-`87 --sysroot=*) sysroot=`echo $opt | cut -d '=' -f 2-`
139 ;;88 ;;
89 --targetos=*) targetos=`echo $opt | cut -d '=' -f 2-`
90 ;;
140 --source-path=*) source_path=`echo $opt | cut -d '=' -f 2-`91 --source-path=*) source_path=`echo $opt | cut -d '=' -f 2-`
141 ;;92 ;;
142 --cross-prefix=*) cross_prefix=`echo $opt | cut -d '=' -f 2-`93 --cross-prefix=*) cross_prefix=`echo $opt | cut -d '=' -f 2-`
@@ -192,16 +143,119 @@ for opt do · 49 unmodified lines
192 esac143 esac
193done144done
194 145
195cc="${cross_prefix}${cc}"146show_help() {
196ar="${cross_prefix}${ar}"147cat << EOF
148Usage: configure [options]
149Options: [defaults in brackets after descriptions]
150
151Standard options:
152 --help print this message
153 --prefix=PREFIX install in PREFIX [$prefix]
154 --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
155 [same as prefix]
156 --bindir=DIR user executables in DIR [EPREFIX/bin]
157 --libdir=DIR object code libraries in DIR [EPREFIX/lib]
158 --tccdir=DIR installation directory [EPREFIX/lib/tcc]
159 --includedir=DIR C header files in DIR [PREFIX/include]
160 --sharedir=DIR documentation root DIR [PREFIX/share]
161 --docdir=DIR documentation in DIR [SHAREDIR/doc/tcc]
162 --mandir=DIR man documentation in DIR [SHAREDIR/man]
163 --infodir=DIR info documentation in DIR [SHAREDIR/info]
164
165Advanced options (experts only):
166 --source-path=PATH path of source code [$source_path]
167 --sysroot=PREFIX prepend PREFIX to library/include paths [$sysroot]
168 --cc=CC use C compiler CC [$cc]
169 --ar=AR create archives using AR [$ar]
170 --extra-cflags= specify compiler flags [$CFLAGS]
171 --extra-ldflags= specify linker options [$LDFLAGS]
172
173 --debug include debug info with resulting binaries
174 --disable-static make libtcc.so instead of libtcc.a
175 --enable-static make libtcc.a instead of libtcc.dll (win32)
176 --disable-rpath disable use of -rpath with libtcc.so
177 --with-libgcc use libgcc_s.so.1 instead of libtcc1.a
178 --with-selinux use mmap for executable memory (tcc -run)
179 --enable-cross build cross compilers (see also 'make help')
197 180
198# Checking for CFLAGS181 --sysincludepaths=... specify system include paths, colon separated
199test -z "$CFLAGS" && CFLAGS="-Wall -O2"182 --libpaths=... specify system library paths, colon separated
183 --crtprefix=... specify locations of crt?.o, colon separated
184 --elfinterp=... specify elf interpreter
185 --triplet=... specify system library/include directory triplet
186 --tcc-switches=... specify implicit switches passed to tcc
187
188 --config-uClibc,-musl enable system specific configurations
189 --config-mingw32 build on windows using msys, busybox, etc.
190 --config-backtrace=no disable stack backtraces (with -run or -bt)
191 --config-bcheck=no disable bounds checker (-b)
192 --config-predefs=no do not compile tccdefs.h, instead just include
193 --config-new_macho=no|yes Force apple object format (autodetect osx <= 10)
194 --config-codesign Use codesign on apple to sign executables
195 --dwarf=x Use dwarf debug info instead of stabs (x=2..5)
196
197Cross build options (experimental):
198 --cpu=CPU target CPU [$cpu]
199 --targetos=... target OS (Darwin,WIN32,Android/Termux) [$targetos]
200 --cross-prefix=PREFIX use PREFIX for compile tools [$cross_prefix]
201EOF
202exit 1
203}
204
205default() # set variable unless already set
206{
207 local v
208 eval v=\"\$$1\"
209 test -z "$v" && eval $1=\"$2\"
210}
211
212default_conf() # add to confvars unless already present
213{
214 local v=${1%=*}
215 test "${confvars%$v*}" = "${confvars}" && confvars="$confvars $1"
216}
217
218if test -z "$source_path" -o "$source_path" = "." ; then
219 source_path=$(pwd)
220 source_path_used="no"
221else
222 source_path_used="yes"
223fi
224
225# OS specific
226buildos=$(uname)
227
228case $buildos in
229 Windows_NT|MINGW*|MSYS*|CYGWIN*)
230 buildos="WIN32"
231 ;;
232 Linux)
233 if test "$(uname -o)" = "Android"; then
234 buildos=Android
235 if test -n "$TERMUX_VERSION"; then
236 buildos=Termux
237 fi
238 fi
239 ;;
240esac
241
242if test "$mingw32" = "yes"; then
243 default targetos WIN32
244else
245 default targetos "$buildos"
246fi
200 247
201# on OSX M1 with --cpu=x86_64, build a tcc to run under rosetta entirely248cpu_sys=$(uname -m)
202if test "$darwin" = "yes" -a "$cpu" = "x86_64" -a "$cpu_sys" = "arm64"; then249default cpu "$cpu_sys"
203 CFLAGS="$CFLAGS -arch $cpu"250cpu_set="$cpu"
204 LDFLAGS="$LDFLAGS -arch $cpu"251
252# check for crpss build
253if test "$cpu_set" != "$cpu_sys" \
254 -o "$targetos" != "$buildos" \
255 -o -n "$cross_prefix" ; then
256 build_cross="yes"
257 cc="${cross_prefix}${cc}"
258 ar="${cross_prefix}${ar}"
205fi259fi
206 260
207case "$cpu" in261case "$cpu" in
@@ -262,109 +316,101 @@ case "$cpu" in · 54 unmodified lines
262 ;;316 ;;
263esac317esac
264 318
265if test "$mingw32" = "yes" ; then319case $targetos in
266 if test "$source_path_used" = "no"; then320 Darwin)
267 source_path="."321 dwarf=4
322 confvars="$confvars OSX"
323 DLLSUF=".dylib"
324 if test -z "$build_cross"; then
325 cc=`command -v cc`
326 cc=`readlink $cc || echo clang`
327 tcc_usrinclude="`xcrun --show-sdk-path`/usr/include"
328 if test "${confvars%new_macho*}" = "${confvars}"; then
329 # if new_macho was not specified and (known) ver <= 10, use old (=no)
330 osxver=$(sw_vers -productVersion 2>/dev/null) # X.Y.Z
331 osxver=${osxver%%.*} # major version (or empty on sw_vers error)
332 [ "${osxver:-11}" -ge 11 ] || confvars="$confvars new_macho=no"
333 fi
334 fi
335 # on OSX M1 with --cpu=x86_64, build a tcc to run under rosetta entirely
336 if test "$cpu" = "x86_64" -a "$cpu_sys" = "arm64"; then
337 CFLAGS="$CFLAGS -arch $cpu"
338 LDFLAGS="$LDFLAGS -arch $cpu"
268 fi339 fi
269 test -z "$prefix" && prefix="C:/Program Files/tcc"340 ;;
270 test -z "$tccdir" && tccdir="${prefix}" && tccdir_auto="yes"341 DragonFly|OpenBSD|FreeBSD|NetBSD)
271 test -z "$bindir" && bindir="${tccdir}"342 confvars="$confvars BSD ldl=no"
272 test -z "$docdir" && docdir="${tccdir}/doc"343 ;;
273 test -z "$libdir" && libdir="${tccdir}/libtcc"344 Android|Termux)
345 if test "$targetos" = "Termux"; then
346 targetos=Android
347 default sysroot "/data/data/com.termux/files/usr"
348 else
349 default sysroot "/usr"
350 fi
351 default prefix "${sysroot}"
352 confvars="$confvars Android new-dtags rpath=no"
353 test "${cpu}" != "i386" && confvars="$confvars pie"
354 default_conf "static=no"
355 if test "${cpu}" = "arm"; then
356 default triplet "arm-linux-androideabi"
357 cpuver=7
358 else
359 default triplet "${cpu_set}-linux-android"
360 fi
361 test "${cpu%64}" != "${cpu}" && S="64" || S=""
362 default tcc_sysincludepaths "{B}/include:{R}/include:{R}/include/${triplet}"
363 default tcc_libpaths "{B}:{R}/lib:/system/lib${S}"
364 default tcc_crtprefix "{R}/lib"
365 default tcc_elfinterp "/system/bin/linker${S}"
366 default tcc_switches "-Wl,-rpath=$sysroot/lib,-section-alignment=0x1000"
367 ;;
368 WIN32)
369 mingw32="yes"
274 confvars="$confvars WIN32"370 confvars="$confvars WIN32"
371 default prefix "C:/Program Files/tcc"
372 default tccdir "${prefix}"
373 default bindir "${tccdir}"
374 default docdir "${tccdir}/doc"
375 default libdir "${tccdir}/libtcc"
376 test "$tccdir" = "$bindir" && tccdir_auto="yes"
275 LIBSUF=".lib"377 LIBSUF=".lib"
276 EXESUF=".exe"378 EXESUF=".exe"
277 DLLSUF=".dll"379 DLLSUF=".dll"
278else380 if test "$source_path_used" = "no"; then
279 if test -z "$prefix" ; then381 source_path="."
280 prefix="/usr/local"
281 fi
282 if test -z "$sharedir" ; then
283 sharedir="${prefix}/share"
284 fi
285 if test x"$execprefix" = x""; then
286 execprefix="${prefix}"
287 fi
288 if test x"$libdir" = x""; then
289 libdir="${execprefix}/lib"
290 fi
291 if test x"$bindir" = x""; then
292 bindir="${execprefix}/bin"
293 fi
294 if test x"$docdir" = x""; then
295 docdir="${sharedir}/doc"
296 fi
297 if test x"$mandir" = x""; then
298 mandir="${sharedir}/man"
299 fi
300 if test x"$infodir" = x""; then
301 infodir="${sharedir}/info"
302 fi
303 if test x"$tccdir" = x""; then
304 tccdir="${libdir}/tcc"
305 fi
306 if test x"$includedir" = x""; then
307 includedir="${prefix}/include"
308 fi382 fi
309fi # mingw32383 ;;
310 384 *)
311if test x"$show_help" = "xyes" ; then385 ;;
312cat << EOF386esac
313Usage: configure [options]
314Options: [defaults in brackets after descriptions]
315
316Standard options:
317 --help print this message
318 --prefix=PREFIX install in PREFIX [$prefix]
319 --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
320 [same as prefix]
321 --bindir=DIR user executables in DIR [EPREFIX/bin]
322 --libdir=DIR object code libraries in DIR [EPREFIX/lib]
323 --tccdir=DIR installation directory [EPREFIX/lib/tcc]
324 --includedir=DIR C header files in DIR [PREFIX/include]
325 --sharedir=DIR documentation root DIR [PREFIX/share]
326 --docdir=DIR documentation in DIR [SHAREDIR/doc/tcc]
327 --mandir=DIR man documentation in DIR [SHAREDIR/man]
328 --infodir=DIR info documentation in DIR [SHAREDIR/info]
329 387
330Advanced options (experts only):388if test "$mingw32" = "no"; then
331 --source-path=PATH path of source code [$source_path]389 default prefix "/usr/local"
332 --cross-prefix=PREFIX use PREFIX for compile tools [$cross_prefix]390 default execprefix "${prefix}"
333 --sysroot=PREFIX prepend PREFIX to library/include paths [$sysroot]391 default libdir "${execprefix}/lib"
334 --cc=CC use C compiler CC [$cc]392 default bindir "${execprefix}/bin"
335 --ar=AR create archives using AR [$ar]393 default tccdir "${libdir}/tcc"
336 --extra-cflags= specify compiler flags [$CFLAGS]394 default includedir "${prefix}/include"
337 --extra-ldflags= specify linker options [$LDFLAGS]395 default sharedir "${prefix}/share"
338 --cpu=CPU CPU [$cpu]396 default docdir "${sharedir}/doc"
397 default mandir "${sharedir}/man"
398 default infodir "${sharedir}/info"
399fi
339 400
340 --debug include debug info with resulting binaries401# set default CFLAGS
341 --disable-static make libtcc.so instead of libtcc.a402default CFLAGS "-Wall -O2"
342 --enable-static make libtcc.a instead of libtcc.dll (win32)
343 --disable-rpath disable use of -rpath with libtcc.so
344 --with-libgcc use libgcc_s.so.1 instead of libtcc1.a
345 --with-selinux use mmap for executable memory (tcc -run)
346 --enable-cross build cross compilers (see also 'make help')
347 403
348 --sysincludepaths=... specify system include paths, colon separated404if test "$mingw32" = "yes" -a "$cc_name" = "gcc"; then
349 --libpaths=... specify system library paths, colon separated405 # avoid mingw dependencies such as 'libgcc_s_dw2-1.dll'
350 --crtprefix=... specify locations of crt?.o, colon separated406 default LDFLAGS "-static"
351 --elfinterp=... specify elf interpreter407fi
352 --triplet=... specify system library/include directory triplet
353 --tcc-switches=... specify implicit switches passed to tcc
354 408
355 --config-uClibc,-musl enable system specific configurations409if test x"$show_help" = "xyes" ; then
356 --config-mingw32 build on windows using msys, busybox, etc.410 show_help
357 --config-backtrace=no disable stack backtraces (with -run or -bt)
358 --config-bcheck=no disable bounds checker (-b)
359 --config-predefs=no do not compile tccdefs.h, instead just include
360 --config-new_macho=no|yes Force apple object format (autodetect osx <= 10)
361 --config-codesign Use codesign on apple to sign executables
362 --dwarf=x Use dwarf debug info instead of stabs (x=2..5)
363EOF
364exit 1
365fi411fi
366 412
367if test -z "$cross_prefix" ; then413if test -z "$build_cross"; then
368 CONFTEST=./conftest$EXESUF414 CONFTEST=./conftest$EXESUF
369 if ! $cc -o $CONFTEST $source_path/conftest.c ; then415 if ! $cc -o $CONFTEST $source_path/conftest.c ; then
370 echo "configure: error: '$cc' failed to compile conftest.c."416 echo "configure: error: '$cc' failed to compile conftest.c."
@@ -376,13 +422,11 @@ if test -z "$cross_prefix" ; then · 5 unmodified lines
376 _triplet="$($CONFTEST triplet)"422 _triplet="$($CONFTEST triplet)"
377 fi423 fi
378 if test "$mingw32" = "no" ; then424 if test "$mingw32" = "no" ; then
379
380 if test -z "$triplet" -a -n "$_triplet"; then425 if test -z "$triplet" -a -n "$_triplet"; then
381 if test -f "/usr/lib/$_triplet/crti.o" -o -n "$use_triplet" ; then426 if test -f "/usr/lib/$_triplet/crti.o"; then
382 triplet="$_triplet"427 triplet="$_triplet"
383 fi428 fi
384 fi429 fi
385
386 if test -z "$triplet"; then430 if test -z "$triplet"; then
387 if test $cpu = "x86_64" -o $cpu = "arm64" -o $cpu = "riscv64" ; then431 if test $cpu = "x86_64" -o $cpu = "arm64" -o $cpu = "riscv64" ; then
388 if test -f "/usr/lib64/crti.o" ; then432 if test -f "/usr/lib64/crti.o" ; then
@@ -390,21 +434,6 @@ if test -z "$cross_prefix" ; then · 1 unmodified line
390 fi434 fi
391 fi435 fi
392 fi436 fi
393
394 if test "$cpu" = "arm" ; then
395 if test "${triplet%eabihf}" != "$triplet" ; then
396 confvars="$confvars arm_eabihf arm_vfp"
397 elif test "${triplet%eabi}" != "$triplet" ; then
398 confvars="$confvars arm_eabi arm_vfp"
399 elif test "${_triplet%eabihf}" != "$_triplet" ; then
400 confvars="$confvars arm_eabihf arm_vfp"
401 elif test "${_triplet%eabi}" != "$_triplet" ; then
402 confvars="$confvars arm_eabi arm_vfp"
403 elif grep -s -q "^Features.* \(vfp\|iwmmxt\) " /proc/cpuinfo ; then
404 confvars="$confvars arm_vfp"
405 fi
406 fi
407
408 if test "$suggest" = "yes"; then437 if test "$suggest" = "yes"; then
409 if test -f "/lib/ld-uClibc.so.0" ; then438 if test -f "/lib/ld-uClibc.so.0" ; then
410 echo "Perhaps you want ./configure --config-uClibc"439 echo "Perhaps you want ./configure --config-uClibc"
@@ -413,23 +442,43 @@ if test -z "$cross_prefix" ; then · 2 unmodified lines
413 echo "Perhaps you want ./configure --config-musl"442 echo "Perhaps you want ./configure --config-musl"
414 fi443 fi
415 fi444 fi
416 else # mingw32 = yes
417 if test "$cc_name" = "gcc"; then
418 # avoid mingw dependencies such as 'libgcc_s_dw2-1.dll'
419 test -z "$LDFLAGS" && LDFLAGS="-static"
420 fi
421 fi445 fi
422else446else
423 # if cross compiling, cannot launch a program, so make a static guess447 # can only make guesses about compiler and target
448 if test "${cc%tcc*}" != "$cc"; then
449 cc_name="tcc"
450 elif test "${cc%clang*}" != "$cc"; then
451 cc_name="clang"
452 fi
424 case $cpu in453 case $cpu in
425 ppc|mips|s390) bigendian=yes;;454 ppc|mips|s390) bigendian=yes;;
426 esac455 esac
456 case $targetos in
457 Linux)
458 default triplet "$cpu_set-linux-gnu"
459 esac
427fi460fi
428 461
429if test "$bigendian" = "yes" ; then462if test "$bigendian" = "yes" ; then
430 confvars="$confvars BIGENDIAN"463 confvars="$confvars BIGENDIAN"
431fi464fi
432 465
466if test "$cpu" = "arm"; then
467 if test "${triplet%eabihf}" != "$triplet" ; then
468 confvars="$confvars arm_eabihf arm_vfp"
469 elif test "${triplet%eabi}" != "$triplet" ; then
470 confvars="$confvars arm_eabi arm_vfp"
471 elif test -z "$build_cross"; then
472 if test "${_triplet%eabihf}" != "$_triplet" ; then
473 confvars="$confvars arm_eabihf arm_vfp"
474 elif test "${_triplet%eabi}" != "$_triplet" ; then
475 confvars="$confvars arm_eabi arm_vfp"
476 elif grep -s -q "^Features.* \(vfp\|iwmmxt\) " /proc/cpuinfo ; then
477 confvars="$confvars arm_vfp"
478 fi
479 fi
480fi
481
433# a final configuration tuning482# a final configuration tuning
434if test "$cc_name" != "tcc"; then483if test "$cc_name" != "tcc"; then
435 OPT1="-Wdeclaration-after-statement -fno-strict-aliasing"484 OPT1="-Wdeclaration-after-statement -fno-strict-aliasing"
@@ -438,7 +487,7 @@ if test "$cc_name" != "tcc"; then · 2 unmodified lines
438 OPT2="$OPT2 -Wstringop-truncation"487 OPT2="$OPT2 -Wstringop-truncation"
439 if test "$cc_name" = "clang"; then488 if test "$cc_name" = "clang"; then
440 OPT1="$OPT1 -fheinous-gnu-extensions"489 OPT1="$OPT1 -fheinous-gnu-extensions"
441 OPT2="$OPT2 -Wstring-plus-int"490 OPT2="$OPT2 -Wstring-plus-int -Wdeprecated-declarations"
442 fi491 fi
443 $cc $OPT1 $OPT2 -o a.out -c -xc - < /dev/null > cc_msg.txt 2>&1492 $cc $OPT1 $OPT2 -o a.out -c -xc - < /dev/null > cc_msg.txt 2>&1
444 for o in $OPT1; do # enable these options493 for o in $OPT1; do # enable these options
@@ -470,6 +519,11 @@ echo "C compiler $cc ($gcc_major.$gcc_minor)" · 25 unmodified lines
470echo "Target OS $targetos"519echo "Target OS $targetos"
471echo "CPU $cpu"520echo "CPU $cpu"
472fcho "Triplet " "$triplet"521fcho "Triplet " "$triplet"
522fcho "Libs " "$tcc_libpaths"
523fcho "Sysinclude " "$tcc_sysincludepaths"
524fcho "Crt " "$tcc_crtprefix"
525fcho "Elfinterp " "$tcc_elfinterp"
526fcho "Switches " "$tcc_switches"
473fcho "Config " "${confvars# }"527fcho "Config " "${confvars# }"
474echo "Creating config.mak and config.h"528echo "Creating config.mak and config.h"
475 529
@@ -530,6 +584,7 @@ print_mak TCC_CPU_VERSION "$cpuver" num · 54 unmodified lines
530 584
531echo "ARCH=$cpu" >> config.mak585echo "ARCH=$cpu" >> config.mak
532echo "TARGETOS=$targetos" >> config.mak586echo "TARGETOS=$targetos" >> config.mak
587echo "BUILDOS=$buildos" >> config.mak
533 588
534predefs="1"589predefs="1"
535for v in $confvars ; do590for v in $confvars ; do
conftest.c+6−8
@@ -1,8 +1,8 @@
1/* ----------------------------------------------------------------------- */1/* ----------------------------------------------------------------------- */
2#if C2STR
3
4/* with -D C2STR: convert tccdefs.h to C-strings */2/* with -D C2STR: convert tccdefs.h to C-strings */
5 3
4#if C2STR
5
6#include <stdio.h>6#include <stdio.h>
7#include <string.h>7#include <string.h>
8 8
@@ -166,14 +166,16 @@ int main(int argc, char **argv) · 157 unmodified lines
166}166}
167 167
168/* ----------------------------------------------------------------------- */168/* ----------------------------------------------------------------------- */
169#elif 1
170
171/* get some information from the host compiler for configure */169/* get some information from the host compiler for configure */
172 170
171#elif 1
172
173#include <stdio.h>173#include <stdio.h>
174 174
175#if defined(_WIN32)175#if defined(_WIN32)
176#include <fcntl.h>176#include <fcntl.h>
177#include <io.h>
178int _CRT_glob = 0;
177#endif179#endif
178 180
179/* Define architecture */181/* Define architecture */
@@ -233,10 +235,6 @@ int main(int argc, char **argv) · 53 unmodified lines
233# define TRIPLET TRIPLET_ARCH "-" TRIPLET_OS "-" TRIPLET_ABI235# define TRIPLET TRIPLET_ARCH "-" TRIPLET_OS "-" TRIPLET_ABI
234#endif236#endif
235 237
236#if defined(_WIN32)
237int _CRT_glob = 0;
238#endif
239
240int main(int argc, char *argv[])238int main(int argc, char *argv[])
241{239{
242#if defined(_WIN32)240#if defined(_WIN32)
tcc-doc.texi+6−5
@@ -364,10 +364,11 @@ bounds (@pxref{Bounds}). @option{-g} is implied. · 363 unmodified lines
364 364
365@item -bt[N]365@item -bt[N]
366Display N callers in stack traces. This is useful with @option{-g} or @option{-b}.366Display N callers in stack traces. This is useful with @option{-g} or @option{-b}.
367With executables, additional support for stack traces is included.367When activated, @code{__TCC_BACKTRACE__} is defined.
368 368
369A function @code{ int tcc_backtrace(const char *fmt, ...); } is provided369With executables, additional support for stack traces is included. A function
370to trigger a stack trace with a message on demand.370 @code{ int tcc_backtrace(const char *fmt, ...); }
371is provided to trigger a stack trace with a message on demand.
371 372
372@end table373@end table
373 374
@@ -937,7 +938,7 @@ Here are some examples of caught errors: · 563 unmodified lines
937@end example938@end example
938@end table939@end table
939 940
940TCC defines @code{__BOUNDS_CHECKING_ON} if activated.941TCC defines @code{__TCC_BCHECK__} if activated.
941 942
942There are five environment variables that can be used to control the behavior:943There are five environment variables that can be used to control the behavior:
943@itemize944@itemize
@@ -984,7 +985,7 @@ for bounds checking errors. · 40 unmodified lines
984@end itemize985@end itemize
985 986
986@example987@example
987#if defined(__TINYC__) && __BOUNDS_CHECKING_ON988#ifdef __TCC_BCHECK__
988extern void __bounds_checking (int x);989extern void __bounds_checking (int x);
989# define BOUNDS_CHECKING_OFF __bounds_checking(1)990# define BOUNDS_CHECKING_OFF __bounds_checking(1)
990# define BOUNDS_CHECKING_ON __bounds_checking(-1)991# define BOUNDS_CHECKING_ON __bounds_checking(-1)
tests/pp/Makefile+2−2
@@ -10,7 +10,7 @@ VPATH = $(SRC) · 9 unmodified lines
10files = $(patsubst %.$1,%.test,$(notdir $(wildcard $(SRC)/*.$1)))10files = $(patsubst %.$1,%.test,$(notdir $(wildcard $(SRC)/*.$1)))
11TESTS = $(call files,c) $(call files,S)11TESTS = $(call files,c) $(call files,S)
12 12
13all test testspp.all testcpp.all: $(sort $(TESTS))13all test testspp.all: $(sort $(TESTS))
14 14
15DIFF_OPTS = -Nu -b15DIFF_OPTS = -Nu -b
16 16
@@ -29,7 +29,7 @@ FILTER = 2>&1 | sed 's,$(SRC)/,,g' · 12 unmodified lines
29 diff $(DIFF_OPTS) $(SRC)/$*.expect $*.output \29 diff $(DIFF_OPTS) $(SRC)/$*.expect $*.output \
30 && rm -f $*.output30 && rm -f $*.output
31 31
32testspp.% testcpp.%: %.test ;32testspp.%: %.test ;
33 33
34# automatically generate .expect files with gcc:34# automatically generate .expect files with gcc:
35%.expect: # %.c35%.expect: # %.c
tests/tests2/Makefile+4−4
@@ -124,7 +124,7 @@ endif · 123 unmodified lines
124# Filter source directory in warnings/errors (out-of-tree builds)124# Filter source directory in warnings/errors (out-of-tree builds)
125FILTER = 2>&1 | sed -e 's,$(SRC)/,,g'125FILTER = 2>&1 | sed -e 's,$(SRC)/,,g'
126 126
127all test tests2.all testc2.all: $(filter-out $(SKIP),$(TESTS))127all test tests2.all: $(filter-out $(SKIP),$(TESTS))
128 @$(MAKE) clean --no-print-directory -s128 @$(MAKE) clean --no-print-directory -s
129 129
130%.test: %.c %.expect130%.test: %.c %.expect
@@ -138,15 +138,15 @@ T3 = $(FILTER) >$*.output 2>&1 || true \ · 7 unmodified lines
138 && rm -f $*.output $(filter $*.expect,$(GEN-ALWAYS))138 && rm -f $*.output $(filter $*.expect,$(GEN-ALWAYS))
139 139
140# run single test and update .expect file, e.g. "make tests2.37+"140# run single test and update .expect file, e.g. "make tests2.37+"
141tests2.%+ testc2.%+:141tests2.%+:
142 @$(MAKE) $(call F2,$(call F1,$*)) --no-print-directory142 @$(MAKE) $(call F2,$(call F1,$*)) --no-print-directory
143 143
144# just run tcc to see the output, e.g. "make tests2.37-"144# just run tcc to see the output, e.g. "make tests2.37-"
145tests2.%- testc2.%-:145tests2.%-:
146 @$(MAKE) $(call F1,$*) T3= --no-print-directory146 @$(MAKE) $(call F1,$*) T3= --no-print-directory
147 147
148# run single test, e.g. "make tests2.37"148# run single test, e.g. "make tests2.37"
149tests2.% testc2.%:149tests2.%:
150 @$(MAKE) $(call F1,$*) --no-print-directory150 @$(MAKE) $(call F1,$*) --no-print-directory
151 151
152F1 = $(or $(filter $1_%,$(TESTS)),$1_???.test)152F1 = $(or $(filter $1_%,$(TESTS)),$1_???.test)
win32/build-tcc.bat+44−37
@@ -7,7 +7,8 @@ setlocal · 6 unmodified lines
7if (%1)==(-clean) goto :cleanup7if (%1)==(-clean) goto :cleanup
8set CC=gcc8set CC=gcc
9set /p VERSION= < ..\VERSION9set /p VERSION= < ..\VERSION
10set INST=10set TCCDIR=
11set BINDIR=
11set DOC=no12set DOC=no
12set EXES_ONLY=no13set EXES_ONLY=no
13goto :a014goto :a0
@@ -23,7 +24,8 @@ goto :a2 · 9 unmodified lines
23:a124:a1
24if (%1)==(-t) set T=%2&& goto :a225if (%1)==(-t) set T=%2&& goto :a2
25if (%1)==(-v) set VERSION=%~2&& goto :a226if (%1)==(-v) set VERSION=%~2&& goto :a2
26if (%1)==(-i) set INST=%2&& goto :a227if (%1)==(-i) set TCCDIR=%2&& goto :a2
28if (%1)==(-b) set BINDIR=%2&& goto :a2
27if (%1)==(-d) set DOC=yes&& goto :a329if (%1)==(-d) set DOC=yes&& goto :a3
28if (%1)==(-x) set EXES_ONLY=yes&& goto :a330if (%1)==(-x) set EXES_ONLY=yes&& goto :a3
29if (%1)==() goto :p131if (%1)==() goto :p1
@@ -35,6 +37,7 @@ echo -c "prog options" use prog with options to compile tcc · 5 unmodified lines
35echo -t 32/64 force 32/64 bit default target37echo -t 32/64 force 32/64 bit default target
36echo -v "version" set tcc version38echo -v "version" set tcc version
37echo -i tccdir install tcc into tccdir39echo -i tccdir install tcc into tccdir
40echo -b bindir but install tcc.exe and libtcc.dll into bindir
38echo -d create tcc-doc.html too (needs makeinfo)41echo -d create tcc-doc.html too (needs makeinfo)
39echo -x just create the executables42echo -x just create the executables
40echo -clean delete all previously produced files and directories43echo -clean delete all previously produced files and directories
@@ -87,18 +90,24 @@ if %PROCESSOR_ARCHITECTURE%_==AMD64_ set T=64 · 46 unmodified lines
87if %PROCESSOR_ARCHITEW6432%_==AMD64_ set T=6490if %PROCESSOR_ARCHITEW6432%_==AMD64_ set T=64
88:p291:p2
89if "%CC:~-3%"=="gcc" set CC=%CC% -O2 -s -static92if "%CC:~-3%"=="gcc" set CC=%CC% -O2 -s -static
93if (%BINDIR%)==() set BINDIR=%TCCDIR%
94
90set D32=-DTCC_TARGET_PE -DTCC_TARGET_I38695set D32=-DTCC_TARGET_PE -DTCC_TARGET_I386
91set D64=-DTCC_TARGET_PE -DTCC_TARGET_X86_6496set D64=-DTCC_TARGET_PE -DTCC_TARGET_X86_64
92set P32=i386-win3297set P32=i386-win32
93set P64=x86_64-win3298set P64=x86_64-win32
99
94if %T%==64 goto :t64100if %T%==64 goto :t64
95set D=%D32%101set D=%D32%
102set P=%P32%
96set DX=%D64%103set DX=%D64%
97set PX=%P64%104set PX=%P64%
98set TX=64105set TX=64
99goto :p3106goto :p3
107
100:t64108:t64
101set D=%D64%109set D=%D64%
110set P=%P64%
102set DX=%D32%111set DX=%D32%
103set PX=%P32%112set PX=%P32%
104set TX=32113set TX=32
@@ -111,17 +120,16 @@ for /f %%b in ('git.exe rev-parse --abbrev-ref HEAD') do set GITHASH=%%b · 6 unmodified lines
111for /f %%b in ('git.exe log -1 "--pretty=format:%%cs_%GITHASH%@%%h"') do set GITHASH=%%b120for /f %%b in ('git.exe log -1 "--pretty=format:%%cs_%GITHASH%@%%h"') do set GITHASH=%%b
112git.exe diff --quiet121git.exe diff --quiet
113if %ERRORLEVEL%==1 set GITHASH=%GITHASH%*122if %ERRORLEVEL%==1 set GITHASH=%GITHASH%*
114set DEF_GITHASH=-DTCC_GITHASH="""%GITHASH%"""
115:git_done123:git_done
116
117@echo on124@echo on
118 125
119:config.h126:config.h
120echo>..\config.h #define TCC_VERSION "%VERSION%"127echo>..\config.h #define TCC_VERSION "%VERSION%"
121echo>> ..\config.h #ifdef TCC_TARGET_X86_64128if not (%GITHASH%)==() echo>> ..\config.h #define TCC_GITHASH "%GITHASH%"
122echo>> ..\config.h #define TCC_LIBTCC1 "libtcc1-64.a"129@if not (%BINDIR%)==(%TCCDIR%) echo>> ..\config.h #define CONFIG_TCCDIR "%TCCDIR:\=/%"
123echo>> ..\config.h #else130if %TX%==64 echo>> ..\config.h #ifdef TCC_TARGET_X86_64
124echo>> ..\config.h #define TCC_LIBTCC1 "libtcc1-32.a"131if %TX%==32 echo>> ..\config.h #ifdef TCC_TARGET_I386
132echo>> ..\config.h #define CONFIG_TCC_CROSSPREFIX "%PX%-"
125echo>> ..\config.h #endif133echo>> ..\config.h #endif
126 134
127for %%f in (*tcc.exe *tcc.dll) do @del %%f135for %%f in (*tcc.exe *tcc.dll) do @del %%f
@@ -135,7 +143,7 @@ for %%f in (*tcc.exe *tcc.dll) do @del %%f · 7 unmodified lines
135@if _%LIBTCC_C%_==__ set LIBTCC_C=..\libtcc.c143@if _%LIBTCC_C%_==__ set LIBTCC_C=..\libtcc.c
136%CC% -o libtcc.dll -shared %LIBTCC_C% %D% -DLIBTCC_AS_DLL144%CC% -o libtcc.dll -shared %LIBTCC_C% %D% -DLIBTCC_AS_DLL
137@if errorlevel 1 goto :the_end145@if errorlevel 1 goto :the_end
138%CC% -o tcc.exe ..\tcc.c libtcc.dll %D% -DONE_SOURCE"=0" %DEF_GITHASH%146%CC% -o tcc.exe ..\tcc.c libtcc.dll %D% -DONE_SOURCE"=0"
139%CC% -o %PX%-tcc.exe ..\tcc.c %DX%147%CC% -o %PX%-tcc.exe ..\tcc.c %DX%
140:compiler_done148:compiler_done
141@if (%EXES_ONLY%)==(yes) goto :files_done149@if (%EXES_ONLY%)==(yes) goto :files_done
@@ -151,15 +159,9 @@ copy>nul tcc-win32.txt doc · 9 unmodified lines
151if exist libtcc.dll .\tcc -impdef libtcc.dll -o libtcc\libtcc.def159if exist libtcc.dll .\tcc -impdef libtcc.dll -o libtcc\libtcc.def
152@if errorlevel 1 goto :the_end160@if errorlevel 1 goto :the_end
153 161
154:libtcc1.a162:lib
155call :makelib %T%163call :make_lib %T% || goto :the_end
156@if errorlevel 1 goto :the_end164@if exist %PX%-tcc.exe call :make_lib %TX% %PX%- || goto :the_end
157@if exist %PX%-tcc.exe call :makelib %TX%
158@if errorlevel 1 goto :the_end
159.\tcc -m%T% -c ../lib/bcheck.c -o lib/bcheck.o -bt
160.\tcc -m%T% -c ../lib/bt-exe.c -o lib/bt-exe.o
161.\tcc -m%T% -c ../lib/bt-log.c -o lib/bt-log.o
162.\tcc -m%T% -c ../lib/bt-dll.c -o lib/bt-dll.o
163 165
164:tcc-doc.html166:tcc-doc.html
165@if not (%DOC%)==(yes) goto :doc-done167@if not (%DOC%)==(yes) goto :doc-done
@@ -171,27 +173,32 @@ cmd /c makeinfo --html --no-split ../tcc-doc.texi -o doc/tcc-doc.html · 5 unmodified lines
171for %%f in (*.o *.def) do @del %%f173for %%f in (*.o *.def) do @del %%f
172 174
173:copy-install175:copy-install
174@if (%INST%)==() goto :the_end176@if (%TCCDIR%)==() goto :the_end
175if not exist %INST% mkdir %INST%177if not exist %BINDIR% mkdir %BINDIR%
176for %%f in (*tcc.exe *tcc.dll) do @copy>nul %%f %INST%\%%f178for %%f in (*tcc.exe *tcc.dll) do @copy>nul %%f %BINDIR%\%%f
177@if not exist %INST%\lib mkdir %INST%\lib179if not exist %TCCDIR% mkdir %TCCDIR%
178for %%f in (lib\*.a lib\*.o lib\*.def) do @copy>nul %%f %INST%\%%f180@if not exist %TCCDIR%\lib mkdir %TCCDIR%\lib
179for %%f in (include examples libtcc doc) do @xcopy>nul /s/i/q/y %%f %INST%\%%f181for %%f in (lib\*.a lib\*.o lib\*.def) do @copy>nul %%f %TCCDIR%\%%f
182for %%f in (include examples libtcc doc) do @xcopy>nul /s/i/q/y %%f %TCCDIR%\%%f
180 183
181:the_end184:the_end
182exit /B %ERRORLEVEL%185exit /B %ERRORLEVEL%
183 186
184:makelib187:make_lib
185.\tcc -m%1 -c ../lib/libtcc1.c188.\tcc -B. -m%1 -c ../lib/libtcc1.c
186.\tcc -m%1 -c lib/crt1.c189.\tcc -B. -m%1 -c lib/crt1.c
187.\tcc -m%1 -c lib/crt1w.c190.\tcc -B. -m%1 -c lib/crt1w.c
188.\tcc -m%1 -c lib/wincrt1.c191.\tcc -B. -m%1 -c lib/wincrt1.c
189.\tcc -m%1 -c lib/wincrt1w.c192.\tcc -B. -m%1 -c lib/wincrt1w.c
190.\tcc -m%1 -c lib/dllcrt1.c193.\tcc -B. -m%1 -c lib/dllcrt1.c
191.\tcc -m%1 -c lib/dllmain.c194.\tcc -B. -m%1 -c lib/dllmain.c
192.\tcc -m%1 -c lib/chkstk.S195.\tcc -B. -m%1 -c lib/chkstk.S
193.\tcc -m%1 -c ../lib/alloca.S196.\tcc -B. -m%1 -c ../lib/alloca.S
194.\tcc -m%1 -c ../lib/alloca-bt.S197.\tcc -B. -m%1 -c ../lib/alloca-bt.S
195.\tcc -m%1 -c ../lib/stdatomic.c198.\tcc -B. -m%1 -c ../lib/stdatomic.c
196.\tcc -m%1 -ar lib/libtcc1-%1.a libtcc1.o crt1.o crt1w.o wincrt1.o wincrt1w.o dllcrt1.o dllmain.o chkstk.o alloca.o alloca-bt.o stdatomic.o199.\tcc -B. -m%1 -ar lib/%2libtcc1.a libtcc1.o crt1.o crt1w.o wincrt1.o wincrt1w.o dllcrt1.o dllmain.o chkstk.o alloca.o alloca-bt.o stdatomic.o
200.\tcc -B. -m%1 -c ../lib/bcheck.c -o lib/%2bcheck.o -bt
201.\tcc -B. -m%1 -c ../lib/bt-exe.c -o lib/%2bt-exe.o
202.\tcc -B. -m%1 -c ../lib/bt-log.c -o lib/%2bt-log.o
203.\tcc -B. -m%1 -c ../lib/bt-dll.c -o lib/%2bt-dll.o
197exit /B %ERRORLEVEL%204exit /B %ERRORLEVEL%

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