mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 23:04:33 +00:00
Rollup merge of #110365 - ozkanonur:ship-tools-with-sysroot, r=jyn514
ship tools with sysroot Provides tool binaries under the sysroot which can be used/tested with `cargo +custom-toolchain $tool` Clippy and fmt works without any problem. But can't say the same for miri: ```sh ~/devspace/.other/chunk-list stable $ cargo +stage2 miri setup Running `"rustup" "component" "add" "rust-src"` to install the `rust-src` component for the selected toolchain. error: stage2 is a custom toolchain fatal error: failed to install the `rust-src` component for the selected toolchain ``` it's looking for `$sysroot/lib/rustlib/src/rust/library` and that simply doesn't exists for `x build`. cc `@jyn514` (I thought you might be interested on this, since you did few review iterations on previous PRs of adding tools to sysroot) -- **Update** Now we are able to use `miri` as well. After running `x b miri cargo-miri --stage 2`, I am able to run `cargo +stage2 miri setup` which works as expected. Resolves #110625 Resolves #97762 Resolves #81431
This commit is contained in:
commit
f2321ecce5
@ -1328,7 +1328,6 @@ impl Step for Sysroot {
|
||||
true
|
||||
}
|
||||
});
|
||||
return INTERNER.intern_path(sysroot);
|
||||
}
|
||||
|
||||
// Symlink the source root into the same location inside the sysroot,
|
||||
|
@ -748,6 +748,7 @@ macro_rules! tool_extended {
|
||||
stable = $stable:expr
|
||||
$(,tool_std = $tool_std:literal)?
|
||||
$(,allow_features = $allow_features:expr)?
|
||||
$(,add_bins_to_sysroot = $add_bins_to_sysroot:expr)?
|
||||
;)+) => {
|
||||
$(
|
||||
#[derive(Debug, Clone, Hash, PartialEq, Eq)]
|
||||
@ -790,7 +791,7 @@ macro_rules! tool_extended {
|
||||
|
||||
#[allow(unused_mut)]
|
||||
fn run(mut $sel, $builder: &Builder<'_>) -> Option<PathBuf> {
|
||||
$builder.ensure(ToolBuild {
|
||||
let tool = $builder.ensure(ToolBuild {
|
||||
compiler: $sel.compiler,
|
||||
target: $sel.target,
|
||||
tool: $tool_name,
|
||||
@ -800,7 +801,27 @@ macro_rules! tool_extended {
|
||||
is_optional_tool: true,
|
||||
source_type: SourceType::InTree,
|
||||
allow_features: concat!($($allow_features)*),
|
||||
})
|
||||
})?;
|
||||
|
||||
if (false $(|| !$add_bins_to_sysroot.is_empty())?) && $sel.compiler.stage > 0 {
|
||||
let bindir = $builder.sysroot($sel.compiler).join("bin");
|
||||
t!(fs::create_dir_all(&bindir));
|
||||
|
||||
#[allow(unused_variables)]
|
||||
let tools_out = $builder
|
||||
.cargo_out($sel.compiler, Mode::ToolRustc, $sel.target);
|
||||
|
||||
$(for add_bin in $add_bins_to_sysroot {
|
||||
let bin_source = tools_out.join(exe(add_bin, $sel.target));
|
||||
let bin_destination = bindir.join(exe(add_bin, $sel.compiler.host));
|
||||
$builder.copy(&bin_source, &bin_destination);
|
||||
})?
|
||||
|
||||
let tool = bindir.join(exe($tool_name, $sel.compiler.host));
|
||||
Some(tool)
|
||||
} else {
|
||||
Some(tool)
|
||||
}
|
||||
}
|
||||
}
|
||||
)+
|
||||
@ -814,15 +835,15 @@ macro_rules! tool_extended {
|
||||
tool_extended!((self, builder),
|
||||
Cargofmt, "src/tools/rustfmt", "cargo-fmt", stable=true;
|
||||
CargoClippy, "src/tools/clippy", "cargo-clippy", stable=true;
|
||||
Clippy, "src/tools/clippy", "clippy-driver", stable=true;
|
||||
Miri, "src/tools/miri", "miri", stable=false;
|
||||
CargoMiri, "src/tools/miri/cargo-miri", "cargo-miri", stable=true;
|
||||
Clippy, "src/tools/clippy", "clippy-driver", stable=true, add_bins_to_sysroot = ["clippy-driver", "cargo-clippy"];
|
||||
Miri, "src/tools/miri", "miri", stable=false, add_bins_to_sysroot = ["miri"];
|
||||
CargoMiri, "src/tools/miri/cargo-miri", "cargo-miri", stable=true, add_bins_to_sysroot = ["cargo-miri"];
|
||||
// FIXME: tool_std is not quite right, we shouldn't allow nightly features.
|
||||
// But `builder.cargo` doesn't know how to handle ToolBootstrap in stages other than 0,
|
||||
// and this is close enough for now.
|
||||
Rls, "src/tools/rls", "rls", stable=true, tool_std=true;
|
||||
RustDemangler, "src/tools/rust-demangler", "rust-demangler", stable=false, tool_std=true;
|
||||
Rustfmt, "src/tools/rustfmt", "rustfmt", stable=true;
|
||||
Rustfmt, "src/tools/rustfmt", "rustfmt", stable=true, add_bins_to_sysroot = ["rustfmt", "cargo-fmt"];
|
||||
);
|
||||
|
||||
impl<'a> Builder<'a> {
|
||||
|
Loading…
Reference in New Issue
Block a user