Skip to content

Add compiler-builtins to bootstrap #142106

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
62 changes: 62 additions & 0 deletions src/bootstrap/src/core/build_steps/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2731,6 +2731,68 @@ impl Step for Crate {
}
}

/// Test compiler-builtins via its testcrate.
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct CompilerBuiltins {
compiler: Compiler,
target: TargetSelection,
mode: Mode,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The builtins only make sense for Mode::Std, I think? So we don't need to parametrize this and the step can just hardcode it.

}

impl Step for CompilerBuiltins {
type Output = ();
const DEFAULT: bool = true;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This actually makes it run on CI :)


fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
run.paths(&["library/compiler-builtins", "library/compiler-builtins/compiler-builtins"])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
run.paths(&["library/compiler-builtins", "library/compiler-builtins/compiler-builtins"])
run.path("library/compiler-builtins")

Should be enough, I think.

}

fn make_run(run: RunConfig<'_>) {
let builder = run.builder;
let host = run.build_triple();
let compiler = builder.compiler_for(builder.top_stage, host, host);

builder.ensure(CompilerBuiltins { compiler, target: run.target, mode: Mode::Std });
}

fn run(self, builder: &Builder<'_>) -> Self::Output {
let compiler = self.compiler;
let target = self.target;
let mode = self.mode;

builder.ensure(compile::Std::new(compiler, compiler.host).force_recompile(true));
let compiler = builder.compiler_for(compiler.stage, compiler.host, target);

// Also prepare a sysroot for the target.
if !builder.config.is_host_target(target) {
builder.ensure(compile::Std::new(compiler, target).force_recompile(true));
builder.ensure(RemoteCopyLibs { compiler, target });
}

let make_cargo = |f: fn(&mut builder::Cargo) -> &mut builder::Cargo| {
let mut c = builder::Cargo::new(
builder,
compiler,
mode,
SourceType::InTree,
target,
Kind::Test,
);
f(&mut c);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
f(&mut c);
c.current_dir(&builder.src.join("library").join("compiler-builtins"));
f(&mut c);

c
};

// Most tests are in the builtins-test crate.
let crates = ["compiler-builtins".to_string(), "builtins-test".to_string()];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
let crates = ["compiler-builtins".to_string(), "builtins-test".to_string()];
let crates = ["compiler_builtins".to_string(), "builtins-test".to_string()];

let cargo = make_cargo(|c| c);
run_cargo_test(cargo, &[], &crates, "compiler-buitlins", target, builder);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
run_cargo_test(cargo, &[], &crates, "compiler-buitlins", target, builder);
run_cargo_test(cargo, &[], &crates, "compiler-builtins", target, builder);

:) Also below.

let cargo = make_cargo(|c| c.arg("--release"));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need another variation for --release? Cargo automatically sets --release based on rust.optimize config value.

run_cargo_test(cargo, &[], &crates, "compiler-buitlins --release", target, builder);
let cargo = make_cargo(|c| c.arg("--features=c"));
run_cargo_test(cargo, &[], &crates, "compiler-buitlins --features c", target, builder);
}
}

/// Rustdoc is special in various ways, which is why this step is different from `Crate`.
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct CrateRustdoc {
Expand Down
1 change: 1 addition & 0 deletions src/bootstrap/src/core/builder/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1024,6 +1024,7 @@ impl<'a> Builder<'a> {
test::HtmlCheck,
test::RustInstaller,
test::TestFloatParse,
test::CompilerBuiltins,
test::CollectLicenseMetadata,
// Run bootstrap close to the end as it's unlikely to fail
test::Bootstrap,
Expand Down
Loading