Skip to content

Rollup of 8 pull requests #143755

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

Closed
wants to merge 41 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
2953787
DRAFT: Add an aarch64-msvc build running on ARM64 Windows
dpaoliello Apr 28, 2025
e101e38
std_detect: Tidying of slice length
a4lg Jun 29, 2025
bb2d169
use `is_multiple_of` to check if an addr is aligned
folkertdev Jul 5, 2025
e8d9e80
Add empty rust-version file
Kobzol Jun 26, 2025
f697f81
Add josh synchronization scripts
Kobzol Jun 26, 2025
8ae4e6a
Update stabilization version of certain x86 intrinsics to 1.89
Amanieu Jun 30, 2025
e46d220
Use simd_extract! macro instead of calling simd_extract directly
clarfonthey Jun 30, 2025
600497f
Mark `avx` broadcast intrinsics as safe
okaneco Jun 23, 2025
b535003
Remove std-detect dev dependency in core_arch
Kobzol Jul 4, 2025
816f029
Update README.md
kilavvy Jun 29, 2025
8600192
Add config files for `rustc-josh-sync`
Kobzol Jul 4, 2025
ce73251
Prepare for merging from rust-lang/rust
Kobzol Jul 4, 2025
1bc289d
std_detect: RISC-V Linux: Ergonomic querying with `riscv_hwprobe`
a4lg Jun 29, 2025
fddd05b
some clippy fixes
hkBst Jul 6, 2025
658b5c8
Use `simd_funnel_sh{l,r}` and `simd_round_ties_even` to remove uses o…
sayantn Jul 7, 2025
a95bd00
Remove custom josh-sync scripts
Kobzol Jul 8, 2025
07d5fbb
Update README with link to `josh-sync`
Kobzol Jul 8, 2025
82126a6
fix whitespace in `aarch64.spec.yml`
folkertdev Jul 8, 2025
323c646
remote intermediate assignment
folkertdev Jul 8, 2025
92701fe
shorten array literals
folkertdev Jul 8, 2025
061a941
remove unneeded cast
folkertdev Jul 8, 2025
701d222
Reset rust-version
Kobzol Jul 8, 2025
3c9297c
Prepare for merging from rust-lang/rust
Kobzol Jul 8, 2025
bdead41
Merge ref '040e2f8b9ff2' from rust-lang/rust
Kobzol Jul 8, 2025
a310bdd
Merge pull request #1853 from Kobzol/pull-fixed
Amanieu Jul 8, 2025
d54c3ea
Preserve the .debug_gdb_scripts section
sebastianpoeplau Jul 3, 2025
3e675f4
Fix `--skip-std-check-if-no-download-rustc`
Kobzol Jul 9, 2025
84eeca2
Make some "safe" llvm ops actually sound
oli-obk Jul 10, 2025
7632c55
extract single_import_can_define_name and finalize_glob_module_binding
b-naber Jul 10, 2025
7dfc3e9
Rework borrowing suggestions to use `Expr` instead of just `Span`
estebank Jul 10, 2025
0674eca
Make `Diag::multipart_suggestions` always verbose
estebank Jul 10, 2025
d692444
Update test
estebank Jul 10, 2025
341f12d
Properly track the depth when expanding free alias types
fmease Jul 10, 2025
a37b01d
Rollup merge of #140136 - dpaoliello:arm64winci, r=Kobzol
tgross35 Jul 10, 2025
bf8cf57
Rollup merge of #143642 - Kobzol:stdarch-push, r=Amanieu
tgross35 Jul 10, 2025
45d8905
Rollup merge of #143679 - sebastianpoeplau:preserve-debug-gdb-scripts…
tgross35 Jul 10, 2025
51cb3b0
Rollup merge of #143707 - Kobzol:bootstrap-std-check, r=jieyouxu
tgross35 Jul 10, 2025
7966892
Rollup merge of #143722 - oli-obk:sound-llvm, r=dianqk
tgross35 Jul 10, 2025
d809ba8
Rollup merge of #143728 - LorrensP-2158466:refactor-resolve-extractio…
tgross35 Jul 10, 2025
92d93df
Rollup merge of #143742 - estebank:borrow-suggestion, r=compiler-errors
tgross35 Jul 10, 2025
fba04fa
Rollup merge of #143744 - fmease:lta-expand-proper-depth, r=compiler-…
tgross35 Jul 10, 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
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,9 @@ jobs:
- name: show the current environment
run: src/ci/scripts/dump-environment.sh

