Skip to content

Commit

Permalink
Inform Cargo about build flags
Browse files Browse the repository at this point in the history
  • Loading branch information
thomwiggers committed Oct 24, 2024
1 parent 9c7253d commit 95ffa1b
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions pqcrypto-classicmceliece/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ fn main() {
build_avx2!("mceliece8192128f");
}

println!("cargo::rustc-check-cfg=cfg(enable_x86_avx2)");
if target_arch == "x86_64" && avx2_enabled && !is_windows {
// Print enableing flag for AVX2 implementation
println!("cargo:rustc-cfg=enable_x86_avx2");
Expand Down
2 changes: 2 additions & 0 deletions pqcrypto-falcon/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,12 @@ fn main() {
build_aarch64!("falcon-padded-1024");
}

println!("cargo::rustc-check-cfg=cfg(enable_x86_avx2)");
if target_arch == "x86_64" && avx2_enabled {
// Print enableing flag for AVX2 implementation
println!("cargo:rustc-cfg=enable_x86_avx2");
}
println!("cargo::rustc-check-cfg=cfg(enable_aarch64_neon)");
if target_arch == "aarch64" && neon_enabled {
// Print enableing flag for AARCH64 implementation
println!("cargo:rustc-cfg=enable_aarch64_neon");
Expand Down
2 changes: 2 additions & 0 deletions pqcrypto-mldsa/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,12 @@ fn main() {
build_aarch64!("ml-dsa-87");
}

println!("cargo::rustc-check-cfg=cfg(enable_x86_avx2)");
if target_arch == "x86_64" && avx2_enabled && !is_windows {
// Print enableing flag for AVX2 implementation
println!("cargo:rustc-cfg=enable_x86_avx2");
}
println!("cargo::rustc-check-cfg=cfg(enable_aarch64_neon)");
if target_arch == "aarch64" && neon_enabled {
// Print enableing flag for AARCH64 implementation
println!("cargo:rustc-cfg=enable_aarch64_neon");
Expand Down
2 changes: 2 additions & 0 deletions pqcrypto-mlkem/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,12 @@ fn main() {
build_aarch64!("ml-kem-1024");
}

println!("cargo::rustc-check-cfg=cfg(enable_x86_avx2)");
if target_arch == "x86_64" && avx2_enabled && !is_windows && !is_macos {
// Print enableing flag for AVX2 implementation
println!("cargo:rustc-cfg=enable_x86_avx2");
}
println!("cargo::rustc-check-cfg=cfg(enable_aarch64_neon)");
if target_arch == "aarch64" && neon_enabled {
// Print enableing flag for AARCH64 implementation
println!("cargo:rustc-cfg=enable_aarch64_neon");
Expand Down
1 change: 1 addition & 0 deletions pqcrypto-sphincsplus/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ fn main() {
build_avx2!("sphincs-sha2-256s-simple");
}

println!("cargo::rustc-check-cfg=cfg(enable_x86_avx2)");
if target_arch == "x86_64" && avx2_enabled {
// Print enableing flag for AVX2 implementation
println!("cargo:rustc-cfg=enable_x86_avx2");
Expand Down
3 changes: 3 additions & 0 deletions pqcrypto-template/scheme/build.rs.j2
Original file line number Diff line number Diff line change
Expand Up @@ -111,18 +111,21 @@ fn main() {
{% endfor %}

{% if globals.x86_avx2 %}
println!("cargo::rustc-check-cfg=cfg(enable_x86_avx2)");
if {{ x86_avx2_guard }} {
// Print enableing flag for AVX2 implementation
println!("cargo:rustc-cfg=enable_x86_avx2");
}
{% endif %}
{% if globals.x86_aes %}
println!("cargo::rustc-check-cfg=cfg(enable_x86_aes)");
if {{ x86_aes_guard }} {
// Print enableing flag for AES implementation
println!("cargo:rustc-cfg=enable_x86_aes");
}
{% endif %}
{% if globals.aarch64_neon %}
println!("cargo::rustc-check-cfg=cfg(enable_aarch64_neon)");
if {{ aarch64_neon_guard }} {
// Print enableing flag for AARCH64 implementation
println!("cargo:rustc-cfg=enable_aarch64_neon");
Expand Down

0 comments on commit 95ffa1b

Please sign in to comment.