Skip to content

Commit

Permalink
Update 3.1-frontend.md
Browse files Browse the repository at this point in the history
  • Loading branch information
hxuhack authored Jul 9, 2024
1 parent ba5f5e3 commit 308c222
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/3.1-frontend.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,10 @@ Traditionally, performing code analysis requires modifying the compiler source c
Developers then need to recompile the compiler to activate these new passes, which can be cumbersome.
The Rust compiler offers a more portable way to conduct code analysis using the [rustc_driver](https://rustc-dev-guide.rust-lang.org/rustc-driver.html).
We refer to this approach as the **frontend** method because it allows developers to directly access internal compiler data and perform analysis as callbacks.

## Custom Cargo Commands
To support project-level program analysis, we want the analysis tool to be integrated into cargo as [subcommands](https://doc.rust-lang.org/cargo/reference/external-tools.html). To this end, we can name the tool as cargo-toolname and place it in $CARGO_HOME/bin or $PATH. Then we can execute the tool via the following command.
```
cargo toolname -more_arguments
```
Cargo will automatically search the binaries named cargo-toolname from the paths.

0 comments on commit 308c222

Please sign in to comment.