Skip to content

Commit

Permalink
Fix: Disable simd for emscripten target
Browse files Browse the repository at this point in the history
  • Loading branch information
spector-9 committed Aug 6, 2024
1 parent 859254b commit 602bf35
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,4 @@ crate-type = ["staticlib", "cdylib", "rlib"]
[build-dependencies]
anyhow = "1.0.75"
cmake = "0.1.50"

[features]
tap = "1.0.1"
17 changes: 16 additions & 1 deletion build.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
use anyhow::Result;
use cmake::Config;
use std::{env, path::PathBuf};
use tap::prelude::*;

const MANIFEST_DIR: &str = env!("CARGO_MANIFEST_DIR");

pub fn main() -> Result<()> {
let os = std::env::var("CARGO_CFG_TARGET_OS").expect("CARGO_CFG_TARGET_OS not set");

if os == "emscripten" {
println!("cargo:rustc-link-arg=--no-entry");
}
let vendor = PathBuf::from(MANIFEST_DIR).join("vendor");
anyhow::ensure!(
vendor.exists(),
Expand All @@ -13,6 +19,13 @@ pub fn main() -> Result<()> {
let dst = Config::new(vendor)
// OFF
.define("WITH_JAVA", "OFF")
.pipe(|x| {
if os == "emscripten" {
x.define("WITH_SIMD", "OFF")
} else {
x
}
})
.define("ENABLE_SHARED", "OFF")
.define("WITH_TURBOJPEG", "OFF")
// ON
Expand All @@ -21,7 +34,9 @@ pub fn main() -> Result<()> {
// .build_arg(format!("-j{}", std::thread::available_parallelism()?.get()))
.build();

let lib_folder = if cfg!(target_os = "linux") {
let lib_folder = if cfg!(target_os = "linux")
&& std::env::var("CARGO_CFG_TARGET_POINTER_WIDTH").expect("CARGO_CFG_TARGET_FAMILY") == "64"
{
"lib64"
} else {
"lib"
Expand Down

0 comments on commit 602bf35

Please sign in to comment.