Skip to content
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 ld: handle -v linker arg #20512

Merged
merged 2 commits into from
Aug 7, 2024
Merged

Conversation

aikawayataro
Copy link
Contributor

The "-v" argument is the same as "--version", but the linker should not exit after the version is printed.
CMake passes this argument during ABI info detection, and currently zig cc fails because this flag is not supported.

Fixes #20493

The "-v" argument is the same as "--version", but the linker should
not exit after the version is printed.
@@ -2475,6 +2475,8 @@ fn buildOutputType(
fatal("unable to parse /version '{s}': {s}", .{ arg, @errorName(err) });
};
have_version = true;
} else if (mem.eql(u8, arg, "-v")) {
try std.io.getStdOut().writeAll("zig ld " ++ build_options.version ++ "\n");
} else if (mem.eql(u8, arg, "--version")) {
Copy link
Contributor

@alexrp alexrp Jul 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While you're here, could you add a branch that handles -V as well, which just does warn("ignoring request for supported emulations: unimplemented", .{});? It should likewise not exit.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While you're here, could you add a branch that handles -V as well, which just does warn("ignoring request for supported emulations: unimplemented", .{});? It should likewise not exit.

I'll have a look at this one in the meantime

@alexrp
Copy link
Contributor

alexrp commented Jul 21, 2024

The "-v" argument is the same as "--version", but the linker should not exit after the version is printed.

Verified this behavior with GNU ld 2.41.

The "-V' argument lists the supported emulations. While linker
emulation is not implemented, it's beneficial to warn user regarding
this.
@aikawayataro aikawayataro requested a review from alexrp July 23, 2024 16:09
@alexrp
Copy link
Contributor

alexrp commented Jul 30, 2024

cc @kubkon (also needs approval to run CI)

@andrewrk andrewrk merged commit 87e8fc1 into ziglang:master Aug 7, 2024
10 checks passed
@andrewrk
Copy link
Member

andrewrk commented Aug 7, 2024

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CMake fails to detect ABI info with Zig cc/c++.
3 participants