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.
|
|
|
|
//!
|
|
|
|
//! This module implements parsing `config.mk` and `config.toml` configuration
|
|
|
|
//! files to tweak how the build runs.
|
|
|
|
|
2015-11-19 15:20:12 -08:00
|
|
|
use std::collections::HashMap;
|
|
|
|
use std::env;
|
|
|
|
use std::fs::File;
|
|
|
|
use std::io::prelude::*;
|
|
|
|
use std::path::PathBuf;
|
|
|
|
use std::process;
|
|
|
|
|
|
|
|
use num_cpus;
|
|
|
|
use rustc_serialize::Decodable;
|
|
|
|
use toml::{Parser, Decoder, Value};
|
2017-03-15 07:35:35 -07:00
|
|
|
use util::{exe, push_exe_path};
|
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
|
|
|
|
/// `src/bootstrap/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,
|
2015-11-19 15:20:12 -08:00
|
|
|
pub target_config: HashMap<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,
|
2015-11-19 15:20:12 -08:00
|
|
|
|
|
|
|
// llvm codegen options
|
|
|
|
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-03-05 16:11:11 +01:00
|
|
|
pub llvm_link_jobs: Option<u32>,
|
2017-03-07 23:20:39 +03:00
|
|
|
pub llvm_clean_rebuild: bool,
|
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
|
|
|
|
|
|
|
pub build: String,
|
|
|
|
pub host: Vec<String>,
|
|
|
|
pub target: Vec<String>,
|
2016-05-23 13:49:37 -07:00
|
|
|
pub rustc: Option<PathBuf>,
|
|
|
|
pub cargo: Option<PathBuf>,
|
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
|
|
|
|
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>,
|
|
|
|
pub docdir: Option<PathBuf>,
|
|
|
|
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>,
|
2016-12-30 09:26:25 -08:00
|
|
|
pub configure_args: Vec<String>,
|
2017-02-15 15:57:06 -08:00
|
|
|
pub openssl_static: bool,
|
2015-11-19 15:20:12 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
/// Per-target configuration stored in the global configuration structure.
|
|
|
|
#[derive(Default)]
|
|
|
|
pub struct Target {
|
|
|
|
pub llvm_config: Option<PathBuf>,
|
|
|
|
pub jemalloc: Option<PathBuf>,
|
|
|
|
pub cc: Option<PathBuf>,
|
|
|
|
pub cxx: Option<PathBuf>,
|
|
|
|
pub ndk: Option<PathBuf>,
|
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.
|
|
|
|
#[derive(RustcDecodable, Default)]
|
|
|
|
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.
|
|
|
|
#[derive(RustcDecodable, Default, Clone)]
|
|
|
|
struct Build {
|
|
|
|
build: Option<String>,
|
|
|
|
host: Vec<String>,
|
|
|
|
target: Vec<String>,
|
|
|
|
cargo: Option<String>,
|
|
|
|
rustc: Option<String>,
|
|
|
|
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-15 15:57:06 -08:00
|
|
|
openssl_static: 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.
|
|
|
|
#[derive(RustcDecodable, Default, Clone)]
|
|
|
|
struct Install {
|
|
|
|
prefix: Option<String>,
|
2016-12-28 09:18:54 -08:00
|
|
|
mandir: Option<String>,
|
|
|
|
docdir: Option<String>,
|
|
|
|
libdir: 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.
|
|
|
|
#[derive(RustcDecodable, Default)]
|
|
|
|
struct Llvm {
|
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-03-05 16:11:11 +01:00
|
|
|
link_jobs: Option<u32>,
|
2017-03-07 23:20:39 +03:00
|
|
|
clean_rebuild: Option<bool>,
|
2015-11-19 15:20:12 -08:00
|
|
|
}
|
|
|
|
|
2017-01-24 14:37:04 -08:00
|
|
|
#[derive(RustcDecodable, Default, Clone)]
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2016-12-12 11:36:52 -08:00
|
|
|
#[derive(RustcDecodable)]
|
|
|
|
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.
|
|
|
|
#[derive(RustcDecodable, Default)]
|
|
|
|
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>,
|
2015-11-19 15:20:12 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
/// TOML representation of how each build target is configured.
|
|
|
|
#[derive(RustcDecodable, Default)]
|
|
|
|
struct TomlTarget {
|
|
|
|
llvm_config: Option<String>,
|
|
|
|
jemalloc: Option<String>,
|
|
|
|
cc: Option<String>,
|
|
|
|
cxx: Option<String>,
|
|
|
|
android_ndk: Option<String>,
|
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 {
|
|
|
|
pub fn parse(build: &str, file: Option<PathBuf>) -> Config {
|
|
|
|
let mut config = Config::default();
|
|
|
|
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.build = build.to_string();
|
|
|
|
config.channel = "dev".to_string();
|
2016-08-27 17:12:37 -05:00
|
|
|
config.codegen_tests = true;
|
2017-02-14 09:54:58 -08:00
|
|
|
config.rust_dist_src = true;
|
2015-11-19 15:20:12 -08:00
|
|
|
|
|
|
|
let toml = file.map(|file| {
|
|
|
|
let mut f = t!(File::open(&file));
|
|
|
|
let mut toml = String::new();
|
|
|
|
t!(f.read_to_string(&mut toml));
|
|
|
|
let mut p = Parser::new(&toml);
|
|
|
|
let table = match p.parse() {
|
|
|
|
Some(table) => table,
|
|
|
|
None => {
|
|
|
|
println!("failed to parse TOML configuration:");
|
|
|
|
for err in p.errors.iter() {
|
|
|
|
let (loline, locol) = p.to_linecol(err.lo);
|
|
|
|
let (hiline, hicol) = p.to_linecol(err.hi);
|
|
|
|
println!("{}:{}-{}:{}: {}", loline, locol, hiline,
|
|
|
|
hicol, err.desc);
|
|
|
|
}
|
|
|
|
process::exit(2);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
let mut d = Decoder::new(Value::Table(table));
|
|
|
|
match Decodable::decode(&mut d) {
|
|
|
|
Ok(cfg) => cfg,
|
|
|
|
Err(e) => {
|
|
|
|
println!("failed to decode TOML: {}", e);
|
|
|
|
process::exit(2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}).unwrap_or_else(|| TomlConfig::default());
|
|
|
|
|
|
|
|
let build = toml.build.clone().unwrap_or(Build::default());
|
|
|
|
set(&mut config.build, build.build.clone());
|
|
|
|
config.host.push(config.build.clone());
|
|
|
|
for host in build.host.iter() {
|
|
|
|
if !config.host.contains(host) {
|
|
|
|
config.host.push(host.clone());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for target in config.host.iter().chain(&build.target) {
|
|
|
|
if !config.target.contains(target) {
|
|
|
|
config.target.push(target.clone());
|
|
|
|
}
|
|
|
|
}
|
2016-05-23 13:49:37 -07:00
|
|
|
config.rustc = build.rustc.map(PathBuf::from);
|
|
|
|
config.cargo = build.cargo.map(PathBuf::from);
|
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);
|
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-15 15:57:06 -08:00
|
|
|
set(&mut config.openssl_static, build.openssl_static);
|
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);
|
|
|
|
config.mandir = install.mandir.clone().map(PathBuf::from);
|
|
|
|
config.docdir = install.docdir.clone().map(PathBuf::from);
|
|
|
|
config.libdir = install.libdir.clone().map(PathBuf::from);
|
2016-12-19 15:49:57 -07:00
|
|
|
}
|
|
|
|
|
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);
|
2015-11-19 15:20:12 -08:00
|
|
|
set(&mut config.llvm_assertions, llvm.assertions);
|
|
|
|
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-03-07 23:20:39 +03:00
|
|
|
set(&mut config.llvm_clean_rebuild, llvm.clean_rebuild);
|
2016-12-29 02:23:38 +08:00
|
|
|
config.llvm_targets = llvm.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 {
|
|
|
|
set(&mut config.rust_debug_assertions, rust.debug_assertions);
|
|
|
|
set(&mut config.rust_debuginfo, rust.debuginfo);
|
2016-10-19 09:48:46 -07:00
|
|
|
set(&mut config.rust_debuginfo_lines, rust.debuginfo_lines);
|
2017-01-10 20:01:54 -08:00
|
|
|
set(&mut config.rust_debuginfo_only_std, rust.debuginfo_only_std);
|
2015-11-19 15:20:12 -08:00
|
|
|
set(&mut config.rust_optimize, rust.optimize);
|
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.debug_jemalloc, rust.debug_jemalloc);
|
|
|
|
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());
|
|
|
|
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);
|
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
|
|
|
|
|
|
|
config.target_config.insert(triple.clone(), target);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2015-11-19 15:20:12 -08:00
|
|
|
return config
|
|
|
|
}
|
2015-11-19 16:55:21 -08:00
|
|
|
|
2016-05-02 15:16:15 -07:00
|
|
|
/// "Temporary" routine to parse `config.mk` into this configuration.
|
|
|
|
///
|
|
|
|
/// While we still have `./configure` this implements the ability to decode
|
|
|
|
/// that configuration into this. This isn't exactly a full-blown makefile
|
|
|
|
/// parser, but hey it gets the job done!
|
2015-11-19 16:55:21 -08:00
|
|
|
pub fn update_with_config_mk(&mut self) {
|
|
|
|
let mut config = String::new();
|
|
|
|
File::open("config.mk").unwrap().read_to_string(&mut config).unwrap();
|
|
|
|
for line in config.lines() {
|
|
|
|
let mut parts = line.splitn(2, ":=").map(|s| s.trim());
|
|
|
|
let key = parts.next().unwrap();
|
|
|
|
let value = match parts.next() {
|
|
|
|
Some(n) if n.starts_with('\"') => &n[1..n.len() - 1],
|
|
|
|
Some(n) => n,
|
|
|
|
None => continue
|
|
|
|
};
|
|
|
|
|
|
|
|
macro_rules! check {
|
|
|
|
($(($name:expr, $val:expr),)*) => {
|
|
|
|
if value == "1" {
|
|
|
|
$(
|
|
|
|
if key == concat!("CFG_ENABLE_", $name) {
|
|
|
|
$val = true;
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
if key == concat!("CFG_DISABLE_", $name) {
|
|
|
|
$val = false;
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
)*
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
check! {
|
|
|
|
("MANAGE_SUBMODULES", self.submodules),
|
|
|
|
("COMPILER_DOCS", self.compiler_docs),
|
|
|
|
("DOCS", self.docs),
|
|
|
|
("LLVM_ASSERTIONS", self.llvm_assertions),
|
2016-11-13 12:38:10 -06:00
|
|
|
("LLVM_RELEASE_DEBUGINFO", self.llvm_release_debuginfo),
|
2015-11-19 16:55:21 -08:00
|
|
|
("OPTIMIZE_LLVM", self.llvm_optimize),
|
|
|
|
("LLVM_VERSION_CHECK", self.llvm_version_check),
|
|
|
|
("LLVM_STATIC_STDCPP", self.llvm_static_stdcpp),
|
2016-11-16 23:28:14 -08:00
|
|
|
("LLVM_LINK_SHARED", self.llvm_link_shared),
|
2017-03-08 16:22:08 +03:00
|
|
|
("LLVM_CLEAN_REBUILD", self.llvm_clean_rebuild),
|
2015-11-19 16:55:21 -08:00
|
|
|
("OPTIMIZE", self.rust_optimize),
|
|
|
|
("DEBUG_ASSERTIONS", self.rust_debug_assertions),
|
|
|
|
("DEBUGINFO", self.rust_debuginfo),
|
2016-10-19 09:48:46 -07:00
|
|
|
("DEBUGINFO_LINES", self.rust_debuginfo_lines),
|
2017-01-10 20:01:54 -08:00
|
|
|
("DEBUGINFO_ONLY_STD", self.rust_debuginfo_only_std),
|
2015-11-19 16:55:21 -08:00
|
|
|
("JEMALLOC", self.use_jemalloc),
|
|
|
|
("DEBUG_JEMALLOC", self.debug_jemalloc),
|
|
|
|
("RPATH", self.rust_rpath),
|
2016-05-13 15:26:41 -07:00
|
|
|
("OPTIMIZE_TESTS", self.rust_optimize_tests),
|
|
|
|
("DEBUGINFO_TESTS", self.rust_debuginfo_tests),
|
2016-10-29 21:58:52 -04:00
|
|
|
("QUIET_TESTS", self.quiet_tests),
|
2016-05-23 09:49:46 -07:00
|
|
|
("LOCAL_REBUILD", self.local_rebuild),
|
2016-07-01 19:47:30 -04:00
|
|
|
("NINJA", self.ninja),
|
2016-08-27 17:12:37 -05:00
|
|
|
("CODEGEN_TESTS", self.codegen_tests),
|
2017-02-10 22:59:40 +02:00
|
|
|
("LOCKED_DEPS", self.locked_deps),
|
2016-11-01 13:46:38 -07:00
|
|
|
("VENDOR", self.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
|
|
|
("FULL_BOOTSTRAP", self.full_bootstrap),
|
2017-01-20 17:03:06 -08:00
|
|
|
("EXTENDED", self.extended),
|
2017-02-03 18:58:47 -05:00
|
|
|
("SANITIZERS", self.sanitizers),
|
2017-02-14 09:54:58 -08:00
|
|
|
("DIST_SRC", self.rust_dist_src),
|
2017-02-15 15:57:06 -08:00
|
|
|
("CARGO_OPENSSL_STATIC", self.openssl_static),
|
2015-11-19 16:55:21 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
match key {
|
2017-02-12 11:27:39 -08:00
|
|
|
"CFG_BUILD" if value.len() > 0 => self.build = value.to_string(),
|
|
|
|
"CFG_HOST" if value.len() > 0 => {
|
|
|
|
self.host.extend(value.split(" ").map(|s| s.to_string()));
|
|
|
|
|
2015-11-19 16:55:21 -08:00
|
|
|
}
|
2017-02-12 11:27:39 -08:00
|
|
|
"CFG_TARGET" if value.len() > 0 => {
|
|
|
|
self.target.extend(value.split(" ").map(|s| s.to_string()));
|
2015-11-19 16:55:21 -08:00
|
|
|
}
|
|
|
|
"CFG_MUSL_ROOT" if value.len() > 0 => {
|
2016-10-31 21:06:27 +01:00
|
|
|
self.musl_root = Some(parse_configure_path(value));
|
2015-11-19 16:55:21 -08:00
|
|
|
}
|
2016-10-05 11:00:55 -07:00
|
|
|
"CFG_MUSL_ROOT_X86_64" if value.len() > 0 => {
|
|
|
|
let target = "x86_64-unknown-linux-musl".to_string();
|
|
|
|
let target = self.target_config.entry(target)
|
|
|
|
.or_insert(Target::default());
|
2016-10-31 21:06:27 +01:00
|
|
|
target.musl_root = Some(parse_configure_path(value));
|
2016-10-05 11:00:55 -07:00
|
|
|
}
|
|
|
|
"CFG_MUSL_ROOT_I686" if value.len() > 0 => {
|
|
|
|
let target = "i686-unknown-linux-musl".to_string();
|
|
|
|
let target = self.target_config.entry(target)
|
|
|
|
.or_insert(Target::default());
|
2016-10-31 21:06:27 +01:00
|
|
|
target.musl_root = Some(parse_configure_path(value));
|
2016-10-05 11:00:55 -07:00
|
|
|
}
|
|
|
|
"CFG_MUSL_ROOT_ARM" if value.len() > 0 => {
|
|
|
|
let target = "arm-unknown-linux-musleabi".to_string();
|
|
|
|
let target = self.target_config.entry(target)
|
|
|
|
.or_insert(Target::default());
|
2016-10-31 21:06:27 +01:00
|
|
|
target.musl_root = Some(parse_configure_path(value));
|
2016-10-05 11:00:55 -07:00
|
|
|
}
|
|
|
|
"CFG_MUSL_ROOT_ARMHF" if value.len() > 0 => {
|
|
|
|
let target = "arm-unknown-linux-musleabihf".to_string();
|
|
|
|
let target = self.target_config.entry(target)
|
|
|
|
.or_insert(Target::default());
|
2016-10-31 21:06:27 +01:00
|
|
|
target.musl_root = Some(parse_configure_path(value));
|
2016-10-05 11:00:55 -07:00
|
|
|
}
|
|
|
|
"CFG_MUSL_ROOT_ARMV7" if value.len() > 0 => {
|
|
|
|
let target = "armv7-unknown-linux-musleabihf".to_string();
|
|
|
|
let target = self.target_config.entry(target)
|
|
|
|
.or_insert(Target::default());
|
2016-10-31 21:06:27 +01:00
|
|
|
target.musl_root = Some(parse_configure_path(value));
|
2016-10-05 11:00:55 -07:00
|
|
|
}
|
2015-11-19 16:55:21 -08:00
|
|
|
"CFG_DEFAULT_AR" if value.len() > 0 => {
|
|
|
|
self.rustc_default_ar = Some(value.to_string());
|
|
|
|
}
|
|
|
|
"CFG_DEFAULT_LINKER" if value.len() > 0 => {
|
|
|
|
self.rustc_default_linker = Some(value.to_string());
|
|
|
|
}
|
2016-10-29 20:11:53 +02:00
|
|
|
"CFG_GDB" if value.len() > 0 => {
|
2016-10-31 21:06:27 +01:00
|
|
|
self.gdb = Some(parse_configure_path(value));
|
2016-10-29 20:11:53 +02:00
|
|
|
}
|
2015-11-19 16:55:21 -08:00
|
|
|
"CFG_RELEASE_CHANNEL" => {
|
|
|
|
self.channel = value.to_string();
|
|
|
|
}
|
|
|
|
"CFG_PREFIX" => {
|
2016-12-28 09:18:54 -08:00
|
|
|
self.prefix = Some(PathBuf::from(value));
|
2015-11-19 16:55:21 -08:00
|
|
|
}
|
2016-10-05 22:42:19 -07:00
|
|
|
"CFG_DOCDIR" => {
|
2016-12-28 09:18:54 -08:00
|
|
|
self.docdir = Some(PathBuf::from(value));
|
2016-10-05 22:42:19 -07:00
|
|
|
}
|
|
|
|
"CFG_LIBDIR" => {
|
2016-12-28 09:18:54 -08:00
|
|
|
self.libdir = Some(PathBuf::from(value));
|
2016-10-05 22:42:19 -07:00
|
|
|
}
|
2017-01-20 09:22:16 -05:00
|
|
|
"CFG_LIBDIR_RELATIVE" => {
|
|
|
|
self.libdir_relative = Some(PathBuf::from(value));
|
|
|
|
}
|
2016-10-05 22:42:19 -07:00
|
|
|
"CFG_MANDIR" => {
|
2016-12-28 09:18:54 -08:00
|
|
|
self.mandir = Some(PathBuf::from(value));
|
2016-10-05 22:42:19 -07:00
|
|
|
}
|
2015-11-19 16:55:21 -08:00
|
|
|
"CFG_LLVM_ROOT" if value.len() > 0 => {
|
|
|
|
let target = self.target_config.entry(self.build.clone())
|
|
|
|
.or_insert(Target::default());
|
2016-10-31 21:06:27 +01:00
|
|
|
let root = parse_configure_path(value);
|
2016-10-31 21:00:32 +01:00
|
|
|
target.llvm_config = Some(push_exe_path(root, &["bin", "llvm-config"]));
|
2015-11-19 16:55:21 -08:00
|
|
|
}
|
|
|
|
"CFG_JEMALLOC_ROOT" if value.len() > 0 => {
|
|
|
|
let target = self.target_config.entry(self.build.clone())
|
|
|
|
.or_insert(Target::default());
|
2017-01-29 20:35:11 +09:00
|
|
|
target.jemalloc = Some(parse_configure_path(value).join("libjemalloc_pic.a"));
|
2015-11-19 16:55:21 -08:00
|
|
|
}
|
|
|
|
"CFG_ARM_LINUX_ANDROIDEABI_NDK" if value.len() > 0 => {
|
|
|
|
let target = "arm-linux-androideabi".to_string();
|
|
|
|
let target = self.target_config.entry(target)
|
2016-05-05 01:08:14 +03:00
|
|
|
.or_insert(Target::default());
|
2016-10-31 21:06:27 +01:00
|
|
|
target.ndk = Some(parse_configure_path(value));
|
2016-05-05 01:08:14 +03:00
|
|
|
}
|
|
|
|
"CFG_ARMV7_LINUX_ANDROIDEABI_NDK" if value.len() > 0 => {
|
|
|
|
let target = "armv7-linux-androideabi".to_string();
|
|
|
|
let target = self.target_config.entry(target)
|
2015-11-19 16:55:21 -08:00
|
|
|
.or_insert(Target::default());
|
2016-10-31 21:06:27 +01:00
|
|
|
target.ndk = Some(parse_configure_path(value));
|
2015-11-19 16:55:21 -08:00
|
|
|
}
|
|
|
|
"CFG_I686_LINUX_ANDROID_NDK" if value.len() > 0 => {
|
2016-06-28 13:31:30 -07:00
|
|
|
let target = "i686-linux-android".to_string();
|
2015-11-19 16:55:21 -08:00
|
|
|
let target = self.target_config.entry(target)
|
|
|
|
.or_insert(Target::default());
|
2016-10-31 21:06:27 +01:00
|
|
|
target.ndk = Some(parse_configure_path(value));
|
2015-11-19 16:55:21 -08:00
|
|
|
}
|
|
|
|
"CFG_AARCH64_LINUX_ANDROID_NDK" if value.len() > 0 => {
|
2016-06-28 13:31:30 -07:00
|
|
|
let target = "aarch64-linux-android".to_string();
|
2015-11-19 16:55:21 -08:00
|
|
|
let target = self.target_config.entry(target)
|
|
|
|
.or_insert(Target::default());
|
2016-10-31 21:06:27 +01:00
|
|
|
target.ndk = Some(parse_configure_path(value));
|
2015-11-19 16:55:21 -08:00
|
|
|
}
|
2017-04-20 14:02:42 -03:00
|
|
|
"CFG_X86_64_LINUX_ANDROID_NDK" if value.len() > 0 => {
|
|
|
|
let target = "x86_64-linux-android".to_string();
|
|
|
|
let target = self.target_config.entry(target)
|
|
|
|
.or_insert(Target::default());
|
|
|
|
target.ndk = Some(parse_configure_path(value));
|
|
|
|
}
|
2016-05-23 13:49:37 -07:00
|
|
|
"CFG_LOCAL_RUST_ROOT" if value.len() > 0 => {
|
2016-10-31 21:06:27 +01:00
|
|
|
let path = parse_configure_path(value);
|
2016-10-31 21:00:32 +01:00
|
|
|
self.rustc = Some(push_exe_path(path.clone(), &["bin", "rustc"]));
|
|
|
|
self.cargo = Some(push_exe_path(path, &["bin", "cargo"]));
|
2016-05-23 13:49:37 -07:00
|
|
|
}
|
2016-11-14 08:04:39 -08:00
|
|
|
"CFG_PYTHON" if value.len() > 0 => {
|
|
|
|
let path = parse_configure_path(value);
|
|
|
|
self.python = Some(path);
|
|
|
|
}
|
2016-12-12 11:36:52 -08:00
|
|
|
"CFG_ENABLE_CCACHE" if value == "1" => {
|
2017-03-15 07:35:35 -07:00
|
|
|
self.ccache = Some(exe("ccache", &self.build));
|
2016-12-12 11:36:52 -08:00
|
|
|
}
|
|
|
|
"CFG_ENABLE_SCCACHE" if value == "1" => {
|
2017-03-15 07:35:35 -07:00
|
|
|
self.ccache = Some(exe("sccache", &self.build));
|
2016-12-12 11:36:52 -08:00
|
|
|
}
|
2016-12-30 09:26:25 -08:00
|
|
|
"CFG_CONFIGURE_ARGS" if value.len() > 0 => {
|
|
|
|
self.configure_args = value.split_whitespace()
|
|
|
|
.map(|s| s.to_string())
|
|
|
|
.collect();
|
|
|
|
}
|
2017-01-28 13:38:06 -08:00
|
|
|
"CFG_QEMU_ARMHF_ROOTFS" if value.len() > 0 => {
|
|
|
|
let target = "arm-unknown-linux-gnueabihf".to_string();
|
|
|
|
let target = self.target_config.entry(target)
|
|
|
|
.or_insert(Target::default());
|
|
|
|
target.qemu_rootfs = Some(parse_configure_path(value));
|
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
2016-11-04 17:44:53 -07:00
|
|
|
#[cfg(not(windows))]
|
|
|
|
fn parse_configure_path(path: &str) -> PathBuf {
|
|
|
|
path.into()
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg(windows)]
|
|
|
|
fn parse_configure_path(path: &str) -> PathBuf {
|
|
|
|
// on windows, configure produces unix style paths e.g. /c/some/path but we
|
|
|
|
// only want real windows paths
|
|
|
|
|
|
|
|
use std::process::Command;
|
|
|
|
use build_helper;
|
|
|
|
|
|
|
|
// '/' is invalid in windows paths, so we can detect unix paths by the presence of it
|
|
|
|
if !path.contains('/') {
|
|
|
|
return path.into();
|
|
|
|
}
|
|
|
|
|
|
|
|
let win_path = build_helper::output(Command::new("cygpath").arg("-w").arg(path));
|
|
|
|
let win_path = win_path.trim();
|
|
|
|
|
|
|
|
win_path.into()
|
|
|
|
}
|
|
|
|
|
2015-11-19 15:20:12 -08:00
|
|
|
fn set<T>(field: &mut T, val: Option<T>) {
|
|
|
|
if let Some(v) = val {
|
|
|
|
*field = v;
|
|
|
|
}
|
|
|
|
}
|