I'm writing a Rust program targeted for an STM32F407 processor using zinc. I'd like to be able to produce a linker map file. I've found that I can put the following in my main.rs and this gives me the desired result:
#![feature(link_args)]
#[link_args = "-Wl,-Map=blink_stm32f4.map"]
extern {}
However, the documentation for link_args
suggests not to use this method.
What other methods exist to get the linker to produce a map file?
link-args
is possible to pass to rustc
via rustc -C link-args="-Wl,-Map=blink_stm32f4.map" test.rs
.
And there is option of cargo
rustflags
in build
section. See cargo config. It works like this:
$ cargo new --bin testbin
$ cd testbin
$ cat .cargo/config
[build]
rustflags = ["-Clink-args=-Wl,-Map=/tmp/blink_f7.map"]
$ cargo build
Also there is linker
option in cargo
config. I don't try to pass via
this option gcc
plus flags
, only gcc
, but you can write gcc
wrapper script like:
$ cat my-linker.sh
#!/bin/sh
arm-...-gcc -Wl,-Map=blink_stm32f4.map $@