Skip to content
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

Merged
merged 1 commit into from
Oct 30, 2020
Merged

Conversation

camelid
Copy link
Member

@camelid camelid commented Oct 30, 2020

CONTRIBUTING.md Outdated Show resolved Hide resolved
CONTRIBUTING.md Outdated Show resolved Hide resolved
@jyn514
Copy link
Member

jyn514 commented Oct 30, 2020

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
Copy link
Member Author

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?

Copy link
Member

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 ?

Copy link
Member

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.

Copy link
Member

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?

Copy link
Member

@RalfJung RalfJung Oct 30, 2020

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.

Copy link
Member Author

@camelid camelid Oct 30, 2020

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.

Copy link
Member Author

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.

Copy link
Member Author

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.

Copy link
Member

@RalfJung RalfJung Oct 31, 2020

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.

Copy link
Member

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
Copy link
Member Author

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.

@RalfJung
Copy link
Member

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.

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.

@RalfJung
Copy link
Member

Thanks @camelid!
@bors r+

@bors
Copy link
Contributor

bors commented Oct 30, 2020

📌 Commit 1496462 has been approved by RalfJung

@bors
Copy link
Contributor

bors commented Oct 30, 2020

⌛ Testing commit 1496462 with merge 8f36839...

@bors
Copy link
Contributor

bors commented Oct 30, 2020

☀️ Test successful - checks-actions
Approved by: RalfJung
Pushing 8f36839 to master...

@bors bors merged commit 8f36839 into rust-lang:master Oct 30, 2020
@camelid camelid deleted the patch-2 branch October 30, 2020 19:02
bors added a commit that referenced this pull request Nov 7, 2020
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`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants