Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation for WASM? #93

Open
TheButlah opened this issue Aug 22, 2020 · 22 comments
Open

Documentation for WASM? #93

TheButlah opened this issue Aug 22, 2020 · 22 comments

Comments

@TheButlah
Copy link

TheButlah commented Aug 22, 2020

Hello, I tried using the wasm feature and targeted wasm32-unknown-unknown, but I get a bunch of errors, many of which include fatal error: 'stdlib.h' file not found, resulting in an error when building. What is the correct process to target wasm32-unknown-unknown?

@gyscos
Copy link
Owner

gyscos commented Nov 17, 2020

I think right now only wasm32-unknown-emscripten has a C standard library you can use, and the zstd C lib relies on it for allocation and other details.

EDIT: rustwasm/team#291

@Borber
Copy link

Borber commented Jan 21, 2022

Two years have passed, has there been any progress on this matter? I finally got it to work with wasm32-unknown-emscripten after a lot of trouble recently, but trunk doesn't support wasm32-unknown-emscripten

@quininer
Copy link
Contributor

quininer commented Feb 8, 2022

I have implemented this feature in PR #139 139. should we release a new version? @gyscos

@kylebarron
Copy link
Contributor

I tried to follow the steps listed in #139 (using current master) but it seemed to fail when building for wasm32-unknown-unknown. Am I doing something wrong?

git clone https://github.com/gyscos/zstd-rs --recursive
cd zstd-rs
git checkout 9334ec7
cd zstd-safe/zstd-sys/
cargo build --target wasm32-unknown-unknown --no-default-features --example it_work
> cargo build --target wasm32-unknown-unknown --no-default-features --example it_work
    Updating crates.io index
   Compiling libc v0.2.119
   Compiling jobserver v0.1.24
   Compiling cc v1.0.73
   Compiling zstd-sys v1.6.3+zstd.1.5.2 (/Users/kbarron/tmp/zstd-rs/zstd-safe/zstd-sys)
The following warnings were emitted during compilation:

warning: error: unable to create target: 'No available targets are compatible with triple "wasm32-unknown-unknown"'
warning: 1 error generated.
warning: error: unable to create target: 'No available targets are compatible with triple "wasm32-unknown-unknown"'
warning: 1 error generated.
warning: error: unable to create target: 'No available targets are compatible with triple "wasm32-unknown-unknown"'
warning: 1 error generated.
warning: error: unable to create target: 'No available targets are compatible with triple "wasm32-unknown-unknown"'
warning: 1 error generated.
warning: error: unable to create target: 'No available targets are compatible with triple "wasm32-unknown-unknown"'
warning: 1 error generated.
warning: error: unable to create target: 'No available targets are compatible with triple "wasm32-unknown-unknown"'
warning: 1 error generated.
warning: error: unable to create target: 'No available targets are compatible with triple "wasm32-unknown-unknown"'
warning: 1 error generated.
warning: error: unable to create target: 'No available targets are compatible with triple "wasm32-unknown-unknown"'
warning: 1 error generated.
warning: error: unable to create target: 'No available targets are compatible with triple "wasm32-unknown-unknown"'
warning: 1 error generated.

error: failed to run custom build command for `zstd-sys v1.6.3+zstd.1.5.2 (/Users/kbarron/tmp/zstd-rs/zstd-safe/zstd-sys)`

Caused by:
  process didn't exit successfully: `/Users/kbarron/tmp/zstd-rs/zstd-safe/zstd-sys/target/debug/build/zstd-sys-efe3514e9ecf8963/build-script-build` (exit status: 1)
  --- stdout
  cargo:rustc-cfg=feature="std"
  cargo:rerun-if-changed=wasm-shim/stdlib.h
  cargo:rerun-if-changed=wasm-shim/string.h
  TARGET = Some("wasm32-unknown-unknown")
  HOST = Some("x86_64-apple-darwin")
  CC_wasm32-unknown-unknown = None
  CC_wasm32_unknown_unknown = None
  TARGET_CC = None
  CC = None
  CFLAGS_wasm32-unknown-unknown = None
  CFLAGS_wasm32_unknown_unknown = None
  TARGET_CFLAGS = None
  CFLAGS = None
  CRATE_CC_NO_DEFAULTS = None
  DEBUG = Some("true")
  running: "clang" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "--target=wasm32-unknown-unknown" "-I" "wasm-shim/" "-I" "zstd/lib/" "-I" "zstd/lib/common" "-fvisibility=hidden" "-DXXH_STATIC_ASSERT=0" "-DZSTD_LIB_DEPRECATED=0" "-DXXH_PRIVATE_API=" "-DZSTDLIB_VISIBILITY=" "-DZSTDERRORLIB_VISIBILITY=" "-o" "/Users/kbarron/tmp/zstd-rs/zstd-safe/zstd-sys/target/wasm32-unknown-unknown/debug/build/zstd-sys-e544bdc3e2e20244/out/zstd/lib/compress/zstd_compress_superblock.o" "-c" "zstd/lib/compress/zstd_compress_superblock.c"
  running: "clang" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "--target=wasm32-unknown-unknown" "-I" "wasm-shim/" "-I" "zstd/lib/" "-I" "zstd/lib/common" "-fvisibility=hidden" "-DXXH_STATIC_ASSERT=0" "-DZSTD_LIB_DEPRECATED=0" "-DXXH_PRIVATE_API=" "-DZSTDLIB_VISIBILITY=" "-DZSTDERRORLIB_VISIBILITY=" "-o" "/Users/kbarron/tmp/zstd-rs/zstd-safe/zstd-sys/target/wasm32-unknown-unknown/debug/build/zstd-sys-e544bdc3e2e20244/out/zstd/lib/common/fse_decompress.o" "-c" "zstd/lib/common/fse_decompress.c"
  running: "clang" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "--target=wasm32-unknown-unknown" "-I" "wasm-shim/" "-I" "zstd/lib/" "-I" "zstd/lib/common" "-fvisibility=hidden" "-DXXH_STATIC_ASSERT=0" "-DZSTD_LIB_DEPRECATED=0" "-DXXH_PRIVATE_API=" "-DZSTDLIB_VISIBILITY=" "-DZSTDERRORLIB_VISIBILITY=" "-o" "/Users/kbarron/tmp/zstd-rs/zstd-safe/zstd-sys/target/wasm32-unknown-unknown/debug/build/zstd-sys-e544bdc3e2e20244/out/zstd/lib/common/error_private.o" "-c" "zstd/lib/common/error_private.c"
  running: "clang" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "--target=wasm32-unknown-unknown" "-I" "wasm-shim/" "-I" "zstd/lib/" "-I" "zstd/lib/common" "-fvisibility=hidden" "-DXXH_STATIC_ASSERT=0" "-DZSTD_LIB_DEPRECATED=0" "-DXXH_PRIVATE_API=" "-DZSTDLIB_VISIBILITY=" "-DZSTDERRORLIB_VISIBILITY=" "-o" "/Users/kbarron/tmp/zstd-rs/zstd-safe/zstd-sys/target/wasm32-unknown-unknown/debug/build/zstd-sys-e544bdc3e2e20244/out/zstd/lib/common/entropy_common.o" "-c" "zstd/lib/common/entropy_common.c"
  running: "clang" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "--target=wasm32-unknown-unknown" "-I" "wasm-shim/" "-I" "zstd/lib/" "-I" "zstd/lib/common" "-fvisibility=hidden" "-DXXH_STATIC_ASSERT=0" "-DZSTD_LIB_DEPRECATED=0" "-DXXH_PRIVATE_API=" "-DZSTDLIB_VISIBILITY=" "-DZSTDERRORLIB_VISIBILITY=" "-o" "/Users/kbarron/tmp/zstd-rs/zstd-safe/zstd-sys/target/wasm32-unknown-unknown/debug/build/zstd-sys-e544bdc3e2e20244/out/zstd/lib/common/debug.o" "-c" "zstd/lib/common/debug.c"
  running: "clang" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "--target=wasm32-unknown-unknown" "-I" "wasm-shim/" "-I" "zstd/lib/" "-I" "zstd/lib/common" "-fvisibility=hidden" "-DXXH_STATIC_ASSERT=0" "-DZSTD_LIB_DEPRECATED=0" "-DXXH_PRIVATE_API=" "-DZSTDLIB_VISIBILITY=" "-DZSTDERRORLIB_VISIBILITY=" "-o" "/Users/kbarron/tmp/zstd-rs/zstd-safe/zstd-sys/target/wasm32-unknown-unknown/debug/build/zstd-sys-e544bdc3e2e20244/out/zstd/lib/common/threading.o" "-c" "zstd/lib/common/threading.c"
  running: "clang" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "--target=wasm32-unknown-unknown" "-I" "wasm-shim/" "-I" "zstd/lib/" "-I" "zstd/lib/common" "-fvisibility=hidden" "-DXXH_STATIC_ASSERT=0" "-DZSTD_LIB_DEPRECATED=0" "-DXXH_PRIVATE_API=" "-DZSTDLIB_VISIBILITY=" "-DZSTDERRORLIB_VISIBILITY=" "-o" "/Users/kbarron/tmp/zstd-rs/zstd-safe/zstd-sys/target/wasm32-unknown-unknown/debug/build/zstd-sys-e544bdc3e2e20244/out/zstd/lib/common/zstd_common.o" "-c" "zstd/lib/common/zstd_common.c"
  running: "clang" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "--target=wasm32-unknown-unknown" "-I" "wasm-shim/" "-I" "zstd/lib/" "-I" "zstd/lib/common" "-fvisibility=hidden" "-DXXH_STATIC_ASSERT=0" "-DZSTD_LIB_DEPRECATED=0" "-DXXH_PRIVATE_API=" "-DZSTDLIB_VISIBILITY=" "-DZSTDERRORLIB_VISIBILITY=" "-o" "/Users/kbarron/tmp/zstd-rs/zstd-safe/zstd-sys/target/wasm32-unknown-unknown/debug/build/zstd-sys-e544bdc3e2e20244/out/zstd/lib/common/pool.o" "-c" "zstd/lib/common/pool.c"
  cargo:warning=error: unable to create target: 'No available targets are compatible with triple "wasm32-unknown-unknown"'
  cargo:warning=1 error generated.
  exit status: 1
  running: "clang" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "--target=wasm32-unknown-unknown" "-I" "wasm-shim/" "-I" "zstd/lib/" "-I" "zstd/lib/common" "-fvisibility=hidden" "-DXXH_STATIC_ASSERT=0" "-DZSTD_LIB_DEPRECATED=0" "-DXXH_PRIVATE_API=" "-DZSTDLIB_VISIBILITY=" "-DZSTDERRORLIB_VISIBILITY=" "-o" "/Users/kbarron/tmp/zstd-rs/zstd-safe/zstd-sys/target/wasm32-unknown-unknown/debug/build/zstd-sys-e544bdc3e2e20244/out/zstd/lib/compress/zstdmt_compress.o" "-c" "zstd/lib/compress/zstdmt_compress.c"
  cargo:warning=error: unable to create target: 'No available targets are compatible with triple "wasm32-unknown-unknown"'
  cargo:warning=1 error generated.
  exit status: 1
  cargo:warning=error: unable to create target: 'No available targets are compatible with triple "wasm32-unknown-unknown"'
  cargo:warning=1 error generated.
  exit status: 1
  cargo:warning=error: unable to create target: 'No available targets are compatible with triple "wasm32-unknown-unknown"'
  cargo:warning=1 error generated.
  exit status: 1
  cargo:warning=error: unable to create target: 'No available targets are compatible with triple "wasm32-unknown-unknown"'
  cargo:warning=1 error generated.
  cargo:warning=error: unable to create target: 'No available targets are compatible with triple "wasm32-unknown-unknown"'
  exit status: 1
  cargo:warning=1 error generated.
  exit status: 1
  cargo:warning=error: unable to create target: 'No available targets are compatible with triple "wasm32-unknown-unknown"'
  cargo:warning=1 error generated.
  exit status: 1
  cargo:warning=error: unable to create target: 'No available targets are compatible with triple "wasm32-unknown-unknown"'
  cargo:warning=1 error generated.
  exit status: 1
  cargo:warning=error: unable to create target: 'No available targets are compatible with triple "wasm32-unknown-unknown"'
  cargo:warning=1 error generated.
  exit status: 1

  --- stderr


  error occurred: Command "clang" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "--target=wasm32-unknown-unknown" "-I" "wasm-shim/" "-I" "zstd/lib/" "-I" "zstd/lib/common" "-fvisibility=hidden" "-DXXH_STATIC_ASSERT=0" "-DZSTD_LIB_DEPRECATED=0" "-DXXH_PRIVATE_API=" "-DZSTDLIB_VISIBILITY=" "-DZSTDERRORLIB_VISIBILITY=" "-o" "/Users/kbarron/tmp/zstd-rs/zstd-safe/zstd-sys/target/wasm32-unknown-unknown/debug/build/zstd-sys-e544bdc3e2e20244/out/zstd/lib/common/entropy_common.o" "-c" "zstd/lib/common/entropy_common.c" with args "clang" did not execute successfully (status code exit status: 1).

