Stream: t-compiler/help

Topic: freeze stage0


Xavier Denis (Jul 13 2020 at 18:22, on Zulip):

Is it possible to 'freeze' stage0? it seems crazy that if I change a single line in a mir transformation i have to recompile stage0 and then all of stage1, why can't I just recompile librustc_mir?

bjorn3 (Jul 13 2020 at 18:23, on Zulip):

./x.py build --keep-stage 0 I think

LeSeulArtichaut (Jul 13 2020 at 18:23, on Zulip):

I think if you use --keep-stage 1, stage 1 stdlib won't be compiled again

Xavier Denis (Jul 13 2020 at 18:23, on Zulip):

can i set those options in config.toml?

bjorn3 (Jul 13 2020 at 18:25, on Zulip):

I don't think so

Xavier Denis (Jul 13 2020 at 18:29, on Zulip):

weeeeee using keep-stage 0 dropped a 1 line change rebuild from 5m42 to 1m30

Xavier Denis (Jul 13 2020 at 18:29, on Zulip):

still long but muuuch more manageable

Xavier Denis (Jul 13 2020 at 18:29, on Zulip):

if lld worked on mac i'd switch to it since that seems to speed things up as well

Joshua Nelson (Jul 13 2020 at 18:37, on Zulip):

can i set those options in config.toml?

You don't want to, --keep-stage will lead to weird errors if the compiler changes too much, you need to recompile the standard library once in a while

Joshua Nelson (Jul 13 2020 at 18:38, on Zulip):

I have to recompile stage0 then all of stage1

Do you need stage1 specifically? Can you use build --stage 1 src/libstd instead? That will only build the stage0 compiler

Xavier Denis (Jul 13 2020 at 18:42, on Zulip):

ugh... using keep-stage 0 doesn't work, it doesn't seem to compile my changes in

Xavier Denis (Jul 13 2020 at 18:42, on Zulip):

I need to build librustc_mir

LeSeulArtichaut (Jul 13 2020 at 18:42, on Zulip):

What command were you using?

Xavier Denis (Jul 13 2020 at 18:42, on Zulip):

./x.py build -i --stage 1 --keep-stage 0

Xavier Denis (Jul 13 2020 at 18:43, on Zulip):

it seems really weird cuz all i did was include logging

LeSeulArtichaut (Jul 13 2020 at 18:43, on Zulip):

Joshua Nelson said:

I have to recompile stage0 then all of stage1

Do you need stage1 specifically? Can you use build --stage 1 src/libstd instead? That will only build the stage0 compiler

I think this is what you need :point_up:

Xavier Denis (Jul 13 2020 at 18:43, on Zulip):

weird that staging would be the problem..

LeSeulArtichaut (Jul 13 2020 at 18:43, on Zulip):

The rustc dev guide has a few tips btw

Xavier Denis (Jul 13 2020 at 18:45, on Zulip):

ah i should have read the recommended workflows page :P

LeSeulArtichaut (Jul 13 2020 at 18:46, on Zulip):

IIRC what's happening here is that:

Joshua Nelson (Jul 13 2020 at 18:46, on Zulip):

Yes, that's correct

Joshua Nelson (Jul 13 2020 at 18:47, on Zulip):

I'm trying to make bullet point two the default for --stage 1 since a compiler without libstd is pretty useless and you normally only want to build rustc once

Xavier Denis (Jul 13 2020 at 18:47, on Zulip):

what's weird though is that the command generates a new stage1 binary?

Xavier Denis (Jul 13 2020 at 18:47, on Zulip):

if it's not building the stage1 compiler how is that possible?

Xavier Denis (Jul 13 2020 at 18:48, on Zulip):

/shrug it works for me now

LeSeulArtichaut (Jul 13 2020 at 18:49, on Zulip):

I guess it depends on what you are calling stage 1? x)

Joshua Nelson (Jul 13 2020 at 18:49, on Zulip):

The stage1 binary is not the same as the stage1 artifacts

Joshua Nelson (Jul 13 2020 at 18:49, on Zulip):

The stage1 artifacts are the things built with stage1/rustc

Joshua Nelson (Jul 13 2020 at 18:50, on Zulip):

It's confusing because the build directory refers to the compiler that's running but the x.py args refer to the compiler being built

Joshua Nelson (Jul 13 2020 at 18:50, on Zulip):

@eddyb and I have argued about this :P

LeSeulArtichaut (Jul 13 2020 at 18:51, on Zulip):

Yeah it's confusing, but at least only infra and release people have to worry about it :stuck_out_tongue:

Xavier Denis (Jul 13 2020 at 18:51, on Zulip):

ohhhh ok so --stage 1 is referring to the artifacts built from stage1?

Joshua Nelson (Jul 13 2020 at 18:51, on Zulip):

Yes exactly

Xavier Denis (Jul 13 2020 at 18:51, on Zulip):

