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
243$(X)tccpp.o : $(TCCDEFS_H)243$(X)tccpp.o : $(TCCDEFS_H)
244endif244endif
245 245
246FROM_GIT := $(shell git rev-parse >/dev/null 2>&1 && echo yes || echo no)246GITHASH:=$(shell git rev-parse --abbrev-ref HEAD 2>/dev/null || echo no)
247 247ifneq ($(GITHASH),no)
248ifeq ($(FROM_GIT),yes)248GITHASH:=$(shell git log -1 --pretty='format:%cs $(GITHASH)@%h')$(shell git diff --quiet || echo '*')
249GITHASH:=$(shell git rev-parse --abbrev-ref HEAD):$(shell git rev-parse --short HEAD) $(shell git log -1 --pretty='format:%cI')249DEF_GITHASH:= -DTCC_GITHASH="\"$(GITHASH)\""
250GITLOCAL:=$(shell git diff --quiet || echo ' locally modified')
251DEF_GITHASH:= -DTCC_GITHASH="\"$(GITHASH)$(GITLOCAL)\""
252endif250endif
253 251
254ifeq ($(CONFIG_debug),yes)252ifeq ($(CONFIG_debug),yes)
@@ -270,7 +268,7 @@ $(X)%.o : %.c $(LIBTCC_INC) · 15 unmodified lines
270 268
271# additional dependencies269# additional dependencies
272$(X)tcc.o : tcctools.c270$(X)tcc.o : tcctools.c
273$(X)tcc.o : DEFINES += $(DEF_GITHASH) $(DEF_GITDATE)271$(X)tcc.o : DEFINES += $(DEF_GITHASH)
274 272
275# Host Tiny C Compiler273# Host Tiny C Compiler
276tcc$(EXESUF): tcc.o $(LIBTCC)274tcc$(EXESUF): tcc.o $(LIBTCC)
include/tccdefs.h+1−1
@@ -245,7 +245,7 @@ · 244 unmodified lines
245 # define __RENAME(X) __asm__(X)245 # define __RENAME(X) __asm__(X)
246 #endif246 #endif
247 247
248 #ifdef __BOUNDS_CHECKING_ON248 #ifdef __TCC_BCHECK__
249 # define __BUILTINBC(ret,name,params) ret __builtin_##name params __RENAME("__bound_"#name);249 # define __BUILTINBC(ret,name,params) ret __builtin_##name params __RENAME("__bound_"#name);
250 # define __BOUND(ret,name,params) ret name params __RENAME("__bound_"#name);250 # define __BOUND(ret,name,params) ret name params __RENAME("__bound_"#name);
251 #else251 #else
lib/bt-exe.c+2−1
@@ -3,7 +3,8 @@ · 2 unmodified lines
3 from tccrun.c into executables. */3 from tccrun.c into executables. */
4 4
5#define CONFIG_TCC_BACKTRACE_ONLY5#define CONFIG_TCC_BACKTRACE_ONLY
6#define ONE_SOURCE 06#define ONE_SOURCE 1
7#define pstrcpy tcc_pstrcpy
7#include "../tccrun.c"8#include "../tccrun.c"
8 9
9int (*__rt_error)(void*, void*, const char *, va_list);10int (*__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
695 BufferedFile *bf = file;695 BufferedFile *bf = file;
696 if (bf->fd > 0) {696 if (bf->fd > 0) {
697 close(bf->fd);697 close(bf->fd);
698 total_lines += bf->line_num;698 total_lines += bf->line_num - 1;
699 }699 }
700 if (bf->true_filename != bf->filename)700 if (bf->true_filename != bf->filename)
701 tcc_free(bf->true_filename);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 }
1868reparse:1868reparse:
1869 if (r[0] != '-' || r[1] == '\0') {1869 if (r[0] != '-' || r[1] == '\0') {
1870 if (r[0] != '@') /* allow "tcc file(s) -run @ args ..." */1870 args_parser_add_file(s, r, s->filetype);
1871 args_parser_add_file(s, r, s->filetype);
1872 if (run) {1871 if (run) {
1872dorun:
1873 if (tcc_set_options(s, run))1873 if (tcc_set_options(s, run))
1874 return -1;1874 return -1;
1875 arg_start = optind - 1;1875 arg_start = optind - 1;
@@ -1878,6 +1878,10 @@ reparse: · 2 unmodified lines
1878 continue;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 /* find option in table */1885 /* find option in table */
1882 for(popt = tcc_options; ; ++popt) {1886 for(popt = tcc_options; ; ++popt) {
1883 const char *p1 = popt->name;1887 const char *p1 = popt->name;
tcc.c+1−1
@@ -27,7 +27,7 @@ · 26 unmodified lines
27static const char help[] =27static const char help[] =
28 "Tiny C Compiler "TCC_VERSION" - Copyright (C) 2001-2006 Fabrice Bellard\n"28 "Tiny C Compiler "TCC_VERSION" - Copyright (C) 2001-2006 Fabrice Bellard\n"
29 "Usage: tcc [options...] [-o outfile] [-c] infile(s)...\n"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 "General options:\n"31 "General options:\n"
32 " -c compile only - generate an object file\n"32 " -c compile only - generate an object file\n"
33 " -o outfile set output filename\n"33 " -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
3588 putdef(cs, "__TCC_PP__");3588 putdef(cs, "__TCC_PP__");
3589 if (s1->output_type == TCC_OUTPUT_MEMORY)3589 if (s1->output_type == TCC_OUTPUT_MEMORY)
3590 putdef(cs, "__TCC_RUN__");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 if (s1->char_is_unsigned)3599 if (s1->char_is_unsigned)
3592 putdef(cs, "__CHAR_UNSIGNED__");3600 putdef(cs, "__CHAR_UNSIGNED__");
3593 if (s1->optimize > 0)3601 if (s1->optimize > 0)
@@ -3596,14 +3604,6 @@ static void tcc_predefs(TCCState *s1, CString *cs, int is_asm) · 2 unmodified lines
3596 putdef(cs, "_REENTRANT");3604 putdef(cs, "_REENTRANT");
3597 if (s1->leading_underscore)3605 if (s1->leading_underscore)
3598 putdef(cs, "__leading_underscore");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 cstr_printf(cs, "#define __SIZEOF_POINTER__ %d\n", PTR_SIZE);3607 cstr_printf(cs, "#define __SIZEOF_POINTER__ %d\n", PTR_SIZE);
3608 cstr_printf(cs, "#define __SIZEOF_LONG__ %d\n", LONG_SIZE);3608 cstr_printf(cs, "#define __SIZEOF_LONG__ %d\n", LONG_SIZE);
3609 if (!is_asm) {3609 if (!is_asm) {
tests/tests2/117_builtins.c+1−1
@@ -11,7 +11,7 @@ main (void) · 10 unmodified lines
11 char tmp[100];11 char tmp[100];
12 int r = 0;12 int r = 0;
13 13
14#if defined __BOUNDS_CHECKING_ON || defined BC_ON14#if defined __TCC_BCHECK__
15 printf("BOUNDS ON:\n");15 printf("BOUNDS ON:\n");
16#else16#else
17 printf("BOUNDS OFF:\n");17 printf("BOUNDS OFF:\n");
win32/build-tcc.bat+11−10
@@ -7,14 +7,6 @@ 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
10git.exe --version 2>nul
11if not %ERRORLEVEL%==0 goto :git_done
12for /f %%b in ('git.exe rev-parse --abbrev-ref HEAD') do set GITHASH=%%b
13for /f %%h in ('git.exe rev-parse --short HEAD') do set GITHASH=%GITHASH%:%%h
14git.exe diff --quiet
15if %ERRORLEVEL%==1 set GITHASH=%GITHASH%-mod
16set DEF_GITHASH=-DTCC_GITHASH="""%GITHASH%"""
17:git_done
18set INST=10set INST=
19set DOC=no11set DOC=no
20set EXES_ONLY=no12set EXES_ONLY=no
@@ -94,7 +86,7 @@ set T=32 · 73 unmodified lines
94if %PROCESSOR_ARCHITECTURE%_==AMD64_ set T=6486if %PROCESSOR_ARCHITECTURE%_==AMD64_ set T=64
95if %PROCESSOR_ARCHITEW6432%_==AMD64_ set T=6487if %PROCESSOR_ARCHITEW6432%_==AMD64_ set T=64
96:p288:p2
97if "%CC:~-3%"=="gcc" set CC=%CC% -O2 -s -static %DEF_GITHASH%89if "%CC:~-3%"=="gcc" set CC=%CC% -O2 -s -static
98set D32=-DTCC_TARGET_PE -DTCC_TARGET_I38690set D32=-DTCC_TARGET_PE -DTCC_TARGET_I386
99set D64=-DTCC_TARGET_PE -DTCC_TARGET_X86_6491set D64=-DTCC_TARGET_PE -DTCC_TARGET_X86_64
100set P32=i386-win3292set P32=i386-win32
@@ -113,6 +105,15 @@ set TX=32 · 12 unmodified lines
113goto :p3105goto :p3
114 106
115:p3107:p3
108git.exe --version 2>nul
109if not %ERRORLEVEL%==0 goto :git_done
110for /f %%b in ('git.exe rev-parse --abbrev-ref HEAD') do set GITHASH=%%b
111for /f %%b in ('git.exe log -1 "--pretty=format:%%cs_%GITHASH%@%%h"') do set GITHASH=%%b
112git.exe diff --quiet
113if %ERRORLEVEL%==1 set GITHASH=%GITHASH%*
114set DEF_GITHASH=-DTCC_GITHASH="""%GITHASH%"""
115:git_done
116
116@echo on117@echo on
117 118
118:config.h119:config.h
@@ -134,7 +135,7 @@ for %%f in (*tcc.exe *tcc.dll) do @del %%f · 15 unmodified lines
134@if _%LIBTCC_C%_==__ set LIBTCC_C=..\libtcc.c135@if _%LIBTCC_C%_==__ set LIBTCC_C=..\libtcc.c
135%CC% -o libtcc.dll -shared %LIBTCC_C% %D% -DLIBTCC_AS_DLL136%CC% -o libtcc.dll -shared %LIBTCC_C% %D% -DLIBTCC_AS_DLL
136@if errorlevel 1 goto :the_end137@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%CC% -o %PX%-tcc.exe ..\tcc.c %DX%139%CC% -o %PX%-tcc.exe ..\tcc.c %DX%
139:compiler_done140:compiler_done
140@if (%EXES_ONLY%)==(yes) goto :files_done141@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