Skip to content

Commit e5edded

Browse files
authored
Rollup merge of rust-lang#83370 - jyn514:setup-tools, r=Mark-Simulacrum
Add `x.py setup tools` which enables `download-rustc` by default Helps with rust-lang#81930. I know I said in that issue that I should fix that rebasing rebuilds bootstrap, but the compile time improvement is so good I think it's ok to leave that fix for later (I still plan to work on it). I think all the outright bugs have been fixed :) This builds on rust-lang#83368 so I can set the option to `if-unchanged`. r? ```@Mark-Simulacrum```
2 parents d203fce + f8653c9 commit e5edded

File tree

3 files changed

+34
-5
lines changed

3 files changed

+34
-5
lines changed

src/bootstrap/defaults/config.compiler.toml

+1-2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,5 @@ debug-logging = true
88
incremental = true
99

1010
[llvm]
11-
# Will download LLVM from CI if available on your platform (Linux only for now)
12-
# https://github.com/rust-lang/rust/issues/77084 tracks support for more platforms
11+
# Will download LLVM from CI if available on your platform.
1312
download-ci-llvm = "if-available"
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# These defaults are meant for contributors to tools which build on the
2+
# compiler, but do not modify it directly.
3+
[rust]
4+
# This enables `RUSTC_LOG=debug`, avoiding confusing situations
5+
# where adding `debug!()` appears to do nothing.
6+
# However, it makes running the compiler slightly slower.
7+
debug-logging = true
8+
# This greatly increases the speed of rebuilds, especially when there are only minor changes. However, it makes the initial build slightly slower.
9+
incremental = true
10+
# Download rustc from CI instead of building it from source.
11+
# This cuts compile times by almost 60x, but means you can't modify the compiler.
12+
download-rustc = "if-unchanged"
13+
14+
[llvm]
15+
# Will download LLVM from CI if available on your platform.
16+
download-ci-llvm = "if-available"

src/bootstrap/setup.rs

+17-3
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ pub enum Profile {
1313
Compiler,
1414
Codegen,
1515
Library,
16+
Tools,
1617
User,
1718
}
1819

@@ -24,15 +25,16 @@ impl Profile {
2425
pub fn all() -> impl Iterator<Item = Self> {
2526
use Profile::*;
2627
// N.B. these are ordered by how they are displayed, not alphabetically
27-
[Library, Compiler, Codegen, User].iter().copied()
28+
[Library, Compiler, Codegen, Tools, User].iter().copied()
2829
}
2930

3031
pub fn purpose(&self) -> String {
3132
use Profile::*;
3233
match self {
3334
Library => "Contribute to the standard library",
34-
Compiler => "Contribute to the compiler or rustdoc",
35+
Compiler => "Contribute to the compiler itself",
3536
Codegen => "Contribute to the compiler, and also modify LLVM or codegen",
37+
Tools => "Contribute to tools which depend on the compiler, but do not modify it directly (e.g. rustdoc, clippy, miri)",
3638
User => "Install Rust from source",
3739
}
3840
.to_string()
@@ -53,9 +55,12 @@ impl FromStr for Profile {
5355
fn from_str(s: &str) -> Result<Self, Self::Err> {
5456
match s {
5557
"lib" | "library" => Ok(Profile::Library),
56-
"compiler" | "rustdoc" => Ok(Profile::Compiler),
58+
"compiler" => Ok(Profile::Compiler),
5759
"llvm" | "codegen" => Ok(Profile::Codegen),
5860
"maintainer" | "user" => Ok(Profile::User),
61+
"tools" | "tool" | "rustdoc" | "clippy" | "miri" | "rustfmt" | "rls" => {
62+
Ok(Profile::Tools)
63+
}
5964
_ => Err(format!("unknown profile: '{}'", s)),
6065
}
6166
}
@@ -68,6 +73,7 @@ impl fmt::Display for Profile {
6873
Profile::Codegen => write!(f, "codegen"),
6974
Profile::Library => write!(f, "library"),
7075
Profile::User => write!(f, "user"),
76+
Profile::Tools => write!(f, "tools"),
7177
}
7278
}
7379
}
@@ -103,6 +109,14 @@ pub fn setup(src_path: &Path, profile: Profile) {
103109

104110
let suggestions = match profile {
105111
Profile::Codegen | Profile::Compiler => &["check", "build", "test"][..],
112+
Profile::Tools => &[
113+
"check",
114+
"build",
115+
"test src/test/rustdoc*",
116+
"test src/tools/clippy",
117+
"test src/tools/miri",
118+
"test src/tools/rustfmt",
119+
],
106120
Profile::Library => &["check", "build", "test library/std", "doc"],
107121
Profile::User => &["dist", "build"],
108122
};

0 commit comments

Comments
 (0)