attempt to fix playwright (#4198)

* disable precompress by default

* go back to nuking wasm dir in some cases

* enable more wasm-opt flags, use stable

* add better logging for wasm-opt failure
This commit is contained in:
Jonathan Kelley authored and GitHub committed 2025-05-25 18:51:40 +01:00
1 parent 22e0682f10
commit 9027ffc278
6 files changed
+568 -420

No files matched your search

+9 -2
View File
@@ -4,7 +4,7 @@ use std::path::Path;
/// Write these wasm bytes with a particular set of optimizations
pub async fn write_wasm(bytes: &[u8], output_path: &Path, cfg: &WasmOptConfig) -> Result<()> {
tokio::fs::write(output_path, bytes).await?;
std::fs::write(output_path, bytes)?;
optimize(output_path, output_path, cfg).await?;
Ok(())
}
@@ -32,6 +32,7 @@ async fn run_locally(input_path: &Path, output_path: &Path, cfg: &WasmOptConfig)
"--enable-reference-types",
"--enable-bulk-memory",
"--enable-mutable-globals",
"--enable-nontrapping-float-to-int",
];
if cfg.memory_packing {
@@ -60,7 +61,7 @@ async fn run_locally(input_path: &Path, output_path: &Path, cfg: &WasmOptConfig)
WasmOptLevel::Four => "-O4",
};
tokio::process::Command::new("wasm-opt")
let res = tokio::process::Command::new("wasm-opt")
.arg(input_path)
.arg(level)
.arg("-o")
@@ -69,6 +70,11 @@ async fn run_locally(input_path: &Path, output_path: &Path, cfg: &WasmOptConfig)
.output()
.await?;
if !res.status.success() {
let err = String::from_utf8_lossy(&res.stderr);
tracing::error!("wasm-opt failed with status code {}: {}", res.status, err);
}
Ok(())
}
@@ -95,6 +101,7 @@ async fn run_from_lib(
.enable_feature(wasm_opt::Feature::ReferenceTypes)
.enable_feature(wasm_opt::Feature::BulkMemory)
.enable_feature(wasm_opt::Feature::MutableGlobals)
.enable_feature(wasm_opt::Feature::TruncSat)
.add_pass(wasm_opt::Pass::MemoryPacking)
.debug_info(options.debug);