From 179bf0e58d4b6f0e710f3a5a46678f4a40efc488 Mon Sep 17 00:00:00 2001 From: ec2 Date: Fri, 21 Apr 2023 09:09:47 -0400 Subject: [PATCH] actual no_std support for baremetal --- bindings/rust/Cargo.toml | 4 ++-- bindings/rust/build.rs | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/bindings/rust/Cargo.toml b/bindings/rust/Cargo.toml index 09b60330..b6dc711d 100644 --- a/bindings/rust/Cargo.toml +++ b/bindings/rust/Cargo.toml @@ -28,7 +28,7 @@ links = "blst" # Binary can be executed on systems similar to the host. default = ["std"] # When compiled without this feature library is `no_std` compatible -std = [] +std = ["dep:threadpool"] # Compile in portable mode, without ISA extensions. # Binary can be executed on all systems. portable = [] @@ -48,7 +48,7 @@ glob = "0.3" zeroize = { version = "^1.1", features = ["zeroize_derive"] } [target.'cfg(not(target_arch = "wasm32"))'.dependencies] -threadpool = "^1.8.1" +threadpool = { version = "^1.8.1", optional = true } [dev-dependencies] rand = "0.7" diff --git a/bindings/rust/build.rs b/bindings/rust/build.rs index 987ab70f..98e448d1 100644 --- a/bindings/rust/build.rs +++ b/bindings/rust/build.rs @@ -28,6 +28,7 @@ fn assembly(file_vec: &mut Vec, base_dir: &Path, _arch: &String) { fn main() { // account for cross-compilation [by examining environment variable] let target_arch = env::var("CARGO_CFG_TARGET_ARCH").unwrap(); + let target_os = env::var("CARGO_CFG_TARGET_OS").unwrap(); if target_arch.eq("wasm32") { println!("cargo:rustc-cfg=feature=\"no-threads\""); @@ -131,7 +132,7 @@ fn main() { .flag_if_supported("-fno-builtin") .flag_if_supported("-Wno-unused-function") .flag_if_supported("-Wno-unused-command-line-argument"); - if target_arch.eq("wasm32") { + if target_arch.eq("wasm32") || target_os.eq("none") { cc.flag_if_supported("-ffreestanding"); } if !cfg!(debug_assertions) {