diff options
| author | Alex Rønne Petersen <alex@alexrp.com> | 2025-05-03 06:32:15 +0200 |
|---|---|---|
| committer | Alex Rønne Petersen <alex@alexrp.com> | 2025-05-03 10:54:36 +0200 |
| commit | d2f92e1797cf30c2fb0993d7e09de73e496144f5 (patch) | |
| tree | 5ff3a50055955dc6fd586defaec9e180f22f6506 /src/Compilation | |
| parent | f6476e9caeadea0c0c6b18841dffcf72bffdd582 (diff) | |
| download | zig-d2f92e1797cf30c2fb0993d7e09de73e496144f5.tar.gz zig-d2f92e1797cf30c2fb0993d7e09de73e496144f5.zip | |
compiler: Link libunwind when linking glibc statically.
glibc's libc.a depends on the functions provided by libunwind.
Diffstat (limited to 'src/Compilation')
| -rw-r--r-- | src/Compilation/Config.zig | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/Compilation/Config.zig b/src/Compilation/Config.zig index 1de0d83aa7..71df1d9311 100644 --- a/src/Compilation/Config.zig +++ b/src/Compilation/Config.zig @@ -129,6 +129,7 @@ pub const ResolveError = error{ LldCannotIncrementallyLink, LtoRequiresLld, SanitizeThreadRequiresLibCpp, + LibCRequiresLibUnwind, LibCppRequiresLibUnwind, OsRequiresLibC, LibCppRequiresLibC, @@ -312,7 +313,7 @@ pub fn resolve(options: Options) ResolveError!Config { break :b false; }; - const link_libunwind = b: { + var link_libunwind = b: { if (link_libcpp and target_util.libCxxNeedsLibUnwind(target)) { if (options.link_libunwind == false) return error.LibCppRequiresLibUnwind; break :b true; @@ -379,6 +380,13 @@ pub fn resolve(options: Options) ResolveError!Config { break :b .static; }; + // This is done here to avoid excessive duplicated logic due to the complex dependencies between these options. + if (options.output_mode == .Exe and link_libc and target_util.libCNeedsLibUnwind(target, link_mode)) { + if (options.link_libunwind == false) return error.LibCRequiresLibUnwind; + + link_libunwind = true; + } + const import_memory = options.import_memory orelse (options.output_mode == .Obj); const export_memory = b: { if (link_mode == .dynamic) { |
