- tccpp.c: rename ... to __TCC_BCHECK__/__TCC_BACKTRACE__ - libtcc.c: correct total line count - libtcc.c: support -run -- args... (instead of -run @ args ...) - Makefile/build-tcc.bat: streamline GITHASH string somewhat - bt-exe.c: avoid redef of pstrcpy() with 'tcc -bt tcc.c ...'
Unified · Split
| @@ -243,12 +243,10 @@ $(TCC_FILES) : DEFINES += -DONE_SOURCE=0 · 242 unmodified lines | ||
| 243 | 243 | $(X)tccpp.o : $(TCCDEFS_H) |
| 244 | 244 | endif |
| 245 | 245 | |
| 246 | −FROM_GIT := $(shell git rev-parse >/dev/null 2>&1 && echo yes || echo no) | |
| 247 | − | |
| 248 | −ifeq ($(FROM_GIT),yes) | |
| 249 | −GITHASH:=$(shell git rev-parse --abbrev-ref HEAD):$(shell git rev-parse --short HEAD) $(shell git log -1 --pretty='format:%cI') | |
| 250 | −GITLOCAL:=$(shell git diff --quiet || echo ' locally modified') | |
| 251 | −DEF_GITHASH:= -DTCC_GITHASH="\"$(GITHASH)$(GITLOCAL)\"" | |
| 246 | +GITHASH:=$(shell git rev-parse --abbrev-ref HEAD 2>/dev/null || echo no) | |
| 247 | +ifneq ($(GITHASH),no) | |
| 248 | +GITHASH:=$(shell git log -1 --pretty='format:%cs $(GITHASH)@%h')$(shell git diff --quiet || echo '*') | |
| 249 | +DEF_GITHASH:= -DTCC_GITHASH="\"$(GITHASH)\"" | |
| 252 | 250 | endif |
| 253 | 251 | |
| 254 | 252 | ifeq ($(CONFIG_debug),yes) |
| @@ -270,7 +268,7 @@ $(X)%.o : %.c $(LIBTCC_INC) · 15 unmodified lines | ||
| 270 | 268 | |
| 271 | 269 | # additional dependencies |
| 272 | 270 | $(X)tcc.o : tcctools.c |
| 273 | −$(X)tcc.o : DEFINES += $(DEF_GITHASH) $(DEF_GITDATE) | |
| 271 | +$(X)tcc.o : DEFINES += $(DEF_GITHASH) | |
| 274 | 272 | |
| 275 | 273 | # Host Tiny C Compiler |
| 276 | 274 | tcc$(EXESUF): tcc.o $(LIBTCC) |
| @@ -245,7 +245,7 @@ · 244 unmodified lines | ||
| 245 | 245 | # define __RENAME(X) __asm__(X) |
| 246 | 246 | #endif |
| 247 | 247 | |
| 248 | − #ifdef __BOUNDS_CHECKING_ON | |
| 248 | + #ifdef __TCC_BCHECK__ | |
| 249 | 249 | # define __BUILTINBC(ret,name,params) ret __builtin_##name params __RENAME("__bound_"#name); |
| 250 | 250 | # define __BOUND(ret,name,params) ret name params __RENAME("__bound_"#name); |
| 251 | 251 | #else |
| @@ -3,7 +3,8 @@ · 2 unmodified lines | ||
| 3 | 3 | from tccrun.c into executables. */ |
| 4 | 4 | |
| 5 | 5 | #define CONFIG_TCC_BACKTRACE_ONLY |
| 6 | −#define ONE_SOURCE 0 | |
| 6 | +#define ONE_SOURCE 1 | |
| 7 | +#define pstrcpy tcc_pstrcpy | |
| 7 | 8 | #include "../tccrun.c" |
| 8 | 9 | |
| 9 | 10 | int (*__rt_error)(void*, void*, const char *, va_list); |
| @@ -695,7 +695,7 @@ ST_FUNC void tcc_close(void) · 694 unmodified lines | ||
| 695 | 695 | BufferedFile *bf = file; |
| 696 | 696 | if (bf->fd > 0) { |
| 697 | 697 | close(bf->fd); |
| 698 | − total_lines += bf->line_num; | |
| 698 | + total_lines += bf->line_num - 1; | |
| 699 | 699 | } |
| 700 | 700 | if (bf->true_filename != bf->filename) |
| 701 | 701 | tcc_free(bf->true_filename); |
| @@ -1867,9 +1867,9 @@ PUB_FUNC int tcc_parse_args(TCCState *s, int *pargc, char ***pargv, int optind) · 1165 unmodified lines | ||
| 1867 | 1867 | } |
| 1868 | 1868 | reparse: |
| 1869 | 1869 | if (r[0] != '-' || r[1] == '\0') { |
| 1870 | − if (r[0] != '@') /* allow "tcc file(s) -run @ args ..." */ | |
| 1871 | − args_parser_add_file(s, r, s->filetype); | |
| 1870 | + args_parser_add_file(s, r, s->filetype); | |
| 1872 | 1871 | if (run) { |
| 1872 | +dorun: | |
| 1873 | 1873 | if (tcc_set_options(s, run)) |
| 1874 | 1874 | return -1; |
| 1875 | 1875 | arg_start = optind - 1; |
| @@ -1878,6 +1878,10 @@ reparse: · 2 unmodified lines | ||
| 1878 | 1878 | continue; |
| 1879 | 1879 | } |
| 1880 | 1880 | |
| 1881 | + /* allow "tcc files... -run -- args ..." */ | |
| 1882 | + if (r[1] == '-' && r[2] == '\0' && run) | |
| 1883 | + goto dorun; | |
| 1884 | + | |
| 1881 | 1885 | /* find option in table */ |
| 1882 | 1886 | for(popt = tcc_options; ; ++popt) { |
| 1883 | 1887 | const char *p1 = popt->name; |
| @@ -27,7 +27,7 @@ · 26 unmodified lines | ||
| 27 | 27 | static const char help[] = |
| 28 | 28 | "Tiny C Compiler "TCC_VERSION" - Copyright (C) 2001-2006 Fabrice Bellard\n" |
| 29 | 29 | "Usage: tcc [options...] [-o outfile] [-c] infile(s)...\n" |
| 30 | − " tcc [options...] -run infile [arguments...]\n" | |
| 30 | + " tcc [options...] -run infile (or --) [arguments...]\n" | |
| 31 | 31 | "General options:\n" |
| 32 | 32 | " -c compile only - generate an object file\n" |
| 33 | 33 | " -o outfile set output filename\n" |
| @@ -3588,6 +3588,14 @@ static void tcc_predefs(TCCState *s1, CString *cs, int is_asm) · 3587 unmodified lines | ||
| 3588 | 3588 | putdef(cs, "__TCC_PP__"); |
| 3589 | 3589 | if (s1->output_type == TCC_OUTPUT_MEMORY) |
| 3590 | 3590 | putdef(cs, "__TCC_RUN__"); |
| 3591 | +#ifdef CONFIG_TCC_BACKTRACE | |
| 3592 | + if (s1->do_backtrace) | |
| 3593 | + putdef(cs, "__TCC_BACKTRACE__"); | |
| 3594 | +#endif | |
| 3595 | +#ifdef CONFIG_TCC_BCHECK | |
| 3596 | + if (s1->do_bounds_check) | |
| 3597 | + putdef(cs, "__TCC_BCHECK__"); | |
| 3598 | +#endif | |
| 3591 | 3599 | if (s1->char_is_unsigned) |
| 3592 | 3600 | putdef(cs, "__CHAR_UNSIGNED__"); |
| 3593 | 3601 | if (s1->optimize > 0) |
| @@ -3596,14 +3604,6 @@ static void tcc_predefs(TCCState *s1, CString *cs, int is_asm) · 2 unmodified lines | ||
| 3596 | 3604 | putdef(cs, "_REENTRANT"); |
| 3597 | 3605 | if (s1->leading_underscore) |
| 3598 | 3606 | putdef(cs, "__leading_underscore"); |
| 3599 | −#ifdef CONFIG_TCC_BCHECK | |
| 3600 | − if (s1->do_bounds_check) | |
| 3601 | − putdef(cs, "__BOUNDS_CHECKING_ON"); | |
| 3602 | −#endif | |
| 3603 | −#ifdef CONFIG_TCC_BACKTRACE | |
| 3604 | − if (s1->do_backtrace) | |
| 3605 | − putdef(cs, "__TCC_BACKTRACE_ENABLED__"); | |
| 3606 | −#endif | |
| 3607 | 3607 | cstr_printf(cs, "#define __SIZEOF_POINTER__ %d\n", PTR_SIZE); |
| 3608 | 3608 | cstr_printf(cs, "#define __SIZEOF_LONG__ %d\n", LONG_SIZE); |
| 3609 | 3609 | if (!is_asm) { |
| @@ -11,7 +11,7 @@ main (void) · 10 unmodified lines | ||
| 11 | 11 | char tmp[100]; |
| 12 | 12 | int r = 0; |
| 13 | 13 | |
| 14 | −#if defined __BOUNDS_CHECKING_ON || defined BC_ON | |
| 14 | +#if defined __TCC_BCHECK__ | |
| 15 | 15 | printf("BOUNDS ON:\n"); |
| 16 | 16 | #else |
| 17 | 17 | printf("BOUNDS OFF:\n"); |
| @@ -7,14 +7,6 @@ setlocal · 6 unmodified lines | ||
| 7 | 7 | if (%1)==(-clean) goto :cleanup |
| 8 | 8 | set CC=gcc |
| 9 | 9 | set /p VERSION= < ..\VERSION |
| 10 | −git.exe --version 2>nul | |
| 11 | −if not %ERRORLEVEL%==0 goto :git_done | |
| 12 | −for /f %%b in ('git.exe rev-parse --abbrev-ref HEAD') do set GITHASH=%%b | |
| 13 | −for /f %%h in ('git.exe rev-parse --short HEAD') do set GITHASH=%GITHASH%:%%h | |
| 14 | −git.exe diff --quiet | |
| 15 | −if %ERRORLEVEL%==1 set GITHASH=%GITHASH%-mod | |
| 16 | −set DEF_GITHASH=-DTCC_GITHASH="""%GITHASH%""" | |
| 17 | −:git_done | |
| 18 | 10 | set INST= |
| 19 | 11 | set DOC=no |
| 20 | 12 | set EXES_ONLY=no |
| @@ -94,7 +86,7 @@ set T=32 · 73 unmodified lines | ||
| 94 | 86 | if %PROCESSOR_ARCHITECTURE%_==AMD64_ set T=64 |
| 95 | 87 | if %PROCESSOR_ARCHITEW6432%_==AMD64_ set T=64 |
| 96 | 88 | :p2 |
| 97 | −if "%CC:~-3%"=="gcc" set CC=%CC% -O2 -s -static %DEF_GITHASH% | |
| 89 | +if "%CC:~-3%"=="gcc" set CC=%CC% -O2 -s -static | |
| 98 | 90 | set D32=-DTCC_TARGET_PE -DTCC_TARGET_I386 |
| 99 | 91 | set D64=-DTCC_TARGET_PE -DTCC_TARGET_X86_64 |
| 100 | 92 | set P32=i386-win32 |
| @@ -113,6 +105,15 @@ set TX=32 · 12 unmodified lines | ||
| 113 | 105 | goto :p3 |
| 114 | 106 | |
| 115 | 107 | :p3 |
| 108 | +git.exe --version 2>nul | |
| 109 | +if not %ERRORLEVEL%==0 goto :git_done | |
| 110 | +for /f %%b in ('git.exe rev-parse --abbrev-ref HEAD') do set GITHASH=%%b | |
| 111 | +for /f %%b in ('git.exe log -1 "--pretty=format:%%cs_%GITHASH%@%%h"') do set GITHASH=%%b | |
| 112 | +git.exe diff --quiet | |
| 113 | +if %ERRORLEVEL%==1 set GITHASH=%GITHASH%* | |
| 114 | +set DEF_GITHASH=-DTCC_GITHASH="""%GITHASH%""" | |
| 115 | +:git_done | |
| 116 | + | |
| 116 | 117 | @echo on |
| 117 | 118 | |
| 118 | 119 | :config.h |
| @@ -134,7 +135,7 @@ for %%f in (*tcc.exe *tcc.dll) do @del %%f · 15 unmodified lines | ||
| 134 | 135 | @if _%LIBTCC_C%_==__ set LIBTCC_C=..\libtcc.c |
| 135 | 136 | %CC% -o libtcc.dll -shared %LIBTCC_C% %D% -DLIBTCC_AS_DLL |
| 136 | 137 | @if errorlevel 1 goto :the_end |
| 137 | −%CC% -o tcc.exe ..\tcc.c libtcc.dll %D% -DONE_SOURCE"=0" | |
| 138 | +%CC% -o tcc.exe ..\tcc.c libtcc.dll %D% -DONE_SOURCE"=0" %DEF_GITHASH% | |
| 138 | 139 | %CC% -o %PX%-tcc.exe ..\tcc.c %DX% |
| 139 | 140 | :compiler_done |
| 140 | 141 | @if (%EXES_ONLY%)==(yes) goto :files_done |