diff options
| author | LemonBoy <thatlemon@gmail.com> | 2021-05-11 12:43:58 +0200 |
|---|---|---|
| committer | LemonBoy <thatlemon@gmail.com> | 2021-05-11 12:43:58 +0200 |
| commit | 2bb8e1ff550ef2b2676e4f7ec3fdaf17aee8d715 (patch) | |
| tree | 968872435a832f456ba52d54ac51c9b1c5dc0939 /src/link/Elf.zig | |
| parent | 780f510ac0137512ad2923835e4ecdb22a81028e (diff) | |
| download | zig-2bb8e1ff550ef2b2676e4f7ec3fdaf17aee8d715.tar.gz zig-2bb8e1ff550ef2b2676e4f7ec3fdaf17aee8d715.zip | |
stage2: Change libc components' linking order
Use the same order as Clang (and, by extension, GCC) for the three most
important libc components: lm comes first, followed by lpthread and then
lc.
Diffstat (limited to 'src/link/Elf.zig')
| -rw-r--r-- | src/link/Elf.zig | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/src/link/Elf.zig b/src/link/Elf.zig index 4375661f64..c31a094093 100644 --- a/src/link/Elf.zig +++ b/src/link/Elf.zig @@ -1648,17 +1648,12 @@ fn linkWithLLD(self: *Elf, comp: *Compilation) !void { // libc dep if (self.base.options.link_libc) { if (self.base.options.libc_installation != null) { - if (self.base.options.link_mode == .Static) { - try argv.append("--start-group"); - try argv.append("-lc"); - try argv.append("-lm"); - try argv.append("--end-group"); - } else { - try argv.append("-lc"); - try argv.append("-lm"); - } - + const needs_grouping = self.base.options.link_mode == .Static; + if (needs_grouping) try argv.append("--start-group"); + try argv.append("-lm"); try argv.append("-lpthread"); + try argv.append("-lc"); + if (needs_grouping) try argv.append("--end-group"); } else if (target.isGnuLibC()) { try argv.append(comp.libunwind_static_lib.?.full_object_path); for (glibc.libs) |lib| { |
