Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ const ALLOWED_CFGS: &[&str] = &[
// Corresponds to `_REDIR_TIME64` in musl: symbol redirects to __*_time64
"musl_redir_time64",
"vxworks_lt_25_09",
"libc_pauthtest",
];

// Extra values to allow for check-cfg.
Expand Down Expand Up @@ -69,6 +70,14 @@ 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();

// FIXME(msrv): Once the MSRV is 1.78, use `cfg(target_abi = "pauthtest")`
// directly instead of translating it to `libc_pauthtest`. `target_abi`
// cannot be used directly in cfg expressions on the current MSRV.
if target_abi == "pauthtest" {
println!("cargo:rustc-cfg=libc_pauthtest");
}

// FIXME: this can be removed in 1-2 releases
println!("cargo:rerun-if-env-changed=RUST_LIBC_UNSTABLE_FREEBSD_VERSION");
Expand Down Expand Up @@ -122,8 +131,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;
}

Expand Down
8 changes: 5 additions & 3 deletions libc-test/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3921,7 +3921,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) {
Expand Down Expand Up @@ -3960,10 +3960,12 @@ 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 versions = &*VERSIONS;
let kernel = versions.linux.unwrap();

let musl_v1_2_3 = env::var("CARGO_CFG_LIBC_UNSTABLE_MUSL_V1_2_3").is_ok();
// Force modern musl also for pauthtest.
let musl_v1_2_3 = env::var("CARGO_CFG_LIBC_UNSTABLE_MUSL_V1_2_3").is_ok() || pauthtest;
if musl_v1_2_3 {
assert!(musl);
}
Expand Down Expand Up @@ -5332,7 +5334,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");
Expand Down
12 changes: 11 additions & 1 deletion src/unix/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,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(libc_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(libc_pauthtest)),
target_env = "ohos"
))] {
#[cfg_attr(
feature = "rustc-dep-of-std",
link(
Expand Down