Skip to content

Commit

Permalink
Auto merge of rust-lang#122303 - matthiaskrgr:rollup-ieokhnz, r=matth…
Browse files Browse the repository at this point in the history
…iaskrgr

Rollup of 8 pull requests

Successful merges:

 - rust-lang#121754 ([bootstrap] Move the `split-debuginfo` setting to the per-target section)
 - rust-lang#122205 (ensure that sysroot is properly set for cross-targets)
 - rust-lang#122275 (disable OOM test in Miri)
 - rust-lang#122276 (io::Read trait: make it more clear when we are adressing implementations vs callers)
 - rust-lang#122286 (use Instance::expect_resolve() instead of unwraping Instance::resolve())
 - rust-lang#122290 (MIR printing: print the path of uneval'd const)
 - rust-lang#122293 (diagnostics: Do not suggest using `#[unix_sigpipe]` without a value)
 - rust-lang#122297 (bootstrap: document what the triples in 'Build' mean)

r? `@ghost`
`@rustbot` modify labels: rollup
  • Loading branch information
bors committed Mar 10, 2024
2 parents af69f4c + c770ce4 commit ffc7900
Show file tree
Hide file tree
Showing 98 changed files with 230 additions and 186 deletions.
8 changes: 2 additions & 6 deletions compiler/rustc_codegen_cranelift/src/main_shim.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,12 @@ pub(crate) fn maybe_create_entry_wrapper(
termination_trait,
)
.unwrap();
let report = Instance::resolve(
let report = Instance::expect_resolve(
tcx,
ParamEnv::reveal_all(),
report.def_id,
tcx.mk_args(&[GenericArg::from(main_ret_ty)]),
)
.unwrap()
.unwrap()
.polymorphize(tcx);

let report_name = tcx.symbol_name(report).name;
Expand All @@ -142,14 +140,12 @@ pub(crate) fn maybe_create_entry_wrapper(
}
} else if is_main_fn {
let start_def_id = tcx.require_lang_item(LangItem::Start, None);
let start_instance = Instance::resolve(
let start_instance = Instance::expect_resolve(
tcx,
ParamEnv::reveal_all(),
start_def_id,
tcx.mk_args(&[main_ret_ty.into()]),
)
.unwrap()
.unwrap()
.polymorphize(tcx);
let start_func_id = import_function(tcx, m, start_instance);

Expand Down
6 changes: 2 additions & 4 deletions compiler/rustc_codegen_gcc/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -473,14 +473,12 @@ impl<'gcc, 'tcx> MiscMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
let tcx = self.tcx;
let func = match tcx.lang_items().eh_personality() {
Some(def_id) if !wants_msvc_seh(self.sess()) => {
let instance = ty::Instance::resolve(
let instance = ty::Instance::expect_resolve(
tcx,
ty::ParamEnv::reveal_all(),
def_id,
ty::List::empty(),
)
.unwrap()
.unwrap();
);

let symbol_name = tcx.symbol_name(instance).name;
let fn_abi = self.fn_abi_of_instance(instance, ty::List::empty());
Expand Down
11 changes: 6 additions & 5 deletions compiler/rustc_codegen_llvm/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -558,11 +558,12 @@ impl<'ll, 'tcx> MiscMethods<'tcx> for CodegenCx<'ll, 'tcx> {

let tcx = self.tcx;
let llfn = match tcx.lang_items().eh_personality() {
Some(def_id) if name.is_none() => self.get_fn_addr(
ty::Instance::resolve(tcx, ty::ParamEnv::reveal_all(), def_id, ty::List::empty())
.unwrap()
.unwrap(),
),
Some(def_id) if name.is_none() => self.get_fn_addr(ty::Instance::expect_resolve(
tcx,
ty::ParamEnv::reveal_all(),
def_id,
ty::List::empty(),
)),
_ => {
let name = name.unwrap_or("rust_eh_personality");
if let Some(llfn) = self.get_declared_value(name) {
Expand Down
16 changes: 6 additions & 10 deletions compiler/rustc_codegen_ssa/src/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -467,16 +467,12 @@ pub fn maybe_create_entry_wrapper<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(

let (start_fn, start_ty, args) = if let EntryFnType::Main { sigpipe } = entry_type {
let start_def_id = cx.tcx().require_lang_item(LangItem::Start, None);
let start_fn = cx.get_fn_addr(
ty::Instance::resolve(
cx.tcx(),
ty::ParamEnv::reveal_all(),
start_def_id,
cx.tcx().mk_args(&[main_ret_ty.into()]),
)
.unwrap()
.unwrap(),
);
let start_fn = cx.get_fn_addr(ty::Instance::expect_resolve(
cx.tcx(),
ty::ParamEnv::reveal_all(),
start_def_id,
cx.tcx().mk_args(&[main_ret_ty.into()]),
));

let i8_ty = cx.type_i8();
let arg_sigpipe = bx.const_u8(sigpipe);
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_const_eval/src/const_eval/eval_queries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ fn eval_body_using_ecx<'mir, 'tcx>(
trace!(
"eval_body_using_ecx: pushing stack frame for global: {}{}",
with_no_trimmed_paths!(ecx.tcx.def_path_str(cid.instance.def_id())),
cid.promoted.map_or_else(String::new, |p| format!("::promoted[{p:?}]"))
cid.promoted.map_or_else(String::new, |p| format!("::{p:?}"))
);

ecx.push_stack_frame(
Expand Down
6 changes: 2 additions & 4 deletions compiler/rustc_const_eval/src/const_eval/machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,14 +243,12 @@ impl<'mir, 'tcx: 'mir> CompileTimeEvalContext<'mir, 'tcx> {
} else if Some(def_id) == self.tcx.lang_items().panic_fmt() {
// For panic_fmt, call const_panic_fmt instead.
let const_def_id = self.tcx.require_lang_item(LangItem::ConstPanicFmt, None);
let new_instance = ty::Instance::resolve(
let new_instance = ty::Instance::expect_resolve(
*self.tcx,
ty::ParamEnv::reveal_all(),
const_def_id,
instance.args,
)
.unwrap()
.unwrap();
);

return Ok(Some(new_instance));
} else if Some(def_id) == self.tcx.lang_items().align_offset_fn() {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_feature/src/builtin_attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
),

// Entry point:
gated!(unix_sigpipe, Normal, template!(Word, NameValueStr: "inherit|sig_ign|sig_dfl"), ErrorFollowing, experimental!(unix_sigpipe)),
gated!(unix_sigpipe, Normal, template!(NameValueStr: "inherit|sig_ign|sig_dfl"), ErrorFollowing, experimental!(unix_sigpipe)),
ungated!(start, Normal, template!(Word), WarnFollowing, @only_local: true),
ungated!(no_start, CrateLevel, template!(Word), WarnFollowing, @only_local: true),
ungated!(no_main, CrateLevel, template!(Word), WarnFollowing, @only_local: true),
Expand Down
16 changes: 13 additions & 3 deletions compiler/rustc_middle/src/mir/consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use rustc_target::abi::{HasDataLayout, Size};

use crate::mir::interpret::{alloc_range, AllocId, ConstAllocation, ErrorHandled, Scalar};
use crate::mir::{pretty_print_const_value, Promoted};
use crate::ty::print::with_no_trimmed_paths;
use crate::ty::GenericArgsRef;
use crate::ty::ScalarInt;
use crate::ty::{self, print::pretty_print_const, Ty, TyCtxt};
Expand Down Expand Up @@ -489,9 +490,18 @@ impl<'tcx> Display for Const<'tcx> {
Const::Ty(c) => pretty_print_const(c, fmt, true),
Const::Val(val, ty) => pretty_print_const_value(val, ty, fmt),
// FIXME(valtrees): Correctly print mir constants.
Const::Unevaluated(..) => {
fmt.write_str("_")?;
Ok(())
Const::Unevaluated(c, _ty) => {
ty::tls::with(move |tcx| {
let c = tcx.lift(c).unwrap();
// Matches `GlobalId` printing.
let instance =
with_no_trimmed_paths!(tcx.def_path_str_with_args(c.def, c.args));
write!(fmt, "{instance}")?;
if let Some(promoted) = c.promoted {
write!(fmt, "::{promoted:?}")?;
}
Ok(())
})
}
}
}
Expand Down
5 changes: 4 additions & 1 deletion compiler/rustc_middle/src/mir/pretty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ fn write_mir_sig(tcx: TyCtxt<'_>, body: &Body<'_>, w: &mut dyn io::Write) -> io:
_ => tcx.is_closure_like(def_id),
};
match (kind, body.source.promoted) {
(_, Some(i)) => write!(w, "{i:?} in ")?,
(_, Some(_)) => write!(w, "const ")?, // promoteds are the closest to consts
(DefKind::Const | DefKind::AssocConst, _) => write!(w, "const ")?,
(DefKind::Static(hir::Mutability::Not), _) => write!(w, "static ")?,
(DefKind::Static(hir::Mutability::Mut), _) => write!(w, "static mut ")?,
Expand All @@ -509,6 +509,9 @@ fn write_mir_sig(tcx: TyCtxt<'_>, body: &Body<'_>, w: &mut dyn io::Write) -> io:
// see notes on #41697 elsewhere
write!(w, "{}", tcx.def_path_str(def_id))?
}
if let Some(p) = body.source.promoted {
write!(w, "::{p:?}")?;
}

if body.source.promoted.is_none() && is_function {
write!(w, "(")?;
Expand Down
6 changes: 2 additions & 4 deletions compiler/rustc_monomorphize/src/collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1339,14 +1339,12 @@ impl<'v> RootCollector<'_, 'v> {
main_ret_ty.no_bound_vars().unwrap(),
);

let start_instance = Instance::resolve(
let start_instance = Instance::expect_resolve(
self.tcx,
ty::ParamEnv::reveal_all(),
start_def_id,
self.tcx.mk_args(&[main_ret_ty.into()]),
)
.unwrap()
.unwrap();
);

self.output.push(create_fn_mono_item(self.tcx, start_instance, DUMMY_SP));
}
Expand Down
8 changes: 4 additions & 4 deletions compiler/rustc_passes/src/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,13 +156,13 @@ fn sigpipe(tcx: TyCtxt<'_>, def_id: DefId) -> u8 {
(Some(sym::inherit), None) => sigpipe::INHERIT,
(Some(sym::sig_ign), None) => sigpipe::SIG_IGN,
(Some(sym::sig_dfl), None) => sigpipe::SIG_DFL,
(_, Some(_)) => {
// Keep going so that `fn emit_malformed_attribute()` can print
// an excellent error message
(Some(_), None) => {
tcx.dcx().emit_err(UnixSigpipeValues { span: attr.span });
sigpipe::DEFAULT
}
_ => {
tcx.dcx().emit_err(UnixSigpipeValues { span: attr.span });
// Keep going so that `fn emit_malformed_attribute()` can print
// an excellent error message
sigpipe::DEFAULT
}
}
Expand Down
40 changes: 26 additions & 14 deletions config.example.toml
Original file line number Diff line number Diff line change
Expand Up @@ -543,23 +543,15 @@
# FIXME(#61117): Some tests fail when this option is enabled.
#debuginfo-level-tests = 0

# Should rustc be build with split debuginfo? Default is platform dependent.
# Valid values are the same as those accepted by `-C split-debuginfo`
# (`off`/`unpacked`/`packed`).
# Should rustc and the standard library be built with split debuginfo? Default
# is platform dependent.
#
# On Linux, split debuginfo is disabled by default.
# This field is deprecated, use `target.<triple>.split-debuginfo` instead.
#
# On Apple platforms, unpacked split debuginfo is used by default. Unpacked
# debuginfo does not run `dsymutil`, which packages debuginfo from disparate
# object files into a single `.dSYM` file. `dsymutil` adds time to builds for
# no clear benefit, and also makes it more difficult for debuggers to find
# debug info. The compiler currently defaults to running `dsymutil` to preserve
# its historical default, but when compiling the compiler itself, we skip it by
# default since we know it's safe to do so in that case.
# The value specified here is only used when targeting the `build.build` triple,
# and is overridden by `target.<triple>.split-debuginfo` if specified.
#
# On Windows platforms, packed debuginfo is the only supported option,
# producing a `.pdb` file.
#split-debuginfo = if linux { off } else if windows { packed } else if apple { unpacked }
#split-debuginfo = see target.<triple>.split-debuginfo

# Whether or not `panic!`s generate backtraces (RUST_BACKTRACE)
#backtrace = true
Expand Down Expand Up @@ -769,6 +761,26 @@
# Setting this will override the `use-lld` option for Rust code when targeting MSVC.
#linker = "cc" (path)

# Should rustc and the standard library be built with split debuginfo? Default
# is platform dependent.
#
# Valid values are the same as those accepted by `-C split-debuginfo`
# (`off`/`unpacked`/`packed`).
#
# On Linux, split debuginfo is disabled by default.
#
# On Apple platforms, unpacked split debuginfo is used by default. Unpacked
# debuginfo does not run `dsymutil`, which packages debuginfo from disparate
# object files into a single `.dSYM` file. `dsymutil` adds time to builds for
# no clear benefit, and also makes it more difficult for debuggers to find
# debug info. The compiler currently defaults to running `dsymutil` to preserve
# its historical default, but when compiling the compiler itself, we skip it by
# default since we know it's safe to do so in that case.
#
# On Windows platforms, packed debuginfo is the only supported option,
# producing a `.pdb` file.
#split-debuginfo = if linux { off } else if windows { packed } else if apple { unpacked }

# Path to the `llvm-config` binary of the installation of a custom LLVM to link
# against. Note that if this is specified we don't compile LLVM at all for this
# target.
Expand Down
17 changes: 7 additions & 10 deletions library/std/src/io/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -692,10 +692,9 @@ pub trait Read {
/// Callers have to ensure that no unchecked out-of-bounds accesses are possible even if
/// `n > buf.len()`.
///
/// No guarantees are provided about the contents of `buf` when this
/// function is called, so implementations cannot rely on any property of the
/// contents of `buf` being true. It is recommended that *implementations*
/// only write data to `buf` instead of reading its contents.
/// *Implementations* of this method can make no assumptions about the contents of `buf` when
/// this function is called. It is recommended that implementations only write data to `buf`
/// instead of reading its contents.
///
/// Correspondingly, however, *callers* of this method in unsafe code must not assume
/// any guarantees about how the implementation uses `buf`. The trait is safe to implement,
Expand Down Expand Up @@ -901,12 +900,10 @@ pub trait Read {
/// This function reads as many bytes as necessary to completely fill the
/// specified buffer `buf`.
///
/// No guarantees are provided about the contents of `buf` when this
/// function is called, so implementations cannot rely on any property of the
/// contents of `buf` being true. It is recommended that implementations
/// only write data to `buf` instead of reading its contents. The
/// documentation on [`read`] has a more detailed explanation on this
/// subject.
/// *Implementations* of this method can make no assumptions about the contents of `buf` when
/// this function is called. It is recommended that implementations only write data to `buf`
/// instead of reading its contents. The documentation on [`read`] has a more detailed
/// explanation of this subject.
///
/// # Errors
///
Expand Down
2 changes: 2 additions & 0 deletions library/std/src/io/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -694,6 +694,8 @@ fn read_buf_full_read() {
}

#[test]
// Miri does not support signalling OOM
#[cfg_attr(miri, ignore)]
// 64-bit only to be sure the allocator will fail fast on an impossible to satsify size
#[cfg(target_pointer_width = "64")]
fn try_oom_error() {
Expand Down
6 changes: 6 additions & 0 deletions src/bootstrap/src/core/build_steps/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2580,6 +2580,12 @@ impl Step for Crate {
// we're working with automatically.
let compiler = builder.compiler_for(compiler.stage, compiler.host, target);

// During cross compilations, sysroot for the target may not be available.
// Ensure that it is prepared.
if builder.config.build != target {
builder.ensure(compile::Rustc::new(compiler, target));
}

let mut cargo = builder::Cargo::new(
builder,
compiler,
Expand Down
7 changes: 4 additions & 3 deletions src/bootstrap/src/core/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1730,15 +1730,16 @@ impl<'a> Builder<'a> {
},
);

let split_debuginfo = self.config.split_debuginfo(target);
let split_debuginfo_is_stable = target.contains("linux")
|| target.contains("apple")
|| (target.is_msvc() && self.config.rust_split_debuginfo == SplitDebuginfo::Packed)
|| (target.is_windows() && self.config.rust_split_debuginfo == SplitDebuginfo::Off);
|| (target.is_msvc() && split_debuginfo == SplitDebuginfo::Packed)
|| (target.is_windows() && split_debuginfo == SplitDebuginfo::Off);

if !split_debuginfo_is_stable {
rustflags.arg("-Zunstable-options");
}
match self.config.rust_split_debuginfo {
match split_debuginfo {
SplitDebuginfo::Packed => rustflags.arg("-Csplit-debuginfo=packed"),
SplitDebuginfo::Unpacked => rustflags.arg("-Csplit-debuginfo=unpacked"),
SplitDebuginfo::Off => rustflags.arg("-Csplit-debuginfo=off"),
Expand Down
Loading

0 comments on commit ffc7900

Please sign in to comment.