From e0e3ceac19c0de0f8b3e408f9d3728496bc051f7 Mon Sep 17 00:00:00 2001 From: Jakub Konka Date: Thu, 5 Nov 2020 11:29:58 +0100 Subject: Re-enable system linker hack It is now possible to force linking with system linker `ld` instead of the LLVM `lld` linker when building natively on the target. This can be done at each stage by specifying `--system-linker-hack` flag, and can be useful on platforms where `lld` fails to operate properly such as macOS 11 Big Sur on ARM64 where every binary/dylib is expected to be codesigned. Some example invocations for each stage of compilation of Zig toolchain: ``` cmake .. -DCMAKE_PREFIX_PATH=/path/to/llvm -DSYSTEM_LINKER_HACK=1 ``` ``` build/zig build test --system-linker-hack ``` ``` build/zig build --prefix $(pwd)/stage2 -Denable-llvm --system-linker-hack ``` ``` build/zig build-exe hello.zig --system-linker-hack ``` --- src/Compilation.zig | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/Compilation.zig') diff --git a/src/Compilation.zig b/src/Compilation.zig index d4289fad34..961f8c08d5 100644 --- a/src/Compilation.zig +++ b/src/Compilation.zig @@ -348,6 +348,8 @@ 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, @@ -775,6 +777,7 @@ 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, .link_libc = link_libc, .link_libcpp = options.link_libcpp, .objects = options.link_objects, -- cgit v1.2.3