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

Feature gate pkg-config for wasm32-unknown-unknown #205

Closed
kylebarron opened this issue Feb 6, 2023 · 6 comments
Closed

Feature gate pkg-config for wasm32-unknown-unknown #205

kylebarron opened this issue Feb 6, 2023 · 6 comments

Comments

@kylebarron
Copy link
Contributor

updating zstd-sys from 2.0.1 to 2.0.6 now brings in pkg-config. I'm not entirely sure why, but updating 2.0.1 to 2.0.6 causes wasm-pack to add

imports['env'] = require('env');

at the beginning of the file, which crashes in various environments. See related issues like rustwasm/wasm-pack#743, rustwasm/wasm-bindgen#2215.

I don't know the details here but was able to track this down where it worked in Node with 2.0.1 and failed in Node with 2.0.6, using cargo update --package zstd-sys 🤷‍♂️

@gyscos
Copy link
Owner

gyscos commented Feb 21, 2023

Hi, and thanks for the report!

To be honest I'm not entirely sure what's causing this. Is the mere presence of pkg-config in the build-dependency tree the issue with wasm-pack? It should only be used during the build step, not included in the actual compiled artifact, so I'm not sure why it would cause this. Might need some more investigation to better understand the issue.

@ppodolsky
Copy link

ppodolsky commented Feb 22, 2023

I've also faced the similar issue (not related to pkg-config, just these env imports), but it happened in debug builds only. I've disasmed WASM module and saw that in my case ZSTD_customMalloc referenced malloc and free which caused issues.

Luckily, building with thin and wasm features helped me. At least, worth to try.

@ppodolsky
Copy link

Even if it is not your issue, you may try to disasm wasm module with wabt and grep import "env", something like

wasm2wat you_binary.wasm | grep import

Then grep found symbols the same way, it may hint you where these imports come from.

@REASY
Copy link

REASY commented Mar 12, 2023

It seems related to the changes in optimization that caused the breakage #151 (comment)

@kylebarron
Copy link
Contributor Author

Finally getting back to this. In kylebarron/parquet-wasm#275 I can confirm that the issue happens between zstd-sys 2.0.1 and 2.0.3. Pinning to 2.0.3 brings in import env, while 2.0.1 does not.

This means that the root cause is not pkg-config because 2.0.3 does not include pkg-config

@kylebarron
Copy link
Contributor Author

kylebarron commented Aug 7, 2023

Well it looks like passing features = ["wasm", "thin"] does actually solve my issue after all!

(It took me a while to realize that it's possible to pass the features on even though zstd is a transitive dependency. I can just declare version = "*" and have the version be pinned by my direct dependencies)

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