| ... | @@ -46,6 +46,7 @@ pub fn buildStaticLib(comp: *Compilation, prog_node: std.Progress.Node) BuildErr | ... | @@ -46,6 +46,7 @@ pub fn buildStaticLib(comp: *Compilation, prog_node: std.Progress.Node) BuildErr |
| 46 | ); | 46 | ); |
| 47 | return error.SubCompilationFailed; | 47 | return error.SubCompilationFailed; |
| 48 | }; | 48 | }; |
| | 49 | const target = comp.root_mod.resolved_target.result; |
| 49 | const root_mod = Module.create(arena, .{ | 50 | const root_mod = Module.create(arena, .{ |
| 50 | .global_cache_directory = comp.global_cache_directory, | 51 | .global_cache_directory = comp.global_cache_directory, |
| 51 | .paths = .{ | 52 | .paths = .{ |
| ... | @@ -63,8 +64,9 @@ pub fn buildStaticLib(comp: *Compilation, prog_node: std.Progress.Node) BuildErr | ... | @@ -63,8 +64,9 @@ pub fn buildStaticLib(comp: *Compilation, prog_node: std.Progress.Node) BuildErr |
| 63 | .valgrind = false, | 64 | .valgrind = false, |
| 64 | .sanitize_c = false, | 65 | .sanitize_c = false, |
| 65 | .sanitize_thread = false, | 66 | .sanitize_thread = false, |
| 66 | .unwind_tables = false, | 67 | // necessary so that libunwind can unwind through its own stack frames |
| 67 | .pic = comp.root_mod.pic, | 68 | .unwind_tables = true, |
| | 69 | .pic = if (target_util.supports_fpic(target)) true else null, |
| 68 | .optimize_mode = comp.compilerRtOptMode(), | 70 | .optimize_mode = comp.compilerRtOptMode(), |
| 69 | }, | 71 | }, |
| 70 | .global = config, | 72 | .global = config, |
| ... | @@ -83,7 +85,6 @@ pub fn buildStaticLib(comp: *Compilation, prog_node: std.Progress.Node) BuildErr | ... | @@ -83,7 +85,6 @@ pub fn buildStaticLib(comp: *Compilation, prog_node: std.Progress.Node) BuildErr |
| 83 | | 85 | |
| 84 | const root_name = "unwind"; | 86 | const root_name = "unwind"; |
| 85 | const link_mode = .static; | 87 | const link_mode = .static; |
| 86 | const target = comp.root_mod.resolved_target.result; | | |
| 87 | const basename = try std.zig.binNameAlloc(arena, .{ | 88 | const basename = try std.zig.binNameAlloc(arena, .{ |
| 88 | .root_name = root_name, | 89 | .root_name = root_name, |
| 89 | .target = target, | 90 | .target = target, |
| ... | @@ -114,16 +115,11 @@ pub fn buildStaticLib(comp: *Compilation, prog_node: std.Progress.Node) BuildErr | ... | @@ -114,16 +115,11 @@ pub fn buildStaticLib(comp: *Compilation, prog_node: std.Progress.Node) BuildErr |
| 114 | try cflags.append("-fno-exceptions"); | 115 | try cflags.append("-fno-exceptions"); |
| 115 | try cflags.append("-I"); | 116 | try cflags.append("-I"); |
| 116 | try cflags.append(try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libunwind", "include" })); | 117 | try cflags.append(try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libunwind", "include" })); |
| 117 | if (target_util.supports_fpic(target)) { | | |
| 118 | try cflags.append("-fPIC"); | | |
| 119 | } | | |
| 120 | try cflags.append("-D_LIBUNWIND_DISABLE_VISIBILITY_ANNOTATIONS"); | 118 | try cflags.append("-D_LIBUNWIND_DISABLE_VISIBILITY_ANNOTATIONS"); |
| 121 | try cflags.append("-Wa,--noexecstack"); | 119 | try cflags.append("-Wa,--noexecstack"); |
| 122 | try cflags.append("-fvisibility=hidden"); | 120 | try cflags.append("-fvisibility=hidden"); |
| 123 | try cflags.append("-fvisibility-inlines-hidden"); | 121 | try cflags.append("-fvisibility-inlines-hidden"); |
| 124 | try cflags.append("-fvisibility-global-new-delete=force-hidden"); | 122 | try cflags.append("-fvisibility-global-new-delete=force-hidden"); |
| 125 | // necessary so that libunwind can unwind through its own stack frames | | |
| 126 | try cflags.append("-funwind-tables"); | | |
| 127 | | 123 | |
| 128 | // This is intentionally always defined because the macro definition means, should it only | 124 | // This is intentionally always defined because the macro definition means, should it only |
| 129 | // build for the target specified by compiler defines. Since we pass -target the compiler | 125 | // build for the target specified by compiler defines. Since we pass -target the compiler |