@gyscos
Copy link
Owner

gyscos commented Mar 3, 2022

Do you have that target installed? rustup target add wasm32-unknown-unknown

@kylebarron
Copy link
Contributor

Yes: info: component 'rust-std' for target 'wasm32-unknown-unknown' is up to date.

Running this block still fails for me with the same errors as above:

git clone https://github.com/gyscos/zstd-rs --recursive
cd zstd-rs
git checkout 9334ec7
cd zstd-safe/zstd-sys/
rustup target add wasm32-unknown-unknown
cargo build --target wasm32-unknown-unknown --no-default-features --example it_work

@gyscos
Copy link
Owner

gyscos commented Mar 3, 2022

And you do have clang installed as well?

What if you add -vv to the cargo build command?

EDIT: looks like it relies on clang-8 at least: rust-lang/cc-rs#378

What is your clang version?

@kylebarron
Copy link
Contributor

> clang --version
Apple clang version 13.0.0 (clang-1300.0.29.30)
Target: x86_64-apple-darwin20.6.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
> cargo build -vv --target wasm32-unknown-unknown --no-default-features --example it_work
    Updating crates.io index
   Compiling libc v0.2.119
     Running `CARGO=/Users/kbarron/.rustup/toolchains/stable-x86_64-apple-darwin/bin/cargo CARGO_CRATE_NAME=build_script_build CARGO_MANIFEST_DIR=/Users/kbarron/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/libc-0.2.119 CARGO_PKG_AUTHORS='The Rust Project Developers' CARGO_PKG_DESCRIPTION='Raw FFI bindings to platform libraries like libc.
' CARGO_PKG_HOMEPAGE='https://github.com/rust-lang/libc' CARGO_PKG_LICENSE='MIT OR Apache-2.0' CARGO_PKG_LICENSE_FILE='' CARGO_PKG_NAME=libc CARGO_PKG_REPOSITORY='https://github.com/rust-lang/libc' CARGO_PKG_VERSION=0.2.119 CARGO_PKG_VERSION_MAJOR=0 CARGO_PKG_VERSION_MINOR=2 CARGO_PKG_VERSION_PATCH=119 CARGO_PKG_VERSION_PRE='' DYLD_FALLBACK_LIBRARY_PATH='/Users/kbarron/tmp/zstd-rs/zstd-safe/zstd-sys/target/debug/deps:/Users/kbarron/.rustup/toolchains/stable-x86_64-apple-darwin/lib:/Users/kbarron/.rustup/toolchains/stable-x86_64-apple-darwin/lib:/Users/kbarron/lib:/usr/local/lib:/usr/lib' rustc --crate-name build_script_build /Users/kbarron/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/libc-0.2.119/build.rs --error-format=json --json=diagnostic-rendered-ansi,future-incompat --crate-type bin --emit=dep-info,link -C embed-bitcode=no -C split-debuginfo=unpacked -C debuginfo=2 --cfg 'feature="default"' --cfg 'feature="std"' -C metadata=bfae9d9521abc245 -C extra-filename=-bfae9d9521abc245 --out-dir /Users/kbarron/tmp/zstd-rs/zstd-safe/zstd-sys/target/debug/build/libc-bfae9d9521abc245 -L dependency=/Users/kbarron/tmp/zstd-rs/zstd-safe/zstd-sys/target/debug/deps --cap-lints warn`
     Running `/Users/kbarron/tmp/zstd-rs/zstd-safe/zstd-sys/target/debug/build/libc-bfae9d9521abc245/build-script-build`
     Running `/Users/kbarron/tmp/zstd-rs/zstd-safe/zstd-sys/target/debug/build/libc-bfae9d9521abc245/build-script-build`
