diff options
| author | Jack O'Connor <[email protected]> | 2025-03-09 11:29:04 -0700 |
|---|---|---|
| committer | Jack O'Connor <[email protected]> | 2025-03-11 13:03:59 -0700 |
| commit | 97ce1c8c47940357f82b6dfa56cdd55d5f8ec1d4 (patch) | |
| tree | 2ddbc2f37bf8933a8b79a6a8518ac34df61d0151 /c/blake3_c_rust_bindings/build.rs | |
| parent | d9b49df0757f8bdfaa542e7181013fbf1555ff89 (diff) | |
tbb support in blake3_c_rust_bindingsrust_bindings_tbb
Diffstat (limited to 'c/blake3_c_rust_bindings/build.rs')
| -rw-r--r-- | c/blake3_c_rust_bindings/build.rs | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/c/blake3_c_rust_bindings/build.rs b/c/blake3_c_rust_bindings/build.rs index c5dc927..e176dac 100644 --- a/c/blake3_c_rust_bindings/build.rs +++ b/c/blake3_c_rust_bindings/build.rs @@ -52,6 +52,21 @@ fn new_build() -> cc::Build { build } +fn new_cpp_build() -> cc::Build { + let mut build = cc::Build::new(); + build.cpp(true); + if is_windows_msvc() { + build.flag("/std:c++20"); + build.flag("/EHs-c-"); + build.flag("/GR-"); + } else { + build.flag("-std=c++20"); + build.flag("-fno-exceptions"); + build.flag("-fno-rtti"); + } + build +} + fn c_dir_path(filename: &str) -> String { // The `cross` tool doesn't support reading files in parent directories. As a hacky workaround // in `cross_test.sh`, we move the c/ directory around and set BLAKE3_C_DIR_OVERRIDE. Regular @@ -68,8 +83,19 @@ fn main() -> Result<(), Box<dyn std::error::Error>> { base_build.file(c_dir_path("blake3.c")); base_build.file(c_dir_path("blake3_dispatch.c")); base_build.file(c_dir_path("blake3_portable.c")); + if cfg!(feature = "tbb") { + base_build.define("BLAKE3_USE_TBB", "1"); + } base_build.compile("blake3_base"); + if cfg!(feature = "tbb") { + let mut tbb_build = new_cpp_build(); + tbb_build.define("BLAKE3_USE_TBB", "1"); + tbb_build.file(c_dir_path("blake3_tbb.cpp")); + tbb_build.compile("blake3_tbb"); + println!("cargo::rustc-link-lib=tbb"); + } + if is_x86_64() && !defined("CARGO_FEATURE_PREFER_INTRINSICS") { // On 64-bit, use the assembly implementations, unless the // "prefer_intrinsics" feature is enabled. |
