Skip to content

Commit

Permalink
fix: cargo build registry-canister for wasm32 target (#3408)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ninegua authored Jan 15, 2025
1 parent 572afbc commit d90e934
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions rs/registry/canister/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ prost = { workspace = true }
serde = { workspace = true }
url = { workspace = true }

[target.'cfg(target_arch = "wasm32")'.dependencies]
getrandom = { version = "0.2", features = [ "custom" ] }

[target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies]
assert_matches = { workspace = true }
candid_parser = { workspace = true }
Expand Down

0 comments on commit d90e934

Please sign in to comment.