Skip to content

Commit

Permalink
Specify build flag that hopefully works
Browse files Browse the repository at this point in the history
  • Loading branch information
thomwiggers committed Nov 11, 2024
1 parent e11234a commit 7e6a110
Showing 1 changed file with 9 additions and 16 deletions.
25 changes: 9 additions & 16 deletions pqcrypto-internals/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,20 @@ fn main() {

let target_arch = env::var("CARGO_CFG_TARGET_ARCH").unwrap_or_default();
let target_env = env::var("CARGO_CFG_TARGET_ENV").unwrap_or_default();
if target_arch == "x86" || target_arch == "x86_64" {
let mut builder = cc::Build::new();
let mut builder = cc::Build::new();

if target_os == "wasi" {
let wasi_sdk_path =
&std::env::var("WASI_SDK_DIR").expect("missing environment variable: WASI_SDK_DIR");
builder.flag(format!("--sysroot={wasi_sdk_path}").as_str());
}
if target_os == "wasi" {
let wasi_sdk_path =
&std::env::var("WASI_SDK_DIR").expect("missing environment variable: WASI_SDK_DIR");
builder.flag(format!("--sysroot={wasi_sdk_path}").as_str());
}

if target_arch == "x86" || target_arch == "x86_64" {
if target_env == "msvc" {
builder.flag("/arch:AVX2");
} else {
builder.flag("-mavx2");
};
}
builder
.file(
cfiledir
Expand All @@ -57,15 +57,8 @@ fn main() {
.compile("keccak4x");
println!("cargo:rustc-link-lib=keccak4x")
} else if target_arch == "aarch64" && target_env != "msvc" {
let mut builder = cc::Build::new();

if target_os == "wasi" {
let wasi_sdk_path =
&std::env::var("WASI_SDK_DIR").expect("missing environment variable: WASI_SDK_DIR");
builder.flag(format!("--sysroot={wasi_sdk_path}").as_str());
}

builder
.flag("-march=armv8-a")
.file(cfiledir.join("keccak2x").join("fips202x2.c"))
.file(cfiledir.join("keccak2x").join("feat.S"))
.compile("keccak2x");
Expand Down

0 comments on commit 7e6a110

Please sign in to comment.