Skip to content
This repository has been archived by the owner on Sep 12, 2023. It is now read-only.

c library ssvmup build can not find <stdlib.h> #6

Open
cs686 opened this issue Aug 5, 2020 · 3 comments
Open

c library ssvmup build can not find <stdlib.h> #6

cs686 opened this issue Aug 5, 2020 · 3 comments

Comments

@cs686
Copy link

cs686 commented Aug 5, 2020

I use libdeflate lib, but can not ssvmup build
image

@hydai
Copy link
Member

hydai commented Aug 5, 2020

Hi @cs686,

Thanks for your information.
ssvmup relies on wasm-bindgen and wasm32-wasi backend.

Unfortunately, the current version of wasm-bindgen/wasm32-wasi backend has some issues when linking rust application with C/C++ libraries. You can find more details in this issue( https://github.com/rustwasm/wasm-bindgen/pull/2209/files ).

Currently, we don't have an easy solution for it.

I've tried libdeflate-sys with standalone wasm32-wasi backend, and it also doesn't work. The error message is attached below:

$ cargo build --target wasm32-wasi

   Compiling libdeflate-sys v0.5.0
The following warnings were emitted during compilation:
warning: libdeflate/lib/aligned_malloc.c:36:10: fatal error: 'stdlib.h' file not found
warning: #include <stdlib.h>
warning:          ^~~~~~~~~~
warning: 1 error generated.

error: failed to run custom build command for `libdeflate-sys v0.5.0`

Caused by:
  process didn't exit successfully: `/home/hydai/workspace/wasm-learning/nodejs/libdeflater/target/release/build/libdeflate-sys-ec0c99f338ab6167/bui
ld-script-build` (exit code: 1)
--- stdout
TARGET = Some("wasm32-wasi")
OPT_LEVEL = Some("3")
HOST = Some("x86_64-unknown-linux-gnu")
CC_wasm32-wasi = None
CC_wasm32_wasi = None
TARGET_CC = None
CC = None
CFLAGS_wasm32-wasi = None
CFLAGS_wasm32_wasi = None
TARGET_CFLAGS = None
CFLAGS = None
CRATE_CC_NO_DEFAULTS = None
DEBUG = Some("false")
running: "clang" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "--target=wasm32-wasi" "-I" "libdeflate/" "-I" "libdeflate/lib/" "-I" "libdef
late/common/" "-o" "/home/hydai/workspace/wasm-learning/nodejs/libdeflater/target/wasm32-wasi/release/build/libdeflate-sys-ab91f28b9c57ff1b/out/lib/
libdeflate/lib/aligned_malloc.o" "-c" "libdeflate/lib/aligned_malloc.c"
cargo:warning=libdeflate/lib/aligned_malloc.c:36:10: fatal error: 'stdlib.h' file not found
cargo:warning=#include <stdlib.h>
cargo:warning=         ^~~~~~~~~~
cargo:warning=1 error generated.
exit code: 1

--- stderr


error occurred: Command "clang" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "--target=wasm32-wasi" "-I" "libdeflate/" "-I" "libdeflate/lib
/" "-I" "libdeflate/common/" "-o" "/home/hydai/workspace/wasm-learning/nodejs/libdeflater/target/wasm32-wasi/release/build/libdeflate-sys-ab91f28b9c
57ff1b/out/lib/libdeflate/lib/aligned_malloc.o" "-c" "libdeflate/lib/aligned_malloc.c" with args "clang" did not execute successfully (status code exit code: 1).

@juntao
Copy link
Member

juntao commented Aug 5, 2020

The sys C libraries often make operating system calls that are not permitted by the WebAssembly sandbox. WebAssembly only allows very limited number of system calls via the WASI interface.

In this particular case, I would recommend to use a pure Rust implementation of deflate.

https://docs.rs/deflate/0.8.6/deflate/

@cs686
Copy link
Author

cs686 commented Aug 6, 2020

@juntao thank,I will try

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

No branches or pull requests

3 participants