History

stuff & etc..

- 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 ...'

grischka committed 3 years ago

Commit bb93bf81 parent a0454008 files · +36 −32Browse files

Unified · Split

8 files
  1. Makefile +5 −7
  2. include/tccdefs.h +1 −1
  3. lib/bt-exe.c +2 −1
  4. libtcc.c +7 −3
  5. tcc.c +1 −1
  6. tccpp.c +8 −8
  7. tests/tests2/117_builtins.c +1 −1
  8. win32/build-tcc.bat +11 −10
Makefile+5−7
@@ -243,12 +243,10 @@ $(TCC_FILES) : DEFINES += -DONE_SOURCE=0 · 242 unmodified lines
243243 $(X)tccpp.o : $(TCCDEFS_H)
244244 endif
245245
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)\""
252250 endif
253251
254252 ifeq ($(CONFIG_debug),yes)
@@ -270,7 +268,7 @@ $(X)%.o : %.c $(LIBTCC_INC) · 15 unmodified lines
270268
271269 # additional dependencies
272270 $(X)tcc.o : tcctools.c
273−$(X)tcc.o : DEFINES += $(DEF_GITHASH) $(DEF_GITDATE)
271+$(X)tcc.o : DEFINES += $(DEF_GITHASH)
274272
275273 # Host Tiny C Compiler
276274 tcc$(EXESUF): tcc.o $(LIBTCC)
include/tccdefs.h+1−1
@@ -245,7 +245,7 @@ · 244 unmodified lines
245245 # define __RENAME(X) __asm__(X)
246246 #endif
247247
248− #ifdef __BOUNDS_CHECKING_ON
248+ #ifdef __TCC_BCHECK__
249249 # define __BUILTINBC(ret,name,params) ret __builtin_##name params __RENAME("__bound_"#name);
250250 # define __BOUND(ret,name,params) ret name params __RENAME("__bound_"#name);
251251 #else
lib/bt-exe.c+2−1
@@ -3,7 +3,8 @@ · 2 unmodified lines
33 from tccrun.c into executables. */
44
55 #define CONFIG_TCC_BACKTRACE_ONLY
6−#define ONE_SOURCE 0
6+#define ONE_SOURCE 1
7+#define pstrcpy tcc_pstrcpy
78 #include "../tccrun.c"
89
910 int (*__rt_error)(void*, void*, const char *, va_list);
libtcc.c+7−3
@@ -695,7 +695,7 @@ ST_FUNC void tcc_close(void) · 694 unmodified lines
695695 BufferedFile *bf = file;
696696 if (bf->fd > 0) {
697697 close(bf->fd);
698− total_lines += bf->line_num;
698+ total_lines += bf->line_num - 1;
699699 }
700700 if (bf->true_filename != bf->filename)
701701 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
18671867 }
18681868 reparse:
18691869 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);
18721871 if (run) {
1872+dorun:
18731873 if (tcc_set_options(s, run))
18741874 return -1;
18751875 arg_start = optind - 1;
@@ -1878,6 +1878,10 @@ reparse: · 2 unmodified lines
18781878 continue;
18791879 }
18801880
1881+ /* allow "tcc files... -run -- args ..." */
1882+ if (r[1] == '-' && r[2] == '\0' && run)
1883+ goto dorun;
1884+
18811885 /* find option in table */
18821886 for(popt = tcc_options; ; ++popt) {
18831887 const char *p1 = popt->name;
tcc.c+1−1
@@ -27,7 +27,7 @@ · 26 unmodified lines
2727 static const char help[] =
2828 "Tiny C Compiler "TCC_VERSION" - Copyright (C) 2001-2006 Fabrice Bellard\n"
2929 "Usage: tcc [options...] [-o outfile] [-c] infile(s)...\n"
30− " tcc [options...] -run infile [arguments...]\n"
30+ " tcc [options...] -run infile (or --) [arguments...]\n"
3131 "General options:\n"
3232 " -c compile only - generate an object file\n"
3333 " -o outfile set output filename\n"
tccpp.c+8−8
@@ -3588,6 +3588,14 @@ static void tcc_predefs(TCCState *s1, CString *cs, int is_asm) · 3587 unmodified lines
35883588 putdef(cs, "__TCC_PP__");
35893589 if (s1->output_type == TCC_OUTPUT_MEMORY)
35903590 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
35913599 if (s1->char_is_unsigned)
35923600 putdef(cs, "__CHAR_UNSIGNED__");
35933601 if (s1->optimize > 0)
@@ -3596,14 +3604,6 @@ static void tcc_predefs(TCCState *s1, CString *cs, int is_asm) · 2 unmodified lines
35963604 putdef(cs, "_REENTRANT");
35973605 if (s1->leading_underscore)
35983606 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
36073607 cstr_printf(cs, "#define __SIZEOF_POINTER__ %d\n", PTR_SIZE);
36083608 cstr_printf(cs, "#define __SIZEOF_LONG__ %d\n", LONG_SIZE);
36093609 if (!is_asm) {
tests/tests2/117_builtins.c+1−1
@@ -11,7 +11,7 @@ main (void) · 10 unmodified lines
1111 char tmp[100];
1212 int r = 0;
1313
14−#if defined __BOUNDS_CHECKING_ON || defined BC_ON
14+#if defined __TCC_BCHECK__
1515 printf("BOUNDS ON:\n");
1616 #else
1717 printf("BOUNDS OFF:\n");
win32/build-tcc.bat+11−10
@@ -7,14 +7,6 @@ setlocal · 6 unmodified lines
77 if (%1)==(-clean) goto :cleanup
88 set CC=gcc
99 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
1810 set INST=
1911 set DOC=no
2012 set EXES_ONLY=no
@@ -94,7 +86,7 @@ set T=32 · 73 unmodified lines
9486 if %PROCESSOR_ARCHITECTURE%_==AMD64_ set T=64
9587 if %PROCESSOR_ARCHITEW6432%_==AMD64_ set T=64
9688 :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
9890 set D32=-DTCC_TARGET_PE -DTCC_TARGET_I386
9991 set D64=-DTCC_TARGET_PE -DTCC_TARGET_X86_64
10092 set P32=i386-win32
@@ -113,6 +105,15 @@ set TX=32 · 12 unmodified lines
113105 goto :p3
114106
115107 :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+
116117 @echo on
117118
118119 :config.h
@@ -134,7 +135,7 @@ for %%f in (*tcc.exe *tcc.dll) do @del %%f · 15 unmodified lines
134135 @if _%LIBTCC_C%_==__ set LIBTCC_C=..\libtcc.c
135136 %CC% -o libtcc.dll -shared %LIBTCC_C% %D% -DLIBTCC_AS_DLL
136137 @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%
138139 %CC% -o %PX%-tcc.exe ..\tcc.c %DX%
139140 :compiler_done
140141 @if (%EXES_ONLY%)==(yes) goto :files_done

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