Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 481b5fa

Browse files
committedNov 24, 2024
Auto merge of #133068 - jieyouxu:download-rustc-default-only-for-tools, r=clubby789
Use `download-rustc=false` global default, `if-unchanged` for tools and library profiles, and make `rust.debug-assertions=true` inhibit downloading CI rustc - Use `download-rustc = false` as global default. - Use `download-rustc = 'if-unchanged'` for tools and library profiles. - Make `rust.debug-assertions = true` inhibit downloading CI rustc because alt rustc builds do not yet have rustc debug assertions enabled. Fixes #133132. cc discussions: https://rust-lang.zulipchat.com/#narrow/channel/326414-t-infra.2Fbootstrap/topic/Bootstrap.20breakage compiler contributors poll: https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/.60download-rustc.20.3D.20'if-unchanged'.60.20for.20.60compiler.60.20profile.3F/near/481877253 library contributors poll: https://rust-lang.zulipchat.com/#narrow/channel/219381-t-libs/topic/.60download-rustc.20.3D.20.22if-unchanged.22.60.20default.20for.20libs.20profile.3F/near/482607011 cc https://rust-lang.zulipchat.com/#narrow/channel/326414-t-infra.2Fbootstrap/topic/When.20is.20rustc.20built.20with.20debug.20assertions.3F cc `@MarcoIeni` since you're working on improving CI job times, sorry, this will definitely regress some CI job times because we're probably lying to ourselves that CI rustc had debug assertions for some time 😅 cc `@onur-ozkan` for FYI, but since you're on vacation (sorry for the ping), r? `@Kobzol` (I *think* you have a bit more context than other bootstrap reviewers?)
2 parents f5d1857 + f7f8ad9 commit 481b5fa

File tree

8 files changed

+75
-13
lines changed

8 files changed

+75
-13
lines changed
 

‎config.example.toml

+10-7
Original file line numberDiff line numberDiff line change
@@ -496,15 +496,18 @@
496496
#
497497
#debug = false
498498

499-
# Whether to download the stage 1 and 2 compilers from CI.
500-
# This is useful if you are working on tools, doc-comments, or library (you will be able to build
501-
# the standard library without needing to build the compiler).
499+
# Whether to download the stage 1 and 2 compilers from CI. This is useful if you
500+
# are working on tools, doc-comments, or library (you will be able to build the
501+
# standard library without needing to build the compiler).
502502
#
503-
# Set this to "if-unchanged" if you are working on `src/tools`, `tests` or `library` (on CI, `library`
504-
# changes triggers in-tree compiler build) to speed up the build process.
503+
# Set this to "if-unchanged" if you are working on `src/tools`, `tests` or
504+
# `library` (on CI, `library` changes triggers in-tree compiler build) to speed
505+
# up the build process if you don't need to build a compiler from the latest
506+
# commit from `master`.
505507
#
506-
# Set this to `true` to always download or `false` to always use the in-tree compiler.
507-
#download-rustc = "if-unchanged"
508+
# Set this to `true` to always download or `false` to always use the in-tree
509+
# compiler.
510+
#download-rustc = false
508511

509512
# Number of codegen units to use for each compiler invocation. A value of 0
510513
# means "the number of cores on this machine", and 1+ is passed through to the

‎src/bootstrap/defaults/config.compiler.toml

+3
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ lto = "off"
1919
# Forces frame pointers to be used with `-Cforce-frame-pointers`.
2020
# This can be helpful for profiling at a small performance cost.
2121
frame-pointers = true
22+
# Compiler contributors often want to build rustc even without any changes to
23+
# e.g. check that it builds locally and check the baseline behavior of a
24+
# compiler built from latest `master` commit.
2225
download-rustc = false
2326

2427
[llvm]

‎src/bootstrap/defaults/config.dist.toml

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ download-ci-llvm = false
1616
# We have several defaults in bootstrap that depend on whether the channel is `dev` (e.g. `omit-git-hash` and `download-ci-llvm`).
1717
# Make sure they don't get set when installing from source.
1818
channel = "nightly"
19+
# Never download a rustc, distributions must build a fresh compiler.
1920
download-rustc = false
2021
lld = true
2122
# Build the llvm-bitcode-linker

‎src/bootstrap/defaults/config.library.toml

+3-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ bench-stage = 0
1010
incremental = true
1111
# Make the compiler and standard library faster to build, at the expense of a ~20% runtime slowdown.
1212
lto = "off"
13-
download-rustc = false
13+
# Download rustc by default for library profile if compiler-affecting
14+
# directories are not modified. For CI this is disabled.
15+
download-rustc = "if-unchanged"
1416

1517
[llvm]
1618
# Will download LLVM from CI if available on your platform.

‎src/bootstrap/defaults/config.tools.toml

+3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
[rust]
44
# This greatly increases the speed of rebuilds, especially when there are only minor changes. However, it makes the initial build slightly slower.
55
incremental = true
6+
# Most commonly, tools contributors do not need to modify the compiler, so
7+
# downloading a CI rustc is a good default for tools profile.
8+
download-rustc = "if-unchanged"
69

710
[build]
811
# Document with the in-tree rustdoc by default, since `download-rustc` makes it quick to compile.

‎src/bootstrap/src/core/config/config.rs

