Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ fn setup_build(build: &mut cc::Build, include_dir: &PathBuf) {
}

let target_arch = env::var("CARGO_CFG_TARGET_ARCH").expect("CARGO_CFG_TARGET_ARCH");
let target_os = env::var("CARGO_CFG_TARGET_OS").unwrap_or_default();
let target_features = env::var("CARGO_CFG_TARGET_FEATURE").unwrap_or_default();
let has_feature = |f: &str| target_features.split(',').any(|feature| feature == f);

Expand Down Expand Up @@ -152,6 +153,14 @@ fn setup_build(build: &mut cc::Build, include_dir: &PathBuf) {
build.debug(false);
}
}
// Emscripten lowers the SSE intrinsics to wasm simd128; cpu.h derives
// WEBP_HAVE_SSE2/SSE41 from the compiler's __SSE2__/__SSE4_1__.
"wasm32" if target_os == "emscripten" && has_feature("simd128") => {
build.flag("-msimd128").flag("-msse2");
if cfg!(feature = "sse41") {
build.flag("-msse4.1");
}
}
_ => {}
};
}