From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 96FE41580E0 for ; Mon, 02 Jun 2025 09:50:20 +0000 (UTC) Received: from lists.gentoo.org (bobolink.gentoo.org [140.211.166.189]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) (Authenticated sender: relay-lists.gentoo.org@gentoo.org) by smtp.gentoo.org (Postfix) with ESMTPSA id 83A87343297 for ; Mon, 02 Jun 2025 09:50:20 +0000 (UTC) Received: from bobolink.gentoo.org (localhost [127.0.0.1]) by bobolink.gentoo.org (Postfix) with ESMTP id CF30E1104EB; Mon, 02 Jun 2025 09:48:39 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bobolink.gentoo.org (Postfix) with ESMTPS id B9B111104E5 for ; Mon, 02 Jun 2025 09:48:39 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 6FA63343102 for ; Mon, 02 Jun 2025 09:48:39 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id AA35927BD for ; Mon, 02 Jun 2025 09:48:36 +0000 (UTC) From: "Matt Jolly" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Matt Jolly" Message-ID: <1748857629.12cbabf1bf6482e7046a73cd59ba7aa0662f4bf8.kangie@gentoo> Subject: [gentoo-commits] proj/rust-patches:1.84 commit in: / X-VCS-Repository: proj/rust-patches X-VCS-Files: 1.83.0-dwarf-llvm-assertion.patch X-VCS-Directories: / X-VCS-Committer: kangie X-VCS-Committer-Name: Matt Jolly X-VCS-Revision: 12cbabf1bf6482e7046a73cd59ba7aa0662f4bf8 X-VCS-Branch: 1.84 Date: Mon, 02 Jun 2025 09:48:36 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 2dc101ee-a0c7-44eb-9045-3882c604da43 X-Archives-Hash: 2340cd0b71386a9d7a9e0ef0ce334fcd commit: 12cbabf1bf6482e7046a73cd59ba7aa0662f4bf8 Author: Matt Jolly gentoo org> AuthorDate: Mon Jun 2 09:47:09 2025 +0000 Commit: Matt Jolly gentoo org> CommitDate: Mon Jun 2 09:47:09 2025 +0000 URL: https://gitweb.gentoo.org/proj/rust-patches.git/commit/?id=12cbabf1 Add patches for Rust 1.84.0-r2 Patches: - 1.78.0-musl-dynamic-linking.patch - 1.83.0-cross-compile-libz.patch - 1.67.0-doc-wasm.patch Signed-off-by: Matt Jolly gentoo.org> 1.83.0-dwarf-llvm-assertion.patch | 220 -------------------------------------- 1 file changed, 220 deletions(-) diff --git a/1.83.0-dwarf-llvm-assertion.patch b/1.83.0-dwarf-llvm-assertion.patch deleted file mode 100644 index 96bdac0..0000000 --- a/1.83.0-dwarf-llvm-assertion.patch +++ /dev/null @@ -1,220 +0,0 @@ -From 1dc106121b62562ead6e7d612fa136dc4b35cd5d Mon Sep 17 00:00:00 2001 -From: Kyle Huey -Date: Mon, 4 Nov 2024 11:38:14 -0800 -Subject: [PATCH] Add discriminators to DILocations when multiple functions are - inlined into a single point. - -LLVM does not expect to ever see multiple dbg_declares for the same variable at the same -location with different values. proc-macros make it possible for arbitrary code, -including multiple calls that get inlined, to happen at any given location in the source -code. Add discriminators when that happens so these locations are different to LLVM. - -This may interfere with the AddDiscriminators pass in LLVM, which is added by the -unstable flag -Zdebug-info-for-profiling. - -Fixes #131944 ---- a/compiler/rustc_codegen_llvm/src/debuginfo/create_scope_map.rs -+++ b/compiler/rustc_codegen_llvm/src/debuginfo/create_scope_map.rs -@@ -1,11 +1,15 @@ -+use std::collections::hash_map::Entry; -+ - use rustc_codegen_ssa::mir::debuginfo::{DebugScope, FunctionDebugContext}; - use rustc_codegen_ssa::traits::*; -+use rustc_data_structures::fx::FxHashMap; - use rustc_index::Idx; - use rustc_index::bit_set::BitSet; - use rustc_middle::mir::{Body, SourceScope}; - use rustc_middle::ty::layout::FnAbiOf; - use rustc_middle::ty::{self, Instance}; - use rustc_session::config::DebugInfo; -+use rustc_span::BytePos; - - use super::metadata::file_metadata; - use super::utils::DIB; -@@ -37,10 +41,20 @@ pub(crate) fn compute_mir_scopes<'ll, 'tcx>( - None - }; - let mut instantiated = BitSet::new_empty(mir.source_scopes.len()); -+ let mut discriminators = FxHashMap::default(); - // Instantiate all scopes. - for idx in 0..mir.source_scopes.len() { - let scope = SourceScope::new(idx); -- make_mir_scope(cx, instance, mir, &variables, debug_context, &mut instantiated, scope); -+ make_mir_scope( -+ cx, -+ instance, -+ mir, -+ &variables, -+ debug_context, -+ &mut instantiated, -+ &mut discriminators, -+ scope, -+ ); - } - assert!(instantiated.count() == mir.source_scopes.len()); - } -@@ -52,6 +66,7 @@ fn make_mir_scope<'ll, 'tcx>( - variables: &Option>, - debug_context: &mut FunctionDebugContext<'tcx, &'ll DIScope, &'ll DILocation>, - instantiated: &mut BitSet, -+ discriminators: &mut FxHashMap, - scope: SourceScope, - ) { - if instantiated.contains(scope) { -@@ -60,7 +75,16 @@ fn make_mir_scope<'ll, 'tcx>( - - let scope_data = &mir.source_scopes[scope]; - let parent_scope = if let Some(parent) = scope_data.parent_scope { -- make_mir_scope(cx, instance, mir, variables, debug_context, instantiated, parent); -+ make_mir_scope( -+ cx, -+ instance, -+ mir, -+ variables, -+ debug_context, -+ instantiated, -+ discriminators, -+ parent, -+ ); - debug_context.scopes[parent] - } else { - // The root is the function itself. -@@ -117,7 +141,37 @@ fn make_mir_scope<'ll, 'tcx>( - // FIXME(eddyb) this doesn't account for the macro-related - // `Span` fixups that `rustc_codegen_ssa::mir::debuginfo` does. - let callsite_scope = parent_scope.adjust_dbg_scope_for_span(cx, callsite_span); -- cx.dbg_loc(callsite_scope, parent_scope.inlined_at, callsite_span) -+ let loc = cx.dbg_loc(callsite_scope, parent_scope.inlined_at, callsite_span); -+ -+ // NB: In order to produce proper debug info for variables (particularly -+ // arguments) in multiply-inline functions, LLVM expects to see a single -+ // DILocalVariable with multiple different DILocations in the IR. While -+ // the source information for each DILocation would be identical, their -+ // inlinedAt attributes will be unique to the particular callsite. -+ // -+ // We generate DILocations here based on the callsite's location in the -+ // source code. A single location in the source code usually can't -+ // produce multiple distinct calls so this mostly works, until -+ // proc-macros get involved. A proc-macro can generate multiple calls -+ // at the same span, which breaks the assumption that we're going to -+ // produce a unique DILocation for every scope we process here. We -+ // have to explicitly add discriminators if we see inlines into the -+ // same source code location. -+ // -+ // Note further that we can't key this hashtable on the span itself, -+ // because these spans could have distinct SyntaxContexts. We have -+ // to key on exactly what we're giving to LLVM. -+ match discriminators.entry(callsite_span.lo()) { -+ Entry::Occupied(mut o) => { -+ *o.get_mut() += 1; -+ unsafe { llvm::LLVMRustDILocationCloneWithBaseDiscriminator(loc, *o.get()) } -+ .expect("Failed to encode discriminator in DILocation") -+ } -+ Entry::Vacant(v) => { -+ v.insert(0); -+ loc -+ } -+ } - }); - - debug_context.scopes[scope] = DebugScope { ---- a/compiler/rustc_codegen_llvm/src/llvm/ffi.rs -+++ b/compiler/rustc_codegen_llvm/src/llvm/ffi.rs -@@ -2174,6 +2174,10 @@ unsafe extern "C" { - Scope: &'a DIScope, - InlinedAt: Option<&'a DILocation>, - ) -> &'a DILocation; -+ pub fn LLVMRustDILocationCloneWithBaseDiscriminator<'a>( -+ Location: &'a DILocation, -+ BD: c_uint, -+ ) -> Option<&'a DILocation>; - pub fn LLVMRustDIBuilderCreateOpDeref() -> u64; - pub fn LLVMRustDIBuilderCreateOpPlusUconst() -> u64; - pub fn LLVMRustDIBuilderCreateOpLLVMFragment() -> u64; ---- a/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp -+++ b/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp -@@ -1305,6 +1305,14 @@ LLVMRustDIBuilderCreateDebugLocation(unsigned Line, unsigned Column, - return wrap(Loc); - } - -+extern "C" LLVMMetadataRef -+LLVMRustDILocationCloneWithBaseDiscriminator(LLVMMetadataRef Location, -+ unsigned BD) { -+ DILocation *Loc = unwrapDIPtr(Location); -+ auto NewLoc = Loc->cloneWithBaseDiscriminator(BD); -+ return wrap(NewLoc.has_value() ? NewLoc.value() : nullptr); -+} -+ - extern "C" uint64_t LLVMRustDIBuilderCreateOpDeref() { - return dwarf::DW_OP_deref; - } ---- /dev/null -+++ b/tests/codegen/debuginfo-proc-macro/auxiliary/macro_def.rs -@@ -0,0 +1,11 @@ -+//@ force-host -+//@ no-prefer-dynamic -+#![crate_type = "proc-macro"] -+ -+extern crate proc_macro; -+use proc_macro::*; -+ -+#[proc_macro] -+pub fn square_twice(_item: TokenStream) -> TokenStream { -+ "(square(env::vars().count() as i32), square(env::vars().count() as i32))".parse().unwrap() -+} ---- /dev/null -+++ b/tests/codegen/debuginfo-proc-macro/mir_inlined_twice_var_locs.rs -@@ -0,0 +1,53 @@ -+//@ min-llvm-version: 19 -+//@ compile-flags: -Cdebuginfo=2 -Copt-level=0 -Zmir-enable-passes=+Inline -+// MSVC is different because of the individual allocas. -+//@ ignore-msvc -+ -+//@ aux-build:macro_def.rs -+ -+// Find the variable. -+// CHECK-DAG: ![[#var_dbg:]] = !DILocalVariable(name: "n",{{( arg: 1,)?}} scope: ![[#var_scope:]] -+ -+// Find both dbg_declares. These will proceed the variable metadata, of course, so we're looking -+// backwards. -+// CHECK-DAG: dbg_declare(ptr %n.dbg.spill{{[0-9]}}, ![[#var_dbg]], !DIExpression(), ![[#var_loc2:]]) -+// CHECK-DAG: dbg_declare(ptr %n.dbg.spill, ![[#var_dbg]], !DIExpression(), ![[#var_loc1:]]) -+ -+// Find the first location definition, looking forwards again. -+// CHECK: ![[#var_loc1]] = !DILocation -+// CHECK-SAME: scope: ![[#var_scope:]], inlinedAt: ![[#var_inlinedAt1:]] -+ -+// Find the first location's inlinedAt -+// NB: If we fail here it's *probably* because we failed to produce two -+// different locations and ended up reusing an earlier one. -+// CHECK: ![[#var_inlinedAt1]] = !DILocation -+// CHECK-SAME: scope: ![[var_inlinedAt1_scope:]] -+ -+// Find the second location definition, still looking forwards. -+// NB: If we failed to produce two different locations, the test will -+// definitely fail by this point (if it hasn't already) because we won't -+// be able to find the same line again. -+// CHECK: ![[#var_loc2]] = !DILocation -+// CHECK-SAME: scope: ![[#var_scope]], inlinedAt: ![[#var_inlinedAt2:]] -+ -+// Find the second location's inlinedAt. -+// CHECK: ![[#var_inlinedAt2]] = !DILocation -+// CHECK-SAME: scope: ![[#var_inlinedAt2_scope:]] -+ -+// Finally, check that a discriminator was emitted for the second scope. -+// FIXMEkhuey ideally we would check that *either* scope has a discriminator -+// but I don't know that it's possible to check that with FileCheck. -+// CHECK: ![[#var_inlinedAt2_scope]] = !DILexicalBlockFile -+// CHECK-SAME: discriminator: [[#]] -+extern crate macro_def; -+ -+use std::env; -+ -+fn square(n: i32) -> i32 { -+ n * n -+} -+ -+fn main() { -+ let (z1, z2) = macro_def::square_twice!(); -+ println!("{z1} == {z2}"); -+} From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 466291580E0 for ; Mon, 02 Jun 2025 09:50:41 +0000 (UTC) Received: from lists.gentoo.org (bobolink.gentoo.org [140.211.166.189]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) (Authenticated sender: relay-lists.gentoo.org@gentoo.org) by smtp.gentoo.org (Postfix) with ESMTPSA id 2ADB134332E for ; Mon, 02 Jun 2025 09:50:41 +0000 (UTC) Received: from bobolink.gentoo.org (localhost [127.0.0.1]) by bobolink.gentoo.org (Postfix) with ESMTP id 5398B1104F8; Mon, 02 Jun 2025 09:48:41 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bobolink.gentoo.org (Postfix) with ESMTPS id 3935F1104F2 for ; Mon, 02 Jun 2025 09:48:41 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id E474B343215 for ; Mon, 02 Jun 2025 09:48:40 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 8631E291E for ; Mon, 02 Jun 2025 09:48:37 +0000 (UTC) From: "Matt Jolly" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Matt Jolly" Message-ID: <1748857629.12cbabf1bf6482e7046a73cd59ba7aa0662f4bf8.kangie@gentoo> Subject: [gentoo-commits] proj/rust-patches:1.85 commit in: / X-VCS-Repository: proj/rust-patches X-VCS-Files: 1.83.0-dwarf-llvm-assertion.patch X-VCS-Directories: / X-VCS-Committer: kangie X-VCS-Committer-Name: Matt Jolly X-VCS-Revision: 12cbabf1bf6482e7046a73cd59ba7aa0662f4bf8 X-VCS-Branch: 1.85 Date: Mon, 02 Jun 2025 09:48:37 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: ddb7778f-b4e6-4a8e-a124-5462774907bc X-Archives-Hash: c832f37375acd00bb842df058e4d20cb Message-ID: <20250602094837.ilzix4qp5_rbCuDmAkRncGP-ohhh60Xvoa11IKxbCa4@z> commit: 12cbabf1bf6482e7046a73cd59ba7aa0662f4bf8 Author: Matt Jolly gentoo org> AuthorDate: Mon Jun 2 09:47:09 2025 +0000 Commit: Matt Jolly gentoo org> CommitDate: Mon Jun 2 09:47:09 2025 +0000 URL: https://gitweb.gentoo.org/proj/rust-patches.git/commit/?id=12cbabf1 Add patches for Rust 1.84.0-r2 Patches: - 1.78.0-musl-dynamic-linking.patch - 1.83.0-cross-compile-libz.patch - 1.67.0-doc-wasm.patch Signed-off-by: Matt Jolly gentoo.org> 1.83.0-dwarf-llvm-assertion.patch | 220 -------------------------------------- 1 file changed, 220 deletions(-) diff --git a/1.83.0-dwarf-llvm-assertion.patch b/1.83.0-dwarf-llvm-assertion.patch deleted file mode 100644 index 96bdac0..0000000 --- a/1.83.0-dwarf-llvm-assertion.patch +++ /dev/null @@ -1,220 +0,0 @@ -From 1dc106121b62562ead6e7d612fa136dc4b35cd5d Mon Sep 17 00:00:00 2001 -From: Kyle Huey -Date: Mon, 4 Nov 2024 11:38:14 -0800 -Subject: [PATCH] Add discriminators to DILocations when multiple functions are - inlined into a single point. - -LLVM does not expect to ever see multiple dbg_declares for the same variable at the same -location with different values. proc-macros make it possible for arbitrary code, -including multiple calls that get inlined, to happen at any given location in the source -code. Add discriminators when that happens so these locations are different to LLVM. - -This may interfere with the AddDiscriminators pass in LLVM, which is added by the -unstable flag -Zdebug-info-for-profiling. - -Fixes #131944 ---- a/compiler/rustc_codegen_llvm/src/debuginfo/create_scope_map.rs -+++ b/compiler/rustc_codegen_llvm/src/debuginfo/create_scope_map.rs -@@ -1,11 +1,15 @@ -+use std::collections::hash_map::Entry; -+ - use rustc_codegen_ssa::mir::debuginfo::{DebugScope, FunctionDebugContext}; - use rustc_codegen_ssa::traits::*; -+use rustc_data_structures::fx::FxHashMap; - use rustc_index::Idx; - use rustc_index::bit_set::BitSet; - use rustc_middle::mir::{Body, SourceScope}; - use rustc_middle::ty::layout::FnAbiOf; - use rustc_middle::ty::{self, Instance}; - use rustc_session::config::DebugInfo; -+use rustc_span::BytePos; - - use super::metadata::file_metadata; - use super::utils::DIB; -@@ -37,10 +41,20 @@ pub(crate) fn compute_mir_scopes<'ll, 'tcx>( - None - }; - let mut instantiated = BitSet::new_empty(mir.source_scopes.len()); -+ let mut discriminators = FxHashMap::default(); - // Instantiate all scopes. - for idx in 0..mir.source_scopes.len() { - let scope = SourceScope::new(idx); -- make_mir_scope(cx, instance, mir, &variables, debug_context, &mut instantiated, scope); -+ make_mir_scope( -+ cx, -+ instance, -+ mir, -+ &variables, -+ debug_context, -+ &mut instantiated, -+ &mut discriminators, -+ scope, -+ ); - } - assert!(instantiated.count() == mir.source_scopes.len()); - } -@@ -52,6 +66,7 @@ fn make_mir_scope<'ll, 'tcx>( - variables: &Option>, - debug_context: &mut FunctionDebugContext<'tcx, &'ll DIScope, &'ll DILocation>, - instantiated: &mut BitSet, -+ discriminators: &mut FxHashMap, - scope: SourceScope, - ) { - if instantiated.contains(scope) { -@@ -60,7 +75,16 @@ fn make_mir_scope<'ll, 'tcx>( - - let scope_data = &mir.source_scopes[scope]; - let parent_scope = if let Some(parent) = scope_data.parent_scope { -- make_mir_scope(cx, instance, mir, variables, debug_context, instantiated, parent); -+ make_mir_scope( -+ cx, -+ instance, -+ mir, -+ variables, -+ debug_context, -+ instantiated, -+ discriminators, -+ parent, -+ ); - debug_context.scopes[parent] - } else { - // The root is the function itself. -@@ -117,7 +141,37 @@ fn make_mir_scope<'ll, 'tcx>( - // FIXME(eddyb) this doesn't account for the macro-related - // `Span` fixups that `rustc_codegen_ssa::mir::debuginfo` does. - let callsite_scope = parent_scope.adjust_dbg_scope_for_span(cx, callsite_span); -- cx.dbg_loc(callsite_scope, parent_scope.inlined_at, callsite_span) -+ let loc = cx.dbg_loc(callsite_scope, parent_scope.inlined_at, callsite_span); -+ -+ // NB: In order to produce proper debug info for variables (particularly -+ // arguments) in multiply-inline functions, LLVM expects to see a single -+ // DILocalVariable with multiple different DILocations in the IR. While -+ // the source information for each DILocation would be identical, their -+ // inlinedAt attributes will be unique to the particular callsite. -+ // -+ // We generate DILocations here based on the callsite's location in the -+ // source code. A single location in the source code usually can't -+ // produce multiple distinct calls so this mostly works, until -+ // proc-macros get involved. A proc-macro can generate multiple calls -+ // at the same span, which breaks the assumption that we're going to -+ // produce a unique DILocation for every scope we process here. We -+ // have to explicitly add discriminators if we see inlines into the -+ // same source code location. -+ // -+ // Note further that we can't key this hashtable on the span itself, -+ // because these spans could have distinct SyntaxContexts. We have -+ // to key on exactly what we're giving to LLVM. -+ match discriminators.entry(callsite_span.lo()) { -+ Entry::Occupied(mut o) => { -+ *o.get_mut() += 1; -+ unsafe { llvm::LLVMRustDILocationCloneWithBaseDiscriminator(loc, *o.get()) } -+ .expect("Failed to encode discriminator in DILocation") -+ } -+ Entry::Vacant(v) => { -+ v.insert(0); -+ loc -+ } -+ } - }); - - debug_context.scopes[scope] = DebugScope { ---- a/compiler/rustc_codegen_llvm/src/llvm/ffi.rs -+++ b/compiler/rustc_codegen_llvm/src/llvm/ffi.rs -@@ -2174,6 +2174,10 @@ unsafe extern "C" { - Scope: &'a DIScope, - InlinedAt: Option<&'a DILocation>, - ) -> &'a DILocation; -+ pub fn LLVMRustDILocationCloneWithBaseDiscriminator<'a>( -+ Location: &'a DILocation, -+ BD: c_uint, -+ ) -> Option<&'a DILocation>; - pub fn LLVMRustDIBuilderCreateOpDeref() -> u64; - pub fn LLVMRustDIBuilderCreateOpPlusUconst() -> u64; - pub fn LLVMRustDIBuilderCreateOpLLVMFragment() -> u64; ---- a/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp -+++ b/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp -@@ -1305,6 +1305,14 @@ LLVMRustDIBuilderCreateDebugLocation(unsigned Line, unsigned Column, - return wrap(Loc); - } - -+extern "C" LLVMMetadataRef -+LLVMRustDILocationCloneWithBaseDiscriminator(LLVMMetadataRef Location, -+ unsigned BD) { -+ DILocation *Loc = unwrapDIPtr(Location); -+ auto NewLoc = Loc->cloneWithBaseDiscriminator(BD); -+ return wrap(NewLoc.has_value() ? NewLoc.value() : nullptr); -+} -+ - extern "C" uint64_t LLVMRustDIBuilderCreateOpDeref() { - return dwarf::DW_OP_deref; - } ---- /dev/null -+++ b/tests/codegen/debuginfo-proc-macro/auxiliary/macro_def.rs -@@ -0,0 +1,11 @@ -+//@ force-host -+//@ no-prefer-dynamic -+#![crate_type = "proc-macro"] -+ -+extern crate proc_macro; -+use proc_macro::*; -+ -+#[proc_macro] -+pub fn square_twice(_item: TokenStream) -> TokenStream { -+ "(square(env::vars().count() as i32), square(env::vars().count() as i32))".parse().unwrap() -+} ---- /dev/null -+++ b/tests/codegen/debuginfo-proc-macro/mir_inlined_twice_var_locs.rs -@@ -0,0 +1,53 @@ -+//@ min-llvm-version: 19 -+//@ compile-flags: -Cdebuginfo=2 -Copt-level=0 -Zmir-enable-passes=+Inline -+// MSVC is different because of the individual allocas. -+//@ ignore-msvc -+ -+//@ aux-build:macro_def.rs -+ -+// Find the variable. -+// CHECK-DAG: ![[#var_dbg:]] = !DILocalVariable(name: "n",{{( arg: 1,)?}} scope: ![[#var_scope:]] -+ -+// Find both dbg_declares. These will proceed the variable metadata, of course, so we're looking -+// backwards. -+// CHECK-DAG: dbg_declare(ptr %n.dbg.spill{{[0-9]}}, ![[#var_dbg]], !DIExpression(), ![[#var_loc2:]]) -+// CHECK-DAG: dbg_declare(ptr %n.dbg.spill, ![[#var_dbg]], !DIExpression(), ![[#var_loc1:]]) -+ -+// Find the first location definition, looking forwards again. -+// CHECK: ![[#var_loc1]] = !DILocation -+// CHECK-SAME: scope: ![[#var_scope:]], inlinedAt: ![[#var_inlinedAt1:]] -+ -+// Find the first location's inlinedAt -+// NB: If we fail here it's *probably* because we failed to produce two -+// different locations and ended up reusing an earlier one. -+// CHECK: ![[#var_inlinedAt1]] = !DILocation -+// CHECK-SAME: scope: ![[var_inlinedAt1_scope:]] -+ -+// Find the second location definition, still looking forwards. -+// NB: If we failed to produce two different locations, the test will -+// definitely fail by this point (if it hasn't already) because we won't -+// be able to find the same line again. -+// CHECK: ![[#var_loc2]] = !DILocation -+// CHECK-SAME: scope: ![[#var_scope]], inlinedAt: ![[#var_inlinedAt2:]] -+ -+// Find the second location's inlinedAt. -+// CHECK: ![[#var_inlinedAt2]] = !DILocation -+// CHECK-SAME: scope: ![[#var_inlinedAt2_scope:]] -+ -+// Finally, check that a discriminator was emitted for the second scope. -+// FIXMEkhuey ideally we would check that *either* scope has a discriminator -+// but I don't know that it's possible to check that with FileCheck. -+// CHECK: ![[#var_inlinedAt2_scope]] = !DILexicalBlockFile -+// CHECK-SAME: discriminator: [[#]] -+extern crate macro_def; -+ -+use std::env; -+ -+fn square(n: i32) -> i32 { -+ n * n -+} -+ -+fn main() { -+ let (z1, z2) = macro_def::square_twice!(); -+ println!("{z1} == {z2}"); -+} From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id C063C1580E0 for ; Mon, 02 Jun 2025 09:51:02 +0000 (UTC) Received: from lists.gentoo.org (bobolink.gentoo.org [140.211.166.189]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) (Authenticated sender: relay-lists.gentoo.org@gentoo.org) by smtp.gentoo.org (Postfix) with ESMTPSA id AEB07343365 for ; Mon, 02 Jun 2025 09:51:02 +0000 (UTC) Received: from bobolink.gentoo.org (localhost [127.0.0.1]) by bobolink.gentoo.org (Postfix) with ESMTP id 949E3110502; Mon, 02 Jun 2025 09:48:41 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bobolink.gentoo.org (Postfix) with ESMTPS id 787901104FB for ; Mon, 02 Jun 2025 09:48:41 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 2E946343234 for ; Mon, 02 Jun 2025 09:48:41 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 76CED28F0 for ; Mon, 02 Jun 2025 09:48:38 +0000 (UTC) From: "Matt Jolly" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Matt Jolly" Message-ID: <1748857629.12cbabf1bf6482e7046a73cd59ba7aa0662f4bf8.kangie@gentoo> Subject: [gentoo-commits] proj/rust-patches:1.86 commit in: / X-VCS-Repository: proj/rust-patches X-VCS-Files: 1.83.0-dwarf-llvm-assertion.patch X-VCS-Directories: / X-VCS-Committer: kangie X-VCS-Committer-Name: Matt Jolly X-VCS-Revision: 12cbabf1bf6482e7046a73cd59ba7aa0662f4bf8 X-VCS-Branch: 1.86 Date: Mon, 02 Jun 2025 09:48:38 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: f6da983c-487d-418a-b657-3f63f39b5e98 X-Archives-Hash: 04abf3da9139c830c2b292267adb32aa Message-ID: <20250602094838.pQ9cdTAC1-JRIBVf_60lf9vLWg_OhjwDG9ado8couFU@z> commit: 12cbabf1bf6482e7046a73cd59ba7aa0662f4bf8 Author: Matt Jolly gentoo org> AuthorDate: Mon Jun 2 09:47:09 2025 +0000 Commit: Matt Jolly gentoo org> CommitDate: Mon Jun 2 09:47:09 2025 +0000 URL: https://gitweb.gentoo.org/proj/rust-patches.git/commit/?id=12cbabf1 Add patches for Rust 1.84.0-r2 Patches: - 1.78.0-musl-dynamic-linking.patch - 1.83.0-cross-compile-libz.patch - 1.67.0-doc-wasm.patch Signed-off-by: Matt Jolly gentoo.org> 1.83.0-dwarf-llvm-assertion.patch | 220 -------------------------------------- 1 file changed, 220 deletions(-) diff --git a/1.83.0-dwarf-llvm-assertion.patch b/1.83.0-dwarf-llvm-assertion.patch deleted file mode 100644 index 96bdac0..0000000 --- a/1.83.0-dwarf-llvm-assertion.patch +++ /dev/null @@ -1,220 +0,0 @@ -From 1dc106121b62562ead6e7d612fa136dc4b35cd5d Mon Sep 17 00:00:00 2001 -From: Kyle Huey -Date: Mon, 4 Nov 2024 11:38:14 -0800 -Subject: [PATCH] Add discriminators to DILocations when multiple functions are - inlined into a single point. - -LLVM does not expect to ever see multiple dbg_declares for the same variable at the same -location with different values. proc-macros make it possible for arbitrary code, -including multiple calls that get inlined, to happen at any given location in the source -code. Add discriminators when that happens so these locations are different to LLVM. - -This may interfere with the AddDiscriminators pass in LLVM, which is added by the -unstable flag -Zdebug-info-for-profiling. - -Fixes #131944 ---- a/compiler/rustc_codegen_llvm/src/debuginfo/create_scope_map.rs -+++ b/compiler/rustc_codegen_llvm/src/debuginfo/create_scope_map.rs -@@ -1,11 +1,15 @@ -+use std::collections::hash_map::Entry; -+ - use rustc_codegen_ssa::mir::debuginfo::{DebugScope, FunctionDebugContext}; - use rustc_codegen_ssa::traits::*; -+use rustc_data_structures::fx::FxHashMap; - use rustc_index::Idx; - use rustc_index::bit_set::BitSet; - use rustc_middle::mir::{Body, SourceScope}; - use rustc_middle::ty::layout::FnAbiOf; - use rustc_middle::ty::{self, Instance}; - use rustc_session::config::DebugInfo; -+use rustc_span::BytePos; - - use super::metadata::file_metadata; - use super::utils::DIB; -@@ -37,10 +41,20 @@ pub(crate) fn compute_mir_scopes<'ll, 'tcx>( - None - }; - let mut instantiated = BitSet::new_empty(mir.source_scopes.len()); -+ let mut discriminators = FxHashMap::default(); - // Instantiate all scopes. - for idx in 0..mir.source_scopes.len() { - let scope = SourceScope::new(idx); -- make_mir_scope(cx, instance, mir, &variables, debug_context, &mut instantiated, scope); -+ make_mir_scope( -+ cx, -+ instance, -+ mir, -+ &variables, -+ debug_context, -+ &mut instantiated, -+ &mut discriminators, -+ scope, -+ ); - } - assert!(instantiated.count() == mir.source_scopes.len()); - } -@@ -52,6 +66,7 @@ fn make_mir_scope<'ll, 'tcx>( - variables: &Option>, - debug_context: &mut FunctionDebugContext<'tcx, &'ll DIScope, &'ll DILocation>, - instantiated: &mut BitSet, -+ discriminators: &mut FxHashMap, - scope: SourceScope, - ) { - if instantiated.contains(scope) { -@@ -60,7 +75,16 @@ fn make_mir_scope<'ll, 'tcx>( - - let scope_data = &mir.source_scopes[scope]; - let parent_scope = if let Some(parent) = scope_data.parent_scope { -- make_mir_scope(cx, instance, mir, variables, debug_context, instantiated, parent); -+ make_mir_scope( -+ cx, -+ instance, -+ mir, -+ variables, -+ debug_context, -+ instantiated, -+ discriminators, -+ parent, -+ ); - debug_context.scopes[parent] - } else { - // The root is the function itself. -@@ -117,7 +141,37 @@ fn make_mir_scope<'ll, 'tcx>( - // FIXME(eddyb) this doesn't account for the macro-related - // `Span` fixups that `rustc_codegen_ssa::mir::debuginfo` does. - let callsite_scope = parent_scope.adjust_dbg_scope_for_span(cx, callsite_span); -- cx.dbg_loc(callsite_scope, parent_scope.inlined_at, callsite_span) -+ let loc = cx.dbg_loc(callsite_scope, parent_scope.inlined_at, callsite_span); -+ -+ // NB: In order to produce proper debug info for variables (particularly -+ // arguments) in multiply-inline functions, LLVM expects to see a single -+ // DILocalVariable with multiple different DILocations in the IR. While -+ // the source information for each DILocation would be identical, their -+ // inlinedAt attributes will be unique to the particular callsite. -+ // -+ // We generate DILocations here based on the callsite's location in the -+ // source code. A single location in the source code usually can't -+ // produce multiple distinct calls so this mostly works, until -+ // proc-macros get involved. A proc-macro can generate multiple calls -+ // at the same span, which breaks the assumption that we're going to -+ // produce a unique DILocation for every scope we process here. We -+ // have to explicitly add discriminators if we see inlines into the -+ // same source code location. -+ // -+ // Note further that we can't key this hashtable on the span itself, -+ // because these spans could have distinct SyntaxContexts. We have -+ // to key on exactly what we're giving to LLVM. -+ match discriminators.entry(callsite_span.lo()) { -+ Entry::Occupied(mut o) => { -+ *o.get_mut() += 1; -+ unsafe { llvm::LLVMRustDILocationCloneWithBaseDiscriminator(loc, *o.get()) } -+ .expect("Failed to encode discriminator in DILocation") -+ } -+ Entry::Vacant(v) => { -+ v.insert(0); -+ loc -+ } -+ } - }); - - debug_context.scopes[scope] = DebugScope { ---- a/compiler/rustc_codegen_llvm/src/llvm/ffi.rs -+++ b/compiler/rustc_codegen_llvm/src/llvm/ffi.rs -@@ -2174,6 +2174,10 @@ unsafe extern "C" { - Scope: &'a DIScope, - InlinedAt: Option<&'a DILocation>, - ) -> &'a DILocation; -+ pub fn LLVMRustDILocationCloneWithBaseDiscriminator<'a>( -+ Location: &'a DILocation, -+ BD: c_uint, -+ ) -> Option<&'a DILocation>; - pub fn LLVMRustDIBuilderCreateOpDeref() -> u64; - pub fn LLVMRustDIBuilderCreateOpPlusUconst() -> u64; - pub fn LLVMRustDIBuilderCreateOpLLVMFragment() -> u64; ---- a/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp -+++ b/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp -@@ -1305,6 +1305,14 @@ LLVMRustDIBuilderCreateDebugLocation(unsigned Line, unsigned Column, - return wrap(Loc); - } - -+extern "C" LLVMMetadataRef -+LLVMRustDILocationCloneWithBaseDiscriminator(LLVMMetadataRef Location, -+ unsigned BD) { -+ DILocation *Loc = unwrapDIPtr(Location); -+ auto NewLoc = Loc->cloneWithBaseDiscriminator(BD); -+ return wrap(NewLoc.has_value() ? NewLoc.value() : nullptr); -+} -+ - extern "C" uint64_t LLVMRustDIBuilderCreateOpDeref() { - return dwarf::DW_OP_deref; - } ---- /dev/null -+++ b/tests/codegen/debuginfo-proc-macro/auxiliary/macro_def.rs -@@ -0,0 +1,11 @@ -+//@ force-host -+//@ no-prefer-dynamic -+#![crate_type = "proc-macro"] -+ -+extern crate proc_macro; -+use proc_macro::*; -+ -+#[proc_macro] -+pub fn square_twice(_item: TokenStream) -> TokenStream { -+ "(square(env::vars().count() as i32), square(env::vars().count() as i32))".parse().unwrap() -+} ---- /dev/null -+++ b/tests/codegen/debuginfo-proc-macro/mir_inlined_twice_var_locs.rs -@@ -0,0 +1,53 @@ -+//@ min-llvm-version: 19 -+//@ compile-flags: -Cdebuginfo=2 -Copt-level=0 -Zmir-enable-passes=+Inline -+// MSVC is different because of the individual allocas. -+//@ ignore-msvc -+ -+//@ aux-build:macro_def.rs -+ -+// Find the variable. -+// CHECK-DAG: ![[#var_dbg:]] = !DILocalVariable(name: "n",{{( arg: 1,)?}} scope: ![[#var_scope:]] -+ -+// Find both dbg_declares. These will proceed the variable metadata, of course, so we're looking -+// backwards. -+// CHECK-DAG: dbg_declare(ptr %n.dbg.spill{{[0-9]}}, ![[#var_dbg]], !DIExpression(), ![[#var_loc2:]]) -+// CHECK-DAG: dbg_declare(ptr %n.dbg.spill, ![[#var_dbg]], !DIExpression(), ![[#var_loc1:]]) -+ -+// Find the first location definition, looking forwards again. -+// CHECK: ![[#var_loc1]] = !DILocation -+// CHECK-SAME: scope: ![[#var_scope:]], inlinedAt: ![[#var_inlinedAt1:]] -+ -+// Find the first location's inlinedAt -+// NB: If we fail here it's *probably* because we failed to produce two -+// different locations and ended up reusing an earlier one. -+// CHECK: ![[#var_inlinedAt1]] = !DILocation -+// CHECK-SAME: scope: ![[var_inlinedAt1_scope:]] -+ -+// Find the second location definition, still looking forwards. -+// NB: If we failed to produce two different locations, the test will -+// definitely fail by this point (if it hasn't already) because we won't -+// be able to find the same line again. -+// CHECK: ![[#var_loc2]] = !DILocation -+// CHECK-SAME: scope: ![[#var_scope]], inlinedAt: ![[#var_inlinedAt2:]] -+ -+// Find the second location's inlinedAt. -+// CHECK: ![[#var_inlinedAt2]] = !DILocation -+// CHECK-SAME: scope: ![[#var_inlinedAt2_scope:]] -+ -+// Finally, check that a discriminator was emitted for the second scope. -+// FIXMEkhuey ideally we would check that *either* scope has a discriminator -+// but I don't know that it's possible to check that with FileCheck. -+// CHECK: ![[#var_inlinedAt2_scope]] = !DILexicalBlockFile -+// CHECK-SAME: discriminator: [[#]] -+extern crate macro_def; -+ -+use std::env; -+ -+fn square(n: i32) -> i32 { -+ n * n -+} -+ -+fn main() { -+ let (z1, z2) = macro_def::square_twice!(); -+ println!("{z1} == {z2}"); -+} From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 8350D1580E0 for ; Mon, 02 Jun 2025 09:51:28 +0000 (UTC) Received: from lists.gentoo.org (bobolink.gentoo.org [140.211.166.189]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) (Authenticated sender: relay-lists.gentoo.org@gentoo.org) by smtp.gentoo.org (Postfix) with ESMTPSA id 7034D343396 for ; Mon, 02 Jun 2025 09:51:28 +0000 (UTC) Received: from bobolink.gentoo.org (localhost [127.0.0.1]) by bobolink.gentoo.org (Postfix) with ESMTP id 09FE111050E; Mon, 02 Jun 2025 09:48:43 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bobolink.gentoo.org (Postfix) with ESMTPS id E624811050D for ; Mon, 02 Jun 2025 09:48:42 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 9A26234321B for ; Mon, 02 Jun 2025 09:48:42 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 86561297F for ; Mon, 02 Jun 2025 09:48:39 +0000 (UTC) From: "Matt Jolly" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Matt Jolly" Message-ID: <1748857629.12cbabf1bf6482e7046a73cd59ba7aa0662f4bf8.kangie@gentoo> Subject: [gentoo-commits] proj/rust-patches:1.87 commit in: / X-VCS-Repository: proj/rust-patches X-VCS-Files: 1.83.0-dwarf-llvm-assertion.patch X-VCS-Directories: / X-VCS-Committer: kangie X-VCS-Committer-Name: Matt Jolly X-VCS-Revision: 12cbabf1bf6482e7046a73cd59ba7aa0662f4bf8 X-VCS-Branch: 1.87 Date: Mon, 02 Jun 2025 09:48:39 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 150e7cc1-7689-4daa-b128-02ea4771fb66 X-Archives-Hash: a143bbc5a5a8700b5c99ccc85eb3ba90 Message-ID: <20250602094839.I4Mv-9rYnKkKDVD5eM5QmUFCMqE_ulCzcviygLnP9sc@z> commit: 12cbabf1bf6482e7046a73cd59ba7aa0662f4bf8 Author: Matt Jolly gentoo org> AuthorDate: Mon Jun 2 09:47:09 2025 +0000 Commit: Matt Jolly gentoo org> CommitDate: Mon Jun 2 09:47:09 2025 +0000 URL: https://gitweb.gentoo.org/proj/rust-patches.git/commit/?id=12cbabf1 Add patches for Rust 1.84.0-r2 Patches: - 1.78.0-musl-dynamic-linking.patch - 1.83.0-cross-compile-libz.patch - 1.67.0-doc-wasm.patch Signed-off-by: Matt Jolly gentoo.org> 1.83.0-dwarf-llvm-assertion.patch | 220 -------------------------------------- 1 file changed, 220 deletions(-) diff --git a/1.83.0-dwarf-llvm-assertion.patch b/1.83.0-dwarf-llvm-assertion.patch deleted file mode 100644 index 96bdac0..0000000 --- a/1.83.0-dwarf-llvm-assertion.patch +++ /dev/null @@ -1,220 +0,0 @@ -From 1dc106121b62562ead6e7d612fa136dc4b35cd5d Mon Sep 17 00:00:00 2001 -From: Kyle Huey -Date: Mon, 4 Nov 2024 11:38:14 -0800 -Subject: [PATCH] Add discriminators to DILocations when multiple functions are - inlined into a single point. - -LLVM does not expect to ever see multiple dbg_declares for the same variable at the same -location with different values. proc-macros make it possible for arbitrary code, -including multiple calls that get inlined, to happen at any given location in the source -code. Add discriminators when that happens so these locations are different to LLVM. - -This may interfere with the AddDiscriminators pass in LLVM, which is added by the -unstable flag -Zdebug-info-for-profiling. - -Fixes #131944 ---- a/compiler/rustc_codegen_llvm/src/debuginfo/create_scope_map.rs -+++ b/compiler/rustc_codegen_llvm/src/debuginfo/create_scope_map.rs -@@ -1,11 +1,15 @@ -+use std::collections::hash_map::Entry; -+ - use rustc_codegen_ssa::mir::debuginfo::{DebugScope, FunctionDebugContext}; - use rustc_codegen_ssa::traits::*; -+use rustc_data_structures::fx::FxHashMap; - use rustc_index::Idx; - use rustc_index::bit_set::BitSet; - use rustc_middle::mir::{Body, SourceScope}; - use rustc_middle::ty::layout::FnAbiOf; - use rustc_middle::ty::{self, Instance}; - use rustc_session::config::DebugInfo; -+use rustc_span::BytePos; - - use super::metadata::file_metadata; - use super::utils::DIB; -@@ -37,10 +41,20 @@ pub(crate) fn compute_mir_scopes<'ll, 'tcx>( - None - }; - let mut instantiated = BitSet::new_empty(mir.source_scopes.len()); -+ let mut discriminators = FxHashMap::default(); - // Instantiate all scopes. - for idx in 0..mir.source_scopes.len() { - let scope = SourceScope::new(idx); -- make_mir_scope(cx, instance, mir, &variables, debug_context, &mut instantiated, scope); -+ make_mir_scope( -+ cx, -+ instance, -+ mir, -+ &variables, -+ debug_context, -+ &mut instantiated, -+ &mut discriminators, -+ scope, -+ ); - } - assert!(instantiated.count() == mir.source_scopes.len()); - } -@@ -52,6 +66,7 @@ fn make_mir_scope<'ll, 'tcx>( - variables: &Option>, - debug_context: &mut FunctionDebugContext<'tcx, &'ll DIScope, &'ll DILocation>, - instantiated: &mut BitSet, -+ discriminators: &mut FxHashMap, - scope: SourceScope, - ) { - if instantiated.contains(scope) { -@@ -60,7 +75,16 @@ fn make_mir_scope<'ll, 'tcx>( - - let scope_data = &mir.source_scopes[scope]; - let parent_scope = if let Some(parent) = scope_data.parent_scope { -- make_mir_scope(cx, instance, mir, variables, debug_context, instantiated, parent); -+ make_mir_scope( -+ cx, -+ instance, -+ mir, -+ variables, -+ debug_context, -+ instantiated, -+ discriminators, -+ parent, -+ ); - debug_context.scopes[parent] - } else { - // The root is the function itself. -@@ -117,7 +141,37 @@ fn make_mir_scope<'ll, 'tcx>( - // FIXME(eddyb) this doesn't account for the macro-related - // `Span` fixups that `rustc_codegen_ssa::mir::debuginfo` does. - let callsite_scope = parent_scope.adjust_dbg_scope_for_span(cx, callsite_span); -- cx.dbg_loc(callsite_scope, parent_scope.inlined_at, callsite_span) -+ let loc = cx.dbg_loc(callsite_scope, parent_scope.inlined_at, callsite_span); -+ -+ // NB: In order to produce proper debug info for variables (particularly -+ // arguments) in multiply-inline functions, LLVM expects to see a single -+ // DILocalVariable with multiple different DILocations in the IR. While -+ // the source information for each DILocation would be identical, their -+ // inlinedAt attributes will be unique to the particular callsite. -+ // -+ // We generate DILocations here based on the callsite's location in the -+ // source code. A single location in the source code usually can't -+ // produce multiple distinct calls so this mostly works, until -+ // proc-macros get involved. A proc-macro can generate multiple calls -+ // at the same span, which breaks the assumption that we're going to -+ // produce a unique DILocation for every scope we process here. We -+ // have to explicitly add discriminators if we see inlines into the -+ // same source code location. -+ // -+ // Note further that we can't key this hashtable on the span itself, -+ // because these spans could have distinct SyntaxContexts. We have -+ // to key on exactly what we're giving to LLVM. -+ match discriminators.entry(callsite_span.lo()) { -+ Entry::Occupied(mut o) => { -+ *o.get_mut() += 1; -+ unsafe { llvm::LLVMRustDILocationCloneWithBaseDiscriminator(loc, *o.get()) } -+ .expect("Failed to encode discriminator in DILocation") -+ } -+ Entry::Vacant(v) => { -+ v.insert(0); -+ loc -+ } -+ } - }); - - debug_context.scopes[scope] = DebugScope { ---- a/compiler/rustc_codegen_llvm/src/llvm/ffi.rs -+++ b/compiler/rustc_codegen_llvm/src/llvm/ffi.rs -@@ -2174,6 +2174,10 @@ unsafe extern "C" { - Scope: &'a DIScope, - InlinedAt: Option<&'a DILocation>, - ) -> &'a DILocation; -+ pub fn LLVMRustDILocationCloneWithBaseDiscriminator<'a>( -+ Location: &'a DILocation, -+ BD: c_uint, -+ ) -> Option<&'a DILocation>; - pub fn LLVMRustDIBuilderCreateOpDeref() -> u64; - pub fn LLVMRustDIBuilderCreateOpPlusUconst() -> u64; - pub fn LLVMRustDIBuilderCreateOpLLVMFragment() -> u64; ---- a/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp -+++ b/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp -@@ -1305,6 +1305,14 @@ LLVMRustDIBuilderCreateDebugLocation(unsigned Line, unsigned Column, - return wrap(Loc); - } - -+extern "C" LLVMMetadataRef -+LLVMRustDILocationCloneWithBaseDiscriminator(LLVMMetadataRef Location, -+ unsigned BD) { -+ DILocation *Loc = unwrapDIPtr(Location); -+ auto NewLoc = Loc->cloneWithBaseDiscriminator(BD); -+ return wrap(NewLoc.has_value() ? NewLoc.value() : nullptr); -+} -+ - extern "C" uint64_t LLVMRustDIBuilderCreateOpDeref() { - return dwarf::DW_OP_deref; - } ---- /dev/null -+++ b/tests/codegen/debuginfo-proc-macro/auxiliary/macro_def.rs -@@ -0,0 +1,11 @@ -+//@ force-host -+//@ no-prefer-dynamic -+#![crate_type = "proc-macro"] -+ -+extern crate proc_macro; -+use proc_macro::*; -+ -+#[proc_macro] -+pub fn square_twice(_item: TokenStream) -> TokenStream { -+ "(square(env::vars().count() as i32), square(env::vars().count() as i32))".parse().unwrap() -+} ---- /dev/null -+++ b/tests/codegen/debuginfo-proc-macro/mir_inlined_twice_var_locs.rs -@@ -0,0 +1,53 @@ -+//@ min-llvm-version: 19 -+//@ compile-flags: -Cdebuginfo=2 -Copt-level=0 -Zmir-enable-passes=+Inline -+// MSVC is different because of the individual allocas. -+//@ ignore-msvc -+ -+//@ aux-build:macro_def.rs -+ -+// Find the variable. -+// CHECK-DAG: ![[#var_dbg:]] = !DILocalVariable(name: "n",{{( arg: 1,)?}} scope: ![[#var_scope:]] -+ -+// Find both dbg_declares. These will proceed the variable metadata, of course, so we're looking -+// backwards. -+// CHECK-DAG: dbg_declare(ptr %n.dbg.spill{{[0-9]}}, ![[#var_dbg]], !DIExpression(), ![[#var_loc2:]]) -+// CHECK-DAG: dbg_declare(ptr %n.dbg.spill, ![[#var_dbg]], !DIExpression(), ![[#var_loc1:]]) -+ -+// Find the first location definition, looking forwards again. -+// CHECK: ![[#var_loc1]] = !DILocation -+// CHECK-SAME: scope: ![[#var_scope:]], inlinedAt: ![[#var_inlinedAt1:]] -+ -+// Find the first location's inlinedAt -+// NB: If we fail here it's *probably* because we failed to produce two -+// different locations and ended up reusing an earlier one. -+// CHECK: ![[#var_inlinedAt1]] = !DILocation -+// CHECK-SAME: scope: ![[var_inlinedAt1_scope:]] -+ -+// Find the second location definition, still looking forwards. -+// NB: If we failed to produce two different locations, the test will -+// definitely fail by this point (if it hasn't already) because we won't -+// be able to find the same line again. -+// CHECK: ![[#var_loc2]] = !DILocation -+// CHECK-SAME: scope: ![[#var_scope]], inlinedAt: ![[#var_inlinedAt2:]] -+ -+// Find the second location's inlinedAt. -+// CHECK: ![[#var_inlinedAt2]] = !DILocation -+// CHECK-SAME: scope: ![[#var_inlinedAt2_scope:]] -+ -+// Finally, check that a discriminator was emitted for the second scope. -+// FIXMEkhuey ideally we would check that *either* scope has a discriminator -+// but I don't know that it's possible to check that with FileCheck. -+// CHECK: ![[#var_inlinedAt2_scope]] = !DILexicalBlockFile -+// CHECK-SAME: discriminator: [[#]] -+extern crate macro_def; -+ -+use std::env; -+ -+fn square(n: i32) -> i32 { -+ n * n -+} -+ -+fn main() { -+ let (z1, z2) = macro_def::square_twice!(); -+ println!("{z1} == {z2}"); -+} From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 51A7F1580E0 for ; Mon, 02 Jun 2025 09:51:47 +0000 (UTC) Received: from lists.gentoo.org (bobolink.gentoo.org [140.211.166.189]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) (Authenticated sender: relay-lists.gentoo.org@gentoo.org) by smtp.gentoo.org (Postfix) with ESMTPSA id 3DA19343308 for ; Mon, 02 Jun 2025 09:51:47 +0000 (UTC) Received: from bobolink.gentoo.org (localhost [127.0.0.1]) by bobolink.gentoo.org (Postfix) with ESMTP id 7C10C11051C; Mon, 02 Jun 2025 09:48:44 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bobolink.gentoo.org (Postfix) with ESMTPS id 6DDB2110519 for ; Mon, 02 Jun 2025 09:48:44 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 24BC23431F8 for ; Mon, 02 Jun 2025 09:48:44 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id A36B92903 for ; Mon, 02 Jun 2025 09:48:40 +0000 (UTC) From: "Matt Jolly" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Matt Jolly" Message-ID: <1748857629.12cbabf1bf6482e7046a73cd59ba7aa0662f4bf8.kangie@gentoo> Subject: [gentoo-commits] proj/rust-patches:1.88 commit in: / X-VCS-Repository: proj/rust-patches X-VCS-Files: 1.83.0-dwarf-llvm-assertion.patch X-VCS-Directories: / X-VCS-Committer: kangie X-VCS-Committer-Name: Matt Jolly X-VCS-Revision: 12cbabf1bf6482e7046a73cd59ba7aa0662f4bf8 X-VCS-Branch: 1.88 Date: Mon, 02 Jun 2025 09:48:40 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 6bbfe9ae-2efa-46d6-97ef-7b287c2a0ffa X-Archives-Hash: c45938a3db722d92912a567cac64d564 Message-ID: <20250602094840.SLtz_RB5ppZ5bgV3hKoa9cBujA0nQd2WTCWrjPwfbOc@z> commit: 12cbabf1bf6482e7046a73cd59ba7aa0662f4bf8 Author: Matt Jolly gentoo org> AuthorDate: Mon Jun 2 09:47:09 2025 +0000 Commit: Matt Jolly gentoo org> CommitDate: Mon Jun 2 09:47:09 2025 +0000 URL: https://gitweb.gentoo.org/proj/rust-patches.git/commit/?id=12cbabf1 Add patches for Rust 1.84.0-r2 Patches: - 1.78.0-musl-dynamic-linking.patch - 1.83.0-cross-compile-libz.patch - 1.67.0-doc-wasm.patch Signed-off-by: Matt Jolly gentoo.org> 1.83.0-dwarf-llvm-assertion.patch | 220 -------------------------------------- 1 file changed, 220 deletions(-) diff --git a/1.83.0-dwarf-llvm-assertion.patch b/1.83.0-dwarf-llvm-assertion.patch deleted file mode 100644 index 96bdac0..0000000 --- a/1.83.0-dwarf-llvm-assertion.patch +++ /dev/null @@ -1,220 +0,0 @@ -From 1dc106121b62562ead6e7d612fa136dc4b35cd5d Mon Sep 17 00:00:00 2001 -From: Kyle Huey -Date: Mon, 4 Nov 2024 11:38:14 -0800 -Subject: [PATCH] Add discriminators to DILocations when multiple functions are - inlined into a single point. - -LLVM does not expect to ever see multiple dbg_declares for the same variable at the same -location with different values. proc-macros make it possible for arbitrary code, -including multiple calls that get inlined, to happen at any given location in the source -code. Add discriminators when that happens so these locations are different to LLVM. - -This may interfere with the AddDiscriminators pass in LLVM, which is added by the -unstable flag -Zdebug-info-for-profiling. - -Fixes #131944 ---- a/compiler/rustc_codegen_llvm/src/debuginfo/create_scope_map.rs -+++ b/compiler/rustc_codegen_llvm/src/debuginfo/create_scope_map.rs -@@ -1,11 +1,15 @@ -+use std::collections::hash_map::Entry; -+ - use rustc_codegen_ssa::mir::debuginfo::{DebugScope, FunctionDebugContext}; - use rustc_codegen_ssa::traits::*; -+use rustc_data_structures::fx::FxHashMap; - use rustc_index::Idx; - use rustc_index::bit_set::BitSet; - use rustc_middle::mir::{Body, SourceScope}; - use rustc_middle::ty::layout::FnAbiOf; - use rustc_middle::ty::{self, Instance}; - use rustc_session::config::DebugInfo; -+use rustc_span::BytePos; - - use super::metadata::file_metadata; - use super::utils::DIB; -@@ -37,10 +41,20 @@ pub(crate) fn compute_mir_scopes<'ll, 'tcx>( - None - }; - let mut instantiated = BitSet::new_empty(mir.source_scopes.len()); -+ let mut discriminators = FxHashMap::default(); - // Instantiate all scopes. - for idx in 0..mir.source_scopes.len() { - let scope = SourceScope::new(idx); -- make_mir_scope(cx, instance, mir, &variables, debug_context, &mut instantiated, scope); -+ make_mir_scope( -+ cx, -+ instance, -+ mir, -+ &variables, -+ debug_context, -+ &mut instantiated, -+ &mut discriminators, -+ scope, -+ ); - } - assert!(instantiated.count() == mir.source_scopes.len()); - } -@@ -52,6 +66,7 @@ fn make_mir_scope<'ll, 'tcx>( - variables: &Option>, - debug_context: &mut FunctionDebugContext<'tcx, &'ll DIScope, &'ll DILocation>, - instantiated: &mut BitSet, -+ discriminators: &mut FxHashMap, - scope: SourceScope, - ) { - if instantiated.contains(scope) { -@@ -60,7 +75,16 @@ fn make_mir_scope<'ll, 'tcx>( - - let scope_data = &mir.source_scopes[scope]; - let parent_scope = if let Some(parent) = scope_data.parent_scope { -- make_mir_scope(cx, instance, mir, variables, debug_context, instantiated, parent); -+ make_mir_scope( -+ cx, -+ instance, -+ mir, -+ variables, -+ debug_context, -+ instantiated, -+ discriminators, -+ parent, -+ ); - debug_context.scopes[parent] - } else { - // The root is the function itself. -@@ -117,7 +141,37 @@ fn make_mir_scope<'ll, 'tcx>( - // FIXME(eddyb) this doesn't account for the macro-related - // `Span` fixups that `rustc_codegen_ssa::mir::debuginfo` does. - let callsite_scope = parent_scope.adjust_dbg_scope_for_span(cx, callsite_span); -- cx.dbg_loc(callsite_scope, parent_scope.inlined_at, callsite_span) -+ let loc = cx.dbg_loc(callsite_scope, parent_scope.inlined_at, callsite_span); -+ -+ // NB: In order to produce proper debug info for variables (particularly -+ // arguments) in multiply-inline functions, LLVM expects to see a single -+ // DILocalVariable with multiple different DILocations in the IR. While -+ // the source information for each DILocation would be identical, their -+ // inlinedAt attributes will be unique to the particular callsite. -+ // -+ // We generate DILocations here based on the callsite's location in the -+ // source code. A single location in the source code usually can't -+ // produce multiple distinct calls so this mostly works, until -+ // proc-macros get involved. A proc-macro can generate multiple calls -+ // at the same span, which breaks the assumption that we're going to -+ // produce a unique DILocation for every scope we process here. We -+ // have to explicitly add discriminators if we see inlines into the -+ // same source code location. -+ // -+ // Note further that we can't key this hashtable on the span itself, -+ // because these spans could have distinct SyntaxContexts. We have -+ // to key on exactly what we're giving to LLVM. -+ match discriminators.entry(callsite_span.lo()) { -+ Entry::Occupied(mut o) => { -+ *o.get_mut() += 1; -+ unsafe { llvm::LLVMRustDILocationCloneWithBaseDiscriminator(loc, *o.get()) } -+ .expect("Failed to encode discriminator in DILocation") -+ } -+ Entry::Vacant(v) => { -+ v.insert(0); -+ loc -+ } -+ } - }); - - debug_context.scopes[scope] = DebugScope { ---- a/compiler/rustc_codegen_llvm/src/llvm/ffi.rs -+++ b/compiler/rustc_codegen_llvm/src/llvm/ffi.rs -@@ -2174,6 +2174,10 @@ unsafe extern "C" { - Scope: &'a DIScope, - InlinedAt: Option<&'a DILocation>, - ) -> &'a DILocation; -+ pub fn LLVMRustDILocationCloneWithBaseDiscriminator<'a>( -+ Location: &'a DILocation, -+ BD: c_uint, -+ ) -> Option<&'a DILocation>; - pub fn LLVMRustDIBuilderCreateOpDeref() -> u64; - pub fn LLVMRustDIBuilderCreateOpPlusUconst() -> u64; - pub fn LLVMRustDIBuilderCreateOpLLVMFragment() -> u64; ---- a/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp -+++ b/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp -@@ -1305,6 +1305,14 @@ LLVMRustDIBuilderCreateDebugLocation(unsigned Line, unsigned Column, - return wrap(Loc); - } - -+extern "C" LLVMMetadataRef -+LLVMRustDILocationCloneWithBaseDiscriminator(LLVMMetadataRef Location, -+ unsigned BD) { -+ DILocation *Loc = unwrapDIPtr(Location); -+ auto NewLoc = Loc->cloneWithBaseDiscriminator(BD); -+ return wrap(NewLoc.has_value() ? NewLoc.value() : nullptr); -+} -+ - extern "C" uint64_t LLVMRustDIBuilderCreateOpDeref() { - return dwarf::DW_OP_deref; - } ---- /dev/null -+++ b/tests/codegen/debuginfo-proc-macro/auxiliary/macro_def.rs -@@ -0,0 +1,11 @@ -+//@ force-host -+//@ no-prefer-dynamic -+#![crate_type = "proc-macro"] -+ -+extern crate proc_macro; -+use proc_macro::*; -+ -+#[proc_macro] -+pub fn square_twice(_item: TokenStream) -> TokenStream { -+ "(square(env::vars().count() as i32), square(env::vars().count() as i32))".parse().unwrap() -+} ---- /dev/null -+++ b/tests/codegen/debuginfo-proc-macro/mir_inlined_twice_var_locs.rs -@@ -0,0 +1,53 @@ -+//@ min-llvm-version: 19 -+//@ compile-flags: -Cdebuginfo=2 -Copt-level=0 -Zmir-enable-passes=+Inline -+// MSVC is different because of the individual allocas. -+//@ ignore-msvc -+ -+//@ aux-build:macro_def.rs -+ -+// Find the variable. -+// CHECK-DAG: ![[#var_dbg:]] = !DILocalVariable(name: "n",{{( arg: 1,)?}} scope: ![[#var_scope:]] -+ -+// Find both dbg_declares. These will proceed the variable metadata, of course, so we're looking -+// backwards. -+// CHECK-DAG: dbg_declare(ptr %n.dbg.spill{{[0-9]}}, ![[#var_dbg]], !DIExpression(), ![[#var_loc2:]]) -+// CHECK-DAG: dbg_declare(ptr %n.dbg.spill, ![[#var_dbg]], !DIExpression(), ![[#var_loc1:]]) -+ -+// Find the first location definition, looking forwards again. -+// CHECK: ![[#var_loc1]] = !DILocation -+// CHECK-SAME: scope: ![[#var_scope:]], inlinedAt: ![[#var_inlinedAt1:]] -+ -+// Find the first location's inlinedAt -+// NB: If we fail here it's *probably* because we failed to produce two -+// different locations and ended up reusing an earlier one. -+// CHECK: ![[#var_inlinedAt1]] = !DILocation -+// CHECK-SAME: scope: ![[var_inlinedAt1_scope:]] -+ -+// Find the second location definition, still looking forwards. -+// NB: If we failed to produce two different locations, the test will -+// definitely fail by this point (if it hasn't already) because we won't -+// be able to find the same line again. -+// CHECK: ![[#var_loc2]] = !DILocation -+// CHECK-SAME: scope: ![[#var_scope]], inlinedAt: ![[#var_inlinedAt2:]] -+ -+// Find the second location's inlinedAt. -+// CHECK: ![[#var_inlinedAt2]] = !DILocation -+// CHECK-SAME: scope: ![[#var_inlinedAt2_scope:]] -+ -+// Finally, check that a discriminator was emitted for the second scope. -+// FIXMEkhuey ideally we would check that *either* scope has a discriminator -+// but I don't know that it's possible to check that with FileCheck. -+// CHECK: ![[#var_inlinedAt2_scope]] = !DILexicalBlockFile -+// CHECK-SAME: discriminator: [[#]] -+extern crate macro_def; -+ -+use std::env; -+ -+fn square(n: i32) -> i32 { -+ n * n -+} -+ -+fn main() { -+ let (z1, z2) = macro_def::square_twice!(); -+ println!("{z1} == {z2}"); -+} From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id C88031580E0 for ; Mon, 02 Jun 2025 09:52:09 +0000 (UTC) Received: from lists.gentoo.org (bobolink.gentoo.org [140.211.166.189]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) (Authenticated sender: relay-lists.gentoo.org@gentoo.org) by smtp.gentoo.org (Postfix) with ESMTPSA id B504D34069F for ; Mon, 02 Jun 2025 09:52:09 +0000 (UTC) Received: from bobolink.gentoo.org (localhost [127.0.0.1]) by bobolink.gentoo.org (Postfix) with ESMTP id CB972110480; Mon, 02 Jun 2025 09:48:44 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bobolink.gentoo.org (Postfix) with ESMTPS id B4FAD110480 for ; Mon, 02 Jun 2025 09:48:44 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 6D4183431F7 for ; Mon, 02 Jun 2025 09:48:44 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id CE76328F1 for ; Mon, 02 Jun 2025 09:48:41 +0000 (UTC) From: "Matt Jolly" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Matt Jolly" Message-ID: <1748857629.12cbabf1bf6482e7046a73cd59ba7aa0662f4bf8.kangie@gentoo> Subject: [gentoo-commits] proj/rust-patches:master commit in: / X-VCS-Repository: proj/rust-patches X-VCS-Files: 1.83.0-dwarf-llvm-assertion.patch X-VCS-Directories: / X-VCS-Committer: kangie X-VCS-Committer-Name: Matt Jolly X-VCS-Revision: 12cbabf1bf6482e7046a73cd59ba7aa0662f4bf8 X-VCS-Branch: master Date: Mon, 02 Jun 2025 09:48:41 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 229e8555-d3fc-4e30-98c6-a917f0a2e2e7 X-Archives-Hash: c8991f3f3a874ffb4628665ebf6f8616 Message-ID: <20250602094841.f57z47BY5K5FXadmL0o4_gD6Fy1NBptSo7WnSt-egaI@z> commit: 12cbabf1bf6482e7046a73cd59ba7aa0662f4bf8 Author: Matt Jolly gentoo org> AuthorDate: Mon Jun 2 09:47:09 2025 +0000 Commit: Matt Jolly gentoo org> CommitDate: Mon Jun 2 09:47:09 2025 +0000 URL: https://gitweb.gentoo.org/proj/rust-patches.git/commit/?id=12cbabf1 Add patches for Rust 1.84.0-r2 Patches: - 1.78.0-musl-dynamic-linking.patch - 1.83.0-cross-compile-libz.patch - 1.67.0-doc-wasm.patch Signed-off-by: Matt Jolly gentoo.org> 1.83.0-dwarf-llvm-assertion.patch | 220 -------------------------------------- 1 file changed, 220 deletions(-) diff --git a/1.83.0-dwarf-llvm-assertion.patch b/1.83.0-dwarf-llvm-assertion.patch deleted file mode 100644 index 96bdac0..0000000 --- a/1.83.0-dwarf-llvm-assertion.patch +++ /dev/null @@ -1,220 +0,0 @@ -From 1dc106121b62562ead6e7d612fa136dc4b35cd5d Mon Sep 17 00:00:00 2001 -From: Kyle Huey -Date: Mon, 4 Nov 2024 11:38:14 -0800 -Subject: [PATCH] Add discriminators to DILocations when multiple functions are - inlined into a single point. - -LLVM does not expect to ever see multiple dbg_declares for the same variable at the same -location with different values. proc-macros make it possible for arbitrary code, -including multiple calls that get inlined, to happen at any given location in the source -code. Add discriminators when that happens so these locations are different to LLVM. - -This may interfere with the AddDiscriminators pass in LLVM, which is added by the -unstable flag -Zdebug-info-for-profiling. - -Fixes #131944 ---- a/compiler/rustc_codegen_llvm/src/debuginfo/create_scope_map.rs -+++ b/compiler/rustc_codegen_llvm/src/debuginfo/create_scope_map.rs -@@ -1,11 +1,15 @@ -+use std::collections::hash_map::Entry; -+ - use rustc_codegen_ssa::mir::debuginfo::{DebugScope, FunctionDebugContext}; - use rustc_codegen_ssa::traits::*; -+use rustc_data_structures::fx::FxHashMap; - use rustc_index::Idx; - use rustc_index::bit_set::BitSet; - use rustc_middle::mir::{Body, SourceScope}; - use rustc_middle::ty::layout::FnAbiOf; - use rustc_middle::ty::{self, Instance}; - use rustc_session::config::DebugInfo; -+use rustc_span::BytePos; - - use super::metadata::file_metadata; - use super::utils::DIB; -@@ -37,10 +41,20 @@ pub(crate) fn compute_mir_scopes<'ll, 'tcx>( - None - }; - let mut instantiated = BitSet::new_empty(mir.source_scopes.len()); -+ let mut discriminators = FxHashMap::default(); - // Instantiate all scopes. - for idx in 0..mir.source_scopes.len() { - let scope = SourceScope::new(idx); -- make_mir_scope(cx, instance, mir, &variables, debug_context, &mut instantiated, scope); -+ make_mir_scope( -+ cx, -+ instance, -+ mir, -+ &variables, -+ debug_context, -+ &mut instantiated, -+ &mut discriminators, -+ scope, -+ ); - } - assert!(instantiated.count() == mir.source_scopes.len()); - } -@@ -52,6 +66,7 @@ fn make_mir_scope<'ll, 'tcx>( - variables: &Option>, - debug_context: &mut FunctionDebugContext<'tcx, &'ll DIScope, &'ll DILocation>, - instantiated: &mut BitSet, -+ discriminators: &mut FxHashMap, - scope: SourceScope, - ) { - if instantiated.contains(scope) { -@@ -60,7 +75,16 @@ fn make_mir_scope<'ll, 'tcx>( - - let scope_data = &mir.source_scopes[scope]; - let parent_scope = if let Some(parent) = scope_data.parent_scope { -- make_mir_scope(cx, instance, mir, variables, debug_context, instantiated, parent); -+ make_mir_scope( -+ cx, -+ instance, -+ mir, -+ variables, -+ debug_context, -+ instantiated, -+ discriminators, -+ parent, -+ ); - debug_context.scopes[parent] - } else { - // The root is the function itself. -@@ -117,7 +141,37 @@ fn make_mir_scope<'ll, 'tcx>( - // FIXME(eddyb) this doesn't account for the macro-related - // `Span` fixups that `rustc_codegen_ssa::mir::debuginfo` does. - let callsite_scope = parent_scope.adjust_dbg_scope_for_span(cx, callsite_span); -- cx.dbg_loc(callsite_scope, parent_scope.inlined_at, callsite_span) -+ let loc = cx.dbg_loc(callsite_scope, parent_scope.inlined_at, callsite_span); -+ -+ // NB: In order to produce proper debug info for variables (particularly -+ // arguments) in multiply-inline functions, LLVM expects to see a single -+ // DILocalVariable with multiple different DILocations in the IR. While -+ // the source information for each DILocation would be identical, their -+ // inlinedAt attributes will be unique to the particular callsite. -+ // -+ // We generate DILocations here based on the callsite's location in the -+ // source code. A single location in the source code usually can't -+ // produce multiple distinct calls so this mostly works, until -+ // proc-macros get involved. A proc-macro can generate multiple calls -+ // at the same span, which breaks the assumption that we're going to -+ // produce a unique DILocation for every scope we process here. We -+ // have to explicitly add discriminators if we see inlines into the -+ // same source code location. -+ // -+ // Note further that we can't key this hashtable on the span itself, -+ // because these spans could have distinct SyntaxContexts. We have -+ // to key on exactly what we're giving to LLVM. -+ match discriminators.entry(callsite_span.lo()) { -+ Entry::Occupied(mut o) => { -+ *o.get_mut() += 1; -+ unsafe { llvm::LLVMRustDILocationCloneWithBaseDiscriminator(loc, *o.get()) } -+ .expect("Failed to encode discriminator in DILocation") -+ } -+ Entry::Vacant(v) => { -+ v.insert(0); -+ loc -+ } -+ } - }); - - debug_context.scopes[scope] = DebugScope { ---- a/compiler/rustc_codegen_llvm/src/llvm/ffi.rs -+++ b/compiler/rustc_codegen_llvm/src/llvm/ffi.rs -@@ -2174,6 +2174,10 @@ unsafe extern "C" { - Scope: &'a DIScope, - InlinedAt: Option<&'a DILocation>, - ) -> &'a DILocation; -+ pub fn LLVMRustDILocationCloneWithBaseDiscriminator<'a>( -+ Location: &'a DILocation, -+ BD: c_uint, -+ ) -> Option<&'a DILocation>; - pub fn LLVMRustDIBuilderCreateOpDeref() -> u64; - pub fn LLVMRustDIBuilderCreateOpPlusUconst() -> u64; - pub fn LLVMRustDIBuilderCreateOpLLVMFragment() -> u64; ---- a/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp -+++ b/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp -@@ -1305,6 +1305,14 @@ LLVMRustDIBuilderCreateDebugLocation(unsigned Line, unsigned Column, - return wrap(Loc); - } - -+extern "C" LLVMMetadataRef -+LLVMRustDILocationCloneWithBaseDiscriminator(LLVMMetadataRef Location, -+ unsigned BD) { -+ DILocation *Loc = unwrapDIPtr(Location); -+ auto NewLoc = Loc->cloneWithBaseDiscriminator(BD); -+ return wrap(NewLoc.has_value() ? NewLoc.value() : nullptr); -+} -+ - extern "C" uint64_t LLVMRustDIBuilderCreateOpDeref() { - return dwarf::DW_OP_deref; - } ---- /dev/null -+++ b/tests/codegen/debuginfo-proc-macro/auxiliary/macro_def.rs -@@ -0,0 +1,11 @@ -+//@ force-host -+//@ no-prefer-dynamic -+#![crate_type = "proc-macro"] -+ -+extern crate proc_macro; -+use proc_macro::*; -+ -+#[proc_macro] -+pub fn square_twice(_item: TokenStream) -> TokenStream { -+ "(square(env::vars().count() as i32), square(env::vars().count() as i32))".parse().unwrap() -+} ---- /dev/null -+++ b/tests/codegen/debuginfo-proc-macro/mir_inlined_twice_var_locs.rs -@@ -0,0 +1,53 @@ -+//@ min-llvm-version: 19 -+//@ compile-flags: -Cdebuginfo=2 -Copt-level=0 -Zmir-enable-passes=+Inline -+// MSVC is different because of the individual allocas. -+//@ ignore-msvc -+ -+//@ aux-build:macro_def.rs -+ -+// Find the variable. -+// CHECK-DAG: ![[#var_dbg:]] = !DILocalVariable(name: "n",{{( arg: 1,)?}} scope: ![[#var_scope:]] -+ -+// Find both dbg_declares. These will proceed the variable metadata, of course, so we're looking -+// backwards. -+// CHECK-DAG: dbg_declare(ptr %n.dbg.spill{{[0-9]}}, ![[#var_dbg]], !DIExpression(), ![[#var_loc2:]]) -+// CHECK-DAG: dbg_declare(ptr %n.dbg.spill, ![[#var_dbg]], !DIExpression(), ![[#var_loc1:]]) -+ -+// Find the first location definition, looking forwards again. -+// CHECK: ![[#var_loc1]] = !DILocation -+// CHECK-SAME: scope: ![[#var_scope:]], inlinedAt: ![[#var_inlinedAt1:]] -+ -+// Find the first location's inlinedAt -+// NB: If we fail here it's *probably* because we failed to produce two -+// different locations and ended up reusing an earlier one. -+// CHECK: ![[#var_inlinedAt1]] = !DILocation -+// CHECK-SAME: scope: ![[var_inlinedAt1_scope:]] -+ -+// Find the second location definition, still looking forwards. -+// NB: If we failed to produce two different locations, the test will -+// definitely fail by this point (if it hasn't already) because we won't -+// be able to find the same line again. -+// CHECK: ![[#var_loc2]] = !DILocation -+// CHECK-SAME: scope: ![[#var_scope]], inlinedAt: ![[#var_inlinedAt2:]] -+ -+// Find the second location's inlinedAt. -+// CHECK: ![[#var_inlinedAt2]] = !DILocation -+// CHECK-SAME: scope: ![[#var_inlinedAt2_scope:]] -+ -+// Finally, check that a discriminator was emitted for the second scope. -+// FIXMEkhuey ideally we would check that *either* scope has a discriminator -+// but I don't know that it's possible to check that with FileCheck. -+// CHECK: ![[#var_inlinedAt2_scope]] = !DILexicalBlockFile -+// CHECK-SAME: discriminator: [[#]] -+extern crate macro_def; -+ -+use std::env; -+ -+fn square(n: i32) -> i32 { -+ n * n -+} -+ -+fn main() { -+ let (z1, z2) = macro_def::square_twice!(); -+ println!("{z1} == {z2}"); -+} From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 582051580E0 for ; Mon, 02 Jun 2025 09:54:09 +0000 (UTC) Received: from lists.gentoo.org (bobolink.gentoo.org [140.211.166.189]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) (Authenticated sender: relay-lists.gentoo.org@gentoo.org) by smtp.gentoo.org (Postfix) with ESMTPSA id 46926343429 for ; Mon, 02 Jun 2025 09:54:09 +0000 (UTC) Received: from bobolink.gentoo.org (localhost [127.0.0.1]) by bobolink.gentoo.org (Postfix) with ESMTP id 177B1110566; Mon, 02 Jun 2025 09:49:03 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bobolink.gentoo.org (Postfix) with ESMTPS id 0737B110562 for ; Mon, 02 Jun 2025 09:49:03 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id B563334327C for ; Mon, 02 Jun 2025 09:49:02 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 0050027BD for ; Mon, 02 Jun 2025 09:49:00 +0000 (UTC) From: "Matt Jolly" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Matt Jolly" Message-ID: <1748857629.12cbabf1bf6482e7046a73cd59ba7aa0662f4bf8.kangie@gentoo> Subject: [gentoo-commits] proj/rust-patches:1.84.0-r2 commit in: / X-VCS-Repository: proj/rust-patches X-VCS-Files: 1.83.0-dwarf-llvm-assertion.patch X-VCS-Directories: / X-VCS-Committer: kangie X-VCS-Committer-Name: Matt Jolly X-VCS-Revision: 12cbabf1bf6482e7046a73cd59ba7aa0662f4bf8 X-VCS-Branch: 1.84.0-r2 Date: Mon, 02 Jun 2025 09:49:00 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: cccdf0a0-2334-45bf-a891-f5b2565a527a X-Archives-Hash: 340e62319fbc4d1cdcd4cf1680243000 Message-ID: <20250602094900.MFZg73mK3K7aTgkAjW7PdNxRFP1ctjkdk4RcceJUUOQ@z> commit: 12cbabf1bf6482e7046a73cd59ba7aa0662f4bf8 Author: Matt Jolly gentoo org> AuthorDate: Mon Jun 2 09:47:09 2025 +0000 Commit: Matt Jolly gentoo org> CommitDate: Mon Jun 2 09:47:09 2025 +0000 URL: https://gitweb.gentoo.org/proj/rust-patches.git/commit/?id=12cbabf1 Add patches for Rust 1.84.0-r2 Patches: - 1.78.0-musl-dynamic-linking.patch - 1.83.0-cross-compile-libz.patch - 1.67.0-doc-wasm.patch Signed-off-by: Matt Jolly gentoo.org> 1.83.0-dwarf-llvm-assertion.patch | 220 -------------------------------------- 1 file changed, 220 deletions(-) diff --git a/1.83.0-dwarf-llvm-assertion.patch b/1.83.0-dwarf-llvm-assertion.patch deleted file mode 100644 index 96bdac0..0000000 --- a/1.83.0-dwarf-llvm-assertion.patch +++ /dev/null @@ -1,220 +0,0 @@ -From 1dc106121b62562ead6e7d612fa136dc4b35cd5d Mon Sep 17 00:00:00 2001 -From: Kyle Huey -Date: Mon, 4 Nov 2024 11:38:14 -0800 -Subject: [PATCH] Add discriminators to DILocations when multiple functions are - inlined into a single point. - -LLVM does not expect to ever see multiple dbg_declares for the same variable at the same -location with different values. proc-macros make it possible for arbitrary code, -including multiple calls that get inlined, to happen at any given location in the source -code. Add discriminators when that happens so these locations are different to LLVM. - -This may interfere with the AddDiscriminators pass in LLVM, which is added by the -unstable flag -Zdebug-info-for-profiling. - -Fixes #131944 ---- a/compiler/rustc_codegen_llvm/src/debuginfo/create_scope_map.rs -+++ b/compiler/rustc_codegen_llvm/src/debuginfo/create_scope_map.rs -@@ -1,11 +1,15 @@ -+use std::collections::hash_map::Entry; -+ - use rustc_codegen_ssa::mir::debuginfo::{DebugScope, FunctionDebugContext}; - use rustc_codegen_ssa::traits::*; -+use rustc_data_structures::fx::FxHashMap; - use rustc_index::Idx; - use rustc_index::bit_set::BitSet; - use rustc_middle::mir::{Body, SourceScope}; - use rustc_middle::ty::layout::FnAbiOf; - use rustc_middle::ty::{self, Instance}; - use rustc_session::config::DebugInfo; -+use rustc_span::BytePos; - - use super::metadata::file_metadata; - use super::utils::DIB; -@@ -37,10 +41,20 @@ pub(crate) fn compute_mir_scopes<'ll, 'tcx>( - None - }; - let mut instantiated = BitSet::new_empty(mir.source_scopes.len()); -+ let mut discriminators = FxHashMap::default(); - // Instantiate all scopes. - for idx in 0..mir.source_scopes.len() { - let scope = SourceScope::new(idx); -- make_mir_scope(cx, instance, mir, &variables, debug_context, &mut instantiated, scope); -+ make_mir_scope( -+ cx, -+ instance, -+ mir, -+ &variables, -+ debug_context, -+ &mut instantiated, -+ &mut discriminators, -+ scope, -+ ); - } - assert!(instantiated.count() == mir.source_scopes.len()); - } -@@ -52,6 +66,7 @@ fn make_mir_scope<'ll, 'tcx>( - variables: &Option>, - debug_context: &mut FunctionDebugContext<'tcx, &'ll DIScope, &'ll DILocation>, - instantiated: &mut BitSet, -+ discriminators: &mut FxHashMap, - scope: SourceScope, - ) { - if instantiated.contains(scope) { -@@ -60,7 +75,16 @@ fn make_mir_scope<'ll, 'tcx>( - - let scope_data = &mir.source_scopes[scope]; - let parent_scope = if let Some(parent) = scope_data.parent_scope { -- make_mir_scope(cx, instance, mir, variables, debug_context, instantiated, parent); -+ make_mir_scope( -+ cx, -+ instance, -+ mir, -+ variables, -+ debug_context, -+ instantiated, -+ discriminators, -+ parent, -+ ); - debug_context.scopes[parent] - } else { - // The root is the function itself. -@@ -117,7 +141,37 @@ fn make_mir_scope<'ll, 'tcx>( - // FIXME(eddyb) this doesn't account for the macro-related - // `Span` fixups that `rustc_codegen_ssa::mir::debuginfo` does. - let callsite_scope = parent_scope.adjust_dbg_scope_for_span(cx, callsite_span); -- cx.dbg_loc(callsite_scope, parent_scope.inlined_at, callsite_span) -+ let loc = cx.dbg_loc(callsite_scope, parent_scope.inlined_at, callsite_span); -+ -+ // NB: In order to produce proper debug info for variables (particularly -+ // arguments) in multiply-inline functions, LLVM expects to see a single -+ // DILocalVariable with multiple different DILocations in the IR. While -+ // the source information for each DILocation would be identical, their -+ // inlinedAt attributes will be unique to the particular callsite. -+ // -+ // We generate DILocations here based on the callsite's location in the -+ // source code. A single location in the source code usually can't -+ // produce multiple distinct calls so this mostly works, until -+ // proc-macros get involved. A proc-macro can generate multiple calls -+ // at the same span, which breaks the assumption that we're going to -+ // produce a unique DILocation for every scope we process here. We -+ // have to explicitly add discriminators if we see inlines into the -+ // same source code location. -+ // -+ // Note further that we can't key this hashtable on the span itself, -+ // because these spans could have distinct SyntaxContexts. We have -+ // to key on exactly what we're giving to LLVM. -+ match discriminators.entry(callsite_span.lo()) { -+ Entry::Occupied(mut o) => { -+ *o.get_mut() += 1; -+ unsafe { llvm::LLVMRustDILocationCloneWithBaseDiscriminator(loc, *o.get()) } -+ .expect("Failed to encode discriminator in DILocation") -+ } -+ Entry::Vacant(v) => { -+ v.insert(0); -+ loc -+ } -+ } - }); - - debug_context.scopes[scope] = DebugScope { ---- a/compiler/rustc_codegen_llvm/src/llvm/ffi.rs -+++ b/compiler/rustc_codegen_llvm/src/llvm/ffi.rs -@@ -2174,6 +2174,10 @@ unsafe extern "C" { - Scope: &'a DIScope, - InlinedAt: Option<&'a DILocation>, - ) -> &'a DILocation; -+ pub fn LLVMRustDILocationCloneWithBaseDiscriminator<'a>( -+ Location: &'a DILocation, -+ BD: c_uint, -+ ) -> Option<&'a DILocation>; - pub fn LLVMRustDIBuilderCreateOpDeref() -> u64; - pub fn LLVMRustDIBuilderCreateOpPlusUconst() -> u64; - pub fn LLVMRustDIBuilderCreateOpLLVMFragment() -> u64; ---- a/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp -+++ b/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp -@@ -1305,6 +1305,14 @@ LLVMRustDIBuilderCreateDebugLocation(unsigned Line, unsigned Column, - return wrap(Loc); - } - -+extern "C" LLVMMetadataRef -+LLVMRustDILocationCloneWithBaseDiscriminator(LLVMMetadataRef Location, -+ unsigned BD) { -+ DILocation *Loc = unwrapDIPtr(Location); -+ auto NewLoc = Loc->cloneWithBaseDiscriminator(BD); -+ return wrap(NewLoc.has_value() ? NewLoc.value() : nullptr); -+} -+ - extern "C" uint64_t LLVMRustDIBuilderCreateOpDeref() { - return dwarf::DW_OP_deref; - } ---- /dev/null -+++ b/tests/codegen/debuginfo-proc-macro/auxiliary/macro_def.rs -@@ -0,0 +1,11 @@ -+//@ force-host -+//@ no-prefer-dynamic -+#![crate_type = "proc-macro"] -+ -+extern crate proc_macro; -+use proc_macro::*; -+ -+#[proc_macro] -+pub fn square_twice(_item: TokenStream) -> TokenStream { -+ "(square(env::vars().count() as i32), square(env::vars().count() as i32))".parse().unwrap() -+} ---- /dev/null -+++ b/tests/codegen/debuginfo-proc-macro/mir_inlined_twice_var_locs.rs -@@ -0,0 +1,53 @@ -+//@ min-llvm-version: 19 -+//@ compile-flags: -Cdebuginfo=2 -Copt-level=0 -Zmir-enable-passes=+Inline -+// MSVC is different because of the individual allocas. -+//@ ignore-msvc -+ -+//@ aux-build:macro_def.rs -+ -+// Find the variable. -+// CHECK-DAG: ![[#var_dbg:]] = !DILocalVariable(name: "n",{{( arg: 1,)?}} scope: ![[#var_scope:]] -+ -+// Find both dbg_declares. These will proceed the variable metadata, of course, so we're looking -+// backwards. -+// CHECK-DAG: dbg_declare(ptr %n.dbg.spill{{[0-9]}}, ![[#var_dbg]], !DIExpression(), ![[#var_loc2:]]) -+// CHECK-DAG: dbg_declare(ptr %n.dbg.spill, ![[#var_dbg]], !DIExpression(), ![[#var_loc1:]]) -+ -+// Find the first location definition, looking forwards again. -+// CHECK: ![[#var_loc1]] = !DILocation -+// CHECK-SAME: scope: ![[#var_scope:]], inlinedAt: ![[#var_inlinedAt1:]] -+ -+// Find the first location's inlinedAt -+// NB: If we fail here it's *probably* because we failed to produce two -+// different locations and ended up reusing an earlier one. -+// CHECK: ![[#var_inlinedAt1]] = !DILocation -+// CHECK-SAME: scope: ![[var_inlinedAt1_scope:]] -+ -+// Find the second location definition, still looking forwards. -+// NB: If we failed to produce two different locations, the test will -+// definitely fail by this point (if it hasn't already) because we won't -+// be able to find the same line again. -+// CHECK: ![[#var_loc2]] = !DILocation -+// CHECK-SAME: scope: ![[#var_scope]], inlinedAt: ![[#var_inlinedAt2:]] -+ -+// Find the second location's inlinedAt. -+// CHECK: ![[#var_inlinedAt2]] = !DILocation -+// CHECK-SAME: scope: ![[#var_inlinedAt2_scope:]] -+ -+// Finally, check that a discriminator was emitted for the second scope. -+// FIXMEkhuey ideally we would check that *either* scope has a discriminator -+// but I don't know that it's possible to check that with FileCheck. -+// CHECK: ![[#var_inlinedAt2_scope]] = !DILexicalBlockFile -+// CHECK-SAME: discriminator: [[#]] -+extern crate macro_def; -+ -+use std::env; -+ -+fn square(n: i32) -> i32 { -+ n * n -+} -+ -+fn main() { -+ let (z1, z2) = macro_def::square_twice!(); -+ println!("{z1} == {z2}"); -+} From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 463401580E0 for ; Mon, 02 Jun 2025 09:54:25 +0000 (UTC) Received: from lists.gentoo.org (bobolink.gentoo.org [140.211.166.189]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) (Authenticated sender: relay-lists.gentoo.org@gentoo.org) by smtp.gentoo.org (Postfix) with ESMTPSA id 208443433F6 for ; Mon, 02 Jun 2025 09:54:25 +0000 (UTC) Received: from bobolink.gentoo.org (localhost [127.0.0.1]) by bobolink.gentoo.org (Postfix) with ESMTP id 757121104B9; Mon, 02 Jun 2025 09:49:04 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bobolink.gentoo.org (Postfix) with ESMTPS id 6F8F211056E for ; Mon, 02 Jun 2025 09:49:04 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 1786D343276 for ; Mon, 02 Jun 2025 09:49:04 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id C1F5B291E for ; Mon, 02 Jun 2025 09:49:00 +0000 (UTC) From: "Matt Jolly" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Matt Jolly" Message-ID: <1748857629.12cbabf1bf6482e7046a73cd59ba7aa0662f4bf8.kangie@gentoo> Subject: [gentoo-commits] proj/rust-patches:1.84.1-r2 commit in: / X-VCS-Repository: proj/rust-patches X-VCS-Files: 1.83.0-dwarf-llvm-assertion.patch X-VCS-Directories: / X-VCS-Committer: kangie X-VCS-Committer-Name: Matt Jolly X-VCS-Revision: 12cbabf1bf6482e7046a73cd59ba7aa0662f4bf8 X-VCS-Branch: 1.84.1-r2 Date: Mon, 02 Jun 2025 09:49:00 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 9fdbde2d-8ae2-46a7-b9ba-63bae15d88c2 X-Archives-Hash: 54c8b1e075ad133fa39ab85099376b15 Message-ID: <20250602094900.-GU_S0qQxshp6TCwNJAkrl1_Tn6ZNzZJEr0gS081uSM@z> commit: 12cbabf1bf6482e7046a73cd59ba7aa0662f4bf8 Author: Matt Jolly gentoo org> AuthorDate: Mon Jun 2 09:47:09 2025 +0000 Commit: Matt Jolly gentoo org> CommitDate: Mon Jun 2 09:47:09 2025 +0000 URL: https://gitweb.gentoo.org/proj/rust-patches.git/commit/?id=12cbabf1 Add patches for Rust 1.84.0-r2 Patches: - 1.78.0-musl-dynamic-linking.patch - 1.83.0-cross-compile-libz.patch - 1.67.0-doc-wasm.patch Signed-off-by: Matt Jolly gentoo.org> 1.83.0-dwarf-llvm-assertion.patch | 220 -------------------------------------- 1 file changed, 220 deletions(-) diff --git a/1.83.0-dwarf-llvm-assertion.patch b/1.83.0-dwarf-llvm-assertion.patch deleted file mode 100644 index 96bdac0..0000000 --- a/1.83.0-dwarf-llvm-assertion.patch +++ /dev/null @@ -1,220 +0,0 @@ -From 1dc106121b62562ead6e7d612fa136dc4b35cd5d Mon Sep 17 00:00:00 2001 -From: Kyle Huey -Date: Mon, 4 Nov 2024 11:38:14 -0800 -Subject: [PATCH] Add discriminators to DILocations when multiple functions are - inlined into a single point. - -LLVM does not expect to ever see multiple dbg_declares for the same variable at the same -location with different values. proc-macros make it possible for arbitrary code, -including multiple calls that get inlined, to happen at any given location in the source -code. Add discriminators when that happens so these locations are different to LLVM. - -This may interfere with the AddDiscriminators pass in LLVM, which is added by the -unstable flag -Zdebug-info-for-profiling. - -Fixes #131944 ---- a/compiler/rustc_codegen_llvm/src/debuginfo/create_scope_map.rs -+++ b/compiler/rustc_codegen_llvm/src/debuginfo/create_scope_map.rs -@@ -1,11 +1,15 @@ -+use std::collections::hash_map::Entry; -+ - use rustc_codegen_ssa::mir::debuginfo::{DebugScope, FunctionDebugContext}; - use rustc_codegen_ssa::traits::*; -+use rustc_data_structures::fx::FxHashMap; - use rustc_index::Idx; - use rustc_index::bit_set::BitSet; - use rustc_middle::mir::{Body, SourceScope}; - use rustc_middle::ty::layout::FnAbiOf; - use rustc_middle::ty::{self, Instance}; - use rustc_session::config::DebugInfo; -+use rustc_span::BytePos; - - use super::metadata::file_metadata; - use super::utils::DIB; -@@ -37,10 +41,20 @@ pub(crate) fn compute_mir_scopes<'ll, 'tcx>( - None - }; - let mut instantiated = BitSet::new_empty(mir.source_scopes.len()); -+ let mut discriminators = FxHashMap::default(); - // Instantiate all scopes. - for idx in 0..mir.source_scopes.len() { - let scope = SourceScope::new(idx); -- make_mir_scope(cx, instance, mir, &variables, debug_context, &mut instantiated, scope); -+ make_mir_scope( -+ cx, -+ instance, -+ mir, -+ &variables, -+ debug_context, -+ &mut instantiated, -+ &mut discriminators, -+ scope, -+ ); - } - assert!(instantiated.count() == mir.source_scopes.len()); - } -@@ -52,6 +66,7 @@ fn make_mir_scope<'ll, 'tcx>( - variables: &Option>, - debug_context: &mut FunctionDebugContext<'tcx, &'ll DIScope, &'ll DILocation>, - instantiated: &mut BitSet, -+ discriminators: &mut FxHashMap, - scope: SourceScope, - ) { - if instantiated.contains(scope) { -@@ -60,7 +75,16 @@ fn make_mir_scope<'ll, 'tcx>( - - let scope_data = &mir.source_scopes[scope]; - let parent_scope = if let Some(parent) = scope_data.parent_scope { -- make_mir_scope(cx, instance, mir, variables, debug_context, instantiated, parent); -+ make_mir_scope( -+ cx, -+ instance, -+ mir, -+ variables, -+ debug_context, -+ instantiated, -+ discriminators, -+ parent, -+ ); - debug_context.scopes[parent] - } else { - // The root is the function itself. -@@ -117,7 +141,37 @@ fn make_mir_scope<'ll, 'tcx>( - // FIXME(eddyb) this doesn't account for the macro-related - // `Span` fixups that `rustc_codegen_ssa::mir::debuginfo` does. - let callsite_scope = parent_scope.adjust_dbg_scope_for_span(cx, callsite_span); -- cx.dbg_loc(callsite_scope, parent_scope.inlined_at, callsite_span) -+ let loc = cx.dbg_loc(callsite_scope, parent_scope.inlined_at, callsite_span); -+ -+ // NB: In order to produce proper debug info for variables (particularly -+ // arguments) in multiply-inline functions, LLVM expects to see a single -+ // DILocalVariable with multiple different DILocations in the IR. While -+ // the source information for each DILocation would be identical, their -+ // inlinedAt attributes will be unique to the particular callsite. -+ // -+ // We generate DILocations here based on the callsite's location in the -+ // source code. A single location in the source code usually can't -+ // produce multiple distinct calls so this mostly works, until -+ // proc-macros get involved. A proc-macro can generate multiple calls -+ // at the same span, which breaks the assumption that we're going to -+ // produce a unique DILocation for every scope we process here. We -+ // have to explicitly add discriminators if we see inlines into the -+ // same source code location. -+ // -+ // Note further that we can't key this hashtable on the span itself, -+ // because these spans could have distinct SyntaxContexts. We have -+ // to key on exactly what we're giving to LLVM. -+ match discriminators.entry(callsite_span.lo()) { -+ Entry::Occupied(mut o) => { -+ *o.get_mut() += 1; -+ unsafe { llvm::LLVMRustDILocationCloneWithBaseDiscriminator(loc, *o.get()) } -+ .expect("Failed to encode discriminator in DILocation") -+ } -+ Entry::Vacant(v) => { -+ v.insert(0); -+ loc -+ } -+ } - }); - - debug_context.scopes[scope] = DebugScope { ---- a/compiler/rustc_codegen_llvm/src/llvm/ffi.rs -+++ b/compiler/rustc_codegen_llvm/src/llvm/ffi.rs -@@ -2174,6 +2174,10 @@ unsafe extern "C" { - Scope: &'a DIScope, - InlinedAt: Option<&'a DILocation>, - ) -> &'a DILocation; -+ pub fn LLVMRustDILocationCloneWithBaseDiscriminator<'a>( -+ Location: &'a DILocation, -+ BD: c_uint, -+ ) -> Option<&'a DILocation>; - pub fn LLVMRustDIBuilderCreateOpDeref() -> u64; - pub fn LLVMRustDIBuilderCreateOpPlusUconst() -> u64; - pub fn LLVMRustDIBuilderCreateOpLLVMFragment() -> u64; ---- a/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp -+++ b/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp -@@ -1305,6 +1305,14 @@ LLVMRustDIBuilderCreateDebugLocation(unsigned Line, unsigned Column, - return wrap(Loc); - } - -+extern "C" LLVMMetadataRef -+LLVMRustDILocationCloneWithBaseDiscriminator(LLVMMetadataRef Location, -+ unsigned BD) { -+ DILocation *Loc = unwrapDIPtr(Location); -+ auto NewLoc = Loc->cloneWithBaseDiscriminator(BD); -+ return wrap(NewLoc.has_value() ? NewLoc.value() : nullptr); -+} -+ - extern "C" uint64_t LLVMRustDIBuilderCreateOpDeref() { - return dwarf::DW_OP_deref; - } ---- /dev/null -+++ b/tests/codegen/debuginfo-proc-macro/auxiliary/macro_def.rs -@@ -0,0 +1,11 @@ -+//@ force-host -+//@ no-prefer-dynamic -+#![crate_type = "proc-macro"] -+ -+extern crate proc_macro; -+use proc_macro::*; -+ -+#[proc_macro] -+pub fn square_twice(_item: TokenStream) -> TokenStream { -+ "(square(env::vars().count() as i32), square(env::vars().count() as i32))".parse().unwrap() -+} ---- /dev/null -+++ b/tests/codegen/debuginfo-proc-macro/mir_inlined_twice_var_locs.rs -@@ -0,0 +1,53 @@ -+//@ min-llvm-version: 19 -+//@ compile-flags: -Cdebuginfo=2 -Copt-level=0 -Zmir-enable-passes=+Inline -+// MSVC is different because of the individual allocas. -+//@ ignore-msvc -+ -+//@ aux-build:macro_def.rs -+ -+// Find the variable. -+// CHECK-DAG: ![[#var_dbg:]] = !DILocalVariable(name: "n",{{( arg: 1,)?}} scope: ![[#var_scope:]] -+ -+// Find both dbg_declares. These will proceed the variable metadata, of course, so we're looking -+// backwards. -+// CHECK-DAG: dbg_declare(ptr %n.dbg.spill{{[0-9]}}, ![[#var_dbg]], !DIExpression(), ![[#var_loc2:]]) -+// CHECK-DAG: dbg_declare(ptr %n.dbg.spill, ![[#var_dbg]], !DIExpression(), ![[#var_loc1:]]) -+ -+// Find the first location definition, looking forwards again. -+// CHECK: ![[#var_loc1]] = !DILocation -+// CHECK-SAME: scope: ![[#var_scope:]], inlinedAt: ![[#var_inlinedAt1:]] -+ -+// Find the first location's inlinedAt -+// NB: If we fail here it's *probably* because we failed to produce two -+// different locations and ended up reusing an earlier one. -+// CHECK: ![[#var_inlinedAt1]] = !DILocation -+// CHECK-SAME: scope: ![[var_inlinedAt1_scope:]] -+ -+// Find the second location definition, still looking forwards. -+// NB: If we failed to produce two different locations, the test will -+// definitely fail by this point (if it hasn't already) because we won't -+// be able to find the same line again. -+// CHECK: ![[#var_loc2]] = !DILocation -+// CHECK-SAME: scope: ![[#var_scope]], inlinedAt: ![[#var_inlinedAt2:]] -+ -+// Find the second location's inlinedAt. -+// CHECK: ![[#var_inlinedAt2]] = !DILocation -+// CHECK-SAME: scope: ![[#var_inlinedAt2_scope:]] -+ -+// Finally, check that a discriminator was emitted for the second scope. -+// FIXMEkhuey ideally we would check that *either* scope has a discriminator -+// but I don't know that it's possible to check that with FileCheck. -+// CHECK: ![[#var_inlinedAt2_scope]] = !DILexicalBlockFile -+// CHECK-SAME: discriminator: [[#]] -+extern crate macro_def; -+ -+use std::env; -+ -+fn square(n: i32) -> i32 { -+ n * n -+} -+ -+fn main() { -+ let (z1, z2) = macro_def::square_twice!(); -+ println!("{z1} == {z2}"); -+} From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 9F3861580E0 for ; Mon, 02 Jun 2025 09:54:50 +0000 (UTC) Received: from lists.gentoo.org (bobolink.gentoo.org [140.211.166.189]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) (Authenticated sender: relay-lists.gentoo.org@gentoo.org) by smtp.gentoo.org (Postfix) with ESMTPSA id 8B426343485 for ; Mon, 02 Jun 2025 09:54:50 +0000 (UTC) Received: from bobolink.gentoo.org (localhost [127.0.0.1]) by bobolink.gentoo.org (Postfix) with ESMTP id B56B111057C; Mon, 02 Jun 2025 09:49:04 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bobolink.gentoo.org (Postfix) with ESMTPS id A22C1110579 for ; Mon, 02 Jun 2025 09:49:04 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 5A36D343282 for ; Mon, 02 Jun 2025 09:49:04 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 9E86828EE for ; Mon, 02 Jun 2025 09:49:01 +0000 (UTC) From: "Matt Jolly" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Matt Jolly" Message-ID: <1748857629.12cbabf1bf6482e7046a73cd59ba7aa0662f4bf8.kangie@gentoo> Subject: [gentoo-commits] proj/rust-patches:1.85.0-r2 commit in: / X-VCS-Repository: proj/rust-patches X-VCS-Files: 1.83.0-dwarf-llvm-assertion.patch X-VCS-Directories: / X-VCS-Committer: kangie X-VCS-Committer-Name: Matt Jolly X-VCS-Revision: 12cbabf1bf6482e7046a73cd59ba7aa0662f4bf8 X-VCS-Branch: 1.85.0-r2 Date: Mon, 02 Jun 2025 09:49:01 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: cc8ae817-5a93-4419-8945-04dc5ee2dc86 X-Archives-Hash: 2657fb972cec39e4c2cc1da4b7e42bd8 Message-ID: <20250602094901.JN--U3ALrYNR7T92qcVX40L8HGMq6NQHVYTZ39dpBdU@z> commit: 12cbabf1bf6482e7046a73cd59ba7aa0662f4bf8 Author: Matt Jolly gentoo org> AuthorDate: Mon Jun 2 09:47:09 2025 +0000 Commit: Matt Jolly gentoo org> CommitDate: Mon Jun 2 09:47:09 2025 +0000 URL: https://gitweb.gentoo.org/proj/rust-patches.git/commit/?id=12cbabf1 Add patches for Rust 1.84.0-r2 Patches: - 1.78.0-musl-dynamic-linking.patch - 1.83.0-cross-compile-libz.patch - 1.67.0-doc-wasm.patch Signed-off-by: Matt Jolly gentoo.org> 1.83.0-dwarf-llvm-assertion.patch | 220 -------------------------------------- 1 file changed, 220 deletions(-) diff --git a/1.83.0-dwarf-llvm-assertion.patch b/1.83.0-dwarf-llvm-assertion.patch deleted file mode 100644 index 96bdac0..0000000 --- a/1.83.0-dwarf-llvm-assertion.patch +++ /dev/null @@ -1,220 +0,0 @@ -From 1dc106121b62562ead6e7d612fa136dc4b35cd5d Mon Sep 17 00:00:00 2001 -From: Kyle Huey -Date: Mon, 4 Nov 2024 11:38:14 -0800 -Subject: [PATCH] Add discriminators to DILocations when multiple functions are - inlined into a single point. - -LLVM does not expect to ever see multiple dbg_declares for the same variable at the same -location with different values. proc-macros make it possible for arbitrary code, -including multiple calls that get inlined, to happen at any given location in the source -code. Add discriminators when that happens so these locations are different to LLVM. - -This may interfere with the AddDiscriminators pass in LLVM, which is added by the -unstable flag -Zdebug-info-for-profiling. - -Fixes #131944 ---- a/compiler/rustc_codegen_llvm/src/debuginfo/create_scope_map.rs -+++ b/compiler/rustc_codegen_llvm/src/debuginfo/create_scope_map.rs -@@ -1,11 +1,15 @@ -+use std::collections::hash_map::Entry; -+ - use rustc_codegen_ssa::mir::debuginfo::{DebugScope, FunctionDebugContext}; - use rustc_codegen_ssa::traits::*; -+use rustc_data_structures::fx::FxHashMap; - use rustc_index::Idx; - use rustc_index::bit_set::BitSet; - use rustc_middle::mir::{Body, SourceScope}; - use rustc_middle::ty::layout::FnAbiOf; - use rustc_middle::ty::{self, Instance}; - use rustc_session::config::DebugInfo; -+use rustc_span::BytePos; - - use super::metadata::file_metadata; - use super::utils::DIB; -@@ -37,10 +41,20 @@ pub(crate) fn compute_mir_scopes<'ll, 'tcx>( - None - }; - let mut instantiated = BitSet::new_empty(mir.source_scopes.len()); -+ let mut discriminators = FxHashMap::default(); - // Instantiate all scopes. - for idx in 0..mir.source_scopes.len() { - let scope = SourceScope::new(idx); -- make_mir_scope(cx, instance, mir, &variables, debug_context, &mut instantiated, scope); -+ make_mir_scope( -+ cx, -+ instance, -+ mir, -+ &variables, -+ debug_context, -+ &mut instantiated, -+ &mut discriminators, -+ scope, -+ ); - } - assert!(instantiated.count() == mir.source_scopes.len()); - } -@@ -52,6 +66,7 @@ fn make_mir_scope<'ll, 'tcx>( - variables: &Option>, - debug_context: &mut FunctionDebugContext<'tcx, &'ll DIScope, &'ll DILocation>, - instantiated: &mut BitSet, -+ discriminators: &mut FxHashMap, - scope: SourceScope, - ) { - if instantiated.contains(scope) { -@@ -60,7 +75,16 @@ fn make_mir_scope<'ll, 'tcx>( - - let scope_data = &mir.source_scopes[scope]; - let parent_scope = if let Some(parent) = scope_data.parent_scope { -- make_mir_scope(cx, instance, mir, variables, debug_context, instantiated, parent); -+ make_mir_scope( -+ cx, -+ instance, -+ mir, -+ variables, -+ debug_context, -+ instantiated, -+ discriminators, -+ parent, -+ ); - debug_context.scopes[parent] - } else { - // The root is the function itself. -@@ -117,7 +141,37 @@ fn make_mir_scope<'ll, 'tcx>( - // FIXME(eddyb) this doesn't account for the macro-related - // `Span` fixups that `rustc_codegen_ssa::mir::debuginfo` does. - let callsite_scope = parent_scope.adjust_dbg_scope_for_span(cx, callsite_span); -- cx.dbg_loc(callsite_scope, parent_scope.inlined_at, callsite_span) -+ let loc = cx.dbg_loc(callsite_scope, parent_scope.inlined_at, callsite_span); -+ -+ // NB: In order to produce proper debug info for variables (particularly -+ // arguments) in multiply-inline functions, LLVM expects to see a single -+ // DILocalVariable with multiple different DILocations in the IR. While -+ // the source information for each DILocation would be identical, their -+ // inlinedAt attributes will be unique to the particular callsite. -+ // -+ // We generate DILocations here based on the callsite's location in the -+ // source code. A single location in the source code usually can't -+ // produce multiple distinct calls so this mostly works, until -+ // proc-macros get involved. A proc-macro can generate multiple calls -+ // at the same span, which breaks the assumption that we're going to -+ // produce a unique DILocation for every scope we process here. We -+ // have to explicitly add discriminators if we see inlines into the -+ // same source code location. -+ // -+ // Note further that we can't key this hashtable on the span itself, -+ // because these spans could have distinct SyntaxContexts. We have -+ // to key on exactly what we're giving to LLVM. -+ match discriminators.entry(callsite_span.lo()) { -+ Entry::Occupied(mut o) => { -+ *o.get_mut() += 1; -+ unsafe { llvm::LLVMRustDILocationCloneWithBaseDiscriminator(loc, *o.get()) } -+ .expect("Failed to encode discriminator in DILocation") -+ } -+ Entry::Vacant(v) => { -+ v.insert(0); -+ loc -+ } -+ } - }); - - debug_context.scopes[scope] = DebugScope { ---- a/compiler/rustc_codegen_llvm/src/llvm/ffi.rs -+++ b/compiler/rustc_codegen_llvm/src/llvm/ffi.rs -@@ -2174,6 +2174,10 @@ unsafe extern "C" { - Scope: &'a DIScope, - InlinedAt: Option<&'a DILocation>, - ) -> &'a DILocation; -+ pub fn LLVMRustDILocationCloneWithBaseDiscriminator<'a>( -+ Location: &'a DILocation, -+ BD: c_uint, -+ ) -> Option<&'a DILocation>; - pub fn LLVMRustDIBuilderCreateOpDeref() -> u64; - pub fn LLVMRustDIBuilderCreateOpPlusUconst() -> u64; - pub fn LLVMRustDIBuilderCreateOpLLVMFragment() -> u64; ---- a/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp -+++ b/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp -@@ -1305,6 +1305,14 @@ LLVMRustDIBuilderCreateDebugLocation(unsigned Line, unsigned Column, - return wrap(Loc); - } - -+extern "C" LLVMMetadataRef -+LLVMRustDILocationCloneWithBaseDiscriminator(LLVMMetadataRef Location, -+ unsigned BD) { -+ DILocation *Loc = unwrapDIPtr(Location); -+ auto NewLoc = Loc->cloneWithBaseDiscriminator(BD); -+ return wrap(NewLoc.has_value() ? NewLoc.value() : nullptr); -+} -+ - extern "C" uint64_t LLVMRustDIBuilderCreateOpDeref() { - return dwarf::DW_OP_deref; - } ---- /dev/null -+++ b/tests/codegen/debuginfo-proc-macro/auxiliary/macro_def.rs -@@ -0,0 +1,11 @@ -+//@ force-host -+//@ no-prefer-dynamic -+#![crate_type = "proc-macro"] -+ -+extern crate proc_macro; -+use proc_macro::*; -+ -+#[proc_macro] -+pub fn square_twice(_item: TokenStream) -> TokenStream { -+ "(square(env::vars().count() as i32), square(env::vars().count() as i32))".parse().unwrap() -+} ---- /dev/null -+++ b/tests/codegen/debuginfo-proc-macro/mir_inlined_twice_var_locs.rs -@@ -0,0 +1,53 @@ -+//@ min-llvm-version: 19 -+//@ compile-flags: -Cdebuginfo=2 -Copt-level=0 -Zmir-enable-passes=+Inline -+// MSVC is different because of the individual allocas. -+//@ ignore-msvc -+ -+//@ aux-build:macro_def.rs -+ -+// Find the variable. -+// CHECK-DAG: ![[#var_dbg:]] = !DILocalVariable(name: "n",{{( arg: 1,)?}} scope: ![[#var_scope:]] -+ -+// Find both dbg_declares. These will proceed the variable metadata, of course, so we're looking -+// backwards. -+// CHECK-DAG: dbg_declare(ptr %n.dbg.spill{{[0-9]}}, ![[#var_dbg]], !DIExpression(), ![[#var_loc2:]]) -+// CHECK-DAG: dbg_declare(ptr %n.dbg.spill, ![[#var_dbg]], !DIExpression(), ![[#var_loc1:]]) -+ -+// Find the first location definition, looking forwards again. -+// CHECK: ![[#var_loc1]] = !DILocation -+// CHECK-SAME: scope: ![[#var_scope:]], inlinedAt: ![[#var_inlinedAt1:]] -+ -+// Find the first location's inlinedAt -+// NB: If we fail here it's *probably* because we failed to produce two -+// different locations and ended up reusing an earlier one. -+// CHECK: ![[#var_inlinedAt1]] = !DILocation -+// CHECK-SAME: scope: ![[var_inlinedAt1_scope:]] -+ -+// Find the second location definition, still looking forwards. -+// NB: If we failed to produce two different locations, the test will -+// definitely fail by this point (if it hasn't already) because we won't -+// be able to find the same line again. -+// CHECK: ![[#var_loc2]] = !DILocation -+// CHECK-SAME: scope: ![[#var_scope]], inlinedAt: ![[#var_inlinedAt2:]] -+ -+// Find the second location's inlinedAt. -+// CHECK: ![[#var_inlinedAt2]] = !DILocation -+// CHECK-SAME: scope: ![[#var_inlinedAt2_scope:]] -+ -+// Finally, check that a discriminator was emitted for the second scope. -+// FIXMEkhuey ideally we would check that *either* scope has a discriminator -+// but I don't know that it's possible to check that with FileCheck. -+// CHECK: ![[#var_inlinedAt2_scope]] = !DILexicalBlockFile -+// CHECK-SAME: discriminator: [[#]] -+extern crate macro_def; -+ -+use std::env; -+ -+fn square(n: i32) -> i32 { -+ n * n -+} -+ -+fn main() { -+ let (z1, z2) = macro_def::square_twice!(); -+ println!("{z1} == {z2}"); -+} From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 7FCFB1580E0 for ; Mon, 02 Jun 2025 09:55:22 +0000 (UTC) Received: from lists.gentoo.org (bobolink.gentoo.org [140.211.166.189]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) (Authenticated sender: relay-lists.gentoo.org@gentoo.org) by smtp.gentoo.org (Postfix) with ESMTPSA id 9C241343299 for ; Mon, 02 Jun 2025 09:55:09 +0000 (UTC) Received: from bobolink.gentoo.org (localhost [127.0.0.1]) by bobolink.gentoo.org (Postfix) with ESMTP id 30D18110585; Mon, 02 Jun 2025 09:49:06 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bobolink.gentoo.org (Postfix) with ESMTPS id 1AAE8110580 for ; Mon, 02 Jun 2025 09:49:06 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id C775534322E for ; Mon, 02 Jun 2025 09:49:05 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 8DF8D297E for ; Mon, 02 Jun 2025 09:49:02 +0000 (UTC) From: "Matt Jolly" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Matt Jolly" Message-ID: <1748857629.12cbabf1bf6482e7046a73cd59ba7aa0662f4bf8.kangie@gentoo> Subject: [gentoo-commits] proj/rust-patches:1.85.1-r1 commit in: / X-VCS-Repository: proj/rust-patches X-VCS-Files: 1.83.0-dwarf-llvm-assertion.patch X-VCS-Directories: / X-VCS-Committer: kangie X-VCS-Committer-Name: Matt Jolly X-VCS-Revision: 12cbabf1bf6482e7046a73cd59ba7aa0662f4bf8 X-VCS-Branch: 1.85.1-r1 Date: Mon, 02 Jun 2025 09:49:02 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 842fc516-c3fd-4e67-9f7d-634c8c021b9a X-Archives-Hash: 1ded43b3370221bbd87c683ca12aff71 Message-ID: <20250602094902.qrs6WK43TdacY6lWtoEL9U7-iHCsyXifk8tb4n0QolU@z> commit: 12cbabf1bf6482e7046a73cd59ba7aa0662f4bf8 Author: Matt Jolly gentoo org> AuthorDate: Mon Jun 2 09:47:09 2025 +0000 Commit: Matt Jolly gentoo org> CommitDate: Mon Jun 2 09:47:09 2025 +0000 URL: https://gitweb.gentoo.org/proj/rust-patches.git/commit/?id=12cbabf1 Add patches for Rust 1.84.0-r2 Patches: - 1.78.0-musl-dynamic-linking.patch - 1.83.0-cross-compile-libz.patch - 1.67.0-doc-wasm.patch Signed-off-by: Matt Jolly gentoo.org> 1.83.0-dwarf-llvm-assertion.patch | 220 -------------------------------------- 1 file changed, 220 deletions(-) diff --git a/1.83.0-dwarf-llvm-assertion.patch b/1.83.0-dwarf-llvm-assertion.patch deleted file mode 100644 index 96bdac0..0000000 --- a/1.83.0-dwarf-llvm-assertion.patch +++ /dev/null @@ -1,220 +0,0 @@ -From 1dc106121b62562ead6e7d612fa136dc4b35cd5d Mon Sep 17 00:00:00 2001 -From: Kyle Huey -Date: Mon, 4 Nov 2024 11:38:14 -0800 -Subject: [PATCH] Add discriminators to DILocations when multiple functions are - inlined into a single point. - -LLVM does not expect to ever see multiple dbg_declares for the same variable at the same -location with different values. proc-macros make it possible for arbitrary code, -including multiple calls that get inlined, to happen at any given location in the source -code. Add discriminators when that happens so these locations are different to LLVM. - -This may interfere with the AddDiscriminators pass in LLVM, which is added by the -unstable flag -Zdebug-info-for-profiling. - -Fixes #131944 ---- a/compiler/rustc_codegen_llvm/src/debuginfo/create_scope_map.rs -+++ b/compiler/rustc_codegen_llvm/src/debuginfo/create_scope_map.rs -@@ -1,11 +1,15 @@ -+use std::collections::hash_map::Entry; -+ - use rustc_codegen_ssa::mir::debuginfo::{DebugScope, FunctionDebugContext}; - use rustc_codegen_ssa::traits::*; -+use rustc_data_structures::fx::FxHashMap; - use rustc_index::Idx; - use rustc_index::bit_set::BitSet; - use rustc_middle::mir::{Body, SourceScope}; - use rustc_middle::ty::layout::FnAbiOf; - use rustc_middle::ty::{self, Instance}; - use rustc_session::config::DebugInfo; -+use rustc_span::BytePos; - - use super::metadata::file_metadata; - use super::utils::DIB; -@@ -37,10 +41,20 @@ pub(crate) fn compute_mir_scopes<'ll, 'tcx>( - None - }; - let mut instantiated = BitSet::new_empty(mir.source_scopes.len()); -+ let mut discriminators = FxHashMap::default(); - // Instantiate all scopes. - for idx in 0..mir.source_scopes.len() { - let scope = SourceScope::new(idx); -- make_mir_scope(cx, instance, mir, &variables, debug_context, &mut instantiated, scope); -+ make_mir_scope( -+ cx, -+ instance, -+ mir, -+ &variables, -+ debug_context, -+ &mut instantiated, -+ &mut discriminators, -+ scope, -+ ); - } - assert!(instantiated.count() == mir.source_scopes.len()); - } -@@ -52,6 +66,7 @@ fn make_mir_scope<'ll, 'tcx>( - variables: &Option>, - debug_context: &mut FunctionDebugContext<'tcx, &'ll DIScope, &'ll DILocation>, - instantiated: &mut BitSet, -+ discriminators: &mut FxHashMap, - scope: SourceScope, - ) { - if instantiated.contains(scope) { -@@ -60,7 +75,16 @@ fn make_mir_scope<'ll, 'tcx>( - - let scope_data = &mir.source_scopes[scope]; - let parent_scope = if let Some(parent) = scope_data.parent_scope { -- make_mir_scope(cx, instance, mir, variables, debug_context, instantiated, parent); -+ make_mir_scope( -+ cx, -+ instance, -+ mir, -+ variables, -+ debug_context, -+ instantiated, -+ discriminators, -+ parent, -+ ); - debug_context.scopes[parent] - } else { - // The root is the function itself. -@@ -117,7 +141,37 @@ fn make_mir_scope<'ll, 'tcx>( - // FIXME(eddyb) this doesn't account for the macro-related - // `Span` fixups that `rustc_codegen_ssa::mir::debuginfo` does. - let callsite_scope = parent_scope.adjust_dbg_scope_for_span(cx, callsite_span); -- cx.dbg_loc(callsite_scope, parent_scope.inlined_at, callsite_span) -+ let loc = cx.dbg_loc(callsite_scope, parent_scope.inlined_at, callsite_span); -+ -+ // NB: In order to produce proper debug info for variables (particularly -+ // arguments) in multiply-inline functions, LLVM expects to see a single -+ // DILocalVariable with multiple different DILocations in the IR. While -+ // the source information for each DILocation would be identical, their -+ // inlinedAt attributes will be unique to the particular callsite. -+ // -+ // We generate DILocations here based on the callsite's location in the -+ // source code. A single location in the source code usually can't -+ // produce multiple distinct calls so this mostly works, until -+ // proc-macros get involved. A proc-macro can generate multiple calls -+ // at the same span, which breaks the assumption that we're going to -+ // produce a unique DILocation for every scope we process here. We -+ // have to explicitly add discriminators if we see inlines into the -+ // same source code location. -+ // -+ // Note further that we can't key this hashtable on the span itself, -+ // because these spans could have distinct SyntaxContexts. We have -+ // to key on exactly what we're giving to LLVM. -+ match discriminators.entry(callsite_span.lo()) { -+ Entry::Occupied(mut o) => { -+ *o.get_mut() += 1; -+ unsafe { llvm::LLVMRustDILocationCloneWithBaseDiscriminator(loc, *o.get()) } -+ .expect("Failed to encode discriminator in DILocation") -+ } -+ Entry::Vacant(v) => { -+ v.insert(0); -+ loc -+ } -+ } - }); - - debug_context.scopes[scope] = DebugScope { ---- a/compiler/rustc_codegen_llvm/src/llvm/ffi.rs -+++ b/compiler/rustc_codegen_llvm/src/llvm/ffi.rs -@@ -2174,6 +2174,10 @@ unsafe extern "C" { - Scope: &'a DIScope, - InlinedAt: Option<&'a DILocation>, - ) -> &'a DILocation; -+ pub fn LLVMRustDILocationCloneWithBaseDiscriminator<'a>( -+ Location: &'a DILocation, -+ BD: c_uint, -+ ) -> Option<&'a DILocation>; - pub fn LLVMRustDIBuilderCreateOpDeref() -> u64; - pub fn LLVMRustDIBuilderCreateOpPlusUconst() -> u64; - pub fn LLVMRustDIBuilderCreateOpLLVMFragment() -> u64; ---- a/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp -+++ b/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp -@@ -1305,6 +1305,14 @@ LLVMRustDIBuilderCreateDebugLocation(unsigned Line, unsigned Column, - return wrap(Loc); - } - -+extern "C" LLVMMetadataRef -+LLVMRustDILocationCloneWithBaseDiscriminator(LLVMMetadataRef Location, -+ unsigned BD) { -+ DILocation *Loc = unwrapDIPtr(Location); -+ auto NewLoc = Loc->cloneWithBaseDiscriminator(BD); -+ return wrap(NewLoc.has_value() ? NewLoc.value() : nullptr); -+} -+ - extern "C" uint64_t LLVMRustDIBuilderCreateOpDeref() { - return dwarf::DW_OP_deref; - } ---- /dev/null -+++ b/tests/codegen/debuginfo-proc-macro/auxiliary/macro_def.rs -@@ -0,0 +1,11 @@ -+//@ force-host -+//@ no-prefer-dynamic -+#![crate_type = "proc-macro"] -+ -+extern crate proc_macro; -+use proc_macro::*; -+ -+#[proc_macro] -+pub fn square_twice(_item: TokenStream) -> TokenStream { -+ "(square(env::vars().count() as i32), square(env::vars().count() as i32))".parse().unwrap() -+} ---- /dev/null -+++ b/tests/codegen/debuginfo-proc-macro/mir_inlined_twice_var_locs.rs -@@ -0,0 +1,53 @@ -+//@ min-llvm-version: 19 -+//@ compile-flags: -Cdebuginfo=2 -Copt-level=0 -Zmir-enable-passes=+Inline -+// MSVC is different because of the individual allocas. -+//@ ignore-msvc -+ -+//@ aux-build:macro_def.rs -+ -+// Find the variable. -+// CHECK-DAG: ![[#var_dbg:]] = !DILocalVariable(name: "n",{{( arg: 1,)?}} scope: ![[#var_scope:]] -+ -+// Find both dbg_declares. These will proceed the variable metadata, of course, so we're looking -+// backwards. -+// CHECK-DAG: dbg_declare(ptr %n.dbg.spill{{[0-9]}}, ![[#var_dbg]], !DIExpression(), ![[#var_loc2:]]) -+// CHECK-DAG: dbg_declare(ptr %n.dbg.spill, ![[#var_dbg]], !DIExpression(), ![[#var_loc1:]]) -+ -+// Find the first location definition, looking forwards again. -+// CHECK: ![[#var_loc1]] = !DILocation -+// CHECK-SAME: scope: ![[#var_scope:]], inlinedAt: ![[#var_inlinedAt1:]] -+ -+// Find the first location's inlinedAt -+// NB: If we fail here it's *probably* because we failed to produce two -+// different locations and ended up reusing an earlier one. -+// CHECK: ![[#var_inlinedAt1]] = !DILocation -+// CHECK-SAME: scope: ![[var_inlinedAt1_scope:]] -+ -+// Find the second location definition, still looking forwards. -+// NB: If we failed to produce two different locations, the test will -+// definitely fail by this point (if it hasn't already) because we won't -+// be able to find the same line again. -+// CHECK: ![[#var_loc2]] = !DILocation -+// CHECK-SAME: scope: ![[#var_scope]], inlinedAt: ![[#var_inlinedAt2:]] -+ -+// Find the second location's inlinedAt. -+// CHECK: ![[#var_inlinedAt2]] = !DILocation -+// CHECK-SAME: scope: ![[#var_inlinedAt2_scope:]] -+ -+// Finally, check that a discriminator was emitted for the second scope. -+// FIXMEkhuey ideally we would check that *either* scope has a discriminator -+// but I don't know that it's possible to check that with FileCheck. -+// CHECK: ![[#var_inlinedAt2_scope]] = !DILexicalBlockFile -+// CHECK-SAME: discriminator: [[#]] -+extern crate macro_def; -+ -+use std::env; -+ -+fn square(n: i32) -> i32 { -+ n * n -+} -+ -+fn main() { -+ let (z1, z2) = macro_def::square_twice!(); -+ println!("{z1} == {z2}"); -+} From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 0416F1580E0 for ; Mon, 02 Jun 2025 09:55:37 +0000 (UTC) Received: from lists.gentoo.org (bobolink.gentoo.org [140.211.166.189]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) (Authenticated sender: relay-lists.gentoo.org@gentoo.org) by smtp.gentoo.org (Postfix) with ESMTPSA id 8662D3432DD for ; Mon, 02 Jun 2025 09:55:33 +0000 (UTC) Received: from bobolink.gentoo.org (localhost [127.0.0.1]) by bobolink.gentoo.org (Postfix) with ESMTP id 6A4E4110590; Mon, 02 Jun 2025 09:49:06 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bobolink.gentoo.org (Postfix) with ESMTPS id 55D0011058A for ; Mon, 02 Jun 2025 09:49:06 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 0DB25343293 for ; Mon, 02 Jun 2025 09:49:06 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 7D43F28FD for ; Mon, 02 Jun 2025 09:49:03 +0000 (UTC) From: "Matt Jolly" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Matt Jolly" Message-ID: <1748857629.12cbabf1bf6482e7046a73cd59ba7aa0662f4bf8.kangie@gentoo> Subject: [gentoo-commits] proj/rust-patches:1.86.0-r2 commit in: / X-VCS-Repository: proj/rust-patches X-VCS-Files: 1.83.0-dwarf-llvm-assertion.patch X-VCS-Directories: / X-VCS-Committer: kangie X-VCS-Committer-Name: Matt Jolly X-VCS-Revision: 12cbabf1bf6482e7046a73cd59ba7aa0662f4bf8 X-VCS-Branch: 1.86.0-r2 Date: Mon, 02 Jun 2025 09:49:03 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 80303396-c83b-4d8e-aa09-97192055cd79 X-Archives-Hash: 30c63c30454a5147d5b22ff385ff1bc7 Message-ID: <20250602094903.pb-ghozgTmBmJm59Fz0NVwvRulYT7M5g5hSlUZnyCBw@z> commit: 12cbabf1bf6482e7046a73cd59ba7aa0662f4bf8 Author: Matt Jolly gentoo org> AuthorDate: Mon Jun 2 09:47:09 2025 +0000 Commit: Matt Jolly gentoo org> CommitDate: Mon Jun 2 09:47:09 2025 +0000 URL: https://gitweb.gentoo.org/proj/rust-patches.git/commit/?id=12cbabf1 Add patches for Rust 1.84.0-r2 Patches: - 1.78.0-musl-dynamic-linking.patch - 1.83.0-cross-compile-libz.patch - 1.67.0-doc-wasm.patch Signed-off-by: Matt Jolly gentoo.org> 1.83.0-dwarf-llvm-assertion.patch | 220 -------------------------------------- 1 file changed, 220 deletions(-) diff --git a/1.83.0-dwarf-llvm-assertion.patch b/1.83.0-dwarf-llvm-assertion.patch deleted file mode 100644 index 96bdac0..0000000 --- a/1.83.0-dwarf-llvm-assertion.patch +++ /dev/null @@ -1,220 +0,0 @@ -From 1dc106121b62562ead6e7d612fa136dc4b35cd5d Mon Sep 17 00:00:00 2001 -From: Kyle Huey -Date: Mon, 4 Nov 2024 11:38:14 -0800 -Subject: [PATCH] Add discriminators to DILocations when multiple functions are - inlined into a single point. - -LLVM does not expect to ever see multiple dbg_declares for the same variable at the same -location with different values. proc-macros make it possible for arbitrary code, -including multiple calls that get inlined, to happen at any given location in the source -code. Add discriminators when that happens so these locations are different to LLVM. - -This may interfere with the AddDiscriminators pass in LLVM, which is added by the -unstable flag -Zdebug-info-for-profiling. - -Fixes #131944 ---- a/compiler/rustc_codegen_llvm/src/debuginfo/create_scope_map.rs -+++ b/compiler/rustc_codegen_llvm/src/debuginfo/create_scope_map.rs -@@ -1,11 +1,15 @@ -+use std::collections::hash_map::Entry; -+ - use rustc_codegen_ssa::mir::debuginfo::{DebugScope, FunctionDebugContext}; - use rustc_codegen_ssa::traits::*; -+use rustc_data_structures::fx::FxHashMap; - use rustc_index::Idx; - use rustc_index::bit_set::BitSet; - use rustc_middle::mir::{Body, SourceScope}; - use rustc_middle::ty::layout::FnAbiOf; - use rustc_middle::ty::{self, Instance}; - use rustc_session::config::DebugInfo; -+use rustc_span::BytePos; - - use super::metadata::file_metadata; - use super::utils::DIB; -@@ -37,10 +41,20 @@ pub(crate) fn compute_mir_scopes<'ll, 'tcx>( - None - }; - let mut instantiated = BitSet::new_empty(mir.source_scopes.len()); -+ let mut discriminators = FxHashMap::default(); - // Instantiate all scopes. - for idx in 0..mir.source_scopes.len() { - let scope = SourceScope::new(idx); -- make_mir_scope(cx, instance, mir, &variables, debug_context, &mut instantiated, scope); -+ make_mir_scope( -+ cx, -+ instance, -+ mir, -+ &variables, -+ debug_context, -+ &mut instantiated, -+ &mut discriminators, -+ scope, -+ ); - } - assert!(instantiated.count() == mir.source_scopes.len()); - } -@@ -52,6 +66,7 @@ fn make_mir_scope<'ll, 'tcx>( - variables: &Option>, - debug_context: &mut FunctionDebugContext<'tcx, &'ll DIScope, &'ll DILocation>, - instantiated: &mut BitSet, -+ discriminators: &mut FxHashMap, - scope: SourceScope, - ) { - if instantiated.contains(scope) { -@@ -60,7 +75,16 @@ fn make_mir_scope<'ll, 'tcx>( - - let scope_data = &mir.source_scopes[scope]; - let parent_scope = if let Some(parent) = scope_data.parent_scope { -- make_mir_scope(cx, instance, mir, variables, debug_context, instantiated, parent); -+ make_mir_scope( -+ cx, -+ instance, -+ mir, -+ variables, -+ debug_context, -+ instantiated, -+ discriminators, -+ parent, -+ ); - debug_context.scopes[parent] - } else { - // The root is the function itself. -@@ -117,7 +141,37 @@ fn make_mir_scope<'ll, 'tcx>( - // FIXME(eddyb) this doesn't account for the macro-related - // `Span` fixups that `rustc_codegen_ssa::mir::debuginfo` does. - let callsite_scope = parent_scope.adjust_dbg_scope_for_span(cx, callsite_span); -- cx.dbg_loc(callsite_scope, parent_scope.inlined_at, callsite_span) -+ let loc = cx.dbg_loc(callsite_scope, parent_scope.inlined_at, callsite_span); -+ -+ // NB: In order to produce proper debug info for variables (particularly -+ // arguments) in multiply-inline functions, LLVM expects to see a single -+ // DILocalVariable with multiple different DILocations in the IR. While -+ // the source information for each DILocation would be identical, their -+ // inlinedAt attributes will be unique to the particular callsite. -+ // -+ // We generate DILocations here based on the callsite's location in the -+ // source code. A single location in the source code usually can't -+ // produce multiple distinct calls so this mostly works, until -+ // proc-macros get involved. A proc-macro can generate multiple calls -+ // at the same span, which breaks the assumption that we're going to -+ // produce a unique DILocation for every scope we process here. We -+ // have to explicitly add discriminators if we see inlines into the -+ // same source code location. -+ // -+ // Note further that we can't key this hashtable on the span itself, -+ // because these spans could have distinct SyntaxContexts. We have -+ // to key on exactly what we're giving to LLVM. -+ match discriminators.entry(callsite_span.lo()) { -+ Entry::Occupied(mut o) => { -+ *o.get_mut() += 1; -+ unsafe { llvm::LLVMRustDILocationCloneWithBaseDiscriminator(loc, *o.get()) } -+ .expect("Failed to encode discriminator in DILocation") -+ } -+ Entry::Vacant(v) => { -+ v.insert(0); -+ loc -+ } -+ } - }); - - debug_context.scopes[scope] = DebugScope { ---- a/compiler/rustc_codegen_llvm/src/llvm/ffi.rs -+++ b/compiler/rustc_codegen_llvm/src/llvm/ffi.rs -@@ -2174,6 +2174,10 @@ unsafe extern "C" { - Scope: &'a DIScope, - InlinedAt: Option<&'a DILocation>, - ) -> &'a DILocation; -+ pub fn LLVMRustDILocationCloneWithBaseDiscriminator<'a>( -+ Location: &'a DILocation, -+ BD: c_uint, -+ ) -> Option<&'a DILocation>; - pub fn LLVMRustDIBuilderCreateOpDeref() -> u64; - pub fn LLVMRustDIBuilderCreateOpPlusUconst() -> u64; - pub fn LLVMRustDIBuilderCreateOpLLVMFragment() -> u64; ---- a/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp -+++ b/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp -@@ -1305,6 +1305,14 @@ LLVMRustDIBuilderCreateDebugLocation(unsigned Line, unsigned Column, - return wrap(Loc); - } - -+extern "C" LLVMMetadataRef -+LLVMRustDILocationCloneWithBaseDiscriminator(LLVMMetadataRef Location, -+ unsigned BD) { -+ DILocation *Loc = unwrapDIPtr(Location); -+ auto NewLoc = Loc->cloneWithBaseDiscriminator(BD); -+ return wrap(NewLoc.has_value() ? NewLoc.value() : nullptr); -+} -+ - extern "C" uint64_t LLVMRustDIBuilderCreateOpDeref() { - return dwarf::DW_OP_deref; - } ---- /dev/null -+++ b/tests/codegen/debuginfo-proc-macro/auxiliary/macro_def.rs -@@ -0,0 +1,11 @@ -+//@ force-host -+//@ no-prefer-dynamic -+#![crate_type = "proc-macro"] -+ -+extern crate proc_macro; -+use proc_macro::*; -+ -+#[proc_macro] -+pub fn square_twice(_item: TokenStream) -> TokenStream { -+ "(square(env::vars().count() as i32), square(env::vars().count() as i32))".parse().unwrap() -+} ---- /dev/null -+++ b/tests/codegen/debuginfo-proc-macro/mir_inlined_twice_var_locs.rs -@@ -0,0 +1,53 @@ -+//@ min-llvm-version: 19 -+//@ compile-flags: -Cdebuginfo=2 -Copt-level=0 -Zmir-enable-passes=+Inline -+// MSVC is different because of the individual allocas. -+//@ ignore-msvc -+ -+//@ aux-build:macro_def.rs -+ -+// Find the variable. -+// CHECK-DAG: ![[#var_dbg:]] = !DILocalVariable(name: "n",{{( arg: 1,)?}} scope: ![[#var_scope:]] -+ -+// Find both dbg_declares. These will proceed the variable metadata, of course, so we're looking -+// backwards. -+// CHECK-DAG: dbg_declare(ptr %n.dbg.spill{{[0-9]}}, ![[#var_dbg]], !DIExpression(), ![[#var_loc2:]]) -+// CHECK-DAG: dbg_declare(ptr %n.dbg.spill, ![[#var_dbg]], !DIExpression(), ![[#var_loc1:]]) -+ -+// Find the first location definition, looking forwards again. -+// CHECK: ![[#var_loc1]] = !DILocation -+// CHECK-SAME: scope: ![[#var_scope:]], inlinedAt: ![[#var_inlinedAt1:]] -+ -+// Find the first location's inlinedAt -+// NB: If we fail here it's *probably* because we failed to produce two -+// different locations and ended up reusing an earlier one. -+// CHECK: ![[#var_inlinedAt1]] = !DILocation -+// CHECK-SAME: scope: ![[var_inlinedAt1_scope:]] -+ -+// Find the second location definition, still looking forwards. -+// NB: If we failed to produce two different locations, the test will -+// definitely fail by this point (if it hasn't already) because we won't -+// be able to find the same line again. -+// CHECK: ![[#var_loc2]] = !DILocation -+// CHECK-SAME: scope: ![[#var_scope]], inlinedAt: ![[#var_inlinedAt2:]] -+ -+// Find the second location's inlinedAt. -+// CHECK: ![[#var_inlinedAt2]] = !DILocation -+// CHECK-SAME: scope: ![[#var_inlinedAt2_scope:]] -+ -+// Finally, check that a discriminator was emitted for the second scope. -+// FIXMEkhuey ideally we would check that *either* scope has a discriminator -+// but I don't know that it's possible to check that with FileCheck. -+// CHECK: ![[#var_inlinedAt2_scope]] = !DILexicalBlockFile -+// CHECK-SAME: discriminator: [[#]] -+extern crate macro_def; -+ -+use std::env; -+ -+fn square(n: i32) -> i32 { -+ n * n -+} -+ -+fn main() { -+ let (z1, z2) = macro_def::square_twice!(); -+ println!("{z1} == {z2}"); -+} From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id EE1721580E0 for ; Mon, 02 Jun 2025 09:55:51 +0000 (UTC) Received: from lists.gentoo.org (bobolink.gentoo.org [140.211.166.189]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) (Authenticated sender: relay-lists.gentoo.org@gentoo.org) by smtp.gentoo.org (Postfix) with ESMTPSA id 539B9343498 for ; Mon, 02 Jun 2025 09:55:49 +0000 (UTC) Received: from bobolink.gentoo.org (localhost [127.0.0.1]) by bobolink.gentoo.org (Postfix) with ESMTP id D6A9411059B; Mon, 02 Jun 2025 09:49:07 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bobolink.gentoo.org (Postfix) with ESMTPS id CFDD0110594 for ; Mon, 02 Jun 2025 09:49:07 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 8539C343292 for ; Mon, 02 Jun 2025 09:49:07 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 875F82916 for ; Mon, 02 Jun 2025 09:49:04 +0000 (UTC) From: "Matt Jolly" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Matt Jolly" Message-ID: <1748857629.12cbabf1bf6482e7046a73cd59ba7aa0662f4bf8.kangie@gentoo> Subject: [gentoo-commits] proj/rust-patches:1.87.0-r1 commit in: / X-VCS-Repository: proj/rust-patches X-VCS-Files: 1.83.0-dwarf-llvm-assertion.patch X-VCS-Directories: / X-VCS-Committer: kangie X-VCS-Committer-Name: Matt Jolly X-VCS-Revision: 12cbabf1bf6482e7046a73cd59ba7aa0662f4bf8 X-VCS-Branch: 1.87.0-r1 Date: Mon, 02 Jun 2025 09:49:04 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: f0fd228e-7dbe-4dba-b86e-8a303df98d93 X-Archives-Hash: f0a4f2874012b293f2931c0282d4509e Message-ID: <20250602094904.rP8GO8mYFGCIvJBKyrmtgfYg5k7pKOEZwTCNkReMIPo@z> commit: 12cbabf1bf6482e7046a73cd59ba7aa0662f4bf8 Author: Matt Jolly gentoo org> AuthorDate: Mon Jun 2 09:47:09 2025 +0000 Commit: Matt Jolly gentoo org> CommitDate: Mon Jun 2 09:47:09 2025 +0000 URL: https://gitweb.gentoo.org/proj/rust-patches.git/commit/?id=12cbabf1 Add patches for Rust 1.84.0-r2 Patches: - 1.78.0-musl-dynamic-linking.patch - 1.83.0-cross-compile-libz.patch - 1.67.0-doc-wasm.patch Signed-off-by: Matt Jolly gentoo.org> 1.83.0-dwarf-llvm-assertion.patch | 220 -------------------------------------- 1 file changed, 220 deletions(-) diff --git a/1.83.0-dwarf-llvm-assertion.patch b/1.83.0-dwarf-llvm-assertion.patch deleted file mode 100644 index 96bdac0..0000000 --- a/1.83.0-dwarf-llvm-assertion.patch +++ /dev/null @@ -1,220 +0,0 @@ -From 1dc106121b62562ead6e7d612fa136dc4b35cd5d Mon Sep 17 00:00:00 2001 -From: Kyle Huey -Date: Mon, 4 Nov 2024 11:38:14 -0800 -Subject: [PATCH] Add discriminators to DILocations when multiple functions are - inlined into a single point. - -LLVM does not expect to ever see multiple dbg_declares for the same variable at the same -location with different values. proc-macros make it possible for arbitrary code, -including multiple calls that get inlined, to happen at any given location in the source -code. Add discriminators when that happens so these locations are different to LLVM. - -This may interfere with the AddDiscriminators pass in LLVM, which is added by the -unstable flag -Zdebug-info-for-profiling. - -Fixes #131944 ---- a/compiler/rustc_codegen_llvm/src/debuginfo/create_scope_map.rs -+++ b/compiler/rustc_codegen_llvm/src/debuginfo/create_scope_map.rs -@@ -1,11 +1,15 @@ -+use std::collections::hash_map::Entry; -+ - use rustc_codegen_ssa::mir::debuginfo::{DebugScope, FunctionDebugContext}; - use rustc_codegen_ssa::traits::*; -+use rustc_data_structures::fx::FxHashMap; - use rustc_index::Idx; - use rustc_index::bit_set::BitSet; - use rustc_middle::mir::{Body, SourceScope}; - use rustc_middle::ty::layout::FnAbiOf; - use rustc_middle::ty::{self, Instance}; - use rustc_session::config::DebugInfo; -+use rustc_span::BytePos; - - use super::metadata::file_metadata; - use super::utils::DIB; -@@ -37,10 +41,20 @@ pub(crate) fn compute_mir_scopes<'ll, 'tcx>( - None - }; - let mut instantiated = BitSet::new_empty(mir.source_scopes.len()); -+ let mut discriminators = FxHashMap::default(); - // Instantiate all scopes. - for idx in 0..mir.source_scopes.len() { - let scope = SourceScope::new(idx); -- make_mir_scope(cx, instance, mir, &variables, debug_context, &mut instantiated, scope); -+ make_mir_scope( -+ cx, -+ instance, -+ mir, -+ &variables, -+ debug_context, -+ &mut instantiated, -+ &mut discriminators, -+ scope, -+ ); - } - assert!(instantiated.count() == mir.source_scopes.len()); - } -@@ -52,6 +66,7 @@ fn make_mir_scope<'ll, 'tcx>( - variables: &Option>, - debug_context: &mut FunctionDebugContext<'tcx, &'ll DIScope, &'ll DILocation>, - instantiated: &mut BitSet, -+ discriminators: &mut FxHashMap, - scope: SourceScope, - ) { - if instantiated.contains(scope) { -@@ -60,7 +75,16 @@ fn make_mir_scope<'ll, 'tcx>( - - let scope_data = &mir.source_scopes[scope]; - let parent_scope = if let Some(parent) = scope_data.parent_scope { -- make_mir_scope(cx, instance, mir, variables, debug_context, instantiated, parent); -+ make_mir_scope( -+ cx, -+ instance, -+ mir, -+ variables, -+ debug_context, -+ instantiated, -+ discriminators, -+ parent, -+ ); - debug_context.scopes[parent] - } else { - // The root is the function itself. -@@ -117,7 +141,37 @@ fn make_mir_scope<'ll, 'tcx>( - // FIXME(eddyb) this doesn't account for the macro-related - // `Span` fixups that `rustc_codegen_ssa::mir::debuginfo` does. - let callsite_scope = parent_scope.adjust_dbg_scope_for_span(cx, callsite_span); -- cx.dbg_loc(callsite_scope, parent_scope.inlined_at, callsite_span) -+ let loc = cx.dbg_loc(callsite_scope, parent_scope.inlined_at, callsite_span); -+ -+ // NB: In order to produce proper debug info for variables (particularly -+ // arguments) in multiply-inline functions, LLVM expects to see a single -+ // DILocalVariable with multiple different DILocations in the IR. While -+ // the source information for each DILocation would be identical, their -+ // inlinedAt attributes will be unique to the particular callsite. -+ // -+ // We generate DILocations here based on the callsite's location in the -+ // source code. A single location in the source code usually can't -+ // produce multiple distinct calls so this mostly works, until -+ // proc-macros get involved. A proc-macro can generate multiple calls -+ // at the same span, which breaks the assumption that we're going to -+ // produce a unique DILocation for every scope we process here. We -+ // have to explicitly add discriminators if we see inlines into the -+ // same source code location. -+ // -+ // Note further that we can't key this hashtable on the span itself, -+ // because these spans could have distinct SyntaxContexts. We have -+ // to key on exactly what we're giving to LLVM. -+ match discriminators.entry(callsite_span.lo()) { -+ Entry::Occupied(mut o) => { -+ *o.get_mut() += 1; -+ unsafe { llvm::LLVMRustDILocationCloneWithBaseDiscriminator(loc, *o.get()) } -+ .expect("Failed to encode discriminator in DILocation") -+ } -+ Entry::Vacant(v) => { -+ v.insert(0); -+ loc -+ } -+ } - }); - - debug_context.scopes[scope] = DebugScope { ---- a/compiler/rustc_codegen_llvm/src/llvm/ffi.rs -+++ b/compiler/rustc_codegen_llvm/src/llvm/ffi.rs -@@ -2174,6 +2174,10 @@ unsafe extern "C" { - Scope: &'a DIScope, - InlinedAt: Option<&'a DILocation>, - ) -> &'a DILocation; -+ pub fn LLVMRustDILocationCloneWithBaseDiscriminator<'a>( -+ Location: &'a DILocation, -+ BD: c_uint, -+ ) -> Option<&'a DILocation>; - pub fn LLVMRustDIBuilderCreateOpDeref() -> u64; - pub fn LLVMRustDIBuilderCreateOpPlusUconst() -> u64; - pub fn LLVMRustDIBuilderCreateOpLLVMFragment() -> u64; ---- a/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp -+++ b/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp -@@ -1305,6 +1305,14 @@ LLVMRustDIBuilderCreateDebugLocation(unsigned Line, unsigned Column, - return wrap(Loc); - } - -+extern "C" LLVMMetadataRef -+LLVMRustDILocationCloneWithBaseDiscriminator(LLVMMetadataRef Location, -+ unsigned BD) { -+ DILocation *Loc = unwrapDIPtr(Location); -+ auto NewLoc = Loc->cloneWithBaseDiscriminator(BD); -+ return wrap(NewLoc.has_value() ? NewLoc.value() : nullptr); -+} -+ - extern "C" uint64_t LLVMRustDIBuilderCreateOpDeref() { - return dwarf::DW_OP_deref; - } ---- /dev/null -+++ b/tests/codegen/debuginfo-proc-macro/auxiliary/macro_def.rs -@@ -0,0 +1,11 @@ -+//@ force-host -+//@ no-prefer-dynamic -+#![crate_type = "proc-macro"] -+ -+extern crate proc_macro; -+use proc_macro::*; -+ -+#[proc_macro] -+pub fn square_twice(_item: TokenStream) -> TokenStream { -+ "(square(env::vars().count() as i32), square(env::vars().count() as i32))".parse().unwrap() -+} ---- /dev/null -+++ b/tests/codegen/debuginfo-proc-macro/mir_inlined_twice_var_locs.rs -@@ -0,0 +1,53 @@ -+//@ min-llvm-version: 19 -+//@ compile-flags: -Cdebuginfo=2 -Copt-level=0 -Zmir-enable-passes=+Inline -+// MSVC is different because of the individual allocas. -+//@ ignore-msvc -+ -+//@ aux-build:macro_def.rs -+ -+// Find the variable. -+// CHECK-DAG: ![[#var_dbg:]] = !DILocalVariable(name: "n",{{( arg: 1,)?}} scope: ![[#var_scope:]] -+ -+// Find both dbg_declares. These will proceed the variable metadata, of course, so we're looking -+// backwards. -+// CHECK-DAG: dbg_declare(ptr %n.dbg.spill{{[0-9]}}, ![[#var_dbg]], !DIExpression(), ![[#var_loc2:]]) -+// CHECK-DAG: dbg_declare(ptr %n.dbg.spill, ![[#var_dbg]], !DIExpression(), ![[#var_loc1:]]) -+ -+// Find the first location definition, looking forwards again. -+// CHECK: ![[#var_loc1]] = !DILocation -+// CHECK-SAME: scope: ![[#var_scope:]], inlinedAt: ![[#var_inlinedAt1:]] -+ -+// Find the first location's inlinedAt -+// NB: If we fail here it's *probably* because we failed to produce two -+// different locations and ended up reusing an earlier one. -+// CHECK: ![[#var_inlinedAt1]] = !DILocation -+// CHECK-SAME: scope: ![[var_inlinedAt1_scope:]] -+ -+// Find the second location definition, still looking forwards. -+// NB: If we failed to produce two different locations, the test will -+// definitely fail by this point (if it hasn't already) because we won't -+// be able to find the same line again. -+// CHECK: ![[#var_loc2]] = !DILocation -+// CHECK-SAME: scope: ![[#var_scope]], inlinedAt: ![[#var_inlinedAt2:]] -+ -+// Find the second location's inlinedAt. -+// CHECK: ![[#var_inlinedAt2]] = !DILocation -+// CHECK-SAME: scope: ![[#var_inlinedAt2_scope:]] -+ -+// Finally, check that a discriminator was emitted for the second scope. -+// FIXMEkhuey ideally we would check that *either* scope has a discriminator -+// but I don't know that it's possible to check that with FileCheck. -+// CHECK: ![[#var_inlinedAt2_scope]] = !DILexicalBlockFile -+// CHECK-SAME: discriminator: [[#]] -+extern crate macro_def; -+ -+use std::env; -+ -+fn square(n: i32) -> i32 { -+ n * n -+} -+ -+fn main() { -+ let (z1, z2) = macro_def::square_twice!(); -+ println!("{z1} == {z2}"); -+} From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 4B4891580E0 for ; Mon, 02 Jun 2025 09:56:21 +0000 (UTC) Received: from lists.gentoo.org (bobolink.gentoo.org [140.211.166.189]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) (Authenticated sender: relay-lists.gentoo.org@gentoo.org) by smtp.gentoo.org (Postfix) with ESMTPSA id 6C7433432D6 for ; Mon, 02 Jun 2025 09:56:20 +0000 (UTC) Received: from bobolink.gentoo.org (localhost [127.0.0.1]) by bobolink.gentoo.org (Postfix) with ESMTP id 67D651105AD; Mon, 02 Jun 2025 09:49:09 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bobolink.gentoo.org (Postfix) with ESMTPS id 4CC7A1105AA for ; Mon, 02 Jun 2025 09:49:09 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 0450734328B for ; Mon, 02 Jun 2025 09:49:09 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 9C9152931 for ; Mon, 02 Jun 2025 09:49:05 +0000 (UTC) From: "Matt Jolly" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Matt Jolly" Message-ID: <1748857629.12cbabf1bf6482e7046a73cd59ba7aa0662f4bf8.kangie@gentoo> Subject: [gentoo-commits] proj/rust-patches:1.88.0_beta20250526 commit in: / X-VCS-Repository: proj/rust-patches X-VCS-Files: 1.83.0-dwarf-llvm-assertion.patch X-VCS-Directories: / X-VCS-Committer: kangie X-VCS-Committer-Name: Matt Jolly X-VCS-Revision: 12cbabf1bf6482e7046a73cd59ba7aa0662f4bf8 X-VCS-Branch: 1.88.0_beta20250526 Date: Mon, 02 Jun 2025 09:49:05 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 6a299e20-51ea-4d12-818a-35f293ce9bda X-Archives-Hash: 645fe40a10762fa761389f2fdf2582f0 Message-ID: <20250602094905.iV2srXIGc-ZWLYUZnhULg8UnzisDH-z6o7AtRfqNGlg@z> commit: 12cbabf1bf6482e7046a73cd59ba7aa0662f4bf8 Author: Matt Jolly gentoo org> AuthorDate: Mon Jun 2 09:47:09 2025 +0000 Commit: Matt Jolly gentoo org> CommitDate: Mon Jun 2 09:47:09 2025 +0000 URL: https://gitweb.gentoo.org/proj/rust-patches.git/commit/?id=12cbabf1 Add patches for Rust 1.84.0-r2 Patches: - 1.78.0-musl-dynamic-linking.patch - 1.83.0-cross-compile-libz.patch - 1.67.0-doc-wasm.patch Signed-off-by: Matt Jolly gentoo.org> 1.83.0-dwarf-llvm-assertion.patch | 220 -------------------------------------- 1 file changed, 220 deletions(-) diff --git a/1.83.0-dwarf-llvm-assertion.patch b/1.83.0-dwarf-llvm-assertion.patch deleted file mode 100644 index 96bdac0..0000000 --- a/1.83.0-dwarf-llvm-assertion.patch +++ /dev/null @@ -1,220 +0,0 @@ -From 1dc106121b62562ead6e7d612fa136dc4b35cd5d Mon Sep 17 00:00:00 2001 -From: Kyle Huey -Date: Mon, 4 Nov 2024 11:38:14 -0800 -Subject: [PATCH] Add discriminators to DILocations when multiple functions are - inlined into a single point. - -LLVM does not expect to ever see multiple dbg_declares for the same variable at the same -location with different values. proc-macros make it possible for arbitrary code, -including multiple calls that get inlined, to happen at any given location in the source -code. Add discriminators when that happens so these locations are different to LLVM. - -This may interfere with the AddDiscriminators pass in LLVM, which is added by the -unstable flag -Zdebug-info-for-profiling. - -Fixes #131944 ---- a/compiler/rustc_codegen_llvm/src/debuginfo/create_scope_map.rs -+++ b/compiler/rustc_codegen_llvm/src/debuginfo/create_scope_map.rs -@@ -1,11 +1,15 @@ -+use std::collections::hash_map::Entry; -+ - use rustc_codegen_ssa::mir::debuginfo::{DebugScope, FunctionDebugContext}; - use rustc_codegen_ssa::traits::*; -+use rustc_data_structures::fx::FxHashMap; - use rustc_index::Idx; - use rustc_index::bit_set::BitSet; - use rustc_middle::mir::{Body, SourceScope}; - use rustc_middle::ty::layout::FnAbiOf; - use rustc_middle::ty::{self, Instance}; - use rustc_session::config::DebugInfo; -+use rustc_span::BytePos; - - use super::metadata::file_metadata; - use super::utils::DIB; -@@ -37,10 +41,20 @@ pub(crate) fn compute_mir_scopes<'ll, 'tcx>( - None - }; - let mut instantiated = BitSet::new_empty(mir.source_scopes.len()); -+ let mut discriminators = FxHashMap::default(); - // Instantiate all scopes. - for idx in 0..mir.source_scopes.len() { - let scope = SourceScope::new(idx); -- make_mir_scope(cx, instance, mir, &variables, debug_context, &mut instantiated, scope); -+ make_mir_scope( -+ cx, -+ instance, -+ mir, -+ &variables, -+ debug_context, -+ &mut instantiated, -+ &mut discriminators, -+ scope, -+ ); - } - assert!(instantiated.count() == mir.source_scopes.len()); - } -@@ -52,6 +66,7 @@ fn make_mir_scope<'ll, 'tcx>( - variables: &Option>, - debug_context: &mut FunctionDebugContext<'tcx, &'ll DIScope, &'ll DILocation>, - instantiated: &mut BitSet, -+ discriminators: &mut FxHashMap, - scope: SourceScope, - ) { - if instantiated.contains(scope) { -@@ -60,7 +75,16 @@ fn make_mir_scope<'ll, 'tcx>( - - let scope_data = &mir.source_scopes[scope]; - let parent_scope = if let Some(parent) = scope_data.parent_scope { -- make_mir_scope(cx, instance, mir, variables, debug_context, instantiated, parent); -+ make_mir_scope( -+ cx, -+ instance, -+ mir, -+ variables, -+ debug_context, -+ instantiated, -+ discriminators, -+ parent, -+ ); - debug_context.scopes[parent] - } else { - // The root is the function itself. -@@ -117,7 +141,37 @@ fn make_mir_scope<'ll, 'tcx>( - // FIXME(eddyb) this doesn't account for the macro-related - // `Span` fixups that `rustc_codegen_ssa::mir::debuginfo` does. - let callsite_scope = parent_scope.adjust_dbg_scope_for_span(cx, callsite_span); -- cx.dbg_loc(callsite_scope, parent_scope.inlined_at, callsite_span) -+ let loc = cx.dbg_loc(callsite_scope, parent_scope.inlined_at, callsite_span); -+ -+ // NB: In order to produce proper debug info for variables (particularly -+ // arguments) in multiply-inline functions, LLVM expects to see a single -+ // DILocalVariable with multiple different DILocations in the IR. While -+ // the source information for each DILocation would be identical, their -+ // inlinedAt attributes will be unique to the particular callsite. -+ // -+ // We generate DILocations here based on the callsite's location in the -+ // source code. A single location in the source code usually can't -+ // produce multiple distinct calls so this mostly works, until -+ // proc-macros get involved. A proc-macro can generate multiple calls -+ // at the same span, which breaks the assumption that we're going to -+ // produce a unique DILocation for every scope we process here. We -+ // have to explicitly add discriminators if we see inlines into the -+ // same source code location. -+ // -+ // Note further that we can't key this hashtable on the span itself, -+ // because these spans could have distinct SyntaxContexts. We have -+ // to key on exactly what we're giving to LLVM. -+ match discriminators.entry(callsite_span.lo()) { -+ Entry::Occupied(mut o) => { -+ *o.get_mut() += 1; -+ unsafe { llvm::LLVMRustDILocationCloneWithBaseDiscriminator(loc, *o.get()) } -+ .expect("Failed to encode discriminator in DILocation") -+ } -+ Entry::Vacant(v) => { -+ v.insert(0); -+ loc -+ } -+ } - }); - - debug_context.scopes[scope] = DebugScope { ---- a/compiler/rustc_codegen_llvm/src/llvm/ffi.rs -+++ b/compiler/rustc_codegen_llvm/src/llvm/ffi.rs -@@ -2174,6 +2174,10 @@ unsafe extern "C" { - Scope: &'a DIScope, - InlinedAt: Option<&'a DILocation>, - ) -> &'a DILocation; -+ pub fn LLVMRustDILocationCloneWithBaseDiscriminator<'a>( -+ Location: &'a DILocation, -+ BD: c_uint, -+ ) -> Option<&'a DILocation>; - pub fn LLVMRustDIBuilderCreateOpDeref() -> u64; - pub fn LLVMRustDIBuilderCreateOpPlusUconst() -> u64; - pub fn LLVMRustDIBuilderCreateOpLLVMFragment() -> u64; ---- a/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp -+++ b/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp -@@ -1305,6 +1305,14 @@ LLVMRustDIBuilderCreateDebugLocation(unsigned Line, unsigned Column, - return wrap(Loc); - } - -+extern "C" LLVMMetadataRef -+LLVMRustDILocationCloneWithBaseDiscriminator(LLVMMetadataRef Location, -+ unsigned BD) { -+ DILocation *Loc = unwrapDIPtr(Location); -+ auto NewLoc = Loc->cloneWithBaseDiscriminator(BD); -+ return wrap(NewLoc.has_value() ? NewLoc.value() : nullptr); -+} -+ - extern "C" uint64_t LLVMRustDIBuilderCreateOpDeref() { - return dwarf::DW_OP_deref; - } ---- /dev/null -+++ b/tests/codegen/debuginfo-proc-macro/auxiliary/macro_def.rs -@@ -0,0 +1,11 @@ -+//@ force-host -+//@ no-prefer-dynamic -+#![crate_type = "proc-macro"] -+ -+extern crate proc_macro; -+use proc_macro::*; -+ -+#[proc_macro] -+pub fn square_twice(_item: TokenStream) -> TokenStream { -+ "(square(env::vars().count() as i32), square(env::vars().count() as i32))".parse().unwrap() -+} ---- /dev/null -+++ b/tests/codegen/debuginfo-proc-macro/mir_inlined_twice_var_locs.rs -@@ -0,0 +1,53 @@ -+//@ min-llvm-version: 19 -+//@ compile-flags: -Cdebuginfo=2 -Copt-level=0 -Zmir-enable-passes=+Inline -+// MSVC is different because of the individual allocas. -+//@ ignore-msvc -+ -+//@ aux-build:macro_def.rs -+ -+// Find the variable. -+// CHECK-DAG: ![[#var_dbg:]] = !DILocalVariable(name: "n",{{( arg: 1,)?}} scope: ![[#var_scope:]] -+ -+// Find both dbg_declares. These will proceed the variable metadata, of course, so we're looking -+// backwards. -+// CHECK-DAG: dbg_declare(ptr %n.dbg.spill{{[0-9]}}, ![[#var_dbg]], !DIExpression(), ![[#var_loc2:]]) -+// CHECK-DAG: dbg_declare(ptr %n.dbg.spill, ![[#var_dbg]], !DIExpression(), ![[#var_loc1:]]) -+ -+// Find the first location definition, looking forwards again. -+// CHECK: ![[#var_loc1]] = !DILocation -+// CHECK-SAME: scope: ![[#var_scope:]], inlinedAt: ![[#var_inlinedAt1:]] -+ -+// Find the first location's inlinedAt -+// NB: If we fail here it's *probably* because we failed to produce two -+// different locations and ended up reusing an earlier one. -+// CHECK: ![[#var_inlinedAt1]] = !DILocation -+// CHECK-SAME: scope: ![[var_inlinedAt1_scope:]] -+ -+// Find the second location definition, still looking forwards. -+// NB: If we failed to produce two different locations, the test will -+// definitely fail by this point (if it hasn't already) because we won't -+// be able to find the same line again. -+// CHECK: ![[#var_loc2]] = !DILocation -+// CHECK-SAME: scope: ![[#var_scope]], inlinedAt: ![[#var_inlinedAt2:]] -+ -+// Find the second location's inlinedAt. -+// CHECK: ![[#var_inlinedAt2]] = !DILocation -+// CHECK-SAME: scope: ![[#var_inlinedAt2_scope:]] -+ -+// Finally, check that a discriminator was emitted for the second scope. -+// FIXMEkhuey ideally we would check that *either* scope has a discriminator -+// but I don't know that it's possible to check that with FileCheck. -+// CHECK: ![[#var_inlinedAt2_scope]] = !DILexicalBlockFile -+// CHECK-SAME: discriminator: [[#]] -+extern crate macro_def; -+ -+use std::env; -+ -+fn square(n: i32) -> i32 { -+ n * n -+} -+ -+fn main() { -+ let (z1, z2) = macro_def::square_twice!(); -+ println!("{z1} == {z2}"); -+}