From b183b612c938a8c9949fee02fa55038273595496 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Wed, 23 Sep 2020 11:15:27 -0700 Subject: [PATCH] stage2: don't build libunwind on OS's that don't need it --- src/Compilation.zig | 3 ++- src/target.zig | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/Compilation.zig b/src/Compilation.zig index 1297341926..9ff2f35134 100644 --- a/src/Compilation.zig +++ b/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 { diff --git a/src/target.zig b/src/target.zig index 8ea880e898..0402ccbd51 100644 --- a/src/target.zig +++ b/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(); }