From 25c4efe0550926c0c0b8a0900224b7d0bed9cfae Mon Sep 17 00:00:00 2001 From: Max Fillinger Date: Thu, 2 Oct 2025 02:02:35 +0200 Subject: [PATCH] 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. --- cortex-m-rt/src/lib.rs | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/cortex-m-rt/src/lib.rs b/cortex-m-rt/src/lib.rs index 2aaeadde..20ed4f11 100644 --- a/cortex-m-rt/src/lib.rs +++ b/cortex-m-rt/src/lib.rs @@ -153,12 +153,25 @@ //! } //! EOF //! -//! $ cargo rustc --target thumbv7m-none-eabi -- -C link-arg=-nostartfiles -C link-arg=-Tlink.x -//! +//! $ RUSTFLAGS="-C link-arg=-Tlink.x" cargo build --target thumbv7m-none-eabi //! $ file target/thumbv7m-none-eabi/debug/app //! app: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), statically linked, (..) //! ``` //! +//! To avoid typing the long command, you can create a `.cargo/config.toml` file: +//! +//! ```toml +//! [target.thumbv7m-none-eabi] +//! rustflags = ["-C", "link-arg=-Tlink.x"] +//! +//! [build] +//! target = "thumbv7m-none-eabi" +//! ``` +//! +//! With this configuration, a simple `cargo build` is enough. +//! +//! For Cortex-M4 devices, use the target thumbv7em-none-eabi instead. +//! //! # Optional features //! //! ## `device`