@@ -192,7 +192,12 @@ fn build_cargo_project(
192
192
if let Ok ( ref old_flags) = old_flags {
193
193
env:: set_var (
194
194
RUSTFLAGS_ENV_VAR ,
195
- [ old_flags, "-C link-arg=-z -C link-arg=stack-size=65536" ] . join ( " " ) ,
195
+ [
196
+ old_flags,
197
+ // add -C target-cpu=mvp try to fix https://github.com/rust-lang/rust/issues/109807
198
+ "-C target-feature=-sign-ext -C target-cpu=mvp -C link-arg=-z -C link-arg=stack-size=65536" ,
199
+ ]
200
+ . join ( " " ) ,
196
201
) ;
197
202
}
198
203
@@ -284,28 +289,31 @@ fn strip_custom_sections(module: &mut Module) {
284
289
/// succeed, and the user will be encouraged to install it for further optimizations.
285
290
fn optimize_wasm ( crate_metadata : & CrateMetadata ) -> Result < ( ) > {
286
291
// Deserialize wasm module from a file.
287
- let mut module =
288
- parity_wasm:: deserialize_file ( & crate_metadata. original_wasm ) . context ( format ! (
289
- "Loading original wasm file '{}'" ,
290
- crate_metadata. original_wasm. display( )
291
- ) ) ?;
292
-
293
- // Perform optimization.
294
- //
295
- // In practice only tree-shaking is performed, i.e transitively removing all symbols that are
296
- // NOT used by the specified entry points.
297
- if pwasm_utils:: optimize (
298
- & mut module,
299
- [ "main" , "deploy" , "memory" , "hash_type" ] . to_vec ( ) ,
300
- )
301
- . is_err ( )
302
- {
303
- anyhow:: bail!( "Optimizer failed" ) ;
304
- }
305
- strip_custom_sections ( & mut module) ;
306
-
307
- parity_wasm:: serialize_to_file ( & crate_metadata. dest_wasm , module) ?;
308
-
292
+ // print!("crate_metadata.original_wasm: {:?}", crate_metadata.original_wasm);
293
+ // print!("crate_metadata.dest_wasm: {:?}", crate_metadata.dest_wasm);
294
+ // let mut module =
295
+ // parity_wasm::deserialize_file(&crate_metadata.original_wasm).context(format!(
296
+ // "Loading original wasm file '{}'",
297
+ // crate_metadata.original_wasm.display()
298
+ // ))?;
299
+
300
+ // // Perform optimization.
301
+ // //
302
+ // // In practice only tree-shaking is performed, i.e transitively removing all symbols that are
303
+ // // NOT used by the specified entry points.
304
+ // if pwasm_utils::optimize(
305
+ // &mut module,
306
+ // ["main", "deploy", "memory", "hash_type"].to_vec(),
307
+ // )
308
+ // .is_err()
309
+ // {
310
+ // anyhow::bail!("Optimizer failed");
311
+ // }
312
+ // strip_custom_sections(&mut module);
313
+
314
+ // parity_wasm::serialize_to_file(&crate_metadata.dest_wasm, module)?;
315
+
316
+ fs:: copy ( & crate_metadata. original_wasm , & crate_metadata. dest_wasm ) ?;
309
317
// check `wasm-opt` installed
310
318
if which:: which ( "wasm-opt" ) . is_err ( ) {
311
319
eprintln ! (
@@ -323,6 +331,7 @@ fn optimize_wasm(crate_metadata: &CrateMetadata) -> Result<()> {
323
331
324
332
let output = Command :: new ( "wasm-opt" )
325
333
. arg ( crate_metadata. dest_wasm . as_os_str ( ) )
334
+ . arg ( "--signext-lowering" )
326
335
. arg ( "-g" )
327
336
. arg ( "-O3" ) // execute -O3 optimization passes (spends potentially a lot of time optimizing)
328
337
. arg ( "-o" )
0 commit comments