Hi everyone
I'm trying to build the crate sherpa-rs to wasm using wasm-pack on macOS
I can build it for Windows/Linux/macOS
But when I tried to build for wasm with
cd /tmp
git clone --recursive https://github.com/thewh1teagle/sherpa-rs
cd sherpa-rs
rustup target add wasm32-unknown-unknown
cargo build --no-default-features --target wasm32-unknown-unknown -p sherpa-rs-sys
it failed the following error:
Compiling sherpa-rs-sys v0.6.1 (/private/tmp/sherpa-rs/crates/sherpa-rs-sys)
error: failed to run custom build command for `sherpa-rs-sys v0.6.1 (/private/tmp/sherpa-rs/crates/sherpa-rs-sys)`
Caused by:
process didn't exit successfully: `/private/tmp/sherpa-rs/target/debug/build/sherpa-rs-sys-ddc28712cd8e2cd0/build-script-build` (exit status: 101)
--- stdout
cargo:rerun-if-changed=wrapper.h
cargo:rerun-if-changed=./sherpa-onnx
cargo:rerun-if-changed=dist.txt
cargo::rerun-if-env-changed=SHERPA_BUILD_SHARED_LIBS
cargo::rerun-if-env-changed=CMAKE_BUILD_PARALLEL_LEVEL
cargo::rerun-if-env-changed=CMAKE_VERBOSE
cargo::rerun-if-env-changed=SHERPA_LIB_PATH
cargo::rerun-if-env-changed=SHERPA_STATIC_CRT
cargo::rerun-if-env-changed=SHERPA_LIB_PROFILE
cargo::rerun-if-env-changed=BUILD_DEBUG
cargo:rerun-if-env-changed=TARGET
cargo:rerun-if-env-changed=BINDGEN_EXTRA_CLANG_ARGS_wasm32-unknown-unknown
cargo:rerun-if-env-changed=BINDGEN_EXTRA_CLANG_ARGS_wasm32_unknown_unknown
cargo:rerun-if-env-changed=BINDGEN_EXTRA_CLANG_ARGS
cargo:rerun-if-changed=wrapper.h
cargo:rerun-if-changed=./sherpa-onnx/sherpa-onnx/c-api/c-api.h
cargo:rerun-if-changed=/opt/homebrew/Cellar/llvm/19.1.5/lib/clang/19/include/stdint.h
CMAKE_TOOLCHAIN_FILE_wasm32-unknown-unknown = None
CMAKE_TOOLCHAIN_FILE_wasm32_unknown_unknown = None
TARGET_CMAKE_TOOLCHAIN_FILE = None
CMAKE_TOOLCHAIN_FILE = None
CMAKE_GENERATOR_wasm32-unknown-unknown = None
CMAKE_GENERATOR_wasm32_unknown_unknown = None
TARGET_CMAKE_GENERATOR = None
CMAKE_GENERATOR = None
CMAKE_PREFIX_PATH_wasm32-unknown-unknown = None
CMAKE_PREFIX_PATH_wasm32_unknown_unknown = None
TARGET_CMAKE_PREFIX_PATH = None
CMAKE_PREFIX_PATH = None
CMAKE_wasm32-unknown-unknown = None
CMAKE_wasm32_unknown_unknown = None
TARGET_CMAKE = None
CMAKE = None
running: cd "/private/tmp/sherpa-rs/target/wasm32-unknown-unknown/debug/build/sherpa-rs-sys-4e1b650b1e950cf4/out/build" && CMAKE_PREFIX_PATH="" "cmake" "/private/tmp/sherpa-rs/target/wasm32-unknown-unknown/debug/build/sherpa-rs-sys-4e1b650b1e950cf4/out/sherpa-onnx" "-DSHERPA_ONNX_ENABLE_C_API=ON" "-DSHERPA_ONNX_ENABLE_BINARY=OFF" "-DBUILD_SHARED_LIBS=ON" "-DSHERPA_ONNX_ENABLE_WEBSOCKET=OFF" "-DSHERPA_ONNX_ENABLE_TTS=OFF" "-DSHERPA_ONNX_BUILD_C_API_EXAMPLES=OFF" "-DCMAKE_SYSTEM_NAME=unknown" "-DCMAKE_SYSTEM_PROCESSOR=wasm32" "-DCMAKE_INSTALL_PREFIX=/private/tmp/sherpa-rs/target/wasm32-unknown-unknown/debug/build/sherpa-rs-sys-4e1b650b1e950cf4/out" "-DCMAKE_C_FLAGS= -ffunction-sections -fdata-sections -fPIC -fno-exceptions --target=wasm32-unknown-unknown" "-DCMAKE_C_COMPILER=/opt/homebrew/opt/llvm/bin/clang" "-DCMAKE_CXX_FLAGS= -ffunction-sections -fdata-sections -fPIC -fno-exceptions --target=wasm32-unknown-unknown" "-DCMAKE_CXX_COMPILER=/opt/homebrew/opt/llvm/bin/clang++" "-DCMAKE_ASM_FLAGS= -ffunction-sections -fdata-sections -fPIC -fno-exceptions --target=wasm32-unknown-unknown" "-DCMAKE_ASM_COMPILER=/opt/homebrew/opt/llvm/bin/clang" "-DCMAKE_BUILD_TYPE=Release"
-- The C compiler identification is Clang 19.1.5
-- The CXX compiler identification is Clang 19.1.5
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - failed
-- Check for working C compiler: /opt/homebrew/opt/llvm/bin/clang
-- Check for working C compiler: /opt/homebrew/opt/llvm/bin/clang - broken
-- Configuring incomplete, errors occurred!
--- stderr
cp: /private/tmp/sherpa-rs/crates/sherpa-rs-sys/sherpa-onnx/scripts/go/_internal/lib/x86_64-apple-darwin: No such file or directory
cp: /private/tmp/sherpa-rs/crates/sherpa-rs-sys/sherpa-onnx/scripts/go/_internal/lib/aarch64-apple-darwin: No such file or directory
cp: /private/tmp/sherpa-rs/crates/sherpa-rs-sys/sherpa-onnx/scripts/go/_internal/lib/x86_64-unknown-linux-gnu: No such file or directory
cp: /private/tmp/sherpa-rs/crates/sherpa-rs-sys/sherpa-onnx/scripts/go/_internal/vad-spoken-language-identification/run.sh: No such file or directory
cp: /private/tmp/sherpa-rs/crates/sherpa-rs-sys/sherpa-onnx/scripts/go/_internal/vad-spoken-language-identification/main.go: No such file or directory
System is unknown to cmake, create:
Platform/unknown to use this system, please post your config file on discourse.cmake.org so it can be added to cmake
System is unknown to cmake, create:
Platform/unknown to use this system, please post your config file on discourse.cmake.org so it can be added to cmake
System is unknown to cmake, create:
Platform/unknown to use this system, please post your config file on discourse.cmake.org so it can be added to cmake
CMake Error at /Applications/CMake.app/Contents/share/cmake-3.30/Modules/CMakeTestCCompiler.cmake:67 (message):
The C compiler
"/opt/homebrew/opt/llvm/bin/clang"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: '/tmp/sherpa-rs/target/wasm32-unknown-unknown/debug/build/sherpa-rs-sys-4e1b650b1e950cf4/out/build/CMakeFiles/CMakeScratch/TryCompile-Hdvjw6'
Run Build Command(s): /Applications/CMake.app/Contents/bin/cmake -E env VERBOSE=1 /usr/bin/make -f Makefile cmTC_f38b3/fast
/Applications/Xcode.app/Contents/Developer/usr/bin/make -f CMakeFiles/cmTC_f38b3.dir/build.make CMakeFiles/cmTC_f38b3.dir/build
Building C object CMakeFiles/cmTC_f38b3.dir/testCCompiler.c.obj
/opt/homebrew/opt/llvm/bin/clang -ffunction-sections -fdata-sections -fPIC -fno-exceptions --target=wasm32-unknown-unknown -MD -MT CMakeFiles/cmTC_f38b3.dir/testCCompiler.c.obj -MF CMakeFiles/cmTC_f38b3.dir/testCCompiler.c.obj.d -o CMakeFiles/cmTC_f38b3.dir/testCCompiler.c.obj -c /tmp/sherpa-rs/target/wasm32-unknown-unknown/debug/build/sherpa-rs-sys-4e1b650b1e950cf4/out/build/CMakeFiles/CMakeScratch/TryCompile-Hdvjw6/testCCompiler.c
Linking C executable cmTC_f38b3
/Applications/CMake.app/Contents/bin/cmake -E cmake_link_script CMakeFiles/cmTC_f38b3.dir/link.txt --verbose=1
/opt/homebrew/opt/llvm/bin/clang -ffunction-sections -fdata-sections -fPIC -fno-exceptions --target=wasm32-unknown-unknown -L/opt/homebrew/opt/ruby/lib CMakeFiles/cmTC_f38b3.dir/testCCompiler.c.obj -o cmTC_f38b3
clang: error: unable to execute command: Executable "wasm-ld" doesn't exist!
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [cmTC_f38b3] Error 1
make: *** [cmTC_f38b3/fast] Error 2
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:8 (project)
thread 'main' panicked at /Users/user/.cargo/registry/src/index.crates.io-6f17d22bba15001f/cmake-0.1.50/src/lib.rs:1098:5:
command did not execute successfully, got: exit status: 1
build script failed, must exit now
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
I would appreciate any guidance or tips on how to resolve this issue. Thank you in advance!
Maybe related: Status of rust+C bindings for wasm targets · Issue #291 · rustwasm/team · GitHub