[libc 0.2.119] cargo:rerun-if-changed=build.rs
[libc 0.2.119] cargo:rerun-if-changed=build.rs
[libc 0.2.119] cargo:rustc-cfg=freebsd11
[libc 0.2.119] cargo:rustc-cfg=libc_priv_mod_use
[libc 0.2.119] cargo:rustc-cfg=libc_union
[libc 0.2.119] cargo:rustc-cfg=libc_const_size_of
[libc 0.2.119] cargo:rustc-cfg=libc_align
[libc 0.2.119] cargo:rustc-cfg=libc_core_cvoid
[libc 0.2.119] cargo:rustc-cfg=libc_packedN
[libc 0.2.119] cargo:rustc-cfg=libc_cfg_target_vendor
[libc 0.2.119] cargo:rustc-cfg=libc_non_exhaustive
[libc 0.2.119] cargo:rustc-cfg=libc_ptr_addr_of
[libc 0.2.119] cargo:rustc-cfg=freebsd11
[libc 0.2.119] cargo:rustc-cfg=libc_priv_mod_use
[libc 0.2.119] cargo:rustc-cfg=libc_union
[libc 0.2.119] cargo:rustc-cfg=libc_const_size_of
[libc 0.2.119] cargo:rustc-cfg=libc_align
[libc 0.2.119] cargo:rustc-cfg=libc_core_cvoid
[libc 0.2.119] cargo:rustc-cfg=libc_packedN
[libc 0.2.119] cargo:rustc-cfg=libc_cfg_target_vendor
[libc 0.2.119] cargo:rustc-cfg=libc_non_exhaustive
[libc 0.2.119] cargo:rustc-cfg=libc_ptr_addr_of
     Running `CARGO=/Users/kbarron/.rustup/toolchains/stable-x86_64-apple-darwin/bin/cargo CARGO_CRATE_NAME=libc CARGO_MANIFEST_DIR=/Users/kbarron/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/libc-0.2.119 CARGO_PKG_AUTHORS='The Rust Project Developers' CARGO_PKG_DESCRIPTION='Raw FFI bindings to platform libraries like libc.
' CARGO_PKG_HOMEPAGE='https://github.com/rust-lang/libc' CARGO_PKG_LICENSE='MIT OR Apache-2.0' CARGO_PKG_LICENSE_FILE='' CARGO_PKG_NAME=libc CARGO_PKG_REPOSITORY='https://github.com/rust-lang/libc' CARGO_PKG_VERSION=0.2.119 CARGO_PKG_VERSION_MAJOR=0 CARGO_PKG_VERSION_MINOR=2 CARGO_PKG_VERSION_PATCH=119 CARGO_PKG_VERSION_PRE='' DYLD_FALLBACK_LIBRARY_PATH='/Users/kbarron/tmp/zstd-rs/zstd-safe/zstd-sys/target/debug/deps:/Users/kbarron/.rustup/toolchains/stable-x86_64-apple-darwin/lib:/Users/kbarron/.rustup/toolchains/stable-x86_64-apple-darwin/lib:/Users/kbarron/lib:/usr/local/lib:/usr/lib' OUT_DIR=/Users/kbarron/tmp/zstd-rs/zstd-safe/zstd-sys/target/debug/build/libc-938ed99d378697e1/out rustc --crate-name libc /Users/kbarron/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/libc-0.2.119/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type lib --emit=dep-info,metadata,link -C embed-bitcode=no -C split-debuginfo=unpacked -C debuginfo=2 --cfg 'feature="default"' --cfg 'feature="std"' -C metadata=d132da372e291c03 -C extra-filename=-d132da372e291c03 --out-dir /Users/kbarron/tmp/zstd-rs/zstd-safe/zstd-sys/target/debug/deps -L dependency=/Users/kbarron/tmp/zstd-rs/zstd-safe/zstd-sys/target/debug/deps --cap-lints warn --cfg freebsd11 --cfg libc_priv_mod_use --cfg libc_union --cfg libc_const_size_of --cfg libc_align --cfg libc_core_cvoid --cfg libc_packedN --cfg libc_cfg_target_vendor --cfg libc_non_exhaustive --cfg libc_ptr_addr_of`
     Running `CARGO=/Users/kbarron/.rustup/toolchains/stable-x86_64-apple-darwin/bin/cargo CARGO_CRATE_NAME=libc CARGO_MANIFEST_DIR=/Users/kbarron/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/libc-0.2.119 CARGO_PKG_AUTHORS='The Rust Project Developers' CARGO_PKG_DESCRIPTION='Raw FFI bindings to platform libraries like libc.
' CARGO_PKG_HOMEPAGE='https://github.com/rust-lang/libc' CARGO_PKG_LICENSE='MIT OR Apache-2.0' CARGO_PKG_LICENSE_FILE='' CARGO_PKG_NAME=libc CARGO_PKG_REPOSITORY='https://github.com/rust-lang/libc' CARGO_PKG_VERSION=0.2.119 CARGO_PKG_VERSION_MAJOR=0 CARGO_PKG_VERSION_MINOR=2 CARGO_PKG_VERSION_PATCH=119 CARGO_PKG_VERSION_PRE='' DYLD_FALLBACK_LIBRARY_PATH='/Users/kbarron/tmp/zstd-rs/zstd-safe/zstd-sys/target/debug/deps:/Users/kbarron/.rustup/toolchains/stable-x86_64-apple-darwin/lib:/Users/kbarron/.rustup/toolchains/stable-x86_64-apple-darwin/lib:/Users/kbarron/lib:/usr/local/lib:/usr/lib' OUT_DIR=/Users/kbarron/tmp/zstd-rs/zstd-safe/zstd-sys/target/wasm32-unknown-unknown/debug/build/libc-3b4e6dc3f96f645f/out rustc --crate-name libc /Users/kbarron/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/libc-0.2.119/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type lib --emit=dep-info,metadata,link -C embed-bitcode=no -C debuginfo=2 --cfg 'feature="default"' --cfg 'feature="std"' -C metadata=ac7d6ba7ecd695bf -C extra-filename=-ac7d6ba7ecd695bf --out-dir /Users/kbarron/tmp/zstd-rs/zstd-safe/zstd-sys/target/wasm32-unknown-unknown/debug/deps --target wasm32-unknown-unknown -L dependency=/Users/kbarron/tmp/zstd-rs/zstd-safe/zstd-sys/target/wasm32-unknown-unknown/debug/deps -L dependency=/Users/kbarron/tmp/zstd-rs/zstd-safe/zstd-sys/target/debug/deps --cap-lints warn --cfg freebsd11 --cfg libc_priv_mod_use --cfg libc_union --cfg libc_const_size_of --cfg libc_align --cfg libc_core_cvoid --cfg libc_packedN --cfg libc_cfg_target_vendor --cfg libc_non_exhaustive --cfg libc_ptr_addr_of`
   Compiling jobserver v0.1.24
     Running `CARGO=/Users/kbarron/.rustup/toolchains/stable-x86_64-apple-darwin/bin/cargo CARGO_CRATE_NAME=jobserver CARGO_MANIFEST_DIR=/Users/kbarron/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/jobserver-0.1.24 CARGO_PKG_AUTHORS='Alex Crichton <[email protected]>' CARGO_PKG_DESCRIPTION='An implementation of the GNU make jobserver for Rust
' CARGO_PKG_HOMEPAGE='https://github.com/alexcrichton/jobserver-rs' CARGO_PKG_LICENSE=MIT/Apache-2.0 CARGO_PKG_LICENSE_FILE='' CARGO_PKG_NAME=jobserver CARGO_PKG_REPOSITORY='https://github.com/alexcrichton/jobserver-rs' CARGO_PKG_VERSION=0.1.24 CARGO_PKG_VERSION_MAJOR=0 CARGO_PKG_VERSION_MINOR=1 CARGO_PKG_VERSION_PATCH=24 CARGO_PKG_VERSION_PRE='' DYLD_FALLBACK_LIBRARY_PATH='/Users/kbarron/tmp/zstd-rs/zstd-safe/zstd-sys/target/debug/deps:/Users/kbarron/.rustup/toolchains/stable-x86_64-apple-darwin/lib:/Users/kbarron/.rustup/toolchains/stable-x86_64-apple-darwin/lib:/Users/kbarron/lib:/usr/local/lib:/usr/lib' rustc --crate-name jobserver --edition=2018 /Users/kbarron/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/jobserver-0.1.24/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type lib --emit=dep-info,metadata,link -C embed-bitcode=no -C split-debuginfo=unpacked -C debuginfo=2 -C metadata=2e4b99667a7ddd7d -C extra-filename=-2e4b99667a7ddd7d --out-dir /Users/kbarron/tmp/zstd-rs/zstd-safe/zstd-sys/target/debug/deps -L dependency=/Users/kbarron/tmp/zstd-rs/zstd-safe/zstd-sys/target/debug/deps --extern libc=/Users/kbarron/tmp/zstd-rs/zstd-safe/zstd-sys/target/debug/deps/liblibc-d132da372e291c03.rmeta --cap-lints warn`
   Compiling cc v1.0.73
     Running `CARGO=/Users/kbarron/.rustup/toolchains/stable-x86_64-apple-darwin/bin/cargo CARGO_CRATE_NAME=cc CARGO_MANIFEST_DIR=/Users/kbarron/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/cc-1.0.73 CARGO_PKG_AUTHORS='Alex Crichton <[email protected]>' CARGO_PKG_DESCRIPTION='A build-time dependency for Cargo build scripts to assist in invoking the native
C compiler to compile native C code into a static archive to be linked into Rust
code.
' CARGO_PKG_HOMEPAGE='https://github.com/alexcrichton/cc-rs' CARGO_PKG_LICENSE=MIT/Apache-2.0 CARGO_PKG_LICENSE_FILE='' CARGO_PKG_NAME=cc CARGO_PKG_REPOSITORY='https://github.com/alexcrichton/cc-rs' CARGO_PKG_VERSION=1.0.73 CARGO_PKG_VERSION_MAJOR=1 CARGO_PKG_VERSION_MINOR=0 CARGO_PKG_VERSION_PATCH=73 CARGO_PKG_VERSION_PRE='' DYLD_FALLBACK_LIBRARY_PATH='/Users/kbarron/tmp/zstd-rs/zstd-safe/zstd-sys/target/debug/deps:/Users/kbarron/.rustup/toolchains/stable-x86_64-apple-darwin/lib:/Users/kbarron/.rustup/toolchains/stable-x86_64-apple-darwin/lib:/Users/kbarron/lib:/usr/local/lib:/usr/lib' rustc --crate-name cc --edition=2018 /Users/kbarron/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/cc-1.0.73/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,future-incompat --crate-type lib --emit=dep-info,metadata,link -C embed-bitcode=no -C split-debuginfo=unpacked -C debuginfo=2 --cfg 'feature="jobserver"' --cfg 'feature="parallel"' -C metadata=a41a365a96abe1d8 -C extra-filename=-a41a365a96abe1d8 --out-dir /Users/kbarron/tmp/zstd-rs/zstd-safe/zstd-sys/target/debug/deps -L dependency=/Users/kbarron/tmp/zstd-rs/zstd-safe/zstd-sys/target/debug/deps --extern jobserver=/Users/kbarron/tmp/zstd-rs/zstd-safe/zstd-sys/target/debug/deps/libjobserver-2e4b99667a7ddd7d.rmeta --cap-lints warn`
   Compiling zstd-sys v1.6.3+zstd.1.5.2 (/Users/kbarron/tmp/zstd-rs/zstd-safe/zstd-sys)
     Running `CARGO=/Users/kbarron/.rustup/toolchains/stable-x86_64-apple-darwin/bin/cargo CARGO_CRATE_NAME=build_script_build CARGO_MANIFEST_DIR=/Users/kbarron/tmp/zstd-rs/zstd-safe/zstd-sys CARGO_PKG_AUTHORS='Alexandre Bury <[email protected]>' CARGO_PKG_DESCRIPTION='Low-level bindings for the zstd compression library.' CARGO_PKG_HOMEPAGE='' CARGO_PKG_LICENSE=MIT/Apache-2.0 CARGO_PKG_LICENSE_FILE='' CARGO_PKG_NAME=zstd-sys CARGO_PKG_REPOSITORY='https://github.com/gyscos/zstd-rs' CARGO_PKG_VERSION=1.6.3+zstd.1.5.2 CARGO_PKG_VERSION_MAJOR=1 CARGO_PKG_VERSION_MINOR=6 CARGO_PKG_VERSION_PATCH=3 CARGO_PKG_VERSION_PRE='' CARGO_PRIMARY_PACKAGE=1 DYLD_FALLBACK_LIBRARY_PATH='/Users/kbarron/tmp/zstd-rs/zstd-safe/zstd-sys/target/debug/deps:/Users/kbarron/.rustup/toolchains/stable-x86_64-apple-darwin/lib:/Users/kbarron/.rustup/toolchains/stable-x86_64-apple-darwin/lib:/Users/kbarron/lib:/usr/local/lib:/usr/lib' rustc --crate-name build_script_build --edition=2018 build.rs --error-format=json --json=diagnostic-rendered-ansi,future-incompat --crate-type bin --emit=dep-info,link -C embed-bitcode=no -C split-debuginfo=unpacked -C debuginfo=2 -C metadata=efe3514e9ecf8963 -C extra-filename=-efe3514e9ecf8963 --out-dir /Users/kbarron/tmp/zstd-rs/zstd-safe/zstd-sys/target/debug/build/zstd-sys-efe3514e9ecf8963 -C incremental=/Users/kbarron/tmp/zstd-rs/zstd-safe/zstd-sys/target/debug/incremental -L dependency=/Users/kbarron/tmp/zstd-rs/zstd-safe/zstd-sys/target/debug/deps --extern cc=/Users/kbarron/tmp/zstd-rs/zstd-safe/zstd-sys/target/debug/deps/libcc-a41a365a96abe1d8.rlib`
     Running `/Users/kbarron/tmp/zstd-rs/zstd-safe/zstd-sys/target/debug/build/zstd-sys-efe3514e9ecf8963/build-script-build`
