Skip to content
Open
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
16 changes: 14 additions & 2 deletions toolchain/zig-wrapper.zig
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,20 @@ fn parseArgs(
.arg1, .cc => try args.appendSlice(arena, &[_][]const u8{arg0_noexe}),
}

while (argv_it.next()) |arg|
try args.append(arena, arg);
// Process arguments, transforming -u SYMBOL into -Wl,-u,SYMBOL
// This is needed because zig c++ doesn't handle the -u flag correctly
// (it tries to open the symbol name as a file instead of passing it to the linker)
while (argv_it.next()) |arg| {
if (mem.eql(u8, arg, "-u")) {
// Get the next argument (the symbol name)
if (argv_it.next()) |symbol| {
const transformed = try std.fmt.allocPrint(arena, "-Wl,-u,{s}", .{symbol});
try args.append(arena, transformed);
}
} else {
try args.append(arena, arg);
}
}

// Add -target as the last parameter. The wrapper should overwrite
// the target specified by other tools calling the wrapper.
Expand Down