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

Need web-assembly support . #48

Open
naskarsubhajit opened this issue Oct 8, 2018 · 5 comments
Open

Need web-assembly support . #48

naskarsubhajit opened this issue Oct 8, 2018 · 5 comments

Comments

@naskarsubhajit
Copy link

Hi,
It will be great help if you can guide to create a webassembly out of this library so as we can use it from browser.

@gyscos
Copy link
Owner

gyscos commented Oct 8, 2018

Hi!
Supporting wasm targets would be great indeed!
Right now it seems libc is the problem: we use libc types rather than std::os::raw so that zstd-sys can work with #[no_std], but libc doesn't seem to work well with wasm just yet...

I suppose one option might be to use feature flags to switch between libc and std, letting users choose between wasm and embedded.

Edit: the current master branch should now compile for the wasm32-unknown-unknown target. Haven't tested it yet.

@gyscos
Copy link
Owner

gyscos commented Mar 23, 2021

Hi again!
Like mentioned in #93, the current way to build C libraries for ASM is to use the emscripten backend:

# Make sure you have emscripten installed (such that `emcc` and `emar` are in the $PATH)
rustup target add wasm32-unknown-emscripten
cargo build --target wasm32-unknown-emscripten

@gyscos
Copy link
Owner

gyscos commented Mar 10, 2022

Since then, #139 has brought support for wasm32-unknown-unknown.
Right now dictionary-building and legacy support are not supported, so you'd need to disable the default features, but it should otherwise compile fine.

@yjhmelody
Copy link

Hi @gyscos Still have such problems when I read the doc https://github.com/gyscos/zstd-rs/wiki/Compile-for-WASM :

  CC_wasm32-unknown-unknown = None
  CC_wasm32_unknown_unknown = None
  TARGET_CC = None
  CC = Some("/usr/local/opt/llvm/bin/clang")
  CFLAGS_wasm32-unknown-unknown = None
  CFLAGS_wasm32_unknown_unknown = None
  TARGET_CFLAGS = None
  CFLAGS = None
  CRATE_CC_NO_DEFAULTS = None
  running: "/usr/local/opt/llvm/bin/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/yjhmelody/code/github/zstd-rs/zstd-safe/zstd-sys/target/wasm32-unknown-unknown/debug/build/zstd-sys-ff6d63836dba9265/out/zstd/lib/compress/zstd_fast.o" "-c" "zstd/lib/compress/zstd_fast.c"

  --- stderr


  error occurred: Failed to find tool. Is `clang` installed?

@jokemanfire
Copy link

Hi @gyscos Still have such problems when I read the doc https://github.com/gyscos/zstd-rs/wiki/Compile-for-WASM :

  CC_wasm32-unknown-unknown = None
  CC_wasm32_unknown_unknown = None
  TARGET_CC = None
  CC = Some("/usr/local/opt/llvm/bin/clang")
  CFLAGS_wasm32-unknown-unknown = None
  CFLAGS_wasm32_unknown_unknown = None
  TARGET_CFLAGS = None
  CFLAGS = None
  CRATE_CC_NO_DEFAULTS = None
  running: "/usr/local/opt/llvm/bin/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/yjhmelody/code/github/zstd-rs/zstd-safe/zstd-sys/target/wasm32-unknown-unknown/debug/build/zstd-sys-ff6d63836dba9265/out/zstd/lib/compress/zstd_fast.o" "-c" "zstd/lib/compress/zstd_fast.c"

  --- stderr


  error occurred: Failed to find tool. Is `clang` installed?

hello, I don't know if you have been resolved , but it looks like you didn't install the clang ..

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

4 participants