Skip to content
Open
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
9 changes: 7 additions & 2 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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;
}

Expand Down
8 changes: 5 additions & 3 deletions libc-test/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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");
Expand Down
12 changes: 11 additions & 1 deletion src/unix/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Loading