-
Notifications
You must be signed in to change notification settings - Fork 352
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update locally-built rustc instructions #1610
Conversation
I didn't realize miri required a full 2-stage build. Are there other tools that require two stages, maybe clippy? I'd like to have a defaults profile for them, right now there's only 'compiler' and 'user' neither of which are really correct. |
CONTRIBUTING.md
Outdated
|
||
# Build a stage 2 rustc. | ||
# This step can take 30 minutes or more. | ||
./x.py build --stage 2 library/std |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've just noticed that this doesn't work locally; I get an error like:
error[E0463]: can't find crate for `rustc_attr`
--> src/lib.rs:14:1
|
14 | extern crate rustc_attr;
| ^^^^^^^^^^^^^^^^^^^^^^^^ can't find crate
error: aborting due to previous error
For more information about this error, try `rustc --explain E0463`.
error: could not compile `miri`
But ./x.py build --stage 2 compiler/rustc
fixes it even though it takes three seconds to execute. Is this an x.py
bug?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wait, only three seconds to execute? Something really weird is going on here ... Maybe this is something like rust-lang/rust#73519 ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah ./x.py build --stage 2 compiler/rustc
is right.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@RalfJung do you know why miri requires the compiler artifacts from the next stage? Is it a compiler plugin instead of being linked to the compiler?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it a compiler plugin instead of being linked to the compiler?
What is the difference between these two?
Miri is linked to the compiler, and of course also linked to the standard library. Thus it needs a librustc and a libstd that were both built by the same rustc as the one building Miri itself. (Only things built by the same compiler can be linked together.) Stage 1 does not satisfy this condition, only stage 2 does.
There is a way to fiddle with all the flags (using different versions of rustc for different things) to not require full boostrapping -- that's why ./x.py test src/tools/miri --stage 0
works. But doing this without bootstrap's help is near impossible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
./x.py build --stage 1 library/std
didn't work:
error[E0463]: can't find crate for `rustc_attr`
--> src/lib.rs:14:1
|
14 | extern crate rustc_attr;
| ^^^^^^^^^^^^^^^^^^^^^^^^ can't find crate
error: aborting due to previous error
(And I checked to make sure I set the toolchain to r2stage1
-- all the deps compiled fine, just miri failed.)
The x.py
build took 3 mins and 35 seconds, which sounds a little fast to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jyn514 ./x.py build --stage 1 compiler/rustc
worked!
It took 23 minutes, so it must be doing more than build --stage 1 library/std
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just looked at the x.py
logs and it seems like build --stage 1 library/std
builds:
- stage0 std artifacts
- stage0 compiler artifacts
- stage1 std artifacts
But the output is kind of confusing so I'm not 100% sure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
./x.py build --stage 1 compiler/rustc worked!
What exactly did you test to conclude that Miri works? Did you do ./miri test
? I definitely tried this in the past and it did not work, and IIRC proc-macros were the culprit.
EDIT: Ah no I misread, you did build rustc twice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah no I misread, --stage 1 compiler/rustc
builds rustc twice, so it is basically the same as --stage 2 compiler/rustc
I think? Just some uplifting is happening.
it seems like build --stage 1 library/std builds:
Yes. And --stage 1 compiler/rustc
additionally builds "stage1 compiler artifacts", also known as "the stage 2 compiler".
Which switch did you use after a ./x.py build --stage 1 compiler/rustc
, to then build Miri?
CONTRIBUTING.md
Outdated
# If you change something, you can get a faster rebuild by doing | ||
./x.py --keep-stage 0 build src/rustc | ||
./x.py build --keep-stage 0 --stage 2 library/std |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably will happen for this too.
I think having too many profiles wold be somewhat confusing.^^ Only very few people will need this for Miri I think, and instead of making this easier we should get rust-lang/rust#76666 fixed which will make this mostly unnecessary. |
📌 Commit 1496462 has been approved by |
☀️ Test successful - checks-actions |
CONTRIBUTING.md: Use `build --stage 1` instead of `build --stage 2` It seems to work fine with `--stage 1` and it should be faster. Cc #1610 Cc `@jyn514`
Cc rust-lang/rust#78435