- name: install rust
run: src/ci/scripts/install-rust.sh

- name: install awscli
run: src/ci/scripts/install-awscli.sh

Expand Down
7 changes: 2 additions & 5 deletions compiler/rustc_codegen_gcc/src/debuginfo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,6 @@ impl<'a, 'gcc, 'tcx> DebugInfoBuilderMethods for Builder<'a, 'gcc, 'tcx> {
_variable_alloca.set_location(_dbg_loc);
}

fn insert_reference_to_gdb_debug_scripts_section_global(&mut self) {
// TODO(antoyo): insert reference to gdb debug scripts section global.
}

/// FIXME(tempdragon): Currently, this function is not yet implemented. It seems that the
/// debug name and the mangled name should both be included in the LValues.
/// Besides, a function to get the rvalue type(m_is_lvalue) should also be included.
Expand Down Expand Up @@ -254,7 +250,8 @@ impl<'gcc, 'tcx> DebugInfoCodegenMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
// TODO(antoyo): implement.
}

fn debuginfo_finalize(&self) {
fn debuginfo_finalize(&mut self) {
// TODO: emit section `.debug_gdb_scripts`.
self.context.set_debug_info(true)
}

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_llvm/src/back/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1182,7 +1182,7 @@ fn create_msvc_imps(
.filter_map(|val| {
// Exclude some symbols that we know are not Rust symbols.
let name = llvm::get_value_name(val);
if ignored(name) { None } else { Some((val, name)) }
if ignored(&name) { None } else { Some((val, name)) }
})
.map(move |(val, name)| {
let mut imp_name = prefix.as_bytes().to_vec();
Expand Down
12 changes: 6 additions & 6 deletions compiler/rustc_codegen_llvm/src/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,16 @@ pub(crate) fn compile_codegen_unit(
}

// Finalize code coverage by injecting the coverage map. Note, the coverage map will
// also be added to the `llvm.compiler.used` variable, created next.
// also be added to the `llvm.compiler.used` variable, created below.
if cx.sess().instrument_coverage() {
cx.coverageinfo_finalize();
}

// Finalize debuginfo. This adds to `llvm.used`, created below.
if cx.sess().opts.debuginfo != DebugInfo::None {
cx.debuginfo_finalize();
}

// Create the llvm.used and llvm.compiler.used variables.
if !cx.used_statics.is_empty() {
cx.create_used_variable_impl(c"llvm.used", &cx.used_statics);
Expand All @@ -130,11 +135,6 @@ pub(crate) fn compile_codegen_unit(
llvm::LLVMDeleteGlobal(old_g);
}
}

// Finalize debuginfo
if cx.sess().opts.debuginfo != DebugInfo::None {
cx.debuginfo_finalize();
}
}

ModuleCodegen::new_regular(cgu_name.to_string(), llvm_module)
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_llvm/src/builder/autodiff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ fn generate_enzyme_call<'ll>(
// add outer_fn name to ad_name to make it unique, in case users apply autodiff to multiple
// functions. Unwrap will only panic, if LLVM gave us an invalid string.
let name = llvm::get_value_name(outer_fn);
let outer_fn_name = std::str::from_utf8(name).unwrap();
let outer_fn_name = std::str::from_utf8(&name).unwrap();
ad_name.push_str(outer_fn_name);

// Let us assume the user wrote the following function square:
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_llvm/src/consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ impl<'ll> CodegenCx<'ll, '_> {
// specific rules on what can be cast. So instead of adding a new way to
// generate static initializers that match the static's type, we picked
// the easier option and retroactively change the type of the static item itself.
let name = llvm::get_value_name(g).to_vec();
let name = llvm::get_value_name(g);
llvm::set_value_name(g, b"");

let linkage = llvm::get_linkage(g);
Expand Down
28 changes: 11 additions & 17 deletions compiler/rustc_codegen_llvm/src/debuginfo/gdb.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// .debug_gdb_scripts binary section.

use std::ffi::CString;

use rustc_ast::attr;
use rustc_codegen_ssa::base::collect_debugger_visualizers_transitive;
use rustc_codegen_ssa::traits::*;
Expand All @@ -9,31 +11,21 @@ use rustc_middle::middle::debugger_visualizer::DebuggerVisualizerType;
use rustc_session::config::{CrateType, DebugInfo};
use rustc_span::sym;

use crate::builder::Builder;
use crate::common::CodegenCx;
use crate::llvm;
use crate::value::Value;

/// Inserts a side-effect free instruction sequence that makes sure that the
/// .debug_gdb_scripts global is referenced, so it isn't removed by the linker.
pub(crate) fn insert_reference_to_gdb_debug_scripts_section_global(bx: &mut Builder<'_, '_, '_>) {
if needs_gdb_debug_scripts_section(bx) {
let gdb_debug_scripts_section = get_or_insert_gdb_debug_scripts_section_global(bx);
// Load just the first byte as that's all that's necessary to force
// LLVM to keep around the reference to the global.
let volatile_load_instruction = bx.volatile_load(bx.type_i8(), gdb_debug_scripts_section);
unsafe {
llvm::LLVMSetAlignment(volatile_load_instruction, 1);
}
}
}

/// Allocates the global variable responsible for the .debug_gdb_scripts binary
/// section.
pub(crate) fn get_or_insert_gdb_debug_scripts_section_global<'ll>(
cx: &CodegenCx<'ll, '_>,
cx: &mut CodegenCx<'ll, '_>,
) -> &'ll Value {
let c_section_var_name = c"__rustc_debug_gdb_scripts_section__";
let c_section_var_name = CString::new(format!(
"__rustc_debug_gdb_scripts_section_{}_{:08x}",
cx.tcx.crate_name(LOCAL_CRATE),
cx.tcx.stable_crate_id(LOCAL_CRATE),
))
.unwrap();
let section_var_name = c_section_var_name.to_str().unwrap();

let section_var = unsafe { llvm::LLVMGetNamedGlobal(cx.llmod, c_section_var_name.as_ptr()) };
Expand Down Expand Up @@ -80,6 +72,8 @@ pub(crate) fn get_or_insert_gdb_debug_scripts_section_global<'ll>(
// This should make sure that the whole section is not larger than
// the string it contains. Otherwise we get a warning from GDB.
llvm::LLVMSetAlignment(section_var, 1);
// Make sure that the linker doesn't optimize the global away.
cx.add_used_global(section_var);
section_var
}
})
Expand Down
34 changes: 16 additions & 18 deletions compiler/rustc_codegen_llvm/src/debuginfo/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ use tracing::debug;

