about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorJoshua Nelson <jyn514@gmail.com>2021-02-23 13:01:39 -0500
committerJoshua Nelson <jyn514@gmail.com>2021-04-07 14:36:02 -0400
commit28e83a47164db25bd818c73dbc3d64695bf197e0 (patch)
tree5bc1ecba1976d03bdd54246fd38e39dc0ad0bfaa /src
parent8cd7d86ce27f22260a89ff0d47638cc1de827c9d (diff)
Cleanup option parsing and config.toml.example
- Add an assertion that `link-shared = true` when `thin-lto = true`.
  Previously, link-shared would be silently overwritten.

- Get rid of `Option<bool>` in bootstrap/config.rs. Set defaults
  immediately instead of delaying until later in bootstrap. This makes
  it easier to find what the default value is.

- Remove redundant `config.x = false` when the default was already false
- Set defaults for `bindir` in `default_opts()` instead of `parse()`
- Update `download-ci-llvm = if-supported` option to match bootstrap.py
- Remove redundant check for link_shared. Previously, it was checked twice.

- Update various options in config.toml.example to their defaults.
  Previously, some options showed an example value instead of the
  default value.

- Fix incorrect defaults in config.toml.example
  + `use-libcxx` defaults to false
  + Add missing `check-stage = 0`
  + Update several defaults to be conditional (e.g. `if incremental { 10 } else { 100 }`)

- Remove redundant defaults in prose
- Use the same comment for the default and target-dependent `musl-root`
- Fix typos
- Link to `cc_detect` for `cc` and `cxx`, since the logic is ... complicated.
- Update more defaults to better reflect how they actually get set
- Remove ignored `gpg-password-file` option

  This stopped being used in
  https://github.com/rust-lang/rust/commit/7704d35accfe1b587ce41ea09ca3bf6a47aca117,
  but was never removed from config.toml.

- Remove unused flags from `config.toml`
    + Disallow `infodir` and `localstatedir` in `config.toml`
    + Allow the flags in `./configure`, but give a warning that they will be
      ignored.
    + Fix incorrect comment that `datadir` will be ignored.

    Example output:

    ```
    $ ./configure --set install.infodir=xxx
    configure: processing command line
    configure:
    configure: install.infodir      := xxx
    configure: build.configure-args := ['--set', 'install.infodir=xxx']
    warning: infodir will be ignored
    configure:
    configure: writing `config.toml` in current directory
    configure:
    configure: run `python /home/joshua/rustc3/x.py --help`
    configure:
    ```

- Update CHANGELOG
- Add "as an example" where appropriate
- Link to an issue instead of to ephemeral chats
Diffstat (limited to 'src')
-rw-r--r--src/bootstrap/CHANGELOG.md1
-rw-r--r--src/bootstrap/config.rs52
-rwxr-xr-xsrc/bootstrap/configure.py7
-rw-r--r--src/bootstrap/lib.rs2
-rw-r--r--src/bootstrap/native.rs4
5 files changed, 39 insertions, 27 deletions
diff --git a/src/bootstrap/CHANGELOG.md b/src/bootstrap/CHANGELOG.md
index f899f21080e..8437a10426b 100644
--- a/src/bootstrap/CHANGELOG.md
+++ b/src/bootstrap/CHANGELOG.md
@@ -8,6 +8,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
 ## [Changes since the last major version]
 
 - `llvm-libunwind` now accepts `in-tree` (formerly true), `system` or `no` (formerly false) [#77703](https://github.com/rust-lang/rust/pull/77703)
+- 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)
 
 ### Non-breaking changes
 
