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

Compiling tx_ibc.wasm on the ledger failed on M1 Mac #1831

Closed
Tracked by #2021
yito88 opened this issue Aug 18, 2023 · 2 comments · Fixed by #3275
Closed
Tracked by #2021

Compiling tx_ibc.wasm on the ledger failed on M1 Mac #1831

yito88 opened this issue Aug 18, 2023 · 2 comments · Fixed by #3275

Comments

@yito88
Copy link
Member

yito88 commented Aug 18, 2023

When starting the ledger, the pre-compilation for tx_ibc.wasm built on my local failed.

The application panicked (crashed).
Message:  called `Result::unwrap()` on an `Err` value: ImpossibleRelocation(Dynamic(DynamicLabel(0)))
Location: /Users/yuji/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wasmer-compiler-singlepass-2.3.0/src/machine_arm64.rs:2064

It happened from v0.21.1. v0.21.0 didn't happen. Upgrading ibc-rs might cause this issue.

Chip: Apple M1 Pro
OS: macOS 13.2.1

wasm-opt version 114 (version_114)

@yito88
Copy link
Member Author

yito88 commented Aug 20, 2023

I found a workaround.

In my investigation, the commit caused this issue.
It requires std in ibc-rs to receive a packet made by CosmosSDK. (So, the workaround can be applied only for testing between Namada chains.)
And, I changed RUSTFLAGS in the wasm building by referring to near/nearcore#9143.

But I'm not sure why RUSTFLAGS also needs to be changed. If std is the root cause, the RUSTFLAGS change is not needed.

Workaround:

diff --git a/core/Cargo.toml b/core/Cargo.toml
index 9401b7c3c..74d80cdfd 100644
--- a/core/Cargo.toml
+++ b/core/Cargo.toml
@@ -39,6 +39,7 @@ abciplus = [
 ]
 
 ibc-mocks = [
   "ibc/mocks",
+  "ibc/std",
 ]
 
@@ -72,7 +73,7 @@ ferveo = {optional = true, git = "https://github.com/anoma/ferveo", rev = "e5abd
 ferveo-common = {git = "https://github.com/anoma/ferveo", rev = "e5abd0acc938da90140351a65a26472eb495ce4d"}
 tpke = {package = "group-threshold-cryptography", optional = true, git = "https://github.com/anoma/ferveo", rev = "e5abd0acc938da90140351a65a26472eb495ce4d"}
 # TODO using the same version of tendermint-rs as we do here.
-ibc = { git = "https://github.com/heliaxdev/cosmos-ibc-rs.git", rev = "38a827d3901e590b2935ee5b6b81b4d67c399560", features = ["serde"], optional = true}
+ibc = { git = "https://github.com/heliaxdev/cosmos-ibc-rs.git", rev = "38a827d3901e590b2935ee5b6b81b4d67c399560", default-features = false, features = ["serde"], optional = true}
 ibc-proto = {git = "https://github.com/heliaxdev/ibc-proto-rs.git", rev = "31892ee743b2af017d5629b2af419ee20b6100c7", default-features = false, optional = true}
 ics23.workspace = true
 impl-num-traits = "0.1.2"
diff --git a/wasm/wasm_source/Makefile b/wasm/wasm_source/Makefile
index a88065355..dee19b9b7 100644
--- a/wasm/wasm_source/Makefile
+++ b/wasm/wasm_source/Makefile
@@ -56,7 +56,7 @@ fmt-check:
 # Build a selected wasm
 # Linker flag "-s" for stripping (https://github.com/rust-lang/cargo/issues/3483#issuecomment-431209957)
 $(wasms): %:
-	RUSTFLAGS='-C link-arg=-s' $(cargo) build --release --target wasm32-unknown-unknown --target-dir 'target' --features $@ && \
+	RUSTFLAGS='-C link-arg=-s -C target-cpu=mvp' $(cargo) build --release --target wasm32-unknown-unknown --target-dir 'target' --features $@ && \
 	cp "./target/wasm32-unknown-unknown/release/namada_wasm.wasm" ../[email protected]
 
 # Build a selected wasm in debug mode

@yito88
Copy link
Member Author

yito88 commented Sep 12, 2023

The workaround didn't work with 0.22.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants