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 a sysroot crate to represent the standard library crates #108865

Merged
merged 1 commit into from
May 4, 2023
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
10 changes: 9 additions & 1 deletion Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4733,6 +4733,15 @@ dependencies = [
"unicode-xid",
]

[[package]]
name = "sysroot"
version = "0.0.0"
dependencies = [
"proc_macro",
"std",
"test",
]

[[package]]
name = "tar"
version = "0.4.38"
Expand Down Expand Up @@ -4817,7 +4826,6 @@ dependencies = [
"getopts",
"panic_abort",
"panic_unwind",
"proc_macro",
"std",
]

Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
members = [
"compiler/rustc",
"library/std",
"library/test",
"library/sysroot",
"src/rustdoc-json-types",
"src/tools/build_helper",
"src/tools/cargotest",
Expand Down
27 changes: 27 additions & 0 deletions library/sysroot/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
[package]
name = "sysroot"
version = "0.0.0"
edition = "2021"

# this is a dummy crate to ensure that all required crates appear in the sysroot
[dependencies]
proc_macro = { path = "../proc_macro" }
std = { path = "../std" }
test = { path = "../test" }

# Forward features to the `std` crate as necessary
[features]
default = ["std_detect_file_io", "std_detect_dlsym_getauxval", "panic-unwind"]
backtrace = ["std/backtrace"]
compiler-builtins-c = ["std/compiler-builtins-c"]
compiler-builtins-mem = ["std/compiler-builtins-mem"]
compiler-builtins-no-asm = ["std/compiler-builtins-no-asm"]
compiler-builtins-mangled-names = ["std/compiler-builtins-mangled-names"]
llvm-libunwind = ["std/llvm-libunwind"]
system-llvm-libunwind = ["std/system-llvm-libunwind"]
panic-unwind = ["std/panic_unwind"]
panic_immediate_abort = ["std/panic_immediate_abort"]
profiler = ["std/profiler"]
std_detect_file_io = ["std/std_detect_file_io"]
std_detect_dlsym_getauxval = ["std/std_detect_dlsym_getauxval"]
std_detect_env_override = ["std/std_detect_env_override"]
1 change: 1 addition & 0 deletions library/sysroot/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// This is intentionally empty since this crate is only used to depend on other library crates.
20 changes: 0 additions & 20 deletions library/test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,3 @@ std = { path = "../std" }
core = { path = "../core" }
panic_unwind = { path = "../panic_unwind" }
panic_abort = { path = "../panic_abort" }

# not actually used but needed to always have proc_macro in the sysroot
proc_macro = { path = "../proc_macro" }

# Forward features to the `std` crate as necessary
[features]
default = ["std_detect_file_io", "std_detect_dlsym_getauxval", "panic-unwind"]
backtrace = ["std/backtrace"]
compiler-builtins-c = ["std/compiler-builtins-c"]
compiler-builtins-mem = ["std/compiler-builtins-mem"]
compiler-builtins-no-asm = ["std/compiler-builtins-no-asm"]
compiler-builtins-mangled-names = ["std/compiler-builtins-mangled-names"]
llvm-libunwind = ["std/llvm-libunwind"]
system-llvm-libunwind = ["std/system-llvm-libunwind"]
panic-unwind = ["std/panic_unwind"]
panic_immediate_abort = ["std/panic_immediate_abort"]
profiler = ["std/profiler"]
std_detect_file_io = ["std/std_detect_file_io"]
std_detect_dlsym_getauxval = ["std/std_detect_dlsym_getauxval"]
std_detect_env_override = ["std/std_detect_env_override"]
2 changes: 1 addition & 1 deletion src/bootstrap/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ impl Step for Std {
const DEFAULT: bool = true;

fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
run.all_krates("test").path("library")
run.all_krates("sysroot").path("library")
}

fn make_run(run: RunConfig<'_>) {
Expand Down
2 changes: 1 addition & 1 deletion src/bootstrap/clean.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ macro_rules! clean_crate_tree {

clean_crate_tree! {
Rustc, Mode::Rustc, "rustc-main";
Std, Mode::Std, "test";
Std, Mode::Std, "sysroot";
}

fn clean_default(build: &Build, all: bool) {
Expand Down
4 changes: 2 additions & 2 deletions src/bootstrap/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ impl Step for Std {
// When downloading stage1, the standard library has already been copied to the sysroot, so
// there's no need to rebuild it.
let builder = run.builder;
run.crate_or_deps("test")
run.crate_or_deps("sysroot")
.path("library")
.lazy_default_condition(Box::new(|| !builder.download_rustc()))
}
Expand Down Expand Up @@ -364,7 +364,7 @@ pub fn std_cargo(builder: &Builder<'_>, target: TargetSelection, stage: u32, car
.arg("--features")
.arg(features)
.arg("--manifest-path")
.arg(builder.src.join("library/test/Cargo.toml"));
.arg(builder.src.join("library/sysroot/Cargo.toml"));

// Help the libc crate compile by assisting it in finding various
// sysroot native libraries.
Expand Down
2 changes: 1 addition & 1 deletion src/bootstrap/doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ impl Step for Std {

fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
let builder = run.builder;
run.all_krates("test").path("library").default_condition(builder.config.docs)
run.all_krates("sysroot").path("library").default_condition(builder.config.docs)
}

fn make_run(run: RunConfig<'_>) {
Expand Down
2 changes: 1 addition & 1 deletion src/bootstrap/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2163,7 +2163,7 @@ impl Step for Crate {
const DEFAULT: bool = true;

fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
run.crate_or_deps("test")
run.crate_or_deps("sysroot")
}

fn make_run(run: RunConfig<'_>) {
Expand Down