diff --git a/config.toml.example b/config.toml.example index e832570ed982e..c0eaff1bc56e7 100644 --- a/config.toml.example +++ b/config.toml.example @@ -14,6 +14,11 @@ # ============================================================================= [llvm] +# Skip rebuilding LLVM. If set to true, `bootstrap.py` will not rebuild LLVM. +# This can be used or overridden with the command-line arguments +# --skip-llvm-rebuild and --no-skip-llvm-rebuild as well. +# skip-llvm-rebuild = false + # Indicates whether the LLVM build is a Release or Debug build #optimize = true diff --git a/src/bootstrap/bootstrap.py b/src/bootstrap/bootstrap.py index 4caf36a6f2a51..976144e91e953 100644 --- a/src/bootstrap/bootstrap.py +++ b/src/bootstrap/bootstrap.py @@ -330,6 +330,7 @@ def __init__(self): self.use_locked_deps = '' self.use_vendored_sources = '' self.verbose = False + self.skip_llvm_rebuild = False def download_stage0(self): """Fetch the build system for Rust, written in Rust @@ -734,6 +735,9 @@ def update_submodules(self): if module.endswith("llvm-project"): if self.get_toml('llvm-config') and self.get_toml('lld') != 'true': continue + if self.skip_llvm_rebuild: + print("Skipping llvm-project rebuild") + continue check = self.check_submodule(module, slow_submodules) filtered_submodules.append((module, check)) submodules_names.append(module) @@ -820,6 +824,10 @@ def bootstrap(help_triggered): parser.add_argument('--src') parser.add_argument('--clean', action='store_true') parser.add_argument('-v', '--verbose', action='count', default=0) + parser.add_argument('--skip-llvm-rebuild', + dest='skip_llvm_rebuild', action='store_true', default=None) + parser.add_argument('--no-skip-llvm-rebuild', + dest='skip_llvm_rebuild', action='store_false') args = [a for a in sys.argv if a != '-h' and a != '--help'] args, _ = parser.parse_known_args(args) @@ -840,6 +848,17 @@ def bootstrap(help_triggered): if config_verbose is not None: build.verbose = max(build.verbose, int(config_verbose)) + config_skip_llvm_rebuild = build.get_toml('skip-llvm-rebuild') + if args.skip_llvm_rebuild is not None: + # explicit cli arg is the strongest truth, ignore config file + build.skip_llvm_rebuild = args.skip_llvm_rebuild + elif config_skip_llvm_rebuild is not None: + # explicit config arg, no cli arg, trust the config file + build.skip_llvm_rebuild = config_skip_llvm_rebuild == 'true' + else: + # no config, no cli arg, defaulting to not skipping + build.skip_llvm_rebuild = False + build.use_vendored_sources = build.get_toml('vendor', 'build') == 'true' build.use_locked_deps = build.get_toml('locked-deps', 'build') == 'true' diff --git a/src/bootstrap/config.rs b/src/bootstrap/config.rs index d1bdfa0a76763..e3919bd8b678e 100644 --- a/src/bootstrap/config.rs +++ b/src/bootstrap/config.rs @@ -66,6 +66,7 @@ pub struct Config { pub backtrace_on_ice: bool, // llvm codegen options + pub skip_llvm_rebuild: bool, pub llvm_assertions: bool, pub llvm_optimize: bool, pub llvm_thin_lto: bool, @@ -243,6 +244,7 @@ struct Install { #[derive(Deserialize, Default)] #[serde(deny_unknown_fields, rename_all = "kebab-case")] struct Llvm { + skip_llvm_rebuild: Option, optimize: Option, thin_lto: Option, release_debuginfo: Option, @@ -513,6 +515,7 @@ impl Config { } set(&mut config.ninja, llvm.ninja); llvm_assertions = llvm.assertions; + set(&mut config.skip_llvm_rebuild, llvm.skip_llvm_rebuild); set(&mut config.llvm_optimize, llvm.optimize); set(&mut config.llvm_thin_lto, llvm.thin_lto); set(&mut config.llvm_release_debuginfo, llvm.release_debuginfo);