How to get a linker to create a map file using Cargo

I am writing a Rust program aimed at the STM32F407 processor using zinc. I would like to be able to create a linker map file. I 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 using this method.

What are other methods for creating a linker to create a map file?

+5
source share
1 answer

link-args can go to rustc via rustc -C link-args="-Wl,-Map=blink_stm32f4.map" test.rs

And there is a cargo rustflags option in the build section. See load configuration . It works as follows:

 $ cargo new --bin testbin $ cd testbin $ cat .cargo/config [build] rustflags = ["-Clink-args=-Wl,-Map=/tmp/blink_f7.map"] $ cargo build 

There is also a linker option in the cargo configuration. I am not trying to get through this gcc plus flags option, only gcc , but you can write a gcc wrapper script as:

 $ cat my-linker.sh #!/bin/sh arm-...-gcc -Wl,-Map=blink_stm32f4.map $@ 
+3
source

All Articles