authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2024-10-07 00:16:27+02:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2024-10-26 22:00:49+02:00
logf02d25d883cb5e9d9487e25ed9241c6c13bc1f88
treeffe1e59cfae02b455ff62079859e839b98d67cd3
parentbf31c9505cab00ec9ec80c845dac5571d52f6100
signaturebadge-check Signed by SSH key SHA256:7B/LJ7bpR1eX8aCXSr4mtd5M45VMPKcx9zY8e95b5QM

std.Target: Implement DynamicLinker.kind() function.

This helps callers of DynamicLinker.standard() make informed decisions about the usefulness of the returned value.

1 files changed, 69 insertions(+), 0 deletions(-)

lib/std/Target.zig+69
......@@ -2009,6 +2009,75 @@ pub const DynamicLinker = struct {
20092009 return std.mem.eql(u8, lhs.buffer[0..lhs.len], rhs.buffer[0..rhs.len]);
20102010 }
20112011
2012 pub const Kind = enum {
2013 /// No dynamic linker.
2014 none,
2015 /// Dynamic linker path is determined by the arch/OS components.
2016 arch_os,
2017 /// Dynamic linker path is determined by the arch/OS/ABI components.
2018 arch_os_abi,
2019 };
2020
2021 pub fn kind(os: Os.Tag) Kind {
2022 return switch (os) {
2023 .fuchsia,
2024
2025 .haiku,
2026 .serenity,
2027
2028 .dragonfly,
2029 .freebsd,
2030 .netbsd,
2031 .openbsd,
2032
2033 .bridgeos,
2034 .driverkit,
2035 .ios,
2036 .macos,
2037 .tvos,
2038 .visionos,
2039 .watchos,
2040
2041 .illumos,
2042 .solaris,
2043 => .arch_os,
2044 .hurd,
2045 .linux,
2046 => .arch_os_abi,
2047 .freestanding,
2048 .other,
2049
2050 .contiki,
2051 .elfiamcu,
2052 .hermit,
2053
2054 .aix,
2055 .plan9,
2056 .rtems,
2057 .zos,
2058
2059 .uefi,
2060 .windows,
2061
2062 .emscripten,
2063 .wasi,
2064
2065 .amdhsa,
2066 .amdpal,
2067 .cuda,
2068 .mesa3d,
2069 .nvcl,
2070 .opencl,
2071 .opengl,
2072 .vulkan,
2073
2074 .ps3,
2075 .ps4,
2076 .ps5,
2077 => .none,
2078 };
2079 }
2080
20122081 pub fn standard(cpu: Cpu, os: Os, abi: Abi) DynamicLinker {
20132082 return switch (os.tag) {
20142083 .fuchsia => init("ld.so.1"), // Fuchsia is unusual in that `DT_INTERP` is just a basename.