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

fix: avoid enabling "js" feature of getrandom for wasm32 target #3309

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

ninegua
Copy link
Member

@ninegua ninegua commented Jan 2, 2025

The dependency "tower-request-id" will pull in crate "ulid", which enables the "js" feature of crate "getrandom" for wasm32 targets. This is at odds for our canister compilation using cargo because because cargo works at global level and both "js" and "custom" features would be enabled, and the result wasm file would have unresolved symbols like __wbindgen_placeholder__.

Note that this problem does not exist for bazel compilation, but still is worth fixing.

The fix is simply to require a more recent version of "ulid" that does not enable the "js" feature of "getrandom".

@github-actions github-actions bot added the fix label Jan 2, 2025
@ninegua ninegua force-pushed the paulliu/avoid-getrandom-js-feature branch from 5fb96fd to 574ba4a Compare January 2, 2025 14:37
@ninegua
Copy link
Member Author

ninegua commented Jan 5, 2025

Also made a PR upstream dylanhart/ulid-rs#86

@ninegua ninegua force-pushed the paulliu/avoid-getrandom-js-feature branch from 574ba4a to 2892429 Compare January 11, 2025 06:01
@ninegua
Copy link
Member Author

ninegua commented Jan 11, 2025

Now that the problem with ulid is fixed by upstream version 1.1.4.

But we have another problem (that didn't previously exist): quinn-proto and ring (whose versions were updated in the latest master) also force getrandom/js feature upon their dependencies. This is a harder problem to fix because ring seems to require getrandom/js in order to compile for wasm32-unknown-unknown.

github-merge-queue bot pushed a commit that referenced this pull request Jan 15, 2025
The following command currently failed to compile the registry canister
if running from the /ic/rs/registery/canister sub-directory:

cargo build --profile canister-release --target wasm32-unknown-unknown
--bin registry-canister

The fix is to make sure the feature `getrandom/custom` is enabled.

Note that the above command would succeed if running from the top-level
directory, but would produce incorrect wasm binary. This is because
cargo would bring in global dependencies that enable both
`getrandom/custom` and `getrandom/js` features, and the latter will lead
to wasm binaries having unwanted imports (See #3309 for more details).

Since this problem does not affect bazel builds, this fix is only
relevant to cargo.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant