aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2021-05-12 22:25:20 -0700
committerAndrew Kelley <andrew@ziglang.org>2021-05-12 22:29:21 -0700
commit4b59f564344598b4d1f1a51839a4dc5cbf357012 (patch)
treeac1567c2e4fdbde343b30150b0fd42e3742e2a08 /src
parent459c9f05359e3405f39e4c954c62c61a493e49ae (diff)
downloadzig-4b59f564344598b4d1f1a51839a4dc5cbf357012.tar.gz
zig-4b59f564344598b4d1f1a51839a4dc5cbf357012.zip
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.
Diffstat (limited to 'src')
-rw-r--r--src/Compilation.zig1
-rw-r--r--src/link/Elf.zig3
2 files changed, 3 insertions, 1 deletions
diff --git a/src/Compilation.zig b/src/Compilation.zig
index 6a9f75acf5..b14e598f71 100644
--- a/src/Compilation.zig
+++ b/src/Compilation.zig
@@ -3023,7 +3023,6 @@ fn wantBuildLibUnwindFromSource(comp: *Compilation) bool {
.Exe => true,
};
return comp.bin_file.options.link_libc and is_exe_or_dyn_lib and
- comp.bin_file.options.libc_installation == null and
target_util.libcNeedsLibUnwind(comp.getTarget());
}
diff --git a/src/link/Elf.zig b/src/link/Elf.zig
index 9a0aeabe6c..fbbe40022a 100644
--- a/src/link/Elf.zig
+++ b/src/link/Elf.zig
@@ -1648,6 +1648,9 @@ fn linkWithLLD(self: *Elf, comp: *Compilation) !void {
// libc dep
if (self.base.options.link_libc) {
if (self.base.options.libc_installation != null) {
+ if (target_util.libcNeedsLibUnwind(target)) {
+ try argv.append(comp.libunwind_static_lib.?.full_object_path);
+ }
const needs_grouping = self.base.options.link_mode == .Static;
if (needs_grouping) try argv.append("--start-group");
try argv.appendSlice(target_util.libcFullLinkFlags(target));