Can wasm-pack compile a rust project including C++ code that uses stdlib?

636 views Asked by At

I am trying to compile a rust project into WebAssembly with wasm-pack. One of its dependencies is a rust wrapper around C++ code. This dependency can, on its own, be successfully compiled to WebAssembly with Emscripten. However if I try to compile my project or the dependency itself with wasm-pack I get the following error:

  running: "clang" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "--target=wasm32-unknown-unknown" "-I" "src" "-Wall" "
-Wextra" "-o" "/home/ahelwer/src/tlaplus/tree-sitter-tlaplus/target/wasm32-unknown-unknown/release/build/tree-sitter-tlaplus-90
d9bfea3134c6dd/out/src/parser.o" "-c" "src/parser.c"
  cargo:warning=In file included from src/parser.c:1:
  cargo:warning=src/tree_sitter/parser.h:10:10: fatal error: 'stdlib.h' file not found
  cargo:warning=#include <stdlib.h>
  cargo:warning=         ^~~~~~~~~~
  cargo:warning=1 error generated.
  exit status: 1

So it can't find libc. I know Emscripten includes the ability to link programs against the libc (based on musl) it comes with. Does wasm-pack also have this ability? Do you have to modify the build.rs file of the native dependency in some way?

0

There are 0 answers