From 2221e1fa935fef1fbc8a39a478824f0b163e6399 Mon Sep 17 00:00:00 2001 From: Dario Nieuwenhuis Date: Sun, 7 Nov 2021 23:52:11 +0100 Subject: Replace rustflags with build.rs extra-link-args. Rustflags apply to ALL the crates in the graph, while we only need them for the toplevel crate which is the only one getting linked. Rustflags are not equal for all crates, this caused cargo to re-build the same dependency crate multiple times uselessly. After this change, deps are reused more, making builds faster. Note that this only applies when sharing the target/ dir for multiple crates in the repo which is not the default. --- examples/nrf/.cargo/config.toml | 12 ------------ examples/nrf/build.rs | 4 ++++ 2 files changed, 4 insertions(+), 12 deletions(-) (limited to 'examples/nrf') diff --git a/examples/nrf/.cargo/config.toml b/examples/nrf/.cargo/config.toml index 0151d1ed5..c75b5c539 100644 --- a/examples/nrf/.cargo/config.toml +++ b/examples/nrf/.cargo/config.toml @@ -2,17 +2,5 @@ # replace nRF82840_xxAA with your chip as listed in `probe-run --list-chips` runner = "probe-run --chip nRF52840_xxAA" -rustflags = [ - # LLD (shipped with the Rust toolchain) is used as the default linker - "-C", "link-arg=--nmagic", - "-C", "link-arg=-Tlink.x", - "-C", "link-arg=-Tdefmt.x", - - # Code-size optimizations. - "-Z", "trap-unreachable=no", - "-C", "inline-threshold=5", - "-C", "no-vectorize-loops", -] - [build] target = "thumbv7em-none-eabi" diff --git a/examples/nrf/build.rs b/examples/nrf/build.rs index d534cc3df..30691aa97 100644 --- a/examples/nrf/build.rs +++ b/examples/nrf/build.rs @@ -28,4 +28,8 @@ fn main() { // here, we ensure the build script is only re-run when // `memory.x` is changed. println!("cargo:rerun-if-changed=memory.x"); + + println!("cargo:rustc-link-arg-bins=--nmagic"); + println!("cargo:rustc-link-arg-bins=-Tlink.x"); + println!("cargo:rustc-link-arg-bins=-Tdefmt.x"); } -- cgit