Skip to content

[experiment] android testing #640

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

Closed
wants to merge 4 commits into from
Closed
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
11 changes: 11 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,17 @@ rustc-dep-of-std = ['compiler-builtins', 'core']
# are not normally public but are required by the `testcrate`
public-test-deps = []

# Marks all intrinsics functions with weak linkage so that they can be
# replaced at link time by another implementation. This is particularly useful
# for mixed Rust/C++ binaries that want to use the C++ intrinsics, otherwise
# linking against the Rust stdlib will replace those from the compiler-rt
# library.
#
# Unlike the "c" feature, the intrinsics are still provided by the Rust
# implementations and each will be used unless a stronger symbol replaces
# it during linking.
weak-intrinsics = []

[[example]]
name = "intrinsics"
required-features = ["compiler-builtins"]
Expand Down
13 changes: 11 additions & 2 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,11 @@ mod c {

// On iOS and 32-bit OSX these are all just empty intrinsics, no need to
// include them.
if target_vendor != "apple" || target_arch != "x86" {
if target_os != "ios"
&& target_os != "watchos"
&& target_os != "tvos"
&& (target_vendor != "apple" || target_arch != "x86")
{
sources.extend(&[
("__absvti2", "absvti2.c"),
("__addvti3", "addvti3.c"),
Expand Down Expand Up @@ -428,7 +432,12 @@ mod c {
}
}

if target_arch == "arm" && target_vendor != "apple" && target_env != "msvc" {
if target_arch == "arm"
&& target_os != "ios"
&& target_os != "watchos"
&& target_os != "tvos"
&& target_env != "msvc"
{
sources.extend(&[
("__aeabi_div0", "arm/aeabi_div0.c"),
("__aeabi_drsub", "arm/aeabi_drsub.c"),
Expand Down
48 changes: 33 additions & 15 deletions src/arm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@

use core::intrinsics;

// Apple symbols have a leading underscore.
#[cfg(target_vendor = "apple")]
// iOS symbols have a leading underscore.
#[cfg(target_os = "ios")]
macro_rules! bl {
($func:literal) => {
concat!("bl _", $func)
};
}
#[cfg(not(target_vendor = "apple"))]
#[cfg(not(target_os = "ios"))]
macro_rules! bl {
($func:literal) => {
concat!("bl ", $func)
Expand All @@ -20,6 +20,7 @@ macro_rules! bl {
intrinsics! {
// NOTE This function and the ones below are implemented using assembly because they are using a
// custom calling convention which can't be implemented using a normal Rust function.
#[cfg_attr(all(not(windows), not(target_vendor="apple")), weak)]
#[naked]
#[cfg(not(target_env = "msvc"))]
pub unsafe extern "C" fn __aeabi_uidivmod() {
Expand All @@ -35,6 +36,7 @@ intrinsics! {
);
}

#[cfg_attr(all(not(windows), not(target_vendor="apple")), weak)]
#[naked]
pub unsafe extern "C" fn __aeabi_uldivmod() {
core::arch::asm!(
Expand All @@ -51,6 +53,7 @@ intrinsics! {
);
}

#[cfg_attr(all(not(windows), not(target_vendor="apple")), weak)]
#[naked]
pub unsafe extern "C" fn __aeabi_idivmod() {
core::arch::asm!(
Expand All @@ -64,6 +67,7 @@ intrinsics! {
);
}

#[cfg_attr(all(not(windows), not(target_vendor="apple")), weak)]
#[naked]
pub unsafe extern "C" fn __aeabi_ldivmod() {
core::arch::asm!(
Expand All @@ -80,14 +84,18 @@ intrinsics! {
);
}

// The following functions use weak linkage to allow users to override
// with custom implementation.
// FIXME: The `*4` and `*8` variants should be defined as aliases.

#[cfg(not(target_vendor = "apple"))]
#[weak]
#[cfg(not(target_os = "ios"))]
pub unsafe extern "aapcs" fn __aeabi_memcpy(dest: *mut u8, src: *const u8, n: usize) {
crate::mem::memcpy(dest, src, n);
}

#[cfg(not(target_vendor = "apple"))]
#[weak]
#[cfg(not(target_os = "ios"))]
pub unsafe extern "aapcs" fn __aeabi_memcpy4(dest: *mut u8, src: *const u8, n: usize) {
// We are guaranteed 4-alignment, so accessing at u32 is okay.
let mut dest = dest as *mut u32;
Expand All @@ -104,33 +112,39 @@ intrinsics! {
__aeabi_memcpy(dest as *mut u8, src as *const u8, n);
}

#[cfg(not(target_vendor = "apple"))]
#[weak]
#[cfg(not(target_os = "ios"))]
pub unsafe extern "aapcs" fn __aeabi_memcpy8(dest: *mut u8, src: *const u8, n: usize) {
__aeabi_memcpy4(dest, src, n);
}

#[cfg(not(target_vendor = "apple"))]
#[weak]
#[cfg(not(target_os = "ios"))]
pub unsafe extern "aapcs" fn __aeabi_memmove(dest: *mut u8, src: *const u8, n: usize) {
crate::mem::memmove(dest, src, n);
}

#[cfg(not(any(target_vendor = "apple", target_env = "msvc")))]
#[weak]
#[cfg(not(any(target_os = "ios", target_env = "msvc")))]
pub unsafe extern "aapcs" fn __aeabi_memmove4(dest: *mut u8, src: *const u8, n: usize) {
__aeabi_memmove(dest, src, n);
}

#[cfg(not(any(target_vendor = "apple", target_env = "msvc")))]
#[weak]
#[cfg(not(any(target_os = "ios", target_env = "msvc")))]
pub unsafe extern "aapcs" fn __aeabi_memmove8(dest: *mut u8, src: *const u8, n: usize) {
__aeabi_memmove(dest, src, n);
}

#[cfg(not(target_vendor = "apple"))]
#[weak]
#[cfg(not(target_os = "ios"))]
pub unsafe extern "aapcs" fn __aeabi_memset(dest: *mut u8, n: usize, c: i32) {
// Note the different argument order
crate::mem::memset(dest, c, n);
}

#[cfg(not(target_vendor = "apple"))]
#[weak]
#[cfg(not(target_os = "ios"))]
pub unsafe extern "aapcs" fn __aeabi_memset4(dest: *mut u8, n: usize, c: i32) {
let mut dest = dest as *mut u32;
let mut n = n;
Expand All @@ -147,22 +161,26 @@ intrinsics! {
__aeabi_memset(dest as *mut u8, n, byte as i32);
}

#[cfg(not(target_vendor = "apple"))]
#[weak]
#[cfg(not(target_os = "ios"))]
pub unsafe extern "aapcs" fn __aeabi_memset8(dest: *mut u8, n: usize, c: i32) {
__aeabi_memset4(dest, n, c);
}

#[cfg(not(target_vendor = "apple"))]
#[weak]
#[cfg(not(target_os = "ios"))]
pub unsafe extern "aapcs" fn __aeabi_memclr(dest: *mut u8, n: usize) {
__aeabi_memset(dest, n, 0);
}

#[cfg(not(any(target_vendor = "apple", target_env = "msvc")))]
#[weak]
#[cfg(not(any(target_os = "ios", target_env = "msvc")))]
pub unsafe extern "aapcs" fn __aeabi_memclr4(dest: *mut u8, n: usize) {
__aeabi_memset4(dest, n, 0);
}

#[cfg(not(any(target_vendor = "apple", target_env = "msvc")))]
#[weak]
#[cfg(not(any(target_os = "ios", target_env = "msvc")))]
pub unsafe extern "aapcs" fn __aeabi_memclr8(dest: *mut u8, n: usize) {
__aeabi_memset4(dest, n, 0);
}
Expand Down
Loading
Loading