Skip to content

Commit

Permalink
chore: sync with remove meta wasm
Browse files Browse the repository at this point in the history
fix: typo
  • Loading branch information
ecol-master committed Feb 23, 2025
1 parent fbe811d commit 36be227
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 66 deletions.
3 changes: 1 addition & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions examples/big-data-section/proptest-regressions/lib.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Seeds for failure cases proptest has generated in the past. It is
# automatically read and these particular cases re-run before any
# novel cases are generated.
#
# It is recommended to check this file in to source control so that
# everyone who runs the test benefits from these saved cases.
cc 434c860d37beed8bc731d0f33e2cb225bf1807036c20b9ca50bf90962fef0d12 # shrinks to payload = [0, 0]
5 changes: 1 addition & 4 deletions examples/big-data-section/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,7 @@ mod tests {
let sys = System::new();
sys.init_logger();

let prog = Program::from_file(
&sys,
"../../target/wasm32-unknown-unknown/debug/demo_big_data_section.opt.wasm",
);
let prog = Program::current_opt(&sys);
sys.mint_to(gtest::constants::DEFAULT_USER_ALICE, 100000000000);

let expected_value = DataAccess::from_payload(&payload).expect("").constant();
Expand Down
5 changes: 1 addition & 4 deletions utils/wasm-builder/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,4 @@ gear-core.workspace = true
gear-wasm-instrument.workspace = true
gear-wasm-optimizer.workspace = true
rustc_version.workspace = true
itertools.workspace = true

[features]
wasm-opt = ["gear-wasm-optimizer/wasm-opt"]
itertools.workspace = true
1 change: 0 additions & 1 deletion utils/wasm-optimizer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ rust-version.workspace = true
[dependencies]
anyhow = { workspace = true, features = ["std"] }
gear-wasm-instrument.workspace = true
wasm-opt = { workspace = true, optional = true }
regex.workspace = true
log.workspace = true
wasmparser.workspace = true
Expand Down
52 changes: 2 additions & 50 deletions utils/wasm-optimizer/src/optimize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,7 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

#[cfg(not(feature = "wasm-opt"))]
use colored::Colorize;
#[cfg(not(feature = "wasm-opt"))]
use std::process::Command;

#[cfg(feature = "wasm-opt")]
use wasm_opt::{OptimizationOptions, Pass};

use crate::stack_end;
use anyhow::{anyhow, Context, Result};
Expand Down Expand Up @@ -188,6 +182,8 @@ pub fn do_optimization<P: AsRef<Path>>(
.arg("-mvp")
.arg("--enable-sign-ext")
.arg("--enable-mutable-globals")
.arg("--limit-segments")
.arg("--pass-arg=limit-segments@1024")
// the memory in our module is imported, `wasm-opt` needs to be told that
// the memory is initialized to zeroes, otherwise it won't run the
// memory-packing pre-pass.
Expand All @@ -211,47 +207,3 @@ pub fn do_optimization<P: AsRef<Path>>(
}
Ok(())
}

#[cfg(feature = "wasm-opt")]
/// Optimizes the Wasm supplied as `crate_metadata.dest_wasm` using
/// `wasm-opt`.
///
/// The supplied `optimization_level` denotes the number of optimization passes,
/// resulting in potentially a lot of time spent optimizing.
///
/// If successful, the optimized Wasm is written to `dest_optimized`.
pub fn do_optimization<P: AsRef<Path>>(
dest_wasm: P,
dest_optimized: P,
optimization_level: &str,
keep_debug_symbols: bool,
) -> Result<()> {
log::info!(
"Optimization level passed to wasm-opt: {}",
optimization_level
);
match optimization_level {
"0" => OptimizationOptions::new_opt_level_0(),
"1" => OptimizationOptions::new_opt_level_1(),
"2" => OptimizationOptions::new_opt_level_2(),
"3" => OptimizationOptions::new_opt_level_3(),
"4" => OptimizationOptions::new_opt_level_4(),
"s" => OptimizationOptions::new_optimize_for_size(),
"z" => OptimizationOptions::new_optimize_for_size_aggressively(),
_ => panic!("Invalid optimization level {}", optimization_level),
}
.mvp_features_only()
.enable_feature(wasm_opt::Feature::SignExt)
.enable_feature(wasm_opt::Feature::MutableGlobals)
.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
// the memory is initialized to zeroes, otherwise it won't run the
// memory-packing pre-pass.
.zero_filled_memory(true)
.debug_info(keep_debug_symbols)
.run(dest_wasm, dest_optimized)?;

Ok(())
}
6 changes: 1 addition & 5 deletions utils/wasm-proc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,4 @@ clap = { workspace = true, features = ["derive"] }
log.workspace = true
env_logger.workspace = true
gear-wasm-builder.workspace = true
gear-wasm-instrument = { workspace = true, features = ["std"] }

[features]
default = ["wasm-opt"]
wasm-opt = ["gear-wasm-builder/wasm-opt"]
gear-wasm-instrument = { workspace = true, features = ["std"] }

0 comments on commit 36be227

Please sign in to comment.