From 9e68d89cc87c5413a6667bf553a80942804d444e Mon Sep 17 00:00:00 2001 From: Nilstrieb <48135649+Nilstrieb@users.noreply.github.com> Date: Sun, 18 Feb 2024 22:51:17 +0100 Subject: [PATCH] Remove the "codegen" profile from bootstrap This profile originally made sense when download-ci-llvm = if-unchanged didn't exist and we had the bad tradeoff of "never modify or always compile". Thankfully, these grim times are over and we have discovered clean water, so the only differentiator between the two profiles is the codegen profile having LLVM assertions. Adding them doesn't cause that much of a slowdown, <10% on UI tests from an unscientific benchmark. It also had LLVM warnings when compiling, which makes sense for every compiler contributor brave enough to compile LLVM. The way I removed is by just issueing a nice error message. Given that everyone with this profile should be a contributor and not someone like a distro who is more upset when things break, this should be fine. If it isn't, we can always fall back to just letting codegen mean compiler. --- src/bootstrap/defaults/config.codegen.toml | 28 --------------------- src/bootstrap/defaults/config.compiler.toml | 5 ++++ src/bootstrap/src/core/build_steps/setup.rs | 23 ++++++----------- src/bootstrap/src/utils/change_tracker.rs | 5 ++++ triagebot.toml | 5 ---- 5 files changed, 17 insertions(+), 49 deletions(-) delete mode 100644 src/bootstrap/defaults/config.codegen.toml diff --git a/src/bootstrap/defaults/config.codegen.toml b/src/bootstrap/defaults/config.codegen.toml deleted file mode 100644 index cf336d7a63639..0000000000000 --- a/src/bootstrap/defaults/config.codegen.toml +++ /dev/null @@ -1,28 +0,0 @@ -# These defaults are meant for contributors to the compiler who modify codegen or LLVM -[build] -# Contributors working on the compiler will probably expect compiler docs to be generated. -compiler-docs = true - -[llvm] -# This enables debug-assertions in LLVM, -# catching logic errors in codegen much earlier in the process. -assertions = true -# enable warnings during the llvm compilation -enable-warnings = true -# build llvm from source -download-ci-llvm = "if-unchanged" - -[rust] -# This enables `RUSTC_LOG=debug`, avoiding confusing situations -# where adding `debug!()` appears to do nothing. -# However, it makes running the compiler slightly slower. -debug-logging = true -# This greatly increases the speed of rebuilds, especially when there are only minor changes. However, it makes the initial build slightly slower. -incremental = true -# Print backtrace on internal compiler errors during bootstrap -backtrace-on-ice = true -# Make the compiler and standard library faster to build, at the expense of a ~20% runtime slowdown. -lto = "off" -# Forces frame pointers to be used with `-Cforce-frame-pointers`. -# This can be helpful for profiling at a small performance cost. -frame-pointers = true diff --git a/src/bootstrap/defaults/config.compiler.toml b/src/bootstrap/defaults/config.compiler.toml index 5c2d476d98e05..178c6e9056c69 100644 --- a/src/bootstrap/defaults/config.compiler.toml +++ b/src/bootstrap/defaults/config.compiler.toml @@ -19,5 +19,10 @@ lto = "off" frame-pointers = true [llvm] +# This enables debug-assertions in LLVM, +# catching logic errors in codegen much earlier in the process. +assertions = true +# Enable warnings during the LLVM compilation (when LLVM is changed, causing a compilation) +enable-warnings = true # Will download LLVM from CI if available on your platform. download-ci-llvm = "if-unchanged" diff --git a/src/bootstrap/src/core/build_steps/setup.rs b/src/bootstrap/src/core/build_steps/setup.rs index 5b434eddb7158..f7747e66dd9c5 100644 --- a/src/bootstrap/src/core/build_steps/setup.rs +++ b/src/bootstrap/src/core/build_steps/setup.rs @@ -19,7 +19,6 @@ mod tests; #[derive(Clone, Copy, Debug, Eq, PartialEq, Hash)] pub enum Profile { Compiler, - Codegen, Library, Tools, Dist, @@ -48,7 +47,7 @@ impl Profile { pub fn all() -> impl Iterator { use Profile::*; // N.B. these are ordered by how they are displayed, not alphabetically - [Library, Compiler, Codegen, Tools, Dist, None].iter().copied() + [Library, Compiler, Tools, Dist, None].iter().copied() } pub fn purpose(&self) -> String { @@ -56,7 +55,6 @@ impl Profile { match self { Library => "Contribute to the standard library", Compiler => "Contribute to the compiler itself", - Codegen => "Contribute to the compiler, and also modify LLVM or codegen", Tools => "Contribute to tools which depend on the compiler, but do not modify it directly (e.g. rustdoc, clippy, miri)", Dist => "Install Rust from source", None => "Do not modify `config.toml`" @@ -75,7 +73,6 @@ impl Profile { pub fn as_str(&self) -> &'static str { match self { Profile::Compiler => "compiler", - Profile::Codegen => "codegen", Profile::Library => "library", Profile::Tools => "tools", Profile::Dist => "dist", @@ -91,12 +88,15 @@ impl FromStr for Profile { match s { "lib" | "library" => Ok(Profile::Library), "compiler" => Ok(Profile::Compiler), - "llvm" | "codegen" => Ok(Profile::Codegen), "maintainer" | "dist" | "user" => Ok(Profile::Dist), "tools" | "tool" | "rustdoc" | "clippy" | "miri" | "rustfmt" | "rls" => { Ok(Profile::Tools) } "none" => Ok(Profile::None), + "llvm" | "codegen" => Err(format!( + "the \"llvm\" and \"codegen\" profiles have been removed,\ + use \"compiler\" instead which has the same functionality" + )), _ => Err(format!("unknown profile: '{s}'")), } } @@ -170,22 +170,13 @@ impl Step for Profile { } fn run(self, builder: &Builder<'_>) { - // During ./x.py setup once you select the codegen profile. - // The submodule will be downloaded. It does not work in the - // tarball case since they don't include Git and submodules - // are already included. - if !builder.rust_info().is_from_tarball() { - if self == Profile::Codegen { - builder.update_submodule(&Path::new("src/llvm-project")); - } - } - setup(&builder.build.config, self) + setup(&builder.build.config, self); } } pub fn setup(config: &Config, profile: Profile) { let suggestions: &[&str] = match profile { - Profile::Codegen | Profile::Compiler | Profile::None => &["check", "build", "test"], + Profile::Compiler | Profile::None => &["check", "build", "test"], Profile::Tools => &[ "check", "build", diff --git a/src/bootstrap/src/utils/change_tracker.rs b/src/bootstrap/src/utils/change_tracker.rs index 1625047d3e103..fe5b5fe317565 100644 --- a/src/bootstrap/src/utils/change_tracker.rs +++ b/src/bootstrap/src/utils/change_tracker.rs @@ -124,4 +124,9 @@ pub const CONFIG_CHANGE_HISTORY: &[ChangeInfo] = &[ severity: ChangeSeverity::Info, summary: "A new `rust.frame-pointers` option has been introduced and made the default in the compiler and codegen profiles.", }, + ChangeInfo { + change_id: 121278, + severity: ChangeSeverity::Warning, + summary: "The \"codegen\"/\"llvm\" profile has been removed and replaced with \"compiler\", use it instead for the same behavior.", + }, ]; diff --git a/triagebot.toml b/triagebot.toml index 1a30399e46c03..8c9faf92b7fe9 100644 --- a/triagebot.toml +++ b/triagebot.toml @@ -627,11 +627,6 @@ This PR modifies `config.example.toml`. If appropriate, please update `CONFIG_CHANGE_HISTORY` in `src/bootstrap/src/utils/change_tracker.rs`. """ -[mentions."src/bootstrap/defaults/config.compiler.toml"] -message = "This PR changes src/bootstrap/defaults/config.compiler.toml. If appropriate, please also update `config.codegen.toml` so the defaults are in sync." -[mentions."src/bootstrap/defaults/config.codegen.toml"] -message = "This PR changes src/bootstrap/defaults/config.codegen.toml. If appropriate, please also update `config.compiler.toml` so the defaults are in sync." - [mentions."src/bootstrap/src/core/build_steps/llvm.rs"] message = "This PR changes how LLVM is built. Consider updating src/bootstrap/download-ci-llvm-stamp."