Stream: git-wasmtime

Topic: wasmtime / Issue #1998 AArch64 Android compilation fails:...


view this post on Zulip Wasmtime GitHub notifications bot (Jul 09 2020 at 10:22):

Rochet2 opened Issue #1998:

When compiling wasmtime for android aarch64, an error occurs:

$ cargo +nightly build --target aarch64-linux-android --release
   Compiling wasmtime-runtime v0.18.0 (/home/local/rimi/Documents/test/wasmtimetest/android_runtime/wasmtime/crates/runtime)
error: unsupported platform
   --> wasmtime/crates/runtime/src/traphandlers.rs:171:21
    |
171 |                     compile_error!("unsupported platform");
    |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0308]: mismatched types
   --> wasmtime/crates/runtime/src/traphandlers.rs:156:52
    |
156 |         unsafe fn get_pc(cx: *mut libc::c_void) -> *const u8 {
    |                   ------                           ^^^^^^^^^ expected *-ptr, found `()`
    |                   |
    |                   implicitly returns `()` as its body has no tail or `return` expression
    |
    = note: expected raw pointer `*const u8`
                 found unit type `()`

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0308`.
error: could not compile `wasmtime-runtime`.

To learn more, run the command again with --verbose.

The error comes from this code: https://github.com/bytecodealliance/wasmtime/blob/c9a3f05afd45961b0b397f97c4ad79cd7a7c807d/crates/runtime/src/traphandlers.rs#L156-L174

The reason seems to be that there is no aarch64 android case in the code.
By doing the following change I am able to compile successfully, but I am unsure if this is a proper fix to the issue.
The diff was generated for 5c35a9631cdffc00a32b416f9cb0b80f182b716e.

diff --git a/crates/runtime/src/traphandlers.rs b/crates/runtime/src/traphandlers.rs
index 0bd6f2cd1b..198d03a640 100644
--- a/crates/runtime/src/traphandlers.rs
+++ b/crates/runtime/src/traphandlers.rs
@@ -161,7 +161,7 @@ cfg_if::cfg_if! {
                 } else if #[cfg(all(target_os = "linux", target_arch = "x86"))] {
                     let cx = &*(cx as *const libc::ucontext_t);
                     cx.uc_mcontext.gregs[libc::REG_EIP as usize] as *const u8
-                } else if #[cfg(all(target_os = "linux", target_arch = "aarch64"))] {
+                } else if #[cfg(all(any(target_os = "linux", target_os = "android"), target_arch = "aarch64"))] {
                     let cx = &*(cx as *const libc::ucontext_t);
                     cx.uc_mcontext.pc as *const u8
                 } else if #[cfg(target_os = "macos")] {
```*
~~~

view this post on Zulip Wasmtime GitHub notifications bot (Jul 09 2020 at 10:23):

Rochet2 edited Issue #1998:

When compiling wasmtime for android aarch64, an error occurs:

$ cargo +nightly build --target aarch64-linux-android --release
   Compiling wasmtime-runtime v0.18.0 (/home/local/rimi/Documents/test/wasmtimetest/android_runtime/wasmtime/crates/runtime)
error: unsupported platform
   --> wasmtime/crates/runtime/src/traphandlers.rs:171:21
    |
171 |                     compile_error!("unsupported platform");
    |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0308]: mismatched types
   --> wasmtime/crates/runtime/src/traphandlers.rs:156:52
    |
