authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2020-12-04 16:23:21+01:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-12-04 12:39:07-07:00
log96a703ee6deea1dfbfe300fc997c99c485fa3df8
treee04c6e514d31206cf29123cda177b7cc02dda804
parent32997a2fb06edd4365116d07d88de742b59df84d

Version-gate appending -syslibroot flag to lld

This commit version-gates appending `-syslibroot` flag to lld. This is predicated upon the fact that for versions of macOS lower than 11, lld would fail to find and link against frameworks with this flag specified. Co-authored-by: Andrew Kelley <andrew@ziglang.org>

2 files changed, 6 insertions(+), 1 deletions(-)

src/Compilation.zig+4-1
......@@ -530,7 +530,10 @@ pub fn create(gpa: *Allocator, options: InitOptions) !*Compilation {
530530
531531 const darwin_options: DarwinOptions = if (build_options.have_llvm and comptime std.Target.current.isDarwin()) outer: {
532532 const opts: DarwinOptions = if (use_lld and options.is_native_os and options.target.isDarwin()) inner: {
533 const syslibroot = try std.zig.system.getSDKPath(arena);
533 // TODO Revisit this targeting versions lower than macOS 11 when LLVM 12 is out.
534 // See https://github.com/ziglang/zig/issues/6996
535 const at_least_big_sur = options.target.os.getVersionRange().semver.min.major >= 11;
536 const syslibroot = if (at_least_big_sur) try std.zig.system.getSDKPath(arena) else null;
534537 const system_linker_hack = std.os.getenv("ZIG_SYSTEM_LINKER_HACK") != null;
535538 break :inner .{
536539 .syslibroot = syslibroot,
src/link/MachO.zig+2
......@@ -476,6 +476,8 @@ fn linkWithLLD(self: *MachO, comp: *Compilation) !void {
476476 man.hash.addStringSet(self.base.options.system_libs);
477477 man.hash.add(allow_shlib_undefined);
478478 man.hash.add(self.base.options.bind_global_refs_locally);
479 man.hash.add(self.base.options.system_linker_hack);
480 man.hash.addOptionalBytes(self.base.options.syslibroot);
479481
480482 // We don't actually care whether it's a cache hit or miss; we just need the digest and the lock.
481483 _ = try man.hit();