Skip to content

Commit e6c7249

Browse files
bors[bot]adamgreig
andauthored
Merge #423
423: Swap to just-stabilised asm!() and global_asm!() macros r=thejpster a=adamgreig Once Rust 1.59 is released in a couple of days, the `asm!()` and `global_asm!()` macros will become stable, and we will no longer require the various precompiled binaries we've used until now in cortex-m and cortex-m-rt. cc #420. This PR uses `asm!()` in cortex-m, and removes the inline-asm feature, since I anticipate this going into cortex-m 0.8 and so we don't need to leave it behind for compatibility. In various places the previous version would call an extern C method when built for the native target, which would only fail at link time; to preserve the ability to build on x86 I've either made the whole method require the `cortex_m` configuration, or where appropriate/convenient simply skipped the `asm!()` call. This PR replaces the old gcc-preprocessed `asm.S` in cortex-m-rt with use of `global_asm!()`, although since you can't normally use `#[cfg(...)]` attributes with `global_asm!()`, there's also a slightly scary macro modified from one invented by `@Dirbaio` for a similar purpose. I considered putting the initialisation of LR behind an armv6m flag, but since we want to restore it after calling `__pre_init` it seemed better to just leave it the same on both targets. I added Cargo features to optionally set SP and VTOR at startup, which has been variously requested but would previously have required multiplicatively more pre-built binaries. Now: no problem. Relevant issues: * rust-embedded/cortex-m-rt#283 * rust-embedded/cortex-m-rt#55 * rust-embedded/cortex-m-rt#254 * rust-embedded/cortex-m-rt#102 * rust-embedded/cortex-m-rt#338 I've tested these on a couple of targets (and updated the CI): on the whole there's a small improvement in code size due to everyone getting inlined asm, especially in `cortex_m::interrupt::free()`. The major downside is we bump our MSRV from 1.42 (March 2020) to 1.59 (Feb 2022). For cortex-m, I propose putting these changes in the upcoming 0.8 release (which is technically what the master branch is already on) and not backporting. For cortex-m-rt I'm not sure: we don't have any other pending breaking changes, so we could consider a patch release. Anyway, this PR doesn't commit to any particular releases, so we can decide that later. For cortex-m-semihosting/panic-semihosting I think a patch release would be ideal, especially since we had to yank the last c-m-sh release due to conflicting prebuilt binaries (a problem that should now vanish). Also tagging these issues that I think might also benefit from new inline asm: * #265 * #215 * #406 Co-authored-by: Adam Greig <[email protected]>
2 parents 8bb2a61 + ac2a836 commit e6c7249

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+541
-1281
lines changed

Diff for: .github/bors.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ delete_merged_branches = true
33
required_approvals = 1
44
status = [
55
"ci-linux (stable)",
6-
"ci-linux (1.42.0)",
6+
"ci-linux (1.59.0)",
77
"rt-ci-linux (stable)",
8-
"rt-ci-linux (1.42.0)",
8+
"rt-ci-linux (1.59.0)",
99
"rt-ci-other-os (macOS-latest)",
1010
"rt-ci-other-os (windows-latest)",
1111
"rustfmt",

Diff for: .github/workflows/ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616

1717
include:
1818
# Test MSRV
19-
- rust: 1.42.0
19+
- rust: 1.59.0
2020

2121
# Test nightly but don't fail
2222
- rust: nightly

Diff for: .github/workflows/rt-ci.yml

+1-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ jobs:
1111
continue-on-error: ${{ matrix.experimental || false }}
1212
strategy:
1313
matrix:
14-
# All generated code should be running on stable now
15-
rust: [nightly, stable, 1.42.0]
14+
rust: [nightly, stable, 1.59.0]
1615

1716
include:
1817
# Nightly is only for reference and allowed to fail

Diff for: CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
2121
### Fixed
2222
- Fixed `singleton!()` statics sometimes ending up in `.data` instead of `.bss` (#364, #380).
2323

24+
### Changed
25+
- Inline assembly is now always used, requiring Rust 1.59.
26+
2427
### Removed
2528
- removed all peripherals `ptr()` functions in favor of the associated constant `PTR` (#385).
29+
- removed `inline-asm` feature which is now always enabled
2630

2731
## [v0.7.4] - 2021-12-31
2832

Diff for: Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ name = "cortex-m"
1212
readme = "README.md"
1313
repository = "https://github.com/rust-embedded/cortex-m"
1414
version = "0.7.4"
15-
edition = "2018"
15+
edition = "2021"
16+
rust-version = "1.59"
1617
links = "cortex-m" # prevent multiple versions of this crate to be linked together
1718

1819
[dependencies]
@@ -29,7 +30,6 @@ optional = true
2930
[features]
3031
cm7 = []
3132
cm7-r0p1 = ["cm7"]
32-
inline-asm = []
3333
linker-plugin-lto = []
3434
std = []
3535

Diff for: README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ This project is developed and maintained by the [Cortex-M team][team].
1111

1212
## Minimum Supported Rust Version (MSRV)
1313

14-
This crate is guaranteed to compile on stable Rust 1.42 and up. It might compile with older versions but that may change in any new patch release.
14+
This crate is guaranteed to compile on stable Rust 1.59 and up. It might compile with older versions but that may change in any new patch release.
1515

1616
## License
1717

Diff for: asm-toolchain

-1
This file was deleted.

0 commit comments

Comments
 (0)