-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bootstrapping from bootstrap.c
, issues compiling zig2.c
with tcc
and slimcc
#22114
Comments
Does it work when passing |
|
It seems odd that TCC wouldn't have any way of specifying alignment pre-C11. |
With |
glibc does the I actually put a special case in |
That's what I mean; I'm surprised TCC can even be used to compile real, working programs when it ends up with ABI mismatches like this. That makes me wonder if there's something I'm missing. |
Maybe the issue here is just that, while TCC supports |
Looks like tcc:
|
Curiously enough, I can't find any mention of |
❯ cat test.c
#include <stdio.h>
int main()
{
#ifdef __has_attribute
printf("has attribute\n");
#endif
}
❯ tcc -run test.c
❯ tcc -dM -E - < /dev/null | grep __has_attribute
❯ Same deal with a fresh I have no idea what's going on with the TCC on godbolt. |
Yeah, seriously, what's going on here? https://godbolt.org/z/9ce99jvEr |
I think it's here: https://repo.or.cz/tinycc.git/blob/HEAD:/include/tccdefs.h#l155 So it will be |
The This is entirely in the preprocessor pass, the actual C compiler won't see and don't know about it. |
Ah... I had cloned the older https://repo.or.cz/tinycc/tinycc.git (and manually switched to its |
Progress with slimcc, after implementing Lines 51 to 61 in aa7d138
|
Does slimcc support |
Here the Lines 43 to 51 in aa7d138
edit: yeah, GCC with x86 got zig_big_endian == 1 https://godbolt.org/z/7jqPhcqs4
|
It does, but it doesn't define |
Yeah, this should be using
Ok, it would seem reasonable to add a slimcc check to the |
I would prefer just don't hardcode |
Next problem
The compound literal is not a constant expression, using it in a static object initialization is not particularly portable:
|
Would you mind filing a separate issue against the C backend for this one? I think we'd want to fix that, but it's probably going to be lower priority than the other problems in this issue. |
I have no idea which part of the C backend generated it, only that it appears in Since GCC |
From what I'm seeing in |
Maybe the macros concerning atomics could be defined to cause compile errors if |
Re: |
Next one is about tentative definitions with _Thread_local.
The C standard at
So if a C11 compiler implemented these features "by the book", thread_local and tentative don't co-exist, as the first GCC/Clang probably supported tentative __thread objects long before C11 standard text, so they don't mind the usage. |
Just let it fail whenever GCC style atomics got used and |
|
It's done!
Looks like cpuid is working:
build-obj and build-exe failed, what to do about this?
|
This is probably expected to an extent. The self-hosted backends are still in development, and the Zig compiler you get from |
Another question: Does slimcc make GCC-style |
Currently, no, though I probably should implement it on my quest to build more existing projects. On the other hand, GCC/Clang also agree on this: https://godbolt.org/z/8e4bjozKd |
These are encountered at the
$CC -o zig2 zig2.c compiler_rt.c -std=c99 ...
step, with shell commandulimit -s unlimited
to workaround stack-overflow mentioned at issue #22111Here in
stage1/zig.h
,cpuid.h
is included on any x86-64 compiler that is not MSVC. This header may not be present if the C compiler implemented their own preprocessor,tcc
,slimcc
as well aspcc
,cparser
, currently don't provide it.zig/stage1/zig.h
Lines 11 to 17 in aa7d138
With
#include <cpuid.h>
commented out (to see what lies ahead),tcc
andslimcc
failed at, respectively:The
zig_import
macro use the non-standard__asm
convention for function aliasing on any compiler not MSVC.slimcc
stopped here, as its maintainer I will implement it ASAP.zig/stage1/zig.h
Lines 224 to 234 in aa7d138
tcc
stopped at this point,zig/stage1/zig.h
Lines 1250 to 1252 in aa7d138
since it does not advertise
__has_attribute((aligned))
and the build driver passes-std=c99
,zig_align
expands tozig_align_unavailable
as the result of these two macro, failing the compilation.zig/stage1/zig.h
Lines 132 to 146 in aa7d138
The text was updated successfully, but these errors were encountered: