-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
iOS target support #7506
base: main
Are you sure you want to change the base?
iOS target support #7506
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -115,7 +115,7 @@ pub fn infer_native_flags(isa_builder: &mut dyn Configurable) -> Result<(), &'st | |
isa_builder.enable("has_pauth").unwrap(); | ||
} | ||
|
||
if cfg!(target_os = "macos") { | ||
if cfg!(any(target_os = "macos", target_os = "ios")) { | ||
// Pointer authentication is always available on Apple Silicon. | ||
isa_builder.enable("sign_return_address").unwrap(); | ||
// macOS enforces the use of the B key for return addresses. | ||
|
@@ -167,7 +167,10 @@ mod tests { | |
.finish(settings::Flags::new(flag_builder)) | ||
.unwrap(); | ||
|
||
if cfg!(all(target_os = "macos", target_arch = "aarch64")) { | ||
if cfg!(all( | ||
any(target_os = "macos", target_os = "ios"), | ||
target_arch = "aarch64" | ||
)) { | ||
Comment on lines
+170
to
+173
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is also something to watch out for once you're at the point you can run some code. This block is true for macOS but iOS may very well be different in its calling convention. I'm not sure either way (or where to look it up), so it's mostly something to watch out for to see if apps crash when you load them. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. From what I can see from https://developer.apple.com/documentation/xcode/writing-arm64-code-for-apple-platforms, it doesn't look like macOS and iOS have different calling conventions on arm64. |
||
assert_eq!(isa.default_call_conv(), CallConv::AppleAarch64); | ||
} else if cfg!(any(unix, target_os = "nebulet")) { | ||
assert_eq!(isa.default_call_conv(), CallConv::SystemV); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,7 +22,7 @@ use super::wasmtime_fiber_start; | |
use wasmtime_asm_macros::asm_func; | ||
|
||
cfg_if::cfg_if! { | ||
if #[cfg(target_os = "macos")] { | ||
if #[cfg(any(target_os = "macos", target_os = "ios"))] { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This relates to my comment about pointer authentication above, because if iOS uses the A key instead of the B key then this block would need to change. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looking at https://support.apple.com/en-ng/guide/security/sec8b776536b/1/web/1#sec0167b469d, there does not seem to be any indication there are any differences across iOS and macOS regarding which key is used, it always seems to be IB for return addresses. |
||
macro_rules! paci1716 { () => ("pacib1716\n"); } | ||
macro_rules! pacisp { () => ("pacibsp\n"); } | ||
macro_rules! autisp { () => ("autibsp\n"); } | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,7 +56,7 @@ pub unsafe fn platform_init() { | |
|
||
// Sometimes we need to handle SIGBUS too: | ||
// - On Darwin, guard page accesses are raised as SIGBUS. | ||
if cfg!(target_os = "macos") || cfg!(target_os = "freebsd") { | ||
if cfg!(any(target_os = "macos", target_os = "ios")) || cfg!(target_os = "freebsd") { | ||
register(&mut PREV_SIGBUS, libc::SIGBUS); | ||
} | ||
|
||
|
@@ -138,7 +138,7 @@ unsafe extern "C" fn trap_handler( | |
// done running" which will clear the sigaltstack flag and allow | ||
// reusing it for the next signal. Then upon resuming in our custom | ||
// code we blow away the stack anyway with a longjmp. | ||
if cfg!(target_os = "macos") { | ||
if cfg!(any(target_os = "macos", target_os = "ios")) { | ||
unsafe extern "C" fn wasmtime_longjmp_shim(jmp_buf: *const u8) { | ||
wasmtime_longjmp(jmp_buf) | ||
} | ||
|
@@ -178,7 +178,7 @@ unsafe extern "C" fn trap_handler( | |
// more accurate definition. When that PR and/or issue is resolved then this | ||
// should no longer be necessary. | ||
#[repr(C)] | ||
#[cfg(all(target_arch = "aarch64", target_os = "macos"))] | ||
#[cfg(all(target_arch = "aarch64", any(target_os = "macos", target_os = "ios")))] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If possible you'll want to use |
||
struct ucontext_t { | ||
uc_onstack: libc::c_int, | ||
uc_sigmask: libc::sigset_t, | ||
|
@@ -222,13 +222,13 @@ unsafe fn get_pc_and_fp(cx: *mut libc::c_void, _signum: libc::c_int) -> (*const | |
(cx.uc_mcontext.psw.addr - trap_offset) as *const u8, | ||
*(cx.uc_mcontext.gregs[15] as *const usize), | ||
) | ||
} else if #[cfg(all(target_os = "macos", target_arch = "x86_64"))] { | ||
} else if #[cfg(all(any(target_os = "macos", target_os = "ios"), target_arch = "x86_64"))] { | ||
let cx = &*(cx as *const libc::ucontext_t); | ||
( | ||
(*cx.uc_mcontext).__ss.__rip as *const u8, | ||
(*cx.uc_mcontext).__ss.__rbp as usize, | ||
) | ||
} else if #[cfg(all(target_os = "macos", target_arch = "aarch64"))] { | ||
} else if #[cfg(all(any(target_os = "macos", target_os = "ios"), target_arch = "aarch64"))] { | ||
let cx = &*(cx as *const ucontext_t); | ||
( | ||
(*cx.uc_mcontext).__ss.__pc as *const u8, | ||
|
@@ -265,7 +265,9 @@ unsafe fn get_pc_and_fp(cx: *mut libc::c_void, _signum: libc::c_int) -> (*const | |
// See more comments above where this is called for what it's doing. | ||
unsafe fn set_pc(cx: *mut libc::c_void, pc: usize, arg1: usize) { | ||
cfg_if::cfg_if! { | ||
if #[cfg(not(target_os = "macos"))] { | ||
if #[cfg( | ||
all(not(target_os = "macos"), not(target_os = "ios")) | ||
)] { | ||
let _ = (cx, pc, arg1); | ||
unreachable!(); // not used on these platforms | ||
} else if #[cfg(target_arch = "x86_64")] { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,9 @@ | ||
#[cfg(any( | ||
target_os = "linux", | ||
all(target_os = "macos", feature = "posix-signals-on-macos") | ||
all( | ||
any(target_os = "macos", target_os = "ios"), | ||
feature = "posix-signals-on-macos" | ||
) | ||
))] | ||
#[cfg(not(miri))] | ||
Comment on lines
1
to
8
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As a heads up I've posted #7509 which will conflict with this, although what you're doing here of "where macos is needed also allow ios" would also apply to that PR. |
||
mod tests { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,7 @@ fn lldb_with_script(args: &[&str], script: &str) -> Result<String> { | |
let mut cmd = Command::new(&lldb_path); | ||
|
||
cmd.arg("--batch"); | ||
if cfg!(target_os = "macos") { | ||
if cfg!(any(target_os = "macos", target_os = "ios")) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it's ok to skip iOS in this file, it's unlikely these tests will ever complete successfully on iOS (and they're disabled by default too) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (ditto for all other |
||
cmd.args(&["-o", "settings set plugin.jit-loader.gdb.enable on"]); | ||
} | ||
let mut script_file = NamedTempFile::new()?; | ||
|
@@ -60,7 +60,7 @@ fn check_lldb_output(output: &str, directives: &str) -> Result<()> { | |
#[test] | ||
#[ignore] | ||
#[cfg(all( | ||
any(target_os = "linux", target_os = "macos"), | ||
any(target_os = "linux", target_os = "macos", target_os = "ios"), | ||
target_pointer_width = "64" | ||
))] | ||
pub fn test_debug_dwarf_lldb() -> Result<()> { | ||
|
@@ -101,7 +101,7 @@ check: exited with status | |
#[test] | ||
#[ignore] | ||
#[cfg(all( | ||
any(target_os = "linux", target_os = "macos"), | ||
any(target_os = "linux", target_os = "macos", target_os = "ios"), | ||
target_pointer_width = "64" | ||
))] | ||
pub fn test_debug_dwarf5_lldb() -> Result<()> { | ||
|
@@ -142,7 +142,7 @@ check: exited with status | |
#[test] | ||
#[ignore] | ||
#[cfg(all( | ||
any(target_os = "linux", target_os = "macos"), | ||
any(target_os = "linux", target_os = "macos", target_os = "ios"), | ||
target_pointer_width = "64" | ||
))] | ||
pub fn test_debug_dwarf_ref() -> Result<()> { | ||
|
@@ -176,7 +176,7 @@ check: resuming | |
#[test] | ||
#[ignore] | ||
#[cfg(all( | ||
any(target_os = "linux", target_os = "macos"), | ||
any(target_os = "linux", target_os = "macos", target_os = "ios"), | ||
target_pointer_width = "64" | ||
))] | ||
pub fn test_debug_inst_offsets_are_correct_when_branches_are_removed() -> Result<()> { | ||
|
@@ -203,7 +203,7 @@ check: exited with status | |
#[test] | ||
#[ignore] | ||
#[cfg(all( | ||
any(target_os = "linux", target_os = "macos"), | ||
any(target_os = "linux", target_os = "macos", target_os = "ios"), | ||
target_pointer_width = "64" | ||
))] | ||
pub fn test_spilled_frame_base_is_accessible() -> Result<()> { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is something that I think may need to be confirmed. The comment below for example is incorrect since not all iOS devices will run on Apple Silicon, but I'm sure all recent ones do. That being said I don't know the story for return-address-signing on iOS and whether or not it's different than macOS.