Skip to content

Commit

Permalink
Use wasm-opt level 4 and shrink 2
Browse files Browse the repository at this point in the history
  • Loading branch information
ukint-vs committed Jul 22, 2023
1 parent ab9c97a commit 0c122ba
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions utils/wasm-builder/src/optimize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 5 additions & 3 deletions utils/wasm-builder/src/wasm_project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<MetadataRepr>),
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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| {
Expand Down

0 comments on commit 0c122ba

Please sign in to comment.