Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

# UNRELEASED

### feat: Wasm optimization failure issues a warning instead of error

The optimization functionality provided by `ic_wasm::optimize" cannot handle Wasm modules that contains 64-bit table.
Instead of blocking the build, such optimization failure will issue a warning.

### Frontend canister

Sets the `ic_env` cookie for all HTML files only if the canister environment changed in the `commit_batch` method.
Expand Down
2 changes: 1 addition & 1 deletion e2e/assets/memory64/dfx.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"type": "custom",
"candid": "empty.did",
"wasm": "m64.wasm",
"build": "echo \"generated from (module (memory i64 0 0))\"",
"build": "echo \"generated from (module (memory i64 0 0) (table i64 1 10 funcref))\"",
"shrink": true,
"optimize": "Oz",
"gzip": true
Expand Down
Binary file modified e2e/assets/memory64/m64.wasm
Binary file not shown.
3 changes: 3 additions & 0 deletions e2e/tests-dfx/build.bash
Original file line number Diff line number Diff line change
Expand Up @@ -370,4 +370,7 @@ teardown() {
@test "dfx build can post-process memory64 Wasm module" {
install_asset memory64
assert_command dfx build --check
# the module contains table64 which is not supported by ic_wasm::optimize
# optimization failure doesn't fail the build, but a warning is issued
assert_contains "WARN: Failed to optimize the Wasm module:"
}
17 changes: 14 additions & 3 deletions src/dfx/src/lib/models/canister.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,20 @@ impl Canister {
// optimize or shrink
if let Some(level) = info.get_optimize() {
trace!(logger, "Optimizing Wasm at level {}", level);
ic_wasm::optimize::optimize(&mut m, &wasm_opt_level_convert(level), false, &None, true)
.context("Failed to optimize the Wasm module.")?;
modified = true;
match ic_wasm::optimize::optimize(
&mut m,
&wasm_opt_level_convert(level),
false,
&None,
true,
) {
Ok(()) => {
modified = true;
}
Err(e) => {
warn!(logger, "Failed to optimize the Wasm module: {}", e);
}
}
} else if info.get_shrink() == Some(true)
|| (info.get_shrink().is_none() && (info.is_rust() || info.is_motoko()))
{
Expand Down