diff options
| author | Alex Rønne Petersen <alex@alexrp.com> | 2024-11-05 15:26:05 +0100 |
|---|---|---|
| committer | Alex Rønne Petersen <alex@alexrp.com> | 2024-11-05 22:41:09 +0100 |
| commit | 5685a10ded2dbb64070c8f43911a05584901c5eb (patch) | |
| tree | ae5a2586b52f39f218b0b4410f7036632c9eff9f /src | |
| parent | eb14fd8806885b43dd98492f0a6720038d8176c8 (diff) | |
| download | zig-5685a10ded2dbb64070c8f43911a05584901c5eb.tar.gz zig-5685a10ded2dbb64070c8f43911a05584901c5eb.zip | |
libunwind: Pass -fPIC -funwind-tables via module options instead of CFLAGS.
Diffstat (limited to 'src')
| -rw-r--r-- | src/libunwind.zig | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/src/libunwind.zig b/src/libunwind.zig index d7b22e2067..1e101da229 100644 --- a/src/libunwind.zig +++ b/src/libunwind.zig @@ -46,6 +46,7 @@ pub fn buildStaticLib(comp: *Compilation, prog_node: std.Progress.Node) BuildErr ); return error.SubCompilationFailed; }; + const target = comp.root_mod.resolved_target.result; const root_mod = Module.create(arena, .{ .global_cache_directory = comp.global_cache_directory, .paths = .{ @@ -63,8 +64,9 @@ pub fn buildStaticLib(comp: *Compilation, prog_node: std.Progress.Node) BuildErr .valgrind = false, .sanitize_c = false, .sanitize_thread = false, - .unwind_tables = false, - .pic = comp.root_mod.pic, + // necessary so that libunwind can unwind through its own stack frames + .unwind_tables = true, + .pic = if (target_util.supports_fpic(target)) true else null, .optimize_mode = comp.compilerRtOptMode(), }, .global = config, @@ -83,7 +85,6 @@ pub fn buildStaticLib(comp: *Compilation, prog_node: std.Progress.Node) BuildErr const root_name = "unwind"; const link_mode = .static; - const target = comp.root_mod.resolved_target.result; const basename = try std.zig.binNameAlloc(arena, .{ .root_name = root_name, .target = target, @@ -114,16 +115,11 @@ pub fn buildStaticLib(comp: *Compilation, prog_node: std.Progress.Node) BuildErr try cflags.append("-fno-exceptions"); try cflags.append("-I"); try cflags.append(try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libunwind", "include" })); - if (target_util.supports_fpic(target)) { - try cflags.append("-fPIC"); - } try cflags.append("-D_LIBUNWIND_DISABLE_VISIBILITY_ANNOTATIONS"); try cflags.append("-Wa,--noexecstack"); try cflags.append("-fvisibility=hidden"); try cflags.append("-fvisibility-inlines-hidden"); try cflags.append("-fvisibility-global-new-delete=force-hidden"); - // necessary so that libunwind can unwind through its own stack frames - try cflags.append("-funwind-tables"); // This is intentionally always defined because the macro definition means, should it only // build for the target specified by compiler defines. Since we pass -target the compiler |
