Skip to content

Optionally pass --config down to cargo when building the sysroot#5051

Open
erickt wants to merge 1 commit into
rust-lang:masterfrom
erickt:config
Open

Optionally pass --config down to cargo when building the sysroot#5051
erickt wants to merge 1 commit into
rust-lang:masterfrom
erickt:config

Conversation

@erickt

@erickt erickt commented May 19, 2026

Copy link
Copy Markdown

This allows us to do things like point cargo at a vendored directory to support offline builds of the sysroot.

Note: this is blocked on RalfJung/rustc-build-sysroot#34 being landed and released in a build.

@rustbot

rustbot commented May 19, 2026

Copy link
Copy Markdown
Collaborator

Thank you for contributing to Miri! A reviewer will take a look at your PR, typically within a week or two.
Please remember to not force-push to the PR branch except when you need to rebase due to a conflict or when the reviewer asks you for it.

@rustbot rustbot added the S-waiting-on-review Status: Waiting for a review to complete label May 19, 2026
@RalfJung

Copy link
Copy Markdown
Member

It looks like rust-src since recently contains the vendored dependencies of std, so no optional config should be needed for this? See rust-lang/rust#156196.

@erickt

erickt commented May 20, 2026

Copy link
Copy Markdown
Author

Oh interesting! I’ll test it out with the latest rust-src and get back to you.

This allows us to do things like point cargo at a vendored directory to
support offline builds of the sysroot.

Note: this is blocked on
RalfJung/rustc-build-sysroot#34 being landed and
released in a build.
@erickt

erickt commented May 20, 2026

Copy link
Copy Markdown
Author

Right now it looks like miri isn't able to find the vendored sources automatically if I block network access:

% unshare -r -n -- rustup run nightly cargo run -- miri setup --verbose
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.04s
     Running `target/debug/cargo-miri miri setup --verbose`
Preparing a sysroot for Miri (target: x86_64-unknown-linux-gnu) in .../.cache/miri...
warning: spurious network error (3 tries remaining): [6] Could not resolve hostname (Could not resolve host: static.crates.io)
...

That's also the case if I explicitly point it at the rust-src:

env MIRI_LIB_SRC=$HOME/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library unshare -r -n -- rustup run nightly cargo run -- miri setup --verbose --frozen
warning: spurious network error (3 tries remaining): [6] Could not resolve hostname (Could not resolve host: static.crates.io)
...

However if I use this patch and my patch to rustc-build-sysroot it works:

% unshare -r -n -- rustup run nightly cargo run -- miri setup --verbose --frozen --config ~/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/.cargo/config.toml
   Compiling compiler_builtins v0.1.160 (.../.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/compiler-builtins/compiler-builtins)
   Compiling core v0.0.0 (.../.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core)
...

Would you rather we hardcode cargo-miri or rustc-build-sysroot to always point the config at $MIRI_LIB_SRC/.cargo/config.toml? I'm not sure if that'll work with a normal rust checkout though, since it doesn't have a .cargo/config.toml.

@RalfJung

Copy link
Copy Markdown
Member

We could make it so that if the .cargo/config.toml exists, we use it -- would that suffice for your usecase? That would avoid having to add new flags.

@erickt

erickt commented May 21, 2026

Copy link
Copy Markdown
Author

@RalfJung Yeah I think that would work. We may also be able to just set $CARGO_HOME to $MIRI_LIB_SRC? Otherwise we could explicitly pass down the config file with RalfJung/rustc-build-sysroot#34.

@RalfJung

Copy link
Copy Markdown
Member

@rustbot author
based on the feedback above

@rustbot rustbot added S-waiting-on-author Status: Waiting for the PR author to address review comments and removed S-waiting-on-review Status: Waiting for a review to complete labels May 27, 2026
@rustbot

rustbot commented May 27, 2026

Copy link
Copy Markdown
Collaborator

Reminder, once the PR becomes ready for a review, use @rustbot ready.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-author Status: Waiting for the PR author to address review comments

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants