Skip to content

Rollup of 11 pull requests #143582

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

Merged
merged 31 commits into from
Jul 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
12bc409
Get rid of build-powerpc64le-toolchain.sh
Gelbpunkt Jul 4, 2025
57d989b
Fixed the ABI parameter inconsistency issue in debug.rs for the riscv…
YingkaiLi-VM Jun 3, 2025
64bec0f
Fix tests/ui/abi/debug.rs to cross-compile for riscv64
workingjubilee Jul 5, 2025
db0b491
Fix short linker error output
ia0 Jul 5, 2025
c42a9ac
move `stable_mir` back to its own crate and move `rustc_internal` to …
makai410 Jul 5, 2025
7775166
interpret: rename StackPopCleanup
RalfJung Jul 6, 2025
4bdd671
Update run-make test
ia0 Jul 6, 2025
a40274d
Dont resolve instance of root in mir_callgraph_cyclic
compiler-errors Jul 6, 2025
627cefa
remove `rustc_smir` from tests
makai410 Jul 6, 2025
8d5eb6b
mbe: Simplify compile_declarative_macro by factoring out some variables
joshtriplett Jul 6, 2025
87cd178
mbe: Factor out a helper to check an LHS
joshtriplett Jul 6, 2025
493cdf2
mbe: Factor out a helper to check for unexpected EOF in definition
joshtriplett Jul 6, 2025
ef0465a
mbe: Clarify comments about error handling in `compile_declarative_ma…
joshtriplett Jul 7, 2025
22342b0
doc(std): clarify `NonZero<T>` usage limitation in doc comment
xizheyin Jun 28, 2025
cdbdd8a
Reverse comparison order
ia0 Jul 7, 2025
2765bd4
std: fix typo in `std::path`
xizheyin Jul 7, 2025
1eff043
rustc_codegen_llvm: Remove reference to non-existing `no_landing_pads()`
Enselic Jul 7, 2025
aa364ca
compiler: Deduplicate `must_emit_unwind_tables()` comments
Enselic Jul 7, 2025
9adbf62
Disable download-rustc for library profile
Noratrieb Jul 7, 2025
979d7b2
Add change tracker entry for disabling `download-rustc` temporarily
jieyouxu Jul 7, 2025
0742569
Rollup merge of #143130 - xizheyin:142966, r=ibraheemdev
jieyouxu Jul 7, 2025
9c6ef43
Rollup merge of #143415 - Gelbpunkt:cleanup-dist-ppc64le-toolchain, r…
jieyouxu Jul 7, 2025
fc13c96
Rollup merge of #143464 - workingjubilee:make-debug-rs-cross-compile,…
jieyouxu Jul 7, 2025
4ba4b5f
Rollup merge of #143482 - ia0:fix, r=fee1-dead
jieyouxu Jul 7, 2025
02aa4ff
Rollup merge of #143524 - makai410:smir-move-back, r=oli-obk
jieyouxu Jul 7, 2025
eed5594
Rollup merge of #143528 - RalfJung:stack-pop-cleanup, r=oli-obk
jieyouxu Jul 7, 2025
b6015a6
Rollup merge of #143551 - compiler-errors:root-sub, r=cjgillot
jieyouxu Jul 7, 2025
4be8c49
Rollup merge of #143558 - joshtriplett:mbe-refactors, r=SparrowLii
jieyouxu Jul 7, 2025
e366f16
Rollup merge of #143563 - xizheyin:fix-typo, r=joshtriplett
jieyouxu Jul 7, 2025
0938cb7
Rollup merge of #143564 - Enselic:must_emit_unwind_tables-comment, r=…
jieyouxu Jul 7, 2025
364dbd6
Rollup merge of #143577 - Noratrieb:Noratrieb-patch-4, r=Kobzol
jieyouxu Jul 7, 2025
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
12 changes: 9 additions & 3 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4553,9 +4553,6 @@ dependencies = [
"rustc_session",
"rustc_span",
"rustc_target",
"scoped-tls",
"serde",
"tracing",
]

[[package]]
Expand Down Expand Up @@ -5108,7 +5105,16 @@ checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3"
name = "stable_mir"
version = "0.1.0-preview"
dependencies = [
"rustc_abi",
"rustc_hir",
"rustc_middle",
"rustc_session",
"rustc_smir",
"rustc_span",
"rustc_target",
"scoped-tls",
"serde",
"tracing",
]

[[package]]
Expand Down
16 changes: 0 additions & 16 deletions compiler/rustc_codegen_llvm/src/attributes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -370,22 +370,6 @@ pub(crate) fn llfn_attrs_from_instance<'ll, 'tcx>(
};
to_add.extend(inline_attr(cx, inline));

// The `uwtable` attribute according to LLVM is:
//
// This attribute indicates that the ABI being targeted requires that an
// unwind table entry be produced for this function even if we can show
// that no exceptions passes by it. This is normally the case for the
// ELF x86-64 abi, but it can be disabled for some compilation units.
//
// Typically when we're compiling with `-C panic=abort` (which implies this
// `no_landing_pads` check) we don't need `uwtable` because we can't
// generate any exceptions! On Windows, however, exceptions include other
// events such as illegal instructions, segfaults, etc. This means that on
// Windows we end up still needing the `uwtable` attribute even if the `-C
// panic=abort` flag is passed.
//
// You can also find more info on why Windows always requires uwtables here:
// https://bugzilla.mozilla.org/show_bug.cgi?id=1302078
if cx.sess().must_emit_unwind_tables() {
to_add.push(uwtable_attr(cx.llcx, cx.sess().opts.unstable_opts.use_sync_unwind));
}
Expand Down
15 changes: 11 additions & 4 deletions compiler/rustc_codegen_ssa/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ impl<G: EmissionGuarantee> Diagnostic<'_, G> for LinkingFailed<'_> {
} else if arg.as_encoded_bytes().ends_with(b".rlib") {
let rlib_path = Path::new(&arg);
let dir = rlib_path.parent().unwrap();
let filename = rlib_path.file_name().unwrap().to_owned();
let filename = rlib_path.file_stem().unwrap().to_owned();
if let Some(ArgGroup::Rlibs(parent, rlibs)) = args.last_mut() {
if parent == dir {
rlibs.push(filename);
Expand All @@ -471,7 +471,7 @@ impl<G: EmissionGuarantee> Diagnostic<'_, G> for LinkingFailed<'_> {
args.push(ArgGroup::Regular(arg));
}
}
let crate_hash = regex::bytes::Regex::new(r"-[0-9a-f]+\.rlib$").unwrap();
let crate_hash = regex::bytes::Regex::new(r"-[0-9a-f]+").unwrap();
self.command.args(args.into_iter().map(|arg_group| {
match arg_group {
// SAFETY: we are only matching on ASCII, not any surrogate pairs, so any replacements we do will still be valid.
Expand All @@ -494,7 +494,11 @@ impl<G: EmissionGuarantee> Diagnostic<'_, G> for LinkingFailed<'_> {
Err(_) => false,
};
let mut arg = dir.into_os_string();
arg.push("/{");
arg.push("/");
let needs_braces = rlibs.len() >= 2;
if needs_braces {
arg.push("{");
}
let mut first = true;
for mut rlib in rlibs {
if !first {
Expand All @@ -513,7 +517,10 @@ impl<G: EmissionGuarantee> Diagnostic<'_, G> for LinkingFailed<'_> {
}
arg.push(rlib);
}
arg.push("}.rlib");
if needs_braces {
arg.push("}");
}
arg.push(".rlib");
arg
}
}
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_const_eval/src/const_eval/eval_queries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use super::{CanAccessMutGlobal, CompileTimeInterpCx, CompileTimeMachine};
use crate::const_eval::CheckAlignment;
use crate::interpret::{
CtfeValidationMode, GlobalId, Immediate, InternKind, InternResult, InterpCx, InterpErrorKind,
InterpResult, MPlaceTy, MemoryKind, OpTy, RefTracking, StackPopCleanup, create_static_alloc,
InterpResult, MPlaceTy, MemoryKind, OpTy, RefTracking, ReturnContinuation, create_static_alloc,
intern_const_alloc_recursive, interp_ok, throw_exhaust,
};
use crate::{CTRL_C_RECEIVED, errors};
Expand Down Expand Up @@ -76,7 +76,7 @@ fn eval_body_using_ecx<'tcx, R: InterpretationResult<'tcx>>(
cid.instance,
body,
&ret.clone().into(),
StackPopCleanup::Root { cleanup: false },
ReturnContinuation::Stop { cleanup: false },
)?;
ecx.storage_live_for_always_live_locals()?;

Expand Down
36 changes: 18 additions & 18 deletions compiler/rustc_const_eval/src/interpret/call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use tracing::{info, instrument, trace};

use super::{
CtfeProvenance, FnVal, ImmTy, InterpCx, InterpResult, MPlaceTy, Machine, OpTy, PlaceTy,
Projectable, Provenance, ReturnAction, Scalar, StackPopCleanup, StackPopInfo, interp_ok,
Projectable, Provenance, ReturnAction, ReturnContinuation, Scalar, StackPopInfo, interp_ok,
throw_ub, throw_ub_custom, throw_unsup_format,
};
use crate::fluent_generated as fluent;
Expand Down Expand Up @@ -340,7 +340,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
args: &[FnArg<'tcx, M::Provenance>],
with_caller_location: bool,
destination: &PlaceTy<'tcx, M::Provenance>,
mut stack_pop: StackPopCleanup,
mut cont: ReturnContinuation,
) -> InterpResult<'tcx> {
// Compute callee information.
// FIXME: for variadic support, do we have to somehow determine callee's extra_args?
Expand All @@ -365,15 +365,15 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {

if !callee_fn_abi.can_unwind {
// The callee cannot unwind, so force the `Unreachable` unwind handling.
match &mut stack_pop {
StackPopCleanup::Root { .. } => {}
StackPopCleanup::Goto { unwind, .. } => {
match &mut cont {
ReturnContinuation::Stop { .. } => {}
ReturnContinuation::Goto { unwind, .. } => {
*unwind = mir::UnwindAction::Unreachable;
}
}
}

self.push_stack_frame_raw(instance, body, destination, stack_pop)?;
self.push_stack_frame_raw(instance, body, destination, cont)?;

// If an error is raised here, pop the frame again to get an accurate backtrace.
// To this end, we wrap it all in a `try` block.
Expand Down Expand Up @@ -617,7 +617,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
&args,
with_caller_location,
destination,
StackPopCleanup::Goto { ret: target, unwind },
ReturnContinuation::Goto { ret: target, unwind },
)
}
// `InstanceKind::Virtual` does not have callable MIR. Calls to `Virtual` instances must be
Expand Down Expand Up @@ -755,16 +755,16 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
// Note that we are using `pop_stack_frame_raw` and not `return_from_current_stack_frame`,
// as the latter "executes" the goto to the return block, but we don't want to,
// only the tail called function should return to the current return block.
let StackPopInfo { return_action, return_to_block, return_place } = self
.pop_stack_frame_raw(false, |_this, _return_place| {
let StackPopInfo { return_action, return_cont, return_place } =
self.pop_stack_frame_raw(false, |_this, _return_place| {
// This function's return value is just discarded, the tail-callee will fill in the return place instead.
interp_ok(())
})?;

assert_eq!(return_action, ReturnAction::Normal);

// Take the "stack pop cleanup" info, and use that to initiate the next call.
let StackPopCleanup::Goto { ret, unwind } = return_to_block else {
let ReturnContinuation::Goto { ret, unwind } = return_cont else {
bug!("can't tailcall as root");
};

Expand Down Expand Up @@ -896,23 +896,23 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
// Normal return, figure out where to jump.
if unwinding {
// Follow the unwind edge.
match stack_pop_info.return_to_block {
StackPopCleanup::Goto { unwind, .. } => {
match stack_pop_info.return_cont {
ReturnContinuation::Goto { unwind, .. } => {
// This must be the very last thing that happens, since it can in fact push a new stack frame.
self.unwind_to_block(unwind)
}
StackPopCleanup::Root { .. } => {
panic!("encountered StackPopCleanup::Root when unwinding!")
ReturnContinuation::Stop { .. } => {
panic!("encountered ReturnContinuation::Stop when unwinding!")
}
}
} else {
// Follow the normal return edge.
match stack_pop_info.return_to_block {
StackPopCleanup::Goto { ret, .. } => self.return_to_block(ret),
StackPopCleanup::Root { .. } => {
match stack_pop_info.return_cont {
ReturnContinuation::Goto { ret, .. } => self.return_to_block(ret),
ReturnContinuation::Stop { .. } => {
assert!(
self.stack().is_empty(),
"only the bottommost frame can have StackPopCleanup::Root"
"only the bottommost frame can have ReturnContinuation::Stop"
);
interp_ok(())
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_const_eval/src/interpret/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ pub use self::operand::{ImmTy, Immediate, OpTy};
pub use self::place::{MPlaceTy, MemPlaceMeta, PlaceTy, Writeable};
use self::place::{MemPlace, Place};
pub use self::projection::{OffsetMode, Projectable};
pub use self::stack::{Frame, FrameInfo, LocalState, StackPopCleanup, StackPopInfo};
pub use self::stack::{Frame, FrameInfo, LocalState, ReturnContinuation, StackPopInfo};
pub(crate) use self::util::create_static_alloc;
pub use self::validity::{CtfeValidationMode, RangeSet, RefTracking};
pub use self::visitor::ValueVisitor;
38 changes: 19 additions & 19 deletions compiler/rustc_const_eval/src/interpret/stack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ pub struct Frame<'tcx, Prov: Provenance = CtfeProvenance, Extra = ()> {
////////////////////////////////////////////////////////////////////////////////
// Return place and locals
////////////////////////////////////////////////////////////////////////////////
/// Work to perform when returning from this function.
return_to_block: StackPopCleanup,
/// Where to continue when returning from this function.
return_cont: ReturnContinuation,

/// The location where the result of the current stack frame should be written to,
/// and its layout in the caller. This place is to be interpreted relative to the
Expand Down Expand Up @@ -106,19 +106,19 @@ pub struct Frame<'tcx, Prov: Provenance = CtfeProvenance, Extra = ()> {
pub(super) loc: Either<mir::Location, Span>,
}

/// Where and how to continue when returning/unwinding from the current function.
#[derive(Clone, Copy, Eq, PartialEq, Debug)] // Miri debug-prints these
pub enum StackPopCleanup {
pub enum ReturnContinuation {
/// Jump to the next block in the caller, or cause UB if None (that's a function
/// that may never return). Also store layout of return place so
/// we can validate it at that layout.
/// that may never return).
/// `ret` stores the block we jump to on a normal return, while `unwind`
/// stores the block used for cleanup during unwinding.
Goto { ret: Option<mir::BasicBlock>, unwind: mir::UnwindAction },
/// The root frame of the stack: nowhere else to jump to.
/// The root frame of the stack: nowhere else to jump to, so we stop.
/// `cleanup` says whether locals are deallocated. Static computation
/// wants them leaked to intern what they need (and just throw away
/// the entire `ecx` when it is done).
Root { cleanup: bool },
Stop { cleanup: bool },
}

/// Return type of [`InterpCx::pop_stack_frame_raw`].
Expand All @@ -127,8 +127,8 @@ pub struct StackPopInfo<'tcx, Prov: Provenance> {
/// stack frame.
pub return_action: ReturnAction,

/// [`return_to_block`](Frame::return_to_block) of the popped stack frame.
pub return_to_block: StackPopCleanup,
/// [`return_cont`](Frame::return_cont) of the popped stack frame.
pub return_cont: ReturnContinuation,

/// [`return_place`](Frame::return_place) of the popped stack frame.
pub return_place: PlaceTy<'tcx, Prov>,
Expand Down Expand Up @@ -255,7 +255,7 @@ impl<'tcx, Prov: Provenance> Frame<'tcx, Prov> {
Frame {
body: self.body,
instance: self.instance,
return_to_block: self.return_to_block,
return_cont: self.return_cont,
return_place: self.return_place,
locals: self.locals,
loc: self.loc,
Expand Down Expand Up @@ -350,20 +350,20 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
/// the arguments or local variables.
///
/// The high-level version of this is `init_stack_frame`.
#[instrument(skip(self, body, return_place, return_to_block), level = "debug")]
#[instrument(skip(self, body, return_place, return_cont), level = "debug")]
pub(crate) fn push_stack_frame_raw(
&mut self,
instance: ty::Instance<'tcx>,
body: &'tcx mir::Body<'tcx>,
return_place: &PlaceTy<'tcx, M::Provenance>,
return_to_block: StackPopCleanup,
return_cont: ReturnContinuation,
) -> InterpResult<'tcx> {
trace!("body: {:#?}", body);

// We can push a `Root` frame if and only if the stack is empty.
debug_assert_eq!(
self.stack().is_empty(),
matches!(return_to_block, StackPopCleanup::Root { .. })
matches!(return_cont, ReturnContinuation::Stop { .. })
);

// First push a stack frame so we have access to `instantiate_from_current_frame` and other
Expand All @@ -373,7 +373,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
let pre_frame = Frame {
body,
loc: Right(body.span), // Span used for errors caused during preamble.
return_to_block,
return_cont,
return_place: return_place.clone(),
locals,
instance,
Expand Down Expand Up @@ -429,15 +429,15 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
copy_ret_val(self, &frame.return_place)?;
}

let return_to_block = frame.return_to_block;
let return_cont = frame.return_cont;
let return_place = frame.return_place.clone();

// Cleanup: deallocate locals.
// Usually we want to clean up (deallocate locals), but in a few rare cases we don't.
// We do this while the frame is still on the stack, so errors point to the callee.
let cleanup = match return_to_block {
StackPopCleanup::Goto { .. } => true,
StackPopCleanup::Root { cleanup, .. } => cleanup,
let cleanup = match return_cont {
ReturnContinuation::Goto { .. } => true,
ReturnContinuation::Stop { cleanup, .. } => cleanup,
};

let return_action = if cleanup {
Expand All @@ -455,7 +455,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
ReturnAction::NoCleanup
};

interp_ok(StackPopInfo { return_action, return_to_block, return_place })
interp_ok(StackPopInfo { return_action, return_cont, return_place })
}

/// In the current stack frame, mark all locals as live that are not arguments and don't have
Expand Down
Loading
Loading