Skip to content

Commit

Permalink
Support Android
Browse files Browse the repository at this point in the history
I'll send a PR after rust-lang/libc#1622 is merged and released
  • Loading branch information
Yuji Yamamoto committed Mar 23, 2020
1 parent 704c342 commit 0df0a1c
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 9 deletions.
2 changes: 1 addition & 1 deletion lib/clif-backend/src/libcalls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ pub extern "C" fn nearbyintf64(x: f64) -> f64 {

// FIXME: Is there a replacement on AArch64?
#[cfg(all(
any(target_os = "freebsd", target_os = "linux"),
any(target_os = "freebsd", target_os = "linux", target_os = "android"),
target_arch = "aarch64"
))]
#[no_mangle]
Expand Down
12 changes: 10 additions & 2 deletions lib/clif-backend/src/signal/unix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,15 +229,21 @@ unsafe fn get_faulting_addr_and_ip(
(si_addr, rip as _)
}

#[cfg(all(target_os = "linux", target_arch = "aarch64"))]
#[cfg(all(
any(target_os = "linux", target_os = "android"),
target_arch = "aarch64"
))]
unsafe fn get_faulting_addr_and_ip(
_siginfo: *const c_void,
_ucontext: *const c_void,
) -> (*const c_void, *const c_void) {
(::std::ptr::null(), ::std::ptr::null())
}

#[cfg(all(target_os = "linux", target_arch = "x86_64"))]
#[cfg(all(
any(target_os = "linux", target_os = "android"),
target_arch = "x86_64"
))]
unsafe fn get_faulting_addr_and_ip(
siginfo: *const c_void,
ucontext: *const c_void,
Expand Down Expand Up @@ -332,5 +338,7 @@ unsafe fn get_faulting_addr_and_ip(
all(target_os = "macos", target_arch = "x86_64"),
all(target_os = "linux", target_arch = "x86_64"),
all(target_os = "linux", target_arch = "aarch64"),
all(target_os = "android", target_arch = "x86_64"),
all(target_os = "android", target_arch = "aarch64"),
)))]
compile_error!("This crate doesn't yet support compiling on operating systems other than linux and macos and architectures other than x86_64");
3 changes: 2 additions & 1 deletion lib/runtime-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ wasmparser = "0.51.3"
parking_lot = "0.10.0"
lazy_static = "1.4"
errno = "0.2"
libc = "0.2.60"
#libc = "0.2.60"
libc = { path = "../../../libc", version = "0.2.65" }
hex = "0.4"
smallvec = "0.6"
bincode = "1.1"
Expand Down
2 changes: 1 addition & 1 deletion lib/runtime-core/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ fn main() {
.file("image-loading-freebsd-x86-64.s")
.compile("image-loading");
}
("linux", "x86_64") => {
("linux", "x86_64") | ("android", "x86_64") => {
cc::Build::new()
.file("image-loading-linux-x86-64.s")
.compile("image-loading");
Expand Down
10 changes: 8 additions & 2 deletions lib/runtime-core/src/fault.rs
Original file line number Diff line number Diff line change
Expand Up @@ -743,7 +743,10 @@ pub unsafe fn get_fault_info(siginfo: *const c_void, ucontext: *mut c_void) -> F
}
}

#[cfg(all(target_os = "linux", target_arch = "aarch64"))]
#[cfg(all(
any(target_os = "linux", target_os = "android"),
target_arch = "aarch64"
))]
/// Get fault info from siginfo and ucontext.
pub unsafe fn get_fault_info(siginfo: *const c_void, ucontext: *mut c_void) -> FaultInfo {
#[allow(dead_code)]
Expand Down Expand Up @@ -810,7 +813,10 @@ pub unsafe fn get_fault_info(siginfo: *const c_void, ucontext: *mut c_void) -> F
}
}

#[cfg(all(target_os = "linux", target_arch = "x86_64"))]
#[cfg(all(
any(target_os = "linux", target_os = "android"),
target_arch = "x86_64"
))]
/// Get fault info from siginfo and ucontext.
pub unsafe fn get_fault_info(siginfo: *const c_void, ucontext: *mut c_void) -> FaultInfo {
use libc::{
Expand Down
2 changes: 2 additions & 0 deletions lib/singlepass-backend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
all(target_os = "macos", target_arch = "x86_64"),
all(target_os = "linux", target_arch = "x86_64"),
all(target_os = "linux", target_arch = "aarch64"),
all(target_os = "android", target_arch = "x86_64"),
all(target_os = "android", target_arch = "aarch64"),
)))]
compile_error!("This crate doesn't yet support compiling on operating systems other than FreeBSD, linux and macos and architectures other than x86_64");

Expand Down
14 changes: 12 additions & 2 deletions lib/wasi/src/syscalls/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
#![allow(unused, clippy::too_many_arguments)]
pub mod types;
#[cfg(any(target_os = "freebsd", target_os = "linux", target_os = "macos"))]
#[cfg(any(
target_os = "freebsd",
target_os = "linux",
target_os = "android",
target_os = "macos"
))]
pub mod unix;
#[cfg(any(target_os = "windows"))]
pub mod windows;
Expand All @@ -23,7 +28,12 @@ use std::convert::{Infallible, TryInto};
use std::io::{self, Read, Seek, Write};
use wasmer_runtime_core::{memory::Memory, vm::Ctx};

#[cfg(any(target_os = "freebsd", target_os = "linux", target_os = "macos"))]
#[cfg(any(
target_os = "freebsd",
target_os = "linux",
target_os = "android",
target_os = "macos"
))]
pub use unix::*;

#[cfg(any(target_os = "windows"))]
Expand Down

0 comments on commit 0df0a1c

Please sign in to comment.