Debian Codegraph @

third_party/rust/serde_json/build.rs

raw
1 use std::env;
2
3 fn main() {
4 println!("cargo:rerun-if-changed=build.rs");
5
6 println!("cargo:rustc-check-cfg=cfg(fast_arithmetic, values(\"32\", \"64\"))");
7
8 // Decide ideal limb width for arithmetic in the float parser and string
9 // parser.
10 let target_arch = env::var_os("CARGO_CFG_TARGET_ARCH").unwrap();
11 let target_pointer_width = env::var_os("CARGO_CFG_TARGET_POINTER_WIDTH").unwrap();
12 if target_arch == "aarch64"
13 || target_arch == "loongarch64"
14 || target_arch == "mips64"
15 || target_arch == "powerpc64"
16 || target_arch == "wasm32"
17 || target_arch == "x86_64"
18 || target_pointer_width == "64"
19 {
20 // The above list of architectures are ones that have native support for
21 // 64-bit arithmetic, but which have some targets using a smaller
22 // pointer width. Examples include aarch64-unknown-linux-gnu_ilp32 and
23 // x86_64-unknown-linux-gnux32. So our choice of limb width is not
24 // equivalent to using usize everywhere.
25 println!("cargo:rustc-cfg=fast_arithmetic=\"64\"");
26 } else {
27 println!("cargo:rustc-cfg=fast_arithmetic=\"32\"");
28 }
29 }