mirror of
https://github.com/ziglang/zig.git
synced 2025-12-30 18:13:19 +00:00
link: ELF, COFF, WASM: honor the "must_link" flag of positionals
Previously only the MachO linker was honoring the flag.
This commit is contained in:
parent
0e6d2184ca
commit
d7deffee8d
@ -1121,7 +1121,11 @@ fn linkWithLLD(self: *Coff, comp: *Compilation) !void {
|
||||
|
||||
try argv.ensureUnusedCapacity(self.base.options.objects.len);
|
||||
for (self.base.options.objects) |obj| {
|
||||
argv.appendAssumeCapacity(obj.path);
|
||||
if (obj.must_link) {
|
||||
argv.appendAssumeCapacity(try allocPrint(arena, "-WHOLEARCHIVE:{s}", .{obj.path}));
|
||||
} else {
|
||||
argv.appendAssumeCapacity(obj.path);
|
||||
}
|
||||
}
|
||||
|
||||
for (comp.c_object_table.keys()) |key| {
|
||||
|
||||
@ -1732,9 +1732,20 @@ fn linkWithLLD(self: *Elf, comp: *Compilation) !void {
|
||||
}
|
||||
|
||||
// Positional arguments to the linker such as object files.
|
||||
try argv.ensureUnusedCapacity(self.base.options.objects.len);
|
||||
var whole_archive = false;
|
||||
for (self.base.options.objects) |obj| {
|
||||
argv.appendAssumeCapacity(obj.path);
|
||||
if (obj.must_link and !whole_archive) {
|
||||
try argv.append("-whole-archive");
|
||||
whole_archive = true;
|
||||
} else if (!obj.must_link and whole_archive) {
|
||||
try argv.append("-no-whole-archive");
|
||||
whole_archive = false;
|
||||
}
|
||||
try argv.append(obj.path);
|
||||
}
|
||||
if (whole_archive) {
|
||||
try argv.append("-no-whole-archive");
|
||||
whole_archive = false;
|
||||
}
|
||||
|
||||
for (comp.c_object_table.keys()) |key| {
|
||||
|
||||
@ -1437,9 +1437,20 @@ fn linkWithLLD(self: *Wasm, comp: *Compilation) !void {
|
||||
}
|
||||
|
||||
// Positional arguments to the linker such as object files.
|
||||
try argv.ensureUnusedCapacity(self.base.options.objects.len);
|
||||
var whole_archive = false;
|
||||
for (self.base.options.objects) |obj| {
|
||||
argv.appendAssumeCapacity(obj.path);
|
||||
if (obj.must_link and !whole_archive) {
|
||||
try argv.append("-whole-archive");
|
||||
whole_archive = true;
|
||||
} else if (!obj.must_link and whole_archive) {
|
||||
try argv.append("-no-whole-archive");
|
||||
whole_archive = false;
|
||||
}
|
||||
try argv.append(obj.path);
|
||||
}
|
||||
if (whole_archive) {
|
||||
try argv.append("-no-whole-archive");
|
||||
whole_archive = false;
|
||||
}
|
||||
|
||||
for (comp.c_object_table.keys()) |key| {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user