Skip to content

Commit

Permalink
wasm-builder: Also set mcpu for c deps (#3777)
Browse files Browse the repository at this point in the history
Closes: #3192
  • Loading branch information
bkchr authored Jul 18, 2024
1 parent e2d3b8b commit 35fcac7
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions substrate/utils/wasm-builder/src/wasm_project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,12 @@ fn maybe_compact_and_compress_wasm(
compact_blob_path.as_ref().and_then(|p| try_compress_blob(&p.0, blob_name));
(compact_blob_path, compact_compressed_blob_path)
} else {
// We at least want to lower the `sign-ext` code to `mvp`.
wasm_opt::OptimizationOptions::new_opt_level_0()
.add_pass(wasm_opt::Pass::SignextLowering)
.run(bloaty_blob_binary.bloaty_path(), bloaty_blob_binary.bloaty_path())
.expect("Failed to lower sign-ext in WASM binary.");

(None, None)
};

Expand Down Expand Up @@ -783,18 +789,15 @@ impl BuildConfiguration {
(None, false) => {
let profile = Profile::Release;
build_helper::warning!(
"Unknown cargo profile `{}`. Defaulted to `{:?}` for the runtime build.",
name,
profile,
"Unknown cargo profile `{name}`. Defaulted to `{profile:?}` for the runtime build.",
);
profile
},
// Invalid profile specified.
(None, true) => {
// We use println! + exit instead of a panic in order to have a cleaner output.
println!(
"Unexpected profile name: `{}`. One of the following is expected: {:?}",
name,
"Unexpected profile name: `{name}`. One of the following is expected: {:?}",
Profile::iter().map(|p| p.directory()).collect::<Vec<_>>(),
);
process::exit(1);
Expand Down Expand Up @@ -963,13 +966,16 @@ fn compact_wasm(
.mvp_features_only()
.debug_info(true)
.add_pass(wasm_opt::Pass::StripDwarf)
.add_pass(wasm_opt::Pass::SignextLowering)
.run(bloaty_binary.bloaty_path(), &wasm_compact_path)
.expect("Failed to compact generated WASM binary.");

println!(
"{} {}",
colorize_info_message("Compacted wasm in"),
colorize_info_message(format!("{:?}", start.elapsed()).as_str())
);

Some(WasmBinary(wasm_compact_path))
}

Expand Down

0 comments on commit 35fcac7

Please sign in to comment.