Skip to content
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

Enable x.py check for miri #102950

Merged
merged 4 commits into from
Nov 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/bootstrap/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,7 @@ impl<'a> Builder<'a> {
check::CodegenBackend,
check::Clippy,
check::Miri,
check::CargoMiri,
check::Rls,
check::RustAnalyzer,
check::Rustfmt,
Expand Down
7 changes: 3 additions & 4 deletions src/bootstrap/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -451,14 +451,13 @@ macro_rules! tool_check_step {
}

tool_check_step!(Rustdoc, "src/tools/rustdoc", "src/librustdoc", SourceType::InTree);
// Clippy and Rustfmt are hybrids. They are external tools, but use a git subtree instead
// Clippy, miri and Rustfmt are hybrids. They are external tools, but use a git subtree instead
// of a submodule. Since the SourceType only drives the deny-warnings
// behavior, treat it as in-tree so that any new warnings in clippy will be
// rejected.
tool_check_step!(Clippy, "src/tools/clippy", SourceType::InTree);
// Miri on the other hand is treated as out of tree, since InTree also causes it to
// be run as part of `check`, which can fail on platforms which libffi-sys has no support for.
tool_check_step!(Miri, "src/tools/miri", SourceType::Submodule);
tool_check_step!(Miri, "src/tools/miri", SourceType::InTree);
oli-obk marked this conversation as resolved.
Show resolved Hide resolved
tool_check_step!(CargoMiri, "src/tools/miri/cargo-miri", SourceType::InTree);
tool_check_step!(Rls, "src/tools/rls", SourceType::InTree);
tool_check_step!(Rustfmt, "src/tools/rustfmt", SourceType::InTree);

Expand Down
35 changes: 6 additions & 29 deletions src/bootstrap/doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -734,7 +734,7 @@ impl Step for Rustc {
}

macro_rules! tool_doc {
($tool: ident, $should_run: literal, $path: literal, [$($krate: literal),+ $(,)?], in_tree = $in_tree:expr $(,)?) => {
($tool: ident, $should_run: literal, $path: literal, [$($krate: literal),+ $(,)?] $(,)?) => {
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub struct $tool {
target: TargetSelection,
Expand Down Expand Up @@ -790,12 +790,6 @@ macro_rules! tool_doc {
t!(fs::create_dir_all(&out_dir));
t!(symlink_dir_force(&builder.config, &out, &out_dir));

let source_type = if $in_tree == true {
SourceType::InTree
} else {
SourceType::Submodule
};

// Build cargo command.
let mut cargo = prepare_tool_cargo(
builder,
Expand All @@ -804,7 +798,7 @@ macro_rules! tool_doc {
target,
"doc",
$path,
source_type,
SourceType::InTree,
&[],
);

Expand All @@ -820,38 +814,21 @@ macro_rules! tool_doc {
cargo.rustdocflag("--show-type-layout");
cargo.rustdocflag("--generate-link-to-definition");
cargo.rustdocflag("-Zunstable-options");
if $in_tree == true {
builder.run(&mut cargo.into());
} else {
// Allow out-of-tree docs to fail (since the tool might be in a broken state).
if !builder.try_run(&mut cargo.into()) {
builder.info(&format!(
"WARNING: tool {} failed to document; ignoring failure because it is an out-of-tree tool",
stringify!($tool).to_lowercase(),
));
}
}
builder.run(&mut cargo.into());
}
}
}
}

tool_doc!(
Rustdoc,
"rustdoc-tool",
"src/tools/rustdoc",
["rustdoc", "rustdoc-json-types"],
in_tree = true
);
tool_doc!(Rustdoc, "rustdoc-tool", "src/tools/rustdoc", ["rustdoc", "rustdoc-json-types"],);
tool_doc!(
Rustfmt,
"rustfmt-nightly",
"src/tools/rustfmt",
["rustfmt-nightly", "rustfmt-config_proc_macro"],
in_tree = true
);
tool_doc!(Clippy, "clippy", "src/tools/clippy", ["clippy_utils"], in_tree = true);
tool_doc!(Miri, "miri", "src/tools/miri", ["miri"], in_tree = false);
tool_doc!(Clippy, "clippy", "src/tools/clippy", ["clippy_utils"]);
tool_doc!(Miri, "miri", "src/tools/miri", ["miri"]);

#[derive(Ord, PartialOrd, Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub struct ErrorIndex {
Expand Down
4 changes: 2 additions & 2 deletions src/bootstrap/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@ impl Step for Miri {
host,
"run",
"src/tools/miri/cargo-miri",
SourceType::Submodule,
SourceType::InTree,
&[],
);
cargo.add_rustc_lib_path(builder, compiler);
Expand Down Expand Up @@ -550,7 +550,7 @@ impl Step for Miri {
host,
"test",
"src/tools/miri",
SourceType::Submodule,
SourceType::InTree,
&[],
);
cargo.add_rustc_lib_path(builder, compiler);
Expand Down
30 changes: 12 additions & 18 deletions src/bootstrap/tool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -794,10 +794,9 @@ macro_rules! tool_extended {
$($name:ident,
$path:expr,
$tool_name:expr,
stable = $stable:expr,
$(in_tree = $in_tree:expr,)?
$(tool_std = $tool_std:literal,)?
$extra_deps:block;)+) => {
stable = $stable:expr
$(,tool_std = $tool_std:literal)?
;)+) => {
$(
#[derive(Debug, Clone, Hash, PartialEq, Eq)]
pub struct $name {
Expand Down Expand Up @@ -839,7 +838,6 @@ macro_rules! tool_extended {

#[allow(unused_mut)]
fn run(mut $sel, $builder: &Builder<'_>) -> Option<PathBuf> {
$extra_deps
$builder.ensure(ToolBuild {
compiler: $sel.compiler,
target: $sel.target,
Expand All @@ -848,11 +846,7 @@ macro_rules! tool_extended {
path: $path,
extra_features: $sel.extra_features,
is_optional_tool: true,
source_type: if false $(|| $in_tree)* {
SourceType::InTree
} else {
SourceType::Submodule
},
source_type: SourceType::InTree,
})
}
}
Expand All @@ -865,17 +859,17 @@ macro_rules! tool_extended {
// Note: Most submodule updates for tools are handled by bootstrap.py, since they're needed just to
// invoke Cargo to build bootstrap. See the comment there for more details.
tool_extended!((self, builder),
Cargofmt, "src/tools/rustfmt", "cargo-fmt", stable=true, in_tree=true, {};
CargoClippy, "src/tools/clippy", "cargo-clippy", stable=true, in_tree=true, {};
Clippy, "src/tools/clippy", "clippy-driver", stable=true, in_tree=true, {};
Miri, "src/tools/miri", "miri", stable=false, in_tree=true, {};
CargoMiri, "src/tools/miri/cargo-miri", "cargo-miri", stable=false, in_tree=true, {};
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;
// 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, in_tree=true, tool_std=true, {};
RustDemangler, "src/tools/rust-demangler", "rust-demangler", stable=false, in_tree=true, tool_std=true, {};
Rustfmt, "src/tools/rustfmt", "rustfmt", stable=true, in_tree=true, {};
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;
);

impl<'a> Builder<'a> {
Expand Down
2 changes: 2 additions & 0 deletions src/tools/miri/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
clippy::cast_lossless,
clippy::cast_possible_truncation,
)]
// Needed for rustdoc from bootstrap (with `-Znormalize-docs`).
#![recursion_limit = "256"]

extern crate rustc_apfloat;
extern crate rustc_ast;
Expand Down