summaryrefslogtreecommitdiffstats
path: root/vendor/libc/build.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 18:31:44 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 18:31:44 +0000
commitc23a457e72abe608715ac76f076f47dc42af07a5 (patch)
tree2772049aaf84b5c9d0ed12ec8d86812f7a7904b6 /vendor/libc/build.rs
parentReleasing progress-linux version 1.73.0+dfsg1-1~progress7.99u1. (diff)
downloadrustc-c23a457e72abe608715ac76f076f47dc42af07a5.tar.xz
rustc-c23a457e72abe608715ac76f076f47dc42af07a5.zip
Merging upstream version 1.74.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/libc/build.rs')
-rw-r--r--vendor/libc/build.rs39
1 files changed, 38 insertions, 1 deletions
diff --git a/vendor/libc/build.rs b/vendor/libc/build.rs
index 79bec0ea4..787b8b86a 100644
--- a/vendor/libc/build.rs
+++ b/vendor/libc/build.rs
@@ -7,6 +7,7 @@ use std::string::String;
// need to know all the possible cfgs that this script will set. If you need to set another cfg
// make sure to add it to this list as well.
const ALLOWED_CFGS: &'static [&'static str] = &[
+ "emscripten_new_stat_abi",
"freebsd10",
"freebsd11",
"freebsd12",
@@ -34,7 +35,10 @@ const ALLOWED_CFGS: &'static [&'static str] = &[
const CHECK_CFG_EXTRA: &'static [(&'static str, &'static [&'static str])] = &[
("target_os", &["switch", "aix", "ohos"]),
("target_env", &["illumos", "wasi", "aix", "ohos"]),
- ("target_arch", &["loongarch64"]),
+ (
+ "target_arch",
+ &["loongarch64", "mips32r6", "mips64r6", "csky"],
+ ),
];
fn main() {
@@ -69,6 +73,12 @@ fn main() {
Some(_) | None => set_cfg("freebsd11"),
}
+ match emcc_version_code() {
+ Some(v) if (v >= 30142) => set_cfg("emscripten_new_stat_abi"),
+ // Non-Emscripten or version < 3.1.42.
+ Some(_) | None => (),
+ }
+
// On CI: deny all warnings
if libc_ci {
set_cfg("libc_deny_warnings");
@@ -238,6 +248,33 @@ fn which_freebsd() -> Option<i32> {
}
}
+fn emcc_version_code() -> Option<u64> {
+ let output = std::process::Command::new("emcc")
+ .arg("-dumpversion")
+ .output()
+ .ok();
+ if output.is_none() {
+ return None;
+ }
+ let output = output.unwrap();
+ if !output.status.success() {
+ return None;
+ }
+
+ let stdout = String::from_utf8(output.stdout).ok();
+ if stdout.is_none() {
+ return None;
+ }
+ let version = stdout.unwrap();
+ let mut pieces = version.trim().split('.');
+
+ let major = pieces.next().and_then(|x| x.parse().ok()).unwrap_or(0);
+ let minor = pieces.next().and_then(|x| x.parse().ok()).unwrap_or(0);
+ let patch = pieces.next().and_then(|x| x.parse().ok()).unwrap_or(0);
+
+ Some(major * 10000 + minor * 100 + patch)
+}
+
fn set_cfg(cfg: &str) {
if !ALLOWED_CFGS.contains(&cfg) {
panic!("trying to set cfg {}, but it is not in ALLOWED_CFGS", cfg);