Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 19 pull requests #47748

Merged
merged 99 commits into from
Jan 26, 2018
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
99 commits
Select commit Hold shift + click to select a range
3f61742
Fix no_integrated_as option to work with new codegen architecture.
pftbest Jan 15, 2018
98dee04
Add run-make test for no_integrated_as flag.
pftbest Jan 16, 2018
9b95e91
rustc_trans: ignore trailing padding larger than 8 bytes.
eddyb Jan 14, 2018
cbeebc5
rustc_trans: take into account primitives larger than 8 bytes.
eddyb Jan 14, 2018
072c3da
track recursion limit when expanding existential impl trait
nikomatsakis Jan 17, 2018
8447f4f
Add CGU size heuristic for partitioning
varkor Jan 13, 2018
e60b0f8
Refactor CodegenUnit size estimates
varkor Jan 15, 2018
c8e9da4
Update comments about the partitioning inefficiency
varkor Jan 15, 2018
5c9a8b5
Add instance_def_size_estimate query
varkor Jan 19, 2018
62703cf
Estimate size of InstanceDef::DropGlue more accurately
varkor Jan 19, 2018
768cbbc
Fix type inhabitedness check for arrays
varkor Jan 19, 2018
c4d0bb3
Fix tidy error
varkor Jan 19, 2018
7188706
Teach rustc about DW_AT_noreturn and a few more DIFlags
mrhota Jan 20, 2018
51fe2fe
rustc_trans: remove an unwrap by replacing a bool with Result.
eddyb Jan 20, 2018
f7f6598
Simplify and fix test
mrhota Jan 21, 2018
e0f9b26
Ensure test doesn't run with llvm 3.9
mrhota Jan 21, 2018
0bbc422
Use std based dedup in projection
ishitatsuyuki Jan 22, 2018
2d56abf
AST/HIR: Add a separate structure for labels
petrochenkov Jan 15, 2018
215d66b
do not ICE when return type includes unconstrained anon region
nikomatsakis Jan 22, 2018
9adf2b2
Add `--explain` for extended error explanations
estebank Jan 22, 2018
4e68e2a
Mark `--explain` as unstable
estebank Jan 22, 2018
fdfb9a2
Add explanation for E0607
estebank Jan 22, 2018
e76d3f6
Fix test for variadic error change
estebank Jan 22, 2018
864f6d1
Only emit expanded diagnostic information once
estebank Jan 22, 2018
ffb827a
Fix test redux
estebank Jan 22, 2018
c6772b4
Implement Ord as necessary
ishitatsuyuki Jan 22, 2018
7d41cba
Don't make it necessary to enable `unstable-options`
estebank Jan 23, 2018
2e81ce7
rustdoc: Hide methods from #[doc(masked)] crates from the search index
ollie27 Jan 23, 2018
a084cd0
incr.comp.: Cache type_of and some other queries.
michaelwoerister Jan 15, 2018
a5d7aae
Make ty::Generics::type_param_to_index use DefId instead of DefIndex …
michaelwoerister Jan 17, 2018
0a4f347
incr.comp.: Cache generics_of query.
michaelwoerister Jan 17, 2018
3dac0f5
Create `StructuredDiagnostic`
estebank Jan 23, 2018
482f7f1
Rename `-Z explain` to `-Z teach`
estebank Jan 23, 2018
7eb7d45
Let LLVM 5 add DW_OP_deref to indirect args itself
cuviper Jan 23, 2018
8bde2ac
rustc: Add `-C lto=val` option
alexcrichton Jan 16, 2018
734ee0f
Rename check.rs to test.rs
Mark-Simulacrum Jan 15, 2018
6aeb1cf
Add ./x.py check src/{libstd,libtest,rustc}.
Mark-Simulacrum Jan 15, 2018
f7ba00c
Turn error into warning
Manishearth Jan 24, 2018
6b26b74
Return Err() if resolve() is called before modules are set up
Manishearth Jan 24, 2018
f0e7677
Return Def from resolve()
Manishearth Jan 24, 2018
5a89f40
Handle methods
Manishearth Jan 24, 2018
62afc43
Make use of the implemented red/green algorithm for variance
Zoxc Jan 24, 2018
a4d3692
Make it work for traits
Manishearth Jan 24, 2018
5faba28
Fix ICE when use trees have multiple empty nested groups
pietroalbini Jan 24, 2018
03f86ae
llvm6: CodeModel::{JIT,}Default no longer exists
alexcrichton Jan 23, 2018
2a7ed74
llvm6: Missing include for LLVM 6 in PassWrapper.cpp
alexcrichton Jan 23, 2018
9eeecd2
llvm6: Tweak fast math intrinsics
alexcrichton Jan 23, 2018
b6fe112
llvm6: Remove MIPS64 archive variant
alexcrichton Jan 23, 2018
caedb36
llvm6: Different return value for writeArchive
alexcrichton Jan 23, 2018
63b3168
llvm6: Don't clone LLVM modules on wasm
alexcrichton Jan 24, 2018
5c5d9dd
Add powerpc to run-pass/conditional-compile-arch.rs
malbarbo Jan 24, 2018
e9a6499
llvm6: Update FreeBSD images to Ubuntu 18.04
alexcrichton Jan 23, 2018
54462f5
Update compiler-builtins submodule
alexcrichton Jan 24, 2018
c26f887
Handle variants
Manishearth Jan 24, 2018
08ca4fd
Add tests
Manishearth Jan 25, 2018
77bc826
Fix rustdoc-js test
ollie27 Jan 25, 2018
3b24033
Rollup merge of #47415 - varkor:cgu-partition-heuristic, r=michaelwoe…
alexcrichton Jan 25, 2018
fe2fb24
Rollup merge of #47437 - eddyb:issue-38763, r=nagisa
alexcrichton Jan 25, 2018
6eb1430
Rollup merge of #47439 - eddyb:issue-45662, r=nagisa
alexcrichton Jan 25, 2018
1bdef2f
Rollup merge of #47453 - pftbest:nointas, r=alexcrichton
alexcrichton Jan 25, 2018
304885d
Rollup merge of #47460 - Mark-Simulacrum:bootstrap-check, r=alexcrichton
alexcrichton Jan 25, 2018
98b3754
Rollup merge of #47502 - petrochenkov:label, r=eddyb
alexcrichton Jan 25, 2018
31f1aa5
Rollup merge of #47529 - nikomatsakis:impl-trait-issue-38064, r=cramertj
alexcrichton Jan 25, 2018
9852b23
Rollup merge of #47600 - varkor:empty-never-array, r=eddyb
alexcrichton Jan 25, 2018
6006b67
Fix regression: account for impl methods in arg count mismatch error
estebank Jan 25, 2018
2b73733
Add description to field and method
estebank Jan 25, 2018
502de01
rustc: SIMD types use pointers in Rust's ABI
alexcrichton Jan 25, 2018
c199cb5
Make 3 run-pass tests works on android (aarch64 and x86)
malbarbo Jan 25, 2018
4856f07
Rollup merge of #47618 - mrhota:dw_at_noreturn, r=michaelwoerister
alexcrichton Jan 25, 2018
8dd36af
Rollup merge of #47626 - eddyb:one-less-unwrap, r=nagisa
alexcrichton Jan 25, 2018
014931b
Rollup merge of #47656 - ishitatsuyuki:patch-1, r=nikomatsakis
alexcrichton Jan 25, 2018
0ee698e
Rollup merge of #47668 - nikomatsakis:issue-47511, r=eddyb
alexcrichton Jan 25, 2018
024e3aa
Rollup merge of #47696 - Zoxc:variance-rg, r=nikomatsakis
alexcrichton Jan 25, 2018
b335b10
Rollup merge of #47701 - Manishearth:intra-fixes, r=QuietMisdreavus
alexcrichton Jan 25, 2018
f7706d5
Rollup merge of #47705 - pietroalbini:fix-47673, r=petrochenkov
alexcrichton Jan 25, 2018
8a9381d
Rollup merge of #47710 - alexcrichton:llvm-6-compat, r=nikomatsakis
alexcrichton Jan 25, 2018
2c7cd60
Rollup merge of #47711 - alexcrichton:update-compiler-builtins, r=nik…
alexcrichton Jan 25, 2018
ad8b313
Rollup merge of #47719 - malbarbo:run-pass-arch-powerpc, r=alexcrichton
alexcrichton Jan 25, 2018
ab623f2
Merge branch 'cache-ty-collect' of https://github.com/michaelwoeriste…
alexcrichton Jan 25, 2018
e61c609
Merge branch 'configure-lto' of https://github.com/alexcrichton/rust …
alexcrichton Jan 25, 2018
cd4b23e
Remove stray src/llvm-emscripten module
alexcrichton Jan 25, 2018
beb756f
Revert update of the i686-freebsd builder
alexcrichton Jan 25, 2018
a76bb88
Call non-git beta builds simply x.y.z-beta
cuviper Jan 26, 2018
6e1cebb
Shorten a filename for MSVC
alexcrichton Jan 26, 2018
9a8d6b8
Do not capture stderr in the compiler. Instead just panic silently fo…
Zoxc Jan 21, 2018
68f2e1e
Ignore an i128 test on emscripten
alexcrichton Jan 26, 2018
aca88e1
Upgrade LLVM to incorporate a fix for #47364
dotdash Jan 26, 2018
ac774e7
Shorten another test path for MSVC
alexcrichton Jan 26, 2018
9594215
Merge branch 'no-stderr-sink' of https://github.com/Zoxc/rust into ro…
alexcrichton Jan 26, 2018
6da912e
Merge branch 'explain' of https://github.com/estebank/rust into rollup
alexcrichton Jan 26, 2018
a7f4156
Merge branch 'llvm5-indirect-deref' of https://github.com/cuviper/rus…
alexcrichton Jan 26, 2018
a910109
Merge branch 'simd-always-mem' of https://github.com/alexcrichton/rus…
alexcrichton Jan 26, 2018
1dc8576
Merge branch 'rustdoc_masked' of https://github.com/ollie27/rust into…
alexcrichton Jan 26, 2018
e684525
Merge branch 'fix-regression' of https://github.com/estebank/rust int…
alexcrichton Jan 26, 2018
afc977f
Merge branch 'android-run-pass' of https://github.com/malbarbo/rust i…
alexcrichton Jan 26, 2018
b741d7d
Merge branch 'beta-prerelease' of https://github.com/cuviper/rust int…
alexcrichton Jan 26, 2018
c915e3a
Merge branch 'mlsm' of https://github.com/dotdash/rust into rollup
alexcrichton Jan 26, 2018
9bb1823
Fix a test case on Windows
alexcrichton Jan 26, 2018
a06d333
Ignore a test on emscripten
alexcrichton Jan 26, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 45 additions & 11 deletions src/librustc/session/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,26 @@ pub enum OptLevel {
SizeMin, // -Oz
}

