wasix-org / cargo-wasix

Cargo wrapper for working with Webassembly wasi(x).
Apache License 2.0
47 stars 9 forks source link

cargo wasix test error: Compilation error: Code for function is too large #55

Open tbraun96 opened 3 months ago

tbraun96 commented 3 months ago

While my code successfully compiles under ordinary targets (package: citadel_pqcrypto), running cargo wasix test --package citadel_pqcrypto fails with: error: Unable to compile "/Users/nologik/avarok/Citadel-Protocol/target/wasm32-wasmer-wasi/debug/deps/primary-0e896da8cb2e0eac.wasm" ╰─▶ 1: Compilation error: Code for function is too large

I thought that maybe running wasmer run --enable-all /Users/nologik/avarok/Citadel-Protocol/target/wasm32-wasmer-wasi/debug/deps/primary-0e896da8cb2e0eac.wasm would solve the problem by enabling larger memory, however, it did not (I get the same error as above). How can I work around this?

theduke commented 3 months ago

Which optimisation level did you compile your code with?

tbraun96 commented 3 months ago

The default. I didn't fiddle with the optimization level

tbraun96 commented 3 months ago

I had to create a custom build profile:

[profile.wasix]
opt-level = 3
inherits = "dev"

cargo wasix test --package=citadel_pqcrypto --profile=wasix

Looks like you're right, I had to set the opt-level to the highest. Thanks @theduke, been awhile since we last chatted.