1
Fork 0

Rollup merge of #97290 - jyn514:fast-submodules, r=Mark-Simulacrum

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`.
This commit is contained in:
Yuki Okushi 2022-05-24 12:18:32 +09:00 committed by GitHub
commit 9845a41233
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 29 additions and 47 deletions

View file

@ -240,10 +240,6 @@ changelog-seen = 2
# Indicate whether git submodules are managed and updated automatically. # Indicate whether git submodules are managed and updated automatically.
#submodules = true #submodules = true
# Update git submodules only when the checked out commit in the submodules differs
# from what is committed in the main rustc repo.
#fast-submodules = true
# The path to (or name of) the GDB executable to use. This is only used for # The path to (or name of) the GDB executable to use. This is only used for
# executing the debuginfo test suite. # executing the debuginfo test suite.
#gdb = "gdb" #gdb = "gdb"

View file

@ -11,6 +11,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- 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) - 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)
- Add options for enabling overflow checks, one for std (`overflow-checks-std`) and one for everything else (`overflow-checks`). Both default to false. - Add options for enabling overflow checks, one for std (`overflow-checks-std`) and one for everything else (`overflow-checks`). Both default to false.
- Change the names for `dist` commands to match the component they generate. [#90684](https://github.com/rust-lang/rust/pull/90684) - Change the names for `dist` commands to match the component they generate. [#90684](https://github.com/rust-lang/rust/pull/90684)
- 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`.
### Non-breaking changes ### Non-breaking changes

View file

