Skip to content

Commit 1036dda

Browse files
committed
Define libc_pauthtest to be used in cfg expressions
As the `target_abi` is an experimental feature and can not be used in `cfg`.
1 parent d3b9f75 commit 1036dda

2 files changed

Lines changed: 10 additions & 3 deletions

File tree

build.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ const ALLOWED_CFGS: &[&str] = &[
3535
// Corresponds to `_REDIR_TIME64` in musl: symbol redirects to __*_time64
3636
"musl_redir_time64",
3737
"vxworks_lt_25_09",
38+
"libc_pauthtest",
3839
];
3940

4041
// Extra values to allow for check-cfg.
@@ -53,7 +54,6 @@ const CHECK_CFG_EXTRA: &[(&str, &[&str])] = &[
5354
"target_arch",
5455
&["loongarch64", "mips32r6", "mips64r6", "csky"],
5556
),
56-
("target_abi", &["pauthtest"]),
5757
];
5858

5959
/// Musl architectures that define `_REDIR_TIME64` (i.e. those that transitioned
@@ -72,6 +72,13 @@ fn main() {
7272
let target_arch = env::var("CARGO_CFG_TARGET_ARCH").unwrap_or_default();
7373
let target_abi = env::var("CARGO_CFG_TARGET_ABI").unwrap_or_default();
7474

75+
// FIXME(msrv): Once the MSRV is 1.78, use `cfg(target_abi = "pauthtest")`
76+
// directly instead of translating it to `libc_pauthtest`. `target_abi`
77+
// cannot be used directly in cfg expressions on the current MSRV.
78+
if target_abi == "pauthtest" {
79+
println!("cargo:rustc-cfg=libc_pauthtest");
80+
}
81+
7582
// FIXME: this can be removed in 1-2 releases
7683
println!("cargo:rerun-if-env-changed=RUST_LIBC_UNSTABLE_FREEBSD_VERSION");
7784
if env::var("RUST_LIBC_UNSTABLE_FREEBSD_VERSION").is_ok() {

src/unix/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -519,15 +519,15 @@ cfg_if! {
519519
#[link(name = "dl", cfg(not(target_feature = "crt-static")))]
520520
#[link(name = "c", cfg(not(target_feature = "crt-static")))]
521521
extern "C" {}
522-
} else if #[cfg(target_abi = "pauthtest")] {
522+
} else if #[cfg(libc_pauthtest)] {
523523
#[link(name = "c")]
524524
#[link(name = "m")]
525525
#[link(name = "rt")]
526526
#[link(name = "pthread")]
527527
#[link(name = "dl")]
528528
extern "C" {}
529529
} else if #[cfg(any(
530-
all(target_env = "musl", not(target_abi = "pauthtest")),
530+
all(target_env = "musl", not(libc_pauthtest)),
531531
target_env = "ohos"
532532
))] {
533533
#[cfg_attr(

0 commit comments

Comments
 (0)