use self::metadata::{UNKNOWN_COLUMN_NUMBER, UNKNOWN_LINE_NUMBER, file_metadata, type_di_node};
use self::namespace::mangled_name_of_instance;
use self::utils::{DIB, create_DIArray, is_node_local_to_unit};
use self::utils::{DIB, create_DIArray, debug_context, is_node_local_to_unit};
use crate::builder::Builder;
use crate::common::{AsCCharPtr, CodegenCx};
use crate::llvm;
Expand Down Expand Up @@ -131,20 +131,22 @@ impl<'ll, 'tcx> CodegenUnitDebugContext<'ll, 'tcx> {
}

/// Creates any deferred debug metadata nodes
pub(crate) fn finalize(cx: &CodegenCx<'_, '_>) {
if let Some(dbg_cx) = &cx.dbg_cx {
debug!("finalize");

if gdb::needs_gdb_debug_scripts_section(cx) {
// Add a .debug_gdb_scripts section to this compile-unit. This will
// cause GDB to try and load the gdb_load_rust_pretty_printers.py file,
// which activates the Rust pretty printers for binary this section is
// contained in.
gdb::get_or_insert_gdb_debug_scripts_section_global(cx);
}
pub(crate) fn finalize(cx: &mut CodegenCx<'_, '_>) {
if cx.dbg_cx.is_none() {
return;
}

debug!("finalize");

dbg_cx.finalize(cx.sess());
if gdb::needs_gdb_debug_scripts_section(cx) {
// Add a .debug_gdb_scripts section to this compile-unit. This will
// cause GDB to try and load the gdb_load_rust_pretty_printers.py file,
// which activates the Rust pretty printers for binary this section is
// contained in.
gdb::get_or_insert_gdb_debug_scripts_section_global(cx);
}

debug_context(cx).finalize(cx.sess());
}

impl<'ll> Builder<'_, 'll, '_> {
Expand Down Expand Up @@ -215,10 +217,6 @@ impl<'ll> DebugInfoBuilderMethods for Builder<'_, 'll, '_> {
}
}

fn insert_reference_to_gdb_debug_scripts_section_global(&mut self) {
gdb::insert_reference_to_gdb_debug_scripts_section_global(self)
}

fn set_var_name(&mut self, value: &'ll Value, name: &str) {
// Avoid wasting time if LLVM value names aren't even enabled.
if self.sess().fewer_names() {
Expand Down Expand Up @@ -614,7 +612,7 @@ impl<'ll, 'tcx> DebugInfoCodegenMethods<'tcx> for CodegenCx<'ll, 'tcx> {
metadata::extend_scope_to_file(self, scope_metadata, file)
}

fn debuginfo_finalize(&self) {
fn debuginfo_finalize(&mut self) {
finalize(self)
}

Expand Down
10 changes: 6 additions & 4 deletions compiler/rustc_codegen_llvm/src/llvm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ pub(crate) fn SetFunctionCallConv(fn_: &Value, cc: CallConv) {
// function.
// For more details on COMDAT sections see e.g., https://www.airs.com/blog/archives/52
pub(crate) fn SetUniqueComdat(llmod: &Module, val: &Value) {
let name_buf = get_value_name(val).to_vec();
let name_buf = get_value_name(val);
let name =
CString::from_vec_with_nul(name_buf).or_else(|buf| CString::new(buf.into_bytes())).unwrap();
set_comdat(llmod, val, &name);
Expand Down Expand Up @@ -319,12 +319,14 @@ pub(crate) fn get_param(llfn: &Value, index: c_uint) -> &Value {
}
}

/// Safe wrapper for `LLVMGetValueName2` into a byte slice
pub(crate) fn get_value_name(value: &Value) -> &[u8] {
/// Safe wrapper for `LLVMGetValueName2`
/// Needs to allocate the value, because `set_value_name` will invalidate
/// the pointer.
pub(crate) fn get_value_name(value: &Value) -> Vec<u8> {
unsafe {
let mut len = 0;
let data = LLVMGetValueName2(value, &mut len);
std::slice::from_raw_parts(data.cast(), len)
std::slice::from_raw_parts(data.cast(), len).to_vec()
}
}

Expand Down
2 changes: 0 additions & 2 deletions compiler/rustc_codegen_ssa/src/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -528,8 +528,6 @@ pub fn maybe_create_entry_wrapper<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
let llbb = Bx::append_block(cx, llfn, "top");
let mut bx = Bx::build(cx, llbb);

bx.insert_reference_to_gdb_debug_scripts_section_global();

let isize_ty = cx.type_isize();
let ptr_ty = cx.type_ptr();
let (arg_argc, arg_argv) = get_argc_argv(&mut bx);
Expand Down
3 changes: 1 addition & 2 deletions compiler/rustc_codegen_ssa/src/traits/debuginfo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ pub trait DebugInfoCodegenMethods<'tcx>: BackendTypes {
scope_metadata: Self::DIScope,
file: &SourceFile,
) -> Self::DIScope;
fn debuginfo_finalize(&self);
fn debuginfo_finalize(&mut self);

// FIXME(eddyb) find a common convention for all of the debuginfo-related
// names (choose between `dbg`, `debug`, `debuginfo`, `debug_info` etc.).
Expand Down Expand Up @@ -81,6 +81,5 @@ pub trait DebugInfoBuilderMethods: BackendTypes {
);
fn set_dbg_loc(&mut self, dbg_loc: Self::DILocation);
fn clear_dbg_loc(&mut self);
fn insert_reference_to_gdb_debug_scripts_section_global(&mut self);
fn set_var_name(&mut self, value: Self::Value, name: &str);
}
2 changes: 1 addition & 1 deletion compiler/rustc_errors/src/diagnostic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1165,7 +1165,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
self.push_suggestion(CodeSuggestion {
substitutions,
msg: self.subdiagnostic_message_to_diagnostic_message(msg),
style: SuggestionStyle::ShowCode,
style: SuggestionStyle::ShowAlways,
applicability,
});
self
Expand Down
6 changes: 4 additions & 2 deletions compiler/rustc_middle/src/ty/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1052,9 +1052,11 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for FreeAliasTypeExpander<'tcx> {
}

self.depth += 1;
ensure_sufficient_stack(|| {
let ty = ensure_sufficient_stack(|| {
self.tcx.type_of(alias.def_id).instantiate(self.tcx, alias.args).fold_with(self)
})
});
self.depth -= 1;
ty
}

fn fold_const(&mut self, ct: ty::Const<'tcx>) -> ty::Const<'tcx> {
Expand Down
Loading
Loading