Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

try to fix Unknown opcode 192 #29

Merged
merged 1 commit into from
Jun 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,12 @@ jobs:
- name: install rust nightly
uses: actions-rs/toolchain@v1
with:
toolchain: nightly-2021-06-23
toolchain: nightly-2024-02-25
components: rustc-dev, rust-src, llvm-tools-preview
- name: install cargo-liquid
run: cargo install --path . --force
- name: install wasm-opt
run: cargo install wasm-opt --force
- name: compile test contract
run: cd .\tests\conflict_analysis_test\contract && cargo liquid build
- name: setup python
Expand Down
8 changes: 4 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ rustc_version = "0.2.3"
cargo-xbuild = "0.6.6"
toml = "0.5.6"
tempfile = "3.1.0"
parity-wasm = "0.41.0"
pwasm-utils = "0.14.0"
parity-wasm = "0.42.0"
pwasm-utils = "0.19.0"
which = "4.0.2"
indicatif = { version = "0.15.0", features = ["rayon", "improved_unicode"] }
console = "0.13.0"
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[toolchain]
channel = "nightly-2023-01-03"
channel = "nightly-2024-02-25"
components = [ "rust-src", "rustc-dev", "llvm-tools-preview" ]
55 changes: 32 additions & 23 deletions src/main/cmd/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,12 @@ fn build_cargo_project(
if let Ok(ref old_flags) = old_flags {
env::set_var(
RUSTFLAGS_ENV_VAR,
[old_flags, "-C link-arg=-z -C link-arg=stack-size=65536"].join(" "),
[
old_flags,
// add -C target-cpu=mvp try to fix https://github.com/rust-lang/rust/issues/109807
"-C target-feature=-sign-ext -C target-cpu=mvp -C link-arg=-z -C link-arg=stack-size=65536",
]
.join(" "),
);
}

Expand Down Expand Up @@ -284,28 +289,31 @@ fn strip_custom_sections(module: &mut Module) {
/// succeed, and the user will be encouraged to install it for further optimizations.
fn optimize_wasm(crate_metadata: &CrateMetadata) -> Result<()> {
// Deserialize wasm module from a file.
let mut module =
parity_wasm::deserialize_file(&crate_metadata.original_wasm).context(format!(
"Loading original wasm file '{}'",
crate_metadata.original_wasm.display()
))?;

// Perform optimization.
//
// In practice only tree-shaking is performed, i.e transitively removing all symbols that are
// NOT used by the specified entry points.
if pwasm_utils::optimize(
&mut module,
["main", "deploy", "memory", "hash_type"].to_vec(),
)
.is_err()
{
anyhow::bail!("Optimizer failed");
}
strip_custom_sections(&mut module);

parity_wasm::serialize_to_file(&crate_metadata.dest_wasm, module)?;

// print!("crate_metadata.original_wasm: {:?}", crate_metadata.original_wasm);
// print!("crate_metadata.dest_wasm: {:?}", crate_metadata.dest_wasm);
// let mut module =
// parity_wasm::deserialize_file(&crate_metadata.original_wasm).context(format!(
// "Loading original wasm file '{}'",
// crate_metadata.original_wasm.display()
// ))?;

// // Perform optimization.
// //
// // In practice only tree-shaking is performed, i.e transitively removing all symbols that are
// // NOT used by the specified entry points.
// if pwasm_utils::optimize(
// &mut module,
// ["main", "deploy", "memory", "hash_type"].to_vec(),
// )
// .is_err()
// {
// anyhow::bail!("Optimizer failed");
// }
// strip_custom_sections(&mut module);

// parity_wasm::serialize_to_file(&crate_metadata.dest_wasm, module)?;

fs::copy(&crate_metadata.original_wasm, &crate_metadata.dest_wasm)?;
// check `wasm-opt` installed
if which::which("wasm-opt").is_err() {
eprintln!(
Expand All @@ -323,6 +331,7 @@ fn optimize_wasm(crate_metadata: &CrateMetadata) -> Result<()> {

let output = Command::new("wasm-opt")
.arg(crate_metadata.dest_wasm.as_os_str())
.arg("--signext-lowering")
.arg("-g")
.arg("-O3") // execute -O3 optimization passes (spends potentially a lot of time optimizing)
.arg("-o")
Expand Down
Loading