authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2026-10-18 04:35:34+02:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2026-10-18 04:35:34+02:00
log4812a98ce535e5c3f27c081b94153612cd4817ac
treef175ad9bd4b4574ba1d8c385f63bd0a75cae648c
parent3a5777b6b10927eca53ae1e607011a9779f2e7b1
parent1797101fdacc6b56c0778501d076cb75bb6434d6

Merge pull request 'cmake: detect glibc and set `ZIG_HOST_TARGET_ABI` accordingly' (#37305) from alexrp/zig:cmake-glibc into master

Reviewed-on: https://codeberg.org/ziglang/zig/pulls/37305

2 files changed, 16 insertions(+), 3 deletions(-)

CMakeLists.txt+11
......@@ -601,6 +601,17 @@ elseif(ZIG_HOST_TARGET_IS_ANDROID)
601601 else()
602602 set(ZIG_HOST_TARGET_ABI "-android")
603603 endif()
604else()
605 check_symbol_exists(__GLIBC__ "features.h" ZIG_HOST_TARGET_IS_GLIBC)
606 if(ZIG_HOST_TARGET_IS_GLIBC)
607 if(ZIG_HOST_TARGET_ARCH MATCHES "^arm(eb)?$" OR ZIG_HOST_TARGET_ARCH MATCHES "^thumb(eb)?$" OR ZIG_HOST_TARGET_ARCH MATCHES "^powerpc(le)?$")
608 set(ZIG_HOST_TARGET_ABI "-gnueabihf")
609 elseif(ZIG_HOST_TARGET_ARCH MATCHES "^mips(el)?$")
610 set(ZIG_HOST_TARGET_ABI "-gnueabi")
611 else()
612 set(ZIG_HOST_TARGET_ABI "-gnu")
613 endif()
614 endif()
604615endif()
605616
606617set(ZIG_HOST_TARGET_TRIPLE "${ZIG_HOST_TARGET_ARCH}-${ZIG_HOST_TARGET_OS}${ZIG_HOST_TARGET_ABI}" CACHE STRING "Host zig target triple.")
lib/std/Target.zig+5-3
......@@ -859,6 +859,8 @@ pub const Abi = enum {
859859 .armeb,
860860 .powerpc,
861861 .powerpcle,
862 .sh,
863 .sheb,
862864 .thumb,
863865 .thumbeb,
864866 => .musleabihf,
......@@ -873,21 +875,21 @@ pub const Abi = enum {
873875 .alpha,
874876 .arc,
875877 .arceb,
876 .or1k,
878 .loongarch32,
877879 .sparc,
878880 .sparc64,
879881 => .gnu,
880882 .csky,
881883 => .gnueabi,
882884 .hppa,
883 .sh,
884 .sheb,
885885 => .gnueabihf,
886886
887887 // No glibc or musl support.
888888 .xtensa,
889889 .xtensaeb,
890890 => .none,
891 .hppa64,
892 => .eabihf,
891893
892894 else => .musl,
893895 },