[zstd-sys 1.6.3+zstd.1.5.2] cargo:rustc-cfg=feature="std"
[zstd-sys 1.6.3+zstd.1.5.2] cargo:rerun-if-changed=wasm-shim/stdlib.h
[zstd-sys 1.6.3+zstd.1.5.2] cargo:rerun-if-changed=wasm-shim/string.h
[zstd-sys 1.6.3+zstd.1.5.2] TARGET = Some("wasm32-unknown-unknown")
[zstd-sys 1.6.3+zstd.1.5.2] HOST = Some("x86_64-apple-darwin")
[zstd-sys 1.6.3+zstd.1.5.2] CC_wasm32-unknown-unknown = None
[zstd-sys 1.6.3+zstd.1.5.2] CC_wasm32_unknown_unknown = None
[zstd-sys 1.6.3+zstd.1.5.2] TARGET_CC = None
[zstd-sys 1.6.3+zstd.1.5.2] CC = None
[zstd-sys 1.6.3+zstd.1.5.2] CFLAGS_wasm32-unknown-unknown = None
[zstd-sys 1.6.3+zstd.1.5.2] CFLAGS_wasm32_unknown_unknown = None
[zstd-sys 1.6.3+zstd.1.5.2] TARGET_CFLAGS = None
[zstd-sys 1.6.3+zstd.1.5.2] CFLAGS = None
[zstd-sys 1.6.3+zstd.1.5.2] CRATE_CC_NO_DEFAULTS = None
[zstd-sys 1.6.3+zstd.1.5.2] DEBUG = Some("true")
[zstd-sys 1.6.3+zstd.1.5.2] running: "clang" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "--target=wasm32-unknown-unknown" "-I" "wasm-shim/" "-I" "zstd/lib/" "-I" "zstd/lib/common" "-fvisibility=hidden" "-DXXH_STATIC_ASSERT=0" "-DZSTD_LIB_DEPRECATED=0" "-DXXH_PRIVATE_API=" "-DZSTDLIB_VISIBILITY=" "-DZSTDERRORLIB_VISIBILITY=" "-o" "/Users/kbarron/tmp/zstd-rs/zstd-safe/zstd-sys/target/wasm32-unknown-unknown/debug/build/zstd-sys-e544bdc3e2e20244/out/zstd/lib/compress/zstd_compress_superblock.o" "-c" "zstd/lib/compress/zstd_compress_superblock.c"
[zstd-sys 1.6.3+zstd.1.5.2] running: "clang" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "--target=wasm32-unknown-unknown" "-I" "wasm-shim/" "-I" "zstd/lib/" "-I" "zstd/lib/common" "-fvisibility=hidden" "-DXXH_STATIC_ASSERT=0" "-DZSTD_LIB_DEPRECATED=0" "-DXXH_PRIVATE_API=" "-DZSTDLIB_VISIBILITY=" "-DZSTDERRORLIB_VISIBILITY=" "-o" "/Users/kbarron/tmp/zstd-rs/zstd-safe/zstd-sys/target/wasm32-unknown-unknown/debug/build/zstd-sys-e544bdc3e2e20244/out/zstd/lib/common/zstd_common.o" "-c" "zstd/lib/common/zstd_common.c"
[zstd-sys 1.6.3+zstd.1.5.2] running: "clang" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "--target=wasm32-unknown-unknown" "-I" "wasm-shim/" "-I" "zstd/lib/" "-I" "zstd/lib/common" "-fvisibility=hidden" "-DXXH_STATIC_ASSERT=0" "-DZSTD_LIB_DEPRECATED=0" "-DXXH_PRIVATE_API=" "-DZSTDLIB_VISIBILITY=" "-DZSTDERRORLIB_VISIBILITY=" "-o" "/Users/kbarron/tmp/zstd-rs/zstd-safe/zstd-sys/target/wasm32-unknown-unknown/debug/build/zstd-sys-e544bdc3e2e20244/out/zstd/lib/common/debug.o" "-c" "zstd/lib/common/debug.c"
[zstd-sys 1.6.3+zstd.1.5.2] running: "clang" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "--target=wasm32-unknown-unknown" "-I" "wasm-shim/" "-I" "zstd/lib/" "-I" "zstd/lib/common" "-fvisibility=hidden" "-DXXH_STATIC_ASSERT=0" "-DZSTD_LIB_DEPRECATED=0" "-DXXH_PRIVATE_API=" "-DZSTDLIB_VISIBILITY=" "-DZSTDERRORLIB_VISIBILITY=" "-o" "/Users/kbarron/tmp/zstd-rs/zstd-safe/zstd-sys/target/wasm32-unknown-unknown/debug/build/zstd-sys-e544bdc3e2e20244/out/zstd/lib/common/threading.o" "-c" "zstd/lib/common/threading.c"
[zstd-sys 1.6.3+zstd.1.5.2] running: "clang" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "--target=wasm32-unknown-unknown" "-I" "wasm-shim/" "-I" "zstd/lib/" "-I" "zstd/lib/common" "-fvisibility=hidden" "-DXXH_STATIC_ASSERT=0" "-DZSTD_LIB_DEPRECATED=0" "-DXXH_PRIVATE_API=" "-DZSTDLIB_VISIBILITY=" "-DZSTDERRORLIB_VISIBILITY=" "-o" "/Users/kbarron/tmp/zstd-rs/zstd-safe/zstd-sys/target/wasm32-unknown-unknown/debug/build/zstd-sys-e544bdc3e2e20244/out/zstd/lib/common/error_private.o" "-c" "zstd/lib/common/error_private.c"
[zstd-sys 1.6.3+zstd.1.5.2] running: "clang" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "--target=wasm32-unknown-unknown" "-I" "wasm-shim/" "-I" "zstd/lib/" "-I" "zstd/lib/common" "-fvisibility=hidden" "-DXXH_STATIC_ASSERT=0" "-DZSTD_LIB_DEPRECATED=0" "-DXXH_PRIVATE_API=" "-DZSTDLIB_VISIBILITY=" "-DZSTDERRORLIB_VISIBILITY=" "-o" "/Users/kbarron/tmp/zstd-rs/zstd-safe/zstd-sys/target/wasm32-unknown-unknown/debug/build/zstd-sys-e544bdc3e2e20244/out/zstd/lib/common/entropy_common.o" "-c" "zstd/lib/common/entropy_common.c"
[zstd-sys 1.6.3+zstd.1.5.2] running: "clang" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "--target=wasm32-unknown-unknown" "-I" "wasm-shim/" "-I" "zstd/lib/" "-I" "zstd/lib/common" "-fvisibility=hidden" "-DXXH_STATIC_ASSERT=0" "-DZSTD_LIB_DEPRECATED=0" "-DXXH_PRIVATE_API=" "-DZSTDLIB_VISIBILITY=" "-DZSTDERRORLIB_VISIBILITY=" "-o" "/Users/kbarron/tmp/zstd-rs/zstd-safe/zstd-sys/target/wasm32-unknown-unknown/debug/build/zstd-sys-e544bdc3e2e20244/out/zstd/lib/common/fse_decompress.o" "-c" "zstd/lib/common/fse_decompress.c"
[zstd-sys 1.6.3+zstd.1.5.2] running: "clang" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "--target=wasm32-unknown-unknown" "-I" "wasm-shim/" "-I" "zstd/lib/" "-I" "zstd/lib/common" "-fvisibility=hidden" "-DXXH_STATIC_ASSERT=0" "-DZSTD_LIB_DEPRECATED=0" "-DXXH_PRIVATE_API=" "-DZSTDLIB_VISIBILITY=" "-DZSTDERRORLIB_VISIBILITY=" "-o" "/Users/kbarron/tmp/zstd-rs/zstd-safe/zstd-sys/target/wasm32-unknown-unknown/debug/build/zstd-sys-e544bdc3e2e20244/out/zstd/lib/common/pool.o" "-c" "zstd/lib/common/pool.c"
[zstd-sys 1.6.3+zstd.1.5.2] cargo:warning=error: unable to create target: 'No available targets are compatible with triple "wasm32-unknown-unknown"'
[zstd-sys 1.6.3+zstd.1.5.2] cargo:warning=1 error generated.
[zstd-sys 1.6.3+zstd.1.5.2] exit status: 1
[zstd-sys 1.6.3+zstd.1.5.2] running: "clang" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "--target=wasm32-unknown-unknown" "-I" "wasm-shim/" "-I" "zstd/lib/" "-I" "zstd/lib/common" "-fvisibility=hidden" "-DXXH_STATIC_ASSERT=0" "-DZSTD_LIB_DEPRECATED=0" "-DXXH_PRIVATE_API=" "-DZSTDLIB_VISIBILITY=" "-DZSTDERRORLIB_VISIBILITY=" "-o" "/Users/kbarron/tmp/zstd-rs/zstd-safe/zstd-sys/target/wasm32-unknown-unknown/debug/build/zstd-sys-e544bdc3e2e20244/out/zstd/lib/compress/zstdmt_compress.o" "-c" "zstd/lib/compress/zstdmt_compress.c"
[zstd-sys 1.6.3+zstd.1.5.2] cargo:warning=error: unable to create target: 'No available targets are compatible with triple "wasm32-unknown-unknown"'
[zstd-sys 1.6.3+zstd.1.5.2] cargo:warning=1 error generated.
[zstd-sys 1.6.3+zstd.1.5.2] exit status: 1
[zstd-sys 1.6.3+zstd.1.5.2] cargo:warning=error: unable to create target: 'No available targets are compatible with triple "wasm32-unknown-unknown"'
[zstd-sys 1.6.3+zstd.1.5.2] cargo:warning=1 error generated.
[zstd-sys 1.6.3+zstd.1.5.2] exit status: 1
[zstd-sys 1.6.3+zstd.1.5.2] cargo:warning=error: unable to create target: 'No available targets are compatible with triple "wasm32-unknown-unknown"'
[zstd-sys 1.6.3+zstd.1.5.2] cargo:warning=1 error generated.
[zstd-sys 1.6.3+zstd.1.5.2] cargo:warning=error: unable to create target: 'No available targets are compatible with triple "wasm32-unknown-unknown"'
[zstd-sys 1.6.3+zstd.1.5.2] exit status: 1
[zstd-sys 1.6.3+zstd.1.5.2] cargo:warning=1 error generated.
[zstd-sys 1.6.3+zstd.1.5.2] cargo:warning=error: unable to create target: 'No available targets are compatible with triple "wasm32-unknown-unknown"'
[zstd-sys 1.6.3+zstd.1.5.2] cargo:warning=1 error generated.
[zstd-sys 1.6.3+zstd.1.5.2] exit status: 1
[zstd-sys 1.6.3+zstd.1.5.2] exit status: 1
[zstd-sys 1.6.3+zstd.1.5.2] cargo:warning=error: unable to create target: 'No available targets are compatible with triple "wasm32-unknown-unknown"'
[zstd-sys 1.6.3+zstd.1.5.2] cargo:warning=1 error generated.
[zstd-sys 1.6.3+zstd.1.5.2] cargo:warning=error: unable to create target: 'No available targets are compatible with triple "wasm32-unknown-unknown"'
[zstd-sys 1.6.3+zstd.1.5.2] cargo:warning=1 error generated.
[zstd-sys 1.6.3+zstd.1.5.2] exit status: 1
[zstd-sys 1.6.3+zstd.1.5.2] exit status: 1
[zstd-sys 1.6.3+zstd.1.5.2] cargo:warning=error: unable to create target: 'No available targets are compatible with triple "wasm32-unknown-unknown"'
[zstd-sys 1.6.3+zstd.1.5.2] cargo:warning=1 error generated.
[zstd-sys 1.6.3+zstd.1.5.2] exit status: 1
[zstd-sys 1.6.3+zstd.1.5.2]
[zstd-sys 1.6.3+zstd.1.5.2]
[zstd-sys 1.6.3+zstd.1.5.2] error occurred: Command "clang" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "--target=wasm32-unknown-unknown" "-I" "wasm-shim/" "-I" "zstd/lib/" "-I" "zstd/lib/common" "-fvisibility=hidden" "-DXXH_STATIC_ASSERT=0" "-DZSTD_LIB_DEPRECATED=0" "-DXXH_PRIVATE_API=" "-DZSTDLIB_VISIBILITY=" "-DZSTDERRORLIB_VISIBILITY=" "-o" "/Users/kbarron/tmp/zstd-rs/zstd-safe/zstd-sys/target/wasm32-unknown-unknown/debug/build/zstd-sys-e544bdc3e2e20244/out/zstd/lib/common/entropy_common.o" "-c" "zstd/lib/common/entropy_common.c" with args "clang" did not execute successfully (status code exit status: 1).
[zstd-sys 1.6.3+zstd.1.5.2]
[zstd-sys 1.6.3+zstd.1.5.2]
The following warnings were emitted during compilation:

