Skip to content

Commit 35b1a1e

Browse files
committed
support nightly-2017-09-22
1 parent 8d053c4 commit 35b1a1e

File tree

5 files changed

+43
-4
lines changed

5 files changed

+43
-4
lines changed

cortex-m-rt/CHANGELOG.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,16 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
77

88
## [Unreleased]
99

10-
## [v0.3.10] - 2018-01-17
10+
## [v0.3.11] - 2018-01-17
11+
12+
### Changed
13+
14+
- Dynamically support recent nightlies, which have the `termination` lang item, and
15+
nightly-2017-09-22, which doesn't. That nightly version is used by the docs.rs builder. Supporting
16+
that version instead of rejecting it ensures this crate and its reverse-dependencies will get
17+
their documentation built by the docs.rs service.
18+
19+
## [v0.3.10] - 2018-01-17 - YANKED
1120

1221
### Removed
1322

@@ -203,7 +212,8 @@ section size addr
203212

204213
Initial release
205214

206-
[Unreleased]: https://github.com/japaric/cortex-m-rt/compare/v0.3.10...HEAD
215+
[Unreleased]: https://github.com/japaric/cortex-m-rt/compare/v0.3.11...HEAD
216+
[v0.3.11]: https://github.com/japaric/cortex-m-rt/compare/v0.3.10...v0.3.11
207217
[v0.3.10]: https://github.com/japaric/cortex-m-rt/compare/v0.3.9...v0.3.10
208218
[v0.3.9]: https://github.com/japaric/cortex-m-rt/compare/v0.3.8...v0.3.9
209219
[v0.3.8]: https://github.com/japaric/cortex-m-rt/compare/v0.3.7...v0.3.8

cortex-m-rt/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ keywords = ["arm", "cortex-m", "runtime", "startup"]
77
license = "MIT OR Apache-2.0"
88
name = "cortex-m-rt"
99
repository = "https://github.com/japaric/cortex-m-rt"
10-
version = "0.3.10"
10+
version = "0.3.11"
1111

1212
[dependencies]
1313
cortex-m = "0.3.0"
@@ -19,3 +19,4 @@ abort-on-panic = []
1919

2020
[build-dependencies]
2121
rustc_version = "0.2.1"
22+
chrono = "0.4.0"

cortex-m-rt/build.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,25 @@
1+
extern crate chrono;
12
extern crate rustc_version;
23

34
use std::env;
45
use std::fs::File;
56
use std::io::Write;
67
use std::path::PathBuf;
78

9+
use chrono::NaiveDate;
10+
811
fn main() {
12+
let date: NaiveDate = rustc_version::version_meta()
13+
.unwrap()
14+
.commit_date
15+
.unwrap()
16+
.parse()
17+
.unwrap();
18+
19+
if date > NaiveDate::from_ymd(2017, 12, 26) {
20+
println!("cargo:rustc-cfg=has_termination_lang")
21+
}
22+
923
let target = env::var("TARGET").unwrap();
1024

1125
has_fpu(&target);

cortex-m-rt/src/lang_items.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ unsafe extern "C" fn panic_fmt(_: ::core::fmt::Arguments, _: &'static str, _: u3
55
::core::intrinsics::abort()
66
}
77

8-
/// Lang item required to make the normal `main` work in applications
8+
// Lang item required to make the normal `main` work in applications
9+
//
910
// This is how the `start` lang item works:
1011
// When `rustc` compiles a binary crate, it creates a `main` function that looks
1112
// like this:
@@ -23,6 +24,7 @@ unsafe extern "C" fn panic_fmt(_: ::core::fmt::Arguments, _: &'static str, _: u3
2324
// The final piece is that the entry point of our program, the reset handler,
2425
// has to call `rustc_main`. That's covered by the `reset_handler` function in
2526
// root of this crate.
27+
#[cfg(has_termination_trait)]
2628
#[lang = "start"]
2729
extern "C" fn start<T>(main: fn() -> T, _argc: isize, _argv: *const *const u8) -> isize
2830
where
@@ -33,11 +35,21 @@ where
3335
0
3436
}
3537

38+
#[cfg(not(has_termination_trait))]
39+
#[lang = "start"]
40+
extern "C" fn start(main: fn(), _argc: isize, _argv: *const *const u8) -> isize {
41+
main();
42+
43+
0
44+
}
45+
3646
#[lang = "termination"]
47+
#[cfg(has_termination_trait)]
3748
pub trait Termination {
3849
fn report(self) -> i32;
3950
}
4051

52+
#[cfg(has_termination_trait)]
4153
impl Termination for () {
4254
fn report(self) -> i32 {
4355
0

cortex-m-rt/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,9 @@
284284
#![no_std]
285285

286286
extern crate compiler_builtins;
287+
#[cfg(target_arch = "arm")]
287288
extern crate cortex_m;
289+
#[cfg(target_arch = "arm")]
288290
extern crate r0;
289291

290292
#[cfg(not(test))]

0 commit comments

Comments
 (0)