Skip to content

Commit f63b1b1

Browse files
committed
add 'environ' variable
Add the environ variable to unix/mod.rs. add aarch64_macos_15_5_or_newer cfg
1 parent 76e737e commit f63b1b1

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

build.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ const ALLOWED_CFGS: &[&str] = &[
3131
// Corresponds to `_REDIR_TIME64` in musl
3232
"musl32_time64",
3333
"vxworks_lt_25_09",
34+
"aarch64_macos_15_5_or_newer",
3435
];
3536

3637
// Extra values to allow for check-cfg.
@@ -65,6 +66,20 @@ fn main() {
6566
let target_ptr_width = env::var("CARGO_CFG_TARGET_POINTER_WIDTH").unwrap_or_default();
6667
let target_arch = env::var("CARGO_CFG_TARGET_ARCH").unwrap_or_default();
6768

69+
println!("cargo:rerun-if-env-changed=MACOSX_DEPLOYMENT_TARGET");
70+
71+
if target_os == "macos" && target_arch == "aarch64" {
72+
if let Ok(deployment) = env::var("MACOSX_DEPLOYMENT_TARGET") {
73+
let mut it = deployment.split('.');
74+
let major = it.next().and_then(|x| x.parse::<u32>().ok()).unwrap_or(0);
75+
let minor = it.next().and_then(|x| x.parse::<u32>().ok()).unwrap_or(0);
76+
77+
if (major, minor) >= (15, 5) {
78+
set_cfg("aarch64_macos_15_5_or_newer");
79+
}
80+
}
81+
}
82+
6883
// The ABI of libc used by std is backward compatible with FreeBSD 12.
6984
// The ABI of libc from crates.io is backward compatible with FreeBSD 12.
7085
//

libc-test/semver/unix.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,7 @@ dlopen
505505
dlsym
506506
dup
507507
dup2
508+
environ
508509
execl
509510
execle
510511
execlp

src/unix/mod.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2429,3 +2429,8 @@ cfg_if! {
24292429
// Unknown target_os
24302430
}
24312431
}
2432+
2433+
extern "C" {
2434+
#[cfg(not(aarch64_macos_15_5_or_newer))]
2435+
pub static mut environ: *mut *mut crate::c_char;
2436+
}

0 commit comments

Comments
 (0)