Skip to content

Commit 893413d

Browse files
Kobzollqd
authored andcommitted
Add a run-make test for checking that certain rustc_ crates build on stable
1 parent f48062e commit 893413d

File tree

5 files changed

+51
-3
lines changed

5 files changed

+51
-3
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
use crate::command::Command;
2+
use crate::env_var;
3+
4+
/// Returns a command that can be used to invoke Cargo.
5+
pub fn cargo() -> Command {
6+
Command::new(env_var("BOOTSTRAP_CARGO"))
7+
}

src/tools/run-make-support/src/external_deps/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
//! such as `cc` or `python`.
33
44
pub mod c_build;
5+
pub mod cargo;
56
pub mod cc;
67
pub mod clang;
78
pub mod htmldocck;

src/tools/run-make-support/src/external_deps/rustc.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,13 @@ pub struct Rustc {
3636

3737
crate::macros::impl_common_helpers!(Rustc);
3838

39+
pub fn rustc_path() -> String {
40+
env_var("RUSTC")
41+
}
42+
3943
#[track_caller]
4044
fn setup_common() -> Command {
41-
let rustc = env_var("RUSTC");
42-
let mut cmd = Command::new(rustc);
45+
let mut cmd = Command::new(rustc_path());
4346
set_host_rpath(&mut cmd);
4447
cmd
4548
}

src/tools/run-make-support/src/lib.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ pub use external_deps::{c_build, cc, clang, htmldocck, llvm, python, rustc, rust
4848
// These rely on external dependencies.
4949
pub use cc::{cc, cxx, extra_c_flags, extra_cxx_flags, Cc};
5050
pub use c_build::{build_native_dynamic_lib, build_native_static_lib, build_native_static_lib_optimized, build_native_static_lib_cxx};
51+
pub use cargo::cargo;
5152
pub use clang::{clang, Clang};
5253
pub use htmldocck::htmldocck;
5354
pub use llvm::{
@@ -56,7 +57,7 @@ pub use llvm::{
5657
LlvmProfdata, LlvmReadobj,
5758
};
5859
pub use python::python_command;
59-
pub use rustc::{aux_build, bare_rustc, rustc, Rustc};
60+
pub use rustc::{aux_build, bare_rustc, rustc, rustc_path, Rustc};
6061
pub use rustdoc::{bare_rustdoc, rustdoc, Rustdoc};
6162

6263
/// [`diff`][mod@diff] is implemented in terms of the [similar] library.
@@ -96,3 +97,4 @@ pub use assertion_helpers::{
9697
pub use string::{
9798
count_regex_matches_in_files_with_extension, invalid_utf8_contains, invalid_utf8_not_contains,
9899
};
100+
use crate::external_deps::cargo;
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
//! Checks if selected rustc crates can be compiled on the stable channel (or a "simulation" of it).
2+
//! These crates are designed to be used by downstream users.
3+
4+
use run_make_support::{cargo, rustc_path, source_root};
5+
6+
fn main() {
7+
// Use the stage0 beta cargo for the compilation (it shouldn't really matter which cargo we use)
8+
let cargo = cargo()
9+
// This is required to allow using nightly cargo features (public-dependency) with beta
10+
// cargo
11+
.env("RUSTC_BOOTSTRAP", "1")
12+
.env("RUSTC", rustc_path())
13+
.arg("build")
14+
.arg("--manifest-path")
15+
.arg(source_root().join("Cargo.toml"))
16+
.args(&[
17+
"--config",
18+
r#"workspace.exclude=["library/core"]"#,
19+
// We want to disallow all nightly features, to simulate a stable build
20+
// public-dependency needs to be enabled for cargo to work
21+
"-Zallow-features=public-dependency",
22+
// Avoid depending on transitive rustc crates
23+
"--no-default-features",
24+
// Check that these crates can be compiled on "stable"
25+
"-p",
26+
"rustc_type_ir",
27+
"-p",
28+
"rustc_next_trait_solver",
29+
"-p",
30+
"rustc_pattern_analysis",
31+
"-p",
32+
"rustc_lexer",
33+
])
34+
.run();
35+
}

0 commit comments

Comments
 (0)