zinkc/
utils.rs

1//! Zink compiler utils
2#![cfg(feature = "utils")]
3
4use std::path::Path;
5
6/// Run wasm-opt on the given WASM file.
7pub fn wasm_opt(input: impl AsRef<Path>, output: impl AsRef<Path>) -> anyhow::Result<()> {
8    ::wasm_opt::OptimizationOptions::new_opt_level_4()
9        .shrink_level(::wasm_opt::ShrinkLevel::Level2)
10        .debug_info(false)
11        .mvp_features_only()
12        .set_converge()
13        .run(&input, &output)
14        .map_err(Into::into)
15}