diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2020-11-02 13:41:32 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-11-02 13:41:32 -0500 |
| commit | 00ceb592ef8d396ec354152c1684321a6c5847e4 (patch) | |
| tree | c12a7a6cb5421aaa19753d2b2223ef4d057db60f /src | |
| parent | be26c3bf4e4c6a7654ea68e6606c1167ef969a09 (diff) | |
| parent | 6ecefd590360be0484d766d18a23e19c6c7325e6 (diff) | |
| download | zig-00ceb592ef8d396ec354152c1684321a6c5847e4.tar.gz zig-00ceb592ef8d396ec354152c1684321a6c5847e4.zip | |
Merge pull request #6932 from kubkon/fix-6318
macOS: fix linking issues on BigSur
Diffstat (limited to 'src')
| -rw-r--r-- | src/Compilation.zig | 9 | ||||
| -rw-r--r-- | src/link.zig | 2 | ||||
| -rw-r--r-- | src/link/MachO.zig | 5 |
3 files changed, 16 insertions, 0 deletions
diff --git a/src/Compilation.zig b/src/Compilation.zig index 472f367b91..d4289fad34 100644 --- a/src/Compilation.zig +++ b/src/Compilation.zig @@ -472,6 +472,14 @@ pub fn create(gpa: *Allocator, options: InitOptions) !*Compilation { break :blk false; }; + const syslibroot = if (build_options.have_llvm and comptime std.Target.current.isDarwin()) outer: { + const path = if (use_lld and options.is_native_os and options.target.isDarwin()) inner: { + const syslibroot_path = try std.zig.system.getSDKPath(arena); + break :inner syslibroot_path; + } else null; + break :outer path; + } else null; + const link_libc = options.link_libc or target_util.osRequiresLibC(options.target); const must_dynamic_link = dl: { @@ -773,6 +781,7 @@ pub fn create(gpa: *Allocator, options: InitOptions) !*Compilation { .frameworks = options.frameworks, .framework_dirs = options.framework_dirs, .system_libs = system_libs, + .syslibroot = syslibroot, .lib_dirs = options.lib_dirs, .rpath_list = options.rpath_list, .strip = strip, diff --git a/src/link.zig b/src/link.zig index 3f6ceb7ac3..02433ecde7 100644 --- a/src/link.zig +++ b/src/link.zig @@ -88,6 +88,8 @@ pub const Options = struct { llvm_cpu_features: ?[*:0]const u8, /// Extra args passed directly to LLD. Ignored when not linking with LLD. extra_lld_args: []const []const u8, + /// Darwin-only. Set the root path to the system libraries and frameworks. + syslibroot: ?[]const u8, objects: []const []const u8, framework_dirs: []const []const u8, diff --git a/src/link/MachO.zig b/src/link/MachO.zig index 7344a698f9..01830c1561 100644 --- a/src/link/MachO.zig +++ b/src/link/MachO.zig @@ -628,6 +628,11 @@ fn linkWithLLD(self: *MachO, comp: *Compilation) !void { } } + if (self.base.options.syslibroot) |dir| { + try argv.append("-syslibroot"); + try argv.append(dir); + } + for (self.base.options.lib_dirs) |lib_dir| { try argv.append("-L"); try argv.append(lib_dir); |
