-
Notifications
You must be signed in to change notification settings - Fork 15
/
build.rs
46 lines (40 loc) · 1.35 KB
/
build.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
//! A simple build script that ensure that the correct cfg flags are set.
use std::env;
fn main() {
let target_arch = env::var("CARGO_CFG_TARGET_ARCH").unwrap();
let target = env::var("TARGET").unwrap();
let host = env::var("HOST").unwrap();
let disable_simd128 = match env::var("LIBCRUX_DISABLE_SIMD128") {
Ok(s) => s == "1" || s == "y" || s == "Y",
Err(_) => false,
};
let disable_simd256 = match env::var("LIBCRUX_DISABLE_SIMD256") {
Ok(s) => s == "1" || s == "y" || s == "Y",
Err(_) => false,
};
// We don't enable any features when cross compiling for now.
let cross = target != host;
if !cross
&& libcrux_platform::simd128_support()
&& target_arch != "x86"
&& !target_arch.contains("wasm")
&& !disable_simd128
{
println!("cargo:rustc-cfg=simd128");
}
if !cross
&& libcrux_platform::simd256_support()
&& target_arch != "x86"
&& !target_arch.contains("wasm")
&& !disable_simd256
{
println!("cargo:rustc-cfg=simd256");
}
if !cross && libcrux_platform::bmi2_adx_support() {
println!("cargo:rustc-cfg=bmi2");
println!("cargo:rustc-cfg=adx");
}
if !cross && libcrux_platform::aes_ni_support() && target_arch == "x86_64" {
println!("cargo:rustc-cfg=aes_ni");
}
}