Skip to content

Commit 602bf35

Browse files
committed
Fix: Disable simd for emscripten target
1 parent 859254b commit 602bf35

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

Cargo.toml

+1-2
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,4 @@ crate-type = ["staticlib", "cdylib", "rlib"]
1313
[build-dependencies]
1414
anyhow = "1.0.75"
1515
cmake = "0.1.50"
16-
17-
[features]
16+
tap = "1.0.1"

build.rs

+16-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
use anyhow::Result;
22
use cmake::Config;
33
use std::{env, path::PathBuf};
4+
use tap::prelude::*;
45

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

78
pub fn main() -> Result<()> {
9+
let os = std::env::var("CARGO_CFG_TARGET_OS").expect("CARGO_CFG_TARGET_OS not set");
10+
11+
if os == "emscripten" {
12+
println!("cargo:rustc-link-arg=--no-entry");
13+
}
814
let vendor = PathBuf::from(MANIFEST_DIR).join("vendor");
915
anyhow::ensure!(
1016
vendor.exists(),
@@ -13,6 +19,13 @@ pub fn main() -> Result<()> {
1319
let dst = Config::new(vendor)
1420
// OFF
1521
.define("WITH_JAVA", "OFF")
22+
.pipe(|x| {
23+
if os == "emscripten" {
24+
x.define("WITH_SIMD", "OFF")
25+
} else {
26+
x
27+
}
28+
})
1629
.define("ENABLE_SHARED", "OFF")
1730
.define("WITH_TURBOJPEG", "OFF")
1831
// ON
@@ -21,7 +34,9 @@ pub fn main() -> Result<()> {
2134
// .build_arg(format!("-j{}", std::thread::available_parallelism()?.get()))
2235
.build();
2336

24-
let lib_folder = if cfg!(target_os = "linux") {
37+
let lib_folder = if cfg!(target_os = "linux")
38+
&& std::env::var("CARGO_CFG_TARGET_POINTER_WIDTH").expect("CARGO_CFG_TARGET_FAMILY") == "64"
39+
{
2540
"lib64"
2641
} else {
2742
"lib"

0 commit comments

Comments
 (0)