warning: error: unable to create target: 'No available targets are compatible with triple "wasm32-unknown-unknown"'
warning: 1 error generated.
warning: error: unable to create target: 'No available targets are compatible with triple "wasm32-unknown-unknown"'
warning: 1 error generated.
warning: error: unable to create target: 'No available targets are compatible with triple "wasm32-unknown-unknown"'
warning: 1 error generated.
warning: error: unable to create target: 'No available targets are compatible with triple "wasm32-unknown-unknown"'
warning: 1 error generated.
warning: error: unable to create target: 'No available targets are compatible with triple "wasm32-unknown-unknown"'
warning: 1 error generated.
warning: error: unable to create target: 'No available targets are compatible with triple "wasm32-unknown-unknown"'
warning: 1 error generated.
warning: error: unable to create target: 'No available targets are compatible with triple "wasm32-unknown-unknown"'
warning: 1 error generated.
warning: error: unable to create target: 'No available targets are compatible with triple "wasm32-unknown-unknown"'
warning: 1 error generated.
warning: error: unable to create target: 'No available targets are compatible with triple "wasm32-unknown-unknown"'
warning: 1 error generated.

error: failed to run custom build command for `zstd-sys v1.6.3+zstd.1.5.2 (/Users/kbarron/tmp/zstd-rs/zstd-safe/zstd-sys)`

