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 11 pull requests #68470

Closed
wants to merge 30 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
470cdf5
add bare metal ARM Cortex-A targets to rustc
japaric Jan 15, 2020
de38803
Add -Wl,-znotext to default linker flags to link with lld 9 on FreeBS…
Jan 19, 2020
358ade9
Add `-Z no-link` flag
Dec 21, 2019
a3a0776
Merge branch 'master' into bare-metal-cortex-a
japaric Jan 20, 2020
6d218db
compiletest: Simplify multi-debugger support
tmiasko Jan 20, 2020
2c0845c
Mark __msan_track_origins as an exported symbol for LTO
nikic Jan 19, 2020
d8c661a
Mark __msan_keep_going as an exported symbol for LTO
tmiasko Jan 21, 2020
dd0507c
Make `TooGeneric` error in WF checking a proper error
varkor Jan 20, 2020
8abbd0b
for now, do not build rust-std for the armv7a-none-eabihf target
japaric Jan 21, 2020
5dee7dd
Handle methods in try diagnostic
phi-gamma Jan 21, 2020
02e66ba
Test try diagnostics for impl and trait methods
phi-gamma Jan 21, 2020
db3b40c
Cleanup: rewrite conditional as match
phi-gamma Jan 21, 2020
d1bb7e1
Privatize private fields of OutputFilenames
Mark-Simulacrum Jan 21, 2020
8c6067c
Store filestem in a pre-formatted form
Mark-Simulacrum Jan 21, 2020
dc97181
Do not base path to append extension
Mark-Simulacrum Jan 21, 2020
eb2da27
bootstrap: update clippy subcmd decription
matthiaskrgr Jan 22, 2020
7962ccb
pprust: use as_deref
Centril Jan 22, 2020
be86fb3
Add some comments about CrateNum, CrateInfo and .rlink file format
Jan 22, 2020
71370c8
librustc_mir: don't allocate vectors where slices will do.
matthiaskrgr Jan 22, 2020
aad22f2
Rollup merge of #67195 - 0dvictor:nolink, r=tmandry
tmandry Jan 22, 2020
3ac1c5e
Rollup merge of #68253 - japaric:bare-metal-cortex-a, r=alexcrichton
tmandry Jan 22, 2020
403a452
Rollup merge of #68361 - t6:patch-freebsd-lld-i386, r=alexcrichton
tmandry Jan 22, 2020
eed641e
Rollup merge of #68388 - varkor:toogeneric-wf, r=eddyb
tmandry Jan 22, 2020
22606de
Rollup merge of #68391 - tmiasko:compiletest-debuginfo, r=alexcrichton
tmandry Jan 22, 2020
5801824
Rollup merge of #68409 - sinkuu:temp_path, r=Mark-Simulacrum
tmandry Jan 22, 2020
0dcea65
Rollup merge of #68410 - tmiasko:msan-lto, r=varkor
tmandry Jan 22, 2020
80b5eaf
Rollup merge of #68425 - phi-gamma:try-method, r=varkor
tmandry Jan 22, 2020
238cd11
Rollup merge of #68440 - matthiaskrgr:xpyclippy, r=Mark-Simulacrum
tmandry Jan 22, 2020
23fff15
Rollup merge of #68441 - Centril:pprust-as_deref, r=Mark-Simulacrum
tmandry Jan 22, 2020
22d9d10
Rollup merge of #68462 - matthiaskrgr:novec, r=varkor
tmandry Jan 22, 2020
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 Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3428,6 +3428,7 @@ dependencies = [
"rustc_session",
"rustc_span",
"rustc_target",
"serialize",
"smallvec 1.0.0",
"syntax",
]
Expand Down
2 changes: 1 addition & 1 deletion src/bootstrap/flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ Usage: x.py <subcommand> [options] [<paths>...]
Subcommands:
build Compile either the compiler or libraries
check Compile either the compiler or libraries, using cargo check
clippy Run clippy
clippy Run clippy (uses rustup/cargo-installed clippy binary)
fix Run cargo fix
fmt Run rustfmt
test Build and run some test suites
Expand Down
8 changes: 0 additions & 8 deletions src/bootstrap/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -957,14 +957,6 @@ impl Step for Compiletest {
}

