authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-07-30 18:58:47+02:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-07-30 18:58:47+02:00
log259b7c3f3fc3f8902f8aa4e6e7539df271073a47
treecb72426a7c6df4e88e604b97e26cdd9b383233e2
parent6ec275ebd8fce2e816f3f66e0fec5e53669b96c1
signaturebadge-check Signed by SSH key SHA256:7B/LJ7bpR1eX8aCXSr4mtd5M45VMPKcx9zY8e95b5QM

std.Target: pull Os.requiresLibC() up to Target


2 files changed, 51 insertions(+), 52 deletions(-)

lib/std/Target.zig+50-51
......@@ -697,57 +697,6 @@ pub const Os = struct {
697697 => |field| @field(os.version_range, @tagName(field)).isAtLeast(ver),
698698 };
699699 }
700
701 /// On Darwin, we always link libSystem which contains libc.
702 /// Similarly on FreeBSD and NetBSD we always link system libc
703 /// since this is the stable syscall interface.
704 pub fn requiresLibC(os: Os) bool {
705 return switch (os.tag) {
706 .aix,
707 .driverkit,
708 .macos,
709 .ios,
710 .tvos,
711 .watchos,
712 .visionos,
713 .dragonfly,
714 .openbsd,
715 .haiku,
716 .solaris,
717 .illumos,
718 .serenity,
719 => true,
720
721 .linux,
722 .windows,
723 .freebsd,
724 .netbsd,
725 .freestanding,
726 .fuchsia,
727 .ps3,
728 .zos,
729 .rtems,
730 .cuda,
731 .nvcl,
732 .amdhsa,
733 .ps4,
734 .ps5,
735 .mesa3d,
736 .contiki,
737 .amdpal,
738 .hermit,
739 .hurd,
740 .wasi,
741 .emscripten,
742 .uefi,
743 .opencl,
744 .opengl,
745 .vulkan,
746 .plan9,
747 .other,
748 => false,
749 };
750 }
751700};
752701
753702pub const aarch64 = @import("Target/aarch64.zig");
......@@ -2055,6 +2004,56 @@ pub inline fn isWasiLibC(target: *const Target) bool {
20552004 return target.os.tag == .wasi and target.abi.isMusl();
20562005}
20572006
2007/// Does this target require linking libc? This may be the case if the target has an unstable
2008/// syscall interface, for example.
2009pub fn requiresLibC(target: *const Target) bool {
2010 return switch (target.os.tag) {
2011 .aix,
2012 .driverkit,
2013 .macos,
2014 .ios,
2015 .tvos,
2016 .watchos,
2017 .visionos,
2018 .dragonfly,
2019 .openbsd,
2020 .haiku,
2021 .solaris,
2022 .illumos,
2023 .serenity,
2024 => true,
2025
2026 .linux
2027 .windows,
2028 .freebsd,
2029 .netbsd,
2030 .freestanding,
2031 .fuchsia,
2032 .ps3,
2033 .zos,
2034 .rtems,
2035 .cuda,
2036 .nvcl,
2037 .amdhsa,
2038 .ps4,
2039 .ps5,
2040 .mesa3d,
2041 .contiki,
2042 .amdpal,
2043 .hermit,
2044 .hurd,
2045 .wasi,
2046 .emscripten,
2047 .uefi,
2048 .opencl,
2049 .opengl,
2050 .vulkan,
2051 .plan9,
2052 .other,
2053 => false,
2054 };
2055}
2056
20582057pub const DynamicLinker = struct {
20592058 /// Contains the memory used to store the dynamic linker path. This field
20602059 /// should not be used directly. See `get` and `set`. This field exists so
src/target.zig+1-1
......@@ -20,7 +20,7 @@ pub fn cannotDynamicLink(target: *const std.Target) bool {
2020/// Similarly on FreeBSD and NetBSD we always link system libc
2121/// since this is the stable syscall interface.
2222pub fn osRequiresLibC(target: *const std.Target) bool {
23 return target.os.requiresLibC();
23 return target.requiresLibC();
2424}
2525
2626pub fn libCNeedsLibUnwind(target: *const std.Target, link_mode: std.builtin.LinkMode) bool {