-
-
Notifications
You must be signed in to change notification settings - Fork 3k
compiler: update aro and translate-c to latest; delete clang translate-c #24497
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
Conversation
1c4bddc
to
960d68b
Compare
960d68b
to
81092b4
Compare
When trying to communicate CLI options to the translate-c executable these are not yet handled:
manually reduced command:
fails:
(truncated) |
aha, aro does not support clang's C runtime includes, which makes sense.
stderr.txt contains:
|
81092b4
to
9cff3c5
Compare
280956f
to
dc91e5b
Compare
@Vexu do you recommend to also ship aro C headers, or do you think it is OK to use clang ones (the files in lib/include) |
Using the Clang headers didn't work when I last tried them. I don't remember why, might have been |
dc91e5b
to
7955ef9
Compare
I tried using this with tetris, however, translate-c created this dep file:
which caused ENOENT on |
That looks like the bug I fixed in Vexu/arocc@d0ebb59. |
66a769c
to
c3bc335
Compare
These warnings are a problem:
Maybe they can be addressed, but also I'm pretty sure they are supposed to be silenced because they are included with Also, what's the best way to convert Aro's errors to an ErrorBundle in Zig? Should we use |
Do you know how Edit: this one is an explicit
This makes me think aro is finding your system glibc instead of zig's glibc. |
it is indeed, and that is how it is supposed to work when compiling natively on the host. |
I see. For some reason I was thinking it was maybe getting headers from two different paths, but I see what you're saying about |
Sorry to be clear Aro is not finding system glibc - this is a middle ground between the translate-c package and status quo in which |
c3bc335
to
cf37d2e
Compare
src/Compilation.zig
Outdated
} | ||
|
||
if (mod.optimize_mode != .Debug) { | ||
try argv.append("-Werror=date-time"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The latest version of aro does have this warning (I noticed it's in the is_clang
condition)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gotcha, thanks!
btw did you see the other ones from the CI failures?
warning: unknown argument '-mmacos-version-min=15.6.0'
warning: unknown warning 'overriding-option' [-Wunknown-warning-option]
error: /home/ci/actions-runner5/_work/zig/zig/lib/libc/include/generic-glibc/bits/floatn.h:80:21: error: _Float128 is not supported on this target
typedef long double _Float128;
^
warning: unknown warning 'shadow' [-Wunknown-warning-option]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The last one I believe comes from
lib/libc/include/any-windows-any/stdio.h:#pragma GCC diagnostic ignored "-Wshadow"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Created an aro issue for the _Float128
thing Vexu/arocc#887
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
If I'm understanding this code correctly, the logic that is panicking here is incorrectly assuming that InternPool is a singleton:
|
also add ability to omit main source file from dep file as it messes up caching strategy
solves several problems with this pattern
These are now maintained in a separate repository: ziglang/translate-c
behavior tests may not depend on this namespace.
This is f5fb720a5399ee98e45f36337b2f68a4d23a783c plus ehaas's nonnull attribute pull request currently at 4b26cb3ac610a0a070fc43e43da8b4cdf0e9101b with zig patches intact.
There can be more than one InternPool instance active at the same time.
bba57d6
to
d83c76e
Compare
Looks like Aro is now (unconditionally?) putting includes into preprocessing, which are causing problems for resinator, which I don't think wants the libc includes:
cc @squeek502 you might want to review the resinator changes in this branch edit: umm actually I think this is a more serious problem because it looks like it would make |
I think it's related to the zig/lib/compiler/resinator/preprocess.zig Lines 91 to 100 in 41e5331
EDIT: I think you're right about it affecting more than |
Nice that workaround did work though so I think you've diagnosed the issue. |
Curiously, this worked: const c = @cImport({
@cInclude("stdio.h");
@cInclude("string.h");
});
const msg = "Hello, world!\n";
pub export fn main(argc: c_int, argv: **u8) c_int {
_ = argv;
_ = argc;
if (c.printf(msg) != @as(c_int, @intCast(c.strlen(msg)))) return -1;
return 0;
}
|
I think that's because
|
I'm going to merge this. Let's keep an eye on issues opened for regressions in translate-c / |
Since I bothered to do the math, here's how this affected Zig binary sizes:
This is expected since the Zig binary that includes LLVM still also includes Clang in order to compile C/C++ files into object files. |
With all due respect this just broke some cImport code I wrote for the start of a software rendered game. Since this commit the cross-compilation to windows now fails and the native Linux compilation shows a myriad of warnings. Why would one jeopardize the ease of C integration that Zig offers by replacing clang with Arocc, a compiler that is still in alpha phase? The sentence "While breakage is likely due to one C compiler being swapped out for another, if it occurs it is a bug rather than a feature." has a very bitter after taste. |
It doesn't say "alpha" in the Aro readme. Where are you deriving alpha status from? Generally, "alpha" is used to mean "the users are the developers". Anyway, it's beside the point. If you're writing a game in Zig I recommend to stick to tagged releases (latest is 0.15.1 at time of writing). Those who choose to use latest master branch builds are helping with development of Zig. If you want to do that, thank you - please report regressions (and unexpected warnings) to https://github.com/ziglang/translate-c/. If you don't want to do that, that's fine too. Other people will donate their time and efforts towards finding and fixing these things before 0.16.0 is tagged. |
This deletes our implementation of translate-c which is based on libclang and replaces it with one based on arocc and translate-c.
Goodbye, and good riddance, to 5,940 lines of our remaining C++ code in the source repository, with 3,763 remaining.
Progress towards #20630. In the future, Zig will drop the
@cImport
language builtin, but for now, it remains, backed by Aro instead of Clang.Progress towards #16270
Upgrade Guide
This is technically a non-breaking change. While breakage is likely due to one C compiler being swapped out for another, if it occurs it is a bug rather than a feature.
So, cross your fingers when you upgrade and report a bug if something breaks.
Merge Checklist
jitCmd