Skip to content

Commit

Permalink
Auto merge of #72222 - Dylan-DPC:rollup-vaw44dg, r=Dylan-DPC
Browse files Browse the repository at this point in the history
Rollup of 7 pull requests

Successful merges:

 - #71809 (Use `LocalDefId` in `DumpVisitor::nest_tables`)
 - #72062 (Add built in PSP target)
 - #72146 (Provide separate option for std debug asserts)
 - #72172 (Forbid stage arguments to check)
 - #72173 (Make intra links work inside trait impl block)
 - #72200 (Add prioritize_on attribute to triagebot)
 - #72214 (Minor fixes to comments)

Failed merges:

r? @ghost
  • Loading branch information
bors committed May 15, 2020
2 parents 85f0da6 + 49d50e6 commit 0271499
Show file tree
Hide file tree
Showing 16 changed files with 280 additions and 52 deletions.
4 changes: 4 additions & 0 deletions config.toml.example
Expand Up @@ -314,6 +314,10 @@
# library.
#debug-assertions = false

# Whether or not debug assertions are enabled for the standard library.
# Overrides the `debug-assertions` option, if defined.
#debug-assertions-std = false

# Debuginfo level for most of Rust code, corresponds to the `-C debuginfo=N` option of `rustc`.
# `0` - no debug info
# `1` - line tables only
Expand Down
9 changes: 8 additions & 1 deletion src/bootstrap/builder.rs
Expand Up @@ -915,7 +915,14 @@ impl<'a> Builder<'a> {
.env("RUSTC", self.out.join("bootstrap/debug/rustc"))
.env("RUSTC_REAL", self.rustc(compiler))
.env("RUSTC_STAGE", stage.to_string())
.env("RUSTC_DEBUG_ASSERTIONS", self.config.rust_debug_assertions.to_string())
.env(
"RUSTC_DEBUG_ASSERTIONS",
if mode == Mode::Std {
self.config.rust_debug_assertions_std.to_string()
} else {
self.config.rust_debug_assertions.to_string()
},
)
.env("RUSTC_SYSROOT", &sysroot)
.env("RUSTC_LIBDIR", &libdir)
.env("RUSTDOC", self.out.join("bootstrap/debug/rustdoc"))
Expand Down
6 changes: 6 additions & 0 deletions src/bootstrap/config.rs
Expand Up @@ -97,6 +97,7 @@ pub struct Config {
pub rust_codegen_units: Option<u32>,
pub rust_codegen_units_std: Option<u32>,
pub rust_debug_assertions: bool,
pub rust_debug_assertions_std: bool,
pub rust_debuginfo_level_rustc: u32,
pub rust_debuginfo_level_std: u32,
pub rust_debuginfo_level_tools: u32,
Expand Down Expand Up @@ -314,6 +315,7 @@ struct Rust {
codegen_units: Option<u32>,
codegen_units_std: Option<u32>,
debug_assertions: Option<bool>,
debug_assertions_std: Option<bool>,
debuginfo_level: Option<u32>,
debuginfo_level_rustc: Option<u32>,
debuginfo_level_std: Option<u32>,
Expand Down Expand Up @@ -518,6 +520,7 @@ impl Config {
let mut llvm_assertions = None;
let mut debug = None;
let mut debug_assertions = None;
let mut debug_assertions_std = None;
let mut debuginfo_level = None;
let mut debuginfo_level_rustc = None;
let mut debuginfo_level_std = None;
Expand Down Expand Up @@ -560,6 +563,7 @@ impl Config {
if let Some(ref rust) = toml.rust {
debug = rust.debug;
debug_assertions = rust.debug_assertions;
debug_assertions_std = rust.debug_assertions_std;
debuginfo_level = rust.debuginfo_level;
debuginfo_level_rustc = rust.debuginfo_level_rustc;
debuginfo_level_std = rust.debuginfo_level_std;
Expand Down Expand Up @@ -658,6 +662,8 @@ impl Config {

let default = debug == Some(true);
config.rust_debug_assertions = debug_assertions.unwrap_or(default);
config.rust_debug_assertions_std =
debug_assertions_std.unwrap_or(config.rust_debug_assertions);

let with_defaults = |debuginfo_level_specific: Option<u32>| {
debuginfo_level_specific.or(debuginfo_level).unwrap_or(if debug == Some(true) {
Expand Down
14 changes: 14 additions & 0 deletions src/bootstrap/flags.rs
Expand Up @@ -503,6 +503,20 @@ Arguments:
}
};

if let Subcommand::Check { .. } = &cmd {
if matches.opt_str("stage").is_some() {
println!("{}", "--stage not supported for x.py check, always treated as stage 0");
process::exit(1);
}
if matches.opt_str("keep-stage").is_some() {
println!(
"{}",
"--keep-stage not supported for x.py check, only one stage available"
);
process::exit(1);
}
}

Flags {
verbose: matches.opt_count("verbose"),
stage: matches.opt_str("stage").map(|j| j.parse().expect("`stage` should be a number")),
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_ast_passes/node_count.rs
@@ -1,4 +1,4 @@
// Simply gives a rought count of the number of nodes in an AST.
// Simply gives a rough count of the number of nodes in an AST.

use rustc_ast::ast::*;
use rustc_ast::visit::*;
Expand Down
25 changes: 25 additions & 0 deletions src/librustc_codegen_ssa/back/link.rs
Expand Up @@ -1179,6 +1179,28 @@ fn add_pre_link_args(
cmd.args(&sess.opts.debugging_opts.pre_link_args);
}

/// Add a link script embedded in the target, if applicable.
fn add_link_script(cmd: &mut dyn Linker, sess: &Session, tmpdir: &Path, crate_type: CrateType) {
match (crate_type, &sess.target.target.options.link_script) {
(CrateType::Cdylib | CrateType::Executable, Some(script)) => {
if !sess.target.target.options.linker_is_gnu {
sess.fatal("can only use link script when linking with GNU-like linker");
}

let file_name = ["rustc", &sess.target.target.llvm_target, "linkfile.ld"].join("-");

let path = tmpdir.join(file_name);
if let Err(e) = fs::write(&path, script) {
sess.fatal(&format!("failed to write link script to {}: {}", path.display(), e));
}

cmd.arg("--script");
cmd.arg(path);
}
_ => {}
}
}

/// Add arbitrary "user defined" args defined from command line and by `#[link_args]` attributes.
/// FIXME: Determine where exactly these args need to be inserted.
fn add_user_defined_link_args(
Expand Down Expand Up @@ -1421,6 +1443,9 @@ fn linker_with_args<'a, B: ArchiveBuilder<'a>>(
// NO-OPT-OUT, OBJECT-FILES-MAYBE, CUSTOMIZATION-POINT
add_pre_link_args(cmd, sess, flavor, crate_type);

// NO-OPT-OUT
add_link_script(cmd, sess, tmpdir, crate_type);

// NO-OPT-OUT, OBJECT-FILES-NO, AUDIT-ORDER
if sess.target.target.options.is_like_fuchsia {
let prefix = match sess.opts.debugging_opts.sanitizer {
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_middle/middle/region.rs
Expand Up @@ -4,7 +4,7 @@
//! For more information about how MIR-based region-checking works,
//! see the [rustc dev guide].
//!
//! [rustc dev guide]: https://rustc-dev-guide.rust-lang.org/mir/borrowck.html
//! [rustc dev guide]: https://rustc-dev-guide.rust-lang.org/borrow_check.html

use crate::ich::{NodeIdHashingMode, StableHashingContext};
use crate::ty::{self, DefIdTree, TyCtxt};
Expand Down Expand Up @@ -181,7 +181,7 @@ impl Scope {
// `blk`; reuse span of `blk` and shift `lo`
// forward to end of indexed statement.
//
// (This is the special case aluded to in the
// (This is the special case alluded to in the
// doc-comment for this method)

let stmt_span = blk.stmts[first_statement_index.index()].span;
Expand Down
70 changes: 41 additions & 29 deletions src/librustc_save_analysis/dump_visitor.rs
Expand Up @@ -21,7 +21,7 @@ use rustc_ast::walk_list;
use rustc_ast_pretty::pprust::{bounds_to_string, generic_params_to_string, ty_to_string};
use rustc_data_structures::fx::FxHashSet;
use rustc_hir::def::{DefKind as HirDefKind, Res};
use rustc_hir::def_id::DefId;
use rustc_hir::def_id::{DefId, LocalDefId};
use rustc_middle::span_bug;
use rustc_middle::ty::{self, DefIdTree, TyCtxt};
use rustc_session::config::Input;
Expand Down Expand Up @@ -104,12 +104,10 @@ impl<'l, 'tcx> DumpVisitor<'l, 'tcx> {
self.dumper.analysis()
}

fn nest_tables<F>(&mut self, item_id: NodeId, f: F)
fn nest_tables<F>(&mut self, item_def_id: LocalDefId, f: F)
where
F: FnOnce(&mut Self),
{
let item_def_id = self.tcx.hir().local_def_id_from_node_id(item_id);

let tables = if self.tcx.has_typeck_tables(item_def_id) {
self.tcx.typeck_tables_of(item_def_id)
} else {
Expand Down Expand Up @@ -272,8 +270,9 @@ impl<'l, 'tcx> DumpVisitor<'l, 'tcx> {
) {
debug!("process_method: {}:{}", id, ident);

let hir_id = self.tcx.hir().node_id_to_hir_id(id);
self.nest_tables(id, |v| {
let map = &self.tcx.hir();
let hir_id = map.node_id_to_hir_id(id);
self.nest_tables(map.local_def_id(hir_id), |v| {
if let Some(mut method_data) = v.save_ctxt.get_method_data(id, ident, span) {
v.process_formals(&sig.decl.inputs, &method_data.qualname);
v.process_generic_params(&generics, &method_data.qualname, id);
Expand All @@ -296,7 +295,8 @@ impl<'l, 'tcx> DumpVisitor<'l, 'tcx> {
// start walking from the newly-created definition.
match sig.header.asyncness {
ast::Async::Yes { return_impl_trait_id, .. } => {
v.nest_tables(return_impl_trait_id, |v| v.visit_ty(ret_ty))
let hir_id = map.node_id_to_hir_id(return_impl_trait_id);
v.nest_tables(map.local_def_id(hir_id), |v| v.visit_ty(ret_ty))
}
_ => v.visit_ty(ret_ty),
}
Expand Down Expand Up @@ -364,8 +364,9 @@ impl<'l, 'tcx> DumpVisitor<'l, 'tcx> {
ty_params: &'l ast::Generics,
body: Option<&'l ast::Block>,
) {
let hir_id = self.tcx.hir().node_id_to_hir_id(item.id);
self.nest_tables(item.id, |v| {
let map = &self.tcx.hir();
let hir_id = map.node_id_to_hir_id(item.id);
self.nest_tables(map.local_def_id(hir_id), |v| {
if let Some(fn_data) = v.save_ctxt.get_item_data(item) {
down_cast_data!(fn_data, DefData, item.span);
v.process_formals(&decl.inputs, &fn_data.qualname);
Expand All @@ -389,7 +390,8 @@ impl<'l, 'tcx> DumpVisitor<'l, 'tcx> {
// start walking from the newly-created definition.
match header.asyncness {
ast::Async::Yes { return_impl_trait_id, .. } => {
v.nest_tables(return_impl_trait_id, |v| v.visit_ty(ret_ty))
let hir_id = map.node_id_to_hir_id(return_impl_trait_id);
v.nest_tables(map.local_def_id(hir_id), |v| v.visit_ty(ret_ty))
}
_ => v.visit_ty(ret_ty),
}
Expand All @@ -407,7 +409,7 @@ impl<'l, 'tcx> DumpVisitor<'l, 'tcx> {
expr: Option<&'l ast::Expr>,
) {
let hir_id = self.tcx.hir().node_id_to_hir_id(item.id);
self.nest_tables(item.id, |v| {
self.nest_tables(self.tcx.hir().local_def_id(hir_id), |v| {
if let Some(var_data) = v.save_ctxt.get_item_data(item) {
down_cast_data!(var_data, DefData, item.span);
v.dumper.dump_def(&access_from!(v.save_ctxt, item, hir_id), var_data);
Expand All @@ -427,15 +429,13 @@ impl<'l, 'tcx> DumpVisitor<'l, 'tcx> {
vis: ast::Visibility,
attrs: &'l [Attribute],
) {
let qualname = format!(
"::{}",
self.tcx.def_path_str(self.tcx.hir().local_def_id_from_node_id(id).to_def_id())
);
let hir_id = self.tcx.hir().node_id_to_hir_id(id);
let qualname =
format!("::{}", self.tcx.def_path_str(self.tcx.hir().local_def_id(hir_id).to_def_id()));

if !self.span.filter_generated(ident.span) {
let sig = sig::assoc_const_signature(id, ident.name, typ, expr, &self.save_ctxt);
let span = self.span_from_span(ident.span);
let hir_id = self.tcx.hir().node_id_to_hir_id(id);

self.dumper.dump_def(
&access_from_vis!(self.save_ctxt, vis, hir_id),
Expand All @@ -457,7 +457,7 @@ impl<'l, 'tcx> DumpVisitor<'l, 'tcx> {
}

// walk type and init value
self.nest_tables(id, |v| {
self.nest_tables(self.tcx.hir().local_def_id(hir_id), |v| {
v.visit_ty(typ);
if let Some(expr) = expr {
v.visit_expr(expr);
Expand All @@ -474,10 +474,9 @@ impl<'l, 'tcx> DumpVisitor<'l, 'tcx> {
) {
debug!("process_struct {:?} {:?}", item, item.span);
let name = item.ident.to_string();
let qualname = format!(
"::{}",
self.tcx.def_path_str(self.tcx.hir().local_def_id_from_node_id(item.id).to_def_id())
);
let hir_id = self.tcx.hir().node_id_to_hir_id(item.id);
let qualname =
format!("::{}", self.tcx.def_path_str(self.tcx.hir().local_def_id(hir_id).to_def_id()));

let kind = match item.kind {
ast::ItemKind::Struct(_, _) => DefKind::Struct,
Expand Down Expand Up @@ -509,7 +508,6 @@ impl<'l, 'tcx> DumpVisitor<'l, 'tcx> {

if !self.span.filter_generated(item.ident.span) {
let span = self.span_from_span(item.ident.span);
let hir_id = self.tcx.hir().node_id_to_hir_id(item.id);
self.dumper.dump_def(
&access_from!(self.save_ctxt, item, hir_id),
Def {
Expand All @@ -529,7 +527,7 @@ impl<'l, 'tcx> DumpVisitor<'l, 'tcx> {
);
}

self.nest_tables(item.id, |v| {
self.nest_tables(self.tcx.hir().local_def_id(hir_id), |v| {
for field in def.fields() {
v.process_struct_field_def(field, item.id);
v.visit_ty(&field.ty);
Expand Down Expand Up @@ -669,14 +667,15 @@ impl<'l, 'tcx> DumpVisitor<'l, 'tcx> {
}

let map = &self.tcx.hir();
self.nest_tables(item.id, |v| {
let hir_id = map.node_id_to_hir_id(item.id);
self.nest_tables(map.local_def_id(hir_id), |v| {
v.visit_ty(&typ);
if let &Some(ref trait_ref) = trait_ref {
v.process_path(trait_ref.ref_id, &trait_ref.path);
}
v.process_generic_params(generics, "", item.id);
for impl_item in impl_items {
v.process_impl_item(impl_item, map.local_def_id_from_node_id(item.id).to_def_id());
v.process_impl_item(impl_item, map.local_def_id(hir_id).to_def_id());
}
});
}
Expand Down Expand Up @@ -1411,7 +1410,10 @@ impl<'l, 'tcx> Visitor<'l> for DumpVisitor<'l, 'tcx> {
}
ast::TyKind::Array(ref element, ref length) => {
self.visit_ty(element);
self.nest_tables(length.id, |v| v.visit_expr(&length.value));
let hir_id = self.tcx.hir().node_id_to_hir_id(length.id);
self.nest_tables(self.tcx.hir().local_def_id(hir_id), |v| {
v.visit_expr(&length.value)
});
}
ast::TyKind::ImplTrait(id, ref bounds) => {
// FIXME: As of writing, the opaque type lowering introduces
Expand All @@ -1423,7 +1425,13 @@ impl<'l, 'tcx> Visitor<'l> for DumpVisitor<'l, 'tcx> {
// bounds...
// This will panic if called on return type `impl Trait`, which
// we guard against in `process_fn`.
self.nest_tables(id, |v| v.process_bounds(bounds));
// FIXME(#71104) Should really be using just `node_id_to_hir_id` but
// some `NodeId` do not seem to have a corresponding HirId.
if let Some(hir_id) = self.tcx.hir().opt_node_id_to_hir_id(id) {
self.nest_tables(self.tcx.hir().local_def_id(hir_id), |v| {
v.process_bounds(bounds)
});
}
}
_ => visit::walk_ty(self, t),
}
Expand Down Expand Up @@ -1471,7 +1479,8 @@ impl<'l, 'tcx> Visitor<'l> for DumpVisitor<'l, 'tcx> {
}

// walk the body
self.nest_tables(ex.id, |v| {
let hir_id = self.tcx.hir().node_id_to_hir_id(ex.id);
self.nest_tables(self.tcx.hir().local_def_id(hir_id), |v| {
v.process_formals(&decl.inputs, &id);
v.visit_expr(body)
});
Expand All @@ -1488,7 +1497,10 @@ impl<'l, 'tcx> Visitor<'l> for DumpVisitor<'l, 'tcx> {
}
ast::ExprKind::Repeat(ref element, ref count) => {
self.visit_expr(element);
self.nest_tables(count.id, |v| v.visit_expr(&count.value));
let hir_id = self.tcx.hir().node_id_to_hir_id(count.id);
self.nest_tables(self.tcx.hir().local_def_id(hir_id), |v| {
v.visit_expr(&count.value)
});
}
// In particular, we take this branch for call and path expressions,
// where we'll index the idents involved just by continuing to walk.
Expand Down
43 changes: 43 additions & 0 deletions src/librustc_target/spec/mipsel_sony_psp.rs
@@ -0,0 +1,43 @@
use crate::spec::{LinkArgs, LinkerFlavor, LldFlavor, RelocModel};
use crate::spec::{Target, TargetOptions, TargetResult};

// The PSP has custom linker requirements.
const LINKER_SCRIPT: &str = include_str!("./mipsel_sony_psp_linker_script.ld");

pub fn target() -> TargetResult {
let mut pre_link_args = LinkArgs::new();
pre_link_args.insert(
LinkerFlavor::Lld(LldFlavor::Ld),
vec!["--eh-frame-hdr".to_string(), "--emit-relocs".to_string()],
);

Ok(Target {
llvm_target: "mipsel-sony-psp".to_string(),
target_endian: "little".to_string(),
target_pointer_width: "32".to_string(),
target_c_int_width: "32".to_string(),
data_layout: "e-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64".to_string(),
arch: "mips".to_string(),
target_os: "psp".to_string(),
target_env: "".to_string(),
target_vendor: "sony".to_string(),
linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld),

options: TargetOptions {
cpu: "mips2".to_string(),
executables: true,
linker: Some("rust-lld".to_owned()),
linker_is_gnu: true,
relocation_model: RelocModel::Static,

// PSP FPU only supports single precision floats.
features: "+single-float".to_string(),

// PSP does not support trap-on-condition instructions.
llvm_args: vec!["-mno-check-zero-division".to_string()],
pre_link_args,
link_script: Some(LINKER_SCRIPT.to_string()),
..Default::default()
},
})
}

0 comments on commit 0271499

Please sign in to comment.