summaryrefslogtreecommitdiffstats
path: root/src/bootstrap/config
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/bootstrap/config.rs28
-rw-r--r--src/bootstrap/config/tests.rs12
-rwxr-xr-xsrc/bootstrap/configure.py28
3 files changed, 53 insertions, 15 deletions
diff --git a/src/bootstrap/config.rs b/src/bootstrap/config.rs
index b41d60d51..05e742549 100644
--- a/src/bootstrap/config.rs
+++ b/src/bootstrap/config.rs
@@ -25,6 +25,7 @@ use crate::flags::{Color, Flags};
use crate::util::{exe, output, t};
use once_cell::sync::OnceCell;
use serde::{Deserialize, Deserializer};
+use serde_derive::Deserialize;
macro_rules! check_ci_llvm {
($name:expr) => {
@@ -65,6 +66,7 @@ pub struct Config {
pub verbose: usize,
pub submodules: Option<bool>,
pub compiler_docs: bool,
+ pub library_docs_private_items: bool,
pub docs_minification: bool,
pub docs: bool,
pub locked_deps: bool,
@@ -96,6 +98,10 @@ pub struct Config {
pub cmd: Subcommand,
pub incremental: bool,
pub dry_run: DryRun,
+ /// Arguments appearing after `--` to be forwarded to tools,
+ /// e.g. `--fix-broken` or test arguments.
+ pub free_args: Vec<String>,
+
/// `None` if we shouldn't download CI compiler artifacts, or the commit to download if we should.
#[cfg(not(test))]
download_rustc_commit: Option<String>,
@@ -168,6 +174,7 @@ pub struct Config {
pub rust_profile_use: Option<String>,
pub rust_profile_generate: Option<String>,
pub rust_lto: RustcLto,
+ pub rust_validate_mir_opts: Option<u32>,
pub llvm_profile_use: Option<String>,
pub llvm_profile_generate: bool,
pub llvm_libunwind_default: Option<LlvmLibunwind>,
@@ -332,8 +339,9 @@ impl SplitDebuginfo {
}
/// LTO mode used for compiling rustc itself.
-#[derive(Default, Clone)]
+#[derive(Default, Clone, PartialEq)]
pub enum RustcLto {
+ Off,
#[default]
ThinLocal,
Thin,
@@ -348,6 +356,7 @@ impl std::str::FromStr for RustcLto {
"thin-local" => Ok(RustcLto::ThinLocal),
"thin" => Ok(RustcLto::Thin),
"fat" => Ok(RustcLto::Fat),
+ "off" => Ok(RustcLto::Off),
_ => Err(format!("Invalid value for rustc LTO: {}", s)),
}
}
@@ -606,6 +615,7 @@ define_config! {
rustfmt: Option<PathBuf> = "rustfmt",
docs: Option<bool> = "docs",
compiler_docs: Option<bool> = "compiler-docs",
+ library_docs_private_items: Option<bool> = "library-docs-private-items",
docs_minification: Option<bool> = "docs-minification",
submodules: Option<bool> = "submodules",
gdb: Option<String> = "gdb",
@@ -762,6 +772,7 @@ define_config! {
// ignored; this is set from an env var set by bootstrap.py
download_rustc: Option<StringOrBool> = "download-rustc",
lto: Option<String> = "lto",
+ validate_mir_opts: Option<u32> = "validate-mir-opts",
}
}
@@ -862,6 +873,7 @@ impl Config {
config.keep_stage = flags.keep_stage;
config.keep_stage_std = flags.keep_stage_std;
config.color = flags.color;
+ config.free_args = flags.free_args.clone().unwrap_or_default();
if let Some(value) = flags.deny_warnings {
config.deny_warnings = value;
}
@@ -965,6 +977,9 @@ impl Config {
config.changelog_seen = toml.changelog_seen;
let build = toml.build.unwrap_or_default();
+ if let Some(file_build) = build.build {
+ config.build = TargetSelection::from_user(&file_build);
+ };
set(&mut config.out, flags.build_dir.or_else(|| build.build_dir.map(PathBuf::from)));
// NOTE: Bootstrap spawns various commands with different working directories.
@@ -1015,6 +1030,7 @@ impl Config {
config.submodules = build.submodules;
set(&mut config.low_priority, build.low_priority);
set(&mut config.compiler_docs, build.compiler_docs);
+ set(&mut config.library_docs_private_items, build.library_docs_private_items);
set(&mut config.docs_minification, build.docs_minification);
set(&mut config.docs, build.docs);
set(&mut config.locked_deps, build.locked_deps);
@@ -1136,6 +1152,7 @@ impl Config {
.as_deref()
.map(|value| RustcLto::from_str(value).unwrap())
.unwrap_or_default();
+ config.rust_validate_mir_opts = rust.validate_mir_opts;
} else {
config.rust_profile_use = flags.rust_profile_use;
config.rust_profile_generate = flags.rust_profile_generate;
@@ -1302,15 +1319,6 @@ impl Config {
} else {
RustfmtState::Unavailable
};
- } else {
- // If using a system toolchain for bootstrapping, see if that has rustfmt available.
- let host = config.build;
- let rustfmt_path = config.initial_rustc.with_file_name(exe("rustfmt", host));
- let bin_root = config.out.join(host.triple).join("stage0");
- if !rustfmt_path.starts_with(&bin_root) {
- // Using a system-provided toolchain; we shouldn't download rustfmt.
- *config.initial_rustfmt.borrow_mut() = RustfmtState::SystemToolchain(rustfmt_path);
- }
}
// Now that we've reached the end of our configuration, infer the
diff --git a/src/bootstrap/config/tests.rs b/src/bootstrap/config/tests.rs
index c30c91317..5a105007f 100644
--- a/src/bootstrap/config/tests.rs
+++ b/src/bootstrap/config/tests.rs
@@ -11,6 +11,11 @@ fn parse(config: &str) -> Config {
#[test]
fn download_ci_llvm() {
+ if crate::native::is_ci_llvm_modified(&parse("")) {
+ eprintln!("Detected LLVM as non-available: running in CI and modified LLVM in this change");
+ return;
+ }
+
let parse_llvm = |s| parse(s).llvm_from_ci;
let if_available = parse_llvm("llvm.download-ci-llvm = \"if-available\"");
@@ -19,6 +24,13 @@ fn download_ci_llvm() {
assert_eq!(parse_llvm(""), if_available);
assert_eq!(parse_llvm("rust.channel = \"dev\""), if_available);
assert!(!parse_llvm("rust.channel = \"stable\""));
+ assert!(parse_llvm("build.build = \"x86_64-unknown-linux-gnu\""));
+ assert!(parse_llvm(
+ "llvm.assertions = true \r\n build.build = \"x86_64-unknown-linux-gnu\" \r\n llvm.download-ci-llvm = \"if-available\""
+ ));
+ assert!(!parse_llvm(
+ "llvm.assertions = true \r\n build.build = \"aarch64-apple-darwin\" \r\n llvm.download-ci-llvm = \"if-available\""
+ ));
}
// FIXME: add test for detecting `src` and `out`
diff --git a/src/bootstrap/configure.py b/src/bootstrap/configure.py
index 0af329e70..ab3d08292 100755
--- a/src/bootstrap/configure.py
+++ b/src/bootstrap/configure.py
@@ -379,8 +379,14 @@ cur_section = None
sections[None] = []
section_order = [None]
targets = {}
+top_level_keys = []
for line in open(rust_dir + '/config.toml.example').read().split("\n"):
+ if cur_section == None:
+ if line.count('=') == 1:
+ top_level_key = line.split('=')[0]
+ top_level_key = top_level_key.strip(' #')
+ top_level_keys.append(top_level_key)
if line.startswith('['):
cur_section = line[1:-1]
if cur_section.startswith('target'):
@@ -436,6 +442,8 @@ def to_toml(value):
return value
else:
return "'" + value + "'"
+ elif isinstance(value, dict):
+ return "{" + ", ".join(map(lambda a: "{} = {}".format(to_toml(a[0]), to_toml(a[1])), value.items())) + "}"
else:
raise RuntimeError('no toml')
@@ -459,12 +467,22 @@ def configure_section(lines, config):
raise RuntimeError("failed to find config line for {}".format(key))
-for section_key in config:
- section_config = config[section_key]
- if section_key not in sections:
- raise RuntimeError("config key {} not in sections".format(section_key))
+def configure_top_level_key(lines, top_level_key, value):
+ for i, line in enumerate(lines):
+ if line.startswith('#' + top_level_key + ' = ') or line.startswith(top_level_key + ' = '):
+ lines[i] = "{} = {}".format(top_level_key, value)
+ return
- if section_key == 'target':
+ raise RuntimeError("failed to find config line for {}".format(top_level_key))
+
+
+for section_key, section_config in config.items():
+ if section_key not in sections and section_key not in top_level_keys:
+ raise RuntimeError("config key {} not in sections or top_level_keys".format(section_key))
+ if section_key in top_level_keys:
+ configure_top_level_key(sections[None], section_key, section_config)
+
+ elif section_key == 'target':
for target in section_config:
configure_section(targets[target], section_config[target])
else: