Can we get rid of the `lib.miri.rs` hack now?
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
We added some quite elaborate hacks in bootstrap and Miri to support ./x miri running standard library tests in Miri. This comment explains why:
// This hack helps bootstrap run standard library tests in Miri. The issue is as
// follows: when running `cargo miri test` on libcore, cargo builds a local copy of core
// and makes it a dependency of the integration test crate. This copy duplicates all the
// lang items, so the build fails. (Regular testing avoids this because the sysroot is a
// literal copy of what `cargo build` produces, but since Miri builds its own sysroot
// this does not work for us.) So we need to make it so that the locally built libcore
// contains all the items from `core`, but does not re-define them -- we want to replace
// the entire crate but a re-export of the sysroot crate. We do this by swapping out the
// source file: if `MIRI_REPLACE_LIBRS_IF_NOT_TEST` is set and we are building a
// `lib.rs` file, and a `lib.miri.rs` file exists in the same folder, we build that
// instead. But crucially we only do that for the library, not the test builds.
Turns out this is problematic not just for Miri but for everyone who wants to run the test suite, so @bjorn3 is moving things around to avoid the underlying issue (https://github.com/rust-lang/rust/pull/135937, https://github.com/rust-lang/rust/pull/136642). Once that is done, we can probably get rid of the hacks in Miri.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Inspect the bootstrap and Miri handling around the lib.miri.rs replacement described in the issue, then review PRs 135937 and 136642 for the prerequisite changes. Remove the obsolete hacks once that work is complete and verify that ./x miri can run the standard library test suite without them.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- build-system, testing-qa
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100