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 8 pull requests #68450

Closed
wants to merge 23 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 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
a3a0776
Merge branch 'master' into bare-metal-cortex-a
japaric 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
1dd59ff
Rollup merge of #68253 - japaric:bare-metal-cortex-a, r=alexcrichton
tmandry Jan 22, 2020
b1f14c2
Rollup merge of #68361 - t6:patch-freebsd-lld-i386, r=alexcrichton
tmandry Jan 22, 2020
7b52b89
Rollup merge of #68388 - varkor:toogeneric-wf, r=eddyb
tmandry Jan 22, 2020
8cd645c
Rollup merge of #68409 - sinkuu:temp_path, r=Mark-Simulacrum
tmandry Jan 22, 2020
d6587fe
Rollup merge of #68410 - tmiasko:msan-lto, r=varkor
tmandry Jan 22, 2020
08558ac
Rollup merge of #68425 - phi-gamma:try-method, r=varkor
tmandry Jan 22, 2020
769ba84
Rollup merge of #68440 - matthiaskrgr:xpyclippy, r=Mark-Simulacrum
tmandry Jan 22, 2020
76db75a
Rollup merge of #68441 - Centril:pprust-as_deref, r=Mark-Simulacrum
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
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
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
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
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
33 changes: 14 additions & 19 deletions src/librustc_interface/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -550,13 +550,13 @@ pub fn build_output_filenames(
.or_else(|| attr::find_crate_name(attrs).map(|n| n.to_string()))
.unwrap_or_else(|| input.filestem().to_owned());

OutputFilenames {
out_directory: dirpath,
out_filestem: stem,
single_output_file: None,
extra: sess.opts.cg.extra_filename.clone(),
outputs: sess.opts.output_types.clone(),
}
OutputFilenames::new(
dirpath,
stem,
None,
sess.opts.cg.extra_filename.clone(),
sess.opts.output_types.clone(),
)
}

