Out of curiosity, how long does iterating on rustc take on your machine? I'm currently running
time ./x.py test src/test/ui and i'm about 10 minutes in
I'm on a laptop though, so i'm not expecting anything exceptional
15-20 minutes on a ryzen 1800x (8 core/16 thread) for a build to stage 1 std
and that's with cached llvm
That's rough, on a desktop with a pretty powerful cpu... what do you do in the meantime? Context switch to another copy of rustc?
@Matthias Prechtl Make sure you pass
-i for incremental and
--stage 1 to only build the compiler once (one or both of these might be the default for
x.py test nowadays). Also, I often don't run the entire test suite locally, just directories that are likely to change. I usually rely on CI to run the full suite.
Since I work mostly in
rustc_mir, which is pretty late in the compilation pipeline, it only takes a few minutes for a build/test cycle.
If you are working on the AST, things will be slower.
@ecstatic-morse thanks for the pointer, i'll try that one :) Curious why that's not the default?
Not sure, maybe just intertia. You modify
config.toml to ensure incremental is on by default (like I said, that may already be the case).
./x.py clean --llvm-skip-rebuild TRUE time ./x.py build
Takes 26min 24s
On an i7-8550U
I'm actually kind of impressed, given that the r7 1800X from @simulacrum takes 15-20mins
I'll try the incremental version and post an update :)
@matprec incremental will only be faster when you're making changes. The initial build will be slower
Do make sure you're always using stage 1 though.
For almost all changes you don't need a stage 2 build
Yeah that's expected :) is a newline change enough to make the incremental checker think it needs to rebuild?
Because then i'll likely try a "worst case" incremental build with a change in the parser
Not sure :slight_smile: Feel free to try
(I don't work on incremental, and
x.py is a bit different than
cargo so it might be relying on file timestamps)
Oh, one more thing. Use
x.py check, not
x.py build when you're still actively developing something. It's quite a bit faster than building.
10min sometimes. Maybe I'm remembering wrong too :)
@matprec One more one more thing. To build just the stage1 compiler with just the stage1 standard library artifacts, it's
./x.py build --stage 1 src/libstd
If you add a custom toolchain to
rustup (I call mine
stage1), which points to the build directory containing the stage 1 compiler, you can run
rustc +stage1 file.rs to test your compiler without worrying about
This means I can alternate between editing files and running individual tests without having to rebuild every time.
time ./x.py build -i --stage 1
real 3m15,065s user 13m27,142s sys 0m42,841s
Thanks so much, your input has been extremely valuable @ecstatic-morse !
I just found https://rust-lang.github.io/rustc-guide/building/suggested.html :) Still crawling through the docs, there's just so much to absorb :D
Yeah that guide is really helpful
Is it acceptable to run tests with the
-i flag? For instance,
./x.py test -i --stage 1 [path to test module]. I am 10 mins into the compile to run one test without
Significantly faster to run tests with
-i. Cut my time down to ~1/3 of that without it
I'd say go for it, afaik incremental shouldn't affect the behaviour of the compiled rustc
@Chris Simpkins ^
I have set
incremental=true in my
config.toml so I don't need to pass that flag manually all the time any more ;)
so, yes, definitely acceptable to set that flag for local testing
Ah very nice! Thank you!