Skip to content

Commit 5df276e

Browse files
committed
Turn on fast_submodules unconditionally
I don't know why anyone would turn this off; doing so makes builds much slower (nearly a 60x slowdown according to #49057). Remove the option to do so, which makes bootstrap a little easier to maintain. Bootstrap continues to allow you to manage submodules manually by setting `submodules = false`.
1 parent e52e711 commit 5df276e

File tree

5 files changed

+30
-48
lines changed

5 files changed

+30
-48
lines changed

config.toml.example

-4
Original file line numberDiff line numberDiff line change
@@ -240,10 +240,6 @@ changelog-seen = 2
240240
# Indicate whether git submodules are managed and updated automatically.
241241
#submodules = true
242242

243-
# Update git submodules only when the checked out commit in the submodules differs
244-
# from what is committed in the main rustc repo.
245-
#fast-submodules = true
246-
247243
# The path to (or name of) the GDB executable to use. This is only used for
248244
# executing the debuginfo test suite.
249245
#gdb = "gdb"

src/bootstrap/CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
1111
- The options `infodir`, `localstatedir`, and `gpg-password-file` are no longer allowed in config.toml. Previously, they were ignored without warning. Note that `infodir` and `localstatedir` are still accepted by `./configure`, with a warning. [#82451](https://github.com/rust-lang/rust/pull/82451)
1212
- Add options for enabling overflow checks, one for std (`overflow-checks-std`) and one for everything else (`overflow-checks`). Both default to false.
1313
- Change the names for `dist` commands to match the component they generate. [#90684](https://github.com/rust-lang/rust/pull/90684)
14+
- The `build.fast-submodules` option has been removed. Fast submodule checkouts are enabled unconditionally. Automatic submodule handling can still be disabled with `build.submodules = false`.
1415

1516
### Non-breaking changes
1617

src/bootstrap/bootstrap.py

+11-19
Original file line numberDiff line numberDiff line change
@@ -926,23 +926,19 @@ def build_triple(self):
926926
return config
927927
return default_build_triple(self.verbose)
928928

929-
def check_submodule(self, module, slow_submodules):
930-
if not slow_submodules:
931-
checked_out = subprocess.Popen(["git", "rev-parse", "HEAD"],
932-
cwd=os.path.join(self.rust_root, module),
933-
stdout=subprocess.PIPE)
934-
return checked_out
935-
else:
936-
return None
929+
def check_submodule(self, module):
930+
checked_out = subprocess.Popen(["git", "rev-parse", "HEAD"],
931+
cwd=os.path.join(self.rust_root, module),
932+
stdout=subprocess.PIPE)
933+
return checked_out
937934

938935
def update_submodule(self, module, checked_out, recorded_submodules):
939936
module_path = os.path.join(self.rust_root, module)
940937

941-
if checked_out is not None:
942-
default_encoding = sys.getdefaultencoding()
943-
checked_out = checked_out.communicate()[0].decode(default_encoding).strip()
944-
if recorded_submodules[module] == checked_out:
945-
return
938+
default_encoding = sys.getdefaultencoding()
939+
checked_out = checked_out.communicate()[0].decode(default_encoding).strip()
940+
if recorded_submodules[module] == checked_out:
941+
return
946942

947943
print("Updating submodule", module)
948944

@@ -991,12 +987,8 @@ def update_submodules(self):
991987
git_version_str = require(['git', '--version']).split()[2].decode(default_encoding)
992988
self.git_version = distutils.version.LooseVersion(git_version_str)
993989

994-
slow_submodules = self.get_toml('fast-submodules') == "false"
995990
start_time = time()
996-
if slow_submodules:
997-
print('Unconditionally updating submodules')
998-
else:
999-
print('Updating only changed submodules')
991+
print('Updating only changed submodules')
1000992
default_encoding = sys.getdefaultencoding()
1001993
# Only update submodules that are needed to build bootstrap. These are needed because Cargo
1002994
# currently requires everything in a workspace to be "locally present" when starting a
@@ -1022,7 +1014,7 @@ def update_submodules(self):
10221014
filtered_submodules = []
10231015
submodules_names = []
10241016
for module in submodules:
1025-
check = self.check_submodule(module, slow_submodules)
1017+
check = self.check_submodule(module)
10261018
filtered_submodules.append((module, check))
10271019
submodules_names.append(module)
10281020
recorded = subprocess.Popen(["git", "ls-tree", "HEAD"] + submodules_names,

src/bootstrap/config.rs

-4
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ pub struct Config {
5050
pub ninja_in_file: bool,
5151
pub verbose: usize,
5252
pub submodules: Option<bool>,
53-
pub fast_submodules: bool,
5453
pub compiler_docs: bool,
5554
pub docs_minification: bool,
5655
pub docs: bool,
@@ -517,7 +516,6 @@ define_config! {
517516
compiler_docs: Option<bool> = "compiler-docs",
518517
docs_minification: Option<bool> = "docs-minification",
519518
submodules: Option<bool> = "submodules",
520-
fast_submodules: Option<bool> = "fast-submodules",
521519
gdb: Option<String> = "gdb",
522520
nodejs: Option<String> = "nodejs",
523521
npm: Option<String> = "npm",
@@ -705,7 +703,6 @@ impl Config {
705703
config.rust_optimize = true;
706704
config.rust_optimize_tests = true;
707705
config.submodules = None;
708-
config.fast_submodules = true;
709706
config.docs = true;
710707
config.docs_minification = true;
711708
config.rust_rpath = true;
@@ -847,7 +844,6 @@ impl Config {
847844
set(&mut config.compiler_docs, build.compiler_docs);
848845
set(&mut config.docs_minification, build.docs_minification);
849846
set(&mut config.docs, build.docs);
850-
set(&mut config.fast_submodules, build.fast_submodules);
851847
set(&mut config.locked_deps, build.locked_deps);
852848
set(&mut config.vendor, build.vendor);
853849
set(&mut config.full_bootstrap, build.full_bootstrap);

src/bootstrap/lib.rs

+18-21
Original file line numberDiff line numberDiff line change
@@ -556,27 +556,24 @@ impl Build {
556556
}
557557

558558
// check_submodule
559-
if self.config.fast_submodules {
560-
let checked_out_hash = output(
561-
Command::new("git").args(&["rev-parse", "HEAD"]).current_dir(&absolute_path),
562-
);
563-
// update_submodules
564-
let recorded = output(
565-
Command::new("git")
566-
.args(&["ls-tree", "HEAD"])
567-
.arg(relative_path)
568-
.current_dir(&self.config.src),
569-
);
570-
let actual_hash = recorded
571-
.split_whitespace()
572-
.nth(2)
573-
.unwrap_or_else(|| panic!("unexpected output `{}`", recorded));
574-
575-
// update_submodule
576-
if actual_hash == checked_out_hash.trim_end() {
577-
// already checked out
578-
return;
579-
}
559+
let checked_out_hash =
560+
output(Command::new("git").args(&["rev-parse", "HEAD"]).current_dir(&absolute_path));
561+
// update_submodules
562+
let recorded = output(
563+
Command::new("git")
564+
.args(&["ls-tree", "HEAD"])
565+
.arg(relative_path)
566+
.current_dir(&self.config.src),
567+
);
568+
let actual_hash = recorded
569+
.split_whitespace()
570+
.nth(2)
571+
.unwrap_or_else(|| panic!("unexpected output `{}`", recorded));
572+
573+
// update_submodule
574+
if actual_hash == checked_out_hash.trim_end() {
575+
// already checked out
576+
return;
580577
}
581578

582579
println!("Updating submodule {}", relative_path.display());

0 commit comments

Comments
 (0)