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

objdump: use -arch-name instead of -triple #19

Merged
merged 1 commit into from
Aug 28, 2018
Merged

objdump: use -arch-name instead of -triple #19

merged 1 commit into from
Aug 28, 2018

Conversation

japaric
Copy link
Member

@japaric japaric commented 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

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

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
@japaric
Copy link
Member Author

japaric commented Aug 27, 2018

ping @ryankurte @therealprof anyone of you up for reviewing this?

Copy link
Contributor

@therealprof therealprof left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@japaric
Copy link
Member Author

japaric commented Aug 28, 2018

bors r=therealprof

bors bot added a commit that referenced this pull request 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
Copy link
Contributor

bors bot commented Aug 28, 2018

Build succeeded

@bors bors bot merged commit 85bcdc6 into master Aug 28, 2018
@bors bors bot deleted the arch-name branch August 28, 2018 11:33
bors bot added a commit that referenced this pull request 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
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

error: unable to get target for 'riscv32imac-unknown-none-elf'
2 participants