diff --git a/compiler/gen_wasm/src/lib.rs b/compiler/gen_wasm/src/lib.rs index d1f71b9619..4f832d452c 100644 --- a/compiler/gen_wasm/src/lib.rs +++ b/compiler/gen_wasm/src/lib.rs @@ -96,7 +96,8 @@ pub fn build_module_help<'a>( let initial_module = WasmModule::preload(env.arena, preload_bytes); // Adjust Wasm function indices to account for functions from the object file - let fn_index_offset: u32 = initial_module.import.function_count + initial_module.code.preloaded_count; + let fn_index_offset: u32 = + initial_module.import.function_count + initial_module.code.preloaded_count; // Get a map of name to index for the preloaded functions // Assumes the preloaded object file has all symbols exported, as per `zig build-lib -dymamic` diff --git a/compiler/gen_wasm/src/wasm_module/dead_code.rs b/compiler/gen_wasm/src/wasm_module/dead_code.rs index 7d46ae95c5..49d2f0d6d8 100644 --- a/compiler/gen_wasm/src/wasm_module/dead_code.rs +++ b/compiler/gen_wasm/src/wasm_module/dead_code.rs @@ -140,6 +140,9 @@ pub fn trace_function_deps<'a, Indices: IntoIterator>( if next_trace.is_empty() { break; } + next_trace.sort_unstable(); + next_trace.dedup(); + current_trace.clone_from(&next_trace); next_trace.clear(); }