-
-
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
zig cc -Wl,--version: unsupported linker arg: --version #15549
Comments
Just encountered similar problem while trying to use |
Here's what I think it should do:
It will be up to Meson to decide what to do with this information. |
I am hitting the same problem with cmake; trying to use zig as drop in replacement for C/C++.
|
I would like to contribute to this issue, but I am new to Zig and its compiler, so I take it as an opportunity to dig deeper into Zig if someone is willing to guide me. Me digging the codeTo my understanding, the execution of Lines 2207 to 2217 in 128fd7d
A very naive approach that I tried is to add another else if (mem.eql(u8, arg, "--version")) {
try std.io.getStdOut().writeAll("zig ld " ++ build_options.version ++ "\n");
} However, this has two effects:
This secondary effect is produced when hitting line 2272 Lines 2267 to 2273 in 128fd7d
QuestionsI read the comment #15549 (comment) but i do not understand why this Lines 3942 to 3948 in 2892347
should be the place to act to fix the issue. May I have some help to clear my mind? |
My original intent was to execve to the underlying system-specific lld. So the output of
What Andrew is proposing is much easier to implement, since you don't need to invoke the underlying linker.
I believe this should not be necessary. Just exit after printing the version. |
I see it now, thanks for the clarification! Shall I add the |
I implemented the change, but then, while using it, I realized that it is more complicated than anticipated. Simple printing the version and exit does not work since it will cause an early exit on any invocation of On the other end, printing the ld version and continue the program execution will behave correctly, but it will print on stdout both What would be the correct behaviour? |
We should follow the lead on what gcc/clang do:
It does not create a file:
Does that help? |
Yes! Actually thanks to your example I found out what was bugging me: I got even more confused because the Well, I guess I can revisit my PR, remove the |
zig cc -Wl,--version
is not understood by the linker:clang-16
zig-cc
meson uses it to determine the linker. Example when configuring glib:
I did not find a reasonable way to add such flag to
src/main.zig
andsrc/Compilation.zig
. The best current way to do it is here:zig/src/Compilation.zig
Lines 3942 to 3948 in 2892347
However, this whole function implies a single
c_object
is passed, which is obviously not the case here.The text was updated successfully, but these errors were encountered: