2015-11-19 15:20:12 -08:00
|
|
|
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
|
|
|
|
// file at the top-level directory of this distribution and at
|
|
|
|
// http://rust-lang.org/COPYRIGHT.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
|
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
|
|
// option. This file may not be copied, modified, or distributed
|
|
|
|
// except according to those terms.
|
|
|
|
|
2016-05-02 15:16:15 -07:00
|
|
|
//! Serialized configuration of a build.
|
|
|
|
//!
|
2017-08-26 15:01:48 -07:00
|
|
|
//! This module implements parsing `config.toml` configuration files to tweak
|
|
|
|
//! how the build runs.
|
2016-05-02 15:16:15 -07:00
|
|
|
|
2015-11-19 15:20:12 -08:00
|
|
|
use std::collections::HashMap;
|
|
|
|
use std::env;
|
2017-08-26 15:01:48 -07:00
|
|
|
use std::fs::File;
|
2015-11-19 15:20:12 -08:00
|
|
|
use std::io::prelude::*;
|
|
|
|
use std::path::PathBuf;
|
|
|
|
use std::process;
|
2017-07-29 22:12:53 -06:00
|
|
|
use std::cmp;
|
2015-11-19 15:20:12 -08:00
|
|
|
|
|
|
|
use num_cpus;
|
2017-07-04 10:03:01 -06:00
|
|
|
use toml;
|
2017-08-26 15:01:48 -07:00
|
|
|
use util::exe;
|
2017-07-13 18:48:44 -06:00
|
|
|
use cache::{INTERNER, Interned};
|
2017-07-29 22:12:53 -06:00
|
|
|
use flags::Flags;
|
|
|
|
pub use flags::Subcommand;
|
2015-11-19 15:20:12 -08:00
|
|
|
|
|
|
|
/// Global configuration for the entire build and/or bootstrap.
|
|
|
|
///
|
|
|
|
/// This structure is derived from a combination of both `config.toml` and
|
|
|
|
/// `config.mk`. As of the time of this writing it's unlikely that `config.toml`
|
|
|
|
/// is used all that much, so this is primarily filled out by `config.mk` which
|
|
|
|
/// is generated from `./configure`.
|
|
|
|
///
|
|
|
|
/// Note that this structure is not decoded directly into, but rather it is
|
2016-05-02 15:16:15 -07:00
|
|
|
/// filled out from the decoded forms of the structs below. For documentation
|
|
|
|
/// each field, see the corresponding fields in
|
2017-08-11 22:24:25 -07:00
|
|
|
/// `config.toml.example`.
|
2015-11-19 15:20:12 -08:00
|
|
|
#[derive(Default)]
|
|
|
|
pub struct Config {
|
2016-12-12 11:36:52 -08:00
|
|
|
pub ccache: Option<String>,
|
2016-04-10 00:27:32 -04:00
|
|
|
pub ninja: bool,
|
2016-11-16 18:02:56 -05:00
|
|
|
pub verbose: usize,
|
2015-11-19 15:20:12 -08:00
|
|
|
pub submodules: bool,
|
|
|
|
pub compiler_docs: bool,
|
|
|
|
pub docs: bool,
|
2017-02-10 22:59:40 +02:00
|
|
|
pub locked_deps: bool,
|
2016-11-01 13:46:38 -07:00
|
|
|
pub vendor: bool,
|
2017-07-13 18:48:44 -06:00
|
|
|
pub target_config: HashMap<Interned<String>, Target>,
|
rustbuild: Compile rustc twice, not thrice
This commit switches the rustbuild build system to compiling the
compiler twice for a normal bootstrap rather than the historical three
times.
Rust is a bootstrapped language which means that a previous version of
the compiler is used to build the next version of the compiler. Over
time, however, we change many parts of compiler artifacts such as the
metadata format, symbol names, etc. These changes make artifacts from
one compiler incompatible from another compiler. Consequently if a
compiler wants to be able to use some artifacts then it itself must have
compiled the artifacts.
Historically the rustc build system has achieved this by compiling the
compiler three times:
* An older compiler (stage0) is downloaded to kick off the chain.
* This compiler now compiles a new compiler (stage1)
* The stage1 compiler then compiles another compiler (stage2)
* Finally, the stage2 compiler needs libraries to link against, so it
compiles all the libraries again.
This entire process amounts in compiling the compiler three times.
Additionally, this process always guarantees that the Rust source tree
can compile itself because the stage2 compiler (created by a freshly
created compiler) would successfully compile itself again. This
property, ensuring Rust can compile itself, is quite important!
In general, though, this third compilation is not required for general
purpose development on the compiler. The third compiler (stage2) can
reuse the libraries that were created during the second compile. In
other words, the second compilation can produce both a compiler and the
libraries that compiler will use. These artifacts *must* be compatible
due to the way plugins work today anyway, and they were created by the
same source code so they *should* be compatible as well.
So given all that, this commit switches the default build process to
only compile the compiler three times, avoiding this third compilation
by copying artifacts from the previous one. Along the way a new entry in
the Travis matrix was also added to ensure that our full bootstrap can
succeed. This entry does not run tests, though, as it should not be
necessary.
To restore the old behavior of a full bootstrap (three compiles) you can
either pass:
./configure --enable-full-bootstrap
or if you're using config.toml:
[build]
full-bootstrap = true
Overall this will hopefully be an easy 33% win in build times of the
compiler. If we do 33% less work we should be 33% faster! This in turn
should affect cycle times and such on Travis and AppVeyor positively as
well as making it easier to work on the compiler itself.
2016-12-25 15:20:33 -08:00
|
|
|
pub full_bootstrap: bool,
|
2017-01-20 17:03:06 -08:00
|
|
|
pub extended: bool,
|
2017-02-03 18:58:47 -05:00
|
|
|
pub sanitizers: bool,
|
2017-02-13 09:57:50 +00:00
|
|
|
pub profiler: bool,
|
2017-08-03 10:53:56 -06:00
|
|
|
pub ignore_git: bool,
|
2015-11-19 15:20:12 -08:00
|
|
|
|
2017-08-10 21:17:42 +05:00
|
|
|
pub run_host_only: bool,
|
|
|
|
|
2017-07-29 22:12:53 -06:00
|
|
|
pub on_fail: Option<String>,
|
|
|
|
pub stage: Option<u32>,
|
|
|
|
pub keep_stage: Option<u32>,
|
|
|
|
pub src: PathBuf,
|
|
|
|
pub jobs: Option<u32>,
|
|
|
|
pub cmd: Subcommand,
|
|
|
|
pub incremental: bool,
|
|
|
|
|
2015-11-19 15:20:12 -08:00
|
|
|
// llvm codegen options
|
2017-06-18 16:00:10 +02:00
|
|
|
pub llvm_enabled: bool,
|
2015-11-19 15:20:12 -08:00
|
|
|
pub llvm_assertions: bool,
|
|
|
|
pub llvm_optimize: bool,
|
2016-11-10 17:30:06 +01:00
|
|
|
pub llvm_release_debuginfo: bool,
|
2015-11-19 15:20:12 -08:00
|
|
|
pub llvm_version_check: bool,
|
|
|
|
pub llvm_static_stdcpp: bool,
|
2016-11-16 23:28:14 -08:00
|
|
|
pub llvm_link_shared: bool,
|
2016-12-29 02:23:38 +08:00
|
|
|
pub llvm_targets: Option<String>,
|
2017-06-16 15:43:43 -07:00
|
|
|
pub llvm_experimental_targets: Option<String>,
|
2017-03-05 16:11:11 +01:00
|
|
|
pub llvm_link_jobs: Option<u32>,
|
2015-11-19 15:20:12 -08:00
|
|
|
|
|
|
|
// rust codegen options
|
|
|
|
pub rust_optimize: bool,
|
|
|
|
pub rust_codegen_units: u32,
|
|
|
|
pub rust_debug_assertions: bool,
|
|
|
|
pub rust_debuginfo: bool,
|
2016-10-19 09:48:46 -07:00
|
|
|
pub rust_debuginfo_lines: bool,
|
2017-01-10 20:01:54 -08:00
|
|
|
pub rust_debuginfo_only_std: bool,
|
2015-11-19 15:20:12 -08:00
|
|
|
pub rust_rpath: bool,
|
|
|
|
pub rustc_default_linker: Option<String>,
|
|
|
|
pub rustc_default_ar: Option<String>,
|
2016-05-13 15:26:41 -07:00
|
|
|
pub rust_optimize_tests: bool,
|
|
|
|
pub rust_debuginfo_tests: bool,
|
2017-02-14 09:54:58 -08:00
|
|
|
pub rust_dist_src: bool,
|
2015-11-19 15:20:12 -08:00
|
|
|
|
2017-07-13 18:48:44 -06:00
|
|
|
pub build: Interned<String>,
|
2017-07-29 22:12:53 -06:00
|
|
|
pub hosts: Vec<Interned<String>>,
|
|
|
|
pub targets: Vec<Interned<String>>,
|
2016-05-23 09:49:46 -07:00
|
|
|
pub local_rebuild: bool,
|
2015-11-19 15:20:12 -08:00
|
|
|
|
2017-01-24 14:37:04 -08:00
|
|
|
// dist misc
|
|
|
|
pub dist_sign_folder: Option<PathBuf>,
|
|
|
|
pub dist_upload_addr: Option<String>,
|
|
|
|
pub dist_gpg_password_file: Option<PathBuf>,
|
|
|
|
|
2015-11-19 15:20:12 -08:00
|
|
|
// libstd features
|
|
|
|
pub debug_jemalloc: bool,
|
|
|
|
pub use_jemalloc: bool,
|
2016-07-26 15:21:25 -05:00
|
|
|
pub backtrace: bool, // support for RUST_BACKTRACE
|
2015-11-19 15:20:12 -08:00
|
|
|
|
|
|
|
// misc
|
2017-03-23 22:57:29 +01:00
|
|
|
pub low_priority: bool,
|
2015-11-19 15:20:12 -08:00
|
|
|
pub channel: String,
|
2016-10-29 21:58:52 -04:00
|
|
|
pub quiet_tests: bool,
|
2016-09-06 01:04:41 -05:00
|
|
|
// Fallback musl-root for all targets
|
2015-11-19 15:20:12 -08:00
|
|
|
pub musl_root: Option<PathBuf>,
|
2016-12-28 09:18:54 -08:00
|
|
|
pub prefix: Option<PathBuf>,
|
2017-04-28 11:03:58 +02:00
|
|
|
pub sysconfdir: Option<PathBuf>,
|
2016-12-28 09:18:54 -08:00
|
|
|
pub docdir: Option<PathBuf>,
|
2017-04-28 11:01:15 +02:00
|
|
|
pub bindir: Option<PathBuf>,
|
2016-12-28 09:18:54 -08:00
|
|
|
pub libdir: Option<PathBuf>,
|
2017-01-20 09:22:16 -05:00
|
|
|
pub libdir_relative: Option<PathBuf>,
|
2016-12-28 09:18:54 -08:00
|
|
|
pub mandir: Option<PathBuf>,
|
2016-08-27 17:12:37 -05:00
|
|
|
pub codegen_tests: bool,
|
2016-09-07 13:13:37 -07:00
|
|
|
pub nodejs: Option<PathBuf>,
|
2016-10-29 20:11:53 +02:00
|
|
|
pub gdb: Option<PathBuf>,
|
2016-11-14 08:04:39 -08:00
|
|
|
pub python: Option<PathBuf>,
|
2017-02-15 15:57:06 -08:00
|
|
|
pub openssl_static: bool,
|
2017-08-26 15:01:48 -07:00
|
|
|
pub configure_args: Vec<String>,
|
2017-06-27 13:32:04 -06:00
|
|
|
|
|
|
|
// These are either the stage0 downloaded binaries or the locally installed ones.
|
|
|
|
pub initial_cargo: PathBuf,
|
|
|
|
pub initial_rustc: PathBuf,
|
2015-11-19 15:20:12 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
/// Per-target configuration stored in the global configuration structure.
|
|
|
|
#[derive(Default)]
|
|
|
|
pub struct Target {
|
2017-06-21 17:03:14 -06:00
|
|
|
/// Some(path to llvm-config) if using an external LLVM.
|
2015-11-19 15:20:12 -08:00
|
|
|
pub llvm_config: Option<PathBuf>,
|
|
|
|
pub jemalloc: Option<PathBuf>,
|
|
|
|
pub cc: Option<PathBuf>,
|
|
|
|
pub cxx: Option<PathBuf>,
|
|
|
|
pub ndk: Option<PathBuf>,
|
2017-08-22 16:24:29 -05:00
|
|
|
pub crt_static: Option<bool>,
|
2016-09-06 01:04:41 -05:00
|
|
|
pub musl_root: Option<PathBuf>,
|
2017-01-28 13:38:06 -08:00
|
|
|
pub qemu_rootfs: Option<PathBuf>,
|
2015-11-19 15:20:12 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
/// Structure of the `config.toml` file that configuration is read from.
|
|
|
|
///
|
|
|
|
/// This structure uses `Decodable` to automatically decode a TOML configuration
|
|
|
|
/// file into this format, and then this is traversed and written into the above
|
|
|
|
/// `Config` structure.
|
2017-07-04 10:03:01 -06:00
|
|
|
#[derive(Deserialize, Default)]
|
2017-07-18 16:14:44 -06:00
|
|
|
#[serde(deny_unknown_fields, rename_all = "kebab-case")]
|
2015-11-19 15:20:12 -08:00
|
|
|
struct TomlConfig {
|
|
|
|
build: Option<Build>,
|
2016-12-19 15:49:57 -07:00
|
|
|
install: Option<Install>,
|
2015-11-19 15:20:12 -08:00
|
|
|
llvm: Option<Llvm>,
|
|
|
|
rust: Option<Rust>,
|
|
|
|
target: Option<HashMap<String, TomlTarget>>,
|
2017-01-24 14:37:04 -08:00
|
|
|
dist: Option<Dist>,
|
2015-11-19 15:20:12 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
/// TOML representation of various global build decisions.
|
2017-07-04 10:03:01 -06:00
|
|
|
#[derive(Deserialize, Default, Clone)]
|
2017-07-18 16:14:44 -06:00
|
|
|
#[serde(deny_unknown_fields, rename_all = "kebab-case")]
|
2015-11-19 15:20:12 -08:00
|
|
|
struct Build {
|
|
|
|
build: Option<String>,
|
2017-07-04 10:03:01 -06:00
|
|
|
#[serde(default)]
|
2015-11-19 15:20:12 -08:00
|
|
|
host: Vec<String>,
|
2017-07-04 10:03:01 -06:00
|
|
|
#[serde(default)]
|
2015-11-19 15:20:12 -08:00
|
|
|
target: Vec<String>,
|
|
|
|
cargo: Option<String>,
|
|
|
|
rustc: Option<String>,
|
2017-03-23 22:57:29 +01:00
|
|
|
low_priority: Option<bool>,
|
2015-11-19 15:20:12 -08:00
|
|
|
compiler_docs: Option<bool>,
|
|
|
|
docs: Option<bool>,
|
2016-10-07 09:43:26 -07:00
|
|
|
submodules: Option<bool>,
|
2016-10-29 20:11:53 +02:00
|
|
|
gdb: Option<String>,
|
2017-02-10 22:59:40 +02:00
|
|
|
locked_deps: Option<bool>,
|
2016-11-01 13:46:38 -07:00
|
|
|
vendor: Option<bool>,
|
2016-11-10 16:04:53 -07:00
|
|
|
nodejs: Option<String>,
|
2016-11-14 08:04:39 -08:00
|
|
|
python: Option<String>,
|
rustbuild: Compile rustc twice, not thrice
This commit switches the rustbuild build system to compiling the
compiler twice for a normal bootstrap rather than the historical three
times.
Rust is a bootstrapped language which means that a previous version of
the compiler is used to build the next version of the compiler. Over
time, however, we change many parts of compiler artifacts such as the
metadata format, symbol names, etc. These changes make artifacts from
one compiler incompatible from another compiler. Consequently if a
compiler wants to be able to use some artifacts then it itself must have
compiled the artifacts.
Historically the rustc build system has achieved this by compiling the
compiler three times:
* An older compiler (stage0) is downloaded to kick off the chain.
* This compiler now compiles a new compiler (stage1)
* The stage1 compiler then compiles another compiler (stage2)
* Finally, the stage2 compiler needs libraries to link against, so it
compiles all the libraries again.
This entire process amounts in compiling the compiler three times.
Additionally, this process always guarantees that the Rust source tree
can compile itself because the stage2 compiler (created by a freshly
created compiler) would successfully compile itself again. This
property, ensuring Rust can compile itself, is quite important!
In general, though, this third compilation is not required for general
purpose development on the compiler. The third compiler (stage2) can
reuse the libraries that were created during the second compile. In
other words, the second compilation can produce both a compiler and the
libraries that compiler will use. These artifacts *must* be compatible
due to the way plugins work today anyway, and they were created by the
same source code so they *should* be compatible as well.
So given all that, this commit switches the default build process to
only compile the compiler three times, avoiding this third compilation
by copying artifacts from the previous one. Along the way a new entry in
the Travis matrix was also added to ensure that our full bootstrap can
succeed. This entry does not run tests, though, as it should not be
necessary.
To restore the old behavior of a full bootstrap (three compiles) you can
either pass:
./configure --enable-full-bootstrap
or if you're using config.toml:
[build]
full-bootstrap = true
Overall this will hopefully be an easy 33% win in build times of the
compiler. If we do 33% less work we should be 33% faster! This in turn
should affect cycle times and such on Travis and AppVeyor positively as
well as making it easier to work on the compiler itself.
2016-12-25 15:20:33 -08:00
|
|
|
full_bootstrap: Option<bool>,
|
2017-01-20 17:03:06 -08:00
|
|
|
extended: Option<bool>,
|
2017-02-06 18:03:26 +01:00
|
|
|
verbose: Option<usize>,
|
2017-02-03 18:58:47 -05:00
|
|
|
sanitizers: Option<bool>,
|
2017-02-13 09:57:50 +00:00
|
|
|
profiler: Option<bool>,
|
2017-02-15 15:57:06 -08:00
|
|
|
openssl_static: Option<bool>,
|
2017-08-26 15:01:48 -07:00
|
|
|
configure_args: Option<Vec<String>>,
|
|
|
|
local_rebuild: Option<bool>,
|
2015-11-19 15:20:12 -08:00
|
|
|
}
|
|
|
|
|
2016-12-19 15:49:57 -07:00
|
|
|
/// TOML representation of various global install decisions.
|
2017-07-04 10:03:01 -06:00
|
|
|
#[derive(Deserialize, Default, Clone)]
|
2017-07-18 16:14:44 -06:00
|
|
|
#[serde(deny_unknown_fields, rename_all = "kebab-case")]
|
2016-12-19 15:49:57 -07:00
|
|
|
struct Install {
|
|
|
|
prefix: Option<String>,
|
2017-04-28 11:03:58 +02:00
|
|
|
sysconfdir: Option<String>,
|
2016-12-28 09:18:54 -08:00
|
|
|
docdir: Option<String>,
|
2017-04-28 11:01:15 +02:00
|
|
|
bindir: Option<String>,
|
2016-12-28 09:18:54 -08:00
|
|
|
libdir: Option<String>,
|
2017-04-28 11:01:15 +02:00
|
|
|
mandir: Option<String>,
|
2016-12-19 15:49:57 -07:00
|
|
|
}
|
|
|
|
|
2015-11-19 15:20:12 -08:00
|
|
|
/// TOML representation of how the LLVM build is configured.
|
2017-07-04 10:03:01 -06:00
|
|
|
#[derive(Deserialize, Default)]
|
2017-07-18 16:14:44 -06:00
|
|
|
#[serde(deny_unknown_fields, rename_all = "kebab-case")]
|
2015-11-19 15:20:12 -08:00
|
|
|
struct Llvm {
|
2017-06-18 16:00:10 +02:00
|
|
|
enabled: Option<bool>,
|
2016-12-12 11:36:52 -08:00
|
|
|
ccache: Option<StringOrBool>,
|
2016-04-10 00:27:32 -04:00
|
|
|
ninja: Option<bool>,
|
2015-11-19 15:20:12 -08:00
|
|
|
assertions: Option<bool>,
|
|
|
|
optimize: Option<bool>,
|
2016-11-10 17:30:06 +01:00
|
|
|
release_debuginfo: Option<bool>,
|
2015-11-19 15:20:12 -08:00
|
|
|
version_check: Option<bool>,
|
|
|
|
static_libstdcpp: Option<bool>,
|
2016-12-29 02:23:38 +08:00
|
|
|
targets: Option<String>,
|
2017-06-16 15:43:43 -07:00
|
|
|
experimental_targets: Option<String>,
|
2017-03-05 16:11:11 +01:00
|
|
|
link_jobs: Option<u32>,
|
2017-08-26 15:01:48 -07:00
|
|
|
link_shared: Option<bool>,
|
2015-11-19 15:20:12 -08:00
|
|
|
}
|
|
|
|
|
2017-07-04 10:03:01 -06:00
|
|
|
#[derive(Deserialize, Default, Clone)]
|
2017-07-18 16:14:44 -06:00
|
|
|
#[serde(deny_unknown_fields, rename_all = "kebab-case")]
|
2017-01-24 14:37:04 -08:00
|
|
|
struct Dist {
|
|
|
|
sign_folder: Option<String>,
|
|
|
|
gpg_password_file: Option<String>,
|
|
|
|
upload_addr: Option<String>,
|
2017-02-14 09:54:58 -08:00
|
|
|
src_tarball: Option<bool>,
|
2017-01-24 14:37:04 -08:00
|
|
|
}
|
|
|
|
|
2017-07-04 10:03:01 -06:00
|
|
|
#[derive(Deserialize)]
|
|
|
|
#[serde(untagged)]
|
2016-12-12 11:36:52 -08:00
|
|
|
enum StringOrBool {
|
|
|
|
String(String),
|
|
|
|
Bool(bool),
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Default for StringOrBool {
|
|
|
|
fn default() -> StringOrBool {
|
|
|
|
StringOrBool::Bool(false)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-11-19 15:20:12 -08:00
|
|
|
/// TOML representation of how the Rust build is configured.
|
2017-07-04 10:03:01 -06:00
|
|
|
#[derive(Deserialize, Default)]
|
2017-07-18 16:14:44 -06:00
|
|
|
#[serde(deny_unknown_fields, rename_all = "kebab-case")]
|
2015-11-19 15:20:12 -08:00
|
|
|
struct Rust {
|
|
|
|
optimize: Option<bool>,
|
|
|
|
codegen_units: Option<u32>,
|
|
|
|
debug_assertions: Option<bool>,
|
|
|
|
debuginfo: Option<bool>,
|
2016-10-19 09:48:46 -07:00
|
|
|
debuginfo_lines: Option<bool>,
|
2017-01-10 20:01:54 -08:00
|
|
|
debuginfo_only_std: Option<bool>,
|
2015-11-19 15:20:12 -08:00
|
|
|
debug_jemalloc: Option<bool>,
|
|
|
|
use_jemalloc: Option<bool>,
|
2016-07-26 15:21:25 -05:00
|
|
|
backtrace: Option<bool>,
|
2015-11-19 15:20:12 -08:00
|
|
|
default_linker: Option<String>,
|
|
|
|
default_ar: Option<String>,
|
|
|
|
channel: Option<String>,
|
|
|
|
musl_root: Option<String>,
|
|
|
|
rpath: Option<bool>,
|
2016-05-13 15:26:41 -07:00
|
|
|
optimize_tests: Option<bool>,
|
|
|
|
debuginfo_tests: Option<bool>,
|
2016-09-03 01:29:12 +00:00
|
|
|
codegen_tests: Option<bool>,
|
2017-08-03 10:53:56 -06:00
|
|
|
ignore_git: Option<bool>,
|
2017-08-26 15:01:48 -07:00
|
|
|
debug: Option<bool>,
|
|
|
|
dist_src: Option<bool>,
|
|
|
|
quiet_tests: Option<bool>,
|
2015-11-19 15:20:12 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
/// TOML representation of how each build target is configured.
|
2017-07-04 10:03:01 -06:00
|
|
|
#[derive(Deserialize, Default)]
|
2017-07-18 16:14:44 -06:00
|
|
|
#[serde(deny_unknown_fields, rename_all = "kebab-case")]
|
2015-11-19 15:20:12 -08:00
|
|
|
struct TomlTarget {
|
|
|
|
llvm_config: Option<String>,
|
|
|
|
jemalloc: Option<String>,
|
|
|
|
cc: Option<String>,
|
|
|
|
cxx: Option<String>,
|
|
|
|
android_ndk: Option<String>,
|
2017-08-22 16:24:29 -05:00
|
|
|
crt_static: Option<bool>,
|
2016-10-04 20:17:53 -05:00
|
|
|
musl_root: Option<String>,
|
2017-01-28 13:38:06 -08:00
|
|
|
qemu_rootfs: Option<String>,
|
2015-11-19 15:20:12 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
impl Config {
|
2017-07-29 22:12:53 -06:00
|
|
|
pub fn parse(args: &[String]) -> Config {
|
|
|
|
let flags = Flags::parse(&args);
|
|
|
|
let file = flags.config.clone();
|
2015-11-19 15:20:12 -08:00
|
|
|
let mut config = Config::default();
|
2017-06-18 16:00:10 +02:00
|
|
|
config.llvm_enabled = true;
|
2015-11-19 15:20:12 -08:00
|
|
|
config.llvm_optimize = true;
|
|
|
|
config.use_jemalloc = true;
|
2016-07-26 15:21:25 -05:00
|
|
|
config.backtrace = true;
|
2015-11-19 15:20:12 -08:00
|
|
|
config.rust_optimize = true;
|
2016-05-13 15:26:41 -07:00
|
|
|
config.rust_optimize_tests = true;
|
2015-11-19 15:20:12 -08:00
|
|
|
config.submodules = true;
|
|
|
|
config.docs = true;
|
|
|
|
config.rust_rpath = true;
|
|
|
|
config.rust_codegen_units = 1;
|
|
|
|
config.channel = "dev".to_string();
|
2016-08-27 17:12:37 -05:00
|
|
|
config.codegen_tests = true;
|
2017-08-03 10:53:56 -06:00
|
|
|
config.ignore_git = false;
|
2017-02-14 09:54:58 -08:00
|
|
|
config.rust_dist_src = true;
|
2015-11-19 15:20:12 -08:00
|
|
|
|
2017-07-29 22:12:53 -06:00
|
|
|
config.on_fail = flags.on_fail;
|
|
|
|
config.stage = flags.stage;
|
|
|
|
config.src = flags.src;
|
|
|
|
config.jobs = flags.jobs;
|
|
|
|
config.cmd = flags.cmd;
|
|
|
|
config.incremental = flags.incremental;
|
|
|
|
config.keep_stage = flags.keep_stage;
|
|
|
|
|
2017-08-10 21:17:42 +05:00
|
|
|
// If --target was specified but --host wasn't specified, don't run any host-only tests.
|
|
|
|
config.run_host_only = flags.host.is_empty() && !flags.target.is_empty();
|
|
|
|
|
2015-11-19 15:20:12 -08:00
|
|
|
let toml = file.map(|file| {
|
|
|
|
let mut f = t!(File::open(&file));
|
2017-07-04 10:03:01 -06:00
|
|
|
let mut contents = String::new();
|
|
|
|
t!(f.read_to_string(&mut contents));
|
|
|
|
match toml::from_str(&contents) {
|
|
|
|
Ok(table) => table,
|
|
|
|
Err(err) => {
|
|
|
|
println!("failed to parse TOML configuration '{}': {}",
|
|
|
|
file.display(), err);
|
2015-11-19 15:20:12 -08:00
|
|
|
process::exit(2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}).unwrap_or_else(|| TomlConfig::default());
|
|
|
|
|
|
|
|
let build = toml.build.clone().unwrap_or(Build::default());
|
2017-07-13 18:48:44 -06:00
|
|
|
set(&mut config.build, build.build.clone().map(|x| INTERNER.intern_string(x)));
|
2017-07-29 22:45:49 -06:00
|
|
|
set(&mut config.build, flags.build);
|
|
|
|
if config.build.is_empty() {
|
|
|
|
// set by bootstrap.py
|
|
|
|
config.build = INTERNER.intern_str(&env::var("BUILD").unwrap());
|
|
|
|
}
|
2017-07-29 22:12:53 -06:00
|
|
|
config.hosts.push(config.build.clone());
|
2015-11-19 15:20:12 -08:00
|
|
|
for host in build.host.iter() {
|
2017-07-13 18:48:44 -06:00
|
|
|
let host = INTERNER.intern_str(host);
|
2017-07-29 22:12:53 -06:00
|
|
|
if !config.hosts.contains(&host) {
|
|
|
|
config.hosts.push(host);
|
2015-11-19 15:20:12 -08:00
|
|
|
}
|
|
|
|
}
|
2017-07-29 22:12:53 -06:00
|
|
|
for target in config.hosts.iter().cloned()
|
2017-07-13 18:48:44 -06:00
|
|
|
.chain(build.target.iter().map(|s| INTERNER.intern_str(s)))
|
|
|
|
{
|
2017-07-29 22:12:53 -06:00
|
|
|
if !config.targets.contains(&target) {
|
|
|
|
config.targets.push(target);
|
2015-11-19 15:20:12 -08:00
|
|
|
}
|
|
|
|
}
|
2017-07-29 22:12:53 -06:00
|
|
|
config.hosts = if !flags.host.is_empty() {
|
|
|
|
flags.host
|
|
|
|
} else {
|
|
|
|
config.hosts
|
|
|
|
};
|
|
|
|
config.targets = if !flags.target.is_empty() {
|
|
|
|
flags.target
|
|
|
|
} else {
|
|
|
|
config.targets
|
|
|
|
};
|
|
|
|
|
2017-08-10 21:17:42 +05:00
|
|
|
|
2016-11-10 16:04:53 -07:00
|
|
|
config.nodejs = build.nodejs.map(PathBuf::from);
|
2016-10-29 20:11:53 +02:00
|
|
|
config.gdb = build.gdb.map(PathBuf::from);
|
2016-11-14 08:04:39 -08:00
|
|
|
config.python = build.python.map(PathBuf::from);
|
2017-03-23 22:57:29 +01:00
|
|
|
set(&mut config.low_priority, build.low_priority);
|
2015-11-19 15:20:12 -08:00
|
|
|
set(&mut config.compiler_docs, build.compiler_docs);
|
|
|
|
set(&mut config.docs, build.docs);
|
2016-10-07 09:43:26 -07:00
|
|
|
set(&mut config.submodules, build.submodules);
|
2017-02-10 22:59:40 +02:00
|
|
|
set(&mut config.locked_deps, build.locked_deps);
|
2016-11-01 13:46:38 -07:00
|
|
|
set(&mut config.vendor, build.vendor);
|
rustbuild: Compile rustc twice, not thrice
This commit switches the rustbuild build system to compiling the
compiler twice for a normal bootstrap rather than the historical three
times.
Rust is a bootstrapped language which means that a previous version of
the compiler is used to build the next version of the compiler. Over
time, however, we change many parts of compiler artifacts such as the
metadata format, symbol names, etc. These changes make artifacts from
one compiler incompatible from another compiler. Consequently if a
compiler wants to be able to use some artifacts then it itself must have
compiled the artifacts.
Historically the rustc build system has achieved this by compiling the
compiler three times:
* An older compiler (stage0) is downloaded to kick off the chain.
* This compiler now compiles a new compiler (stage1)
* The stage1 compiler then compiles another compiler (stage2)
* Finally, the stage2 compiler needs libraries to link against, so it
compiles all the libraries again.
This entire process amounts in compiling the compiler three times.
Additionally, this process always guarantees that the Rust source tree
can compile itself because the stage2 compiler (created by a freshly
created compiler) would successfully compile itself again. This
property, ensuring Rust can compile itself, is quite important!
In general, though, this third compilation is not required for general
purpose development on the compiler. The third compiler (stage2) can
reuse the libraries that were created during the second compile. In
other words, the second compilation can produce both a compiler and the
libraries that compiler will use. These artifacts *must* be compatible
due to the way plugins work today anyway, and they were created by the
same source code so they *should* be compatible as well.
So given all that, this commit switches the default build process to
only compile the compiler three times, avoiding this third compilation
by copying artifacts from the previous one. Along the way a new entry in
the Travis matrix was also added to ensure that our full bootstrap can
succeed. This entry does not run tests, though, as it should not be
necessary.
To restore the old behavior of a full bootstrap (three compiles) you can
either pass:
./configure --enable-full-bootstrap
or if you're using config.toml:
[build]
full-bootstrap = true
Overall this will hopefully be an easy 33% win in build times of the
compiler. If we do 33% less work we should be 33% faster! This in turn
should affect cycle times and such on Travis and AppVeyor positively as
well as making it easier to work on the compiler itself.
2016-12-25 15:20:33 -08:00
|
|
|
set(&mut config.full_bootstrap, build.full_bootstrap);
|
2017-01-20 17:03:06 -08:00
|
|
|
set(&mut config.extended, build.extended);
|
2017-02-06 18:03:26 +01:00
|
|
|
set(&mut config.verbose, build.verbose);
|
2017-02-03 18:58:47 -05:00
|
|
|
set(&mut config.sanitizers, build.sanitizers);
|
2017-02-13 09:57:50 +00:00
|
|
|
set(&mut config.profiler, build.profiler);
|
2017-02-15 15:57:06 -08:00
|
|
|
set(&mut config.openssl_static, build.openssl_static);
|
2017-08-26 15:01:48 -07:00
|
|
|
set(&mut config.configure_args, build.configure_args);
|
|
|
|
set(&mut config.local_rebuild, build.local_rebuild);
|
2017-07-29 22:12:53 -06:00
|
|
|
config.verbose = cmp::max(config.verbose, flags.verbose);
|
2015-11-19 15:20:12 -08:00
|
|
|
|
2016-12-19 15:49:57 -07:00
|
|
|
if let Some(ref install) = toml.install {
|
2016-12-28 09:18:54 -08:00
|
|
|
config.prefix = install.prefix.clone().map(PathBuf::from);
|
2017-04-28 11:03:58 +02:00
|
|
|
config.sysconfdir = install.sysconfdir.clone().map(PathBuf::from);
|
2016-12-28 09:18:54 -08:00
|
|
|
config.docdir = install.docdir.clone().map(PathBuf::from);
|
2017-04-28 11:01:15 +02:00
|
|
|
config.bindir = install.bindir.clone().map(PathBuf::from);
|
2016-12-28 09:18:54 -08:00
|
|
|
config.libdir = install.libdir.clone().map(PathBuf::from);
|
2017-04-28 11:01:15 +02:00
|
|
|
config.mandir = install.mandir.clone().map(PathBuf::from);
|
2016-12-19 15:49:57 -07:00
|
|
|
}
|
|
|
|
|
2017-08-26 15:01:48 -07:00
|
|
|
// Store off these values as options because if they're not provided
|
|
|
|
// we'll infer default values for them later
|
|
|
|
let mut llvm_assertions = None;
|
|
|
|
let mut debuginfo_lines = None;
|
|
|
|
let mut debuginfo_only_std = None;
|
|
|
|
let mut debug = None;
|
|
|
|
let mut debug_jemalloc = None;
|
|
|
|
let mut debuginfo = None;
|
|
|
|
let mut debug_assertions = None;
|
|
|
|
let mut optimize = None;
|
|
|
|
|
2015-11-19 15:20:12 -08:00
|
|
|
if let Some(ref llvm) = toml.llvm {
|
2016-12-12 11:36:52 -08:00
|
|
|
match llvm.ccache {
|
|
|
|
Some(StringOrBool::String(ref s)) => {
|
|
|
|
config.ccache = Some(s.to_string())
|
|
|
|
}
|
|
|
|
Some(StringOrBool::Bool(true)) => {
|
|
|
|
config.ccache = Some("ccache".to_string());
|
|
|
|
}
|
|
|
|
Some(StringOrBool::Bool(false)) | None => {}
|
|
|
|
}
|
2016-04-10 00:27:32 -04:00
|
|
|
set(&mut config.ninja, llvm.ninja);
|
2017-06-18 16:00:10 +02:00
|
|
|
set(&mut config.llvm_enabled, llvm.enabled);
|
2017-08-26 15:01:48 -07:00
|
|
|
llvm_assertions = llvm.assertions;
|
2015-11-19 15:20:12 -08:00
|
|
|
set(&mut config.llvm_optimize, llvm.optimize);
|
2016-11-10 17:30:06 +01:00
|
|
|
set(&mut config.llvm_release_debuginfo, llvm.release_debuginfo);
|
2015-11-19 15:20:12 -08:00
|
|
|
set(&mut config.llvm_version_check, llvm.version_check);
|
|
|
|
set(&mut config.llvm_static_stdcpp, llvm.static_libstdcpp);
|
2017-08-26 15:01:48 -07:00
|
|
|
set(&mut config.llvm_link_shared, llvm.link_shared);
|
2016-12-29 02:23:38 +08:00
|
|
|
config.llvm_targets = llvm.targets.clone();
|
2017-06-16 15:43:43 -07:00
|
|
|
config.llvm_experimental_targets = llvm.experimental_targets.clone();
|
2017-03-05 16:11:11 +01:00
|
|
|
config.llvm_link_jobs = llvm.link_jobs;
|
2015-11-19 15:20:12 -08:00
|
|
|
}
|
2016-12-19 17:42:07 -07:00
|
|
|
|
2015-11-19 15:20:12 -08:00
|
|
|
if let Some(ref rust) = toml.rust {
|
2017-08-26 15:01:48 -07:00
|
|
|
debug = rust.debug;
|
|
|
|
debug_assertions = rust.debug_assertions;
|
|
|
|
debuginfo = rust.debuginfo;
|
|
|
|
debuginfo_lines = rust.debuginfo_lines;
|
|
|
|
debuginfo_only_std = rust.debuginfo_only_std;
|
|
|
|
optimize = rust.optimize;
|
|
|
|
debug_jemalloc = rust.debug_jemalloc;
|
2016-05-13 15:26:41 -07:00
|
|
|
set(&mut config.rust_optimize_tests, rust.optimize_tests);
|
|
|
|
set(&mut config.rust_debuginfo_tests, rust.debuginfo_tests);
|
2016-09-03 01:29:12 +00:00
|
|
|
set(&mut config.codegen_tests, rust.codegen_tests);
|
2015-11-19 15:20:12 -08:00
|
|
|
set(&mut config.rust_rpath, rust.rpath);
|
|
|
|
set(&mut config.use_jemalloc, rust.use_jemalloc);
|
2016-07-26 15:21:25 -05:00
|
|
|
set(&mut config.backtrace, rust.backtrace);
|
2015-11-19 15:20:12 -08:00
|
|
|
set(&mut config.channel, rust.channel.clone());
|
2017-08-03 10:53:56 -06:00
|
|
|
set(&mut config.ignore_git, rust.ignore_git);
|
2017-08-26 15:01:48 -07:00
|
|
|
set(&mut config.rust_dist_src, rust.dist_src);
|
|
|
|
set(&mut config.quiet_tests, rust.quiet_tests);
|
2015-11-19 15:20:12 -08:00
|
|
|
config.rustc_default_linker = rust.default_linker.clone();
|
|
|
|
config.rustc_default_ar = rust.default_ar.clone();
|
|
|
|
config.musl_root = rust.musl_root.clone().map(PathBuf::from);
|
|
|
|
|
|
|
|
match rust.codegen_units {
|
|
|
|
Some(0) => config.rust_codegen_units = num_cpus::get() as u32,
|
|
|
|
Some(n) => config.rust_codegen_units = n,
|
|
|
|
None => {}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if let Some(ref t) = toml.target {
|
|
|
|
for (triple, cfg) in t {
|
|
|
|
let mut target = Target::default();
|
|
|
|
|
|
|
|
if let Some(ref s) = cfg.llvm_config {
|
|
|
|
target.llvm_config = Some(env::current_dir().unwrap().join(s));
|
|
|
|
}
|
|
|
|
if let Some(ref s) = cfg.jemalloc {
|
|
|
|
target.jemalloc = Some(env::current_dir().unwrap().join(s));
|
|
|
|
}
|
|
|
|
if let Some(ref s) = cfg.android_ndk {
|
|
|
|
target.ndk = Some(env::current_dir().unwrap().join(s));
|
|
|
|
}
|
|
|
|
target.cxx = cfg.cxx.clone().map(PathBuf::from);
|
|
|
|
target.cc = cfg.cc.clone().map(PathBuf::from);
|
2017-08-22 16:24:29 -05:00
|
|
|
target.crt_static = cfg.crt_static.clone();
|
2016-10-04 20:17:53 -05:00
|
|
|
target.musl_root = cfg.musl_root.clone().map(PathBuf::from);
|
2017-01-28 13:38:06 -08:00
|
|
|
target.qemu_rootfs = cfg.qemu_rootfs.clone().map(PathBuf::from);
|
2015-11-19 15:20:12 -08:00
|
|
|
|
2017-07-13 18:48:44 -06:00
|
|
|
config.target_config.insert(INTERNER.intern_string(triple.clone()), target);
|
2015-11-19 15:20:12 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-01-24 14:37:04 -08:00
|
|
|
if let Some(ref t) = toml.dist {
|
|
|
|
config.dist_sign_folder = t.sign_folder.clone().map(PathBuf::from);
|
|
|
|
config.dist_gpg_password_file = t.gpg_password_file.clone().map(PathBuf::from);
|
|
|
|
config.dist_upload_addr = t.upload_addr.clone();
|
2017-02-14 09:54:58 -08:00
|
|
|
set(&mut config.rust_dist_src, t.src_tarball);
|
2017-01-24 14:37:04 -08:00
|
|
|
}
|
|
|
|
|
2017-06-27 13:32:04 -06:00
|
|
|
let cwd = t!(env::current_dir());
|
|
|
|
let out = cwd.join("build");
|
|
|
|
|
|
|
|
let stage0_root = out.join(&config.build).join("stage0/bin");
|
|
|
|
config.initial_rustc = match build.rustc {
|
|
|
|
Some(s) => PathBuf::from(s),
|
|
|
|
None => stage0_root.join(exe("rustc", &config.build)),
|
|
|
|
};
|
|
|
|
config.initial_cargo = match build.cargo {
|
|
|
|
Some(s) => PathBuf::from(s),
|
|
|
|
None => stage0_root.join(exe("cargo", &config.build)),
|
|
|
|
};
|
2017-06-20 18:04:36 -06:00
|
|
|
|
2017-08-26 15:01:48 -07:00
|
|
|
// Now that we've reached the end of our configuration, infer the
|
|
|
|
// default values for all options that we haven't otherwise stored yet.
|
2017-06-20 18:04:36 -06:00
|
|
|
|
2017-08-26 15:01:48 -07:00
|
|
|
let default = config.channel == "nightly";
|
|
|
|
config.llvm_assertions = llvm_assertions.unwrap_or(default);
|
2015-11-19 16:55:21 -08:00
|
|
|
|
2017-08-26 15:01:48 -07:00
|
|
|
let default = match &config.channel[..] {
|
|
|
|
"stable" | "beta" | "nightly" => true,
|
|
|
|
_ => false,
|
|
|
|
};
|
|
|
|
config.rust_debuginfo_lines = debuginfo_lines.unwrap_or(default);
|
|
|
|
config.rust_debuginfo_only_std = debuginfo_only_std.unwrap_or(default);
|
2015-11-19 16:55:21 -08:00
|
|
|
|
2017-08-26 15:01:48 -07:00
|
|
|
let default = debug == Some(true);
|
|
|
|
config.debug_jemalloc = debug_jemalloc.unwrap_or(default);
|
|
|
|
config.rust_debuginfo = debuginfo.unwrap_or(default);
|
|
|
|
config.rust_debug_assertions = debug_assertions.unwrap_or(default);
|
|
|
|
config.rust_optimize = optimize.unwrap_or(!default);
|
2017-02-12 11:27:39 -08:00
|
|
|
|
2017-08-26 15:01:48 -07:00
|
|
|
config
|
2015-11-19 16:55:21 -08:00
|
|
|
}
|
2016-11-16 18:02:56 -05:00
|
|
|
|
|
|
|
pub fn verbose(&self) -> bool {
|
|
|
|
self.verbose > 0
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn very_verbose(&self) -> bool {
|
|
|
|
self.verbose > 1
|
|
|
|
}
|
2015-11-19 15:20:12 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
fn set<T>(field: &mut T, val: Option<T>) {
|
|
|
|
if let Some(v) = val {
|
|
|
|
*field = v;
|
|
|
|
}
|
|
|
|
}
|