156 |         unsafe fn get_pc(cx: *mut libc::c_void) -> *const u8 {
    |                   ------                           ^^^^^^^^^ expected *-ptr, found `()`
    |                   |
    |                   implicitly returns `()` as its body has no tail or `return` expression
    |
    = note: expected raw pointer `*const u8`
                 found unit type `()`

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0308`.
error: could not compile `wasmtime-runtime`.

To learn more, run the command again with --verbose.

The error comes from this code: https://github.com/bytecodealliance/wasmtime/blob/c9a3f05afd45961b0b397f97c4ad79cd7a7c807d/crates/runtime/src/traphandlers.rs#L156-L174

The reason seems to be that there is no aarch64 android case in the code.
By doing the following change I am able to compile successfully, but I am unsure if this is a proper fix to the issue.
The diff was generated for 5c35a9631cdffc00a32b416f9cb0b80f182b716e.

diff --git a/crates/runtime/src/traphandlers.rs b/crates/runtime/src/traphandlers.rs
index 0bd6f2cd1b..198d03a640 100644
--- a/crates/runtime/src/traphandlers.rs
+++ b/crates/runtime/src/traphandlers.rs
@@ -161,7 +161,7 @@ cfg_if::cfg_if! {
                 } else if #[cfg(all(target_os = "linux", target_arch = "x86"))] {
                     let cx = &*(cx as *const libc::ucontext_t);
                     cx.uc_mcontext.gregs[libc::REG_EIP as usize] as *const u8
-                } else if #[cfg(all(target_os = "linux", target_arch = "aarch64"))] {
+                } else if #[cfg(all(any(target_os = "linux", target_os = "android"), target_arch = "aarch64"))] {
                     let cx = &*(cx as *const libc::ucontext_t);
                     cx.uc_mcontext.pc as *const u8
                 } else if #[cfg(target_os = "macos")] {

view this post on Zulip Wasmtime GitHub notifications bot (Jul 09 2020 at 12:16):

Rochet2 edited Issue #1998:

Error

When compiling wasmtime for android aarch64, an error occurs:

$ cargo +nightly build --target aarch64-linux-android --release
   Compiling wasmtime-runtime v0.18.0 (/home/local/rimi/Documents/test/wasmtimetest/android_runtime/wasmtime/crates/runtime)
error: unsupported platform
   --> wasmtime/crates/runtime/src/traphandlers.rs:171:21
    |
171 |                     compile_error!("unsupported platform");
    |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0308]: mismatched types
   --> wasmtime/crates/runtime/src/traphandlers.rs:156:52
    |
156 |         unsafe fn get_pc(cx: *mut libc::c_void) -> *const u8 {
    |                   ------                           ^^^^^^^^^ expected *-ptr, found `()`
    |                   |
    |                   implicitly returns `()` as its body has no tail or `return` expression
    |
    = note: expected raw pointer `*const u8`
                 found unit type `()`

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0308`.
error: could not compile `wasmtime-runtime`.

To learn more, run the command again with --verbose.

Problem

The error comes from this code: https://github.com/bytecodealliance/wasmtime/blob/c9a3f05afd45961b0b397f97c4ad79cd7a7c807d/crates/runtime/src/traphandlers.rs#L156-L174
The reason seems to be that there is no aarch64 android case in the code.

Proposed solution

By doing the following change I am able to compile successfully, but I am unsure if this is a proper fix to the issue.
The diff was generated for 5c35a9631cdffc00a32b416f9cb0b80f182b716e.

diff --git a/crates/runtime/src/traphandlers.rs b/crates/runtime/src/traphandlers.rs
index 0bd6f2cd1b..198d03a640 100644
--- a/crates/runtime/src/traphandlers.rs
+++ b/crates/runtime/src/traphandlers.rs
@@ -161,7 +161,7 @@ cfg_if::cfg_if! {
                 } else if #[cfg(all(target_os = "linux", target_arch = "x86"))] {
                     let cx = &*(cx as *const libc::ucontext_t);
                     cx.uc_mcontext.gregs[libc::REG_EIP as usize] as *const u8
-                } else if #[cfg(all(target_os = "linux", target_arch = "aarch64"))] {
+                } else if #[cfg(all(any(target_os = "linux", target_os = "android"), target_arch = "aarch64"))] {
                     let cx = &*(cx as *const libc::ucontext_t);
                     cx.uc_mcontext.pc as *const u8
                 } else if #[cfg(target_os = "macos")] {

view this post on Zulip Wasmtime GitHub notifications bot (Jul 09 2020 at 13:54):

alexcrichton commented on Issue #1998:

If that patch works for you then it looks right to me too, would you be interested in sending a PR for this?

view this post on Zulip Wasmtime GitHub notifications bot (Jul 09 2020 at 16:04):

alexcrichton commented on Issue #1998:

Addressed in https://github.com/bytecodealliance/wasmtime/pull/2002

view this post on Zulip Wasmtime GitHub notifications bot (Jul 09 2020 at 16:04):

alexcrichton closed Issue #1998:

Error

When compiling wasmtime for android aarch64, an error occurs:

$ cargo +nightly build --target aarch64-linux-android --release
   Compiling wasmtime-runtime v0.18.0 (/home/local/rimi/Documents/test/wasmtimetest/android_runtime/wasmtime/crates/runtime)
error: unsupported platform
   --> wasmtime/crates/runtime/src/traphandlers.rs:171:21
    |
171 |                     compile_error!("unsupported platform");
    |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0308]: mismatched types
   --> wasmtime/crates/runtime/src/traphandlers.rs:156:52
    |
156 |         unsafe fn get_pc(cx: *mut libc::c_void) -> *const u8 {
    |                   ------                           ^^^^^^^^^ expected *-ptr, found `()`
    |                   |
    |                   implicitly returns `()` as its body has no tail or `return` expression
    |
    = note: expected raw pointer `*const u8`
                 found unit type `()`

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0308`.
error: could not compile `wasmtime-runtime`.

To learn more, run the command again with --verbose.

Problem

The error comes from this code: https://github.com/bytecodealliance/wasmtime/blob/c9a3f05afd45961b0b397f97c4ad79cd7a7c807d/crates/runtime/src/traphandlers.rs#L156-L174
The reason seems to be that there is no aarch64 android case in the code.

Proposed solution

By doing the following change I am able to compile successfully, but I am unsure if this is a proper fix to the issue.
The diff was generated for 5c35a9631cdffc00a32b416f9cb0b80f182b716e.

diff --git a/crates/runtime/src/traphandlers.rs b/crates/runtime/src/traphandlers.rs
index 0bd6f2cd1b..198d03a640 100644
--- a/crates/runtime/src/traphandlers.rs
+++ b/crates/runtime/src/traphandlers.rs
@@ -161,7 +161,7 @@ cfg_if::cfg_if! {
                 } else if #[cfg(all(target_os = "linux", target_arch = "x86"))] {
                     let cx = &*(cx as *const libc::ucontext_t);
                     cx.uc_mcontext.gregs[libc::REG_EIP as usize] as *const u8
-                } else if #[cfg(all(target_os = "linux", target_arch = "aarch64"))] {
+                } else if #[cfg(all(any(target_os = "linux", target_os = "android"), target_arch = "aarch64"))] {
                     let cx = &*(cx as *const libc::ucontext_t);
                     cx.uc_mcontext.pc as *const u8
                 } else if #[cfg(target_os = "macos")] {

Last updated: Nov 22 2024 at 17:03 UTC