if suite == "debuginfo" {
let msvc = builder.config.build.contains("msvc");
if mode == "debuginfo" {
return builder.ensure(Compiletest {
mode: if msvc { "debuginfo-cdb" } else { "debuginfo-gdb+lldb" },
..self
});
}

builder
.ensure(dist::DebuggerScripts { sysroot: builder.sysroot(compiler), host: target });
}
Expand Down
5 changes: 5 additions & 0 deletions src/ci/docker/dist-various-1/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ ENV TARGETS=$TARGETS,armebv7r-none-eabihf
ENV TARGETS=$TARGETS,armv7r-none-eabi
ENV TARGETS=$TARGETS,armv7r-none-eabihf
ENV TARGETS=$TARGETS,thumbv7neon-unknown-linux-gnueabihf
ENV TARGETS=$TARGETS,armv7a-none-eabi

# riscv targets currently do not need a C compiler, as compiler_builtins
# doesn't currently have it enabled, and the riscv gcc compiler is not
Expand All @@ -173,6 +174,10 @@ ENV CC_mipsel_unknown_linux_musl=mipsel-openwrt-linux-gcc \
CC_thumbv7neon_unknown_linux_gnueabihf=arm-linux-gnueabihf-gcc \
AR_thumbv7neon_unknown_linux_gnueabihf=arm-linux-gnueabihf-ar \
CXX_thumbv7neon_unknown_linux_gnueabihf=arm-linux-gnueabihf-g++ \
CC_armv7a_none_eabi=arm-none-eabi-gcc \
CC_armv7a_none_eabihf=arm-none-eabi-gcc \
CFLAGS_armv7a_none_eabi=-march=armv7-a \
CFLAGS_armv7a_none_eabihf=-march=armv7-a+vfpv3 \
CC_riscv64gc_unknown_linux_gnu=riscv64-unknown-linux-gnu-gcc \
AR_riscv64gc_unknown_linux_gnu=riscv64-unknown-linux-gnu-ar \
CXX_riscv64gc_unknown_linux_gnu=riscv64-unknown-linux-gnu-g++ \
Expand Down
5 changes: 3 additions & 2 deletions src/librustc/middle/cstore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub use rustc_session::utils::NativeLibraryKind;

/// Where a crate came from on the local filesystem. One of these three options
/// must be non-None.
#[derive(PartialEq, Clone, Debug, HashStable)]
#[derive(PartialEq, Clone, Debug, HashStable, RustcEncodable, RustcDecodable)]
pub struct CrateSource {
pub dylib: Option<(PathBuf, PathKind)>,
pub rlib: Option<(PathBuf, PathKind)>,
Expand Down Expand Up @@ -75,7 +75,7 @@ impl DepKind {
}
}

