Closed
Description
STR
$ cat src/lib.rs
#![no_std]
#[no_mangle]
pub fn foo(x: u32, y: u32) -> u32 {
x + y
}
$ cargo build --target riscv32imac-unknown-none-elf --release
$ cargo objdump --target riscv32imac-unknown-none-elf -v -- -d target/riscv32imac-unknown-none-elf/release/libfoo.rlib
"/home/japaric/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/bin/llvm-objdump" "-triple" "riscv32imac-unknown-none-elf" "-d" "target/riscv32imac-unknown-none-elf/release/libfoo.rlib"
target/riscv32imac-unknown-none-elf/release/libfoo.rlib(foo-5f01dd28752961b9.foo0-d59093d565f158ef2f92ae2d0a10a47.rs.rcgu.o): file format ELF32-riscv
/home/japaric/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/bin/llvm-objdump: 'foo-5f01dd28752961b9.foo0-d59093d565f158ef2f92ae2d0a10a47.rs.rcgu.o': can't find target: : error: unable to get target for 'riscv32imac-unknown-none-elf', see --version and --triple.
.
The problem is that the triple passed to llvm-objdump is not a valid LLVM triple; riscv32imac
is not a valid LLVM architecture name.
A solution to this problem would be to use pass -arch-name
, instead of -triple
, to llvm-objdump. The argument to pass would then have to be a valid LLVM architecture (see cargo objdump -- -version
) so we would need to map the Rust architecture (see rustc --target $T --print cfg
) into a LLVM architecture. We have to be careful with the thumbv*
targets which have target_arch: "arm"
but actually map to "thumb" LLVM architecture.