authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2026-09-17 06:24:24+02:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2026-09-17 15:27:49+02:00
logab5ce5b5e1742f54ae2b9a78899f50523f947665
treef4ca03e05aae4b4e9f6e7b2d20c2c1d3c82ecc23
parentb7104c95f249e42d0068bc2a94f7f426c0c740f3
signature Signed by SSH key SHA256:7B/LJ7bpR1eX8aCXSr4mtd5M45VMPKcx9zY8e95b5QM

std.Target: make DynamicLinker.standard() version range agnostic

Dynamic linker paths do change sometimes, but I'm not aware of a single instance of this happening where a compatibility symlink wasn't left in place. And even if we ignore that, the only two instances that we handled here were FreeBSD 6.0 (~2005) and DragonFly BSD 3.8 (~2014). Removing this requirement helps solve the chicken-and-egg problem going on in std.zig.system.resolveTargetQuery().

2 files changed, 7 insertions(+), 17 deletions(-)

lib/std/Target.zig+5-15
...@@ -2532,8 +2532,8 @@ pub const DynamicLinker = struct {...@@ -2532,8 +2532,8 @@ pub const DynamicLinker = struct {
2532 /// the ABI; it does not necessarily mean that `abi` makes any sense at all for that platform.2532 /// the ABI; it does not necessarily mean that `abi` makes any sense at all for that platform.
2533 /// The responsibility for determining whether `abi` is valid in this case rests with the2533 /// The responsibility for determining whether `abi` is valid in this case rests with the
2534 /// caller. `Abi.default()` can be used to pick a best-effort default ABI for such platforms.2534 /// caller. `Abi.default()` can be used to pick a best-effort default ABI for such platforms.
2535 pub fn standard(cpu: Cpu, os: Os, abi: Abi) DynamicLinker {2535 pub fn standard(cpu: Cpu, os: Os.Tag, abi: Abi) DynamicLinker {
2536 return switch (os.tag) {2536 return switch (os) {
2537 .fuchsia => switch (cpu.arch) {2537 .fuchsia => switch (cpu.arch) {
2538 .arm,2538 .arm,
2539 .aarch64,2539 .aarch64,
...@@ -2833,12 +2833,7 @@ pub const DynamicLinker = struct {...@@ -2833,12 +2833,7 @@ pub const DynamicLinker = struct {
2833 else => none,2833 else => none,
2834 },2834 },
28352835
2836 .dragonfly => if (cpu.arch == .x86_64) initFmt("{s}/libexec/ld-elf.so.2", .{2836 .dragonfly => if (cpu.arch == .x86_64) init("/libexec/ld-elf.so.2") else none,
2837 if (os.version_range.semver.isAtLeast(.{ .major = 3, .minor = 8, .patch = 0 }) orelse false)
2838 ""
2839 else
2840 "/usr",
2841 }) else none,
28422837
2843 .freebsd => switch (cpu.arch) {2838 .freebsd => switch (cpu.arch) {
2844 .arm,2839 .arm,
...@@ -2849,12 +2844,7 @@ pub const DynamicLinker = struct {...@@ -2849,12 +2844,7 @@ pub const DynamicLinker = struct {
2849 .riscv64,2844 .riscv64,
2850 .x86,2845 .x86,
2851 .x86_64,2846 .x86_64,
2852 => initFmt("{s}/libexec/ld-elf.so.1", .{2847 => init("/libexec/ld-elf.so.1"),
2853 if (os.version_range.semver.isAtLeast(.{ .major = 6, .minor = 0, .patch = 0 }) orelse false)
2854 ""
2855 else
2856 "/usr",
2857 }),
2858 else => none,2848 else => none,
2859 },2849 },
28602850
...@@ -2968,7 +2958,7 @@ pub const DynamicLinker = struct {...@@ -2968,7 +2958,7 @@ pub const DynamicLinker = struct {
2968};2958};
29692959
2970pub fn standardDynamicLinkerPath(target: *const Target) DynamicLinker {2960pub fn standardDynamicLinkerPath(target: *const Target) DynamicLinker {
2971 return DynamicLinker.standard(target.cpu, target.os, target.abi);2961 return DynamicLinker.standard(target.cpu, target.os.tag, target.abi);
2972}2962}
29732963
2974pub fn ptrBitWidth_cpu_abi(cpu: Cpu, abi: Abi) u16 {2964pub fn ptrBitWidth_cpu_abi(cpu: Cpu, abi: Abi) u16 {
lib/std/zig/system.zig+2-2
...@@ -995,7 +995,7 @@ fn detectAbiAndDynamicLinker(io: Io, cpu: Target.Cpu, os: Target.Os, query: Targ...@@ -995,7 +995,7 @@ fn detectAbiAndDynamicLinker(io: Io, cpu: Target.Cpu, os: Target.Os, query: Targ
995 // will then look for a dynamic linker with a matching path on the system and pick the ABI995 // will then look for a dynamic linker with a matching path on the system and pick the ABI
996 // we associated it with here.996 // we associated it with here.
997 .arch_os_abi => for (all_abis) |abi| {997 .arch_os_abi => for (all_abis) |abi| {
998 const ld = Target.DynamicLinker.standard(cpu, os, abi);998 const ld = Target.DynamicLinker.standard(cpu, os.tag, abi);
999999
1000 // Does the generated target triple actually have a standard dynamic linker path?1000 // Does the generated target triple actually have a standard dynamic linker path?
1001 if (ld.get() == null) continue;1001 if (ld.get() == null) continue;
...@@ -1141,7 +1141,7 @@ fn defaultAbiAndDynamicLinker(cpu: Target.Cpu, os: Target.Os, query: Target.Quer...@@ -1141,7 +1141,7 @@ fn defaultAbiAndDynamicLinker(cpu: Target.Cpu, os: Target.Os, query: Target.Quer
1141 .os = os,1141 .os = os,
1142 .abi = abi,1142 .abi = abi,
1143 .ofmt = query.ofmt orelse Target.ObjectFormat.default(os.tag, cpu.arch),1143 .ofmt = query.ofmt orelse Target.ObjectFormat.default(os.tag, cpu.arch),
1144 .dynamic_linker = query.dynamic_linker orelse .standard(cpu, os, abi),1144 .dynamic_linker = query.dynamic_linker orelse .standard(cpu, os.tag, abi),
1145 };1145 };
1146}1146}
11471147