#[derive(PartialEq, Clone, Debug)]
#[derive(PartialEq, Clone, Debug, RustcEncodable, RustcDecodable)]
pub enum LibSource {
Some(PathBuf),
MetadataOnly,
Expand Down Expand Up @@ -160,6 +160,7 @@ pub enum ExternCrateSource {
Path,
}

#[derive(RustcEncodable, RustcDecodable)]
pub struct EncodedMetadata {
pub raw_data: Vec<u8>,
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/dependency_format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pub type DependencyList = Vec<Linkage>;
/// This is local to the tcx, and is generally relevant to one session.
pub type Dependencies = Vec<(config::CrateType, DependencyList)>;

#[derive(Copy, Clone, PartialEq, Debug, HashStable)]
#[derive(Copy, Clone, PartialEq, Debug, HashStable, RustcEncodable, RustcDecodable)]
pub enum Linkage {
NotLinked,
IncludedFromDylib,
Expand Down
34 changes: 23 additions & 11 deletions src/librustc/traits/error_reporting/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -919,17 +919,29 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
report_object_safety_error(self.tcx, span, did, violations)
}

// already reported in the query
ConstEvalFailure(err) => {
if let ErrorHandled::TooGeneric = err {
// Silence this error, as it can be produced during intermediate steps
// when a constant is not yet able to be evaluated (but will be later).
return;
}
self.tcx.sess.delay_span_bug(
span,
&format!("constant in type had an ignored error: {:?}", err),
);
ConstEvalFailure(ErrorHandled::TooGeneric) => {
// In this instance, we have a const expression containing an unevaluated
// generic parameter. We have no idea whether this expression is valid or
// not (e.g. it might result in an error), but we don't want to just assume
// that it's okay, because that might result in post-monomorphisation time
// errors. The onus is really on the caller to provide values that it can
// prove are well-formed.
let mut err = self
.tcx
.sess
.struct_span_err(span, "constant expression depends on a generic parameter");
// FIXME(const_generics): we should suggest to the user how they can resolve this
// issue. However, this is currently not actually possible
// (see https://github.com/rust-lang/rust/issues/66962#issuecomment-575907083).
err.note("this may fail depending on what value the parameter takes");
err
}

// Already reported in the query.
ConstEvalFailure(ErrorHandled::Reported) => {
self.tcx
.sess
.delay_span_bug(span, &format!("constant in type had an ignored error"));
return;
}

Expand Down
54 changes: 34 additions & 20 deletions src/librustc/traits/error_reporting/on_unimplemented.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,31 +59,45 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
fn describe_enclosure(&self, hir_id: hir::HirId) -> Option<&'static str> {
let hir = &self.tcx.hir();
let node = hir.find(hir_id)?;
if let hir::Node::Item(hir::Item { kind: hir::ItemKind::Fn(sig, _, body_id), .. }) = &node {
self.describe_generator(*body_id).or_else(|| {
match &node {
hir::Node::Item(hir::Item { kind: hir::ItemKind::Fn(sig, _, body_id), .. }) => {
self.describe_generator(*body_id).or_else(|| {
Some(if let hir::FnHeader { asyncness: hir::IsAsync::Async, .. } = sig.header {
"an async function"
} else {
"a function"
})
})
}
hir::Node::TraitItem(hir::TraitItem {
kind: hir::TraitItemKind::Method(_, hir::TraitMethod::Provided(body_id)),
..
}) => self.describe_generator(*body_id).or_else(|| Some("a trait method")),
hir::Node::ImplItem(hir::ImplItem {
kind: hir::ImplItemKind::Method(sig, body_id),
..
}) => self.describe_generator(*body_id).or_else(|| {
Some(if let hir::FnHeader { asyncness: hir::IsAsync::Async, .. } = sig.header {
"an async function"
"an async method"
} else {
"a function"
"a method"
})
})
} else if let hir::Node::Expr(hir::Expr {
kind: hir::ExprKind::Closure(_is_move, _, body_id, _, gen_movability),
..
}) = &node
{
self.describe_generator(*body_id).or_else(|| {
}),
hir::Node::Expr(hir::Expr {
kind: hir::ExprKind::Closure(_is_move, _, body_id, _, gen_movability),
..
}) => self.describe_generator(*body_id).or_else(|| {
Some(if gen_movability.is_some() { "an async closure" } else { "a closure" })
})
} else if let hir::Node::Expr(hir::Expr { .. }) = &node {
let parent_hid = hir.get_parent_node(hir_id);
if parent_hid != hir_id {
return self.describe_enclosure(parent_hid);
} else {
None
}),
hir::Node::Expr(hir::Expr { .. }) => {
let parent_hid = hir.get_parent_node(hir_id);
if parent_hid != hir_id {
return self.describe_enclosure(parent_hid);
} else {
None
}
}
} else {
None
_ => None,
}
}

Expand Down
1 change: 1 addition & 0 deletions src/librustc_codegen_llvm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ rustc_incremental = { path = "../librustc_incremental" }
rustc_index = { path = "../librustc_index" }
rustc_llvm = { path = "../librustc_llvm" }
rustc_session = { path = "../librustc_session" }
rustc_serialize = { path = "../libserialize", package = "serialize" }
rustc_target = { path = "../librustc_target" }
smallvec = { version = "1.0", features = ["union", "may_dangle"] }
syntax = { path = "../libsyntax" }
Expand Down
14 changes: 14 additions & 0 deletions src/librustc_codegen_llvm/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ use rustc_codegen_ssa::CompiledModule;
use rustc_errors::{FatalError, Handler};
use std::any::Any;
use std::ffi::CStr;
use std::fs;
use std::sync::Arc;
use syntax::expand::allocator::AllocatorKind;

Expand All @@ -44,6 +45,7 @@ use rustc::ty::{self, TyCtxt};
use rustc::util::common::ErrorReported;
use rustc_codegen_ssa::ModuleCodegen;
use rustc_codegen_utils::codegen_backend::CodegenBackend;
use rustc_serialize::json;

mod back {
pub mod archive;
Expand Down Expand Up @@ -298,6 +300,18 @@ impl CodegenBackend for LlvmCodegenBackend {
return Ok(());
}

if sess.opts.debugging_opts.no_link {
// FIXME: use a binary format to encode the `.rlink` file
let rlink_data = json::encode(&codegen_results).map_err(|err| {
sess.fatal(&format!("failed to encode rlink: {}", err));
})?;
let rlink_file = outputs.with_extension("rlink");
fs::write(&rlink_file, rlink_data).map_err(|err| {
sess.fatal(&format!("failed to write file {}: {}", rlink_file.display(), err));
})?;
return Ok(());
}

// Run the linker on any artifacts that resulted from the LLVM run.
// This should produce either a finished executable or library.
sess.time("link_crate", || {
Expand Down
1 change: 1 addition & 0 deletions src/librustc_codegen_ssa/back/linker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ use rustc_target::spec::{LinkerFlavor, LldFlavor};

/// For all the linkers we support, and information they might
/// need out of the shared crate context before we get rid of it.
#[derive(RustcEncodable, RustcDecodable)]
pub struct LinkerInfo {
exports: FxHashMap<CrateType, Vec<String>>,
}
Expand Down
12 changes: 11 additions & 1 deletion src/librustc_codegen_ssa/back/symbol_export.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::sync::Arc;

use rustc::middle::codegen_fn_attrs::CodegenFnAttrFlags;
use rustc::middle::exported_symbols::{metadata_symbol_name, ExportedSymbol, SymbolExportLevel};
use rustc::session::config;
use rustc::session::config::{self, Sanitizer};
use rustc::ty::query::Providers;
use rustc::ty::subst::SubstsRef;
use rustc::ty::Instance;
Expand Down Expand Up @@ -206,6 +206,16 @@ fn exported_symbols_provider_local(
}));
}

if let Some(Sanitizer::Memory) = tcx.sess.opts.debugging_opts.sanitizer {
// Similar to profiling, preserve weak msan symbol during LTO.
const MSAN_WEAK_SYMBOLS: [&str; 2] = ["__msan_track_origins", "__msan_keep_going"];

symbols.extend(MSAN_WEAK_SYMBOLS.iter().map(|sym| {
let exported_symbol = ExportedSymbol::NoDefId(SymbolName::new(sym));
(exported_symbol, SymbolExportLevel::C)
}));
}

if tcx.sess.crate_types.borrow().contains(&config::CrateType::Dylib) {
let symbol_name = metadata_symbol_name(tcx);
let exported_symbol = ExportedSymbol::NoDefId(SymbolName::new(&symbol_name));
Expand Down
13 changes: 10 additions & 3 deletions src/librustc_codegen_ssa/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ impl<M> ModuleCodegen<M> {
}
}

#[derive(Debug)]
#[derive(Debug, RustcEncodable, RustcDecodable)]
pub struct CompiledModule {
pub name: String,
pub kind: ModuleKind,
Expand All @@ -101,7 +101,7 @@ pub struct CachedModuleCodegen {
pub source: WorkProduct,
}

#[derive(Copy, Clone, Debug, PartialEq)]
#[derive(Copy, Clone, Debug, PartialEq, RustcEncodable, RustcDecodable)]
pub enum ModuleKind {
Regular,
Metadata,
Expand All @@ -117,7 +117,13 @@ bitflags::bitflags! {
}

/// Misc info we load from metadata to persist beyond the tcx.
#[derive(Debug)]
/// Note: though `CrateNum` is only meaningful within the same tcx, information within `CrateInfo`
/// is self-contained. `CrateNum` can be viewed as a unique identifier within a `CrateInfo`, where
/// `used_crate_source` contains all `CrateSource` of the dependents, and maintains a mapping from
/// identifiers (`CrateNum`) to `CrateSource`. The other fields map `CrateNum` to the crate's own
/// additional properties, so that effectively we can retrieve each dependent crate's `CrateSource`
/// and the corresponding properties without referencing information outside of a `CrateInfo`.
#[derive(Debug, RustcEncodable, RustcDecodable)]
pub struct CrateInfo {
pub panic_runtime: Option<CrateNum>,
pub compiler_builtins: Option<CrateNum>,
Expand All @@ -135,6 +141,7 @@ pub struct CrateInfo {
pub dependency_formats: Lrc<Dependencies>,
}

#[derive(RustcEncodable, RustcDecodable)]
pub struct CodegenResults {
pub crate_name: Symbol,
pub modules: Vec<CompiledModule>,
Expand Down
34 changes: 29 additions & 5 deletions src/librustc_hir/def_id.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use rustc_data_structures::AtomicRef;
use rustc_index::vec::Idx;
use rustc_serialize::{Decoder, Encoder};
use std::fmt;
use std::u32;
use std::{u32, u64};

rustc_index::newtype_index! {
pub struct CrateId {
Expand Down Expand Up @@ -86,8 +87,18 @@ impl fmt::Display for CrateNum {
}
}

impl rustc_serialize::UseSpecializedEncodable for CrateNum {}
impl rustc_serialize::UseSpecializedDecodable for CrateNum {}
/// As a local identifier, a `CrateNum` is only meaningful within its context, e.g. within a tcx.
/// Therefore, make sure to include the context when encode a `CrateNum`.
impl rustc_serialize::UseSpecializedEncodable for CrateNum {
fn default_encode<E: Encoder>(&self, e: &mut E) -> Result<(), E::Error> {
e.emit_u32(self.as_u32())
}
}
impl rustc_serialize::UseSpecializedDecodable for CrateNum {
fn default_decode<D: Decoder>(d: &mut D) -> Result<CrateNum, D::Error> {
Ok(CrateNum::from_u32(d.read_u32()?))
}
}

rustc_index::newtype_index! {
/// A DefIndex is an index into the hir-map for a crate, identifying a
Expand Down Expand Up @@ -135,8 +146,21 @@ impl DefId {
}
}

impl rustc_serialize::UseSpecializedEncodable for DefId {}
impl rustc_serialize::UseSpecializedDecodable for DefId {}
impl rustc_serialize::UseSpecializedEncodable for DefId {
fn default_encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> {
let krate = u64::from(self.krate.as_u32());
let index = u64::from(self.index.as_u32());
s.emit_u64((krate << 32) | index)
}
}
impl rustc_serialize::UseSpecializedDecodable for DefId {
fn default_decode<D: Decoder>(d: &mut D) -> Result<DefId, D::Error> {
let def_id = d.read_u64()?;
let krate = CrateNum::from_u32((def_id >> 32) as u32);
let index = DefIndex::from_u32((def_id & 0xffffffff) as u32);
Ok(DefId { krate, index })
}
}

pub fn default_def_id_debug(def_id: DefId, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("DefId").field("krate", &def_id.krate).field("index", &def_id.index).finish()
Expand Down
Loading