Skip to content

Commit 8c6c1dd

Browse files
committed
Automatically calculate std::env::consts::ARCH.
This simplifies the definition for ARCH. Note that this changes asmjs-unknown-emscripten ARCH to `wasm32`, which reflects the actual target arch.
1 parent d9e8d62 commit 8c6c1dd

File tree

2 files changed

+2
-76
lines changed

2 files changed

+2
-76
lines changed

src/libstd/build.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,5 @@ fn main() {
6363
println!("cargo:rustc-link-lib=c");
6464
println!("cargo:rustc-link-lib=compiler_rt");
6565
}
66+
println!("cargo:rustc-env=STD_ENV_ARCH={}", env::var("CARGO_CFG_TARGET_ARCH").unwrap());
6667
}

src/libstd/env.rs

Lines changed: 1 addition & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -882,7 +882,7 @@ pub mod consts {
882882
/// - s390x
883883
/// - sparc64
884884
#[stable(feature = "env", since = "1.0.0")]
885-
pub const ARCH: &str = super::arch::ARCH;
885+
pub const ARCH: &str = env!("STD_ENV_ARCH");
886886

887887
/// The family of the operating system. Example value is `unix`.
888888
///
@@ -966,81 +966,6 @@ pub mod consts {
966966
pub const EXE_EXTENSION: &str = os::EXE_EXTENSION;
967967
}
968968

969-
#[cfg(target_arch = "x86")]
970-
mod arch {
971-
pub const ARCH: &str = "x86";
972-
}
973-
974-
#[cfg(target_arch = "x86_64")]
975-
mod arch {
976-
pub const ARCH: &str = "x86_64";
977-
}
978-
979-
#[cfg(target_arch = "arm")]
980-
mod arch {
981-
pub const ARCH: &str = "arm";
982-
}
983-
984-
#[cfg(target_arch = "aarch64")]
985-
mod arch {
986-
pub const ARCH: &str = "aarch64";
987-
}
988-
989-
#[cfg(target_arch = "mips")]
990-
mod arch {
991-
pub const ARCH: &str = "mips";
992-
}
993-
994-
#[cfg(target_arch = "mips64")]
995-
mod arch {
996-
pub const ARCH: &str = "mips64";
997-
}
998-
999-
#[cfg(target_arch = "powerpc")]
1000-
mod arch {
1001-
pub const ARCH: &str = "powerpc";
1002-
}
1003-
1004-
#[cfg(target_arch = "powerpc64")]
1005-
mod arch {
1006-
pub const ARCH: &str = "powerpc64";
1007-
}
1008-
1009-
#[cfg(target_arch = "s390x")]
1010-
mod arch {
1011-
pub const ARCH: &str = "s390x";
1012-
}
1013-
1014-
#[cfg(target_arch = "sparc64")]
1015-
mod arch {
1016-
pub const ARCH: &str = "sparc64";
1017-
}
1018-
1019-
#[cfg(target_arch = "le32")]
1020-
mod arch {
1021-
pub const ARCH: &str = "le32";
1022-
}
1023-
1024-
#[cfg(target_arch = "asmjs")]
1025-
mod arch {
1026-
pub const ARCH: &str = "asmjs";
1027-
}
1028-
1029-
#[cfg(target_arch = "wasm32")]
1030-
mod arch {
1031-
pub const ARCH: &str = "wasm32";
1032-
}
1033-
1034-
#[cfg(target_arch = "hexagon")]
1035-
mod arch {
1036-
pub const ARCH: &'static str = "hexagon";
1037-
}
1038-
1039-
#[cfg(target_arch = "riscv64")]
1040-
mod arch {
1041-
pub const ARCH: &'static str = "riscv64";
1042-
}
1043-
1044969
#[cfg(test)]
1045970
mod tests {
1046971
use super::*;

0 commit comments

Comments
 (0)