-
Notifications
You must be signed in to change notification settings - Fork 408
improve README instructions for using rustup and for compiling separate crates
#483
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
0c83b2f to
8259670
Compare
README.md
Outdated
| project through Miri. | ||
| Compile your project and its dependencies against a MIR-enabled libstd as described | ||
| above. The easiest way to do this is to copy `xargo/build.sh` and `xargo/Xargo.toml` | ||
| into your own project's root, and to re-run `build.sh`. This ensures that `libstd` |
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 am a bit surprised by this. build.sh installs the new libstd globally, so you can use MIRI_SYSROOT=~/.xargo/HOST cargo +nightly miri even without copying it. If you are using the same compiler, this locally built libstd should be compatible with the one shipped with rustc.
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! If you run cargo clean first you are correct. But cargo will use cached dependency compilations even if you change MIRI_SYSROOT. (Maybe this is a bug in cargo?)
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 don't see how your instructions can make any difference there. If you used xargo build later, that would take the new libstd into account, but cargo build for sure doesn't care about ~/.xargo/HOST.
Something doesn't add up here.
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 think there are actually some bugs here, and I opened #486 to track that.
But none of that should require a copy of Xargo.toml, and I have yet to see a situation where that helps.
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.
In my project (rust-bitcoin), if I run
cargo clean
MIRI_SYSROOT=~/.xargo/HOST cargo +nightly-2018-10-14 build
MIRI_SYSROOT=~/.xargo/HOST cargo +nightly-2018-10-14 miri ## does not error, seems to do nothing
MIRI_SYSROOT=~/.xargo/HOST cargo +nightly-2018-10-14 miri test
I will reliably get the error
error[E0460]: found possibly newer version of crate `std` which `bitcoin_bech32` depends on
My fix was to bring Xargo.toml into the crate root and run the commands in build.sh there. But now I see that a more straightforward thing to do is to just run cargo clean before MIRI_SYSROOT=~/.xargo/HOST cargo miri test and it'll work.
This definitely seems like some sort of bug rather than something we should update the README for.
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 think the following requirements are important to get cargo miri to work with a local libstd:
xargo/build.shmust be executed with the same toolchain ascargo miri.MIRI_SYSROOTmust be set when the project is built.
Can you write the instructions in a way that makes that as clear as possible?
README.md
Outdated
|
|
||
| 1. Install Miri using `rustup run nightly-2018-10-15 cargo install --all-features --path .`, | ||
| with the date replaced as appropriate. | ||
| 2. Edit `build.sh` to replace `xargo` with `rustup run nightly-2018-10-15 xargo`. |
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.
Instead, I think we can tell people to run rustup run nightly-2018-10-15 xargo/build.sh
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, nice, I'll fix this.
0241f1b to
bcf4476
Compare
README.md
Outdated
|
|
||
| 1. Install Miri using `cargo +nightly-2018-10-15 install --all-features --path .`, | ||
| with the date replaced as appropriate. | ||
| 2. Run `build.sh` as `rustup run nightly-2018-10-15 build.sh`. |
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.
Should be xargo/build.sh, shouldn't it?
bcf4476 to
29d1966
Compare
|
Rebased, addressed nits, and replaced the "copy |
README.md
Outdated
| 1. Run `cargo clean` to eliminate any cached dependencies that were built against | ||
| the non-MIR `libstd`. | ||
| 2. For a binary project, run `MIRI_SYSROOT=~/.xargo/HOST cargo +nightly miri` to | ||
| build and run your project; for a binary or library, use `MIRI_SYSROOT=~/.xargo/HOST cargo +nightly miri test` |
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'd rearrange the sentence a bit here: The prat after the semicolon I'd start with what this is good for ("to run all tests"). Reading this I wondered "wait the first part is for a binary, the second part is for a binary or library, that's odd".
README.md
Outdated
|
|
||
| If you forget to set `MIRI_SYSROOT`, be sure to run `cargo clean` again before | ||
| correcting it. Otherwise you are likely to get "dependency was built against possibly | ||
| newer std" errors. |
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.
Maybe add a remark here saying if this throws strange errors about crate mismatches, probably the xargo sysroot was built with a different nightly than the current project and one should run rustup run nightly xargo/build.sh.
README.md
Outdated
|
|
||
| You may prefer to do this rather than depending on the rustup default toolchain, | ||
| if you routinely update the default, since **it is essential that `xargo/build.sh` | ||
| is run with the same toolchain as `cargo miri`.** |
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 find this somewhat redundant. If we make the original instructions specify a toolchain everywhere, it seems clear that we can replace nightly by another toolchain name, doesn't it? It may be worth stating that explicitly, but I am not a fan of repeating instructions.
8f8d65a to
e22edfb
Compare
rust-toolchain
Outdated
| @@ -1 +0,0 @@ | |||
| nightly-2018-10-14 | |||
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.
Could you instead just replace it with nightly so that people don't have to switch to nightly manually, while at the same time not pinning to a specific nightly?
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.
They will still have to switch to nightly manually when doing the other steps; this override only controls compilation of Miri. This will be especially confusing if they have their default compiler set to a specific nightly, which is common for people using unstable compiler tools.
12ed60a to
67895b7
Compare
README.md
Outdated
| To target a specific nightly, modify the above instructions as follows. | ||
| To target a specific nightly, modify the above instructions as follows. It is recommended | ||
| to use the nightly specified in the `rust-version` file in this repo, since that is the | ||
| most recent nightly supported by Miri. |
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.
Maybe I should bold this? It's pretty far down. Or maybe I should move it to the top of the README?
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 would get rid of this entire section, and instead write "Building Miri" and the following sections in a way that explicitly specifies nightly in every step (we have to, with rust-toolchain gone!). Then I think we can avoid repeating these instructions here?
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.
Sounds good.
|
Most of the README, starting at "Building Miri", now needs to be adjusted to add the |
README.md
Outdated
|
|
||
| ### Common Problems | ||
|
|
||
| When modifying the above instructions, you may encounter a number of confusing 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.
Why "modifying"?
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 was trying to politely say "you typed the instructions wrong".
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.
lol, that subtlety was lost on me.^^ Maybe just say "When using" or "when working with"?
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.
Heh, yeah, I guess that's even more polite :)
| have `MIRI_SYSROOT` set. Run `cargo clean` before switching from non-Miri to Miri | ||
| builds and vice-versa. | ||
|
|
||
| #### "found crate `std` compiled by an incompatible version of rustc" |
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 do not understand how/why this is different from the one right before. Seems to me both are caused by "sysroot confusion", and both are solved the same way. Why should we give different advise for these two?
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 don't understand. They have different causes and different solutions.
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.
Oh, the difference is "deps were built without MIRI_SYSROOT vs MIRI_SYSROOT was built with the wrong toolchain, I see. Makes sense.
I think what threw me off was specifically mentioning cargo miri test. The same applies to cargo miri, right? So maybe just say cargo miri then.
README.md
Outdated
|
|
||
| Install Miri as a cargo subcommand with `cargo install --all-features`, and install | ||
| a full libstd as described above. | ||
| Install Miri as a cargo subcommand with `cargo install --all-features --path .`. |
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 and everything above it in the README still lacks a +nightly. The instructions as they are now just don't work.
…rate Cargo projects
…ghout Also replace `cargo miri test` with `cargo miri` in general examples.
67895b7 to
5347411
Compare
|
Rebased; added a commit which
|
|
I like it. :) Still have some tweaks I want to do but I will just make a PR of my own then and ask you for feedback. Cycling PR because the Travis state is stuck. |
I found that with the existing instructions I would get errors along the lines of "
libstdnot found", or "dependency was built against possibly newerlibstd", and it was very difficult to tell what was going on because there are many moving parts and actually multiple things that can go wrong.Update the README to hold the user's hand more and give troubleshooting help.