I am currently trying to compile a bare metal application for an ARM Cortex A8 based SoC, for that purpose I've written a custom arm-none-eabi target file and a .cargo/config file which which looks as follows
[target.arm-none-eabi] linker = "arm-none-eabi-gcc" rustflags = [ "-C", "target-cpu=cortex-a8", ]
I then tried to compile that using cargo-xbuild (already opened an issue over there) However it ignored the linker flag and compiled with /usr/bin/ld instead. If i change the file to
[target.arm-none-eabi] rustflags = [ "-C", "target-cpu=cortex-a8", "-C", "linker=arm-none-eabi-gcc" ]
Everything works fine and it uses the arm-none-eabi-gcc linker. After some trouble shooting on Github we came to the conclusion that this is apparently not cargo-xbuilds fault as compiling with cargo build and a custom sysroot will also ignore the linker flag and use /usr/bin/ld. Im currrently running on cargo 1.33.0 nightly from 2019-01-03 with rustc 1.33.0 nightly from one day later.
Has anybody got an idea why cargo ignores the linker flag and just uses the default linker / how to tell cargo to use the linker flag without defining it as a custom rustflag?