From b5c473e4141c6b1bc7a1babec3e01f894442f436 Mon Sep 17 00:00:00 2001 From: Chris Denton Date: Tue, 23 Dec 2025 15:50:33 +0000 Subject: [PATCH 1/5] Avoid using env::temp when linking a binary This keeps all build artefacts (even temporary ones) within the build directory. --- compiler/rustc_codegen_ssa/src/back/link.rs | 11 ++++++----- compiler/rustc_fs_util/src/lib.rs | 6 +----- tests/run-make/invalid-tmpdir-env-var/rmake.rs | 8 ++++---- 3 files changed, 11 insertions(+), 14 deletions(-) diff --git a/compiler/rustc_codegen_ssa/src/back/link.rs b/compiler/rustc_codegen_ssa/src/back/link.rs index 70db6794742d0..ba07345dd43f5 100644 --- a/compiler/rustc_codegen_ssa/src/back/link.rs +++ b/compiler/rustc_codegen_ssa/src/back/link.rs @@ -103,17 +103,18 @@ pub fn link_binary( }); if outputs.outputs.should_link() { - let tmpdir = TempDirBuilder::new() - .prefix("rustc") - .tempdir() - .unwrap_or_else(|error| sess.dcx().emit_fatal(errors::CreateTempDir { error })); - let path = MaybeTempDir::new(tmpdir, sess.opts.cg.save_temps); let output = out_filename( sess, crate_type, outputs, codegen_results.crate_info.local_crate_name, ); + let tmpdir = TempDirBuilder::new() + .prefix("rustc") + .tempdir_in(output.parent().unwrap_or_else(|| Path::new("."))) + .unwrap_or_else(|error| sess.dcx().emit_fatal(errors::CreateTempDir { error })); + let path = MaybeTempDir::new(tmpdir, sess.opts.cg.save_temps); + let crate_name = format!("{}", codegen_results.crate_info.local_crate_name); let out_filename = output.file_for_writing( outputs, diff --git a/compiler/rustc_fs_util/src/lib.rs b/compiler/rustc_fs_util/src/lib.rs index 7a883a13b72da..e21da4cdddf7d 100644 --- a/compiler/rustc_fs_util/src/lib.rs +++ b/compiler/rustc_fs_util/src/lib.rs @@ -1,6 +1,6 @@ use std::ffi::{CString, OsStr}; use std::path::{Path, PathBuf, absolute}; -use std::{env, fs, io}; +use std::{fs, io}; use tempfile::TempDir; @@ -139,8 +139,4 @@ impl<'a, 'b> TempDirBuilder<'a, 'b> { } self.builder.tempdir_in(dir) } - - pub fn tempdir(&self) -> io::Result { - self.tempdir_in(env::temp_dir()) - } } diff --git a/tests/run-make/invalid-tmpdir-env-var/rmake.rs b/tests/run-make/invalid-tmpdir-env-var/rmake.rs index c5b9dca33a940..a62592757879d 100644 --- a/tests/run-make/invalid-tmpdir-env-var/rmake.rs +++ b/tests/run-make/invalid-tmpdir-env-var/rmake.rs @@ -1,9 +1,7 @@ //@ needs-target-std // // When the TMP (on Windows) or TMPDIR (on Unix) variable is set to an invalid -// or non-existing directory, this used to cause an internal compiler error (ICE). After the -// addition of proper error handling in #28430, this test checks that the expected message is -// printed. +// or non-existing directory, this used to cause an internal compiler error (ICE). // See https://github.com/rust-lang/rust/issues/14698 use run_make_support::{is_windows, rustc}; @@ -18,5 +16,7 @@ fn main() { } else { rustc.env("TMPDIR", "fake"); } - rustc.input("foo.rs").run_fail().assert_stderr_contains("couldn't create a temp dir"); + let result = rustc.input("foo.rs").run_unchecked(); + // Ensure that rustc doesn't ICE by checking the exit code isn't 101. + assert_ne!(result.status().code(), Some(101)); } From 6e354544bfe4bc6ce17265bfb8013631d505f1ac Mon Sep 17 00:00:00 2001 From: Chris Denton Date: Tue, 23 Dec 2025 17:46:09 +0000 Subject: [PATCH 2/5] Rename invalid-tmpdir-env-var to invalid-tmpdir-no-ice --- .../{invalid-tmpdir-env-var => invalid-tmpdir-no-ice}/foo.rs | 0 .../{invalid-tmpdir-env-var => invalid-tmpdir-no-ice}/rmake.rs | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename tests/run-make/{invalid-tmpdir-env-var => invalid-tmpdir-no-ice}/foo.rs (100%) rename tests/run-make/{invalid-tmpdir-env-var => invalid-tmpdir-no-ice}/rmake.rs (100%) diff --git a/tests/run-make/invalid-tmpdir-env-var/foo.rs b/tests/run-make/invalid-tmpdir-no-ice/foo.rs similarity index 100% rename from tests/run-make/invalid-tmpdir-env-var/foo.rs rename to tests/run-make/invalid-tmpdir-no-ice/foo.rs diff --git a/tests/run-make/invalid-tmpdir-env-var/rmake.rs b/tests/run-make/invalid-tmpdir-no-ice/rmake.rs similarity index 100% rename from tests/run-make/invalid-tmpdir-env-var/rmake.rs rename to tests/run-make/invalid-tmpdir-no-ice/rmake.rs From 855281c8871e43980fc41b54d1d5949a9863103d Mon Sep 17 00:00:00 2001 From: WANG Rui Date: Wed, 24 Dec 2025 16:04:58 +0800 Subject: [PATCH 3/5] Disable f16 on LoongArch for LLVM < 21 The `f16` type works on the LoongArch target starting from LLVM 21. However, the current minimum supported external LLVM version is 20, so `f16` must not be enabled on LoongArch for LLVM version < 21. --- compiler/rustc_codegen_llvm/src/llvm_util.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/compiler/rustc_codegen_llvm/src/llvm_util.rs b/compiler/rustc_codegen_llvm/src/llvm_util.rs index a5a8f8e6a25e8..01181ce261842 100644 --- a/compiler/rustc_codegen_llvm/src/llvm_util.rs +++ b/compiler/rustc_codegen_llvm/src/llvm_util.rs @@ -383,6 +383,7 @@ fn update_target_reliable_float_cfg(sess: &Session, cfg: &mut TargetConfig) { // Infinite recursion (Arch::CSky, _) => false, (Arch::Hexagon, _) if major < 21 => false, // (fixed in llvm21) + (Arch::LoongArch32 | Arch::LoongArch64, _) if major < 21 => false, // (fixed in llvm21) (Arch::PowerPC | Arch::PowerPC64, _) => false, (Arch::Sparc | Arch::Sparc64, _) => false, (Arch::Wasm32 | Arch::Wasm64, _) => false, From 13c6256efe7d426abeb7c86a20b14ba38dc7ad4e Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Wed, 24 Dec 2025 10:21:07 +0000 Subject: [PATCH 4/5] Include rustc version in ICE messages Rather than only including them in the ICE file. Not every user includes the ICE file in their bug reports, nor do they always list the rustc version. --- compiler/rustc_driver_impl/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_driver_impl/src/lib.rs b/compiler/rustc_driver_impl/src/lib.rs index 63fc9c96f450d..7820198f2dcf2 100644 --- a/compiler/rustc_driver_impl/src/lib.rs +++ b/compiler/rustc_driver_impl/src/lib.rs @@ -1531,15 +1531,15 @@ fn report_ice( .map(PathBuf::from) .map(|env_var| session_diagnostics::IcePathErrorEnv { env_var }), }); - dcx.emit_note(session_diagnostics::IceVersion { version, triple: tuple }); None } } } else { - dcx.emit_note(session_diagnostics::IceVersion { version, triple: tuple }); None }; + dcx.emit_note(session_diagnostics::IceVersion { version, triple: tuple }); + if let Some((flags, excluded_cargo_defaults)) = rustc_session::utils::extra_compiler_flags() { dcx.emit_note(session_diagnostics::IceFlags { flags: flags.join(" ") }); if excluded_cargo_defaults { From a3dc0ef8fc677e2ac33753528e8722736401de8a Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Wed, 24 Dec 2025 12:25:30 +0000 Subject: [PATCH 5/5] Fix some divergences with the cg_clif subtree For some reason git-subtree incorrectly synced those changes. --- compiler/rustc_codegen_cranelift/example/mini_core.rs | 1 - .../example/mini_core_hello_world.rs | 11 +---------- .../rustc_codegen_cranelift/src/intrinsics/simd.rs | 10 +--------- 3 files changed, 2 insertions(+), 20 deletions(-) diff --git a/compiler/rustc_codegen_cranelift/example/mini_core.rs b/compiler/rustc_codegen_cranelift/example/mini_core.rs index b522ea1937166..2dd75563a34d3 100644 --- a/compiler/rustc_codegen_cranelift/example/mini_core.rs +++ b/compiler/rustc_codegen_cranelift/example/mini_core.rs @@ -6,7 +6,6 @@ extern_types, decl_macro, rustc_attrs, - rustc_private, transparent_unions, auto_traits, freeze_impls, diff --git a/compiler/rustc_codegen_cranelift/example/mini_core_hello_world.rs b/compiler/rustc_codegen_cranelift/example/mini_core_hello_world.rs index 10549cd2a41e2..c971a7df34b07 100644 --- a/compiler/rustc_codegen_cranelift/example/mini_core_hello_world.rs +++ b/compiler/rustc_codegen_cranelift/example/mini_core_hello_world.rs @@ -1,13 +1,4 @@ -#![feature( - no_core, - lang_items, - never_type, - linkage, - extern_types, - thread_local, - repr_simd, - rustc_private -)] +#![feature(no_core, lang_items, never_type, linkage, extern_types, thread_local, repr_simd)] #![no_core] #![allow(dead_code, non_camel_case_types, internal_features)] diff --git a/compiler/rustc_codegen_cranelift/src/intrinsics/simd.rs b/compiler/rustc_codegen_cranelift/src/intrinsics/simd.rs index 15aef60c5af37..bef9c67474577 100644 --- a/compiler/rustc_codegen_cranelift/src/intrinsics/simd.rs +++ b/compiler/rustc_codegen_cranelift/src/intrinsics/simd.rs @@ -1005,14 +1005,6 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>( let lane_clif_ty = fx.clif_type(val_lane_ty).unwrap(); let ret_lane_layout = fx.layout_of(ret_lane_ty); - let alignment = - generic_args[3].expect_const().to_branch()[0].to_leaf().to_simd_alignment(); - - let memflags = match alignment { - SimdAlign::Unaligned => MemFlags::new().with_notrap(), - _ => MemFlags::trusted(), - }; - for lane_idx in 0..ptr_lane_count { let val_lane = val.value_lane(fx, lane_idx).load_scalar(fx); let ptr_lane = ptr.value_lane(fx, lane_idx).load_scalar(fx); @@ -1028,7 +1020,7 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>( fx.bcx.seal_block(if_disabled); fx.bcx.switch_to_block(if_enabled); - let res = fx.bcx.ins().load(lane_clif_ty, memflags, ptr_lane, 0); + let res = fx.bcx.ins().load(lane_clif_ty, MemFlags::trusted(), ptr_lane, 0); fx.bcx.ins().jump(next, &[res.into()]); fx.bcx.switch_to_block(if_disabled);