book icon indicating copy to clipboard operation
book copied to clipboard

cargo objdump fails on `-triple` flag when used with a recent LLVM 11

Open airelil opened this issue 5 years ago • 2 comments

Running cargo objdump --bin app --release -- -disassemble -no-show-raw-insn -print-imm-hex as suggested in Inspecting section of QEMU chapter can produce the following error:

cargo objdump --bin app --release -- -disassemble -no-show-raw-insn -print-imm-hex
    Finished release [optimized + debuginfo] target(s) in 0.02s
llvm-objdump: Unknown command line argument '-triple'.  Try: '/home/vk/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/bin/llvm-objdump --help'
llvm-objdump: Did you mean '--triple'?
llvm-objdump: Unknown command line argument '-disassemble'.  Try: '/home/vk/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/bin/llvm-objdump --help'
llvm-objdump: Did you mean '--disassemble'?
llvm-objdump: Unknown command line argument '-no-show-raw-insn'.  Try: '/home/vk/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/bin/llvm-objdump --help'
llvm-objdump: Did you mean '--no-show-raw-insn'?
llvm-objdump: for the --reloc option: may only occur zero or one times!
llvm-objdump: Unknown command line argument '-print-imm-hex'.  Try: '/home/vk/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/bin/llvm-objdump --help'
llvm-objdump: Did you mean '--print-imm-hex'?

It seems that it's fixed with https://github.com/rust-embedded/cargo-binutils/commit/aa5464b4eaacfabe808d00db2e155df3740425a2, but might not been yet published on crates.io (https://github.com/rust-embedded/cargo-binutils/issues/93) I'm using Ubuntu 20.04 with following llvm-objdump version:

bin/llvm-objdump --version
LLVM (http://llvm.org/):
  LLVM version 11.0.0-rust-1.47.0-stable
  Optimized build.
  Default target: x86_64-unknown-linux-gnu
  Host CPU: ivybridge

The workaround for me was installing cargo-binutils from GitHub and running it with double hyphens for all flags:

cargo install --git https://github.com/rust-embedded/cargo-binutils.git

cargo objdump --bin app --release -- --disassemble --no-show-raw-insn --print-imm-hex

airelil avatar Oct 10 '20 23:10 airelil

I have exactly the same problem on windows.

ghost avatar Oct 11 '20 16:10 ghost

Is issue actual?

burrbull avatar Jul 28 '23 08:07 burrbull