A cargo sub-commond for spanning the call stack for a `cortex-m` bare metal application.
A cargo subcommand for spanning the call stack for a `cortex-m` bare metal application.
## Requirements
- A recent (Edition 2018) Rust toolchain.
- LLVM `opt` tool, as distributed in the arch-linux LLVM package. As the tool uses `opt` to operate on the underlying `llvm-ir` we can give no compatibility guarantees if `opt` version differs to the `rustc` LLVM backend. The tool has been tested to work with LLVM `opt` 7.0, while the Rust toolchain has already moved to the LLVM 8.0 preview.
Out {hash: None, crate_name: None, out_dir: None }
thread 'main' panicked at '--out-dir missing', libcore/option.rs:1008:5
note: Run with `RUST_BACKTRACE=1`for a backtrace.
```
In this case, `rustc` did not recompile the crate (or example), and thus we cannot determine the output directory. This can be solved by forcing recompilation (e.g. by touching the respective source file.)
error: extra arguments to `rustc` can only be passed to one target, consider filtering
the package by passing e.g. `--lib` or `--bin NAME` to specify a single target
thread 'main' panicked at 'assertion failed: status.success()', src/main.rs:228:13
note: Run with `RUST_BACKTRACE=1`for a backtrace.
```
In this case `rustc` will abort, as extra arguments cannot be parsed to multiple targets. This problem is solved by giving a single target (see Usage above).
``` sh
cargo call-stack > callgraph.dot
...
error: can't perform LTO when compiling incrementally
```
In this case `rustc` fails, as we require LTO optimization in order to achieve a single (monolithic) LLVM-IR for the call-graph analysis. This problem is solved by adding the `--release` flag (see Usage above).
## Tech notes
### Cargo sub-commands
...
...
@@ -38,3 +92,13 @@ the package by passing e.g. `--lib` or `--bin NAME` to specify a single target
```
This is fine Since we are interested in analysing a single application. This error is reported directly by `rustc` (not by the `call-stack` command).
## Todo
### Usabililty improvements
- forcing rebuild or find the current hash somehow (perhaps by date of generated files, if re-compilation is not done (can be checked))