Some(ref out_file) => {
Expand All @@ -578,18 +578,13 @@ pub fn build_output_filenames(
sess.warn("ignoring --out-dir flag due to -o flag");
}

OutputFilenames {
out_directory: out_file.parent().unwrap_or_else(|| Path::new("")).to_path_buf(),
out_filestem: out_file
.file_stem()
.unwrap_or_default()
.to_str()
.unwrap()
.to_string(),
single_output_file: ofile,
extra: sess.opts.cg.extra_filename.clone(),
outputs: sess.opts.output_types.clone(),
}
OutputFilenames::new(
out_file.parent().unwrap_or_else(|| Path::new("")).to_path_buf(),
out_file.file_stem().unwrap_or_default().to_str().unwrap().to_string(),
ofile,
sess.opts.cg.extra_filename.clone(),
sess.opts.output_types.clone(),
)
}
}
}
Expand Down
31 changes: 20 additions & 11 deletions src/librustc_session/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -447,9 +447,8 @@ impl Input {
#[derive(Clone, Hash)]
pub struct OutputFilenames {
pub out_directory: PathBuf,
pub out_filestem: String,
filestem: String,
pub single_output_file: Option<PathBuf>,
pub extra: String,
pub outputs: OutputTypes,
}

Expand All @@ -458,6 +457,21 @@ impl_stable_hash_via_hash!(OutputFilenames);
pub const RUST_CGU_EXT: &str = "rcgu";

impl OutputFilenames {
pub fn new(
out_directory: PathBuf,
out_filestem: String,
single_output_file: Option<PathBuf>,
extra: String,
outputs: OutputTypes,
) -> Self {
OutputFilenames {
out_directory,
single_output_file,
outputs,
filestem: format!("{}{}", out_filestem, extra),
}
}

pub fn path(&self, flavor: OutputType) -> PathBuf {
self.outputs
.get(&flavor)
Expand All @@ -477,8 +491,6 @@ impl OutputFilenames {
/// Like temp_path, but also supports things where there is no corresponding
/// OutputType, like noopt-bitcode or lto-bitcode.
pub fn temp_path_ext(&self, ext: &str, codegen_unit_name: Option<&str>) -> PathBuf {
let base = self.out_directory.join(&self.filestem());

let mut extension = String::new();

if let Some(codegen_unit_name) = codegen_unit_name {
Expand All @@ -495,16 +507,13 @@ impl OutputFilenames {
extension.push_str(ext);
}

let path = base.with_extension(&extension[..]);
path
self.with_extension(&extension)
}

pub fn with_extension(&self, extension: &str) -> PathBuf {
self.out_directory.join(&self.filestem()).with_extension(extension)
}

pub fn filestem(&self) -> String {
format!("{}{}", self.out_filestem, self.extra)
let mut path = self.out_directory.join(&self.filestem);
path.set_extension(extension);
path
}
}

Expand Down
48 changes: 48 additions & 0 deletions src/librustc_target/spec/armv7a_none_eabi.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// Generic ARMv7-A target for bare-metal code - floating point disabled
//
// This is basically the `armv7-unknown-linux-gnueabi` target with some changes
// (listed below) to bring it closer to the bare-metal `thumb` & `aarch64`
// targets:
//
// - `TargetOptions.features`: added `+strict-align`. rationale: unaligned
// memory access is disabled on boot on these cores
// - linker changed to LLD. rationale: C is not strictly needed to build
// bare-metal binaries (the `gcc` linker has the advantage that it knows where C
// libraries and crt*.o are but it's not much of an advantage here); LLD is also
// faster
// - `target_os` set to `none`. rationale: matches `thumb` targets
// - `target_{env,vendor}` set to an empty string. rationale: matches `thumb`
// targets
// - `panic_strategy` set to `abort`. rationale: matches `thumb` targets
// - `relocation-model` set to `static`; also no PIE, no relro and no dynamic
// linking. rationale: matches `thumb` targets

use super::{LinkerFlavor, LldFlavor, PanicStrategy, Target, TargetOptions};

pub fn target() -> Result<Target, String> {
let opts = TargetOptions {
linker: Some("rust-lld".to_owned()),
features: "+v7,+thumb2,+soft-float,-neon,+strict-align".to_string(),
executables: true,
relocation_model: "static".to_string(),
disable_redzone: true,
max_atomic_width: Some(64),
panic_strategy: PanicStrategy::Abort,
abi_blacklist: super::arm_base::abi_blacklist(),
emit_debug_gdb_scripts: false,
..Default::default()
};
Ok(Target {
llvm_target: "armv7a-none-eabi".to_string(),
target_endian: "little".to_string(),
target_pointer_width: "32".to_string(),
target_c_int_width: "32".to_string(),
target_os: "none".to_string(),
target_env: String::new(),
target_vendor: String::new(),
data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".to_string(),
arch: "arm".to_string(),
linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld),
options: opts,
})
}
36 changes: 36 additions & 0 deletions src/librustc_target/spec/armv7a_none_eabihf.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// Generic ARMv7-A target for bare-metal code - floating point enabled (assumes
// FPU is present and emits FPU instructions)
//
// This is basically the `armv7-unknown-linux-gnueabihf` target with some
// changes (list in `armv7a_none_eabi.rs`) to bring it closer to the bare-metal
// `thumb` & `aarch64` targets.

use super::{LinkerFlavor, LldFlavor, PanicStrategy, Target, TargetOptions};

pub fn target() -> Result<Target, String> {
let opts = TargetOptions {
linker: Some("rust-lld".to_owned()),
features: "+v7,+vfp3,-d32,+thumb2,-neon,+strict-align".to_string(),
executables: true,
relocation_model: "static".to_string(),
disable_redzone: true,
max_atomic_width: Some(64),
panic_strategy: PanicStrategy::Abort,
abi_blacklist: super::arm_base::abi_blacklist(),
emit_debug_gdb_scripts: false,
..Default::default()
};
Ok(Target {
llvm_target: "armv7a-none-eabihf".to_string(),
target_endian: "little".to_string(),
target_pointer_width: "32".to_string(),
target_c_int_width: "32".to_string(),
target_os: "none".to_string(),
target_env: String::new(),
target_vendor: String::new(),
data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".to_string(),
arch: "arm".to_string(),
linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld),
options: opts,
})
}
4 changes: 3 additions & 1 deletion src/librustc_target/spec/i686_unknown_freebsd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ pub fn target() -> TargetResult {
let mut base = super::freebsd_base::opts();
base.cpu = "pentium4".to_string();
base.max_atomic_width = Some(64);
base.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap().push("-m32".to_string());
let pre_link_args = base.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap();
pre_link_args.push("-m32".to_string());
pre_link_args.push("-Wl,-znotext".to_string());
base.stack_probes = true;

Ok(Target {
Expand Down
3 changes: 3 additions & 0 deletions src/librustc_target/spec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,9 @@ supported_targets! {
("thumbv8m.main-none-eabi", thumbv8m_main_none_eabi),
("thumbv8m.main-none-eabihf", thumbv8m_main_none_eabihf),

("armv7a-none-eabi", armv7a_none_eabi),
("armv7a-none-eabihf", armv7a_none_eabihf),

("msp430-none-elf", msp430_none_elf),

("aarch64-unknown-cloudabi", aarch64_unknown_cloudabi),
Expand Down
4 changes: 2 additions & 2 deletions src/libsyntax/print/pprust.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1645,7 +1645,7 @@ impl<'a> State<'a> {
self.print_expr_as_cond(i);
self.s.space();
self.print_block(then);
self.print_else(e.as_ref().map(|e| &**e))
self.print_else(e.as_deref())
}
// Final `else` block.
ast::ExprKind::Block(ref b, _) => {
Expand Down Expand Up @@ -1949,7 +1949,7 @@ impl<'a> State<'a> {
self.print_let(pat, scrutinee);
}
ast::ExprKind::If(ref test, ref blk, ref elseopt) => {
self.print_if(test, blk, elseopt.as_ref().map(|e| &**e));
self.print_if(test, blk, elseopt.as_deref())
}
ast::ExprKind::While(ref test, ref blk, opt_label) => {
if let Some(label) = opt_label {
Expand Down
Loading