for benchmarking the preprocessor, without having to use the PP_BENCH
macro. No output will be produced for '-E -bench', so it's the raw
tokenization/preprocess speed.
tccgen.c:
- cleanup __builtin_... stuff
- merge __attribute((alias("sym"))) with __asm__("sym")
Now one cannot have both, however for alias underscores are
added if enabled. For __asm__ they aren't.
tccpp.c:
- extend tcc_predefs accordingly. Was generated with
'cd tests/misc && tcc -run c2str.c tcc_predef.h tcc_predefs'
xxx-gen.c:
- move bcheck setjmp test to tccgen.c:gbound_args()
i386-gen.c:
- create win32 compatible stack space for big structures
tcctest.c:
- some cleanup + nicer output
tested on win32/64 to pass the tests when enabled
- libtcc.c :
let tcc define __leading_underscore if enabled
tcc_add_symbol() : add _ automatically
- tccelf.c : remove tcc_get_symbol_err(), find_c_sym()
currently symbol length is limited to 256 in several
places, so we can use a fixed local buffer for now as well.
- win32/lib/crtinit.c : new file for init/fini
- lib/*.S, tests7* : use __leading_underscore
- bt-log.c: this file wont work relibaly if compiled with gcc
- configure/Makefile : cleanup, really use CC_NAME
- tccasm.c : remove C99 construct that MSVC doesn't compile
- arm-gen.c, x86_64-gen.c, riscv64-gen.c, tccmacho.c : ditto
- arm64-gen.c: commit 383acf8eff wrote:
"Instead of a cast, it would be better to pass the exact type."
It is true that there are better solutions but it is not
passing the exact type (I think).
- tcctest.c: revert "fix cast test for clang" 03646ad46f
this obviously wants to test non-portable conversions
- 114_bound_signal.test: clock_nanosleep is too new for older
linuxes, just use sleep() instead
Thus it can parse command-line -Dsym=value directly, for the
convenience of libtcc users or tcc itself
Also used in libtcc_test_mt.c to avoid strdup().
tccelf.c/tccpp.c/tccrun.c
Change: "..."+int into &"..."[int] to avoid clang warning.
tests/tcctest.c:
- Change __APPLE__ into __clang__
- Add undefined_function for clang
- disable most asm code for clang
- Fix res6/res8 for __builtin_constant_p
This uses a glibc feature present since constructor/destructor support was added.
Modify tccrun.c to call constructor with argc, argcv, envp.
In lib/bcheck.c use these values to register them in the splay tree.
Remove HAS_ENVIRON is lib/bcheck.c as it is not needed any more.
Modify win32/lib/crt1.c/win32/lib/dllcrt1.c/win32/lib/wincrt1.c to also
call constructor with argc, argcv, envp.
While implementing I saw that tccrun did nog call main with envp. Fixed it.
Also fix fetch_and_add_arm.S to make it work on armv6 (raspberry pi default).
some linux programs (kernel) really want to have 'extern inline'
functions be visible from other units, i.e. not be static, but also
mark them as always_inline. That's -fgnu89-inline semantics, so it's
fine, but we don't (yet) implement this, so we can't make them static
just so. But we do need this hack on MacOS due to some uses in
system headers (see commit f18f8651).
So, for now conditionalize the hack on Mach-O.
via some heavy-handed hackery in the ASM symbol handling in case
C symbols get a leading underscore (but ASM symbols do not).
But this is now like clang and GCC on Darwin work: asm symbols are
undecorated, C symbols get a _ prepended, so to connect both some
trickery is involved for the ASM symbols that don't have a _ prepended.
They must be included in the C symbol table (because that's what we use
to lookup also ASM labels), but they also must not disturb the normal
C symbol (which don't have the _ prepended), so they need some mangling.
A bit unsatisfying, but well. So, add asm-c-connect-test to the working
ones for Darwin as well.
all except the below work now on MacOS, also as executable test,
not just with -run:
* dlltest - we don't support dylib generation (yet)
* memtest - tccmacho.c contains some leaks
* asm-c-connect-test - some confusion with underscores still
we need to disable or adjust some tests where clang behaves
slightly different from GCC:
* slight difference in __FILE__ behaviour
* difference (to less useful vs GCC) in computed #include
* difference in __builtin_constant_p
* attribute(weak, alias) isn't supported by clang on MacOS (though
it could be, as Mach-O has the capabilities for this)
* the built-in assembler of clang is mediocre
this was all checked with
Apple LLVM version 10.0.1 (clang-1001.0.46.4)
* instead of /usr/include use the current SDK path as system
include directory (/usr/include is empty with current tools)
(this also removes the need to add these paths in individual
Makefiles)
* define _DARWIN_C_SOURCE in tcc.h to get the full set of decls
from system headers (e.g. vsnprintf), similar to _GNU_SOURCE
(and don't define _ANSI_SOURCE in the main Makefile anymore)
* tests/tests2/Makefile: remove the -w flag, it's added when necessary
in the rules generating the .expect files
this is needed for multi-file testcases using stdio.h, as
the __sputc function is implemented as a extern inline
function (with gnu_inline attribute, but we don't support that for now).
Without this change that leads to multiply defined symbols when using
multiple units including stdio.h.
It also has an always_inline attribute, which we can use to guide our
behaviour, as in ISO-C an always_inline can't be defined with ISO
'extern inline' semantics. This is the minimal change and not a full
implementation of GNU inline semantics, which would require thorough
testcases.
If __clang__ would be defined the header would make use of C99 semantics,
which would work for us. It would also do that if _GNUC_ wouldn't be
defined. But we can't do the latter (as the whole MacOSX SDK refuses
to be compiled with anything not defining that). I haven't tested
defining __clang__, but suspect that's going to be problematic.
* alloca needs to be _alloca
* int64_t and uint64_t are also defined in <sys/_types/_int64_t.h>
but as long long, not as long, so adjust out <stddef.h> to agree
on Darwin
* define __APPLE_CC__ so that <TargetConditionals.h> correctly defines
various macros like TARGET_OS_MAC and TARGET_CPU_X86_64
* non-process-shared POSIX semaphores aren't supported on
Darwin, we use the dispatch framework
* dlsym segfaults with RTLD_NEXT from JIT code, so we must not
even try this for -run. So we need to know in __bound_init
if called from -run code, or from normal code, which means passing
this down also from __bt_init and hence from the stub added in
tcc_add_btstub
* Darwin uses different structures for <ctype.h> facilities, this
merely adds a warning about this
* __libc_freeres doesn't exist
* for non -run modus the context (.prog_base member) is constructed
incorrectly (uses symbol zero for trying to get at the load bias,
which doesn't really work that way), on Mach-O this errors out
(and could also error out on ELF). For now deactivate this, which
makes backtraces not be symbolic on MacOS for not -run.
uncovered by the backtrace/boundcheck tests:
* handle STT_SECTION symbols
* call tcc_add_runtime (to get the bcheck.o/bt-exe.o files added)
* add .stab strtab into segments (we should probably add all stab
syms to the output LC_SYMTAB eventually, but right now TCC uses
32 bit stabs, while mach-o uses 32/64bit stabs
* <malloc.h> isn't as portable as <stdlib.h>
* skip 113_btdll.c on Darwin
* replace [...]\+ with [...]\{1,\} in the sed regex (basic REs
have no + even some sed(1) accept it as \+, but bounds _are_ part
of POSIX BREs)