Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error: unable to get target for 'riscv32imac-unknown-none-elf' #17

Closed
japaric opened this issue Aug 8, 2018 · 7 comments · Fixed by #19
Closed

error: unable to get target for 'riscv32imac-unknown-none-elf' #17

japaric opened this issue Aug 8, 2018 · 7 comments · Fixed by #19
Labels
bug Something isn't working help wanted Extra attention is needed
Milestone

Comments

@japaric
Copy link
Member

japaric commented Aug 8, 2018

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.

@japaric japaric added bug Something isn't working help wanted Extra attention is needed labels Aug 8, 2018
@japaric japaric added this to the RC1 milestone Aug 8, 2018
@japaric
Copy link
Member Author

japaric commented Aug 13, 2018

cc @rust-embedded/riscv

@danc86
Copy link

danc86 commented Aug 13, 2018

Makes me wish we had kept the rust arch name as "riscv" instead of "riscv32" ... but there is no nice solution here, the GNU toolchain insists it is "riscv32" or "riscv64" not "riscv". :-(

@japaric
Copy link
Member Author

japaric commented Aug 25, 2018

Also working on this while I work on #15

japaric added a commit that referenced this issue Aug 25, 2018
infer the arch-name from the output of `rustc --print cfg` is more robust than
just using the target name for the -triple flag.

fixes #17
@dvc94ch
Copy link
Member

dvc94ch commented Aug 26, 2018 via email

@japaric
Copy link
Member Author

japaric commented Aug 26, 2018

@dvc94ch probably because no one asked for it. You can send a PR to add it. You can use rust-lang/rust#51962 as a reference.

@dvc94ch
Copy link
Member

dvc94ch commented Aug 26, 2018 via email

@japaric
Copy link
Member Author

japaric commented Aug 26, 2018

PR #19 fixes this

bors bot added a commit that referenced this issue Aug 28, 2018
19: objdump: use -arch-name instead of -triple r=therealprof a=japaric

infer the arch-name from the output of `rustc --print cfg` is more robust than
just using the target name for the -triple flag.

fixes #17

r? @rust-embedded/tools (anyone)
cc @danc86

Co-authored-by: Jorge Aparicio <[email protected]>
@bors bors bot closed this as completed in #19 Aug 28, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants