Skip to content

Commit 784361d

Browse files
committed
try to fix Unknown opcode 192
1 parent 0a2b55e commit 784361d

File tree

5 files changed

+40
-31
lines changed

5 files changed

+40
-31
lines changed

.github/workflows/workflow.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
- name: install rust nightly
2020
uses: actions-rs/toolchain@v1
2121
with:
22-
toolchain: nightly-2021-06-23
22+
toolchain: nightly-2024-02-25
2323
components: rustc-dev, rust-src, llvm-tools-preview
2424
- name: install cargo-liquid
2525
run: cargo install --path . --force

Cargo.lock

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ rustc_version = "0.2.3"
1616
cargo-xbuild = "0.6.6"
1717
toml = "0.5.6"
1818
tempfile = "3.1.0"
19-
parity-wasm = "0.41.0"
20-
pwasm-utils = "0.14.0"
19+
parity-wasm = "0.42.0"
20+
pwasm-utils = "0.19.0"
2121
which = "4.0.2"
2222
indicatif = { version = "0.15.0", features = ["rayon", "improved_unicode"] }
2323
console = "0.13.0"

rust-toolchain.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[toolchain]
2-
channel = "nightly-2023-01-03"
2+
channel = "nightly-2024-02-25"
33
components = [ "rust-src", "rustc-dev", "llvm-tools-preview" ]

src/main/cmd/build.rs

Lines changed: 32 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,12 @@ fn build_cargo_project(
192192
if let Ok(ref old_flags) = old_flags {
193193
env::set_var(
194194
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(" "),
196201
);
197202
}
198203

@@ -284,28 +289,31 @@ fn strip_custom_sections(module: &mut Module) {
284289
/// succeed, and the user will be encouraged to install it for further optimizations.
285290
fn optimize_wasm(crate_metadata: &CrateMetadata) -> Result<()> {
286291
// 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)?;
309317
// check `wasm-opt` installed
310318
if which::which("wasm-opt").is_err() {
311319
eprintln!(
@@ -323,6 +331,7 @@ fn optimize_wasm(crate_metadata: &CrateMetadata) -> Result<()> {
323331

324332
let output = Command::new("wasm-opt")
325333
.arg(crate_metadata.dest_wasm.as_os_str())
334+
.arg("--signext-lowering")
326335
.arg("-g")
327336
.arg("-O3") // execute -O3 optimization passes (spends potentially a lot of time optimizing)
328337
.arg("-o")

0 commit comments

Comments
 (0)