#[derive(Clone, Copy, PartialEq, Hash)]
pub enum Lto {
/// Don't do any LTO whatsoever
No,

/// Do a full crate graph LTO. The flavor is determined by the compiler
/// (currently the default is "fat").
Yes,

/// Do a full crate graph LTO with ThinLTO
Thin,

/// Do a local graph LTO with ThinLTO (only relevant for multiple codegen
/// units).
ThinLocal,

/// Do a full crate graph LTO with "fat" LTO
Fat,
}

#[derive(Clone, Copy, PartialEq, Hash)]
pub enum DebugInfoLevel {
NoDebugInfo,
Expand Down Expand Up @@ -389,7 +409,7 @@ top_level_options!(
// commands like `--emit llvm-ir` which they're often incompatible with
// if we otherwise use the defaults of rustc.
cli_forced_codegen_units: Option<usize> [UNTRACKED],
cli_forced_thinlto: Option<bool> [UNTRACKED],
cli_forced_thinlto_off: bool [UNTRACKED],
}
);

Expand Down Expand Up @@ -590,7 +610,7 @@ pub fn basic_options() -> Options {
debug_assertions: true,
actually_rustdoc: false,
cli_forced_codegen_units: None,
cli_forced_thinlto: None,
cli_forced_thinlto_off: false,
}
}

