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 ...'
This commit is contained in:
parent
a045400501
commit
bb93bf8cd2
8 changed files with 36 additions and 32 deletions
12
Makefile
12
Makefile
|
@ -243,12 +243,10 @@ $(TCC_FILES) : DEFINES += -DONE_SOURCE=0
|
|||
$(X)tccpp.o : $(TCCDEFS_H)
|
||||
endif
|
||||
|
||||
FROM_GIT := $(shell git rev-parse >/dev/null 2>&1 && echo yes || echo no)
|
||||
|
||||
ifeq ($(FROM_GIT),yes)
|
||||
GITHASH:=$(shell git rev-parse --abbrev-ref HEAD):$(shell git rev-parse --short HEAD) $(shell git log -1 --pretty='format:%cI')
|
||||
GITLOCAL:=$(shell git diff --quiet || echo ' locally modified')
|
||||
DEF_GITHASH:= -DTCC_GITHASH="\"$(GITHASH)$(GITLOCAL)\""
|
||||
GITHASH:=$(shell git rev-parse --abbrev-ref HEAD 2>/dev/null || echo no)
|
||||
ifneq ($(GITHASH),no)
|
||||
GITHASH:=$(shell git log -1 --pretty='format:%cs $(GITHASH)@%h')$(shell git diff --quiet || echo '*')
|
||||
DEF_GITHASH:= -DTCC_GITHASH="\"$(GITHASH)\""
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_debug),yes)
|
||||
|
@ -270,7 +268,7 @@ $(X)%.o : %.c $(LIBTCC_INC)
|
|||
|
||||
# additional dependencies
|
||||
$(X)tcc.o : tcctools.c
|
||||
$(X)tcc.o : DEFINES += $(DEF_GITHASH) $(DEF_GITDATE)
|
||||
$(X)tcc.o : DEFINES += $(DEF_GITHASH)
|
||||
|
||||
# Host Tiny C Compiler
|
||||
tcc$(EXESUF): tcc.o $(LIBTCC)
|
||||
|
|
|
@ -245,7 +245,7 @@
|
|||
# define __RENAME(X) __asm__(X)
|
||||
#endif
|
||||
|
||||
#ifdef __BOUNDS_CHECKING_ON
|
||||
#ifdef __TCC_BCHECK__
|
||||
# define __BUILTINBC(ret,name,params) ret __builtin_##name params __RENAME("__bound_"#name);
|
||||
# define __BOUND(ret,name,params) ret name params __RENAME("__bound_"#name);
|
||||
#else
|
||||
|
|
|
@ -3,7 +3,8 @@
|
|||
from tccrun.c into executables. */
|
||||
|
||||
#define CONFIG_TCC_BACKTRACE_ONLY
|
||||
#define ONE_SOURCE 0
|
||||
#define ONE_SOURCE 1
|
||||
#define pstrcpy tcc_pstrcpy
|
||||
#include "../tccrun.c"
|
||||
|
||||
int (*__rt_error)(void*, void*, const char *, va_list);
|
||||
|
|
10
libtcc.c
10
libtcc.c
|
@ -695,7 +695,7 @@ ST_FUNC void tcc_close(void)
|
|||
BufferedFile *bf = file;
|
||||
if (bf->fd > 0) {
|
||||
close(bf->fd);
|
||||
total_lines += bf->line_num;
|
||||
total_lines += bf->line_num - 1;
|
||||
}
|
||||
if (bf->true_filename != bf->filename)
|
||||
tcc_free(bf->true_filename);
|
||||
|
@ -1867,9 +1867,9 @@ PUB_FUNC int tcc_parse_args(TCCState *s, int *pargc, char ***pargv, int optind)
|
|||
}
|
||||
reparse:
|
||||
if (r[0] != '-' || r[1] == '\0') {
|
||||
if (r[0] != '@') /* allow "tcc file(s) -run @ args ..." */
|
||||
args_parser_add_file(s, r, s->filetype);
|
||||
args_parser_add_file(s, r, s->filetype);
|
||||
if (run) {
|
||||
dorun:
|
||||
if (tcc_set_options(s, run))
|
||||
return -1;
|
||||
arg_start = optind - 1;
|
||||
|
@ -1878,6 +1878,10 @@ reparse:
|
|||
continue;
|
||||
}
|
||||
|
||||
/* allow "tcc files... -run -- args ..." */
|
||||
if (r[1] == '-' && r[2] == '\0' && run)
|
||||
goto dorun;
|
||||
|
||||
/* find option in table */
|
||||
for(popt = tcc_options; ; ++popt) {
|
||||
const char *p1 = popt->name;
|
||||
|
|
2
tcc.c
2
tcc.c
|
@ -27,7 +27,7 @@
|
|||
static const char help[] =
|
||||
"Tiny C Compiler "TCC_VERSION" - Copyright (C) 2001-2006 Fabrice Bellard\n"
|
||||
"Usage: tcc [options...] [-o outfile] [-c] infile(s)...\n"
|
||||
" tcc [options...] -run infile [arguments...]\n"
|
||||
" tcc [options...] -run infile (or --) [arguments...]\n"
|
||||
"General options:\n"
|
||||
" -c compile only - generate an object file\n"
|
||||
" -o outfile set output filename\n"
|
||||
|
|
16
tccpp.c
16
tccpp.c
|
@ -3588,6 +3588,14 @@ static void tcc_predefs(TCCState *s1, CString *cs, int is_asm)
|
|||
putdef(cs, "__TCC_PP__");
|
||||
if (s1->output_type == TCC_OUTPUT_MEMORY)
|
||||
putdef(cs, "__TCC_RUN__");
|
||||
#ifdef CONFIG_TCC_BACKTRACE
|
||||
if (s1->do_backtrace)
|
||||
putdef(cs, "__TCC_BACKTRACE__");
|
||||
#endif
|
||||
#ifdef CONFIG_TCC_BCHECK
|
||||
if (s1->do_bounds_check)
|
||||
putdef(cs, "__TCC_BCHECK__");
|
||||
#endif
|
||||
if (s1->char_is_unsigned)
|
||||
putdef(cs, "__CHAR_UNSIGNED__");
|
||||
if (s1->optimize > 0)
|
||||
|
@ -3596,14 +3604,6 @@ static void tcc_predefs(TCCState *s1, CString *cs, int is_asm)
|
|||
putdef(cs, "_REENTRANT");
|
||||
if (s1->leading_underscore)
|
||||
putdef(cs, "__leading_underscore");
|
||||
#ifdef CONFIG_TCC_BCHECK
|
||||
if (s1->do_bounds_check)
|
||||
putdef(cs, "__BOUNDS_CHECKING_ON");
|
||||
#endif
|
||||
#ifdef CONFIG_TCC_BACKTRACE
|
||||
if (s1->do_backtrace)
|
||||
putdef(cs, "__TCC_BACKTRACE_ENABLED__");
|
||||
#endif
|
||||
cstr_printf(cs, "#define __SIZEOF_POINTER__ %d\n", PTR_SIZE);
|
||||
cstr_printf(cs, "#define __SIZEOF_LONG__ %d\n", LONG_SIZE);
|
||||
if (!is_asm) {
|
||||
|
|
|
@ -11,7 +11,7 @@ main (void)
|
|||
char tmp[100];
|
||||
int r = 0;
|
||||
|
||||
#if defined __BOUNDS_CHECKING_ON || defined BC_ON
|
||||
#if defined __TCC_BCHECK__
|
||||
printf("BOUNDS ON:\n");
|
||||
#else
|
||||
printf("BOUNDS OFF:\n");
|
||||
|
|
|
@ -7,14 +7,6 @@ setlocal
|
|||
if (%1)==(-clean) goto :cleanup
|
||||
set CC=gcc
|
||||
set /p VERSION= < ..\VERSION
|
||||
git.exe --version 2>nul
|
||||
if not %ERRORLEVEL%==0 goto :git_done
|
||||
for /f %%b in ('git.exe rev-parse --abbrev-ref HEAD') do set GITHASH=%%b
|
||||
for /f %%h in ('git.exe rev-parse --short HEAD') do set GITHASH=%GITHASH%:%%h
|
||||
git.exe diff --quiet
|
||||
if %ERRORLEVEL%==1 set GITHASH=%GITHASH%-mod
|
||||
set DEF_GITHASH=-DTCC_GITHASH="""%GITHASH%"""
|
||||
:git_done
|
||||
set INST=
|
||||
set DOC=no
|
||||
set EXES_ONLY=no
|
||||
|
@ -94,7 +86,7 @@ set T=32
|
|||
if %PROCESSOR_ARCHITECTURE%_==AMD64_ set T=64
|
||||
if %PROCESSOR_ARCHITEW6432%_==AMD64_ set T=64
|
||||
:p2
|
||||
if "%CC:~-3%"=="gcc" set CC=%CC% -O2 -s -static %DEF_GITHASH%
|
||||
if "%CC:~-3%"=="gcc" set CC=%CC% -O2 -s -static
|
||||
set D32=-DTCC_TARGET_PE -DTCC_TARGET_I386
|
||||
set D64=-DTCC_TARGET_PE -DTCC_TARGET_X86_64
|
||||
set P32=i386-win32
|
||||
|
@ -113,6 +105,15 @@ set TX=32
|
|||
goto :p3
|
||||
|
||||
:p3
|
||||
git.exe --version 2>nul
|
||||
if not %ERRORLEVEL%==0 goto :git_done
|
||||
for /f %%b in ('git.exe rev-parse --abbrev-ref HEAD') do set GITHASH=%%b
|
||||
for /f %%b in ('git.exe log -1 "--pretty=format:%%cs_%GITHASH%@%%h"') do set GITHASH=%%b
|
||||
git.exe diff --quiet
|
||||
if %ERRORLEVEL%==1 set GITHASH=%GITHASH%*
|
||||
set DEF_GITHASH=-DTCC_GITHASH="""%GITHASH%"""
|
||||
:git_done
|
||||
|
||||
@echo on
|
||||
|
||||
:config.h
|
||||
|
@ -134,7 +135,7 @@ for %%f in (*tcc.exe *tcc.dll) do @del %%f
|
|||
@if _%LIBTCC_C%_==__ set LIBTCC_C=..\libtcc.c
|
||||
%CC% -o libtcc.dll -shared %LIBTCC_C% %D% -DLIBTCC_AS_DLL
|
||||
@if errorlevel 1 goto :the_end
|
||||
%CC% -o tcc.exe ..\tcc.c libtcc.dll %D% -DONE_SOURCE"=0"
|
||||
%CC% -o tcc.exe ..\tcc.c libtcc.dll %D% -DONE_SOURCE"=0" %DEF_GITHASH%
|
||||
%CC% -o %PX%-tcc.exe ..\tcc.c %DX%
|
||||
:compiler_done
|
||||
@if (%EXES_ONLY%)==(yes) goto :files_done
|
||||
|
|
Loading…
Reference in a new issue