ok it all makes sense now

Joshua Nelson (Jul 13 2020 at 18:51, on Zulip):

Yeah it's confusing, but at least only infra and release people have to worry about it :P

I disagree, see e.g. this thread

Xavier Denis (Jul 13 2020 at 18:51, on Zulip):

I thought it meant _build_ the stage1 binary

Joshua Nelson (Jul 13 2020 at 18:53, on Zulip):

:point_up: @eddyb this is what my idea to change x.py was

Joshua Nelson (Jul 13 2020 at 18:53, on Zulip):

That you said was confusing for other reasons

LeSeulArtichaut (Jul 13 2020 at 18:55, on Zulip):

Joshua Nelson said:

Yeah it's confusing, but at least only infra and release people have to worry about it :stuck_out_tongue:

I disagree, see e.g. this thread

I meant, once you have learnt that you should use ./x.py build --stage 1 src/libstd, you don't have to remember the details of the bootstrapping process

Joshua Nelson (Jul 13 2020 at 18:55, on Zulip):

Yeah, making that the default should help a lot

Joshua Nelson (Jul 13 2020 at 18:55, on Zulip):

But I still think the other numbering makes more sense

LeSeulArtichaut (Jul 13 2020 at 18:56, on Zulip):

Plus we'll need to change that command once the standard library is moved to its own directory (soon)?

Joshua Nelson (Jul 13 2020 at 18:56, on Zulip):

Well, that I don't expect to be too confusing

Joshua Nelson (Jul 13 2020 at 18:56, on Zulip):

Just a pain to update the docs

Jake Goulding (Jul 13 2020 at 21:03, on Zulip):

Xavier Denis said:

if lld worked on mac i'd switch to it since that seems to speed things up as well

I've been pointed at https://github.com/michaeleisel/zld but haven't used it myself yet.

Joshua Nelson (Jul 13 2020 at 21:17, on Zulip):

Oh btw @Xavier Denis I missed that you were using -i, you can set that permanently in config.toml with incremental = true

eddyb (Jul 13 2020 at 22:43, on Zulip):

@Joshua Nelson @Xavier Denis it's only confusing because "stage1 binary" can be seen as a thing, even though it's really not what it looks like

eddyb (Jul 13 2020 at 22:43, on Zulip):

like I bet if it wasn't stage1/bin/rustc but stage0to1/bin/rustc it'd make more sense?

eddyb (Jul 13 2020 at 22:44, on Zulip):

(and x.py build --stage 1 would build all the way to having a stage1to2/bin/rustc but no further into stage2-*)

eddyb (Jul 13 2020 at 22:44, on Zulip):

the directories literally named stageN are the wrong ones currently, in that they're "between" stages

eddyb (Jul 13 2020 at 22:45, on Zulip):

stageN-* however, match perfectly

eddyb (Jul 13 2020 at 22:48, on Zulip):

so currently, this is what it looks like:

eddyb (Jul 13 2020 at 22:48, on Zulip):

we could probably not do that last step unless you're actually building anything at stage2

eddyb (Jul 13 2020 at 22:49, on Zulip):

and frankly, the stageN directories... we could name them with "sysroot" in their names or something, or even just try to hide them, idk

eddyb (Jul 13 2020 at 22:49, on Zulip):

but they're basically "output of stage N-1, input of stage N", and used as "sysroots" to do the build, they're not the stage

eddyb (Jul 13 2020 at 22:50, on Zulip):

the only usecase for poking at those directories that is currently "official" is rustup toolchain link, and we could probably solve that by having a x.py symstall or x.py rustup-link or w/e functionality for hooking them up

eddyb (Jul 13 2020 at 22:51, on Zulip):

bonus: x.py symstall could work for system-wide non-rustup "dev installation"

eddyb (Jul 13 2020 at 22:51, on Zulip):

(in case you need to test that)

LeSeulArtichaut (Jul 13 2020 at 22:52, on Zulip):

There's also the usecase of using rustfmt in e.g. rust-analyzer

eddyb (Jul 13 2020 at 22:52, on Zulip):

and the best part is that (I hope) e.g. the rustc symlink and the rustlib one can be separate, and the actual files live wherever the build system needs them to

eddyb (Jul 13 2020 at 22:52, on Zulip):

@LeSeulArtichaut what do you mean?

eddyb (Jul 13 2020 at 22:53, on Zulip):

the executables would be somewhere, RA should definitely not hardcode any paths into build/ though

LeSeulArtichaut (Jul 13 2020 at 22:53, on Zulip):

I mean, for this kind of thing

eddyb (Jul 13 2020 at 22:54, on Zulip):

yeah we'd just change that

RalfJ (Jul 15 2020 at 07:28, on Zulip):

also see https://github.com/rust-lang/rust/issues/59864 which has some helpful explanations leading to a mental model of rustc's staging

Last update: Sep 28 2020 at 15:45UTC