Skip to content

Commit e03db23

Browse files
authored
Rollup merge of rust-lang#54811 - pnkfelix:issue-24840-separate-bootstrap-default-for-optimize-from-debug-setting, r=nikomatsakis
During rustc bootstrap, make default for `optimize` independent of `debug` It may have taken me three and a half years, but I'm following through on my ["threat"](rust-lang#24840 (comment)) Fix rust-lang#24840
2 parents 8455468 + 40e20e2 commit e03db23

File tree

2 files changed

+29
-10
lines changed

2 files changed

+29
-10
lines changed

config.toml.example

+26-9
Original file line numberDiff line numberDiff line change
@@ -243,19 +243,36 @@
243243
# =============================================================================
244244
[rust]
245245

246-
# Indicates that the build should be optimized for debugging Rust. Note that
247-
# this is typically not what you want as it takes an incredibly large amount of
248-
# time to have a debug-mode rustc compile any code (notably libstd). If this
249-
# value is set to `true` it will affect a number of configuration options below
250-
# as well, if unconfigured.
251-
#debug = false
252-
253-
# Whether or not to optimize the compiler and standard library
246+
# Whether or not to optimize the compiler and standard library.
247+
#
254248
# Note: the slowness of the non optimized compiler compiling itself usually
255249
# outweighs the time gains in not doing optimizations, therefore a
256-
# full bootstrap takes much more time with optimize set to false.
250+
# full bootstrap takes much more time with `optimize` set to false.
257251
#optimize = true
258252

253+
# Indicates that the build should be configured for debugging Rust. A
254+
# `debug`-enabled compiler and standard library will be somewhat
255+
# slower (due to e.g. checking of debug assertions) but should remain
256+
# usable.
257+
#
258+
# Note: If this value is set to `true`, it will affect a number of
259+
# configuration options below as well, if they have been left
260+
# unconfigured in this file.
261+
#
262+
# Note: changes to the `debug` setting do *not* affect `optimize`
263+
# above. In theory, a "maximally debuggable" environment would
264+
# set `optimize` to `false` above to assist the introspection
265+
# facilities of debuggers like lldb and gdb. To recreate such an
266+
# environment, explicitly set `optimize` to `false` and `debug`
267+
# to `true`. In practice, everyone leaves `optimize` set to
268+
# `true`, because an unoptimized rustc with debugging
269+
# enabled becomes *unusably slow* (e.g. rust-lang/rust#24840
270+
# reported a 25x slowdown) and bootstrapping the supposed
271+
# "maximally debuggable" environment (notably libstd) takes
272+
# hours to build.
273+
#
274+
#debug = false
275+
259276
# Number of codegen units to use for each compiler invocation. A value of 0
260277
# means "the number of cores on this machine", and 1+ is passed through to the
261278
# compiler.

src/bootstrap/config.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -628,6 +628,9 @@ impl Config {
628628
let default = false;
629629
config.llvm_assertions = llvm_assertions.unwrap_or(default);
630630

631+
let default = true;
632+
config.rust_optimize = optimize.unwrap_or(default);
633+
631634
let default = match &config.channel[..] {
632635
"stable" | "beta" | "nightly" => true,
633636
_ => false,
@@ -640,7 +643,6 @@ impl Config {
640643
config.debug_jemalloc = debug_jemalloc.unwrap_or(default);
641644
config.rust_debuginfo = debuginfo.unwrap_or(default);
642645
config.rust_debug_assertions = debug_assertions.unwrap_or(default);
643-
config.rust_optimize = optimize.unwrap_or(!default);
644646

645647
let default = config.channel == "dev";
646648
config.ignore_git = ignore_git.unwrap_or(default);

0 commit comments

Comments
 (0)