diff options
author | 2017-12-29 21:43:39 +0100 | |
---|---|---|
committer | 2017-12-29 21:43:39 +0100 | |
commit | 018d54639de034b127b2396c0aef4467f9c3b7c9 (patch) | |
tree | d162c9cfe25c78b49682f4d9b180fc9087f15907 | |
parent | 6082bc6e4bb52a5f6f71ae10f083c9852f359d1f (diff) | |
download | cortex-m-018d54639de034b127b2396c0aef4467f9c3b7c9.tar.gz cortex-m-018d54639de034b127b2396c0aef4467f9c3b7c9.tar.zst cortex-m-018d54639de034b127b2396c0aef4467f9c3b7c9.zip |
adapt to changes in the `start` lang item
-rw-r--r-- | cortex-m-rt/Cargo.toml | 6 | ||||
-rw-r--r-- | cortex-m-rt/build.rs | 21 | ||||
-rw-r--r-- | cortex-m-rt/src/lang_items.rs | 27 | ||||
-rw-r--r-- | cortex-m-rt/src/lib.rs | 17 |
4 files changed, 52 insertions, 19 deletions
diff --git a/cortex-m-rt/Cargo.toml b/cortex-m-rt/Cargo.toml index bc19955..587633e 100644 --- a/cortex-m-rt/Cargo.toml +++ b/cortex-m-rt/Cargo.toml @@ -7,7 +7,7 @@ keywords = ["arm", "cortex-m", "runtime", "startup"] license = "MIT OR Apache-2.0" name = "cortex-m-rt" repository = "https://github.com/japaric/cortex-m-rt" -version = "0.3.7" +version = "0.3.8" [dependencies] cortex-m = "0.3.0" @@ -16,3 +16,7 @@ r0 = "0.2.1" [features] # provides a panic_fmt implementation that calls the abort instruction (`udf 0xfe`) abort-on-panic = [] + +[build-dependencies] +rustc_version = "0.2.1" +chrono = "0.4.0" diff --git a/cortex-m-rt/build.rs b/cortex-m-rt/build.rs index 1d0160c..918cbfb 100644 --- a/cortex-m-rt/build.rs +++ b/cortex-m-rt/build.rs @@ -1,9 +1,30 @@ +extern crate chrono; +extern crate rustc_version; + use std::env; use std::fs::File; use std::io::Write; use std::path::PathBuf; +use chrono::NaiveDate; + fn main() { + let date: NaiveDate = rustc_version::version_meta() + .unwrap() + .commit_date + .unwrap() + .parse() + .unwrap(); + + if date <= NaiveDate::from_ymd(2017, 12, 26) { + let version = env!("CARGO_PKG_VERSION"); + panic!( + "cortex-m-rt v{} doesn't support nightly-2017-12-27 and older; \ + to use the current nightly switch to v0.3.7", + version + ); + } + let target = env::var("TARGET").unwrap(); has_fpu(&target); diff --git a/cortex-m-rt/src/lang_items.rs b/cortex-m-rt/src/lang_items.rs index 9ff95b5..6b15f99 100644 --- a/cortex-m-rt/src/lang_items.rs +++ b/cortex-m-rt/src/lang_items.rs @@ -1,12 +1,7 @@ /// Default panic handler #[cfg(feature = "abort-on-panic")] #[lang = "panic_fmt"] -unsafe extern "C" fn panic_fmt( - _: ::core::fmt::Arguments, - _: &'static str, - _: u32, - _: u32, -) -> ! { +unsafe extern "C" fn panic_fmt(_: ::core::fmt::Arguments, _: &'static str, _: u32, _: u32) -> ! { ::core::intrinsics::abort() } @@ -29,12 +24,22 @@ unsafe extern "C" fn panic_fmt( // has to call `rustc_main`. That's covered by the `reset_handler` function in // root of this crate. #[lang = "start"] -extern "C" fn start( - main: fn(), - _argc: isize, - _argv: *const *const u8, -) -> isize { +extern "C" fn start<T>(main: fn() -> T, _argc: isize, _argv: *const *const u8) -> isize +where + T: Termination, +{ main(); 0 } + +#[lang = "termination"] +pub trait Termination { + fn report(self) -> i32; +} + +impl Termination for () { + fn report(self) -> i32 { + 0 + } +} diff --git a/cortex-m-rt/src/lib.rs b/cortex-m-rt/src/lib.rs index df6640f..9c5e7bf 100644 --- a/cortex-m-rt/src/lib.rs +++ b/cortex-m-rt/src/lib.rs @@ -278,8 +278,7 @@ //! } //! ``` -#![cfg_attr(any(target_arch = "arm", feature = "abort-on-panic"), - feature(core_intrinsics))] +#![cfg_attr(any(target_arch = "arm", feature = "abort-on-panic"), feature(core_intrinsics))] #![deny(missing_docs)] #![deny(warnings)] #![feature(asm)] @@ -291,8 +290,8 @@ #![feature(used)] #![no_std] -extern crate cortex_m; extern crate compiler_builtins; +extern crate cortex_m; extern crate r0; #[cfg(not(test))] @@ -374,7 +373,8 @@ unsafe extern "C" fn reset_handler() -> ! { } #[cfg(target_arch = "arm")] -global_asm!(r#" +global_asm!( + r#" .weak NMI NMI = DEFAULT_HANDLER @@ -398,13 +398,16 @@ PENDSV = DEFAULT_HANDLER .weak SYS_TICK SYS_TICK = DEFAULT_HANDLER -"#); +"# +); #[cfg(not(armv6m))] -global_asm!(r#" +global_asm!( + r#" .weak DEBUG_MONITOR DEBUG_MONITOR = DEFAULT_HANDLER -"#); +"# +); #[cfg(target_arch = "arm")] extern "C" { |