+46-4
Original file line numberDiff line numberDiff line change
@@ -1771,8 +1771,37 @@ impl Config {
17711771
std_features: std_features_toml,
17721772
} = rust;
17731773

1774-
config.download_rustc_commit =
1775-
config.download_ci_rustc_commit(download_rustc, config.llvm_assertions);
1774+
// FIXME(#133381): alt rustc builds currently do *not* have rustc debug assertions
1775+
// enabled. We should not download a CI alt rustc if we need rustc to have debug
1776+
// assertions (e.g. for crashes test suite). This can be changed once something like
1777+
// [Enable debug assertions on alt
1778+
// builds](https://github.com/rust-lang/rust/pull/131077) lands.
1779+
//
1780+
// Note that `rust.debug = true` currently implies `rust.debug-assertions = true`!
1781+
//
1782+
// This relies also on the fact that the global default for `download-rustc` will be
1783+
// `false` if it's not explicitly set.
1784+
let debug_assertions_requested = matches!(rustc_debug_assertions_toml, Some(true))
1785+
|| (matches!(debug_toml, Some(true))
1786+
&& !matches!(rustc_debug_assertions_toml, Some(false)));
1787+
1788+
if debug_assertions_requested {
1789+
if let Some(ref opt) = download_rustc {
1790+
if opt.is_string_or_true() {
1791+
eprintln!(
1792+
"WARN: currently no CI rustc builds have rustc debug assertions \
1793+
enabled. Please either set `rust.debug-assertions` to `false` if you \
1794+
want to use download CI rustc or set `rust.download-rustc` to `false`."
1795+
);
1796+
}
1797+
}
1798+
}
1799+
1800+
config.download_rustc_commit = config.download_ci_rustc_commit(
1801+
download_rustc,
1802+
debug_assertions_requested,
1803+
config.llvm_assertions,
1804+
);
17761805

17771806
debug = debug_toml;
17781807
rustc_debug_assertions = rustc_debug_assertions_toml;
@@ -2778,6 +2807,7 @@ impl Config {
27782807
fn download_ci_rustc_commit(
27792808
&self,
27802809
download_rustc: Option<StringOrBool>,
2810+
debug_assertions_requested: bool,
27812811
llvm_assertions: bool,
27822812
) -> Option<String> {
27832813
if !is_download_ci_available(&self.build.triple, llvm_assertions) {
@@ -2786,8 +2816,12 @@ impl Config {
27862816

27872817
// If `download-rustc` is not set, default to rebuilding.
27882818
let if_unchanged = match download_rustc {
2789-
None => self.rust_info.is_managed_git_subrepository(),
2790-
Some(StringOrBool::Bool(false)) => return None,
2819+
// Globally default `download-rustc` to `false`, because some contributors don't use
2820+
// profiles for reasons such as:
2821+
// - They need to seamlessly switch between compiler/library work.
2822+
// - They don't want to use compiler profile because they need to override too many
2823+
// things and it's easier to not use a profile.
2824+
None | Some(StringOrBool::Bool(false)) => return None,
27912825
Some(StringOrBool::Bool(true)) => false,
27922826
Some(StringOrBool::String(s)) if s == "if-unchanged" => {
27932827
if !self.rust_info.is_managed_git_subrepository() {
@@ -2845,6 +2879,14 @@ impl Config {
28452879
return None;
28462880
}
28472881

2882+
if debug_assertions_requested {
2883+
eprintln!(
2884+
"WARN: `rust.debug-assertions = true` will prevent downloading CI rustc as alt CI \
2885+
rustc is not currently built with debug assertions."
2886+
);
2887+
return None;
2888+
}
2889+
28482890
Some(commit)
28492891
}
28502892

‎src/bootstrap/src/utils/change_tracker.rs

+5
Original file line numberDiff line numberDiff line change
@@ -305,4 +305,9 @@ pub const CONFIG_CHANGE_HISTORY: &[ChangeInfo] = &[
305305
severity: ChangeSeverity::Info,
306306
summary: "`rust.llvm-tools` is now enabled by default when no `config.toml` is provided.",
307307
},
308+
ChangeInfo {
309+
change_id: 133068,
310+
severity: ChangeSeverity::Warning,
311+
summary: "Revert `rust.download-rustc` global default to `false` and only use `rust.download-rustc = \"if-unchanged\"` default for library and tools profile. As alt CI rustc is built without debug assertions, `rust.debug-assertions = true` will now inhibit downloading CI rustc.",
312+
},
308313
];

‎src/ci/docker/host-x86_64/x86_64-gnu-tools/Dockerfile

+4-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,10 @@ ENV RUST_CONFIGURE_ARGS \
8484
--enable-new-symbol-mangling
8585

8686
ENV HOST_TARGET x86_64-unknown-linux-gnu
87-
ENV FORCE_CI_RUSTC 1
87+
88+
# FIXME(#133381): currently rustc alt builds do *not* have rustc debug
89+
# assertions enabled! Therefore, we cannot force download CI rustc.
90+
#ENV FORCE_CI_RUSTC 1
8891

8992
COPY host-x86_64/dist-x86_64-linux/shared.sh /scripts/
9093
COPY host-x86_64/dist-x86_64-linux/build-gccjit.sh /scripts/

0 commit comments

Comments
 (0)
Failed to load comments.