From 92f87dca4987555fe8a87504dea68b37a29d62b9 Mon Sep 17 00:00:00 2001 From: Alexandre Bury Date: Fri, 13 Oct 2023 09:49:58 -0400 Subject: [PATCH] Add no_wasm_shim feature --- zstd-safe/zstd-sys/Cargo.toml | 5 +++-- zstd-safe/zstd-sys/build.rs | 7 ++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/zstd-safe/zstd-sys/Cargo.toml b/zstd-safe/zstd-sys/Cargo.toml index 60ea4c2d..56047453 100644 --- a/zstd-safe/zstd-sys/Cargo.toml +++ b/zstd-safe/zstd-sys/Cargo.toml @@ -69,12 +69,13 @@ debug = [] # Enable zstd debug logs experimental = [] # Expose experimental ZSTD API legacy = [] # Enable legacy ZSTD support (for versions < zstd-0.8) non-cargo = [] # Silence cargo-specific build flags -pkg-config = [] +pkg-config = [] # Use pkg-config to build the zstd C library. std = [] # Deprecated: we never use types from std. zstdmt = [] # Enable multi-thread support (with pthread) thin = [] # Optimize binary by size no_asm = [] # Disable ASM files (only on amd64 for decompression) -zdict_builder = [] +zdict_builder = [] # Enable dictionary building (dictionary _using_ is always supported). +no_wasm_shim = [] # Disable wasm shims (in case your wasm toolchain includes a C stdlib). # These two are for cross-language LTO. # Will only work if `clang` is used to build the C library. diff --git a/zstd-safe/zstd-sys/build.rs b/zstd-safe/zstd-sys/build.rs index 65303b16..c7b52f51 100644 --- a/zstd-safe/zstd-sys/build.rs +++ b/zstd-safe/zstd-sys/build.rs @@ -133,9 +133,10 @@ fn compile_zstd() { // Note that Emscripten already provides its own C standard library so // wasm32-unknown-emscripten should not be included here. // See: https://github.com/gyscos/zstd-rs/pull/209 - let need_wasm_shim = env::var("TARGET").map_or(false, |target| { - target == "wasm32-unknown-unknown" || target == "wasm32-wasi" - }); + let need_wasm_shim = !cfg!(feature = "no_wasm_shim") + && env::var("TARGET").map_or(false, |target| { + target == "wasm32-unknown-unknown" || target == "wasm32-wasi" + }); if need_wasm_shim { cargo_print(&"rerun-if-changed=wasm-shim/stdlib.h");