diff options
| author | Jakub Konka <kubkon@jakubkonka.com> | 2020-11-05 11:29:58 +0100 |
|---|---|---|
| committer | Jakub Konka <kubkon@jakubkonka.com> | 2020-11-05 18:35:51 +0100 |
| commit | e0e3ceac19c0de0f8b3e408f9d3728496bc051f7 (patch) | |
| tree | 676bca514c95c540837e42106cd8b9e9bb998531 /src/Compilation.zig | |
| parent | 17837affd22a6055c65a14252fa38610fdeabc3a (diff) | |
| download | zig-e0e3ceac19c0de0f8b3e408f9d3728496bc051f7.tar.gz zig-e0e3ceac19c0de0f8b3e408f9d3728496bc051f7.zip | |
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
```
Diffstat (limited to 'src/Compilation.zig')
| -rw-r--r-- | src/Compilation.zig | 3 |
1 files changed, 3 insertions, 0 deletions
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, |
