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