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

Add test to build crates used by r-a on stable #129529

Merged
merged 7 commits into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from 6 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
2 changes: 1 addition & 1 deletion compiler/rustc_type_ir/src/elaborate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ pub fn supertrait_def_ids<I: Interner>(
cx: I,
trait_def_id: I::DefId,
) -> impl Iterator<Item = I::DefId> {
let mut set: HashSet<I::DefId> = HashSet::default();
let mut set = HashSet::default();
let mut stack = vec![trait_def_id];

set.insert(trait_def_id);
Expand Down
7 changes: 7 additions & 0 deletions src/tools/run-make-support/src/external_deps/cargo.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
use crate::command::Command;
use crate::env_var;

/// Returns a command that can be used to invoke Cargo.
pub fn cargo() -> Command {
Command::new(env_var("BOOTSTRAP_CARGO"))
}
1 change: 1 addition & 0 deletions src/tools/run-make-support/src/external_deps/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
//! such as `cc` or `python`.

pub mod c_build;
pub mod cargo;
pub mod cc;
pub mod clang;
pub mod htmldocck;
Expand Down
7 changes: 5 additions & 2 deletions src/tools/run-make-support/src/external_deps/rustc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,13 @@ pub struct Rustc {

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

pub fn rustc_path() -> String {
env_var("RUSTC")
}

#[track_caller]
fn setup_common() -> Command {
let rustc = env_var("RUSTC");
let mut cmd = Command::new(rustc);
let mut cmd = Command::new(rustc_path());
set_host_rpath(&mut cmd);
cmd
}
Expand Down
4 changes: 3 additions & 1 deletion src/tools/run-make-support/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ pub use external_deps::{c_build, cc, clang, htmldocck, llvm, python, rustc, rust
// These rely on external dependencies.
pub use cc::{cc, cxx, extra_c_flags, extra_cxx_flags, Cc};
pub use c_build::{build_native_dynamic_lib, build_native_static_lib, build_native_static_lib_optimized, build_native_static_lib_cxx};
pub use cargo::cargo;
pub use clang::{clang, Clang};
pub use htmldocck::htmldocck;
pub use llvm::{
Expand All @@ -56,7 +57,7 @@ pub use llvm::{
LlvmProfdata, LlvmReadobj,
};
pub use python::python_command;
pub use rustc::{aux_build, bare_rustc, rustc, Rustc};
pub use rustc::{aux_build, bare_rustc, rustc, rustc_path, Rustc};
pub use rustdoc::{bare_rustdoc, rustdoc, Rustdoc};

/// [`diff`][mod@diff] is implemented in terms of the [similar] library.
Expand Down Expand Up @@ -96,3 +97,4 @@ pub use assertion_helpers::{
pub use string::{
count_regex_matches_in_files_with_extension, invalid_utf8_contains, invalid_utf8_not_contains,
};
use crate::external_deps::cargo;
42 changes: 42 additions & 0 deletions tests/run-make/rustc-crates-on-stable/rmake.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
//! Checks if selected rustc crates can be compiled on the stable channel (or a "simulation" of it).
//! These crates are designed to be used by downstream users.

use run_make_support::{cargo, run_in_tmpdir, rustc_path, source_root};

fn main() {
run_in_tmpdir(|| {
lqd marked this conversation as resolved.
Show resolved Hide resolved
// Use the stage0 beta cargo for the compilation (it shouldn't really matter which cargo we
// use)
let cargo = cargo()
lqd marked this conversation as resolved.
Show resolved Hide resolved
// Ensure `proc-macro2`'s nightly detection is disabled
.env("RUSTC_STAGE", "0")
lqd marked this conversation as resolved.
Show resolved Hide resolved
.env("RUSTC", rustc_path())
// We want to disallow all nightly features to simulate a stable build
.env("RUSTFLAGS", "-Zallow-features=")
.arg("build")
.arg("--manifest-path")
.arg(source_root().join("Cargo.toml"))
.args(&[
"--config",
r#"workspace.exclude=["library/core"]"#,
lqd marked this conversation as resolved.
Show resolved Hide resolved
// Avoid depending on transitive rustc crates
"--no-default-features",
// Emit artifacts in this temporary directory, not in the source_root's `target`
// folder
"--target-dir",
".",
lqd marked this conversation as resolved.
Show resolved Hide resolved
])
// Check that these crates can be compiled on "stable"
.args(&[
"-p",
"rustc_type_ir",
"-p",
"rustc_next_trait_solver",
"-p",
"rustc_pattern_analysis",
"-p",
"rustc_lexer",
])
.run();
});
}
Loading