Expand Down Expand Up @@ -780,11 +800,13 @@ macro_rules! options {
Some("crate=integer");
pub const parse_unpretty: Option<&'static str> =
Some("`string` or `string=string`");
pub const parse_lto: Option<&'static str> =
Some("one of `thin`, `fat`, or omitted");
}

#[allow(dead_code)]
mod $mod_set {
use super::{$struct_name, Passes, SomePasses, AllPasses, Sanitizer};
use super::{$struct_name, Passes, SomePasses, AllPasses, Sanitizer, Lto};
use rustc_back::{LinkerFlavor, PanicStrategy, RelroLevel};
use std::path::PathBuf;

Expand Down Expand Up @@ -978,6 +1000,16 @@ macro_rules! options {
_ => false,
}
}

fn parse_lto(slot: &mut Lto, v: Option<&str>) -> bool {
*slot = match v {
None => Lto::Yes,
Some("thin") => Lto::Thin,
Some("fat") => Lto::Fat,
Some(_) => return false,
};
true
}
}
) }

Expand All @@ -994,7 +1026,7 @@ options! {CodegenOptions, CodegenSetter, basic_codegen_options,
"extra arguments to append to the linker invocation (space separated)"),
link_dead_code: bool = (false, parse_bool, [UNTRACKED],
"don't let linker strip dead code (turning it on can be used for code coverage)"),
lto: bool = (false, parse_bool, [TRACKED],
lto: Lto = (Lto::No, parse_lto, [TRACKED],
"perform LLVM link-time optimizations"),
target_cpu: Option<String> = (None, parse_opt_string, [TRACKED],
"select target processor (rustc --print target-cpus for details)"),
Expand Down Expand Up @@ -1677,7 +1709,7 @@ pub fn build_session_options_and_crate_config(matches: &getopts::Matches)

let mut cg = build_codegen_options(matches, error_format);
let mut codegen_units = cg.codegen_units;
let mut thinlto = None;
let mut disable_thinlto = false;

// Issue #30063: if user requests llvm-related output to one
// particular path, disable codegen-units.
Expand All @@ -1699,12 +1731,12 @@ pub fn build_session_options_and_crate_config(matches: &getopts::Matches)
}
early_warn(error_format, "resetting to default -C codegen-units=1");
codegen_units = Some(1);
thinlto = Some(false);
disable_thinlto = true;
}
}
_ => {
codegen_units = Some(1);
thinlto = Some(false);
disable_thinlto = true;
}
}
}
Expand Down Expand Up @@ -1734,7 +1766,7 @@ pub fn build_session_options_and_crate_config(matches: &getopts::Matches)
(&None, &None) => None,
}.map(|m| PathBuf::from(m));

