authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-05-12 22:25:20-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-05-12 22:25:20-07:00
loga7aa3ca66c271bc6f2905e4c3f0dd78763584d5b
tree24e232f653f0e57b9c5d988cd3e10ccf842add65
parent344dc0cc0ffcd32ffb07c43ca7123b8564f2a506

stage2: build and provide libunwind when compiling for native libc

5ac91794cce8bd53916a378815be01e4365d53d9 made Zig link against the system libc when targeting the native C ABI. However this made it stop putting libunwind.a on the linker line when it needed to sometimes, causing undefined symbols when linking against C++ code.

2 files changed, 3 insertions(+), 1 deletions(-)

src/Compilation.zig-1
...@@ -3278,7 +3278,6 @@ fn wantBuildLibUnwindFromSource(comp: *Compilation) bool {...@@ -3278,7 +3278,6 @@ fn wantBuildLibUnwindFromSource(comp: *Compilation) bool {
3278 .Exe => true,3278 .Exe => true,
3279 };3279 };
3280 return comp.bin_file.options.link_libc and is_exe_or_dyn_lib and3280 return comp.bin_file.options.link_libc and is_exe_or_dyn_lib and
3281 comp.bin_file.options.libc_installation == null and
3282 comp.bin_file.options.object_format != .c and3281 comp.bin_file.options.object_format != .c and
3283 target_util.libcNeedsLibUnwind(comp.getTarget());3282 target_util.libcNeedsLibUnwind(comp.getTarget());
3284}3283}
src/link/Elf.zig+3
...@@ -1648,6 +1648,9 @@ fn linkWithLLD(self: *Elf, comp: *Compilation) !void {...@@ -1648,6 +1648,9 @@ fn linkWithLLD(self: *Elf, comp: *Compilation) !void {
1648 // libc dep1648 // libc dep
1649 if (self.base.options.link_libc) {1649 if (self.base.options.link_libc) {
1650 if (self.base.options.libc_installation != null) {1650 if (self.base.options.libc_installation != null) {
1651 if (target_util.libcNeedsLibUnwind(target)) {
1652 try argv.append(comp.libunwind_static_lib.?.full_object_path);
1653 }
1651 const needs_grouping = self.base.options.link_mode == .Static;1654 const needs_grouping = self.base.options.link_mode == .Static;
1652 if (needs_grouping) try argv.append("--start-group");1655 if (needs_grouping) try argv.append("--start-group");
1653 // This matches the order of glibc.libs1656 // This matches the order of glibc.libs