Make code more compatible with gcc. Change
__atomic_store
__atomic_load
__atomic_exchange
__atomic_compare_exchange
Also add (include/stdatomic.h, lib/stdatomic.c):
atomic_thread_fence
atomic_signal_fence
atomic_is_lock_free
And gcc extensions (tcctok.h, tccgen.c, lib/stdatomic.c):
__atomic_fetch_nand
__atomic_and_fetch
__atomic_sub_fetch
__atomic_or_fetch
__atomic_xor_fetch
__atomic_and_fetch
__atomic_nand_fetch
Add new file lib/atomic.S with assembly code for __atomic_compare_exchange_n
for arm/arm64/riscv. Also update lib/Makefile.
Update testcode in 124_atomic_counter and 125_atomic_misc to test new functions.
Also update tests/tests2/Makefile to run tests on arm/arm64/riscv.
Bad assumption make bad things happen:
long d3;
asm(..."1:\tdec %3\n\t" : ... "=&c" (d3)
Which wants 'dec RDI' but did 'dec EDI' on _WIN64.
Also:
- tcctest.c: enable more asm tests for win64
- configure: show errors if any with 'gcc conftest.c'
- tccgen.c: remove decl0(x, y, z)
- x86_64-link.c:
ignore relocation overflow to undefined (weak) symbols
- 104_inline.test:
test lower 32 bits only
- tccpe.c:
support -Wl,--image-base=... above the 32bit range
The script was expecting gcc-3.2 in a specific directory,
works only, when building tcc in the source directory
and creates >3200 files in /tmp (probably a SSD).
Now gcctestsuite.sh works much better.
* use TESTSUITE_PATH, to tell the script the location, where the actual
gcc.c-torture directory is
* work also, when tcc was build in a separate build directory.
use TCC_SOURCE_PATH, when guessing the tcc source directory does not work
* use RUNTIME_DIR to redirect compiler output
(default: XDG_RUNTIME_DIR, then /tmp)
* skip tests for features not implemented in tcc ( *_builtin_*, _Complex )
--
Regards, Detlef
Almost all systems use .gnu_hash so implement it for tcc.
For most of them it is the default.
tccelf.c:
- Add functions elf_gnu_hash/create_gnu_hash/update_gnu_hash
- Update new_section/sort_sections/fill_dynamic/tcc_output_elf/elf_output_file
Tested with setting .hash section to SHF_PRIVATE in elf_output_file.
This reverts commit 2507c71704.
Why crowd up search-paths for the normal native compiler with
all sort of invalid stuff. Why -UCONFIG_TRIPLET if it isn't
set at all for cross-compilers. Also, the patch still didn't
do anything useful "out of the box".
Instead I'd suggest to do something more simple and more effective.
See Makefile:
- set search paths for cross-compilers to /usr/<triplet> by default
- Install any built "xxx-tcc" and "xxx-libtcc1.a", even if not listed
with PROGS_CROSS/LIBTCC1_CROSS
- Support ELF-<target> = ... to set the elf interpreter
Some common gnu-triplets are supported by default
TRIPLET-i386 ?= i386-linux-gnu
TRIPLET-x86_64 ?= x86_64-linux-gnu
TRIPLET-arm ?= arm-linux-gnueabihf
TRIPLET-arm64 ?= aarch64-linux-gnu
TRIPLET-riscv64 ?= riscv64-linux-gnu
Other triplets can be given explicitly, for example like this:
$ make cross-arm-eabi TRIPLET-arm-eabi=arm-linux-gnueabi
$ sudo make install
(As long as it is in the default install location and was not
moved elsewhere into the library search path manually)
Also:
- libtcc.c:
- error1(): show correct line with "In file included from ..."
- support "tcc -Bxxx -vv"
- tcc_new()/tcc_compile(): Don't create elf sections for tcc -E
- tccdbg.c:
- tcc -E -g : revert 1de025c13a
Let's keep things simple, everybody understands 'do_debug'
and dState is set by tcov too (but no debug sections).
- tccgen.c:
- avoid the extra parameter for gind()
(from c3e3a07ed4)
- vla func params: use skip_or_save_block() and enable
VT_LVAL (see 313855c232)
- cleanup nocode_wanted a bit
- tccelf.c:
- tccelf_end_file(): don't try to translate zero-sym relocs
(seems to happen with asm "jmp 0x1000")
- version_add(): do not make "ld-linux.so" DT_NEEDED
This allow the tcc cross compilers to work as expected,
when tcc was build with '--enable-cross' and a simple config-extra.mak
(see the provided config-extra.mak.example).
Make sure, that cross development packages for libc are installed
Fixes also open bugs in various bug tracker. Example in debian: 940469
tcc: error: library 'c' not found
tcc: error: file 'crtn.o' not found
tcc: error: undefined symbol 'printf'
1) recursive types have no storage anymore, so a
static int (*p)[x];
declaration is just fine
2) since somewhen VT_VLA doesn't imply VT_ARRAY anymore, so we
now need to check VLA in at least one place before checking
test_lvalue.
((2) should probably be cleaned up again so that VLA does again imply
ARRAY)
This fixes the bug that "tcc -gdwarf ..."
still creates the stab debug infos,
when tcc was build without using DWARF debug infos by default
(configure option: --dwarf=x)
--
Regards ... Detlef
- also simplify parse(_line)_comment() and parse_pp_string()
- fixes a continuation problem in strings (see tcctest.c)
- no differences in performance could be observed
161 insertions(+), 246 deletions(-), less 85 lines
- make only one function from previously four pieces
- use parse_pp_string() for the normal cases "..." and <...>
- use the sanity check for computed include as end-condition too.
- use 's1' instead of 'tcc_state' when possible
117 insertions(+), 165 deletions(-), less 48 lines
an expression like 'i*0', even though it's value is constant and
can be evaluated at compile time is not an integer constant expression,
and hence no null pointer constant, and therefore the conditional
operator doesn't select the other type.
if a switch is unreachable then so are the case labels.
Unlike normal labels they can't possibly be reached from not-yet
parsed code, so there's no reason to enable codegen again for those.
see testcase. We have to "empty" the macro-stack string on
end_macro, as it may be 'tokstr_buf' which is going to be used
twice in recursive invocations of macro_subst_tok. The uses aren't
overlapping but the first one needs to be properly finalized.
The no-operand vm* instructions can be interpreted as having a
funny modrm byte, but unlike no-operand OPC_MODRM it's also the
r/m field which selects the insn, not (only) the reg field (aka group),
so we need another insn type.
as this is the first opcode TCC supports that has a 0xf3 prefix
and uses integer registers (not SSE ones) this also needs some shuffling
of the prefix code to not generate invalid instructions (the REX prefix
_must_ come directly before the main opcode (including 0f prefix), and
hence needs to come after the 0xf3 prefix). Also disable some mnemonics
in asmtest.S that new GAS doesn't support anymore. The only difference
to GAS (in asmtest.S) is now the 'lock negl' instruction which TCC
emits as 'lock; negl'. That's fine.
they look similar to labels 'foobar : 32' (when foobar is a typedef),
but cannot be handled as such in parse_btype, the context is important
(labels can only happen when called from within 'block', aka decl0 in
VT_LOCAL context). This got broken back in 2019 (1b57560).
The parameter is stored in tccstate, but nothing more.
Used by multiple software packages.
Current tested example is OpenWatcom-v2
--
bye bye ... Detlef
On an armeabi-v7a device (phone) in the termux app with
clang & make installed this passes all the tests.
Can be used as a cross compiler to create "native apps" as well.
Example 'config-extra.mak' for the cross arm-eabi-tcc:
SYSROOT = <path_to_android_ndk...>/sysroot/usr
TRIPLET = arm-linux-androideabi
ANDRVER = 32
ROOT-arm-eabi = $(SYSROOT)
CRT-arm-eabi = {R}/lib/$(TRIPLET)/$(ANDRVER)
LIB-arm-eabi = {B};{R}/lib/$(TRIPLET)/$(ANDRVER);{R}/lib/$(TRIPLET)
INC-arm-eabi = {B}/lib/include;{R}/include/$(TRIPLET);{R}/include
DEF-arm-eabi = -DTCC_TARGET_ARM -DTCC_ARM_VFP -DTCC_ARM_EABI
DEF-arm-eabi += -DTARGETOS_ANDROID -DCONFIG_TCC_PIE -DCONFIG_NEW_DTAGS
DEF-arm-eabi += -DCONFIG_TCC_ELFINTERP=\"/system/bin/linker\"
# on unix replace ';' by ':'.
$ ./configure && make cross-arm-eabi && make install
Sort sections in separate function to allow variable
calculatiion of needed program headers. Such execinstr
and relro cah have their own PT_LOAD header.
315 insertions(+), 370 deletions(-)
Allows to create dynamic executables, using the code path
for TCC_OUTPUT_DLL but add an .interp header (plus a FLAGS_1
entry in the dynamic section to make 'readelf' say "PIE")
Introduces TCC_OUTPUT_DYN as alias for TCC_OUTPUT_DLL.
There is no runtime option, only one to configure:
./configure --config-pie
100 insertions(+), 76 deletions(-)
... rather than from tccdir. Also allows to load cross
versions of bcheck.o etc. (if we would build them which
we currently don't).
18 insertions(+), 24 deletions(-)
Instead, return its symbol index from build_got_entries()
Also, copy dynamic symbols later when size of _GLOBAL_OFFSET_TABLE_
was already set and handle -rdynamic there too.
See commit 4c82b00342
5 insertions(+), 5 deletions(-)
seems that symbols under nocode/NODATA should not produce
elf symbols at all, not just elf symbols with no size.
See commit 4c82b00342
5 insertions(+), 5 deletions(-)