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

Enable use of wasm-pack with panic_immediate_abort #737

Open
sffc opened this issue Nov 10, 2019 · 2 comments
Open

Enable use of wasm-pack with panic_immediate_abort #737

sffc opened this issue Nov 10, 2019 · 2 comments

Comments

@sffc
Copy link

sffc commented Nov 10, 2019

I'm trying to enable panic_immediate_abort in order to get smaller wasm size (see rust-lang/rust#54981). The workflow is to create a Xargo.toml file:

[dependencies]
std = {default-features=false, features=["panic_immediate_abort"]}

However, I can't figure out how to invoke xargo when using wasm-pack build. I can run xargo build --target wasm32-unknown-unknown --release, which I assume puts the output in the target directory without compiling it to the pkg directory, but then wasm-pack build just overwrites the target directory again with the non-xargo build.

@Ngalstyan4
Copy link

Ngalstyan4 commented Jun 4, 2020

I think being able to use xargo instead of cargo has more general uses as well and has to be supported. For example, using wasm32 simd extensions is currently unstable and requires recompiling libcore in order to enable them so in order to take advantage of these in WebAssembly, one has to recompile libcore, typically done by xargo.

For reference, I currently use

xargo build --target wasm32-unknown-unknown --release
wasm-bindgen target/wasm32-unknown-unknown/release/hello_wasm.wasm --out-dir pkg --target web

for the desired effect.

@Pauan
Copy link
Contributor

Pauan commented Jun 4, 2020

Note that it's no longer needed to use xargo, since build-std is now a part of Rust itself (nightly only):

wasm-pack build --release -- -Z build-std=std,panic_abort

This works for enabling simd as well. You simply create a .cargo/config file in your project which contains this:

[build]
rustflags = ["-C", "target-feature=+simd128"]

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

3 participants