if cg.lto && incremental.is_some() {
if cg.lto != Lto::No && incremental.is_some() {
early_error(error_format, "can't perform LTO when compiling incrementally");
}

Expand Down Expand Up @@ -1934,7 +1966,7 @@ pub fn build_session_options_and_crate_config(matches: &getopts::Matches)
debug_assertions,
actually_rustdoc: false,
cli_forced_codegen_units: codegen_units,
cli_forced_thinlto: thinlto,
cli_forced_thinlto_off: disable_thinlto,
},
cfg)
}
Expand Down Expand Up @@ -2052,7 +2084,7 @@ mod dep_tracking {
use std::hash::Hash;
use std::path::PathBuf;
use std::collections::hash_map::DefaultHasher;
use super::{Passes, CrateType, OptLevel, DebugInfoLevel,
use super::{Passes, CrateType, OptLevel, DebugInfoLevel, Lto,
OutputTypes, Externs, ErrorOutputType, Sanitizer};
use syntax::feature_gate::UnstableFeatures;
use rustc_back::{PanicStrategy, RelroLevel};
Expand Down Expand Up @@ -2107,6 +2139,7 @@ mod dep_tracking {
impl_dep_tracking_hash_via_hash!(RelroLevel);
impl_dep_tracking_hash_via_hash!(Passes);
impl_dep_tracking_hash_via_hash!(OptLevel);
impl_dep_tracking_hash_via_hash!(Lto);
impl_dep_tracking_hash_via_hash!(DebugInfoLevel);
impl_dep_tracking_hash_via_hash!(UnstableFeatures);
impl_dep_tracking_hash_via_hash!(Externs);
Expand Down Expand Up @@ -2180,6 +2213,7 @@ mod tests {
use lint;
use middle::cstore;
use session::config::{build_configuration, build_session_options_and_crate_config};
use session::config::Lto;
use session::build_session;
use std::collections::{BTreeMap, BTreeSet};
use std::iter::FromIterator;
Expand Down Expand Up @@ -2656,7 +2690,7 @@ mod tests {

// Make sure changing a [TRACKED] option changes the hash
opts = reference.clone();
opts.cg.lto = true;
opts.cg.lto = Lto::Fat;
assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());

opts = reference.clone();
Expand Down
92 changes: 58 additions & 34 deletions src/librustc/session/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -498,9 +498,65 @@ impl Session {
self.use_mir()
}

pub fn lto(&self) -> bool {
self.opts.cg.lto || self.target.target.options.requires_lto
/// Calculates the flavor of LTO to use for this compilation.
pub fn lto(&self) -> config::Lto {
// If our target has codegen requirements ignore the command line
if self.target.target.options.requires_lto {
return config::Lto::Fat
}

// If the user specified something, return that. If they only said `-C
// lto` and we've for whatever reason forced off ThinLTO via the CLI,
// then ensure we can't use a ThinLTO.
match self.opts.cg.lto {
config::Lto::No => {}
config::Lto::Yes if self.opts.cli_forced_thinlto_off => {
return config::Lto::Fat
}
other => return other,
}

// Ok at this point the target doesn't require anything and the user
// hasn't asked for anything. Our next decision is whether or not
// we enable "auto" ThinLTO where we use multiple codegen units and
// then do ThinLTO over those codegen units. The logic below will
// either return `No` or `ThinLocal`.

// If processing command line options determined that we're incompatible
// with ThinLTO (e.g. `-C lto --emit llvm-ir`) then return that option.
if self.opts.cli_forced_thinlto_off {
return config::Lto::No
}

// If `-Z thinlto` specified process that, but note that this is mostly
// a deprecated option now that `-C lto=thin` exists.
if let Some(enabled) = self.opts.debugging_opts.thinlto {
if enabled {
return config::Lto::ThinLocal
} else {
return config::Lto::No
}
}

// If there's only one codegen unit and LTO isn't enabled then there's
// no need for ThinLTO so just return false.
if self.codegen_units() == 1 {
return config::Lto::No
}

// Right now ThinLTO isn't compatible with incremental compilation.
if self.opts.incremental.is_some() {
return config::Lto::No
}

// Now we're in "defaults" territory. By default we enable ThinLTO for
// optimized compiles (anything greater than O0).
match self.opts.optimize {
config::OptLevel::No => config::Lto::No,
_ => config::Lto::ThinLocal,
}
}

/// Returns the panic strategy for this compile session. If the user explicitly selected one
/// using '-C panic', use that, otherwise use the panic strategy defined by the target.
pub fn panic_strategy(&self) -> PanicStrategy {
Expand Down Expand Up @@ -804,38 +860,6 @@ impl Session {
// scientific.
16
}

/// Returns whether ThinLTO is enabled for this compilation
pub fn thinlto(&self) -> bool {
// If processing command line options determined that we're incompatible
// with ThinLTO (e.g. `-C lto --emit llvm-ir`) then return that option.
if let Some(enabled) = self.opts.cli_forced_thinlto {
return enabled
}

// If explicitly specified, use that with the next highest priority
if let Some(enabled) = self.opts.debugging_opts.thinlto {
return enabled
}

// If there's only one codegen unit and LTO isn't enabled then there's
// no need for ThinLTO so just return false.
if self.codegen_units() == 1 && !self.lto() {
return false
}

// Right now ThinLTO isn't compatible with incremental compilation.
if self.opts.incremental.is_some() {
return false
}

// Now we're in "defaults" territory. By default we enable ThinLTO for
// optimized compiles (anything greater than O0).
match self.opts.optimize {
config::OptLevel::No => false,
_ => true,
}
}
}

pub fn build_session(sopts: config::Options,
Expand Down
22 changes: 17 additions & 5 deletions src/librustc_trans/back/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use super::rpath::RPathConfig;
use super::rpath;
use metadata::METADATA_FILENAME;
use rustc::session::config::{self, NoDebugInfo, OutputFilenames, OutputType, PrintRequest};
use rustc::session::config::RUST_CGU_EXT;
use rustc::session::config::{RUST_CGU_EXT, Lto};
use rustc::session::filesearch;
use rustc::session::search_paths::PathKind;
use rustc::session::Session;
Expand Down Expand Up @@ -503,7 +503,8 @@ fn link_staticlib(sess: &Session,
});
ab.add_rlib(path,
&name.as_str(),
sess.lto() && !ignored_for_lto(sess, &trans.crate_info, cnum),
is_full_lto_enabled(sess) &&
!ignored_for_lto(sess, &trans.crate_info, cnum),
skip_object_files).unwrap();

all_native_libs.extend(trans.crate_info.native_libraries[&cnum].iter().cloned());
Expand Down Expand Up @@ -1211,7 +1212,8 @@ fn add_upstream_rust_crates(cmd: &mut Linker,
lib.kind == NativeLibraryKind::NativeStatic && !relevant_lib(sess, lib)
});

if (!sess.lto() || ignored_for_lto(sess, &trans.crate_info, cnum)) &&
if (!is_full_lto_enabled(sess) ||
ignored_for_lto(sess, &trans.crate_info, cnum)) &&
crate_type != config::CrateTypeDylib &&
!skip_native {
cmd.link_rlib(&fix_windows_verbatim_for_gcc(cratepath));
Expand Down Expand Up @@ -1264,7 +1266,7 @@ fn add_upstream_rust_crates(cmd: &mut Linker,
// file, then we don't need the object file as it's part of the
// LTO module. Note that `#![no_builtins]` is excluded from LTO,
// though, so we let that object file slide.
let skip_because_lto = sess.lto() &&
let skip_because_lto = is_full_lto_enabled(sess) &&
is_rust_object &&
(sess.target.target.options.no_builtins ||
!trans.crate_info.is_no_builtins.contains(&cnum));
Expand Down Expand Up @@ -1301,7 +1303,7 @@ fn add_upstream_rust_crates(cmd: &mut Linker,
fn add_dynamic_crate(cmd: &mut Linker, sess: &Session, cratepath: &Path) {
// If we're performing LTO, then it should have been previously required
// that all upstream rust dependencies were available in an rlib format.
assert!(!sess.lto());
assert!(!is_full_lto_enabled(sess));

// Just need to tell the linker about where the library lives and
// what its name is
Expand Down Expand Up @@ -1409,3 +1411,13 @@ fn link_binaryen(sess: &Session,
e));
}
}

fn is_full_lto_enabled(sess: &Session) -> bool {
match sess.lto() {
Lto::Yes |
Lto::Thin |
Lto::Fat => true,
Lto::No |
Lto::ThinLocal => false,
}
}
Loading