Skip to content

Commit

Permalink
Force use of portable blst in Rust bindings (#338)
Browse files Browse the repository at this point in the history
  • Loading branch information
jtraglia authored Aug 11, 2023
1 parent 74069da commit d874c06
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 34 deletions.
12 changes: 1 addition & 11 deletions bindings/rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,10 @@ license = "Apache-2.0"

[features]

# BLST Compilation:
# By default, compile with ADX extension if the host supports it. Binary can be
# executed on systems similar to the host.
default = ["mainnet-spec"]
mainnet-spec = []
minimal-spec = []
# BLST Compilation:
# Compile in portable mode, without ISA extensions.
# Binary can be executed on all systems.
portable = []
# BLST Compilation:
# Enable ADX even if the host CPU doesn't support it.
# Binary can be executed on Broadwell+ and Ryzen+ systems.
force-adx = []

# BLST Compilation:
# Suppress multi-threading.
# Engaged on wasm32 target architecture automatically.
Expand Down
24 changes: 1 addition & 23 deletions bindings/rust/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,29 +58,7 @@ fn compile_blst(blst_base_dir: PathBuf) {
} else {
cc.define("__BLST_NO_ASM__", None);
}
match (cfg!(feature = "portable"), cfg!(feature = "force-adx")) {
(true, false) => {
println!("Compiling in portable mode without ISA extensions");
cc.define("__BLST_PORTABLE__", None);
}
(false, true) => {
if target_arch.eq("x86_64") {
println!("Enabling ADX support via `force-adx` feature");
cc.define("__ADX__", None);
} else {
println!("`force-adx` is ignored for non-x86_64 targets");
}
}
(false, false) =>
{
#[cfg(target_arch = "x86_64")]
if target_arch.eq("x86_64") && std::is_x86_feature_detected!("adx") {
println!("Enabling ADX because it was detected on the host");
cc.define("__ADX__", None);
}
}
(true, true) => panic!("Cannot compile with both `portable` and `force-adx` features"),
}
cc.define("__BLST_PORTABLE__", None);
if env::var("CARGO_CFG_TARGET_ENV").unwrap().eq("msvc") {
cc.flag("-Zl");
}
Expand Down

0 comments on commit d874c06

Please sign in to comment.