-
Notifications
You must be signed in to change notification settings - Fork 1
Make the build process easier #1
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
Conversation
@@ -5,44 +5,39 @@ | |||
```bash | |||
git clone -b linked-examples https://github.com/willcrichton/rust | |||
cd rust | |||
./x.py --stage 1 build | |||
export CUSTOM_RUSTDOC=$(pwd)/build/x86_64-apple-darwin/stage1/bin/rustdoc | |||
./x.py build |
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.
Stage 1 has been the default since https://blog.rust-lang.org/inside-rust/2020/08/30/changes-to-x-py-defaults.html.
# replace `apple-darwin` with your current target as appropriate | ||
rustup toolchain link custom-rustdoc build/x86_64-apple-darwin/stage1 |
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.
Don't know a way to make this target-independent, even rustc-dev-guide does this: https://rustc-dev-guide.rust-lang.org/building/how-to-build-and-run.html?highlight=rustup,link#creating-a-rustup-toolchain
cd example_analyzer | ||
rustup toolchain install nightly --profile default --component rustc-dev | ||
rustup override set nightly | ||
cd example-analyzer | ||
cargo build |
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.
This works because I added rust-toolchain
.
# NOTE: the directory you run this from is important since the project uses | ||
# `rust-toolchain` |
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.
This will also work from doctest/
, but not in your home directory or something.
```bash | ||
# NOTE: the directory you run this from is important since the project uses | ||
# `rust-toolchain` | ||
export LD_LIBRARY_PATH=$(rustc --print sysroot)/lib |
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.
There are two ways I can think of to get rid of this:
- Add a
--run-in <directory>
flag tocargo run
, which sets the sysroot appropriately already - Have rustup do it somehow (???)
Both require changes to rust infra, so probably not happening any time soon.
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 we can just keep it manual for now. But add a note to change "LD" to "DYLD" for mac users please.
# 2. add the flag "--call-locations .call_locations.json" to the end | ||
# 3. run the command | ||
open target/doc/doctest/index.html | ||
cargo +custom-rustdoc rustdoc --open -- --call-locations .call_locations.json |
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 like this because it distinguishes that the only time custom rustdoc is used is for --call-locations
; everything else doesn't really care what toolchain you use it with other than 'some recent nightly'.
// absolutely awful hack to fix the sysroot when running out-of-tree | ||
// Taken from #78926, which took it from src/bin/miri.rs, which in turn took it from clippy ... rustc is a mess. | ||
// FIXME(jyn514): implement https://github.com/rust-lang/rust/pull/78926#issuecomment-726653035 instead |
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.
Everything about this is awful, but not much I can do better until fixing the issue I linked.
Changes all look good! Can you shuffle the code around to not conflict with recent commits? Btw I'm happy to do that myself, but looks like you're PRing from a fork. Feel free to do work on a branch of this repo so we can keep the collab loop a bit tighter. |
Also btw, I was testing compilation with the toolchain you recommended. I randomly got an ICE while building (not running)
Seems to be related to incremental compilation. I tried |
@willcrichton that's an upstream bug, it's since been fixed: rust-lang/rust#79661. I'll update the version of nightly so you don't run into it again. |
Notice I didn't say simpler. This does a quite a few things: - Pins a version of nightly using `rust-toolchain`. This avoids confusion when rustc changes its API in a later version. When rebasing over rust-lang/master, rust-toolchain should also be updated. - Replaces CUSTOM_RUSTDOC with `rustup toolchain link`, which allows determining the sysroot without hardcoding `.rustup/toolchain` in the instructions (*not* the binary). - Replaces 'copy paste what cargo did with additional arguments' with `cargo rustdoc` - Determines the sysroot in `src/main.rs` with rustup instead of hard-coding it. This is an absolute hack, see the comments for details, but it's used by clippy and miri so it works in practice. - Minor changes to the README to distinguish the current directory
This avoids an incremental compilation bug fixed on nightly: rust-lang/rust#79661
Ok, this is ready for another round of review. |
Sounds good, I'll do that for follow-ups. |
Notice I didn't say simpler.
This does a quite a few things:
rust-toolchain
. This avoidsconfusion when rustc changes its API in a later version. When rebasing
over rust-lang/master, rust-toolchain should also be updated.
rustup toolchain link
, which allowsdetermining the sysroot without hardcoding
.rustup/toolchain
in theinstructions (not the binary).
cargo rustdoc
src/main.rs
with rustup instead ofhard-coding it. This is an absolute hack, see the comments for details,
but it's used by clippy and miri so it works in practice.