Add a build option to specify the bootstrap cache
Setting the bootstrap cache path to an external location can help to speed up builds in cases where the build directory is not kept between builds, e.g. in CI or other automated build systems.
This commit is contained in:
parent
d911613280
commit
c98e25bab9
6 changed files with 22 additions and 9 deletions
|
@ -300,6 +300,10 @@
|
||||||
# This is only useful for verifying that rustc generates reproducible builds.
|
# This is only useful for verifying that rustc generates reproducible builds.
|
||||||
#full-bootstrap = false
|
#full-bootstrap = false
|
||||||
|
|
||||||
|
# Set the bootstrap/download cache path. It is useful when building rust
|
||||||
|
# repeatedly in a CI invironment.
|
||||||
|
# bootstrap-cache-path = /shared/cache
|
||||||
|
|
||||||
# Enable a build of the extended Rust tool set which is not only the compiler
|
# Enable a build of the extended Rust tool set which is not only the compiler
|
||||||
# but also tools such as Cargo. This will also produce "combined installers"
|
# but also tools such as Cargo. This will also produce "combined installers"
|
||||||
# which are used to install Rust and Cargo together.
|
# which are used to install Rust and Cargo together.
|
||||||
|
|
|
@ -557,7 +557,9 @@ class RustBuild(object):
|
||||||
shutil.rmtree(bin_root)
|
shutil.rmtree(bin_root)
|
||||||
|
|
||||||
key = self.stage0_compiler.date
|
key = self.stage0_compiler.date
|
||||||
cache_dst = os.getenv('RUSTC_BOOTSTRAP_CACHE', os.path.join(self.build_dir, "cache"))
|
cache_dst = (self.get_toml('bootstrap-cache-path', 'build') or
|
||||||
|
os.path.join(self.build_dir, "cache"))
|
||||||
|
|
||||||
rustc_cache = os.path.join(cache_dst, key)
|
rustc_cache = os.path.join(cache_dst, key)
|
||||||
if not os.path.exists(rustc_cache):
|
if not os.path.exists(rustc_cache):
|
||||||
os.makedirs(rustc_cache)
|
os.makedirs(rustc_cache)
|
||||||
|
|
|
@ -149,6 +149,7 @@ v("default-linker", "rust.default-linker", "the default linker")
|
||||||
# (others are conditionally saved).
|
# (others are conditionally saved).
|
||||||
o("manage-submodules", "build.submodules", "let the build manage the git submodules")
|
o("manage-submodules", "build.submodules", "let the build manage the git submodules")
|
||||||
o("full-bootstrap", "build.full-bootstrap", "build three compilers instead of two (not recommended except for testing reproducible builds)")
|
o("full-bootstrap", "build.full-bootstrap", "build three compilers instead of two (not recommended except for testing reproducible builds)")
|
||||||
|
o("bootstrap-cache-path", "build.bootstrap-cache-path", "use provided path for the bootstrap cache")
|
||||||
o("extended", "build.extended", "build an extended rust tool set")
|
o("extended", "build.extended", "build an extended rust tool set")
|
||||||
|
|
||||||
v("tools", None, "List of extended tools will be installed")
|
v("tools", None, "List of extended tools will be installed")
|
||||||
|
|
|
@ -161,6 +161,7 @@ pub struct Config {
|
||||||
pub vendor: bool,
|
pub vendor: bool,
|
||||||
pub target_config: HashMap<TargetSelection, Target>,
|
pub target_config: HashMap<TargetSelection, Target>,
|
||||||
pub full_bootstrap: bool,
|
pub full_bootstrap: bool,
|
||||||
|
pub bootstrap_cache_path: Option<PathBuf>,
|
||||||
pub extended: bool,
|
pub extended: bool,
|
||||||
pub tools: Option<HashSet<String>>,
|
pub tools: Option<HashSet<String>>,
|
||||||
pub sanitizers: bool,
|
pub sanitizers: bool,
|
||||||
|
@ -827,6 +828,7 @@ define_config! {
|
||||||
locked_deps: Option<bool> = "locked-deps",
|
locked_deps: Option<bool> = "locked-deps",
|
||||||
vendor: Option<bool> = "vendor",
|
vendor: Option<bool> = "vendor",
|
||||||
full_bootstrap: Option<bool> = "full-bootstrap",
|
full_bootstrap: Option<bool> = "full-bootstrap",
|
||||||
|
bootstrap_cache_path: Option<PathBuf> = "bootstrap-cache-path",
|
||||||
extended: Option<bool> = "extended",
|
extended: Option<bool> = "extended",
|
||||||
tools: Option<HashSet<String>> = "tools",
|
tools: Option<HashSet<String>> = "tools",
|
||||||
verbose: Option<usize> = "verbose",
|
verbose: Option<usize> = "verbose",
|
||||||
|
@ -1389,6 +1391,7 @@ impl Config {
|
||||||
locked_deps,
|
locked_deps,
|
||||||
vendor,
|
vendor,
|
||||||
full_bootstrap,
|
full_bootstrap,
|
||||||
|
bootstrap_cache_path,
|
||||||
extended,
|
extended,
|
||||||
tools,
|
tools,
|
||||||
verbose,
|
verbose,
|
||||||
|
@ -1477,6 +1480,7 @@ impl Config {
|
||||||
config.reuse = reuse.map(PathBuf::from);
|
config.reuse = reuse.map(PathBuf::from);
|
||||||
config.submodules = submodules;
|
config.submodules = submodules;
|
||||||
config.android_ndk = android_ndk;
|
config.android_ndk = android_ndk;
|
||||||
|
config.bootstrap_cache_path = bootstrap_cache_path;
|
||||||
set(&mut config.low_priority, low_priority);
|
set(&mut config.low_priority, low_priority);
|
||||||
set(&mut config.compiler_docs, compiler_docs);
|
set(&mut config.compiler_docs, compiler_docs);
|
||||||
set(&mut config.library_docs_private_items, library_docs_private_items);
|
set(&mut config.library_docs_private_items, library_docs_private_items);
|
||||||
|
|
|
@ -578,10 +578,8 @@ impl Config {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let cache_dst = match env::var_os("RUSTC_BOOTSTRAP_CACHE") {
|
let cache_dst =
|
||||||
Some(v) => PathBuf::from(v),
|
self.bootstrap_cache_path.as_ref().cloned().unwrap_or_else(|| self.out.join("cache"));
|
||||||
None => self.out.join("cache"),
|
|
||||||
};
|
|
||||||
|
|
||||||
let cache_dir = cache_dst.join(key);
|
let cache_dir = cache_dst.join(key);
|
||||||
if !cache_dir.exists() {
|
if !cache_dir.exists() {
|
||||||
|
@ -709,10 +707,9 @@ download-rustc = false
|
||||||
let llvm_assertions = self.llvm_assertions;
|
let llvm_assertions = self.llvm_assertions;
|
||||||
|
|
||||||
let cache_prefix = format!("llvm-{llvm_sha}-{llvm_assertions}");
|
let cache_prefix = format!("llvm-{llvm_sha}-{llvm_assertions}");
|
||||||
let cache_dst = match env::var_os("RUSTC_BOOTSTRAP_CACHE") {
|
let cache_dst =
|
||||||
Some(v) => PathBuf::from(v),
|
self.bootstrap_cache_path.as_ref().cloned().unwrap_or_else(|| self.out.join("cache"));
|
||||||
None => self.out.join("cache"),
|
|
||||||
};
|
|
||||||
let rustc_cache = cache_dst.join(cache_prefix);
|
let rustc_cache = cache_dst.join(cache_prefix);
|
||||||
if !rustc_cache.exists() {
|
if !rustc_cache.exists() {
|
||||||
t!(fs::create_dir_all(&rustc_cache));
|
t!(fs::create_dir_all(&rustc_cache));
|
||||||
|
|
|
@ -136,4 +136,9 @@ pub const CONFIG_CHANGE_HISTORY: &[ChangeInfo] = &[
|
||||||
severity: ChangeSeverity::Info,
|
severity: ChangeSeverity::Info,
|
||||||
summary: "`x install` now skips providing tarball sources (under 'build/dist' path) to speed up the installation process.",
|
summary: "`x install` now skips providing tarball sources (under 'build/dist' path) to speed up the installation process.",
|
||||||
},
|
},
|
||||||
|
ChangeInfo {
|
||||||
|
change_id: 121976,
|
||||||
|
severity: ChangeSeverity::Info,
|
||||||
|
summary: "A new `boostrap-cache-path` option has been introduced. Set it in your config.toml to use a different path for the download cache.",
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
Loading…
Add table
Reference in a new issue