Caused by:
  process didn't exit successfully: `/Users/kbarron/tmp/zstd-rs/zstd-safe/zstd-sys/target/debug/build/zstd-sys-efe3514e9ecf8963/build-script-build` (exit status: 1)
  --- stdout
  cargo:rustc-cfg=feature="std"
  cargo:rerun-if-changed=wasm-shim/stdlib.h
  cargo:rerun-if-changed=wasm-shim/string.h
  TARGET = Some("wasm32-unknown-unknown")
  HOST = Some("x86_64-apple-darwin")
  CC_wasm32-unknown-unknown = None
  CC_wasm32_unknown_unknown = None
  TARGET_CC = None
  CC = None
  CFLAGS_wasm32-unknown-unknown = None
  CFLAGS_wasm32_unknown_unknown = None
  TARGET_CFLAGS = None
  CFLAGS = None
  CRATE_CC_NO_DEFAULTS = None
  DEBUG = Some("true")
  running: "clang" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "--target=wasm32-unknown-unknown" "-I" "wasm-shim/" "-I" "zstd/lib/" "-I" "zstd/lib/common" "-fvisibility=hidden" "-DXXH_STATIC_ASSERT=0" "-DZSTD_LIB_DEPRECATED=0" "-DXXH_PRIVATE_API=" "-DZSTDLIB_VISIBILITY=" "-DZSTDERRORLIB_VISIBILITY=" "-o" "/Users/kbarron/tmp/zstd-rs/zstd-safe/zstd-sys/target/wasm32-unknown-unknown/debug/build/zstd-sys-e544bdc3e2e20244/out/zstd/lib/compress/zstd_compress_superblock.o" "-c" "zstd/lib/compress/zstd_compress_superblock.c"
  running: "clang" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "--target=wasm32-unknown-unknown" "-I" "wasm-shim/" "-I" "zstd/lib/" "-I" "zstd/lib/common" "-fvisibility=hidden" "-DXXH_STATIC_ASSERT=0" "-DZSTD_LIB_DEPRECATED=0" "-DXXH_PRIVATE_API=" "-DZSTDLIB_VISIBILITY=" "-DZSTDERRORLIB_VISIBILITY=" "-o" "/Users/kbarron/tmp/zstd-rs/zstd-safe/zstd-sys/target/wasm32-unknown-unknown/debug/build/zstd-sys-e544bdc3e2e20244/out/zstd/lib/common/zstd_common.o" "-c" "zstd/lib/common/zstd_common.c"
  running: "clang" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "--target=wasm32-unknown-unknown" "-I" "wasm-shim/" "-I" "zstd/lib/" "-I" "zstd/lib/common" "-fvisibility=hidden" "-DXXH_STATIC_ASSERT=0" "-DZSTD_LIB_DEPRECATED=0" "-DXXH_PRIVATE_API=" "-DZSTDLIB_VISIBILITY=" "-DZSTDERRORLIB_VISIBILITY=" "-o" "/Users/kbarron/tmp/zstd-rs/zstd-safe/zstd-sys/target/wasm32-unknown-unknown/debug/build/zstd-sys-e544bdc3e2e20244/out/zstd/lib/common/debug.o" "-c" "zstd/lib/common/debug.c"
  running: "clang" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "--target=wasm32-unknown-unknown" "-I" "wasm-shim/" "-I" "zstd/lib/" "-I" "zstd/lib/common" "-fvisibility=hidden" "-DXXH_STATIC_ASSERT=0" "-DZSTD_LIB_DEPRECATED=0" "-DXXH_PRIVATE_API=" "-DZSTDLIB_VISIBILITY=" "-DZSTDERRORLIB_VISIBILITY=" "-o" "/Users/kbarron/tmp/zstd-rs/zstd-safe/zstd-sys/target/wasm32-unknown-unknown/debug/build/zstd-sys-e544bdc3e2e20244/out/zstd/lib/common/threading.o" "-c" "zstd/lib/common/threading.c"
  running: "clang" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "--target=wasm32-unknown-unknown" "-I" "wasm-shim/" "-I" "zstd/lib/" "-I" "zstd/lib/common" "-fvisibility=hidden" "-DXXH_STATIC_ASSERT=0" "-DZSTD_LIB_DEPRECATED=0" "-DXXH_PRIVATE_API=" "-DZSTDLIB_VISIBILITY=" "-DZSTDERRORLIB_VISIBILITY=" "-o" "/Users/kbarron/tmp/zstd-rs/zstd-safe/zstd-sys/target/wasm32-unknown-unknown/debug/build/zstd-sys-e544bdc3e2e20244/out/zstd/lib/common/error_private.o" "-c" "zstd/lib/common/error_private.c"
  running: "clang" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "--target=wasm32-unknown-unknown" "-I" "wasm-shim/" "-I" "zstd/lib/" "-I" "zstd/lib/common" "-fvisibility=hidden" "-DXXH_STATIC_ASSERT=0" "-DZSTD_LIB_DEPRECATED=0" "-DXXH_PRIVATE_API=" "-DZSTDLIB_VISIBILITY=" "-DZSTDERRORLIB_VISIBILITY=" "-o" "/Users/kbarron/tmp/zstd-rs/zstd-safe/zstd-sys/target/wasm32-unknown-unknown/debug/build/zstd-sys-e544bdc3e2e20244/out/zstd/lib/common/entropy_common.o" "-c" "zstd/lib/common/entropy_common.c"
  running: "clang" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "--target=wasm32-unknown-unknown" "-I" "wasm-shim/" "-I" "zstd/lib/" "-I" "zstd/lib/common" "-fvisibility=hidden" "-DXXH_STATIC_ASSERT=0" "-DZSTD_LIB_DEPRECATED=0" "-DXXH_PRIVATE_API=" "-DZSTDLIB_VISIBILITY=" "-DZSTDERRORLIB_VISIBILITY=" "-o" "/Users/kbarron/tmp/zstd-rs/zstd-safe/zstd-sys/target/wasm32-unknown-unknown/debug/build/zstd-sys-e544bdc3e2e20244/out/zstd/lib/common/fse_decompress.o" "-c" "zstd/lib/common/fse_decompress.c"
  running: "clang" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "--target=wasm32-unknown-unknown" "-I" "wasm-shim/" "-I" "zstd/lib/" "-I" "zstd/lib/common" "-fvisibility=hidden" "-DXXH_STATIC_ASSERT=0" "-DZSTD_LIB_DEPRECATED=0" "-DXXH_PRIVATE_API=" "-DZSTDLIB_VISIBILITY=" "-DZSTDERRORLIB_VISIBILITY=" "-o" "/Users/kbarron/tmp/zstd-rs/zstd-safe/zstd-sys/target/wasm32-unknown-unknown/debug/build/zstd-sys-e544bdc3e2e20244/out/zstd/lib/common/pool.o" "-c" "zstd/lib/common/pool.c"
  cargo:warning=error: unable to create target: 'No available targets are compatible with triple "wasm32-unknown-unknown"'
  cargo:warning=1 error generated.
  exit status: 1
  running: "clang" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "--target=wasm32-unknown-unknown" "-I" "wasm-shim/" "-I" "zstd/lib/" "-I" "zstd/lib/common" "-fvisibility=hidden" "-DXXH_STATIC_ASSERT=0" "-DZSTD_LIB_DEPRECATED=0" "-DXXH_PRIVATE_API=" "-DZSTDLIB_VISIBILITY=" "-DZSTDERRORLIB_VISIBILITY=" "-o" "/Users/kbarron/tmp/zstd-rs/zstd-safe/zstd-sys/target/wasm32-unknown-unknown/debug/build/zstd-sys-e544bdc3e2e20244/out/zstd/lib/compress/zstdmt_compress.o" "-c" "zstd/lib/compress/zstdmt_compress.c"
  cargo:warning=error: unable to create target: 'No available targets are compatible with triple "wasm32-unknown-unknown"'
  cargo:warning=1 error generated.
  exit status: 1
  cargo:warning=error: unable to create target: 'No available targets are compatible with triple "wasm32-unknown-unknown"'
  cargo:warning=1 error generated.
  exit status: 1
  cargo:warning=error: unable to create target: 'No available targets are compatible with triple "wasm32-unknown-unknown"'
  cargo:warning=1 error generated.
  cargo:warning=error: unable to create target: 'No available targets are compatible with triple "wasm32-unknown-unknown"'
  exit status: 1
  cargo:warning=1 error generated.
  cargo:warning=error: unable to create target: 'No available targets are compatible with triple "wasm32-unknown-unknown"'
  cargo:warning=1 error generated.
  exit status: 1
  exit status: 1
  cargo:warning=error: unable to create target: 'No available targets are compatible with triple "wasm32-unknown-unknown"'
  cargo:warning=1 error generated.
  cargo:warning=error: unable to create target: 'No available targets are compatible with triple "wasm32-unknown-unknown"'
  cargo:warning=1 error generated.
  exit status: 1
  exit status: 1
  cargo:warning=error: unable to create target: 'No available targets are compatible with triple "wasm32-unknown-unknown"'
  cargo:warning=1 error generated.
  exit status: 1

  --- stderr


  error occurred: Command "clang" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "--target=wasm32-unknown-unknown" "-I" "wasm-shim/" "-I" "zstd/lib/" "-I" "zstd/lib/common" "-fvisibility=hidden" "-DXXH_STATIC_ASSERT=0" "-DZSTD_LIB_DEPRECATED=0" "-DXXH_PRIVATE_API=" "-DZSTDLIB_VISIBILITY=" "-DZSTDERRORLIB_VISIBILITY=" "-o" "/Users/kbarron/tmp/zstd-rs/zstd-safe/zstd-sys/target/wasm32-unknown-unknown/debug/build/zstd-sys-e544bdc3e2e20244/out/zstd/lib/common/entropy_common.o" "-c" "zstd/lib/common/entropy_common.c" with args "clang" did not execute successfully (status code exit status: 1).

@gyscos
Copy link
Owner

gyscos commented Mar 3, 2022

Looks possibly related to this?

https://stackoverflow.com/questions/49628272/osx-compile-to-webassembly-with-llc-llc-error-unable-to-get-target-for-w

https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=903110 (for Debian, but the idea might be the same)

Basically there's a possibility your installed LLVM is not built with wasm support.

I don't know much about either macos or LLVM build config, so I may be out of my depth.

Also seeing this:
https://00f.net/2019/04/07/compiling-to-webassembly-with-llvm-and-clang/

On macOS, the Homebrew version of clang should be used instead of the Xcode one. This can be achieved with:

export PATH=/usr/local/opt/llvm/bin:$PATH

You can also try llvm-config --targets-built, see if it includes WebAssembly?

% llvm-config --targets-built
AArch64 AMDGPU ARM AVR BPF Hexagon Lanai Mips MSP430 NVPTX PowerPC RISCV Sparc SystemZ WebAssembly X86 XCore

@kylebarron
Copy link
Contributor

This is helpful! When I set export PATH=/usr/local/opt/llvm/bin:$PATH, I see WebAssembly as one of the targets:

