Skip to content

Commit 25c4efe

Browse files
committed
Fix build command in docs
The docs say to pass the -nostartfiles flag to the linker. This is a leftover from when GCC was used as the linker. This fixes the build command so that it works with the default rust-ldd linker. While at it, add a sample .cargo/config.toml file.
1 parent a3ff54b commit 25c4efe

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

cortex-m-rt/src/lib.rs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,12 +153,25 @@
153153
//! }
154154
//! EOF
155155
//!
156-
//! $ cargo rustc --target thumbv7m-none-eabi -- -C link-arg=-nostartfiles -C link-arg=-Tlink.x
157-
//!
156+
//! $ RUSTFLAGS="-C link-arg=-Tlink.x" cargo build --target thumbv7m-none-eabi
158157
//! $ file target/thumbv7m-none-eabi/debug/app
159158
//! app: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), statically linked, (..)
160159
//! ```
161160
//!
161+
//! To avoid typing the long command, you can create a `.cargo/config.toml` file:
162+
//!
163+
//! ```toml
164+
//! [target.thumbv7m-none-eabi]
165+
//! rustflags = ["-C", "link-arg=-Tlink.x"]
166+
//!
167+
//! [build]
168+
//! target = "thumbv7m-none-eabi"
169+
//! ```
170+
//!
171+
//! With this configuration, a simple `cargo build` is enough.
172+
//!
173+
//! For Cortex-M4 devices, use the target thumbv7em-none-eabi instead.
174+
//!
162175
//! # Optional features
163176
//!
164177
//! ## `device`

0 commit comments

Comments
 (0)