Skip to content

Commit

Permalink
use LLD as the default linker
Browse files Browse the repository at this point in the history
closes #39
  • Loading branch information
japaric committed Aug 25, 2018
1 parent 014dab6 commit 72e9140
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 12 deletions.
45 changes: 37 additions & 8 deletions .cargo/config
Original file line number Diff line number Diff line change
@@ -1,27 +1,56 @@
[target.thumbv6m-none-eabi]
runner = 'arm-none-eabi-gdb'
rustflags = [
"-C", "link-arg=-Wl,-Tlink.x",
"-C", "link-arg=-nostartfiles",
# LLD (shipped with the Rust toolchain) is used as the default linker
"-C", "link-arg=-Tlink.x",

# if you run into problems with LLD switch to the GNU linker by commenting out
# this line
# "-C", "linker=arm-none-eabi-ld",

# if you need to link to pre-compiled C libraries provided by a C toolchain
# use GCC as the linker by commenting out both lines above and then
# uncommenting the three lines below
# "-C", "linker=arm-none-eabi-gcc",
# "-C", "link-arg=-Wl,-Tlink.x",
# "-C", "link-arg=-nostartfiles",
]

[target.thumbv7m-none-eabi]
runner = 'arm-none-eabi-gdb'
rustflags = [
"-C", "link-arg=-Wl,-Tlink.x",
"-C", "link-arg=-nostartfiles",
# the comments under `[target.thumbv6m-none-eabi]` also apply here
"-C", "link-arg=-Tlink.x",

# "-C", "linker=arm-none-eabi-ld",

# "-C", "linker=arm-none-eabi-gcc",
# "-C", "link-arg=-Wl,-Tlink.x",
# "-C", "link-arg=-nostartfiles",
]

[target.thumbv7em-none-eabi]
runner = 'arm-none-eabi-gdb'
rustflags = [
"-C", "link-arg=-Wl,-Tlink.x",
"-C", "link-arg=-nostartfiles",
# the comments under `[target.thumbv6m-none-eabi]` also apply here
"-C", "link-arg=-Tlink.x",

# "-C", "linker=arm-none-eabi-ld",

# "-C", "linker=arm-none-eabi-gcc",
# "-C", "link-arg=-Wl,-Tlink.x",
# "-C", "link-arg=-nostartfiles",
]

[target.thumbv7em-none-eabihf]
runner = 'arm-none-eabi-gdb'
rustflags = [
"-C", "link-arg=-Wl,-Tlink.x",
"-C", "link-arg=-nostartfiles",
# the comments under `[target.thumbv6m-none-eabi]` also apply here
"-C", "link-arg=-Tlink.x",

# "-C", "linker=arm-none-eabi-ld",

# "-C", "linker=arm-none-eabi-gcc",
# "-C", "link-arg=-Wl,-Tlink.x",
# "-C", "link-arg=-nostartfiles",
]
9 changes: 5 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
//!
//! - Nightly Rust toolchain newer than `nightly-2018-04-08`: `rustup default nightly`
//! - Cargo `clone` subcommand: `cargo install cargo-clone`
//! - ARM toolchain: `sudo apt-get install gcc-arm-none-eabi` (on Ubuntu)
//! - GDB: `sudo apt-get install gdb-arm-none-eabi` (on Ubuntu)
//! - OpenOCD: `sudo apt-get install OpenOCD` (on Ubuntu)
//! - [Optional] Cargo `add` subcommand: `cargo install cargo-edit`
Expand Down Expand Up @@ -179,11 +178,13 @@
//! ``` text
//! $ cargo build
//! Compiling demo v0.1.0 (file:///home/japaric/tmp/demo)
//! error: linking with `arm-none-eabi-ld` failed: exit code: 1
//! error: linking with `rust-lld` failed: exit code: 1
//! |
//! = note: "arm-none-eabi-gcc" "-L" (..)
//! = note: "rust-lld" "-flavor" "gnu" "-L" (..)
//! (..)
//! = note: rust-lld: error: section '.vector_table' will not fit in region 'FLASH': overflowed by X bytes
//! rust-lld: error: section '.vector_table' will not fit in region 'FLASH': overflowed by Y bytes
//! (..)
//! (..)/ld: region `FLASH' overflowed by XXX bytes
//! ```
//!
//! Solution: Specify your device memory layout in the `memory.x` linker script. See [Usage]
Expand Down

0 comments on commit 72e9140

Please sign in to comment.