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

launcher: workaround zig cc -Wl,--version #55

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 34 additions & 2 deletions toolchain/launcher.zig
Original file line number Diff line number Diff line change
Expand Up @@ -219,11 +219,25 @@ fn parseArgs(
// args is the path to the zig binary and args to it.
var args = ArrayListUnmanaged([]const u8){};
try args.appendSlice(arena, &[_][]const u8{ zig_exe, zig_tool });

if (maybe_target) |target|
try args.appendSlice(arena, &[_][]const u8{ "-target", target });

while (argv_it.next()) |arg|
try args.append(arena, arg);
const is_linux = if (maybe_target) |target|
mem.indexOf(u8, target, "linux") != null
else
false;

while (argv_it.next()) |arg| {
// hack for https://github.com/ziglang/zig/issues/15549
if (is_linux and mem.eql(u8, "-Wl,--version", arg)) {
args.shrinkRetainingCapacity(1); // only external/zig_sdk/zig
try args.appendSlice(arena, &[_][]const u8{ "ld.lld", "--version" });
break;
} else {
try args.append(arena, arg);
}
}

return ParseResults{ .exec = .{ .args = args, .env = env } };
}
Expand Down Expand Up @@ -361,6 +375,24 @@ test "launcher:parseArgs" {
},
},
},
.{
.args = &[_][:0]const u8{
"tools" ++ sep ++ "x86_64-linux-musl" ++ sep ++ "c++" ++ EXE,
"-Wl,--version",
},
.want_result = .{
.exec = .{
.args = &[_][:0]const u8{
"tools" ++ sep ++ "x86_64-linux-musl" ++ sep ++
".." ++ sep ++ ".." ++ sep ++ "zig" ++ EXE,
"ld.lld",
"--version",
},
.env_zig_lib_dir = "tools" ++ sep ++ "x86_64-linux-musl" ++
sep ++ ".." ++ sep ++ ".." ++ sep ++ "lib",
},
},
},
.{
.args = &[_][:0]const u8{
"tools" ++ sep ++ "x86_64-linux-musl" ++ sep ++ "ar" ++ EXE,
Expand Down