Move link-arg setting from .cargo/config.toml to build.rs to make it less easy to forget about

This commit is contained in:
Adam Greig
2023-02-17 17:18:22 +00:00
parent 627ac5c5d5
commit a2a454a36d
2 changed files with 21 additions and 12 deletions

View File

@@ -7,6 +7,8 @@
//! Cargo re-run the build script whenever `memory.x` is changed,
//! updating `memory.x` ensures a rebuild of the application with the
//! new memory settings.
//!
//! The build script also sets the linker flags to tell it which link script to use.
use std::env;
use std::fs::File;
@@ -28,4 +30,14 @@ fn main() {
// here, we ensure the build script is only re-run when
// `memory.x` is changed.
println!("cargo:rerun-if-changed=memory.x");
// Specify linker arguments.
// `--nmagic` is required if memory section addresses are not aligned to 0x10000,
// for example the FLASH and RAM sections in your `memory.x`.
// See https://github.com/rust-embedded/cortex-m-quickstart/pull/95
println!("cargo:rustc-link-arg=--nmagic");
// Set the linker script to the one provided by cortex-m-rt.
println!("cargo:rustc-link-arg=-Tlink.x");
}