Skip to content

Commit 72e9140

Browse files
committed
use LLD as the default linker
closes #39
1 parent 014dab6 commit 72e9140

File tree

2 files changed

+42
-12
lines changed

2 files changed

+42
-12
lines changed

.cargo/config

+37-8
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,56 @@
11
[target.thumbv6m-none-eabi]
22
runner = 'arm-none-eabi-gdb'
33
rustflags = [
4-
"-C", "link-arg=-Wl,-Tlink.x",
5-
"-C", "link-arg=-nostartfiles",
4+
# LLD (shipped with the Rust toolchain) is used as the default linker
5+
"-C", "link-arg=-Tlink.x",
6+
7+
# if you run into problems with LLD switch to the GNU linker by commenting out
8+
# this line
9+
# "-C", "linker=arm-none-eabi-ld",
10+
11+
# if you need to link to pre-compiled C libraries provided by a C toolchain
12+
# use GCC as the linker by commenting out both lines above and then
13+
# uncommenting the three lines below
14+
# "-C", "linker=arm-none-eabi-gcc",
15+
# "-C", "link-arg=-Wl,-Tlink.x",
16+
# "-C", "link-arg=-nostartfiles",
617
]
718

819
[target.thumbv7m-none-eabi]
920
runner = 'arm-none-eabi-gdb'
1021
rustflags = [
11-
"-C", "link-arg=-Wl,-Tlink.x",
12-
"-C", "link-arg=-nostartfiles",
22+
# the comments under `[target.thumbv6m-none-eabi]` also apply here
23+
"-C", "link-arg=-Tlink.x",
24+
25+
# "-C", "linker=arm-none-eabi-ld",
26+
27+
# "-C", "linker=arm-none-eabi-gcc",
28+
# "-C", "link-arg=-Wl,-Tlink.x",
29+
# "-C", "link-arg=-nostartfiles",
1330
]
1431

1532
[target.thumbv7em-none-eabi]
1633
runner = 'arm-none-eabi-gdb'
1734
rustflags = [
18-
"-C", "link-arg=-Wl,-Tlink.x",
19-
"-C", "link-arg=-nostartfiles",
35+
# the comments under `[target.thumbv6m-none-eabi]` also apply here
36+
"-C", "link-arg=-Tlink.x",
37+
38+
# "-C", "linker=arm-none-eabi-ld",
39+
40+
# "-C", "linker=arm-none-eabi-gcc",
41+
# "-C", "link-arg=-Wl,-Tlink.x",
42+
# "-C", "link-arg=-nostartfiles",
2043
]
2144

2245
[target.thumbv7em-none-eabihf]
2346
runner = 'arm-none-eabi-gdb'
2447
rustflags = [
25-
"-C", "link-arg=-Wl,-Tlink.x",
26-
"-C", "link-arg=-nostartfiles",
48+
# the comments under `[target.thumbv6m-none-eabi]` also apply here
49+
"-C", "link-arg=-Tlink.x",
50+
51+
# "-C", "linker=arm-none-eabi-ld",
52+
53+
# "-C", "linker=arm-none-eabi-gcc",
54+
# "-C", "link-arg=-Wl,-Tlink.x",
55+
# "-C", "link-arg=-nostartfiles",
2756
]

src/lib.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
//!
55
//! - Nightly Rust toolchain newer than `nightly-2018-04-08`: `rustup default nightly`
66
//! - Cargo `clone` subcommand: `cargo install cargo-clone`
7-
//! - ARM toolchain: `sudo apt-get install gcc-arm-none-eabi` (on Ubuntu)
87
//! - GDB: `sudo apt-get install gdb-arm-none-eabi` (on Ubuntu)
98
//! - OpenOCD: `sudo apt-get install OpenOCD` (on Ubuntu)
109
//! - [Optional] Cargo `add` subcommand: `cargo install cargo-edit`
@@ -179,11 +178,13 @@
179178
//! ``` text
180179
//! $ cargo build
181180
//! Compiling demo v0.1.0 (file:///home/japaric/tmp/demo)
182-
//! error: linking with `arm-none-eabi-ld` failed: exit code: 1
181+
//! error: linking with `rust-lld` failed: exit code: 1
183182
//! |
184-
//! = note: "arm-none-eabi-gcc" "-L" (..)
183+
//! = note: "rust-lld" "-flavor" "gnu" "-L" (..)
184+
//! (..)
185+
//! = note: rust-lld: error: section '.vector_table' will not fit in region 'FLASH': overflowed by X bytes
186+
//! rust-lld: error: section '.vector_table' will not fit in region 'FLASH': overflowed by Y bytes
185187
//! (..)
186-
//! (..)/ld: region `FLASH' overflowed by XXX bytes
187188
//! ```
188189
//!
189190
//! Solution: Specify your device memory layout in the `memory.x` linker script. See [Usage]

0 commit comments

Comments
 (0)