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 13 pull requests #53197

Closed
wants to merge 36 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
c70eb4b
Automatically expand section if url id point to one of its component
GuillaumeGomez Aug 5, 2018
70cafec
improper_ctypes lint for individual foreign items
VPashkov Aug 6, 2018
e8bb7bf
Account for --remap-path-prefix in save-analysis
Xanewok Aug 6, 2018
b011b09
NetBSD: fix signedess of char
jakllsch Aug 5, 2018
44d32d4
Avoid unnecessary pattern matching against Option and Result
ljedrz Jul 27, 2018
43850e0
Special case error message for thread-local statics.
davidtwco Aug 6, 2018
6608552
Re-enable drop-locations debuginfo tests.
michaelwoerister Aug 7, 2018
4eb52ff
Re-enable a bunch of debuginfo tests.
michaelwoerister Aug 7, 2018
d5f8edf
Fix outdated description of -Zcross-lang-lto.
michaelwoerister Aug 2, 2018
3a3b331
Fix issue around dllimport and ThinLTO as LLD runs it.
michaelwoerister Aug 2, 2018
aa9eeff
Make sure upstream object files are added to staticlibs when compiling
michaelwoerister Aug 2, 2018
54fba3a
Run cross-lang-lto tests also for MSVC (since there's no reason not to)
michaelwoerister Aug 3, 2018
386e000
Add test case for omitting dllimport during cross-lang LTO.
michaelwoerister Aug 3, 2018
3742f4d
Add test case for including upstream object files in staticlibs when …
michaelwoerister Aug 3, 2018
f2969ed
Set 'PrepareForThinLTO' whenever doing cross-language LTO.
michaelwoerister Aug 3, 2018
b27a161
Annotate functions in LLVM with target-cpu, same as Clang does.
michaelwoerister Aug 2, 2018
5ce865e
Add wasm32 simd128 target feature
gnzlbg Aug 7, 2018
020b073
add wasm_target_feature feature gate
gnzlbg Aug 7, 2018
877c469
Avoid increased alignment of TLS segments on Fuchsia
cramertj Aug 7, 2018
2cdaf3b
add feature-gate test
gnzlbg Aug 8, 2018
f4039af
Suggest comma when missing in macro call
estebank Aug 8, 2018
3a70050
Address review comments for #53031 and fix some merge fallout.
michaelwoerister Aug 6, 2018
9876e38
Move SmallVec and ThinVec out of libsyntax
ljedrz Aug 5, 2018
6f7a937
Rollup merge of #52773 - ljedrz:unncecessary_patterns, r=nikomatsakis
cramertj Aug 8, 2018
f6ecd18
Rollup merge of #53031 - michaelwoerister:cross-lto, r=alexcrichton
cramertj Aug 8, 2018
9da5d25
Rollup merge of #53085 - ljedrz:cleanup_syntax_structures, r=Mark-Sim…
cramertj Aug 8, 2018
f3d57ef
Rollup merge of #53094 - GuillaumeGomez:automatic-expand, r=nrc
cramertj Aug 8, 2018
c346391
Rollup merge of #53100 - VPashkov:issue-52456-improper_ctypes, r=eddyb
cramertj Aug 8, 2018
e35ca13
Rollup merge of #53110 - Xanewok:save-analysis-remap-path, r=nrc
cramertj Aug 8, 2018
5d2deee
Rollup merge of #53116 - jakllsch:netbsd-unsigned-char, r=alexcrichton
cramertj Aug 8, 2018
5cfdbae
Rollup merge of #53131 - davidtwco:issue-52663-thread-local-static, r…
cramertj Aug 8, 2018
42edec6
Rollup merge of #53152 - michaelwoerister:reenable-drop-location-debu…
cramertj Aug 8, 2018
197861a
Rollup merge of #53154 - michaelwoerister:reenable-some-debuginfo-tes…
cramertj Aug 8, 2018
26511ef
Rollup merge of #53179 - gnzlbg:patch-3, r=alexcrichton
cramertj Aug 8, 2018
1729652
Rollup merge of #53180 - cramertj:tls-align, r=alexcrichton
cramertj Aug 8, 2018
35f7927
Rollup merge of #53183 - estebank:println-comma, r=oli-obk
cramertj Aug 8, 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
1 change: 1 addition & 0 deletions src/Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2048,6 +2048,7 @@ version = "0.0.0"
dependencies = [
"log 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc 0.0.0",
"rustc_data_structures 0.0.0",
"rustc_errors 0.0.0",
"rustc_target 0.0.0",
"syntax 0.0.0",
Expand Down
25 changes: 13 additions & 12 deletions src/librustc/hir/lowering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ use lint::builtin::{self, PARENTHESIZED_PARAMS_IN_TYPES_AND_MODULES,
ELIDED_LIFETIMES_IN_PATHS};
use middle::cstore::CrateStore;
use rustc_data_structures::indexed_vec::IndexVec;
use rustc_data_structures::small_vec::OneVector;
use rustc_data_structures::thin_vec::ThinVec;
use session::Session;
use util::common::FN_OUTPUT_NAME;
use util::nodemap::{DefIdMap, NodeMap};
Expand All @@ -71,7 +73,6 @@ use syntax::std_inject;
use syntax::symbol::{keywords, Symbol};
use syntax::tokenstream::{Delimited, TokenStream, TokenTree};
use syntax::parse::token::Token;
use syntax::util::small_vector::SmallVector;
use syntax::visit::{self, Visitor};
use syntax_pos::{Span, MultiSpan};

Expand Down Expand Up @@ -3136,12 +3137,12 @@ impl<'a> LoweringContext<'a> {
&mut self,
decl: &FnDecl,
header: &FnHeader,
ids: &mut SmallVector<hir::ItemId>,
ids: &mut OneVector<hir::ItemId>,
) {
if let Some(id) = header.asyncness.opt_return_id() {
ids.push(hir::ItemId { id });
}
struct IdVisitor<'a> { ids: &'a mut SmallVector<hir::ItemId> }
struct IdVisitor<'a> { ids: &'a mut OneVector<hir::ItemId> }
impl<'a, 'b> Visitor<'a> for IdVisitor<'b> {
fn visit_ty(&mut self, ty: &'a Ty) {
match ty.node {
Expand Down Expand Up @@ -3174,36 +3175,36 @@ impl<'a> LoweringContext<'a> {
}
}

fn lower_item_id(&mut self, i: &Item) -> SmallVector<hir::ItemId> {
fn lower_item_id(&mut self, i: &Item) -> OneVector<hir::ItemId> {
match i.node {
ItemKind::Use(ref use_tree) => {
let mut vec = SmallVector::one(hir::ItemId { id: i.id });
let mut vec = OneVector::one(hir::ItemId { id: i.id });
self.lower_item_id_use_tree(use_tree, i.id, &mut vec);
vec
}
ItemKind::MacroDef(..) => SmallVector::new(),
ItemKind::MacroDef(..) => OneVector::new(),
ItemKind::Fn(ref decl, ref header, ..) => {
let mut ids = SmallVector::one(hir::ItemId { id: i.id });
let mut ids = OneVector::one(hir::ItemId { id: i.id });
self.lower_impl_trait_ids(decl, header, &mut ids);
ids
},
ItemKind::Impl(.., None, _, ref items) => {
let mut ids = SmallVector::one(hir::ItemId { id: i.id });
let mut ids = OneVector::one(hir::ItemId { id: i.id });
for item in items {
if let ImplItemKind::Method(ref sig, _) = item.node {
self.lower_impl_trait_ids(&sig.decl, &sig.header, &mut ids);
}
}
ids
},
_ => SmallVector::one(hir::ItemId { id: i.id }),
_ => OneVector::one(hir::ItemId { id: i.id }),
}
}

fn lower_item_id_use_tree(&mut self,
tree: &UseTree,
base_id: NodeId,
vec: &mut SmallVector<hir::ItemId>)
vec: &mut OneVector<hir::ItemId>)
{
match tree.kind {
UseTreeKind::Nested(ref nested_vec) => for &(ref nested, id) in nested_vec {
Expand Down Expand Up @@ -4295,8 +4296,8 @@ impl<'a> LoweringContext<'a> {
}
}

fn lower_stmt(&mut self, s: &Stmt) -> SmallVector<hir::Stmt> {
SmallVector::one(match s.node {
fn lower_stmt(&mut self, s: &Stmt) -> OneVector<hir::Stmt> {
OneVector::one(match s.node {
StmtKind::Local(ref l) => Spanned {
node: hir::StmtKind::Decl(
P(Spanned {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/hir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ use syntax::ext::hygiene::SyntaxContext;
use syntax::ptr::P;
use syntax::symbol::{Symbol, keywords};
use syntax::tokenstream::TokenStream;
use syntax::util::ThinVec;
use syntax::util::parser::ExprPrecedence;
use ty::AdtKind;
use ty::query::Providers;

use rustc_data_structures::indexed_vec;
use rustc_data_structures::sync::{ParallelIterator, par_iter, Send, Sync, scope};
use rustc_data_structures::thin_vec::ThinVec;

use serialize::{self, Encoder, Encodable, Decoder, Decodable};
use std::collections::BTreeMap;
Expand Down
9 changes: 1 addition & 8 deletions src/librustc/session/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -831,7 +831,7 @@ macro_rules! options {
pub const parse_lto: Option<&'static str> =
Some("one of `thin`, `fat`, or omitted");
pub const parse_cross_lang_lto: Option<&'static str> =
Some("either a boolean (`yes`, `no`, `on`, `off`, etc), `no-link`, \
Some("either a boolean (`yes`, `no`, `on`, `off`, etc), \
or the path to the linker plugin");
}

Expand Down Expand Up @@ -2006,13 +2006,6 @@ pub fn build_session_options_and_crate_config(
(&None, &None) => None,
}.map(|m| PathBuf::from(m));

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

if debugging_opts.profile && incremental.is_some() {
early_error(
error_format,
Expand Down
27 changes: 26 additions & 1 deletion src/librustc/session/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use lint::builtin::BuiltinLintDiagnostics;
use middle::allocator::AllocatorKind;
use middle::dependency_format;
use session::search_paths::PathKind;
use session::config::{OutputType};
use session::config::{OutputType, Lto};
use ty::tls;
use util::nodemap::{FxHashMap, FxHashSet};
use util::common::{duration_to_secs_str, ErrorReported};
Expand Down Expand Up @@ -1189,9 +1189,34 @@ pub fn build_session_(
driver_lint_caps: FxHashMap(),
};

validate_commandline_args_with_session_available(&sess);

sess
}

// If it is useful to have a Session available already for validating a
// commandline argument, you can do so here.
fn validate_commandline_args_with_session_available(sess: &Session) {

if sess.lto() != Lto::No && sess.opts.incremental.is_some() {
sess.err("can't perform LTO when compiling incrementally");
}

// Since we don't know if code in an rlib will be linked to statically or
// dynamically downstream, rustc generates `__imp_` symbols that help the
// MSVC linker deal with this lack of knowledge (#27438). Unfortunately,
// these manually generated symbols confuse LLD when it tries to merge
// bitcode during ThinLTO. Therefore we disallow dynamic linking on MSVC
// when compiling for LLD ThinLTO. This way we can validly just not generate
// the `dllimport` attributes and `__imp_` symbols in that case.
if sess.opts.debugging_opts.cross_lang_lto.enabled() &&
sess.opts.cg.prefer_dynamic &&
sess.target.target.options.is_like_msvc {
sess.err("Linker plugin based LTO is not supported together with \
`-C prefer-dynamic` when targeting MSVC");
}
}

/// Hash value constructed out of all the `-C metadata` arguments passed to the
/// compiler. Together with the crate-name forms a unique global identifier for
/// the crate.
Expand Down
5 changes: 1 addition & 4 deletions src/librustc/traits/auto_trait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -681,10 +681,7 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
}
}
&ty::Predicate::RegionOutlives(ref binder) => {
if let Err(_) = select
.infcx()
.region_outlives_predicate(&dummy_cause, binder)
{
if select.infcx().region_outlives_predicate(&dummy_cause, binder).is_err() {
return false;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/traits/error_reporting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
// Eventually I'll need to implement param-env-aware
// `Γ₁ ⊦ φ₁ => Γ₂ ⊦ φ₂` logic.
let param_env = ty::ParamEnv::empty();
if let Ok(_) = self.can_sub(param_env, error, implication) {
if self.can_sub(param_env, error, implication).is_ok() {
debug!("error_implies: {:?} -> {:?} -> {:?}", cond, error, implication);
return true
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/traits/query/outlives_bounds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> {
// variables. Process these constraints.
let mut fulfill_cx = FulfillmentContext::new();
fulfill_cx.register_predicate_obligations(self, result.obligations);
if let Err(_) = fulfill_cx.select_all_or_error(self) {
if fulfill_cx.select_all_or_error(self).is_err() {
self.tcx.sess.delay_span_bug(
span,
"implied_outlives_bounds failed to solve obligations from instantiation"
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/traits/select.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1587,8 +1587,8 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
-> bool
{
assert!(!skol_trait_ref.has_escaping_regions());
if let Err(_) = self.infcx.at(&obligation.cause, obligation.param_env)
.sup(ty::Binder::dummy(skol_trait_ref), trait_bound) {
if self.infcx.at(&obligation.cause, obligation.param_env)
.sup(ty::Binder::dummy(skol_trait_ref), trait_bound).is_err() {
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion src/librustc/ty/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ fn resolve_associated_item<'a, 'tcx>(
})
}
traits::VtableBuiltin(..) => {
if let Some(_) = tcx.lang_items().clone_trait() {
if tcx.lang_items().clone_trait().is_some() {
Some(Instance {
def: ty::InstanceDef::CloneShim(def_id, trait_ref.self_ty()),
substs: rcvr_substs
Expand Down
1 change: 1 addition & 0 deletions src/librustc_allocator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ test = false

[dependencies]
rustc = { path = "../librustc" }
rustc_data_structures = { path = "../librustc_data_structures" }
rustc_errors = { path = "../librustc_errors" }
rustc_target = { path = "../librustc_target" }
syntax = { path = "../libsyntax" }
Expand Down
14 changes: 7 additions & 7 deletions src/librustc_allocator/expand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
// except according to those terms.

use rustc::middle::allocator::AllocatorKind;
use rustc_data_structures::small_vec::OneVector;
use rustc_errors;
use syntax::{
ast::{
Expand All @@ -28,8 +29,7 @@ use syntax::{
fold::{self, Folder},
parse::ParseSess,
ptr::P,
symbol::Symbol,
util::small_vector::SmallVector,
symbol::Symbol
};
use syntax_pos::Span;

Expand Down Expand Up @@ -65,7 +65,7 @@ struct ExpandAllocatorDirectives<'a> {
}

impl<'a> Folder for ExpandAllocatorDirectives<'a> {
fn fold_item(&mut self, item: P<Item>) -> SmallVector<P<Item>> {
fn fold_item(&mut self, item: P<Item>) -> OneVector<P<Item>> {
debug!("in submodule {}", self.in_submod);

let name = if attr::contains_name(&item.attrs, "global_allocator") {
Expand All @@ -78,20 +78,20 @@ impl<'a> Folder for ExpandAllocatorDirectives<'a> {
_ => {
self.handler
.span_err(item.span, "allocators must be statics");
return SmallVector::one(item);
return OneVector::one(item);
}
}

if self.in_submod > 0 {
self.handler
.span_err(item.span, "`global_allocator` cannot be used in submodules");
return SmallVector::one(item);
return OneVector::one(item);
}

if self.found {
self.handler
.span_err(item.span, "cannot define more than one #[global_allocator]");
return SmallVector::one(item);
return OneVector::one(item);
}
self.found = true;

Expand Down Expand Up @@ -152,7 +152,7 @@ impl<'a> Folder for ExpandAllocatorDirectives<'a> {
let module = f.cx.monotonic_expander().fold_item(module).pop().unwrap();

// Return the item and new submodule
let mut ret = SmallVector::with_capacity(2);
let mut ret = OneVector::with_capacity(2);
ret.push(item);
ret.push(module);

Expand Down
1 change: 1 addition & 0 deletions src/librustc_allocator/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

#[macro_use] extern crate log;
extern crate rustc;
extern crate rustc_data_structures;
extern crate rustc_errors;
extern crate rustc_target;
extern crate syntax;
Expand Down
18 changes: 18 additions & 0 deletions src/librustc_codegen_llvm/attributes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,15 @@ pub fn llvm_target_features(sess: &Session) -> impl Iterator<Item = &str> {
.filter(|l| !l.is_empty())
}

pub fn apply_target_cpu_attr(cx: &CodegenCx<'ll, '_>, llfn: &'ll Value) {
let target_cpu = CString::new(cx.tcx.sess.target_cpu().to_string()).unwrap();
llvm::AddFunctionAttrStringValue(
llfn,
llvm::AttributePlace::Function,
cstr("target-cpu\0"),
target_cpu.as_c_str());
}

/// Composite function which sets LLVM attributes for function depending on its AST (#[attribute])
/// attributes.
pub fn from_fn_attrs(cx: &CodegenCx<'ll, '_>, llfn: &'ll Value, id: DefId) {
Expand Down Expand Up @@ -167,6 +176,15 @@ pub fn from_fn_attrs(cx: &CodegenCx<'ll, '_>, llfn: &'ll Value, id: DefId) {
Some(true) | None => {}
}

// Always annotate functions with the target-cpu they are compiled for.
// Without this, ThinLTO won't inline Rust functions into Clang generated
// functions (because Clang annotates functions this way too).
// NOTE: For now we just apply this if -Zcross-lang-lto is specified, since
// it introduce a little overhead and isn't really necessary otherwise.
if cx.tcx.sess.opts.debugging_opts.cross_lang_lto.enabled() {
apply_target_cpu_attr(cx, llfn);
}

let features = llvm_target_features(cx.tcx.sess)
.map(|s| s.to_string())
.chain(
Expand Down
16 changes: 10 additions & 6 deletions src/librustc_codegen_llvm/back/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@ fn link_staticlib(sess: &Session,
});
ab.add_rlib(path,
&name.as_str(),
is_full_lto_enabled(sess) &&
are_upstream_rust_objects_already_included(sess) &&
!ignored_for_lto(sess, &codegen_results.crate_info, cnum),
skip_object_files).unwrap();

Expand Down Expand Up @@ -1446,7 +1446,7 @@ fn add_upstream_rust_crates(cmd: &mut dyn Linker,
lib.kind == NativeLibraryKind::NativeStatic && !relevant_lib(sess, lib)
});

if (!is_full_lto_enabled(sess) ||
if (!are_upstream_rust_objects_already_included(sess) ||
ignored_for_lto(sess, &codegen_results.crate_info, cnum)) &&
crate_type != config::CrateType::Dylib &&
!skip_native {
Expand Down Expand Up @@ -1500,7 +1500,7 @@ fn add_upstream_rust_crates(cmd: &mut dyn 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 = is_full_lto_enabled(sess) &&
let skip_because_lto = are_upstream_rust_objects_already_included(sess) &&
is_rust_object &&
(sess.target.target.options.no_builtins ||
!codegen_results.crate_info.is_no_builtins.contains(&cnum));
Expand Down Expand Up @@ -1537,7 +1537,7 @@ fn add_upstream_rust_crates(cmd: &mut dyn Linker,
fn add_dynamic_crate(cmd: &mut dyn 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!(!is_full_lto_enabled(sess));
assert!(!are_upstream_rust_objects_already_included(sess));

// Just need to tell the linker about where the library lives and
// what its name is
Expand Down Expand Up @@ -1623,11 +1623,15 @@ fn relevant_lib(sess: &Session, lib: &NativeLibrary) -> bool {
}
}

fn is_full_lto_enabled(sess: &Session) -> bool {
fn are_upstream_rust_objects_already_included(sess: &Session) -> bool {
match sess.lto() {
Lto::Yes |
Lto::Thin |
Lto::Fat => true,
Lto::Thin => {
// If we defer LTO to the linker, we haven't run LTO ourselves, so
// any upstream object files have not been copied yet.
!sess.opts.debugging_opts.cross_lang_lto.enabled()
}
Lto::No |
Lto::ThinLocal => false,
}
Expand Down
4 changes: 4 additions & 0 deletions src/librustc_codegen_llvm/back/lto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,10 @@ pub(crate) fn run(cgcx: &CodegenContext,
}
Lto::Thin |
Lto::ThinLocal => {
if cgcx.opts.debugging_opts.cross_lang_lto.enabled() {
unreachable!("We should never reach this case if the LTO step \
is deferred to the linker");
}
thin_lto(&diag_handler, modules, upstream_modules, &arr, timeline)
}
Lto::No => unreachable!(),
Expand Down
Loading