Skip to content

Commit b693a02

Browse files
committed
Introduce dev command 'cheat sheets' (rust-lang#572)
* Introduce dev command 'cheat sheets' * edits in response to feedback
1 parent c14042a commit b693a02

File tree

2 files changed

+124
-1
lines changed

2 files changed

+124
-1
lines changed

rmc-docs/src/SUMMARY.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@
1515
- [Loops, unwinding, and bounds](./tutorial-loops-unwinding.md)
1616
- [Where to start on real code](./tutorial-real-code.md)
1717

18-
- [RMC developer documentation]()
18+
- [RMC developer documentation](./dev-documentation.md)
1919

2020
- [RMC dashboard](./dashboard.md)

rmc-docs/src/dev-documentation.md

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
# RMC developer documentation
2+
3+
## Build command cheat sheet
4+
5+
```bash
6+
# Normal build
7+
./x.py build -i --stage 1 library/std
8+
```
9+
```bash
10+
# Once built successfully once, do a faster rebuild
11+
./x.py build -i --stage 1 library/std --keep-stage 1
12+
```
13+
([`--keep-stage` comes with caveats](https://rustc-dev-guide.rust-lang.org/building/suggested.html#incremental-builds-with---keep-stage). Know that it may cause spurious build failures.)
14+
```bash
15+
# Full regression suite
16+
./scripts/rmc-regression.sh
17+
```
18+
```bash
19+
# Test suite run (to run a specific suite from src/test/, just remove the others)
20+
./x.py test -i --stage 1 rmc firecracker prusti smack expected cargo-rmc
21+
```
22+
```bash
23+
# Dashboard run
24+
./scripts/setup/install_dashboard_deps.sh
25+
./x.py run -i --stage 1 dashboard
26+
```
27+
```bash
28+
# Documentation build
29+
cd rmc-docs
30+
./build-docs.sh
31+
```
32+
33+
### Resolving development issues
34+
35+
```bash
36+
# "error[E0514]: found crate `std` compiled by an incompatible version of rustc"
37+
# or similar error? Clean build RMC:
38+
rm -rf target build
39+
./x.py build -i --stage 1 library/std
40+
```
41+
42+
## Git command cheat sheet
43+
44+
RMC follows the "squash and merge pull request" pattern.
45+
As a result, the "main commit message" will be the title of your pull request.
46+
The individual commit message bodies you commit during development will by default be a bulleted list in the squashed commit message body, but these are editable at merge time.
47+
So you don't have to worry about a series of "oops typo fix" messages while fixing up your pull request, these can be edited out of the final message when you click merge.
48+
49+
```bash
50+
# Set up your git fork
51+
git remote add fork [email protected]:${USER}/rmc.git
52+
```
53+
```bash
54+
# Reset everything. Don't have any uncommitted changes!
55+
git clean -xffd
56+
git submodule foreach --recursive git clean -xffd
57+
git submodule update --init
58+
# Don't forget to re-configure your RMC build:
59+
./configure \
60+
--enable-debug \
61+
--set=llvm.download-ci-llvm=true \
62+
--set=rust.debug-assertions-std=false \
63+
--set=rust.deny-warnings=false
64+
```
65+
```bash
66+
# Done with that PR, time for a new one?
67+
git switch main
68+
git pull origin
69+
git submodule update --init
70+
./x.py build -i --stage 1 library/std
71+
```
72+
```bash
73+
# Need to update local branch (e.g. for an open pull request?)
74+
git fetch origin
75+
git merge origin/main
76+
# Or rebase, but that requires a force push,
77+
# and because we squash and merge, an extra merge commit in a PR doesn't hurt.
78+
```
79+
```bash
80+
# Search only git-tracked files
81+
git grep codegen_panic
82+
```
83+
```bash
84+
# See all commits that are part of RMC, not part of Rust
85+
git log --graph --oneline origin/upstream-rustc..origin/main
86+
```
87+
```bash
88+
# See all files modified by RMC (compared to upstream Rust)
89+
git diff --stat origin/upstream-rustc..origin/main
90+
```
91+
92+
## RMC command cheat sheet
93+
94+
These can help understand what RMC is generating or encountering on an example or test file:
95+
96+
```bash
97+
# Enable `debug!` macro logging output when running RMC:
98+
rmc --debug file.rs
99+
```
100+
```bash
101+
# Keep CBMC Symbol Table and Goto-C output (.json and .goto)
102+
rmc --keep-temps file.rs
103+
```
104+
```bash
105+
# Generate "C code" from CBMC IR (.c)
106+
rmc --gen-c file.rs
107+
```
108+
109+
## CBMC command cheat sheet
110+
111+
```bash
112+
# See CBMC IR from a C file:
113+
goto-cc file.c -o file.out
114+
goto-instrument --print-internal-representation file.out
115+
# or (for json symbol table)
116+
cbmc --show-symbol-table --json-ui file.out
117+
# or (an alternative concise format)
118+
cbmc --show-goto-functions file.out
119+
```
120+
```bash
121+
# Recover C from goto-c binary
122+
goto-instrument --dump-c file.out > file.gen.c
123+
```

0 commit comments

Comments
 (0)