From 6ef2175eeab7b7a514af8079a2a48c7e03cc1882 Mon Sep 17 00:00:00 2001 From: Jakub Chlanda Date: Wed, 17 Dec 2025 10:05:53 +0000 Subject: [PATCH] Add support for `aarch64-unknown-linux-pauthtest` This is based on a fork of Musl libc, maintained by Access Softek. Please see: https://github.com/access-softek/musl for details. --- build.rs | 9 +++++++-- libc-test/build.rs | 8 +++++--- src/unix/mod.rs | 12 +++++++++++- 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/build.rs b/build.rs index b9a8305918518..7b14e590e32b5 100644 --- a/build.rs +++ b/build.rs @@ -69,6 +69,7 @@ fn main() { let target_os = env::var("CARGO_CFG_TARGET_OS").unwrap_or_default(); let target_ptr_width = env::var("CARGO_CFG_TARGET_POINTER_WIDTH").unwrap_or_default(); let target_arch = env::var("CARGO_CFG_TARGET_ARCH").unwrap_or_default(); + let target_abi = env::var("CARGO_CFG_TARGET_ABI").unwrap_or_default(); // The ABI of libc used by std is backward compatible with FreeBSD 12. // The ABI of libc from crates.io is backward compatible with FreeBSD 12. @@ -115,8 +116,12 @@ fn main() { // OpenHarmony uses a fork of the musl libc let musl = target_env == "musl" || target_env == "ohos"; - // loongarch64, hexagon, and ohos only exist with recent musl - if target_arch == "loongarch64" || target_arch == "hexagon" || target_env == "ohos" { + // loongarch64, hexagon, ohos and pauthtest only exist with recent musl + if target_arch == "loongarch64" + || target_arch == "hexagon" + || target_env == "ohos" + || target_abi == "pauthtest" + { musl_v1_2_3 = true; } diff --git a/libc-test/build.rs b/libc-test/build.rs index 6879015d217fb..585782e78e188 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -3679,7 +3679,7 @@ fn test_linux(target: &str) { // target_env let gnu = target.contains("gnu"); - let musl = target.contains("musl") || target.contains("ohos"); + let musl = target.contains("musl") || target.contains("ohos") || target.contains("pauthtest"); let uclibc = target.contains("uclibc"); match (l4re, gnu, musl, uclibc) { @@ -3716,8 +3716,10 @@ fn test_linux(target: &str) { let mips = target.contains("mips"); let mips64 = target.contains("mips64"); let mips32 = mips && !mips64; + let pauthtest = target.contains("pauthtest"); - let musl_v1_2_3 = env::var("RUST_LIBC_UNSTABLE_MUSL_V1_2_3").is_ok(); + // Force modern musl for pauthtest. + let musl_v1_2_3 = env::var("RUST_LIBC_UNSTABLE_MUSL_V1_2_3").is_ok() || pauthtest; if musl_v1_2_3 { assert!(musl); } @@ -4884,7 +4886,7 @@ fn test_linux(target: &str) { // are included (e.g. because including both sets of headers clashes) fn test_linux_like_apis(target: &str) { let gnu = target.contains("gnu"); - let musl = target.contains("musl") || target.contains("ohos"); + let musl = target.contains("musl") || target.contains("ohos") || target.contains("pauthtest"); let linux = target.contains("linux"); let wali = target.contains("linux") && target.contains("wasm32"); let emscripten = target.contains("emscripten"); diff --git a/src/unix/mod.rs b/src/unix/mod.rs index ef83c7c9a5532..d035c621ee204 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -514,7 +514,17 @@ cfg_if! { #[link(name = "dl", cfg(not(target_feature = "crt-static")))] #[link(name = "c", cfg(not(target_feature = "crt-static")))] extern "C" {} - } else if #[cfg(any(target_env = "musl", target_env = "ohos"))] { + } else if #[cfg(target_abi = "pauthtest")] { + #[link(name = "c")] + #[link(name = "m")] + #[link(name = "rt")] + #[link(name = "pthread")] + #[link(name = "dl")] + extern "C" {} + } else if #[cfg(any( + all(target_env = "musl", not(target_abi = "pauthtest")), + target_env = "ohos" + ))] { #[cfg_attr( feature = "rustc-dep-of-std", link(