Skip to content

Commit f6c0312

Browse files
bors[bot]TDHolmes
andauthored
Merge #369
369: Switch "native" check from being x86_64 only to checking `HOST` r=adamgreig a=TDHolmes If `HOST==TARGET`, we know we're compiling natively. Set a new `rustc` cfg for this and use it where we previously checked for `x86_64`. I was trying to run tests on my M1 MacBook Pro and couldn't since it isn't `x86_64`. Also, the currently configured nightly compiler for asm doesn't have M1 support, so I updated that. I'm fine reverting that change though, I can just do that locally, but I'm sure others will hit the same issue and it's a bit old... Co-authored-by: Tyler Holmes <[email protected]>
2 parents 441cb87 + dcc53bf commit f6c0312

File tree

4 files changed

+17
-12
lines changed

4 files changed

+17
-12
lines changed

build.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,14 @@ use std::{env, fs};
33

44
fn main() {
55
let target = env::var("TARGET").unwrap();
6+
let host_triple = env::var("HOST").unwrap();
67
let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap());
78
let name = env::var("CARGO_PKG_NAME").unwrap();
89

10+
if host_triple == target {
11+
println!("cargo:rustc-cfg=native");
12+
}
13+
914
if target.starts_with("thumb") {
1015
let suffix = if env::var_os("CARGO_FEATURE_LINKER_PLUGIN_LTO").is_some() {
1116
"-lto"

src/peripheral/icb.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! Implementation Control Block
22
3-
#[cfg(any(armv7m, armv8m, target_arch = "x86_64"))]
3+
#[cfg(any(armv7m, armv8m, native))]
44
use volatile_register::RO;
55
use volatile_register::RW;
66

@@ -12,12 +12,12 @@ pub struct RegisterBlock {
1212
/// The bottom four bits of this register give the number of implemented
1313
/// interrupt lines, divided by 32. So a value of `0b0010` indicates 64
1414
/// interrupts.
15-
#[cfg(any(armv7m, armv8m, target_arch = "x86_64"))]
15+
#[cfg(any(armv7m, armv8m, native))]
1616
pub ictr: RO<u32>,
1717

1818
/// The ICTR is not defined in the ARMv6-M Architecture Reference manual, so
1919
/// we replace it with this.
20-
#[cfg(not(any(armv7m, armv8m, target_arch = "x86_64")))]
20+
#[cfg(not(any(armv7m, armv8m, native)))]
2121
_reserved: u32,
2222

2323
/// Auxiliary Control Register

src/peripheral/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ pub mod dcb;
7171
pub mod dwt;
7272
#[cfg(not(armv6m))]
7373
pub mod fpb;
74-
// NOTE(target_arch) is for documentation purposes
75-
#[cfg(any(has_fpu, target_arch = "x86_64"))]
74+
// NOTE(native) is for documentation purposes
75+
#[cfg(any(has_fpu, native))]
7676
pub mod fpu;
7777
pub mod icb;
7878
#[cfg(all(not(armv6m), not(armv8m_base)))]
@@ -411,7 +411,7 @@ pub struct FPU {
411411

412412
unsafe impl Send for FPU {}
413413

414-
#[cfg(any(has_fpu, target_arch = "x86_64"))]
414+
#[cfg(any(has_fpu, native))]
415415
impl FPU {
416416
/// Pointer to the register block
417417
pub const PTR: *const fpu::RegisterBlock = 0xE000_EF30 as *const _;
@@ -423,7 +423,7 @@ impl FPU {
423423
}
424424
}
425425

426-
#[cfg(any(has_fpu, target_arch = "x86_64"))]
426+
#[cfg(any(has_fpu, native))]
427427
impl ops::Deref for FPU {
428428
type Target = self::fpu::RegisterBlock;
429429

src/peripheral/scb.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ impl SCB {
182182
5 => VectActive::Exception(Exception::BusFault),
183183
#[cfg(not(armv6m))]
184184
6 => VectActive::Exception(Exception::UsageFault),
185-
#[cfg(any(armv8m, target_arch = "x86_64"))]
185+
#[cfg(any(armv8m, native))]
186186
7 => VectActive::Exception(Exception::SecureFault),
187187
11 => VectActive::Exception(Exception::SVCall),
188188
#[cfg(not(armv6m))]
@@ -218,7 +218,7 @@ pub enum Exception {
218218
UsageFault,
219219

220220
/// Secure fault interrupt (only on ARMv8-M)
221-
#[cfg(any(armv8m, target_arch = "x86_64"))]
221+
#[cfg(any(armv8m, native))]
222222
SecureFault,
223223

224224
/// SV call interrupt
@@ -250,7 +250,7 @@ impl Exception {
250250
Exception::BusFault => -11,
251251
#[cfg(not(armv6m))]
252252
Exception::UsageFault => -10,
253-
#[cfg(any(armv8m, target_arch = "x86_64"))]
253+
#[cfg(any(armv8m, native))]
254254
Exception::SecureFault => -9,
255255
Exception::SVCall => -5,
256256
#[cfg(not(armv6m))]
@@ -293,7 +293,7 @@ impl VectActive {
293293
5 => VectActive::Exception(Exception::BusFault),
294294
#[cfg(not(armv6m))]
295295
6 => VectActive::Exception(Exception::UsageFault),
296-
#[cfg(any(armv8m, target_arch = "x86_64"))]
296+
#[cfg(any(armv8m, native))]
297297
7 => VectActive::Exception(Exception::SecureFault),
298298
11 => VectActive::Exception(Exception::SVCall),
299299
#[cfg(not(armv6m))]
@@ -934,7 +934,7 @@ pub enum SystemHandler {
934934
UsageFault = 6,
935935

936936
/// Secure fault interrupt (only on ARMv8-M)
937-
#[cfg(any(armv8m, target_arch = "x86_64"))]
937+
#[cfg(any(armv8m, native))]
938938
SecureFault = 7,
939939

940940
/// SV call interrupt

0 commit comments

Comments
 (0)