> llvm-config --targets-built
AArch64 AMDGPU ARM AVR BPF Hexagon Lanai Mips MSP430 NVPTX PowerPC RISCV Sparc SystemZ WebAssembly X86 XCore

But then when trying to build for wasm32-unknown-unknown I get a new error. I tried to google this error a bit but couldn't find anything easy to follow. I might try building this on a linux instance and see if it works there.

> cargo build -vv --target wasm32-unknown-unknown --no-default-features --example it_work
       Fresh libc v0.2.119
       Fresh jobserver v0.1.24
       Fresh cc v1.0.73
warning: warning: /Library/Developer/CommandLineTools/usr/bin/ranlib: archive library: /Users/kbarron/zstd-rs/zstd-safe/zstd-sys/target/wasm32-unknown-unknown/debug/build/zstd-sys-e544bdc3e2e20244/out/libzstd.a the table of contents is empty (no object file members in the library define global symbols)
   Compiling zstd-sys v1.6.3+zstd.1.5.2 (/Users/kbarron/zstd-rs/zstd-safe/zstd-sys)
     Running `CARGO=/Users/kbarron/.rustup/toolchains/stable-x86_64-apple-darwin/bin/cargo CARGO_CRATE_NAME=zstd_sys CARGO_MANIFEST_DIR=/Users/kbarron/zstd-rs/zstd-safe/zstd-sys CARGO_PKG_AUTHORS='Alexandre Bury <[email protected]>' CARGO_PKG_DESCRIPTION='Low-level bindings for the zstd compression library.' CARGO_PKG_HOMEPAGE='' CARGO_PKG_LICENSE=MIT/Apache-2.0 CARGO_PKG_LICENSE_FILE='' CARGO_PKG_NAME=zstd-sys CARGO_PKG_REPOSITORY='https://github.com/gyscos/zstd-rs' CARGO_PKG_VERSION=1.6.3+zstd.1.5.2 CARGO_PKG_VERSION_MAJOR=1 CARGO_PKG_VERSION_MINOR=6 CARGO_PKG_VERSION_PATCH=3 CARGO_PKG_VERSION_PRE='' CARGO_PRIMARY_PACKAGE=1 DYLD_FALLBACK_LIBRARY_PATH='/Users/kbarron/zstd-rs/zstd-safe/zstd-sys/target/debug/deps:/Users/kbarron/.rustup/toolchains/stable-x86_64-apple-darwin/lib:/Users/kbarron/.rustup/toolchains/stable-x86_64-apple-darwin/lib:/Users/kbarron/lib:/usr/local/lib:/usr/lib' OUT_DIR=/Users/kbarron/zstd-rs/zstd-safe/zstd-sys/target/wasm32-unknown-unknown/debug/build/zstd-sys-e544bdc3e2e20244/out rustc --crate-name zstd_sys --edition=2018 src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,future-incompat --crate-type lib --emit=dep-info,metadata,link -C embed-bitcode=no -C debuginfo=2 -C metadata=29f4fc113e786a4a -C extra-filename=-29f4fc113e786a4a --out-dir /Users/kbarron/zstd-rs/zstd-safe/zstd-sys/target/wasm32-unknown-unknown/debug/deps --target wasm32-unknown-unknown -C incremental=/Users/kbarron/zstd-rs/zstd-safe/zstd-sys/target/wasm32-unknown-unknown/debug/incremental -L dependency=/Users/kbarron/zstd-rs/zstd-safe/zstd-sys/target/wasm32-unknown-unknown/debug/deps -L dependency=/Users/kbarron/zstd-rs/zstd-safe/zstd-sys/target/debug/deps --extern libc=/Users/kbarron/zstd-rs/zstd-safe/zstd-sys/target/wasm32-unknown-unknown/debug/deps/liblibc-ac7d6ba7ecd695bf.rmeta -L native=/Users/kbarron/zstd-rs/zstd-safe/zstd-sys/target/wasm32-unknown-unknown/debug/build/zstd-sys-e544bdc3e2e20244/out --cfg 'feature="std"' -l static=zstd`
error: failed to build archive: section too large

The following warnings were emitted during compilation:

warning: warning: /Library/Developer/CommandLineTools/usr/bin/ranlib: archive library: /Users/kbarron/zstd-rs/zstd-safe/zstd-sys/target/wasm32-unknown-unknown/debug/build/zstd-sys-e544bdc3e2e20244/out/libzstd.a the table of contents is empty (no object file members in the library define global symbols)

error: could not compile `zstd-sys` due to previous error

Caused by:
  process didn't exit successfully: `CARGO=/Users/kbarron/.rustup/toolchains/stable-x86_64-apple-darwin/bin/cargo CARGO_CRATE_NAME=zstd_sys CARGO_MANIFEST_DIR=/Users/kbarron/zstd-rs/zstd-safe/zstd-sys CARGO_PKG_AUTHORS='Alexandre Bury <[email protected]>' CARGO_PKG_DESCRIPTION='Low-level bindings for the zstd compression library.' CARGO_PKG_HOMEPAGE='' CARGO_PKG_LICENSE=MIT/Apache-2.0 CARGO_PKG_LICENSE_FILE='' CARGO_PKG_NAME=zstd-sys CARGO_PKG_REPOSITORY='https://github.com/gyscos/zstd-rs' CARGO_PKG_VERSION=1.6.3+zstd.1.5.2 CARGO_PKG_VERSION_MAJOR=1 CARGO_PKG_VERSION_MINOR=6 CARGO_PKG_VERSION_PATCH=3 CARGO_PKG_VERSION_PRE='' CARGO_PRIMARY_PACKAGE=1 DYLD_FALLBACK_LIBRARY_PATH='/Users/kbarron/zstd-rs/zstd-safe/zstd-sys/target/debug/deps:/Users/kbarron/.rustup/toolchains/stable-x86_64-apple-darwin/lib:/Users/kbarron/.rustup/toolchains/stable-x86_64-apple-darwin/lib:/Users/kbarron/lib:/usr/local/lib:/usr/lib' OUT_DIR=/Users/kbarron/zstd-rs/zstd-safe/zstd-sys/target/wasm32-unknown-unknown/debug/build/zstd-sys-e544bdc3e2e20244/out rustc --crate-name zstd_sys --edition=2018 src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,future-incompat --crate-type lib --emit=dep-info,metadata,link -C embed-bitcode=no -C debuginfo=2 -C metadata=29f4fc113e786a4a -C extra-filename=-29f4fc113e786a4a --out-dir /Users/kbarron/zstd-rs/zstd-safe/zstd-sys/target/wasm32-unknown-unknown/debug/deps --target wasm32-unknown-unknown -C incremental=/Users/kbarron/zstd-rs/zstd-safe/zstd-sys/target/wasm32-unknown-unknown/debug/incremental -L dependency=/Users/kbarron/zstd-rs/zstd-safe/zstd-sys/target/wasm32-unknown-unknown/debug/deps -L dependency=/Users/kbarron/zstd-rs/zstd-safe/zstd-sys/target/debug/deps --extern libc=/Users/kbarron/zstd-rs/zstd-safe/zstd-sys/target/wasm32-unknown-unknown/debug/deps/liblibc-ac7d6ba7ecd695bf.rmeta -L native=/Users/kbarron/zstd-rs/zstd-safe/zstd-sys/target/wasm32-unknown-unknown/debug/build/zstd-sys-e544bdc3e2e20244/out --cfg 'feature="std"' -l static=zstd` (exit status: 1)

@gyscos
Copy link
Owner

gyscos commented Mar 4, 2022

Are you running this on a m1 MacBook?

Is this relevant?
rust-bitcoin/rust-secp256k1#283 (comment)

(The next comment however hints that it may not be a solution for everyone)

@kylebarron
Copy link
Contributor

kylebarron commented Mar 4, 2022

Ironically, that was just the thread I needed to see to get everything to work!

I'm on an intel, not M1 Mac; the comment below the one you linked to (rust-bitcoin/rust-secp256k1#283 (comment)), gave the CC and AR env vars that I didn't know I needed to update.

Here's the full sequence that worked for me:

brew install llvm
export PATH="/usr/local/opt/llvm/bin/:$PATH"
export CC=/usr/local/opt/llvm/bin/clang
export AR=/usr/local/opt/llvm/bin/llvm-ar

git clone https://github.com/gyscos/zstd-rs --recursive
cd zstd-rs
git checkout 9334ec7
cd zstd-safe/zstd-sys/
rustup target add wasm32-unknown-unknown
cargo build --target wasm32-unknown-unknown --no-default-features --example it_work

I also tested it in arrow-rs and my WIP WASM wrapper to load Parquet files. ZSTD compiled correctly (pointing to zstd-rs latest master branch, and with default-features = false) and a Parquet file with internal ZSTD compression seemed to load fine in the browser with no code changes!

Thanks so much for your help! Looking forward to having this in a release! 🙂

@gyscos
Copy link
Owner

gyscos commented Mar 9, 2022

Published zstd 0.10.1.

We can start documenting this maybe in this github's project wiki.
EDIT: added this page: https://github.com/gyscos/zstd-rs/wiki/Compile-for-WASM

@gagbo
Copy link

gagbo commented Mar 28, 2022

Hello,

Did you happen to yank this version ? I'm trying to force the 0.10.1 version (can't use 0.11 easily because I also depend on async-compression ), and cargo tells me it cannot find it :