diff --git a/src/bootstrap/config.rs b/src/bootstrap/config.rs
index b9b090bb2d2..0c76ee04752 100644
--- a/src/bootstrap/config.rs
+++ b/src/bootstrap/config.rs
@@ -67,7 +67,7 @@ pub struct Config {
     pub rustc_error_format: Option<String>,
     pub json_output: bool,
     pub test_compare_mode: bool,
-    pub llvm_libunwind: Option<LlvmLibunwind>,
+    pub llvm_libunwind: LlvmLibunwind,
     pub color: Color,
 
     pub on_fail: Option<String>,
@@ -101,8 +101,8 @@ pub struct Config {
     pub llvm_link_jobs: Option<u32>,
     pub llvm_version_suffix: Option<String>,
     pub llvm_use_linker: Option<String>,
-    pub llvm_allow_old_toolchain: Option<bool>,
-    pub llvm_polly: Option<bool>,
+    pub llvm_allow_old_toolchain: bool,
+    pub llvm_polly: bool,
     pub llvm_from_ci: bool,
 
     pub use_lld: bool,
@@ -149,7 +149,6 @@ pub struct Config {
     // dist misc
     pub dist_sign_folder: Option<PathBuf>,
     pub dist_upload_addr: Option<String>,
-    pub dist_gpg_password_file: Option<PathBuf>,
     pub dist_compression_formats: Option<Vec<String>>,
 
     // libstd features
@@ -404,10 +403,6 @@ struct Install {
     libdir: Option<String>,
     mandir: Option<String>,
     datadir: Option<String>,
-
-    // standard paths, currently unused
-    infodir: Option<String>,
-    localstatedir: Option<String>,
 }
 
 /// TOML representation of how the LLVM build is configured.
@@ -563,11 +558,10 @@ impl Config {
         config.rust_rpath = true;
         config.channel = "dev".to_string();
         config.codegen_tests = true;
-        config.ignore_git = false;
         config.rust_dist_src = true;
         config.rust_codegen_backends = vec![INTERNER.intern_str("llvm")];
         config.deny_warnings = true;
-        config.missing_tools = false;
+        config.bindir = "bin".into();
 
         // set by build.rs
         config.build = TargetSelection::from_user(&env!("BUILD_TRIPLE"));
@@ -597,7 +591,6 @@ impl Config {
         config.dry_run = flags.dry_run;
         config.keep_stage = flags.keep_stage;
         config.keep_stage_std = flags.keep_stage_std;
-        config.bindir = "bin".into(); // default
         config.color = flags.color;
         if let Some(value) = flags.deny_warnings {
             config.deny_warnings = value;
@@ -792,12 +785,25 @@ impl Config {
             config.llvm_ldflags = llvm.ldflags.clone();
             set(&mut config.llvm_use_libcxx, llvm.use_libcxx);
             config.llvm_use_linker = llvm.use_linker.clone();
-            config.llvm_allow_old_toolchain = llvm.allow_old_toolchain;
-            config.llvm_polly = llvm.polly;
+            config.llvm_allow_old_toolchain = llvm.allow_old_toolchain.unwrap_or(false);
+            config.llvm_polly = llvm.polly.unwrap_or(false);
             config.llvm_from_ci = match llvm.download_ci_llvm {
                 Some(StringOrBool::String(s)) => {
                     assert!(s == "if-available", "unknown option `{}` for download-ci-llvm", s);
-                    config.build.triple == "x86_64-unknown-linux-gnu"
+                    // This is currently all tier 1 targets (since others may not have CI artifacts)
+                    // https://doc.rust-lang.org/rustc/platform-support.html#tier-1
+                    // FIXME: this is duplicated in bootstrap.py
+                    let supported_platforms = [
+                        "aarch64-unknown-linux-gnu",
+                        "i686-pc-windows-gnu",
+                        "i686-pc-windows-msvc",
+                        "i686-unknown-linux-gnu",
+                        "x86_64-unknown-linux-gnu",
+                        "x86_64-apple-darwin",
+                        "x86_64-pc-windows-gnu",
+                        "x86_64-pc-windows-msvc",
+                    ];
+                    supported_platforms.contains(&&*config.build.triple)
                 }
                 Some(StringOrBool::Bool(b)) => b,
                 None => false,
@@ -818,7 +824,6 @@ impl Config {
                 check_ci_llvm!(llvm.targets);
                 check_ci_llvm!(llvm.experimental_targets);
                 check_ci_llvm!(llvm.link_jobs);
-                check_ci_llvm!(llvm.link_shared);
                 check_ci_llvm!(llvm.clang_cl);
                 check_ci_llvm!(llvm.version_suffix);
                 check_ci_llvm!(llvm.cflags);
@@ -839,6 +844,11 @@ impl Config {
                 // If we're building with ThinLTO on, we want to link to LLVM
                 // shared, to avoid re-doing ThinLTO (which happens in the link
                 // step) with each stage.
+                assert_ne!(
+                    llvm.link_shared,
+                    Some(false),
+                    "setting link-shared=false is incompatible with thin-lto=true"
+                );
                 config.llvm_link_shared = true;
             }
         }
@@ -864,7 +874,8 @@ impl Config {
             set(&mut config.test_compare_mode, rust.test_compare_mode);
             config.llvm_libunwind = rust
                 .llvm_libunwind
-                .map(|v| v.parse().expect("failed to parse rust.llvm-libunwind"));
+                .map(|v| v.parse().expect("failed to parse rust.llvm-libunwind"))
+                .unwrap_or_default();
             set(&mut config.backtrace, rust.backtrace);
             set(&mut config.channel, rust.channel);
             config.description = rust.description;
@@ -952,7 +963,6 @@ impl Config {
 
         if let Some(t) = toml.dist {
             config.dist_sign_folder = t.sign_folder.map(PathBuf::from);
-            config.dist_gpg_password_file = t.gpg_password_file.map(PathBuf::from);
             config.dist_upload_addr = t.upload_addr;
             config.dist_compression_formats = t.compression_formats;
             set(&mut config.rust_dist_src, t.src_tarball);
@@ -976,12 +986,8 @@ impl Config {
         // default values for all options that we haven't otherwise stored yet.
 
         config.llvm_skip_rebuild = llvm_skip_rebuild.unwrap_or(false);
-
-        let default = false;
-        config.llvm_assertions = llvm_assertions.unwrap_or(default);
-
-        let default = true;
-        config.rust_optimize = optimize.unwrap_or(default);
+        config.llvm_assertions = llvm_assertions.unwrap_or(false);
+        config.rust_optimize = optimize.unwrap_or(true);
 
         let default = debug == Some(true);
         config.rust_debug_assertions = debug_assertions.unwrap_or(default);
diff --git a/src/bootstrap/configure.py b/src/bootstrap/configure.py
index 2e6e9142afe..999882a1c04 100755
--- a/src/bootstrap/configure.py
+++ b/src/bootstrap/configure.py
@@ -439,7 +439,12 @@ def configure_section(lines, config):
             lines[i] = "{} = {}".format(key, to_toml(value))
             break
         if not found:
-            raise RuntimeError("failed to find config line for {}".format(key))
+            # These are used by rpm, but aren't accepted by x.py.
+            # Give a warning that they're ignored, but not a hard error.
+            if key in ["infodir", "localstatedir"]:
+                print("warning: {} will be ignored".format(key))
+            else:
+                raise RuntimeError("failed to find config line for {}".format(key))
 
 
 for section_key in config:
diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs
index 5d708d3b25c..24da44b933a 100644
--- a/src/bootstrap/lib.rs
+++ b/src/bootstrap/lib.rs
@@ -547,7 +547,7 @@ impl Build {
     fn std_features(&self, target: TargetSelection) -> String {
         let mut features = "panic-unwind".to_string();
 
-        match self.config.llvm_libunwind.unwrap_or_default() {
+        match self.config.llvm_libunwind {
             LlvmLibunwind::InTree => features.push_str(" llvm-libunwind"),
             LlvmLibunwind::System => features.push_str(" system-llvm-libunwind"),
             LlvmLibunwind::No => {}
diff --git a/src/bootstrap/native.rs b/src/bootstrap/native.rs
index 305ff071dbb..c06ceb80c6a 100644
--- a/src/bootstrap/native.rs
+++ b/src/bootstrap/native.rs
@@ -256,7 +256,7 @@ impl Step for Llvm {
             enabled_llvm_projects.push("compiler-rt");
         }
 
-        if let Some(true) = builder.config.llvm_polly {
+        if builder.config.llvm_polly {
             enabled_llvm_projects.push("polly");
         }
 
@@ -311,7 +311,7 @@ impl Step for Llvm {
             cfg.define("LLVM_USE_LINKER", linker);
         }
 
-        if let Some(true) = builder.config.llvm_allow_old_toolchain {
+        if builder.config.llvm_allow_old_toolchain {
             cfg.define("LLVM_TEMPORARILY_ALLOW_OLD_TOOLCHAIN", "YES");
         }