diff options
| author | Jakub Konka <kubkon@jakubkonka.com> | 2020-11-06 10:58:49 +0100 |
|---|---|---|
| committer | Jakub Konka <kubkon@jakubkonka.com> | 2020-11-06 11:34:51 +0100 |
| commit | b7c3ebcb9e3aefbdd82a43c7ab122931787c7805 (patch) | |
| tree | 4136470a9950065a63e77f5ef61d93e2b3b0f93f /src/Compilation.zig | |
| parent | e0e3ceac19c0de0f8b3e408f9d3728496bc051f7 (diff) | |
| download | zig-b7c3ebcb9e3aefbdd82a43c7ab122931787c7805.tar.gz zig-b7c3ebcb9e3aefbdd82a43c7ab122931787c7805.zip | |
Rely on ZIG_SYSTEM_LINKER_HACK instead of input flags
Diffstat (limited to 'src/Compilation.zig')
| -rw-r--r-- | src/Compilation.zig | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/src/Compilation.zig b/src/Compilation.zig index 961f8c08d5..b6f380ae60 100644 --- a/src/Compilation.zig +++ b/src/Compilation.zig @@ -348,8 +348,6 @@ pub const InitOptions = struct { want_valgrind: ?bool = null, use_llvm: ?bool = null, use_lld: ?bool = null, - /// When set, this option will overwrite LLD with the system linker LD. - system_linker_hack: bool = false, use_clang: ?bool = null, rdynamic: bool = false, strip: bool = false, @@ -474,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 = if (std.os.getenv("ZIG_SYSTEM_LINKER_HACK")) |_| true else false; + 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); @@ -777,14 +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 = options.system_linker_hack, + .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, |