@ -926,23 +926,19 @@ class RustBuild(object):
return config return config
return default_build_triple(self.verbose) return default_build_triple(self.verbose)
def check_submodule(self, module, slow_submodules): def check_submodule(self, module):
if not slow_submodules: checked_out = subprocess.Popen(["git", "rev-parse", "HEAD"],
checked_out = subprocess.Popen(["git", "rev-parse", "HEAD"], cwd=os.path.join(self.rust_root, module),
cwd=os.path.join(self.rust_root, module), stdout=subprocess.PIPE)
stdout=subprocess.PIPE) return checked_out
return checked_out
else:
return None
def update_submodule(self, module, checked_out, recorded_submodules): def update_submodule(self, module, checked_out, recorded_submodules):
module_path = os.path.join(self.rust_root, module) module_path = os.path.join(self.rust_root, module)
if checked_out is not None: default_encoding = sys.getdefaultencoding()
default_encoding = sys.getdefaultencoding() checked_out = checked_out.communicate()[0].decode(default_encoding).strip()
checked_out = checked_out.communicate()[0].decode(default_encoding).strip() if recorded_submodules[module] == checked_out:
if recorded_submodules[module] == checked_out: return
return
print("Updating submodule", module) print("Updating submodule", module)
@ -991,12 +987,8 @@ class RustBuild(object):
git_version_str = require(['git', '--version']).split()[2].decode(default_encoding) git_version_str = require(['git', '--version']).split()[2].decode(default_encoding)
self.git_version = distutils.version.LooseVersion(git_version_str) self.git_version = distutils.version.LooseVersion(git_version_str)
slow_submodules = self.get_toml('fast-submodules') == "false"
start_time = time() start_time = time()
if slow_submodules: print('Updating only changed submodules')
print('Unconditionally updating submodules')
else:
print('Updating only changed submodules')
default_encoding = sys.getdefaultencoding() default_encoding = sys.getdefaultencoding()
# Only update submodules that are needed to build bootstrap. These are needed because Cargo # Only update submodules that are needed to build bootstrap. These are needed because Cargo
# currently requires everything in a workspace to be "locally present" when starting a # currently requires everything in a workspace to be "locally present" when starting a
@ -1022,7 +1014,7 @@ class RustBuild(object):
filtered_submodules = [] filtered_submodules = []
submodules_names = [] submodules_names = []
for module in submodules: for module in submodules:
check = self.check_submodule(module, slow_submodules) check = self.check_submodule(module)
filtered_submodules.append((module, check)) filtered_submodules.append((module, check))
submodules_names.append(module) submodules_names.append(module)
recorded = subprocess.Popen(["git", "ls-tree", "HEAD"] + submodules_names, recorded = subprocess.Popen(["git", "ls-tree", "HEAD"] + submodules_names,

View file

@ -50,7 +50,6 @@ pub struct Config {
pub ninja_in_file: bool, pub ninja_in_file: bool,
pub verbose: usize, pub verbose: usize,
pub submodules: Option<bool>, pub submodules: Option<bool>,
pub fast_submodules: bool,
pub compiler_docs: bool, pub compiler_docs: bool,
pub docs_minification: bool, pub docs_minification: bool,
pub docs: bool, pub docs: bool,
@ -517,7 +516,6 @@ define_config! {
compiler_docs: Option<bool> = "compiler-docs", compiler_docs: Option<bool> = "compiler-docs",
docs_minification: Option<bool> = "docs-minification", docs_minification: Option<bool> = "docs-minification",
submodules: Option<bool> = "submodules", submodules: Option<bool> = "submodules",
fast_submodules: Option<bool> = "fast-submodules",
gdb: Option<String> = "gdb", gdb: Option<String> = "gdb",
nodejs: Option<String> = "nodejs", nodejs: Option<String> = "nodejs",
npm: Option<String> = "npm", npm: Option<String> = "npm",
@ -705,7 +703,6 @@ impl Config {
config.rust_optimize = true; config.rust_optimize = true;
config.rust_optimize_tests = true; config.rust_optimize_tests = true;
config.submodules = None; config.submodules = None;
config.fast_submodules = true;
config.docs = true; config.docs = true;
config.docs_minification = true; config.docs_minification = true;
config.rust_rpath = true; config.rust_rpath = true;
@ -847,7 +844,6 @@ impl Config {
set(&mut config.compiler_docs, build.compiler_docs); set(&mut config.compiler_docs, build.compiler_docs);
set(&mut config.docs_minification, build.docs_minification); set(&mut config.docs_minification, build.docs_minification);
set(&mut config.docs, build.docs); set(&mut config.docs, build.docs);
set(&mut config.fast_submodules, build.fast_submodules);
set(&mut config.locked_deps, build.locked_deps); set(&mut config.locked_deps, build.locked_deps);
set(&mut config.vendor, build.vendor); set(&mut config.vendor, build.vendor);
set(&mut config.full_bootstrap, build.full_bootstrap); set(&mut config.full_bootstrap, build.full_bootstrap);

View file

@ -556,27 +556,24 @@ impl Build {
} }
// check_submodule // check_submodule
if self.config.fast_submodules { let checked_out_hash =
let checked_out_hash = output( output(Command::new("git").args(&["rev-parse", "HEAD"]).current_dir(&absolute_path));
Command::new("git").args(&["rev-parse", "HEAD"]).current_dir(&absolute_path), // update_submodules
); let recorded = output(
// update_submodules Command::new("git")
let recorded = output( .args(&["ls-tree", "HEAD"])
Command::new("git") .arg(relative_path)
.args(&["ls-tree", "HEAD"]) .current_dir(&self.config.src),
.arg(relative_path) );
.current_dir(&self.config.src), let actual_hash = recorded
); .split_whitespace()
let actual_hash = recorded .nth(2)
.split_whitespace() .unwrap_or_else(|| panic!("unexpected output `{}`", recorded));
.nth(2)
.unwrap_or_else(|| panic!("unexpected output `{}`", recorded));
// update_submodule // update_submodule
if actual_hash == checked_out_hash.trim_end() { if actual_hash == checked_out_hash.trim_end() {
// already checked out // already checked out
return; return;
}
} }
println!("Updating submodule {}", relative_path.display()); println!("Updating submodule {}", relative_path.display());