Wasm module defined ____ functions which exceeds the maximum number allowed 6000 with dfx version 0.7.0-beta.3

Experiencing this issue with a test project on 0.7.0-beta.3 version of DFX. This works fine with 0.7.0-beta.2.

Note: there are no where near 6000 functions defined in this project.

I’ve uploaded a project that reproduces the issue here.

Thanks @shan I’ve flagged this internally; will follow up.

2 Likes

Hi @shan, we’ve added checks recently to avoid unnecessarily large wasm modules.

I see in your Dorsfile.toml that you are building your project in debug mode:

command = '''
    cargo build --target wasm32-unknown-unknown --package [email protected] &&
    ic-cdk-optimizer ./target/wasm32-unknown-unknown/debug/[email protected] -o ./target/wasm32-unknown-unknown/debug/[email protected]_opt.wasm
'''

I recommend compiling your project in release mode instead for a more efficient wasm. Try this instead:

command = '''
    cargo build --target wasm32-unknown-unknown --release --package [email protected] &&
    ic-cdk-optimizer ./target/wasm32-unknown-unknown/release/[email protected] -o ./target/wasm32-unknown-unknown/release/[email protected]_opt.wasm
'''
1 Like

Thanks; I built with --release earlier and still was encountering the error so figured it was a bug, but think I forgot to switch my wasm module definition in the build script to the release output. Is there any way to query for the number of functions defined in the wasm module besides decompiling it with something like wabt’s wasm-decompile and just inspecting it manually? Maybe with a build arg for the ic_cdk_optimizer ?

If you’ve got the wabt tools lying around anyway you can use wasm-objdump:

~\code\purescript-wasm [main ≡ +0 ~3 -0 !]> wasm-objdump.exe -h .\bytes.wasm

bytes.wasm:     file format wasm 0x1

Sections:

     Type start=0x0000000e end=0x0000001e (size=0x00000010) count: 3
 Function start=0x00000024 end=0x00000028 (size=0x00000004) count: 3
   Export start=0x0000002e end=0x00000036 (size=0x00000008) count: 1
     Code start=0x0000003c end=0x00000076 (size=0x0000003a) count: 3
2 Likes

Perfect, exactly what I was looking for. Thank you!

1 Like