-
Notifications
You must be signed in to change notification settings - Fork 46
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
Infer executable path #15
Comments
Inferring the path should be done for these tools: |
Working on this because having to type the full path annoys me to no end. |
japaric
added a commit
that referenced
this issue
Aug 26, 2018
this commits extends the UI with the following flag: - `--bin` - `--example` - `--lib` - `--release` if one of `--bin`, `--example` or `--lib` is used then cargo-$tool will first build the Cargo project and then proceed to run the llvm tool on the output artifact -- that is the output artifact will be the first argument passed to the llvm tool. `--release` controls whether the project is compiled with optimizations or not. if none of these three flags is passed then the old behavior is used. No path to an artifact is passed to the llvm tool and the user is expected to provide it. this new logic supports workspaces and the CARGO_TARGET_DIR env variable. closes #15
Merged
PR #20 implements this |
bors bot
added a commit
that referenced
this issue
Aug 28, 2018
20: build and inspect r=therealprof a=japaric build and inspect this commits extends the UI with the following flag: - `--bin` - `--example` - `--lib` - `--release` if one of `--bin`, `--example` or `--lib` is used then cargo-$tool will first build the Cargo project and then proceed to run the llvm tool on the output artifact -- that is the output artifact will be the first argument passed to the llvm tool. `--release` controls whether the project is compiled with optimizations or not. if none of these three flags is passed then the old behavior is used. No path to an artifact is passed to the llvm tool and the user is expected to provide it. this new logic supports workspaces and the CARGO_TARGET_DIR env variable. closes #15 r? @rust-embedded/tools (anyone) This builds on top on #19 so that should be merged first --- ### Sample outputs: ``` rust $ cargo new --lib foo && cd $_ $ cat >src/lib.rs <<'EOF' #![no_std] #[no_mangle] pub fn foo(x: u32, y: u32) -> u32 { x + y } EOF $ cargo objdump --lib --release -- -disassemble 2>/dev/null /home/japaric/tmp/foo/target/release/libfoo.rlib(foo-136cd7af94a84b98.foo.awvzjwiu-cgu.0.rcgu.o): file format ELF64-x86-64 Disassembly of section .text.foo: foo: 0: 8d 04 37 leal (%rdi,%rsi), %eax 3: c3 retq $ cargo objdump --target aarch64-unknown-linux-gnu --lib --release -- -disassemble 2>/dev/null /home/japaric/tmp/foo/target/aarch64-unknown-linux-gnu/release/libfoo.rlib(foo-05ebc283581f4ba3.foo.9kf7hsz7-cgu.0.rcgu.o): file format ELF64-aarch64-little Disassembly of section .text.foo: foo: 0: 20 00 00 0b add w0, w1, w0 4: c0 03 5f d6 ret $ cargo objdump --target riscv32imac-unknown-none-elf --lib --release -- -disassemble 2>/dev/null /home/japaric/tmp/foo/target/riscv32imac-unknown-none-elf/release/libfoo.rlib(foo-05ebc283581f4ba3.foo.9kf7hsz7-cgu.0.rcgu.o): file format ELF32-riscv Disassembly of section .text.foo: foo: 0: 33 85 a5 00 add a0, a1, a0 4: 67 80 00 00 ret $ cargo objdump --target thumbv7m-none-eabi --lib --release -- -disassemble 2>/dev/null /home/japaric/tmp/foo/target/thumbv7m-none-eabi/release/libfoo.rlib(foo-05ebc283581f4ba3.foo.9kf7hsz7-cgu.0.rcgu.o): file format ELF32-arm-little Disassembly of section .text.foo: foo: 0: 08 44 add r0, r1 2: 70 47 bx lr ``` Help text: ``` console $ cargo nm -h cargo-nm 0.1.2 Proxy for the `llvm-nm` tool shipped with the Rust toolchain. USAGE: cargo-nm [FLAGS] [OPTIONS] [--] [args]... FLAGS: -h, --help Prints help information --lib Build only this package's library --release Build artifacts in release mode, with optimizations -V, --version Prints version information -v, --verbose Use verbose output OPTIONS: --bin <NAME> Build only the specified binary --example <NAME> Build only the specified example --target <TRIPLE> Target triple for which the code is compiled ARGS: <args>... The specified <args>... will all be passed to the final tool invocation. ``` Co-authored-by: Jorge Aparicio <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
cargo objdump -- -d -no-show-raw-insn target/thumbv7m-none-eabi/debug/app
is too long to write and redundant if you working on a binary crate. Let's havecargo-binutils
infer the path of the executable. At the end we should be able to just writecargo objdump -- -d -no-show-raw-insn
.Here's what the logic should do (this may contain some errors / holes):
--
use that and don't try to infer the pathCARGO_TARGET_DIR
is set use that$workspace_root/target
$crate_root/target
(XXX what about--manifest-path
?)thumbv7m-none-eabi
) to the path.--release
before--
userelease
as the next path segment; otherwise usedebug
as the next path segment--example $E
before--
appendexamples/$E
to the path.--bin $B
before--
append$B
to the pathsrc/main.rs
exists) append the crate name to the pathsrc/main.rs
is missing) error out (XXX we could check this earlier)tools_args
The text was updated successfully, but these errors were encountered: