Open andrewrk opened 1 year ago
C codegen outputs functions taking arrays qualified inside [...]
like so:
static zig_u8 fn_name(zig_u8 const a0[static const 2])
// ^ ^
TCC added support for this syntax in 2018 but there have been no new releases since 2017.
Would you prefer to change the generated C (maybe for TCC only, since these qualifiers are ignored anyway) or only support TCC built from git?
It also looks like TCC doesn't support thread-local variables, unless built with gcc on Linux i386/x86_64.
I would prefer to change the generated C to not use these qualifiers so that the code generates the lowest common denominator compatibility. There should not be any TCC specific logic.
Thread local variables should lower to something like zig_threadlocal and have that be an undeclared identifier so that TCC generates a compile error when thread local variables are used.
change the generated C to not use these qualifiers
Sounds good, as I understand these qualifiers only add safety/optimization hints to compilers that support them, no change in functionality.
The undeclared identifier thing is already in place (generates an undefined zig_threadlocal_unavailable
), but I thought I should point it out because there are a couple instances of thread-local vars in the behavior tests, which blocks this issue's criterion.
We can pass -fsingle-threaded
in this case to disable dependency on thread local variables
TCC added support for this syntax in 2018 but there have been no new releases since 2017.
many systems now test and pull the master branch from various points, for example:
tcc-0.9.27+date=2022-01-11
on nix0.9.27+git20200814.62c30a4a
on debian0.9.27_git20220323
on alpineAye. More data bits: Arch and Homebrew provide the tagged release by default, but latest is still available with an AUR and --HEAD
respectively. Small point perhaps, but I'm not sure what the expectation is for TCC since it's more niche and the original author disclaims detachment from the project.
Assuming there are other compilers in use without full C99 support out there, "lowest common denominator" might still suggest foregoing the array param qualifiers.
I must be missing something because adding -fsingle-threaded
to the original command still generates a C file with the (undefined) thread-local attribute. I'll comb the community and issues for more info.
This issue can be closed when we add CI test coverage that compiles the behavior tests with
-ofmt=c
and then compiles & runs them with TCC.This command can be used to produce a test.c file for testing with tcc: