From e3575cdad44e63f598b557ba3142675197875906 Mon Sep 17 00:00:00 2001 From: Jakub Konka Date: Tue, 13 Jul 2021 22:58:25 +0200 Subject: zld: decommision use_lld for MachO Invoke `linkAsArchive` directly in MachO backend when LLVM is available and we are asked to create a static lib. --- src/Compilation.zig | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'src/Compilation.zig') diff --git a/src/Compilation.zig b/src/Compilation.zig index 625de58c63..5146e757fa 100644 --- a/src/Compilation.zig +++ b/src/Compilation.zig @@ -866,6 +866,10 @@ pub fn create(gpa: *Allocator, options: InitOptions) !*Compilation { // Make a decision on whether to use LLD or our own linker. const use_lld = options.use_lld orelse blk: { + if (options.target.isDarwin()) { + break :blk false; + } + if (!build_options.have_llvm) break :blk false; @@ -903,11 +907,9 @@ pub fn create(gpa: *Allocator, options: InitOptions) !*Compilation { break :blk false; }; - const darwin_can_use_system_sdk = - // comptime conditions - ((build_options.have_llvm and comptime std.Target.current.isDarwin()) and - // runtime conditions - (use_lld and std.builtin.os.tag == .macos and options.target.isDarwin())); + const darwin_can_use_system_sdk = comptime std.Target.current.isDarwin() and + std.builtin.os.tag == .macos and + options.target.isDarwin(); const sysroot = blk: { if (options.sysroot) |sysroot| { @@ -924,10 +926,10 @@ pub fn create(gpa: *Allocator, options: InitOptions) !*Compilation { const lto = blk: { if (options.want_lto) |explicit| { - if (!use_lld) + if (!use_lld and !options.target.isDarwin()) return error.LtoUnavailableWithoutLld; break :blk explicit; - } else if (!use_lld) { + } else if (!use_lld and !options.target.isDarwin()) { break :blk false; } else if (options.c_source_files.len == 0) { break :blk false; -- cgit v1.2.3