aboutsummaryrefslogtreecommitdiff
path: root/src/Compilation.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2020-11-06 13:22:03 -0500
committerGitHub <noreply@github.com>2020-11-06 13:22:03 -0500
commita9e09a8be4ff6a15dabb1362a6833e6b0af66b22 (patch)
tree67236efd6bbb875d2eef2c7068826dcc2e1abed1 /src/Compilation.zig
parenta1a16a941e6e04c0f6f0d17c4c9f13d2ba32a9a1 (diff)
parentab69b89d528c828e949bb2d2f3632401a2d382fe (diff)
downloadzig-a9e09a8be4ff6a15dabb1362a6833e6b0af66b22.tar.gz
zig-a9e09a8be4ff6a15dabb1362a6833e6b0af66b22.zip
Merge pull request #6990 from kubkon/system-linker-hack
Re-enable system linker hack
Diffstat (limited to 'src/Compilation.zig')
-rw-r--r--src/Compilation.zig26
1 files changed, 18 insertions, 8 deletions
diff --git a/src/Compilation.zig b/src/Compilation.zig
index d4289fad34..36847f0437 100644
--- a/src/Compilation.zig
+++ b/src/Compilation.zig
@@ -472,13 +472,22 @@ 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 DarwinOptions = struct {
+ syslibroot: ?[]const u8 = null,
+ system_linker_hack: bool = false,
+ };
+
+ const darwin_options: DarwinOptions = if (build_options.have_llvm and comptime std.Target.current.isDarwin()) outer: {
+ const opts: DarwinOptions = if (use_lld and options.is_native_os and options.target.isDarwin()) inner: {
+ const syslibroot = try std.zig.system.getSDKPath(arena);
+ const system_linker_hack = std.os.getenv("ZIG_SYSTEM_LINKER_HACK") != null;
+ break :inner .{
+ .syslibroot = syslibroot,
+ .system_linker_hack = system_linker_hack,
+ };
+ } else .{};
+ break :outer opts;
+ } else .{};
const link_libc = options.link_libc or target_util.osRequiresLibC(options.target);
@@ -775,13 +784,14 @@ pub fn create(gpa: *Allocator, options: InitOptions) !*Compilation {
.optimize_mode = options.optimize_mode,
.use_lld = use_lld,
.use_llvm = use_llvm,
+ .system_linker_hack = darwin_options.system_linker_hack,
.link_libc = link_libc,
.link_libcpp = options.link_libcpp,
.objects = options.link_objects,
.frameworks = options.frameworks,
.framework_dirs = options.framework_dirs,
.system_libs = system_libs,
- .syslibroot = syslibroot,
+ .syslibroot = darwin_options.syslibroot,
.lib_dirs = options.lib_dirs,
.rpath_list = options.rpath_list,
.strip = strip,