Skip to content

Commit c924aed

Browse files
committed
Fix Armv8-M Baseline compilation
Armv8-M Baseline, ie thumbv8m.base-none-eabi, is a superset of the Armv6-M architecture profile. As it shares almost the same instruction set, this commit copies the configuration for thumbv6m-none-eabi to enable it.
1 parent fafaace commit c924aed

File tree

3 files changed

+11
-10
lines changed

3 files changed

+11
-10
lines changed

build.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,11 @@ fn main() {
4949
println!("cargo:rustc-cfg=thumb")
5050
}
5151

52-
// compiler-rt `cfg`s away some intrinsics for thumbv6m because that target doesn't have full
53-
// THUMBv2 support. We have to cfg our code accordingly.
54-
if llvm_target[0] == "thumbv6m" {
55-
println!("cargo:rustc-cfg=thumbv6m")
52+
// compiler-rt `cfg`s away some intrinsics for thumbv6m and thumbv8m.base because
53+
// these targets do not have full Thumb-2 support but only original Thumb-1.
54+
// We have to cfg our code accordingly.
55+
if llvm_target[0] == "thumbv6m" || llvm_target[0] == "thumbv8m.base" {
56+
println!("cargo:rustc-cfg=thumb_1")
5657
}
5758

5859
// Only emit the ARM Linux atomic emulation on pre-ARMv6 architectures.
@@ -407,7 +408,7 @@ mod c {
407408
}
408409

409410
// Remove the assembly implementations that won't compile for the target
410-
if llvm_target[0] == "thumbv6m" {
411+
if llvm_target[0] == "thumbv6m" || llvm_target[0] == "thumbv8m.base" {
411412
sources.remove(
412413
&[
413414
"clzdi2",

src/int/sdiv.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ intrinsics! {
7474

7575
#[use_c_shim_if(all(target_arch = "arm",
7676
not(target_os = "ios"),
77-
not(target_env = "msvc")),
78-
not(thumbv6m))]
77+
not(target_env = "msvc"),
78+
not(thumb_1)))]
7979
pub extern "C" fn __modsi3(a: i32, b: i32) -> i32 {
8080
a.mod_(b)
8181
}
@@ -91,7 +91,7 @@ intrinsics! {
9191
}
9292

9393
#[use_c_shim_if(all(target_arch = "arm", not(target_env = "msvc"),
94-
not(target_os = "ios"), not(thumbv6m)))]
94+
not(target_os = "ios"), not(thumb_1)))]
9595
pub extern "C" fn __divmodsi4(a: i32, b: i32, rem: &mut i32) -> i32 {
9696
a.divmod(b, rem, |a, b| __divsi3(a, b))
9797
}

src/int/udiv.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ intrinsics! {
212212
#[use_c_shim_if(all(target_arch = "arm",
213213
not(target_os = "ios"),
214214
not(target_env = "msvc"),
215-
not(thumbv6m)))]
215+
not(thumb_1)))]
216216
/// Returns `n % d`
217217
pub extern "C" fn __umodsi3(n: u32, d: u32) -> u32 {
218218
let q = __udivsi3(n, d);
@@ -222,7 +222,7 @@ intrinsics! {
222222
#[use_c_shim_if(all(target_arch = "arm",
223223
not(target_os = "ios"),
224224
not(target_env = "msvc"),
225-
not(thumbv6m)))]
225+
not(thumb_1)))]
226226
/// Returns `n / d` and sets `*rem = n % d`
227227
pub extern "C" fn __udivmodsi4(n: u32, d: u32, rem: Option<&mut u32>) -> u32 {
228228
let q = __udivsi3(n, d);

0 commit comments

Comments
 (0)