Skip to content

Commit 025481a

Browse files
authored
Rollup merge of rust-lang#78153 - est31:downloaded_llvm_maybe_sync, r=Mark-Simulacrum
Sync LLVM submodule if it has been initialized Since having enabled the download-ci-llvm option, and having rebased on top of rust-lang#76864, I've noticed that I had to update the llvm-project submodule manually if it was checked out. Orignally, the submodule update logic was introduced to reduce the friction for contributors to manage the submodules, or in other words, to prevent getting PRs that have unwanted submodule rollbacks because the contributors didn't run git submodule update. This commit adds logic to ensure there is no inadvertent LLVM submodule rollback in a PR if download-ci-llvm (or llvm-config) is enabled. It will detect whether the llvm-project submodule is initialized, and if so, update it in any case. If it is not initialized, behaviour is kept to not do any update/initialization. An alternative to the chosen implementation would be to not pass the --init command line arg to `git submodule update` for the src/llvm-project submodule. This would show a confusing error message however on all builds with an uninitialized repo. We could pass the --silent param, but we still want it to print something if it is initialized and has to update something. So we just do a manual check for whether the submodule is initialized.
2 parents 982c4b3 + 5948e62 commit 025481a

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/bootstrap/bootstrap.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -893,10 +893,15 @@ def update_submodules(self):
893893
).decode(default_encoding).splitlines()]
894894
filtered_submodules = []
895895
submodules_names = []
896+
llvm_checked_out = os.path.exists(os.path.join(self.rust_root, "src/llvm-project/.git"))
896897
for module in submodules:
897898
if module.endswith("llvm-project"):
899+
# Don't sync the llvm-project submodule either if an external LLVM
900+
# was provided, or if we are downloading LLVM. Also, if the
901+
# submodule has been initialized already, sync it anyways so that
902+
# it doesn't mess up contributor pull requests.
898903
if self.get_toml('llvm-config') or self.downloading_llvm():
899-
if self.get_toml('lld') != 'true':
904+
if self.get_toml('lld') != 'true' and not llvm_checked_out:
900905
continue
901906
check = self.check_submodule(module, slow_submodules)
902907
filtered_submodules.append((module, check))

0 commit comments

Comments
 (0)