33. Usage

Note

flip-link is known to work with ARM Cortex-M programs that link to version 0.6.x or 0.7.x of the cortex-m-rt crate and are linked using the linker shipped with the toolchain (LLD).

At this time, it hasn’t been tested with other architectures or runtime crates.

flip-link is used as a linker during the build process. To use it, configure your build environment in one of the following ways.

33.1. Using cargo

To use with cargo, modify the .cargo/config.toml:

[target.'cfg(all(target_arch = "arm", target_os = "none"))']
# (..)
linker = "flip-link"

33.2. Using rustc

To use with rustc, pass -C linker=flip-link:

rustc src/main.rs -C panic=abort --target thumbv7em-none-eabihf -C linker=flip-link

33.3. Logging

If you want to see what flip-link is up to, you can set these environment variables:

export RUST_LOG=info

This will produce something like:

$ cargo build
...
INFO rustc_codegen_ssa::back::link reporting linker output: flavor=Gnu(No, Yes)
INFO rustc_codegen_ssa::back::link linker stderr:
[INFO  flip_link] found MemoryEntry(line=3, origin=0x20000000, length=0x10000) in /home/ana/git/knurling-rs/test-flip-link-app/target/thumbv7em-none-eabi/debug/build/lm3s6965-bc3a1fd440e03494/out/memory.x
[INFO  flip_link] used RAM spans: origin=0x20000000, length=12, align=4
[INFO  flip_link] new RAM region: ORIGIN=0x2000fff0, LENGTH=16
INFO rustc_codegen_ssa::back::link linker stdout:
INFO rustc_codegen_ssa::back::link reporting linker output: flavor=Gnu(No, Yes)
INFO rustc_codegen_ssa::back::link linker stderr:
[INFO  flip_link] found MemoryEntry(line=3, origin=0x20000000, length=0x10000) in /home/ana/git/knurling-rs/test-flip-link-app/target/thumbv7em-none-eabi/debug/build/lm3s6965-bc3a1fd440e03494/out/memory.x
[INFO  flip_link] used RAM spans: origin=0x20000000, length=12, align=4
[INFO  flip_link] new RAM region: ORIGIN=0x2000fff0, LENGTH=16
INFO rustc_codegen_ssa::back::link linker stdout:
   Finished `dev` profile [unoptimized + debuginfo] target(s) in 4.02s

You can see even more detail about how expressions are parsed using RUST_LOG=debug.