Commit b183b612c9

Andrew Kelley <andrew@ziglang.org>
2020-09-23 20:15:27
stage2: don't build libunwind on OS's that don't need it
1 parent f4dde4d
Changed files (2)
src/Compilation.zig
@@ -1883,7 +1883,8 @@ 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;
+        comp.bin_file.options.libc_installation == null and
+        target_util.libcNeedsLibUnwind(comp.getTarget());
 }
 
 fn updateBuiltinZigFile(comp: *Compilation, mod: *Module) !void {
src/target.zig
@@ -128,6 +128,20 @@ pub fn osRequiresLibC(target: std.Target) bool {
     };
 }
 
+pub fn libcNeedsLibUnwind(target: std.Target) bool {
+    return switch (target.os.tag) {
+        .windows,
+        .macosx,
+        .ios,
+        .watchos,
+        .tvos,
+        .freestanding,
+        => false,
+
+        else => true,
+    };
+}
+
 pub fn requiresPIE(target: std.Target) bool {
     return target.isAndroid();
 }