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

Support windows/arm target #256

Merged
merged 3 commits into from
Sep 7, 2018
Merged
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
2 changes: 1 addition & 1 deletion build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ mod c {
}
}

if target_arch == "arm" && target_os != "ios" {
if target_arch == "arm" && target_os != "ios" && target_env != "msvc" {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's some C files below in addition to assembly files, should they be included even on MSVC?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My understanding is that LLVM uses different builtins when targeting the msvc subsystem, for example __rt_udiv instead of __aeabi_uidivmod. I don't think the C files are required, and I haven't hit any errors yet due to their absence. I checked a few of the C files and they contain helper code for the assembly code.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok!

sources.extend(
&[
"arm/aeabi_div0.c",
Expand Down
2 changes: 1 addition & 1 deletion src/arm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use core::intrinsics;
// calling convention which can't be implemented using a normal Rust function.
// NOTE The only difference between the iOS and non-iOS versions of those functions is that the iOS
// versions use 3 leading underscores in the names of called functions instead of 2.
#[cfg(not(target_os = "ios"))]
#[cfg(not(any(target_os = "ios", target_env = "msvc")))]
#[naked]
#[cfg_attr(not(feature = "mangled-names"), no_mangle)]
pub unsafe fn __aeabi_uidivmod() {
Expand Down
5 changes: 3 additions & 2 deletions src/int/sdiv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ intrinsics! {
}

#[use_c_shim_if(all(target_arch = "arm",
not(target_os = "ios")),
not(target_os = "ios"),
not(target_env = "msvc")),
not(thumbv6m))]
pub extern "C" fn __modsi3(a: i32, b: i32) -> i32 {
a.mod_(b)
Expand All @@ -89,7 +90,7 @@ intrinsics! {
a.mod_(b)
}

#[use_c_shim_if(all(target_arch = "arm",
#[use_c_shim_if(all(target_arch = "arm", not(target_env = "msvc"),
not(target_os = "ios"), not(thumbv6m)))]
pub extern "C" fn __divmodsi4(a: i32, b: i32, rem: &mut i32) -> i32 {
a.divmod(b, rem, |a, b| __divsi3(a, b))
Expand Down
2 changes: 2 additions & 0 deletions src/int/udiv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ intrinsics! {

#[use_c_shim_if(all(target_arch = "arm",
not(target_os = "ios"),
not(target_env = "msvc"),
not(thumbv6m)))]
/// Returns `n % d`
pub extern "C" fn __umodsi3(n: u32, d: u32) -> u32 {
Expand All @@ -220,6 +221,7 @@ intrinsics! {

#[use_c_shim_if(all(target_arch = "arm",
not(target_os = "ios"),
not(target_env = "msvc"),
not(thumbv6m)))]
/// Returns `n / d` and sets `*rem = n % d`
pub extern "C" fn __udivmodsi4(n: u32, d: u32, rem: Option<&mut u32>) -> u32 {
Expand Down