Updating crates.io index
error: failed to select a version for the requirement `zstd = "^0.10.1"`
candidate versions found which didn't match: 0.11.1+zstd.1.5.2, 0.11.0+zstd.1.5.2, 0.10.0+zstd.1.5.2, ...
location searched: crates.io index

@gyscos
Copy link
Owner

gyscos commented Mar 28, 2022

Hi!

Yes, the version was yanked and replaced by 0.11.0. The new feature-based inclusion of the zdict_training code happened to break backward compatibility, and required a semver bump.

@gagbo
Copy link

gagbo commented Apr 20, 2022

Hm, it looks like the dictionary feature actually broke again wasm compilation:

The following warnings were emitted during compilation:

warning: zstd/lib/dictBuilder/cover.c:24:10: fatal error: 'stdio.h' file not found
warning: #include <stdio.h>  /* fprintf */
warning:          ^~~~~~~~~
warning: zstd/lib/dictBuilder/divsufsort.c:39:10: fatal error: 'assert.h' file not found
warning: #include <assert.h>
warning:          ^~~~~~~~~~
warning: 1 error generated.
warning: 1 error generated.
warning: zstd/lib/dictBuilder/fastcover.c:14:10: fatal error: 'stdio.h' file not found
warning: #include <stdio.h>  /* fprintf */
warning:          ^~~~~~~~~
warning: 1 error generated.

error: failed to run custom build command for `zstd-sys v2.0.1+zstd.1.5.2`

Caused by:
  process didn't exit successfully: `/path/to/repo/target/release/build/zstd-sys-2d73c3223fdab5b6/build-script-build` (exit status: 1)
  --- stdout
  cargo:rustc-cfg=feature="std"
  cargo:rerun-if-changed=wasm-shim/stdlib.h
  cargo:rerun-if-changed=wasm-shim/string.h
  TARGET = Some("wasm32-unknown-unknown")
  HOST = Some("x86_64-unknown-linux-gnu")
  CC_wasm32-unknown-unknown = None
  CC_wasm32_unknown_unknown = None
  TARGET_CC = None
  CC = None
  CFLAGS_wasm32-unknown-unknown = None
  CFLAGS_wasm32_unknown_unknown = None
  TARGET_CFLAGS = None
  CFLAGS = None
  CRATE_CC_NO_DEFAULTS = None
  DEBUG = Some("false")
...
  running: "clang" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "--target=wasm32-unknown-unknown" "-I" "wasm-shim/" "-I" "zstd/lib/" "-I" "zstd/lib/common" "-I" "zstd/lib/legacy" "-fvisibility=hidden" "-DXXH_STATIC_ASSERT=0" "-DZSTD_LIB_DEPRECATED=0" "-DXXH_PRIVATE_API=" "-DZSTDLIB_VISIBILITY=" "-DZDICTLIB_VISIBILITY=" "-DZSTDERRORLIB_VISIBILITY=" "-DZSTD_LEGACY_SUPPORT=1" "-o" "/path/to/repo/target/wasm32-unknown-unknown/release/build/zstd-sys-3eeaac5bf4c3a515/out/zstd/lib/dictBuilder/divsufsort.o" "-c" "zstd/lib/dictBuilder/divsufsort.c"
  cargo:warning=zstd/lib/dictBuilder/cover.c:24:10: fatal error: 'stdio.h' file not found
  cargo:warning=#include <stdio.h>  /* fprintf */
  cargo:warning=         ^~~~~~~~~
  cargo:warning=zstd/lib/dictBuilder/divsufsort.c:39:10: fatal error: 'assert.h' file not found
  cargo:warning=#include <assert.h>
  cargo:warning=         ^~~~~~~~~~
  cargo:warning=1 error generated.
  exit status: 0
  exit status: 1
  running: "clang" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "--target=wasm32-unknown-unknown" "-I" "wasm-shim/" "-I" "zstd/lib/" "-I" "zstd/lib/common" "-I" "zstd/lib/legacy" "-fvisibility=hidden" "-DXXH_STATIC_ASSERT=0" "-DZSTD_LIB_DEPRECATED=0" "-DXXH_PRIVATE_API=" "-DZSTDLIB_VISIBILITY=" "-DZDICTLIB_VISIBILITY=" "-DZSTDERRORLIB_VISIBILITY=" "-DZSTD_LEGACY_SUPPORT=1" "-o" "/path/to/repo/target/wasm32-unknown-unknown/release/build/zstd-sys-3eeaac5bf4c3a515/out/zstd/lib/dictBuilder/fastcover.o" "-c" "zstd/lib/dictBuilder/fastcover.c"
  cargo:warning=1 error generated.
  exit status: 1
  cargo:warning=zstd/lib/dictBuilder/fastcover.c:14:10: fatal error: 'stdio.h' file not found
  cargo:warning=#include <stdio.h>  /* fprintf */
  cargo:warning=         ^~~~~~~~~
  exit status: 0
  cargo:warning=1 error generated.
  exit status: 1
...

  --- stderr


  error occurred: Command "clang" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "--target=wasm32-unknown-unknown" "-I" "wasm-shim/" "-I" "zstd/lib/" "-I" "zstd/lib/common" "-I" "zstd/lib/legacy" "-fvisibility=hidden" "-DXXH_STATIC_ASSERT=0" "-DZSTD_LIB_DEPRECATED=0" "-DXXH_PRIVATE_API=" "-DZSTDLIB_VISIBILITY=" "-DZDICTLIB_VISIBILITY=" "-DZSTDERRORLIB_VISIBILITY=" "-DZSTD_LEGACY_SUPPORT=1" "-o" "/path/to/repo/target/wasm32-unknown-unknown/release/build/zstd-sys-3eeaac5bf4c3a515/out/zstd/lib/dictBuilder/cover.o" "-c" "zstd/lib/dictBuilder/cover.c" with args "clang" did not execute successfully (status code exit status: 1).

I can trim less details if necessary, but hopefully that's enough to have an idea. (using 0.11.1, lock file extract below)

[[package]]
name = "zstd"
version = "0.11.1+zstd.1.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "77a16b8414fde0414e90c612eba70985577451c4c504b99885ebed24762cb81a"
dependencies = [
 "zstd-safe",
]

[[package]]
name = "zstd-safe"
version = "5.0.1+zstd.1.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7c12659121420dd6365c5c3de4901f97145b79651fb1d25814020ed2ed0585ae"
dependencies = [
 "libc",
 "zstd-sys",
]

[[package]]
name = "zstd-sys"
version = "2.0.1+zstd.1.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9fd07cbbc53846d9145dbffdf6dd09a7a0aa52be46741825f5c97bdd4f73f12b"
dependencies = [
 "cc",
 "libc",
]

@gagbo
Copy link

gagbo commented Apr 20, 2022

I just found out this PR #139 , so I assume I have to deactivate the dict feature and try again, which is going to take me a while to try out because of feature unification and the feature being default, I'll see.

Indeed, default-features = false did the trick

@corneliusroemer
Copy link

corneliusroemer commented May 2, 2023

export SKIP_WASM_BUILD=1 worked for me :)

@kevin-valerio I have seen your misleading comment in two repos. Either delete it or add that it doesn't fix any wasm build issues, just skips that part.

@nleroy917
Copy link

I'm having a real hard time here. I think that I am narrowing it all down, but still seem to get stuck. Initially the error was due to zstd-sys v2.0.10 as pointed out in a few issues:

However, once I pin it to 2.0.9, I get the following:

failed to run custom build command for `zstd-sys v2.0.9+zstd.1.5.5`

Which ultimately led me here. I've tried a lot of different things, but nothing seems to work. Any help would be appreciated! Here is my Cargo.toml

[lib]
crate-type = ["cdylib", "rlib"]

[features]
default = ["console_error_panic_hook"]

[dependencies]
wasm-bindgen = "0.2.84"
textractor = { path = "../textractor-core" }

# The `console_error_panic_hook` crate provides better debugging of panics by
# logging them with `console.error`. This is great for development, but requires
# all the `std::fmt` and `std::panicking` infrastructure, so isn't great for
# code size when deploying.
console_error_panic_hook = { version = "0.1.7", optional = true }
getrandom = { version = "0.2.15", features=["js"] }
zstd-sys = { version = "=2.0.9", default-features = false }

[dev-dependencies]
wasm-bindgen-test = "0.3.34"

[profile.release]
# Tell `rustc` to optimize for small code size.
opt-level = "s"

I've got an updated clang:

nathanleroy@macbookpro ~ % clang --version
Apple clang version 15.0.0 (clang-1500.0.40.1)
Target: arm64-apple-darwin23.4.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

@kylebarron
Copy link
Contributor

kylebarron commented May 14, 2024

If it helps, parquet-wasm has a lockfile with it building successfully. But you also need to ensure that you're using clang from homebrew, not the default one provided by macos, because that one doesn't have support for wasm.

export PATH="/opt/homebrew/opt/llvm/bin/:$PATH"
export CC=/opt/homebrew/opt/llvm/bin/clang
export AR=/opt/homebrew/opt/llvm/bin/llvm-ar
yarn build

@nleroy917
Copy link

Wow. That was it. So simple... it's odd because I've been using rust and wasm bindings for awhile now and never had an issue like this until now. I'm still a rust noob, however, so its hard for me to really dig into and trace the root cause of these things.

@kylebarron
Copy link
Contributor

It's because zstd-rs uses a C shim, which is uncommon among rust wasm projects

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants