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 @@
11 name: build and run tests
2+
23 on:
34 push:
45 branches: [ mob ]
5− pull_request:
6− branches: [ mob ]
6+
77 jobs:
8− build-release-linux-i686-amd64:
9− name: tinycc master linux/amd64
8+ test-x86_64-linux:
109 runs-on: ubuntu-20.04
1110 steps:
12− - uses: actions/checkout@v2
13− - name: Install dependencies
14− run: sudo apt-get install -y
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
11+ - uses: actions/checkout@v3
12+ - name: make & test tcc
13+ run: ./configure && make && make test -k
2814
29− build-release-osx-amd64:
30− name: tinycc master osx/amd64
15+ test-x86_64-osx:
3116 runs-on: macos-11
3217 steps:
33− - uses: actions/checkout@v2
34− # see what's available in /usr/bin
35− - name: see what's available
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
18+ - uses: actions/checkout@v3
19+ - name: make & test tcc
20+ run: ./configure && make && make test -k
4621
47− build-release-windows-amd64-on-windows:
48− name: tinycc master windows/amd64 on Windows
49− runs-on: windows-latest
22+ test-x86_64-win32:
23+ runs-on: windows-2019
5024 steps:
51− - uses: actions/checkout@v2
52− - uses: msys2/setup-msys2@v2
53− # build project amd64
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
25+ - uses: actions/checkout@v3
26+ - name: make & test tcc
27+ shell: cmd
6728 run: |
68− make test
29+ 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
3131 TAGS
3232 tcc.1
3333 *.pod
34+*.tcov
3435 tcc-doc.html
3536 tcc-doc.info
36−tcc_c.tcov
3737
3838 win32/doc
3939 win32/examples/libtcc_test.c
Changelog+14−7
@@ -1,19 +1,26 @@
11 version 0.9.28:
22
33 User 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)
59
610 Platforms:
7−- new RISC-V (riscv64) target
8−- native macOS support for x86_64/arm64 (Herman ten Brugge)
11+- new RISC-V (riscv64) target (Michael Matz)
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)
915
1016 Features:
11−- Improved support for C11
12−- C11 _Static_assert support (matthias)
17+- _Static_assert() (matthias)
18+- __attribute__ ((cleanup(func))) (matthias)
19+- stdatomic (Dmitry Selyutin)
20+- asm goto ("jmp %l[label]" : : : : label) (Michael Matz)
1321
1422 Fixes:
15−- fix preprocessor line (#line) directive (Herman ten Brugge)
16−Many more! see also git shortlog release_0_9_27...HEAD
23+- ... many, see git shortlog release_0_9_27...release_0_9_27
1724
1825 Version 0.9.27:
1926
Makefile+50−62
@@ -30,13 +30,19 @@ ifdef CONFIG_WIN32 · 29 unmodified lines
3030 LIBTCC = libtcc$(DLLSUF)
3131 LIBTCCDEF = libtcc.def
3232 endif
33+ ifneq ($(CONFIG_debug),yes)
34+ LDFLAGS += -s
35+ endif
3336 NATIVE_TARGET = $(ARCH)-win$(if $(findstring arm,$(ARCH)),ce,32)
3437 else
3538 CFG = -unx
36− LIBS=-lm -lpthread
39+ LIBS+=-lm
3740 ifneq ($(CONFIG_ldl),no)
3841 LIBS+=-ldl
3942 endif
43+ ifneq ($(CONFIG_pthread),no)
44+ LIBS+=-lpthread
45+ endif
4046 # make libtcc as static or dynamic library?
4147 ifeq ($(CONFIG_static),no)
4248 LIBTCC=libtcc$(DLLSUF)
@@ -68,11 +74,8 @@ endif · 25 unmodified lines
6874 TCCFLAGS-unx = -B$(TOP) -I$(TOPSRC)/include -I$(TOPSRC) -I$(TOP)
6975 TCCFLAGS-win = -B$(TOPSRC)/win32 -I$(TOPSRC)/include -I$(TOPSRC) -I$(TOP) -L$(TOP)
7076 TCCFLAGS = $(TCCFLAGS$(CFG))
71−ifdef USE_TCC_C
72−TCC = $(TOP)/tcc_c$(EXESUF) $(TCCFLAGS)
73−else
74−TCC = $(TOP)/tcc$(EXESUF) $(TCCFLAGS)
75−endif
77+TCC_LOCAL = $(TOP)/tcc$(EXESUF)
78+TCC = $(TCC_LOCAL) $(TCCFLAGS)
7679
7780 CFLAGS_P = $(CFLAGS) -pg -static -DCONFIG_TCC_STATIC -DTCC_PROFILE
7881 LIBS_P = $(LIBS)
@@ -181,11 +184,8 @@ DEFINES += $(if $(ELF-$T),-DCONFIG_TCC_ELFINTERP="\"$(ELF-$T)\"") · 102 unmodified lines
181184 DEFINES += $(DEF-$(or $(findstring win,$T),unx))
182185
183186 ifneq ($(X),)
184−ifeq ($(CONFIG_WIN32),yes)
185−DEF-win += -DCONFIG_TCC_CROSSPREFIX="\"$X\""
186−DEF-unx += -DCONFIG_TCC_CROSSPREFIX="\"lib/$X\""
187−else
188187 DEF-all += -DCONFIG_TCC_CROSSPREFIX="\"$X\""
188+ifneq ($(CONFIG_WIN32),yes)
189189 DEF-win += -DCONFIG_TCCDIR="\"$(tccdir)/win32\""
190190 endif
191191 endif
@@ -249,17 +249,14 @@ endif · 57 unmodified lines
249249
250250 GITHASH:=$(shell git rev-parse --abbrev-ref HEAD 2>/dev/null || echo no)
251251 ifneq ($(GITHASH),no)
252−GITHASH:=$(shell git log -1 --pretty='format:%cs $(GITHASH)@%h')$(shell git diff --quiet || echo '*')
253−DEF_GITHASH:= -DTCC_GITHASH="\"$(GITHASH)\""
252+GITHASH:=$(shell git log -1 --date=short --pretty='format:%cd $(GITHASH)@%h')
253+GITMODF:=$(shell git diff --quiet || echo '*')
254+DEF_GITHASH:= -DTCC_GITHASH="\"$(GITHASH)$(GITMODF)\""
254255 endif
255256
256257 ifeq ($(CONFIG_debug),yes)
257258 CFLAGS += -g
258259 LDFLAGS += -g
259−else
260−ifndef CONFIG_OSX
261−LDFLAGS += -s
262−endif
263260 endif
264261
265262 # convert "include/tccdefs.h" to "tccdefs_.h"
@@ -335,7 +332,11 @@ libtcc1.a : tcc$(EXESUF) FORCE · 69 unmodified lines
335332 .PRECIOUS: %-libtcc1.a
336333 FORCE:
337334
338−run-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
337+WHICH = sh -c 'command -v $1'
338+
339+run-if = $(if $(shell $(call WHICH,$1)),$S $1 $2)
339340 S = $(if $(findstring yes,$(SILENT)),@$(info * $@))
340341
341342 # --------------------------------------------------------------------------
@@ -348,7 +349,7 @@ tcc-doc.info: tcc-doc.texi · 6 unmodified lines
348349
349350 tcc.1 : tcc-doc.pod
350351 $(call run-if,pod2man,--section=1 --center="Tiny C Compiler" \
351− --release="$(VERSION)" $< >$@ && rm -f $<)
352+ --release="$(VERSION)" $< >$@)
352353 %.pod : %.texi
353354 $(call run-if,perl,$(TOPSRC)/texi2pod.pl $< $@)
354355
@@ -392,8 +393,9 @@ endif · 37 unmodified lines
392393
393394 # uninstall
394395 uninstall-unx:
395− @rm -fv $(foreach P,$(PROGS) $(PROGS_CROSS),"$(bindir)/$P")
396− @rm -fv "$(libdir)/libtcc.a" "$(libdir)/libtcc.so" "$(libdir)/libtcc.dylib" "$(includedir)/libtcc.h"
396+ @rm -fv $(addprefix "$(bindir)/",$(PROGS) $(PROGS_CROSS))
397+ @rm -fv $(addprefix "$(libdir)/", libtcc*.a libtcc*.so libtcc.dylib,$P)
398+ @rm -fv $(addprefix "$(includedir)/", libtcc.h)
397399 @rm -fv "$(mandir)/man1/tcc.1" "$(infodir)/tcc-doc.info"
398400 @rm -fv "$(docdir)/tcc-doc.html"
399401 @rm -frv "$(tccdir)"
@@ -415,17 +417,19 @@ ifneq "$(wildcard $(LIBTCC1_U))" "" · 15 unmodified lines
415417 $(call IF,$(TOPSRC)/include/*.h $(TOPSRC)/tcclib.h,"$(tccdir)/lib/include")
416418 endif
417419
418−# the msys-git shell works to configure && make except it does not have install
419−ifeq ($(CONFIG_WIN32)-$(shell command -v install || echo no),yes-no)
420−install-win : INSTALL = cp
421−install-win : INSTALLBIN = cp
422−endif
423−
424420 # uninstall on windows
425421 uninstall-win:
426− @rm -fv $(foreach P,libtcc.dll $(PROGS) *-tcc.exe,"$(bindir)"/$P)
427− @rm -fr $(foreach P,doc examples include lib libtcc,"$(tccdir)/$P"/*)
428− @rm -frv $(foreach P,doc examples include lib libtcc,"$(tccdir)/$P")
422+ @rm -fv $(addprefix "$(bindir)/", libtcc*.dll $(PROGS) *-tcc.exe)
423+ @rm -fr $(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
427+ifeq ($(OS),Windows_NT)
428+ifeq ($(shell $(call WHICH,install) || echo no),no)
429+INSTALL = cp
430+INSTALLBIN = cp
431+endif
432+endif
429433
430434 # --------------------------------------------------------------------------
431435 # other stuff
@@ -459,66 +463,50 @@ test: · 27 unmodified lines
459463 # run test(s) from tests2 subdir (see make help)
460464 tests2.%:
461465 @$(MAKE) -C tests/tests2 $@
462−
466+# run test(s) from testspp subdir (see make help)
463467 testspp.%:
464468 @$(MAKE) -C tests/pp $@
465−
466−# run all tests with code coverage
469+# run tests with code coverage
470+tcov-tes% : tcc_c$(EXESUF)
471+ @rm -f $<.tcov
472+ @$(MAKE) --no-print-directory TCC_LOCAL=$(CURDIR)/$< tes$*
467473 tcc_c$(EXESUF): $($T_FILES)
468− @${TCC} -o $@ -ftest-coverage $< $(DEFINES) $(CFLAGS) $(LIBS) $(LDFLAGS)
469−testc: tcc_c$(EXESUF)
470− @rm -f tcc_c.tcov
471− @USE_TCC_C=yes $(MAKE) -C tests
472−testc2.%: tcc_c$(EXESUF)
473− @rm -f tcc_c.tcov
474− @USE_TCC_C=yes $(MAKE) -C tests/tests2 $@
475−testcpp.%: tcc_c$(EXESUF)
476− @rm -f tcc_c.tcov
477− @USE_TCC_C=yes $(MAKE) -C tests/pp $@
474+ $S$(TCC) tcc.c -o $@ -ftest-coverage $(DEFINES)
478475
479476 clean:
480− @rm -f tcc$(EXESUF) tcc_c$(EXESUF) tcc_p$(EXESUF) *-tcc$(EXESUF) tags ETAGS *.pod
481− @rm -f *.o *.a *.so* *.out *.log lib*.def *.exe *.dll a.out *.dylib *_.h
477+ @rm -f tcc$(EXESUF) tcc_c$(EXESUF) tcc_p$(EXESUF) *-tcc$(EXESUF)
478+ @rm -f tags ETAGS *.o *.a *.so* *.out *.log lib*.def *.exe *.dll
479+ @rm -f a.out *.dylib *_.h *.pod *.tcov
482480 @$(MAKE) -s -C lib $@
483481 @$(MAKE) -s -C tests $@
484482
485483 distclean: clean
486− @rm -f config.h config.mak config.texi
487− @rm -f $(TCCDOCS)
484+ @rm -vf config.h config.mak config.texi
485+ @rm -vf $(TCCDOCS)
488486
489487 .PHONY: all clean test tar tags ETAGS doc distclean install uninstall FORCE
490488
491489 help:
492490 @echo "make"
493491 @echo " build native compiler (from separate objects)"
494− @echo ""
495492 @echo "make cross"
496493 @echo " build cross compilers (from one source)"
497− @echo ""
498494 @echo "make ONE_SOURCE=no/yes SILENT=no/yes"
499495 @echo " force building from separate/one object(s), less/more silently"
500− @echo ""
501496 @echo "make cross-TARGET"
502497 @echo " build one specific cross compiler for 'TARGET'. Currently supported:"
503− @echo " $(wordlist 1,6,$(TCC_X))"
504− @echo " $(wordlist 7,99,$(TCC_X))"
505− @echo ""
498+ @echo " $(wordlist 1,8,$(TCC_X))"
499+ @echo " $(wordlist 9,99,$(TCC_X))"
506500 @echo "make test"
507501 @echo " run all tests"
508− @echo ""
509− @echo "make tests2.all / make tests2.37 / make tests2.37+ / make tests2.37-"
510− @echo " run all/single test(s) from tests2, optionally update .expect, display"
511− @echo ""
502+ @echo "make tests2.all / make tests2.37 / make tests2.37+"
503+ @echo " run all/single test(s) from tests2, optionally update .expect"
512504 @echo "make testspp.all / make testspp.17"
513505 @echo " run all/single test(s) from tests/pp"
514− @echo ""
515− @echo "make testc / testc2.all / testc2.37 / testc2.37+ / testc2.37-"
516− @echo "make testcpp.all / make testcpp.17"
517− @echo " run tests with code coverage. After test(s) see tcc_c.tcov"
518− @echo ""
506+ @echo "make tcov-test / tcov-tests2... / tcov-testspp..."
507+ @echo " run tests as above with code coverage. After test(s) see tcc_c$(EXESUF).tcov"
519508 @echo "Other supported make targets:"
520509 @echo " install install-strip doc clean tags ETAGS tar distclean help"
521− @echo ""
522510 @echo "Custom configuration:"
523511 @echo " The makefile includes a file 'config-extra.mak' if it is present."
524512 @echo " This file may contain some custom configuration. For example:"
TODO+2−1
@@ -1,7 +1,8 @@
11 TODO list:
22
33 Releases:
4−- release tcc on a regular basis (which interval? 3 months?)
4+
5+- release tcc on a regular basis
56
67 Bugs:
78
USES+48−0
@@ -7,6 +7,7 @@ bigz An infinite precision Z & Q library. · 6 unmodified lines
77 gawk GNU awk.
88 gmp Library for arbitrary precision arithmetic.
99 gnumake GNU makefile.
10+gnu mes using tinycc to bootstrap a system
1011 mpfr Multiple-precision floating-point library.
1112 mpc Complex floating-point library with exact rounding.
1213 mpv A free, open source, and cross-platform media player.
@@ -18,3 +19,50 @@ tcc Tiny CC which compiles itself. · 5 unmodified lines
1819 zlib Lossless data-compression library.
1920
2021 (*) This list is ordered by name.
22+
23+
24+
25+Forks & Experiments
26+-------------------
27+
28+arm-thumb target
29+ by Erlend Sveen <erlend.sveen@hotmail.com>
30+ https://git.erlendjs.no/erlendjs/tinycc.git
31+
32+riscv32 target
33+ by Sam Ellicott <sellicott@cedarville.edu>
34+ https://github.com/sellicott/tcc-riscv32.git
35+
36+Transputer target
37+ by David Smith <agentdavo@mac.com>
38+ https://github.com/agentdavo/tinycc-transputer
39+
40+tcc-65816 - Tiny C Compiler for 65816 CPU (based on V0.9.23) from SNES-SDK
41+ https://github.com/nArnoSNES/tcc-65816
42+
43+PE-UEFI arm64
44+ by Andrei Warkentin <andrey.warkentin@gmail.com>
45+ https://github.com/andreiw/tinycc/
46+
47+TCCLS - global register allocator (proof of concept)
48+ by Sebastian Falbesoner <sebastian.falbesoner@gmail.com>
49+ https://bitbucket.org/theStack/tccls_poc.git
50+
51+softfloat
52+ by Giovanni Mascellani <gio@debian.org>
53+ https://gitlab.com/giomasce/tinycc.git
54+
55+optimize 386
56+ by Jason Hood <jadoxa@yahoo.com.au>
57+
58+tcctcl : tcl binding
59+ https://code.google.com/archive/p/tcltcc/
60+
61+tcc4tcl : tcl binding
62+ https://chiselapp.com/user/rkeene/repository/tcc4tcl/index
63+
64+lua-tcc : allows a Lua script to compile C code
65+ https://github.com/javierguerragiraldez/lua-tcc
66+
67+tcclua : semi-high-level bindings for `libtcc`
68+ https://github.com/nucular/tcclua/blob/master/tcc.lua
VERSION+1−1
@@ -1 +1 @@
1−0.9.27
1+0.9.28rc
configure+235−180
@@ -47,70 +47,19 @@ gcc_major=0 · 46 unmodified lines
4747 gcc_minor=0
4848 cc_name="gcc"
4949 ar_set=
50−darwin=
50+cpu=
5151 cpuver=
5252 dwarf=
53+targetos=
54+build_cross=
5355
54−# use CC from environment when set
56+# use CC/AR from environment when set
5557 test -n "$CC" && cc="$CC"
56−
57−# OS specific
58−cpu=`uname -m`
59−cpu_sys="$cpu"
60−targetos=`uname`
61−if test "$targetos" = "Linux" ; then
62− test "$(uname -o)" = "Android" && targetos=Android
63−fi
64−
65−case $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− ;;
104−esac
58+test -n "$AR" && ar="$AR"
10559
10660 # find source path
10761 source_path=${0%configure}
10862 source_path=${source_path%/}
109−source_path_used="yes"
110−if test -z "$source_path" -o "$source_path" = "." ; then
111− source_path=`pwd`
112− source_path_used="no"
113−fi
11463
11564 for opt do
11665 eval opt=\"$opt\"
@@ -137,6 +86,8 @@ for opt do · 20 unmodified lines
13786 ;;
13887 --sysroot=*) sysroot=`echo $opt | cut -d '=' -f 2-`
13988 ;;
89+ --targetos=*) targetos=`echo $opt | cut -d '=' -f 2-`
90+ ;;
14091 --source-path=*) source_path=`echo $opt | cut -d '=' -f 2-`
14192 ;;
14293 --cross-prefix=*) cross_prefix=`echo $opt | cut -d '=' -f 2-`
@@ -192,16 +143,119 @@ for opt do · 49 unmodified lines
192143 esac
193144 done
194145
195−cc="${cross_prefix}${cc}"
196−ar="${cross_prefix}${ar}"
146+show_help() {
147+cat << EOF
148+Usage: configure [options]
149+Options: [defaults in brackets after descriptions]
150+
151+Standard 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+
165+Advanced 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')
197180
198−# Checking for CFLAGS
199−test -z "$CFLAGS" && CFLAGS="-Wall -O2"
181+ --sysincludepaths=... specify system include paths, colon separated
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+
197+Cross 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]
201+EOF
202+exit 1
203+}
204+
205+default() # set variable unless already set
206+{
207+ local v
208+ eval v=\"\$$1\"
209+ test -z "$v" && eval $1=\"$2\"
210+}
211+
212+default_conf() # add to confvars unless already present
213+{
214+ local v=${1%=*}
215+ test "${confvars%$v*}" = "${confvars}" && confvars="$confvars $1"
216+}
217+
218+if test -z "$source_path" -o "$source_path" = "." ; then
219+ source_path=$(pwd)
220+ source_path_used="no"
221+else
222+ source_path_used="yes"
223+fi
224+
225+# OS specific
226+buildos=$(uname)
227+
228+case $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+ ;;
240+esac
241+
242+if test "$mingw32" = "yes"; then
243+ default targetos WIN32
244+else
245+ default targetos "$buildos"
246+fi
200247
201−# on OSX M1 with --cpu=x86_64, build a tcc to run under rosetta entirely
202−if test "$darwin" = "yes" -a "$cpu" = "x86_64" -a "$cpu_sys" = "arm64"; then
203− CFLAGS="$CFLAGS -arch $cpu"
204− LDFLAGS="$LDFLAGS -arch $cpu"
248+cpu_sys=$(uname -m)
249+default cpu "$cpu_sys"
250+cpu_set="$cpu"
251+
252+# check for crpss build
253+if 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}"
205259 fi
206260
207261 case "$cpu" in
@@ -262,109 +316,101 @@ case "$cpu" in · 54 unmodified lines
262316 ;;
263317 esac
264318
265−if test "$mingw32" = "yes" ; then
266− if test "$source_path_used" = "no"; then
267− source_path="."
319+case $targetos in
320+ Darwin)
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"
268339 fi
269− test -z "$prefix" && prefix="C:/Program Files/tcc"
270− test -z "$tccdir" && tccdir="${prefix}" && tccdir_auto="yes"
271− test -z "$bindir" && bindir="${tccdir}"
272− test -z "$docdir" && docdir="${tccdir}/doc"
273− test -z "$libdir" && libdir="${tccdir}/libtcc"
340+ ;;
341+ DragonFly|OpenBSD|FreeBSD|NetBSD)
342+ confvars="$confvars BSD ldl=no"
343+ ;;
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"
274370 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"
275377 LIBSUF=".lib"
276378 EXESUF=".exe"
277379 DLLSUF=".dll"
278−else
279− if test -z "$prefix" ; then
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"
380+ if test "$source_path_used" = "no"; then
381+ source_path="."
308382 fi
309−fi # mingw32
310−
311−if test x"$show_help" = "xyes" ; then
312−cat << EOF
313−Usage: configure [options]
314−Options: [defaults in brackets after descriptions]
315−
316−Standard 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]
383+ ;;
384+ *)
385+ ;;
386+esac
329387
330−Advanced options (experts only):
331− --source-path=PATH path of source code [$source_path]
332− --cross-prefix=PREFIX use PREFIX for compile tools [$cross_prefix]
333− --sysroot=PREFIX prepend PREFIX to library/include paths [$sysroot]
334− --cc=CC use C compiler CC [$cc]
335− --ar=AR create archives using AR [$ar]
336− --extra-cflags= specify compiler flags [$CFLAGS]
337− --extra-ldflags= specify linker options [$LDFLAGS]
338− --cpu=CPU CPU [$cpu]
388+if test "$mingw32" = "no"; then
389+ default prefix "/usr/local"
390+ default execprefix "${prefix}"
391+ default libdir "${execprefix}/lib"
392+ default bindir "${execprefix}/bin"
393+ default tccdir "${libdir}/tcc"
394+ default includedir "${prefix}/include"
395+ default sharedir "${prefix}/share"
396+ default docdir "${sharedir}/doc"
397+ default mandir "${sharedir}/man"
398+ default infodir "${sharedir}/info"
399+fi
339400
340− --debug include debug info with resulting binaries
341− --disable-static make libtcc.so instead of libtcc.a
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')
401+# set default CFLAGS
402+default CFLAGS "-Wall -O2"
347403
348− --sysincludepaths=... specify system include paths, colon separated
349− --libpaths=... specify system library paths, colon separated
350− --crtprefix=... specify locations of crt?.o, colon separated
351− --elfinterp=... specify elf interpreter
352− --triplet=... specify system library/include directory triplet
353− --tcc-switches=... specify implicit switches passed to tcc
404+if test "$mingw32" = "yes" -a "$cc_name" = "gcc"; then
405+ # avoid mingw dependencies such as 'libgcc_s_dw2-1.dll'
406+ default LDFLAGS "-static"
407+fi
354408
355− --config-uClibc,-musl enable system specific configurations
356− --config-mingw32 build on windows using msys, busybox, etc.
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)
363−EOF
364−exit 1
409+if test x"$show_help" = "xyes" ; then
410+ show_help
365411 fi
366412
367−if test -z "$cross_prefix" ; then
413+if test -z "$build_cross"; then
368414 CONFTEST=./conftest$EXESUF
369415 if ! $cc -o $CONFTEST $source_path/conftest.c ; then
370416 echo "configure: error: '$cc' failed to compile conftest.c."
@@ -376,13 +422,11 @@ if test -z "$cross_prefix" ; then · 5 unmodified lines
376422 _triplet="$($CONFTEST triplet)"
377423 fi
378424 if test "$mingw32" = "no" ; then
379−
380425 if test -z "$triplet" -a -n "$_triplet"; then
381− if test -f "/usr/lib/$_triplet/crti.o" -o -n "$use_triplet" ; then
426+ if test -f "/usr/lib/$_triplet/crti.o"; then
382427 triplet="$_triplet"
383428 fi
384429 fi
385−
386430 if test -z "$triplet"; then
387431 if test $cpu = "x86_64" -o $cpu = "arm64" -o $cpu = "riscv64" ; then
388432 if test -f "/usr/lib64/crti.o" ; then
@@ -390,21 +434,6 @@ if test -z "$cross_prefix" ; then · 1 unmodified line
390434 fi
391435 fi
392436 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−
408437 if test "$suggest" = "yes"; then
409438 if test -f "/lib/ld-uClibc.so.0" ; then
410439 echo "Perhaps you want ./configure --config-uClibc"
@@ -413,23 +442,43 @@ if test -z "$cross_prefix" ; then · 2 unmodified lines
413442 echo "Perhaps you want ./configure --config-musl"
414443 fi
415444 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
421445 fi
422446 else
423− # if cross compiling, cannot launch a program, so make a static guess
447+ # 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
424453 case $cpu in
425454 ppc|mips|s390) bigendian=yes;;
426455 esac
456+ case $targetos in
457+ Linux)
458+ default triplet "$cpu_set-linux-gnu"
459+ esac
427460 fi
428461
429462 if test "$bigendian" = "yes" ; then
430463 confvars="$confvars BIGENDIAN"
431464 fi
432465
466+if 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
480+fi
481+
433482 # a final configuration tuning
434483 if test "$cc_name" != "tcc"; then
435484 OPT1="-Wdeclaration-after-statement -fno-strict-aliasing"
@@ -438,7 +487,7 @@ if test "$cc_name" != "tcc"; then · 2 unmodified lines
438487 OPT2="$OPT2 -Wstringop-truncation"
439488 if test "$cc_name" = "clang"; then
440489 OPT1="$OPT1 -fheinous-gnu-extensions"
441− OPT2="$OPT2 -Wstring-plus-int"
490+ OPT2="$OPT2 -Wstring-plus-int -Wdeprecated-declarations"
442491 fi
443492 $cc $OPT1 $OPT2 -o a.out -c -xc - < /dev/null > cc_msg.txt 2>&1
444493 for o in $OPT1; do # enable these options
@@ -470,6 +519,11 @@ echo "C compiler $cc ($gcc_major.$gcc_minor)" · 25 unmodified lines
470519 echo "Target OS $targetos"
471520 echo "CPU $cpu"
472521 fcho "Triplet " "$triplet"
522+fcho "Libs " "$tcc_libpaths"
523+fcho "Sysinclude " "$tcc_sysincludepaths"
524+fcho "Crt " "$tcc_crtprefix"
525+fcho "Elfinterp " "$tcc_elfinterp"
526+fcho "Switches " "$tcc_switches"
473527 fcho "Config " "${confvars# }"
474528 echo "Creating config.mak and config.h"
475529
@@ -530,6 +584,7 @@ print_mak TCC_CPU_VERSION "$cpuver" num · 54 unmodified lines
530584
531585 echo "ARCH=$cpu" >> config.mak
532586 echo "TARGETOS=$targetos" >> config.mak
587+echo "BUILDOS=$buildos" >> config.mak
533588
534589 predefs="1"
535590 for v in $confvars ; do
conftest.c+6−8
@@ -1,8 +1,8 @@
11 /* ----------------------------------------------------------------------- */
2−#if C2STR
3−
42 /* with -D C2STR: convert tccdefs.h to C-strings */
53
4+#if C2STR
5+
66 #include <stdio.h>
77 #include <string.h>
88
@@ -166,14 +166,16 @@ int main(int argc, char **argv) · 157 unmodified lines
166166 }
167167
168168 /* ----------------------------------------------------------------------- */
169−#elif 1
170−
171169 /* get some information from the host compiler for configure */
172170
171+#elif 1
172+
173173 #include <stdio.h>
174174
175175 #if defined(_WIN32)
176176 #include <fcntl.h>
177+#include <io.h>
178+int _CRT_glob = 0;
177179 #endif
178180
179181 /* Define architecture */
@@ -233,10 +235,6 @@ int main(int argc, char **argv) · 53 unmodified lines
233235 # define TRIPLET TRIPLET_ARCH "-" TRIPLET_OS "-" TRIPLET_ABI
234236 #endif
235237
236−#if defined(_WIN32)
237−int _CRT_glob = 0;
238−#endif
239−
240238 int main(int argc, char *argv[])
241239 {
242240 #if defined(_WIN32)
tcc-doc.texi+6−5
@@ -364,10 +364,11 @@ bounds (@pxref{Bounds}). @option{-g} is implied. · 363 unmodified lines
364364
365365 @item -bt[N]
366366 Display N callers in stack traces. This is useful with @option{-g} or @option{-b}.
367−With executables, additional support for stack traces is included.
367+When activated, @code{__TCC_BACKTRACE__} is defined.
368368
369−A function @code{ int tcc_backtrace(const char *fmt, ...); } is provided
370−to trigger a stack trace with a message on demand.
369+With executables, additional support for stack traces is included. A function
370+ @code{ int tcc_backtrace(const char *fmt, ...); }
371+is provided to trigger a stack trace with a message on demand.
371372
372373 @end table
373374
@@ -937,7 +938,7 @@ Here are some examples of caught errors: · 563 unmodified lines
937938 @end example
938939 @end table
939940
940−TCC defines @code{__BOUNDS_CHECKING_ON} if activated.
941+TCC defines @code{__TCC_BCHECK__} if activated.
941942
942943 There are five environment variables that can be used to control the behavior:
943944 @itemize
@@ -984,7 +985,7 @@ for bounds checking errors. · 40 unmodified lines
984985 @end itemize
985986
986987 @example
987−#if defined(__TINYC__) && __BOUNDS_CHECKING_ON
988+#ifdef __TCC_BCHECK__
988989 extern void __bounds_checking (int x);
989990 # define BOUNDS_CHECKING_OFF __bounds_checking(1)
990991 # define BOUNDS_CHECKING_ON __bounds_checking(-1)
tests/pp/Makefile+2−2
@@ -10,7 +10,7 @@ VPATH = $(SRC) · 9 unmodified lines
1010 files = $(patsubst %.$1,%.test,$(notdir $(wildcard $(SRC)/*.$1)))
1111 TESTS = $(call files,c) $(call files,S)
1212
13−all test testspp.all testcpp.all: $(sort $(TESTS))
13+all test testspp.all: $(sort $(TESTS))
1414
1515 DIFF_OPTS = -Nu -b
1616
@@ -29,7 +29,7 @@ FILTER = 2>&1 | sed 's,$(SRC)/,,g' · 12 unmodified lines
2929 diff $(DIFF_OPTS) $(SRC)/$*.expect $*.output \
3030 && rm -f $*.output
3131
32−testspp.% testcpp.%: %.test ;
32+testspp.%: %.test ;
3333
3434 # automatically generate .expect files with gcc:
3535 %.expect: # %.c
tests/tests2/Makefile+4−4
@@ -124,7 +124,7 @@ endif · 123 unmodified lines
124124 # Filter source directory in warnings/errors (out-of-tree builds)
125125 FILTER = 2>&1 | sed -e 's,$(SRC)/,,g'
126126
127−all test tests2.all testc2.all: $(filter-out $(SKIP),$(TESTS))
127+all test tests2.all: $(filter-out $(SKIP),$(TESTS))
128128 @$(MAKE) clean --no-print-directory -s
129129
130130 %.test: %.c %.expect
@@ -138,15 +138,15 @@ T3 = $(FILTER) >$*.output 2>&1 || true \ · 7 unmodified lines
138138 && rm -f $*.output $(filter $*.expect,$(GEN-ALWAYS))
139139
140140 # run single test and update .expect file, e.g. "make tests2.37+"
141−tests2.%+ testc2.%+:
141+tests2.%+:
142142 @$(MAKE) $(call F2,$(call F1,$*)) --no-print-directory
143143
144144 # just run tcc to see the output, e.g. "make tests2.37-"
145−tests2.%- testc2.%-:
145+tests2.%-:
146146 @$(MAKE) $(call F1,$*) T3= --no-print-directory
147147
148148 # run single test, e.g. "make tests2.37"
149−tests2.% testc2.%:
149+tests2.%:
150150 @$(MAKE) $(call F1,$*) --no-print-directory
151151
152152 F1 = $(or $(filter $1_%,$(TESTS)),$1_???.test)
win32/build-tcc.bat+44−37
@@ -7,7 +7,8 @@ setlocal · 6 unmodified lines
77 if (%1)==(-clean) goto :cleanup
88 set CC=gcc
99 set /p VERSION= < ..\VERSION
10−set INST=
10+set TCCDIR=
11+set BINDIR=
1112 set DOC=no
1213 set EXES_ONLY=no
1314 goto :a0
@@ -23,7 +24,8 @@ goto :a2 · 9 unmodified lines
2324 :a1
2425 if (%1)==(-t) set T=%2&& goto :a2
2526 if (%1)==(-v) set VERSION=%~2&& goto :a2
26−if (%1)==(-i) set INST=%2&& goto :a2
27+if (%1)==(-i) set TCCDIR=%2&& goto :a2
28+if (%1)==(-b) set BINDIR=%2&& goto :a2
2729 if (%1)==(-d) set DOC=yes&& goto :a3
2830 if (%1)==(-x) set EXES_ONLY=yes&& goto :a3
2931 if (%1)==() goto :p1
@@ -35,6 +37,7 @@ echo -c "prog options" use prog with options to compile tcc · 5 unmodified lines
3537 echo -t 32/64 force 32/64 bit default target
3638 echo -v "version" set tcc version
3739 echo -i tccdir install tcc into tccdir
40+echo -b bindir but install tcc.exe and libtcc.dll into bindir
3841 echo -d create tcc-doc.html too (needs makeinfo)
3942 echo -x just create the executables
4043 echo -clean delete all previously produced files and directories
@@ -87,18 +90,24 @@ if %PROCESSOR_ARCHITECTURE%_==AMD64_ set T=64 · 46 unmodified lines
8790 if %PROCESSOR_ARCHITEW6432%_==AMD64_ set T=64
8891 :p2
8992 if "%CC:~-3%"=="gcc" set CC=%CC% -O2 -s -static
93+if (%BINDIR%)==() set BINDIR=%TCCDIR%
94+
9095 set D32=-DTCC_TARGET_PE -DTCC_TARGET_I386
9196 set D64=-DTCC_TARGET_PE -DTCC_TARGET_X86_64
9297 set P32=i386-win32
9398 set P64=x86_64-win32
99+
94100 if %T%==64 goto :t64
95101 set D=%D32%
102+set P=%P32%
96103 set DX=%D64%
97104 set PX=%P64%
98105 set TX=64
99106 goto :p3
107+
100108 :t64
101109 set D=%D64%
110+set P=%P64%
102111 set DX=%D32%
103112 set PX=%P32%
104113 set TX=32
@@ -111,17 +120,16 @@ for /f %%b in ('git.exe rev-parse --abbrev-ref HEAD') do set GITHASH=%%b · 6 unmodified lines
111120 for /f %%b in ('git.exe log -1 "--pretty=format:%%cs_%GITHASH%@%%h"') do set GITHASH=%%b
112121 git.exe diff --quiet
113122 if %ERRORLEVEL%==1 set GITHASH=%GITHASH%*
114−set DEF_GITHASH=-DTCC_GITHASH="""%GITHASH%"""
115123 :git_done
116−
117124 @echo on
118125
119126 :config.h
120127 echo>..\config.h #define TCC_VERSION "%VERSION%"
121−echo>> ..\config.h #ifdef TCC_TARGET_X86_64
122−echo>> ..\config.h #define TCC_LIBTCC1 "libtcc1-64.a"
123−echo>> ..\config.h #else
124−echo>> ..\config.h #define TCC_LIBTCC1 "libtcc1-32.a"
128+if not (%GITHASH%)==() echo>> ..\config.h #define TCC_GITHASH "%GITHASH%"
129+@if not (%BINDIR%)==(%TCCDIR%) echo>> ..\config.h #define CONFIG_TCCDIR "%TCCDIR:\=/%"
130+if %TX%==64 echo>> ..\config.h #ifdef TCC_TARGET_X86_64
131+if %TX%==32 echo>> ..\config.h #ifdef TCC_TARGET_I386
132+echo>> ..\config.h #define CONFIG_TCC_CROSSPREFIX "%PX%-"
125133 echo>> ..\config.h #endif
126134
127135 for %%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
135143 @if _%LIBTCC_C%_==__ set LIBTCC_C=..\libtcc.c
136144 %CC% -o libtcc.dll -shared %LIBTCC_C% %D% -DLIBTCC_AS_DLL
137145 @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"
139147 %CC% -o %PX%-tcc.exe ..\tcc.c %DX%
140148 :compiler_done
141149 @if (%EXES_ONLY%)==(yes) goto :files_done
@@ -151,15 +159,9 @@ copy>nul tcc-win32.txt doc · 9 unmodified lines
151159 if exist libtcc.dll .\tcc -impdef libtcc.dll -o libtcc\libtcc.def
152160 @if errorlevel 1 goto :the_end
153161
154−:libtcc1.a
155−call :makelib %T%
156−@if errorlevel 1 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
162+:lib
163+call :make_lib %T% || goto :the_end
164+@if exist %PX%-tcc.exe call :make_lib %TX% %PX%- || goto :the_end
163165
164166 :tcc-doc.html
165167 @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
171173 for %%f in (*.o *.def) do @del %%f
172174
173175 :copy-install
174−@if (%INST%)==() goto :the_end
175−if not exist %INST% mkdir %INST%
176−for %%f in (*tcc.exe *tcc.dll) do @copy>nul %%f %INST%\%%f
177−@if not exist %INST%\lib mkdir %INST%\lib
178−for %%f in (lib\*.a lib\*.o lib\*.def) do @copy>nul %%f %INST%\%%f
179−for %%f in (include examples libtcc doc) do @xcopy>nul /s/i/q/y %%f %INST%\%%f
176+@if (%TCCDIR%)==() goto :the_end
177+if not exist %BINDIR% mkdir %BINDIR%
178+for %%f in (*tcc.exe *tcc.dll) do @copy>nul %%f %BINDIR%\%%f
179+if not exist %TCCDIR% mkdir %TCCDIR%
180+@if not exist %TCCDIR%\lib mkdir %TCCDIR%\lib
181+for %%f in (lib\*.a lib\*.o lib\*.def) do @copy>nul %%f %TCCDIR%\%%f
182+for %%f in (include examples libtcc doc) do @xcopy>nul /s/i/q/y %%f %TCCDIR%\%%f
180183
181184 :the_end
182185 exit /B %ERRORLEVEL%
183186
184−:makelib
185−.\tcc -m%1 -c ../lib/libtcc1.c
186−.\tcc -m%1 -c lib/crt1.c
187−.\tcc -m%1 -c lib/crt1w.c
188−.\tcc -m%1 -c lib/wincrt1.c
189−.\tcc -m%1 -c lib/wincrt1w.c
190−.\tcc -m%1 -c lib/dllcrt1.c
191−.\tcc -m%1 -c lib/dllmain.c
192−.\tcc -m%1 -c lib/chkstk.S
193−.\tcc -m%1 -c ../lib/alloca.S
194−.\tcc -m%1 -c ../lib/alloca-bt.S
195−.\tcc -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.o
187+:make_lib
188+.\tcc -B. -m%1 -c ../lib/libtcc1.c
189+.\tcc -B. -m%1 -c lib/crt1.c
190+.\tcc -B. -m%1 -c lib/crt1w.c
191+.\tcc -B. -m%1 -c lib/wincrt1.c
192+.\tcc -B. -m%1 -c lib/wincrt1w.c
193+.\tcc -B. -m%1 -c lib/dllcrt1.c
194+.\tcc -B. -m%1 -c lib/dllmain.c
195+.\tcc -B. -m%1 -c lib/chkstk.S
196+.\tcc -B. -m%1 -c ../lib/alloca.S
197+.\tcc -B. -m%1 -c ../lib/alloca-bt.S
198+.\tcc -B. -m%1 -c ../lib/stdatomic.c
199+.\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
197204 exit /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