From 0c122ba9ad059288333509b61d9881b5e16c83f4 Mon Sep 17 00:00:00 2001 From: Vadim Smirnov Date: Sat, 22 Jul 2023 11:13:58 +0300 Subject: [PATCH] Use wasm-opt level 4 and shrink 2 --- utils/wasm-builder/src/optimize.rs | 1 + utils/wasm-builder/src/wasm_project.rs | 8 +++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/utils/wasm-builder/src/optimize.rs b/utils/wasm-builder/src/optimize.rs index 88c3aed181f..0ad73346ecf 100644 --- a/utils/wasm-builder/src/optimize.rs +++ b/utils/wasm-builder/src/optimize.rs @@ -277,6 +277,7 @@ pub fn do_optimization( "z" => OptimizationOptions::new_optimize_for_size_aggressively(), _ => panic!("Invalid optimization level {}", optimization_level), } + .shrink_level(wasm_opt::ShrinkLevel::Level2) .add_pass(Pass::Dae) .add_pass(Pass::Vacuum) // the memory in our module is imported, `wasm-opt` needs to be told that diff --git a/utils/wasm-builder/src/wasm_project.rs b/utils/wasm-builder/src/wasm_project.rs index 2b7d3a04d49..579ad88445d 100644 --- a/utils/wasm-builder/src/wasm_project.rs +++ b/utils/wasm-builder/src/wasm_project.rs @@ -31,6 +31,8 @@ use std::{ }; use toml::value::Table; +const OPT_LEVEL: &str = "z"; + /// Enum defining type of binary compiling: production program or metawasm. pub enum ProjectType { Program(Option), @@ -158,11 +160,11 @@ impl WasmProject { lib.insert("crate-type".into(), vec!["cdylib".to_string()].into()); let mut dev_profile = Table::new(); - dev_profile.insert("opt-level".into(), "s".into()); + dev_profile.insert("opt-level".into(), OPT_LEVEL.into()); let mut release_profile = Table::new(); release_profile.insert("lto".into(), "fat".into()); - release_profile.insert("opt-level".into(), "z".into()); + release_profile.insert("opt-level".into(), OPT_LEVEL.into()); release_profile.insert("codegen-units".into(), 1.into()); let mut production_profile = Table::new(); @@ -317,7 +319,7 @@ extern "C" fn metahash() {{ let path = optimize::optimize_wasm( original_copy_wasm_path.clone(), opt_wasm_path.clone(), - "z", + "4", true, ) .map(|res| {