From 529aae6fc368818bf64d21aab217826a6c0745fc Mon Sep 17 00:00:00 2001
From: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com>
Date: Mon, 18 Nov 2024 18:58:56 +0100
Subject: [PATCH 01/30] wasi/fs: Improve stopping condition for <ReadDir as
 Iterator>::next

When upgrading [Zed](https://github.com/zed-industries/zed/pull/19349) to Rust 1.82 I've encountered a test failure in our test suite. Specifically, one of our extension tests started hanging. I've tracked it down to a call to std::fs::remove_dir_all not returning when an extension is compiled with Rust 1.82
Our extension system uses WASM components, thus I've looked at the diff between 1.81 and 1.82 with respect to WASI and found 736f773844e7ebf05ccb827c17b7ad9eb28aa295

As it turned out, calling remove_dir_all from extension returned io::ErrorKind::NotFound in 1.81;
the underlying issue is that the ReadDir iterator never actually terminates iteration, however since it loops around, with 1.81 we'd come across an entry second time and fail to remove it, since it would've been removed previously.
With 1.82 and 736f773844e7ebf05ccb827c17b7ad9eb28aa295 it is no longer the case, thus we're seeing the hang.

This commit makes ReadDir::next adhere to readdir contract, namely it will no longer call readdir once the returned # of bytes is smaller than the size of a passed-in buffer.
Previously we'd only terminate the loop if readdir returned 0.
---
 library/std/src/sys/pal/wasi/fs.rs | 31 ++++++++++++++++--------------
 1 file changed, 17 insertions(+), 14 deletions(-)

diff --git a/library/std/src/sys/pal/wasi/fs.rs b/library/std/src/sys/pal/wasi/fs.rs
index 3296c762cca2b..b519a0fe6a3a4 100644
--- a/library/std/src/sys/pal/wasi/fs.rs
+++ b/library/std/src/sys/pal/wasi/fs.rs
@@ -172,20 +172,22 @@ impl Iterator for ReadDir {
             let offset = if self.offset == self.cap {
                 let cookie = self.cookie.take()?;
                 match self.inner.dir.fd.readdir(&mut self.buf, cookie) {
-                    Ok(bytes) => self.cap = bytes,
+                    Ok(bytes) => {
+                        // No more entries if we read less than buffer size
+                        if bytes < self.buf.len() {
+                            self.cookie = None;
+                            if bytes == 0 {
+                                return None;
+                            }
+                        } else {
+                            self.cookie = Some(cookie);
+                        }
+                        self.cap = self.buf.len();
+                        self.offset = 0;
+                        0
+                    }
                     Err(e) => return Some(Err(e)),
                 }
-                self.offset = 0;
-                self.cookie = Some(cookie);
-
-                // If we didn't actually read anything, this is in theory the
-                // end of the directory.
-                if self.cap == 0 {
-                    self.cookie = None;
-                    return None;
-                }
-
-                0
             } else {
                 self.offset
             };
@@ -197,7 +199,6 @@ impl Iterator for ReadDir {
             // where we last left off.
             let dirent_size = mem::size_of::<wasi::Dirent>();
             if data.len() < dirent_size {
-                assert!(self.cookie.is_some());
                 assert!(self.buf.len() >= dirent_size);
                 self.offset = self.cap;
                 continue;
@@ -218,7 +219,9 @@ impl Iterator for ReadDir {
                 self.offset = self.cap;
                 continue;
             }
-            self.cookie = Some(dirent.d_next);
+            self.cookie.as_mut().map(|cookie| {
+                *cookie = dirent.d_next;
+            });
             self.offset = offset + dirent_size + dirent.d_namlen as usize;
 
             let name = &data[..(dirent.d_namlen as usize)];

From 692c19ae8032f80fc75912b98651bfc841cfbaf0 Mon Sep 17 00:00:00 2001
From: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com>
Date: Tue, 26 Nov 2024 13:45:17 +0100
Subject: [PATCH 02/30] Refactor ReadDir into a state machine

---
 library/std/src/sys/pal/wasi/fs.rs | 171 +++++++++++++++++------------
 1 file changed, 101 insertions(+), 70 deletions(-)

diff --git a/library/std/src/sys/pal/wasi/fs.rs b/library/std/src/sys/pal/wasi/fs.rs
index b519a0fe6a3a4..5c6ddfa559eca 100644
--- a/library/std/src/sys/pal/wasi/fs.rs
+++ b/library/std/src/sys/pal/wasi/fs.rs
@@ -27,10 +27,26 @@ pub struct FileAttr {
 
 pub struct ReadDir {
     inner: Arc<ReadDirInner>,
-    cookie: Option<wasi::Dircookie>,
-    buf: Vec<u8>,
-    offset: usize,
-    cap: usize,
+    state: ReadDirState,
+}
+
+enum ReadDirState {
+    /// Next DirEntry should be read from contents of buf at `offset`
+    FillBuffer {
+        next_read_offset: wasi::Dircookie,
+        buf: Vec<u8>,
+    },
+    ProcessEntry {
+        buf: Vec<u8>,
+        next_read_offset: Option<wasi::Dircookie>,
+        offset: usize,
+    },
+    /// Do not fetch any more entries, process all entries
+    RunUntilExhaustion {
+        buf: Vec<u8>,
+        offset: usize,
+    },
+    Done,
 }
 
 struct ReadDirInner {
@@ -147,11 +163,8 @@ impl FileType {
 impl ReadDir {
     fn new(dir: File, root: PathBuf) -> ReadDir {
         ReadDir {
-            cookie: Some(0),
-            buf: vec![0; 128],
-            offset: 0,
-            cap: 0,
             inner: Arc::new(ReadDirInner { dir, root }),
+            state: ReadDirState::FillBuffer { next_read_offset: 0, buf: vec![0; 128] },
         }
     }
 }
@@ -162,81 +175,99 @@ impl fmt::Debug for ReadDir {
     }
 }
 
+impl core::iter::FusedIterator for ReadDir {}
+
 impl Iterator for ReadDir {
     type Item = io::Result<DirEntry>;
 
     fn next(&mut self) -> Option<io::Result<DirEntry>> {
-        loop {
-            // If we've reached the capacity of our buffer then we need to read
-            // some more from the OS, otherwise we pick up at our old offset.
-            let offset = if self.offset == self.cap {
-                let cookie = self.cookie.take()?;
-                match self.inner.dir.fd.readdir(&mut self.buf, cookie) {
-                    Ok(bytes) => {
-                        // No more entries if we read less than buffer size
-                        if bytes < self.buf.len() {
-                            self.cookie = None;
-                            if bytes == 0 {
-                                return None;
-                            }
+        match &mut self.state {
+            ReadDirState::FillBuffer { next_read_offset, ref mut buf } => {
+                let result = self.inner.dir.fd.readdir(buf, *next_read_offset);
+                match result {
+                    Ok(read_bytes) => {
+                        if read_bytes < buf.len() {
+                            buf.truncate(read_bytes);
+                            self.state =
+                                ReadDirState::RunUntilExhaustion { buf: mem::take(buf), offset: 0 };
                         } else {
-                            self.cookie = Some(cookie);
+                            debug_assert_eq!(read_bytes, buf.len());
+                            self.state = ReadDirState::ProcessEntry {
+                                buf: mem::take(buf),
+                                offset: 0,
+                                next_read_offset: Some(*next_read_offset),
+                            };
                         }
-                        self.cap = self.buf.len();
-                        self.offset = 0;
-                        0
+                        self.next()
+                    }
+                    Err(e) => {
+                        self.state = ReadDirState::Done;
+                        return Some(Err(e));
                     }
-                    Err(e) => return Some(Err(e)),
-                }
-            } else {
-                self.offset
-            };
-            let data = &self.buf[offset..self.cap];
-
-            // If we're not able to read a directory entry then that means it
-            // must have been truncated at the end of the buffer, so reset our
-            // offset so we can go back and reread into the buffer, picking up
-            // where we last left off.
-            let dirent_size = mem::size_of::<wasi::Dirent>();
-            if data.len() < dirent_size {
-                assert!(self.buf.len() >= dirent_size);
-                self.offset = self.cap;
-                continue;
-            }
-            let (dirent, data) = data.split_at(dirent_size);
-            let dirent = unsafe { ptr::read_unaligned(dirent.as_ptr() as *const wasi::Dirent) };
-
-            // If the file name was truncated, then we need to reinvoke
-            // `readdir` so we truncate our buffer to start over and reread this
-            // descriptor. Note that if our offset is 0 that means the file name
-            // is massive and we need a bigger buffer.
-            if data.len() < dirent.d_namlen as usize {
-                if offset == 0 {
-                    let amt_to_add = self.buf.capacity();
-                    self.buf.extend(iter::repeat(0).take(amt_to_add));
                 }
-                assert!(self.cookie.is_some());
-                self.offset = self.cap;
-                continue;
             }
-            self.cookie.as_mut().map(|cookie| {
-                *cookie = dirent.d_next;
-            });
-            self.offset = offset + dirent_size + dirent.d_namlen as usize;
+            ReadDirState::ProcessEntry { ref mut buf, next_read_offset, offset } => {
+                let contents = &buf[*offset..];
+                const DIRENT_SIZE: usize = crate::mem::size_of::<wasi::Dirent>();
+                if contents.len() >= DIRENT_SIZE {
+                    let (dirent, data) = contents.split_at(DIRENT_SIZE);
+                    let dirent =
+                        unsafe { ptr::read_unaligned(dirent.as_ptr() as *const wasi::Dirent) };
+                    // If the file name was truncated, then we need to reinvoke
+                    // `readdir` so we truncate our buffer to start over and reread this
+                    // descriptor.
+                    if data.len() < dirent.d_namlen as usize {
+                        if buf.len() < dirent.d_namlen as usize + DIRENT_SIZE {
+                            buf.resize(dirent.d_namlen as usize + DIRENT_SIZE, 0);
+                        }
+                        if let Some(next_read_offset) = *next_read_offset {
+                            self.state =
+                                ReadDirState::FillBuffer { next_read_offset, buf: mem::take(buf) };
+                        } else {
+                            self.state = ReadDirState::Done;
+                        }
+
+                        return self.next();
+                    }
+                    next_read_offset.as_mut().map(|cookie| {
+                        *cookie = dirent.d_next;
+                    });
+                    *offset = *offset + DIRENT_SIZE + dirent.d_namlen as usize;
+
+                    let name = &data[..(dirent.d_namlen as usize)];
 
-            let name = &data[..(dirent.d_namlen as usize)];
+                    // These names are skipped on all other platforms, so let's skip
+                    // them here too
+                    if name == b"." || name == b".." {
+                        return self.next();
+                    }
 
-            // These names are skipped on all other platforms, so let's skip
-            // them here too
-            if name == b"." || name == b".." {
-                continue;
+                    return Some(Ok(DirEntry {
+                        meta: dirent,
+                        name: name.to_vec(),
+                        inner: self.inner.clone(),
+                    }));
+                } else if let Some(next_read_offset) = *next_read_offset {
+                    self.state = ReadDirState::FillBuffer { next_read_offset, buf: mem::take(buf) };
+                } else {
+                    self.state = ReadDirState::Done;
+                }
+                self.next()
             }
+            ReadDirState::RunUntilExhaustion { buf, offset } => {
+                if *offset >= buf.len() {
+                    self.state = ReadDirState::Done;
+                } else {
+                    self.state = ReadDirState::ProcessEntry {
+                        buf: mem::take(buf),
+                        offset: *offset,
+                        next_read_offset: None,
+                    };
+                }
 
-            return Some(Ok(DirEntry {
-                meta: dirent,
-                name: name.to_vec(),
-                inner: self.inner.clone(),
-            }));
+                self.next()
+            }
+            ReadDirState::Done => None,
         }
     }
 }

From f4ab9829e1a3c6e564f79c98f39632aecbc675d3 Mon Sep 17 00:00:00 2001
From: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com>
Date: Tue, 26 Nov 2024 22:46:12 +0100
Subject: [PATCH 03/30] chore: Improve doc comments

---
 library/std/src/sys/pal/wasi/fs.rs | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/library/std/src/sys/pal/wasi/fs.rs b/library/std/src/sys/pal/wasi/fs.rs
index 5c6ddfa559eca..9e233436a8447 100644
--- a/library/std/src/sys/pal/wasi/fs.rs
+++ b/library/std/src/sys/pal/wasi/fs.rs
@@ -31,7 +31,7 @@ pub struct ReadDir {
 }
 
 enum ReadDirState {
-    /// Next DirEntry should be read from contents of buf at `offset`
+    /// Fill `buf` with `buf.len()` bytes starting from `next_read_offset`.
     FillBuffer {
         next_read_offset: wasi::Dircookie,
         buf: Vec<u8>,
@@ -41,7 +41,8 @@ enum ReadDirState {
         next_read_offset: Option<wasi::Dircookie>,
         offset: usize,
     },
-    /// Do not fetch any more entries, process all entries
+    /// There is no more data to get in [`Self::FillBuffer`]; keep returning
+    /// entries via ProcessEntry until `buf` is exhausted.
     RunUntilExhaustion {
         buf: Vec<u8>,
         offset: usize,

From 9142cae7d5b86ac70f815c32c0f3b1223b62a947 Mon Sep 17 00:00:00 2001
From: Folkert <folkert@folkertdev.nl>
Date: Thu, 8 Aug 2024 10:20:40 +0200
Subject: [PATCH 04/30] add `LinkageInfo` to keep track of how we figured out
 the linkage

---
 .../rustc_codegen_cranelift/src/driver/mod.rs |  2 +-
 compiler/rustc_codegen_gcc/src/base.rs        |  2 +-
 compiler/rustc_codegen_llvm/src/base.rs       |  2 +-
 .../src/back/symbol_export.rs                 |  4 +-
 compiler/rustc_codegen_ssa/src/mono_item.rs   | 12 ++---
 compiler/rustc_middle/src/mir/mono.rs         | 46 ++++++++++++++++-
 .../rustc_monomorphize/src/partitioning.rs    | 49 ++++++++++---------
 7 files changed, 82 insertions(+), 35 deletions(-)

diff --git a/compiler/rustc_codegen_cranelift/src/driver/mod.rs b/compiler/rustc_codegen_cranelift/src/driver/mod.rs
index fb0eed07c1971..dbc913528f44a 100644
--- a/compiler/rustc_codegen_cranelift/src/driver/mod.rs
+++ b/compiler/rustc_codegen_cranelift/src/driver/mod.rs
@@ -30,7 +30,7 @@ fn predefine_mono_items<'tcx>(
                         get_function_sig(tcx, module.target_config().default_call_conv, instance);
                     let linkage = crate::linkage::get_clif_linkage(
                         mono_item,
-                        data.linkage,
+                        data.linkage_info.into_linkage(),
                         data.visibility,
                         is_compiler_builtins,
                     );
diff --git a/compiler/rustc_codegen_gcc/src/base.rs b/compiler/rustc_codegen_gcc/src/base.rs
index 18aa32754e1d9..844871a714671 100644
--- a/compiler/rustc_codegen_gcc/src/base.rs
+++ b/compiler/rustc_codegen_gcc/src/base.rs
@@ -213,7 +213,7 @@ pub fn compile_codegen_unit(
 
             let mono_items = cgu.items_in_deterministic_order(tcx);
             for &(mono_item, data) in &mono_items {
-                mono_item.predefine::<Builder<'_, '_, '_>>(&cx, data.linkage, data.visibility);
+                mono_item.predefine::<Builder<'_, '_, '_>>(&cx, data.linkage_info, data.visibility);
             }
 
             // ... and now that we have everything pre-defined, fill out those definitions.
diff --git a/compiler/rustc_codegen_llvm/src/base.rs b/compiler/rustc_codegen_llvm/src/base.rs
index f62310bd94808..82c3cfe9aa04a 100644
--- a/compiler/rustc_codegen_llvm/src/base.rs
+++ b/compiler/rustc_codegen_llvm/src/base.rs
@@ -86,7 +86,7 @@ pub(crate) fn compile_codegen_unit(
             let cx = CodegenCx::new(tcx, cgu, &llvm_module);
             let mono_items = cx.codegen_unit.items_in_deterministic_order(cx.tcx);
             for &(mono_item, data) in &mono_items {
-                mono_item.predefine::<Builder<'_, '_, '_>>(&cx, data.linkage, data.visibility);
+                mono_item.predefine::<Builder<'_, '_, '_>>(&cx, data.linkage_info, data.visibility);
             }
 
             // ... and now that we have everything pre-defined, fill out those definitions.
diff --git a/compiler/rustc_codegen_ssa/src/back/symbol_export.rs b/compiler/rustc_codegen_ssa/src/back/symbol_export.rs
index 788a8a13b3ee4..0321a244f8683 100644
--- a/compiler/rustc_codegen_ssa/src/back/symbol_export.rs
+++ b/compiler/rustc_codegen_ssa/src/back/symbol_export.rs
@@ -283,7 +283,7 @@ fn exported_symbols_provider_local(
     }
 
     if tcx.local_crate_exports_generics() {
-        use rustc_middle::mir::mono::{Linkage, MonoItem, Visibility};
+        use rustc_middle::mir::mono::{MonoItem, Visibility};
         use rustc_middle::ty::InstanceKind;
 
         // Normally, we require that shared monomorphizations are not hidden,
@@ -298,7 +298,7 @@ fn exported_symbols_provider_local(
         // The symbols created in this loop are sorted below it
         #[allow(rustc::potential_query_instability)]
         for (mono_item, data) in cgus.iter().flat_map(|cgu| cgu.items().iter()) {
-            if data.linkage != Linkage::External {
+            if !data.linkage_info.is_external() {
                 // We can only re-use things with external linkage, otherwise
                 // we'll get a linker error
                 continue;
diff --git a/compiler/rustc_codegen_ssa/src/mono_item.rs b/compiler/rustc_codegen_ssa/src/mono_item.rs
index 038c5857face1..04159422e3cb2 100644
--- a/compiler/rustc_codegen_ssa/src/mono_item.rs
+++ b/compiler/rustc_codegen_ssa/src/mono_item.rs
@@ -1,8 +1,8 @@
 use rustc_hir as hir;
 use rustc_middle::mir::interpret::ErrorHandled;
-use rustc_middle::mir::mono::{Linkage, MonoItem, Visibility};
-use rustc_middle::ty::Instance;
+use rustc_middle::mir::mono::{LinkageInfo, MonoItem, Visibility};
 use rustc_middle::ty::layout::{HasTyCtxt, LayoutOf};
+use rustc_middle::ty::Instance;
 use rustc_middle::{span_bug, ty};
 use tracing::debug;
 
@@ -14,7 +14,7 @@ pub trait MonoItemExt<'a, 'tcx> {
     fn predefine<Bx: BuilderMethods<'a, 'tcx>>(
         &self,
         cx: &'a Bx::CodegenCx,
-        linkage: Linkage,
+        linkage_info: LinkageInfo,
         visibility: Visibility,
     );
     fn to_raw_string(&self) -> String;
@@ -116,7 +116,7 @@ impl<'a, 'tcx: 'a> MonoItemExt<'a, 'tcx> for MonoItem<'tcx> {
     fn predefine<Bx: BuilderMethods<'a, 'tcx>>(
         &self,
         cx: &'a Bx::CodegenCx,
-        linkage: Linkage,
+        linkage_info: LinkageInfo,
         visibility: Visibility,
     ) {
         debug!(
@@ -132,10 +132,10 @@ impl<'a, 'tcx: 'a> MonoItemExt<'a, 'tcx> for MonoItem<'tcx> {
 
         match *self {
             MonoItem::Static(def_id) => {
-                cx.predefine_static(def_id, linkage, visibility, symbol_name);
+                cx.predefine_static(def_id, linkage_info.into_linkage(), visibility, symbol_name);
             }
             MonoItem::Fn(instance) => {
-                cx.predefine_fn(instance, linkage, visibility, symbol_name);
+                cx.predefine_fn(instance, linkage_info.into_linkage(), visibility, symbol_name);
             }
             MonoItem::GlobalAsm(..) => {}
         }
diff --git a/compiler/rustc_middle/src/mir/mono.rs b/compiler/rustc_middle/src/mir/mono.rs
index 161716610fe63..ca230d7fa8584 100644
--- a/compiler/rustc_middle/src/mir/mono.rs
+++ b/compiler/rustc_middle/src/mir/mono.rs
@@ -266,13 +266,57 @@ pub struct MonoItemData {
     /// `GloballyShared` maps to `false` and `LocalCopy` maps to `true`.
     pub inlined: bool,
 
-    pub linkage: Linkage,
+    pub linkage_info: LinkageInfo,
     pub visibility: Visibility,
 
     /// A cached copy of the result of `MonoItem::size_estimate`.
     pub size_estimate: usize,
 }
 
+/// Stores how we know what linkage to use
+#[derive(Copy, Clone, PartialEq, Debug, TyEncodable, TyDecodable, HashStable)]
+pub enum LinkageInfo {
+    /// The linkage was specified explicitly (e.g. using #[linkage = "..."])
+    Explicit(Linkage),
+    /// Assume the symbol may be used from other CGUs, a safe default
+    ImplicitExternal,
+    /// We did not find any uses from other CGUs, so it's fine to make this internal
+    ImplicitInternal,
+}
+
+impl LinkageInfo {
+    pub const fn is_external(self) -> bool {
+        matches!(self.into_linkage(), Linkage::External)
+    }
+
+    pub const fn into_linkage(self) -> Linkage {
+        match self {
+            Self::Explicit(linkage) => linkage,
+            Self::ImplicitExternal => Linkage::External,
+            Self::ImplicitInternal => Linkage::Internal,
+        }
+    }
+
+    /// Linkage when the MonoItem is a naked function
+    ///
+    /// Naked functions are generated as a separate declaration (effectively an extern fn) and
+    /// definition (using global assembly). To link them together, some flavor of external linkage
+    /// must be used.
+    pub const fn into_naked_linkage(self) -> Linkage {
+        match self {
+            // promote Weak linkage to ExternalWeak
+            Self::Explicit(Linkage::WeakAny | Linkage::WeakODR) => Linkage::ExternalWeak,
+            Self::Explicit(linkage) => linkage,
+
+            // the "implicit" means that linkage is picked by the partitioning algorithm.
+            // picking external should always be valid (given that we are in fact linking
+            // to the global assembly in the same CGU)
+            Self::ImplicitExternal => Linkage::External,
+            Self::ImplicitInternal => Linkage::External,
+        }
+    }
+}
+
 /// Specifies the linkage type for a `MonoItem`.
 ///
 /// See <https://llvm.org/docs/LangRef.html#linkage-types> for more details about these variants.
diff --git a/compiler/rustc_monomorphize/src/partitioning.rs b/compiler/rustc_monomorphize/src/partitioning.rs
index 7ea4ded2b052c..2fd89e389e547 100644
--- a/compiler/rustc_monomorphize/src/partitioning.rs
+++ b/compiler/rustc_monomorphize/src/partitioning.rs
@@ -109,8 +109,8 @@ use rustc_middle::bug;
 use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags;
 use rustc_middle::middle::exported_symbols::{SymbolExportInfo, SymbolExportLevel};
 use rustc_middle::mir::mono::{
-    CodegenUnit, CodegenUnitNameBuilder, InstantiationMode, Linkage, MonoItem, MonoItemData,
-    Visibility,
+    CodegenUnit, CodegenUnitNameBuilder, InstantiationMode, Linkage, LinkageInfo, MonoItem,
+    MonoItemData, Visibility,
 };
 use rustc_middle::ty::print::{characteristic_def_id_of_type, with_no_trimmed_paths};
 use rustc_middle::ty::visit::TypeVisitableExt;
@@ -245,7 +245,7 @@ where
         let cgu = codegen_units.entry(cgu_name).or_insert_with(|| CodegenUnit::new(cgu_name));
 
         let mut can_be_internalized = true;
-        let (linkage, visibility) = mono_item_linkage_and_visibility(
+        let (linkage_info, visibility) = mono_item_linkage_info_and_visibility(
             cx.tcx,
             &mono_item,
             &mut can_be_internalized,
@@ -259,7 +259,7 @@ where
 
         cgu.items_mut().insert(mono_item, MonoItemData {
             inlined: false,
-            linkage,
+            linkage_info,
             visibility,
             size_estimate,
         });
@@ -278,7 +278,7 @@ where
             // This is a CGU-private copy.
             cgu.items_mut().entry(inlined_item).or_insert_with(|| MonoItemData {
                 inlined: true,
-                linkage: Linkage::Internal,
+                linkage_info: LinkageInfo::ImplicitInternal,
                 visibility: Visibility::Default,
                 size_estimate: inlined_item.size_estimate(cx.tcx),
             });
@@ -589,7 +589,8 @@ fn internalize_symbols<'tcx>(
 
             // If we got here, we did not find any uses from other CGUs, so
             // it's fine to make this monomorphization internal.
-            data.linkage = Linkage::Internal;
+            debug_assert_eq!(data.linkage_info, LinkageInfo::ImplicitExternal);
+            data.linkage_info = LinkageInfo::ImplicitInternal;
             data.visibility = Visibility::Default;
         }
     }
@@ -607,7 +608,7 @@ fn mark_code_coverage_dead_code_cgu<'tcx>(codegen_units: &mut [CodegenUnit<'tcx>
     // function symbols to be included via `-u` or `/include` linker args.
     let dead_code_cgu = codegen_units
         .iter_mut()
-        .filter(|cgu| cgu.items().iter().any(|(_, data)| data.linkage == Linkage::External))
+        .filter(|cgu| cgu.items().iter().any(|(_, data)| data.linkage_info.is_external()))
         .min_by_key(|cgu| cgu.size_estimate());
 
     // If there are no CGUs that have externally linked items, then we just
@@ -736,24 +737,26 @@ fn fallback_cgu_name(name_builder: &mut CodegenUnitNameBuilder<'_>) -> Symbol {
     name_builder.build_cgu_name(LOCAL_CRATE, &["fallback"], Some("cgu"))
 }
 
-fn mono_item_linkage_and_visibility<'tcx>(
+fn mono_item_linkage_info_and_visibility<'tcx>(
     tcx: TyCtxt<'tcx>,
     mono_item: &MonoItem<'tcx>,
     can_be_internalized: &mut bool,
     can_export_generics: bool,
     always_export_generics: bool,
-) -> (Linkage, Visibility) {
+) -> (LinkageInfo, Visibility) {
     if let Some(explicit_linkage) = mono_item.explicit_linkage(tcx) {
-        return (explicit_linkage, Visibility::Default);
+        (LinkageInfo::Explicit(explicit_linkage), Visibility::Default)
+    } else {
+        let vis = mono_item_visibility(
+            tcx,
+            mono_item,
+            can_be_internalized,
+            can_export_generics,
+            always_export_generics,
+        );
+
+        (LinkageInfo::ImplicitExternal, vis)
     }
-    let vis = mono_item_visibility(
-        tcx,
-        mono_item,
-        can_be_internalized,
-        can_export_generics,
-        always_export_generics,
-    );
-    (Linkage::External, vis)
 }
 
 type CguNameCache = UnordMap<(DefId, bool), Symbol>;
@@ -1033,7 +1036,7 @@ fn debug_dump<'a, 'tcx: 'a>(tcx: TyCtxt<'tcx>, label: &str, cgus: &[CodegenUnit<
                 writeln!(s, "  - items: {num_items}, mean size: {mean_size:.1}, sizes: {sizes}",);
 
             for (item, data) in cgu.items_in_deterministic_order(tcx) {
-                let linkage = data.linkage;
+                let linkage_info = data.linkage_info;
                 let symbol_name = item.symbol_name(tcx).name;
                 let symbol_hash_start = symbol_name.rfind('h');
                 let symbol_hash = symbol_hash_start.map_or("<no hash>", |i| &symbol_name[i..]);
@@ -1041,7 +1044,7 @@ fn debug_dump<'a, 'tcx: 'a>(tcx: TyCtxt<'tcx>, label: &str, cgus: &[CodegenUnit<
                 let size = data.size_estimate;
                 let _ = with_no_trimmed_paths!(writeln!(
                     s,
-                    "  - {item} [{linkage:?}] [{symbol_hash}] ({kind}, size: {size})"
+                    "  - {item} [{linkage_info:?}] [{symbol_hash}] ({kind}, size: {size})"
                 ));
             }
 
@@ -1194,7 +1197,7 @@ fn collect_and_partition_mono_items(tcx: TyCtxt<'_>, (): ()) -> (&DefIdSet, &[Co
 
         for cgu in codegen_units {
             for (&mono_item, &data) in cgu.items() {
-                item_to_cgus.entry(mono_item).or_default().push((cgu.name(), data.linkage));
+                item_to_cgus.entry(mono_item).or_default().push((cgu.name(), data.linkage_info));
             }
         }
 
@@ -1207,11 +1210,11 @@ fn collect_and_partition_mono_items(tcx: TyCtxt<'_>, (): ()) -> (&DefIdSet, &[Co
                 let cgus = item_to_cgus.get_mut(i).unwrap_or(&mut empty);
                 cgus.sort_by_key(|(name, _)| *name);
                 cgus.dedup();
-                for &(ref cgu_name, linkage) in cgus.iter() {
+                for &(ref cgu_name, linkage_info) in cgus.iter() {
                     output.push(' ');
                     output.push_str(cgu_name.as_str());
 
-                    let linkage_abbrev = match linkage {
+                    let linkage_abbrev = match linkage_info.into_linkage() {
                         Linkage::External => "External",
                         Linkage::AvailableExternally => "Available",
                         Linkage::LinkOnceAny => "OnceAny",

From bdf64e134d2d55919c567c891ddc00b757fcd27c Mon Sep 17 00:00:00 2001
From: Folkert <folkert@folkertdev.nl>
Date: Fri, 19 Jul 2024 23:04:32 +0200
Subject: [PATCH 05/30] squashed changes to inlining and const eval

first steps of codegen for `#[naked]` functions using `global_asm!`

configure external linkage if no linkage is explicitly set

create a `FunctionCx` and properly evaluate consts

inline attribute is no longer relevant for naked functions

the naked attribute no longer needs to be set by llvm/...

we're generating global asm now, so this attribute is meaningless for the codegen backend
---
 .../rustc_codegen_ssa/src/codegen_attrs.rs    |  11 +-
 compiler/rustc_codegen_ssa/src/mir/mod.rs     |  27 +++
 .../rustc_codegen_ssa/src/mir/naked_asm.rs    | 212 ++++++++++++++++++
 tests/codegen/naked-fn/naked-noinline.rs      |  31 ---
 4 files changed, 248 insertions(+), 33 deletions(-)
 create mode 100644 compiler/rustc_codegen_ssa/src/mir/naked_asm.rs
 delete mode 100644 tests/codegen/naked-fn/naked-noinline.rs

diff --git a/compiler/rustc_codegen_ssa/src/codegen_attrs.rs b/compiler/rustc_codegen_ssa/src/codegen_attrs.rs
index a5acd8170ab81..0768b01cb15e5 100644
--- a/compiler/rustc_codegen_ssa/src/codegen_attrs.rs
+++ b/compiler/rustc_codegen_ssa/src/codegen_attrs.rs
@@ -113,7 +113,10 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
             sym::rustc_allocator_zeroed => {
                 codegen_fn_attrs.flags |= CodegenFnAttrFlags::ALLOCATOR_ZEROED
             }
-            sym::naked => codegen_fn_attrs.flags |= CodegenFnAttrFlags::NAKED,
+            sym::naked => {
+                // this attribute is ignored during codegen, because a function marked as naked is
+                // turned into a global asm block.
+            }
             sym::no_mangle => {
                 if tcx.opt_item_name(did.to_def_id()).is_some() {
                     codegen_fn_attrs.flags |= CodegenFnAttrFlags::NO_MANGLE
@@ -627,7 +630,11 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
     }
 
     if codegen_fn_attrs.flags.contains(CodegenFnAttrFlags::NAKED) {
-        codegen_fn_attrs.inline = InlineAttr::Never;
+        // naked functions are generated using an extern function and global assembly. To
+        // make sure that these can be linked together by LLVM, the linkage should be external,
+        // unless the user explicitly configured something else (in which case any linker errors
+        // they encounter are their responsibility).
+        codegen_fn_attrs.linkage = codegen_fn_attrs.linkage.or(Some(Linkage::External));
     }
 
     // Weak lang items have the same semantics as "std internal" symbols in the
diff --git a/compiler/rustc_codegen_ssa/src/mir/mod.rs b/compiler/rustc_codegen_ssa/src/mir/mod.rs
index 0cbc5c45736e8..b14e43acb6078 100644
--- a/compiler/rustc_codegen_ssa/src/mir/mod.rs
+++ b/compiler/rustc_codegen_ssa/src/mir/mod.rs
@@ -20,6 +20,7 @@ mod coverageinfo;
 pub mod debuginfo;
 mod intrinsic;
 mod locals;
+mod naked_asm;
 pub mod operand;
 pub mod place;
 mod rvalue;
@@ -176,6 +177,32 @@ pub fn codegen_mir<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
     let fn_abi = cx.fn_abi_of_instance(instance, ty::List::empty());
     debug!("fn_abi: {:?}", fn_abi);
 
+    if cx.tcx().has_attr(instance.def.def_id(), rustc_span::sym::naked) {
+        let cached_llbbs = IndexVec::new();
+
+        let fx: FunctionCx<'_, '_, Bx> = FunctionCx {
+            instance,
+            mir,
+            llfn,
+            fn_abi,
+            cx,
+            personality_slot: None,
+            cached_llbbs,
+            unreachable_block: None,
+            terminate_block: None,
+            cleanup_kinds: None,
+            landing_pads: IndexVec::from_elem(None, &mir.basic_blocks),
+            funclets: IndexVec::from_fn_n(|_| None, mir.basic_blocks.len()),
+            locals: locals::Locals::empty(),
+            debug_context: None,
+            per_local_var_debug_info: None,
+            caller_location: None,
+        };
+
+        fx.codegen_naked_asm(instance);
+        return;
+    }
+
     let debug_context = cx.create_function_debug_context(instance, fn_abi, llfn, mir);
 
     let start_llbb = Bx::append_block(cx, llfn, "start");
diff --git a/compiler/rustc_codegen_ssa/src/mir/naked_asm.rs b/compiler/rustc_codegen_ssa/src/mir/naked_asm.rs
new file mode 100644
index 0000000000000..1f41a9aefeb73
--- /dev/null
+++ b/compiler/rustc_codegen_ssa/src/mir/naked_asm.rs
@@ -0,0 +1,212 @@
+use crate::common;
+use crate::mir::FunctionCx;
+use crate::traits::{AsmMethods, BuilderMethods, GlobalAsmOperandRef};
+use rustc_middle::bug;
+use rustc_middle::mir::InlineAsmOperand;
+use rustc_middle::ty;
+use rustc_middle::ty::layout::{HasTyCtxt, LayoutOf};
+use rustc_middle::ty::{Instance, TyCtxt};
+
+use rustc_span::sym;
+use rustc_target::asm::InlineAsmArch;
+
+impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
+    pub fn codegen_naked_asm(&self, instance: Instance<'tcx>) {
+        let cx = &self.cx;
+
+        let rustc_middle::mir::TerminatorKind::InlineAsm {
+            asm_macro: _,
+            template,
+            ref operands,
+            options,
+            line_spans,
+            targets: _,
+            unwind: _,
+        } = self.mir.basic_blocks.iter().next().unwrap().terminator().kind
+        else {
+            bug!("#[naked] functions should always terminate with an asm! block")
+        };
+
+        let operands: Vec<_> =
+            operands.iter().map(|op| self.inline_to_global_operand(op)).collect();
+
+        let (begin, end) = crate::mir::naked_asm::prefix_and_suffix(cx.tcx(), instance);
+
+        let mut template_vec = Vec::new();
+        template_vec.push(rustc_ast::ast::InlineAsmTemplatePiece::String(begin));
+        template_vec.extend(template.iter().cloned());
+        template_vec.push(rustc_ast::ast::InlineAsmTemplatePiece::String(end));
+
+        cx.codegen_global_asm(&template_vec, &operands, options, line_spans);
+    }
+
+    fn inline_to_global_operand(&self, op: &InlineAsmOperand<'tcx>) -> GlobalAsmOperandRef<'tcx> {
+        match op {
+            InlineAsmOperand::Const { value } => {
+                let const_value = self.eval_mir_constant(value);
+                let string = common::asm_const_to_str(
+                    self.cx.tcx(),
+                    value.span,
+                    const_value,
+                    self.cx.layout_of(value.ty()),
+                );
+                GlobalAsmOperandRef::Const { string }
+            }
+            InlineAsmOperand::SymFn { value } => {
+                let instance = match value.ty().kind() {
+                    &ty::FnDef(def_id, args) => Instance::new(def_id, args),
+                    _ => bug!("asm sym is not a function"),
+                };
+
+                GlobalAsmOperandRef::SymFn { instance }
+            }
+            InlineAsmOperand::SymStatic { def_id } => {
+                GlobalAsmOperandRef::SymStatic { def_id: *def_id }
+            }
+            InlineAsmOperand::In { .. }
+            | InlineAsmOperand::Out { .. }
+            | InlineAsmOperand::InOut { .. }
+            | InlineAsmOperand::Label { .. } => {
+                bug!("invalid operand type for naked_asm!")
+            }
+        }
+    }
+}
+
+enum AsmBinaryFormat {
+    Elf,
+    Macho,
+    Coff,
+}
+
+impl AsmBinaryFormat {
+    fn from_target(target: &rustc_target::spec::Target) -> Self {
+        if target.is_like_windows {
+            Self::Coff
+        } else if target.options.vendor == "apple" {
+            Self::Macho
+        } else {
+            Self::Elf
+        }
+    }
+}
+
+fn prefix_and_suffix<'tcx>(tcx: TyCtxt<'tcx>, instance: Instance<'tcx>) -> (String, String) {
+    use std::fmt::Write;
+
+    let target = &tcx.sess.target;
+    let target_arch = tcx.sess.asm_arch;
+
+    let is_arm = target.arch == "arm";
+    let is_thumb = is_arm && target.llvm_target.contains("thumb");
+
+    let mangle = (target.is_like_windows && matches!(target_arch, Some(InlineAsmArch::X86)))
+        || target.options.vendor == "apple";
+
+    let asm_name = format!("{}{}", if mangle { "_" } else { "" }, tcx.symbol_name(instance).name);
+
+    let opt_section = tcx
+        .get_attr(instance.def.def_id(), sym::link_section)
+        .and_then(|attr| attr.value_str())
+        .map(|attr| attr.as_str().to_string());
+
+    let instruction_set =
+        tcx.get_attr(instance.def.def_id(), sym::instruction_set).and_then(|attr| attr.value_str());
+
+    let (arch_prefix, arch_suffix) = if is_arm {
+        (
+            match instruction_set {
+                None => match is_thumb {
+                    true => ".thumb\n.thumb_func",
+                    false => ".arm",
+                },
+                Some(sym::a32) => ".arm",
+                Some(sym::t32) => ".thumb\n.thumb_func",
+                Some(other) => bug!("invalid instruction set: {other}"),
+            },
+            match is_thumb {
+                true => ".thumb",
+                false => ".arm",
+            },
+        )
+    } else {
+        ("", "")
+    };
+
+    let mut begin = String::new();
+    let mut end = String::new();
+    match AsmBinaryFormat::from_target(&tcx.sess.target) {
+        AsmBinaryFormat::Elf => {
+            let section = opt_section.unwrap_or(format!(".text.{asm_name}"));
+
+            let progbits = match is_arm {
+                true => "%progbits",
+                false => "@progbits",
+            };
+
+            let function = match is_arm {
+                true => "%function",
+                false => "@function",
+            };
+
+            writeln!(begin, ".pushsection {section},\"ax\", {progbits}").unwrap();
+            writeln!(begin, ".balign 4").unwrap();
+            writeln!(begin, ".globl {asm_name}").unwrap();
+            writeln!(begin, ".hidden {asm_name}").unwrap();
+            writeln!(begin, ".type {asm_name}, {function}").unwrap();
+            if let Some(instruction_set) = instruction_set {
+                writeln!(begin, "{}", instruction_set.as_str()).unwrap();
+            }
+            if !arch_prefix.is_empty() {
+                writeln!(begin, "{}", arch_prefix).unwrap();
+            }
+            writeln!(begin, "{asm_name}:").unwrap();
+
+            writeln!(end).unwrap();
+            writeln!(end, ".size {asm_name}, . - {asm_name}").unwrap();
+            writeln!(end, ".popsection").unwrap();
+            if !arch_suffix.is_empty() {
+                writeln!(end, "{}", arch_suffix).unwrap();
+            }
+        }
+        AsmBinaryFormat::Macho => {
+            let section = opt_section.unwrap_or("__TEXT,__text".to_string());
+            writeln!(begin, ".pushsection {},regular,pure_instructions", section).unwrap();
+            writeln!(begin, ".balign 4").unwrap();
+            writeln!(begin, ".globl {asm_name}").unwrap();
+            writeln!(begin, ".private_extern {asm_name}").unwrap();
+            if let Some(instruction_set) = instruction_set {
+                writeln!(begin, "{}", instruction_set.as_str()).unwrap();
+            }
+            writeln!(begin, "{asm_name}:").unwrap();
+
+            writeln!(end).unwrap();
+            writeln!(end, ".popsection").unwrap();
+            if !arch_suffix.is_empty() {
+                writeln!(end, "{}", arch_suffix).unwrap();
+            }
+        }
+        AsmBinaryFormat::Coff => {
+            let section = opt_section.unwrap_or(format!(".text.{asm_name}"));
+            writeln!(begin, ".pushsection {},\"xr\"", section).unwrap();
+            writeln!(begin, ".balign 4").unwrap();
+            writeln!(begin, ".globl {asm_name}").unwrap();
+            writeln!(begin, ".def {asm_name}").unwrap();
+            writeln!(begin, ".scl 2").unwrap();
+            writeln!(begin, ".type 32").unwrap();
+            writeln!(begin, ".endef {asm_name}").unwrap();
+            if let Some(instruction_set) = instruction_set {
+                writeln!(begin, "{}", instruction_set.as_str()).unwrap();
+            }
+            writeln!(begin, "{asm_name}:").unwrap();
+
+            writeln!(end).unwrap();
+            writeln!(end, ".popsection").unwrap();
+            if !arch_suffix.is_empty() {
+                writeln!(end, "{}", arch_suffix).unwrap();
+            }
+        }
+    }
+
+    (begin, end)
+}
diff --git a/tests/codegen/naked-fn/naked-noinline.rs b/tests/codegen/naked-fn/naked-noinline.rs
deleted file mode 100644
index 6ea36d9678315..0000000000000
--- a/tests/codegen/naked-fn/naked-noinline.rs
+++ /dev/null
@@ -1,31 +0,0 @@
-// Checks that naked functions are never inlined.
-//@ compile-flags: -O -Zmir-opt-level=3
-//@ needs-asm-support
-//@ ignore-wasm32
-#![crate_type = "lib"]
-#![feature(naked_functions)]
-
-use std::arch::naked_asm;
-
-#[naked]
-#[no_mangle]
-pub unsafe extern "C" fn f() {
-    // Check that f has naked and noinline attributes.
-    //
-    // CHECK:       define {{(dso_local )?}}void @f() unnamed_addr [[ATTR:#[0-9]+]]
-    // CHECK-NEXT:  start:
-    // CHECK-NEXT:    call void asm
-    naked_asm!("");
-}
-
-#[no_mangle]
-pub unsafe fn g() {
-    // Check that call to f is not inlined.
-    //
-    // CHECK-LABEL: define {{(dso_local )?}}void @g()
-    // CHECK-NEXT:  start:
-    // CHECK-NEXT:    call void @f()
-    f();
-}
-
-// CHECK: attributes [[ATTR]] = { naked{{.*}}noinline{{.*}} }

From d67a5c0b25e8fd02f2397d06c5857f96314e6e90 Mon Sep 17 00:00:00 2001
From: Folkert <folkert@folkertdev.nl>
Date: Sat, 20 Jul 2024 01:16:49 +0200
Subject: [PATCH 06/30] test the new global asm output of naked functions

---
 tests/codegen/naked-fn/naked-functions.rs | 28 +++++++++++++++++++----
 1 file changed, 24 insertions(+), 4 deletions(-)

diff --git a/tests/codegen/naked-fn/naked-functions.rs b/tests/codegen/naked-fn/naked-functions.rs
index 3f7447af599ab..00d64089ad8bc 100644
--- a/tests/codegen/naked-fn/naked-functions.rs
+++ b/tests/codegen/naked-fn/naked-functions.rs
@@ -6,8 +6,17 @@
 #![feature(naked_functions)]
 use std::arch::naked_asm;
 
-// CHECK: Function Attrs: naked
-// CHECK-NEXT: define{{.*}}void @naked_empty()
+// CHECK: module asm ".intel_syntax"
+// CHECK: .pushsection .text.naked_empty,\22ax\22, @progbits
+// CHECK: .balign 4"
+// CHECK: .globl naked_empty"
+// CHECK: .hidden naked_empty"
+// CHECK: .type naked_empty, @function"
+// CHECK-LABEL: naked_empty:
+// CHECK: ret
+// CHECK: .popsection
+// CHECK: .att_syntax
+
 #[no_mangle]
 #[naked]
 pub unsafe extern "C" fn naked_empty() {
@@ -17,8 +26,19 @@ pub unsafe extern "C" fn naked_empty() {
     naked_asm!("ret");
 }
 
-// CHECK: Function Attrs: naked
-// CHECK-NEXT: define{{.*}}i{{[0-9]+}} @naked_with_args_and_return(i64 %0, i64 %1)
+// CHECK: .intel_syntax
+// CHECK: .pushsection .text.naked_with_args_and_return,\22ax\22, @progbits
+// CHECK: .balign 4
+// CHECK: .globl naked_with_args_and_return
+// CHECK: .hidden naked_with_args_and_return
+// CHECK: .type naked_with_args_and_return, @function
+// CHECK-LABEL: naked_with_args_and_return:
+// CHECK: lea rax, [rdi + rsi]
+// CHECK: ret
+// CHECK: .size naked_with_args_and_return, . - naked_with_args_and_return
+// CHECK: .popsection
+// CHECK: .att_syntax
+
 #[no_mangle]
 #[naked]
 pub unsafe extern "C" fn naked_with_args_and_return(a: isize, b: isize) -> isize {

From a93192ca85072a41a4f970275d118bde0b3117d5 Mon Sep 17 00:00:00 2001
From: Folkert <folkert@folkertdev.nl>
Date: Sat, 20 Jul 2024 13:17:31 +0200
Subject: [PATCH 07/30] add `InstructionSetAttr::as_str` and make the type
 `Copy`

---
 compiler/rustc_attr/src/builtin.rs | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/compiler/rustc_attr/src/builtin.rs b/compiler/rustc_attr/src/builtin.rs
index 94f9727eb7fbe..c8928097eafda 100644
--- a/compiler/rustc_attr/src/builtin.rs
+++ b/compiler/rustc_attr/src/builtin.rs
@@ -49,12 +49,21 @@ pub enum InlineAttr {
     Never,
 }
 
-#[derive(Clone, Encodable, Decodable, Debug, PartialEq, Eq, HashStable_Generic)]
+#[derive(Copy, Clone, Encodable, Decodable, Debug, PartialEq, Eq, HashStable_Generic)]
 pub enum InstructionSetAttr {
     ArmA32,
     ArmT32,
 }
 
+impl InstructionSetAttr {
+    pub fn as_str(self) -> &'static str {
+        match self {
+            Self::ArmA32 => sym::a32.as_str(),
+            Self::ArmT32 => sym::t32.as_str(),
+        }
+    }
+}
+
 #[derive(Clone, Encodable, Decodable, Debug, HashStable_Generic)]
 pub enum OptimizeAttr {
     None,

From 49a297ab211affaf782cc7603bc413cb8e1ab715 Mon Sep 17 00:00:00 2001
From: Folkert <folkert@folkertdev.nl>
Date: Sat, 20 Jul 2024 13:23:34 +0200
Subject: [PATCH 08/30] squashed changes to tests

correctly emit `.hidden`

this test was added in https://github.com/rust-lang/rust/pull/105193

but actually NO_COVERAGE is no longer a thing in the compiler. Sadly,
the link to the issue is broken, so I don't know what the problem was
originally, but I don't think this is relevant any more with the global
asm approach

rename test file

because it now specifically checks for directives only used by
non-macos, non-windows x86_64

add codegen tests for 4 interesting platforms

add codegen test for the `#[instruction_set]` attribute

add test for `#[link_section]`

use `tcx.codegen_fn_attrs` to get attribute info

Fix #124375

inline const monomorphization/evaluation

getting rid of FunctionCx

mark naked functions as `InstantiatedMode::GloballyShared`

this makes sure that the function prototype is defined correctly, and we don't see LLVM complaining about a global value with invalid linkage

monomorphize type given to `SymFn`

remove hack that always emits `.globl`

monomorphize type given to `Const`

remove `linkage_directive`

make naked functions always have external linkage

mark naked functions as `#[inline(never)]`

add test file for functional generics/const/impl/trait usage of naked functions
---
 compiler/rustc_codegen_llvm/src/attributes.rs |  14 +-
 compiler/rustc_codegen_llvm/src/mono_item.rs  |  10 +-
 .../rustc_codegen_ssa/src/codegen_attrs.rs    |  20 +-
 compiler/rustc_codegen_ssa/src/mir/mod.rs     |  25 +--
 .../rustc_codegen_ssa/src/mir/naked_asm.rs    | 200 ++++++++++--------
 compiler/rustc_codegen_ssa/src/mono_item.rs   |  12 +-
 compiler/rustc_middle/src/mir/mono.rs         |   8 +-
 tests/codegen/naked-fn/generics.rs            | 117 ++++++++++
 tests/codegen/naked-fn/instruction-set.rs     |  43 ++++
 tests/codegen/naked-fn/naked-functions.rs     | 158 +++++++++++---
 tests/codegen/naked-fn/naked-nocoverage.rs    |  19 --
 tests/crashes/124375.rs                       |  11 -
 .../ui/asm/naked-functions-instruction-set.rs |   2 +-
 tests/ui/asm/naked-functions.rs               |   6 +
 14 files changed, 443 insertions(+), 202 deletions(-)
 create mode 100644 tests/codegen/naked-fn/generics.rs
 create mode 100644 tests/codegen/naked-fn/instruction-set.rs
 delete mode 100644 tests/codegen/naked-fn/naked-nocoverage.rs
 delete mode 100644 tests/crashes/124375.rs

diff --git a/compiler/rustc_codegen_llvm/src/attributes.rs b/compiler/rustc_codegen_llvm/src/attributes.rs
index cb958c1d4d771..5552a2410601d 100644
--- a/compiler/rustc_codegen_llvm/src/attributes.rs
+++ b/compiler/rustc_codegen_llvm/src/attributes.rs
@@ -395,17 +395,9 @@ pub(crate) fn llfn_attrs_from_instance<'ll, 'tcx>(
         to_add.push(MemoryEffects::None.create_attr(cx.llcx));
     }
     if codegen_fn_attrs.flags.contains(CodegenFnAttrFlags::NAKED) {
-        to_add.push(AttributeKind::Naked.create_attr(cx.llcx));
-        // HACK(jubilee): "indirect branch tracking" works by attaching prologues to functions.
-        // And it is a module-level attribute, so the alternative is pulling naked functions into
-        // new LLVM modules. Otherwise LLVM's "naked" functions come with endbr prefixes per
-        // https://github.com/rust-lang/rust/issues/98768
-        to_add.push(AttributeKind::NoCfCheck.create_attr(cx.llcx));
-        if llvm_util::get_version() < (19, 0, 0) {
-            // Prior to LLVM 19, branch-target-enforcement was disabled by setting the attribute to
-            // the string "false". Now it is disabled by absence of the attribute.
-            to_add.push(llvm::CreateAttrStringValue(cx.llcx, "branch-target-enforcement", "false"));
-        }
+        // do nothing; a naked function is converted into an extern function
+        // and a global assembly block. LLVM's support for naked functions is
+        // not used.
     } else {
         // Do not set sanitizer attributes for naked functions.
         to_add.extend(sanitize_attrs(cx, codegen_fn_attrs.no_sanitize));
diff --git a/compiler/rustc_codegen_llvm/src/mono_item.rs b/compiler/rustc_codegen_llvm/src/mono_item.rs
index 33789c6261f10..4d1704f2c998f 100644
--- a/compiler/rustc_codegen_llvm/src/mono_item.rs
+++ b/compiler/rustc_codegen_llvm/src/mono_item.rs
@@ -2,6 +2,7 @@ use rustc_codegen_ssa::traits::*;
 use rustc_hir::def::DefKind;
 use rustc_hir::def_id::{DefId, LOCAL_CRATE};
 use rustc_middle::bug;
+use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags;
 use rustc_middle::mir::mono::{Linkage, Visibility};
 use rustc_middle::ty::layout::{FnAbiOf, HasTypingEnv, LayoutOf};
 use rustc_middle::ty::{self, Instance, TypeVisitableExt};
@@ -58,8 +59,15 @@ impl<'tcx> PreDefineCodegenMethods<'tcx> for CodegenCx<'_, 'tcx> {
 
         let fn_abi = self.fn_abi_of_instance(instance, ty::List::empty());
         let lldecl = self.declare_fn(symbol_name, fn_abi, Some(instance));
-        llvm::set_linkage(lldecl, base::linkage_to_llvm(linkage));
         let attrs = self.tcx.codegen_fn_attrs(instance.def_id());
+        let llvm_linkage =
+            if attrs.flags.contains(CodegenFnAttrFlags::NAKED) && linkage == Linkage::Internal {
+                // this is effectively an extern fn, and must have external linkage
+                llvm::Linkage::ExternalLinkage
+            } else {
+                base::linkage_to_llvm(linkage)
+            };
+        llvm::set_linkage(lldecl, llvm_linkage);
         base::set_link_section(lldecl, attrs);
         if (linkage == Linkage::LinkOnceODR || linkage == Linkage::WeakODR)
             && self.tcx.sess.target.supports_comdat()
diff --git a/compiler/rustc_codegen_ssa/src/codegen_attrs.rs b/compiler/rustc_codegen_ssa/src/codegen_attrs.rs
index 0768b01cb15e5..01dd75c5ee85e 100644
--- a/compiler/rustc_codegen_ssa/src/codegen_attrs.rs
+++ b/compiler/rustc_codegen_ssa/src/codegen_attrs.rs
@@ -113,10 +113,7 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
             sym::rustc_allocator_zeroed => {
                 codegen_fn_attrs.flags |= CodegenFnAttrFlags::ALLOCATOR_ZEROED
             }
-            sym::naked => {
-                // this attribute is ignored during codegen, because a function marked as naked is
-                // turned into a global asm block.
-            }
+            sym::naked => codegen_fn_attrs.flags |= CodegenFnAttrFlags::NAKED,
             sym::no_mangle => {
                 if tcx.opt_item_name(did.to_def_id()).is_some() {
                     codegen_fn_attrs.flags |= CodegenFnAttrFlags::NO_MANGLE
@@ -545,6 +542,13 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
         }
     });
 
+    // naked function MUST NOT be inlined! This attribute is required for the rust compiler itself,
+    // but not for the code generation backend because at that point the naked function will just be
+    // a declaration, with a definition provided in global assembly.
+    if codegen_fn_attrs.flags.contains(CodegenFnAttrFlags::NAKED) {
+        codegen_fn_attrs.inline = InlineAttr::Never;
+    }
+
     codegen_fn_attrs.optimize = attrs.iter().fold(OptimizeAttr::None, |ia, attr| {
         if !attr.has_name(sym::optimize) {
             return ia;
@@ -629,14 +633,6 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
         }
     }
 
-    if codegen_fn_attrs.flags.contains(CodegenFnAttrFlags::NAKED) {
-        // naked functions are generated using an extern function and global assembly. To
-        // make sure that these can be linked together by LLVM, the linkage should be external,
-        // unless the user explicitly configured something else (in which case any linker errors
-        // they encounter are their responsibility).
-        codegen_fn_attrs.linkage = codegen_fn_attrs.linkage.or(Some(Linkage::External));
-    }
-
     // Weak lang items have the same semantics as "std internal" symbols in the
     // sense that they're preserved through all our LTO passes and only
     // strippable by the linker.
diff --git a/compiler/rustc_codegen_ssa/src/mir/mod.rs b/compiler/rustc_codegen_ssa/src/mir/mod.rs
index b14e43acb6078..62f69af3f2f75 100644
--- a/compiler/rustc_codegen_ssa/src/mir/mod.rs
+++ b/compiler/rustc_codegen_ssa/src/mir/mod.rs
@@ -177,29 +177,8 @@ pub fn codegen_mir<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
     let fn_abi = cx.fn_abi_of_instance(instance, ty::List::empty());
     debug!("fn_abi: {:?}", fn_abi);
 
-    if cx.tcx().has_attr(instance.def.def_id(), rustc_span::sym::naked) {
-        let cached_llbbs = IndexVec::new();
-
-        let fx: FunctionCx<'_, '_, Bx> = FunctionCx {
-            instance,
-            mir,
-            llfn,
-            fn_abi,
-            cx,
-            personality_slot: None,
-            cached_llbbs,
-            unreachable_block: None,
-            terminate_block: None,
-            cleanup_kinds: None,
-            landing_pads: IndexVec::from_elem(None, &mir.basic_blocks),
-            funclets: IndexVec::from_fn_n(|_| None, mir.basic_blocks.len()),
-            locals: locals::Locals::empty(),
-            debug_context: None,
-            per_local_var_debug_info: None,
-            caller_location: None,
-        };
-
-        fx.codegen_naked_asm(instance);
+    if cx.tcx().codegen_fn_attrs(instance.def_id()).flags.contains(CodegenFnAttrFlags::NAKED) {
+        crate::mir::naked_asm::codegen_naked_asm::<Bx>(cx, &mir, instance);
         return;
     }
 
diff --git a/compiler/rustc_codegen_ssa/src/mir/naked_asm.rs b/compiler/rustc_codegen_ssa/src/mir/naked_asm.rs
index 1f41a9aefeb73..b4eb6110da8ca 100644
--- a/compiler/rustc_codegen_ssa/src/mir/naked_asm.rs
+++ b/compiler/rustc_codegen_ssa/src/mir/naked_asm.rs
@@ -1,74 +1,99 @@
-use crate::common;
-use crate::mir::FunctionCx;
-use crate::traits::{AsmMethods, BuilderMethods, GlobalAsmOperandRef};
-use rustc_middle::bug;
-use rustc_middle::mir::InlineAsmOperand;
-use rustc_middle::ty;
-use rustc_middle::ty::layout::{HasTyCtxt, LayoutOf};
+use rustc_attr::InstructionSetAttr;
+use rustc_middle::mir::mono::{MonoItem, MonoItemData, Visibility};
+use rustc_middle::mir::{Body, InlineAsmOperand};
+use rustc_middle::ty::layout::{HasTyCtxt, HasTypingEnv, LayoutOf};
 use rustc_middle::ty::{Instance, TyCtxt};
-
-use rustc_span::sym;
+use rustc_middle::{bug, ty};
 use rustc_target::asm::InlineAsmArch;
 
-impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
-    pub fn codegen_naked_asm(&self, instance: Instance<'tcx>) {
-        let cx = &self.cx;
-
-        let rustc_middle::mir::TerminatorKind::InlineAsm {
-            asm_macro: _,
-            template,
-            ref operands,
-            options,
-            line_spans,
-            targets: _,
-            unwind: _,
-        } = self.mir.basic_blocks.iter().next().unwrap().terminator().kind
-        else {
-            bug!("#[naked] functions should always terminate with an asm! block")
-        };
-
-        let operands: Vec<_> =
-            operands.iter().map(|op| self.inline_to_global_operand(op)).collect();
-
-        let (begin, end) = crate::mir::naked_asm::prefix_and_suffix(cx.tcx(), instance);
-
-        let mut template_vec = Vec::new();
-        template_vec.push(rustc_ast::ast::InlineAsmTemplatePiece::String(begin));
-        template_vec.extend(template.iter().cloned());
-        template_vec.push(rustc_ast::ast::InlineAsmTemplatePiece::String(end));
-
-        cx.codegen_global_asm(&template_vec, &operands, options, line_spans);
-    }
+use crate::common;
+use crate::traits::{AsmCodegenMethods, BuilderMethods, GlobalAsmOperandRef, MiscCodegenMethods};
+
+pub(crate) fn codegen_naked_asm<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
+    cx: &'a Bx::CodegenCx,
+    mir: &Body<'tcx>,
+    instance: Instance<'tcx>,
+) {
+    let rustc_middle::mir::TerminatorKind::InlineAsm {
+        asm_macro: _,
+        template,
+        ref operands,
+        options,
+        line_spans,
+        targets: _,
+        unwind: _,
+    } = mir.basic_blocks.iter().next().unwrap().terminator().kind
+    else {
+        bug!("#[naked] functions should always terminate with an asm! block")
+    };
 
-    fn inline_to_global_operand(&self, op: &InlineAsmOperand<'tcx>) -> GlobalAsmOperandRef<'tcx> {
-        match op {
-            InlineAsmOperand::Const { value } => {
-                let const_value = self.eval_mir_constant(value);
-                let string = common::asm_const_to_str(
-                    self.cx.tcx(),
-                    value.span,
-                    const_value,
-                    self.cx.layout_of(value.ty()),
-                );
-                GlobalAsmOperandRef::Const { string }
-            }
-            InlineAsmOperand::SymFn { value } => {
-                let instance = match value.ty().kind() {
-                    &ty::FnDef(def_id, args) => Instance::new(def_id, args),
-                    _ => bug!("asm sym is not a function"),
-                };
+    let operands: Vec<_> =
+        operands.iter().map(|op| inline_to_global_operand::<Bx>(cx, instance, op)).collect();
 
-                GlobalAsmOperandRef::SymFn { instance }
-            }
-            InlineAsmOperand::SymStatic { def_id } => {
-                GlobalAsmOperandRef::SymStatic { def_id: *def_id }
-            }
-            InlineAsmOperand::In { .. }
-            | InlineAsmOperand::Out { .. }
-            | InlineAsmOperand::InOut { .. }
-            | InlineAsmOperand::Label { .. } => {
-                bug!("invalid operand type for naked_asm!")
-            }
+    let item_data = cx.codegen_unit().items().get(&MonoItem::Fn(instance)).unwrap();
+    let (begin, end) = crate::mir::naked_asm::prefix_and_suffix(cx.tcx(), instance, item_data);
+
+    let mut template_vec = Vec::new();
+    template_vec.push(rustc_ast::ast::InlineAsmTemplatePiece::String(begin.into()));
+    template_vec.extend(template.iter().cloned());
+    template_vec.push(rustc_ast::ast::InlineAsmTemplatePiece::String(end.into()));
+
+    cx.codegen_global_asm(&template_vec, &operands, options, line_spans);
+}
+
+fn inline_to_global_operand<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
+    cx: &'a Bx::CodegenCx,
+    instance: Instance<'tcx>,
+    op: &InlineAsmOperand<'tcx>,
+) -> GlobalAsmOperandRef<'tcx> {
+    match op {
+        InlineAsmOperand::Const { value } => {
+            let const_value = instance
+                .instantiate_mir_and_normalize_erasing_regions(
+                    cx.tcx(),
+                    cx.typing_env(),
+                    ty::EarlyBinder::bind(value.const_),
+                )
+                .eval(cx.tcx(), cx.typing_env(), value.span)
+                .expect("erroneous constant missed by mono item collection");
+
+            let mono_type = instance.instantiate_mir_and_normalize_erasing_regions(
+                cx.tcx(),
+                cx.typing_env(),
+                ty::EarlyBinder::bind(value.ty()),
+            );
+
+            let string = common::asm_const_to_str(
+                cx.tcx(),
+                value.span,
+                const_value,
+                cx.layout_of(mono_type),
+            );
+
+            GlobalAsmOperandRef::Const { string }
+        }
+        InlineAsmOperand::SymFn { value } => {
+            let mono_type = instance.instantiate_mir_and_normalize_erasing_regions(
+                cx.tcx(),
+                cx.typing_env(),
+                ty::EarlyBinder::bind(value.ty()),
+            );
+
+            let instance = match mono_type.kind() {
+                &ty::FnDef(def_id, args) => Instance::new(def_id, args),
+                _ => bug!("asm sym is not a function"),
+            };
+
+            GlobalAsmOperandRef::SymFn { instance }
+        }
+        InlineAsmOperand::SymStatic { def_id } => {
+            GlobalAsmOperandRef::SymStatic { def_id: *def_id }
+        }
+        InlineAsmOperand::In { .. }
+        | InlineAsmOperand::Out { .. }
+        | InlineAsmOperand::InOut { .. }
+        | InlineAsmOperand::Label { .. } => {
+            bug!("invalid operand type for naked_asm!")
         }
     }
 }
@@ -91,7 +116,11 @@ impl AsmBinaryFormat {
     }
 }
 
-fn prefix_and_suffix<'tcx>(tcx: TyCtxt<'tcx>, instance: Instance<'tcx>) -> (String, String) {
+fn prefix_and_suffix<'tcx>(
+    tcx: TyCtxt<'tcx>,
+    instance: Instance<'tcx>,
+    item_data: &MonoItemData,
+) -> (String, String) {
     use std::fmt::Write;
 
     let target = &tcx.sess.target;
@@ -105,24 +134,18 @@ fn prefix_and_suffix<'tcx>(tcx: TyCtxt<'tcx>, instance: Instance<'tcx>) -> (Stri
 
     let asm_name = format!("{}{}", if mangle { "_" } else { "" }, tcx.symbol_name(instance).name);
 
-    let opt_section = tcx
-        .get_attr(instance.def.def_id(), sym::link_section)
-        .and_then(|attr| attr.value_str())
-        .map(|attr| attr.as_str().to_string());
-
-    let instruction_set =
-        tcx.get_attr(instance.def.def_id(), sym::instruction_set).and_then(|attr| attr.value_str());
+    let attrs = tcx.codegen_fn_attrs(instance.def_id());
+    let link_section = attrs.link_section.map(|symbol| symbol.as_str().to_string());
 
     let (arch_prefix, arch_suffix) = if is_arm {
         (
-            match instruction_set {
+            match attrs.instruction_set {
                 None => match is_thumb {
                     true => ".thumb\n.thumb_func",
                     false => ".arm",
                 },
-                Some(sym::a32) => ".arm",
-                Some(sym::t32) => ".thumb\n.thumb_func",
-                Some(other) => bug!("invalid instruction set: {other}"),
+                Some(InstructionSetAttr::ArmA32) => ".arm",
+                Some(InstructionSetAttr::ArmT32) => ".thumb\n.thumb_func",
             },
             match is_thumb {
                 true => ".thumb",
@@ -137,7 +160,7 @@ fn prefix_and_suffix<'tcx>(tcx: TyCtxt<'tcx>, instance: Instance<'tcx>) -> (Stri
     let mut end = String::new();
     match AsmBinaryFormat::from_target(&tcx.sess.target) {
         AsmBinaryFormat::Elf => {
-            let section = opt_section.unwrap_or(format!(".text.{asm_name}"));
+            let section = link_section.unwrap_or(format!(".text.{asm_name}"));
 
             let progbits = match is_arm {
                 true => "%progbits",
@@ -152,11 +175,10 @@ fn prefix_and_suffix<'tcx>(tcx: TyCtxt<'tcx>, instance: Instance<'tcx>) -> (Stri
             writeln!(begin, ".pushsection {section},\"ax\", {progbits}").unwrap();
             writeln!(begin, ".balign 4").unwrap();
             writeln!(begin, ".globl {asm_name}").unwrap();
-            writeln!(begin, ".hidden {asm_name}").unwrap();
-            writeln!(begin, ".type {asm_name}, {function}").unwrap();
-            if let Some(instruction_set) = instruction_set {
-                writeln!(begin, "{}", instruction_set.as_str()).unwrap();
+            if let Visibility::Hidden = item_data.visibility {
+                writeln!(begin, ".hidden {asm_name}").unwrap();
             }
+            writeln!(begin, ".type {asm_name}, {function}").unwrap();
             if !arch_prefix.is_empty() {
                 writeln!(begin, "{}", arch_prefix).unwrap();
             }
@@ -170,13 +192,12 @@ fn prefix_and_suffix<'tcx>(tcx: TyCtxt<'tcx>, instance: Instance<'tcx>) -> (Stri
             }
         }
         AsmBinaryFormat::Macho => {
-            let section = opt_section.unwrap_or("__TEXT,__text".to_string());
+            let section = link_section.unwrap_or("__TEXT,__text".to_string());
             writeln!(begin, ".pushsection {},regular,pure_instructions", section).unwrap();
             writeln!(begin, ".balign 4").unwrap();
             writeln!(begin, ".globl {asm_name}").unwrap();
-            writeln!(begin, ".private_extern {asm_name}").unwrap();
-            if let Some(instruction_set) = instruction_set {
-                writeln!(begin, "{}", instruction_set.as_str()).unwrap();
+            if let Visibility::Hidden = item_data.visibility {
+                writeln!(begin, ".private_extern {asm_name}").unwrap();
             }
             writeln!(begin, "{asm_name}:").unwrap();
 
@@ -187,7 +208,7 @@ fn prefix_and_suffix<'tcx>(tcx: TyCtxt<'tcx>, instance: Instance<'tcx>) -> (Stri
             }
         }
         AsmBinaryFormat::Coff => {
-            let section = opt_section.unwrap_or(format!(".text.{asm_name}"));
+            let section = link_section.unwrap_or(format!(".text.{asm_name}"));
             writeln!(begin, ".pushsection {},\"xr\"", section).unwrap();
             writeln!(begin, ".balign 4").unwrap();
             writeln!(begin, ".globl {asm_name}").unwrap();
@@ -195,9 +216,6 @@ fn prefix_and_suffix<'tcx>(tcx: TyCtxt<'tcx>, instance: Instance<'tcx>) -> (Stri
             writeln!(begin, ".scl 2").unwrap();
             writeln!(begin, ".type 32").unwrap();
             writeln!(begin, ".endef {asm_name}").unwrap();
-            if let Some(instruction_set) = instruction_set {
-                writeln!(begin, "{}", instruction_set.as_str()).unwrap();
-            }
             writeln!(begin, "{asm_name}:").unwrap();
 
             writeln!(end).unwrap();
diff --git a/compiler/rustc_codegen_ssa/src/mono_item.rs b/compiler/rustc_codegen_ssa/src/mono_item.rs
index 04159422e3cb2..085ef1cd8ea36 100644
--- a/compiler/rustc_codegen_ssa/src/mono_item.rs
+++ b/compiler/rustc_codegen_ssa/src/mono_item.rs
@@ -1,8 +1,9 @@
 use rustc_hir as hir;
+use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags;
 use rustc_middle::mir::interpret::ErrorHandled;
 use rustc_middle::mir::mono::{LinkageInfo, MonoItem, Visibility};
-use rustc_middle::ty::layout::{HasTyCtxt, LayoutOf};
 use rustc_middle::ty::Instance;
+use rustc_middle::ty::layout::{HasTyCtxt, LayoutOf};
 use rustc_middle::{span_bug, ty};
 use tracing::debug;
 
@@ -135,7 +136,14 @@ impl<'a, 'tcx: 'a> MonoItemExt<'a, 'tcx> for MonoItem<'tcx> {
                 cx.predefine_static(def_id, linkage_info.into_linkage(), visibility, symbol_name);
             }
             MonoItem::Fn(instance) => {
-                cx.predefine_fn(instance, linkage_info.into_linkage(), visibility, symbol_name);
+                let attrs = cx.tcx().codegen_fn_attrs(instance.def_id());
+                let linkage = if attrs.flags.contains(CodegenFnAttrFlags::NAKED) {
+                    linkage_info.into_naked_linkage()
+                } else {
+                    linkage_info.into_linkage()
+                };
+
+                cx.predefine_fn(instance, linkage, visibility, symbol_name);
             }
             MonoItem::GlobalAsm(..) => {}
         }
diff --git a/compiler/rustc_middle/src/mir/mono.rs b/compiler/rustc_middle/src/mir/mono.rs
index ca230d7fa8584..4287b2c574ffe 100644
--- a/compiler/rustc_middle/src/mir/mono.rs
+++ b/compiler/rustc_middle/src/mir/mono.rs
@@ -19,6 +19,7 @@ use rustc_target::spec::SymbolVisibility;
 use tracing::debug;
 
 use crate::dep_graph::{DepNode, WorkProduct, WorkProductId};
+use crate::middle::codegen_fn_attrs::CodegenFnAttrFlags;
 use crate::ty::{GenericArgs, Instance, InstanceKind, SymbolName, TyCtxt};
 
 /// Describes how a monomorphization will be instantiated in object files.
@@ -104,7 +105,9 @@ impl<'tcx> MonoItem<'tcx> {
                 let entry_def_id = tcx.entry_fn(()).map(|(id, _)| id);
                 // If this function isn't inlined or otherwise has an extern
                 // indicator, then we'll be creating a globally shared version.
-                if tcx.codegen_fn_attrs(instance.def_id()).contains_extern_indicator()
+                let codegen_fn_attrs = tcx.codegen_fn_attrs(instance.def_id());
+                if codegen_fn_attrs.contains_extern_indicator()
+                    || codegen_fn_attrs.flags.contains(CodegenFnAttrFlags::NAKED)
                     || !instance.def.generates_cgu_internal_copy(tcx)
                     || Some(instance.def_id()) == entry_def_id
                 {
@@ -302,6 +305,9 @@ impl LinkageInfo {
     /// Naked functions are generated as a separate declaration (effectively an extern fn) and
     /// definition (using global assembly). To link them together, some flavor of external linkage
     /// must be used.
+    ///
+    /// This should be just an implementation detail of the backend, which is why this translation
+    /// is made at the final moment.
     pub const fn into_naked_linkage(self) -> Linkage {
         match self {
             // promote Weak linkage to ExternalWeak
diff --git a/tests/codegen/naked-fn/generics.rs b/tests/codegen/naked-fn/generics.rs
new file mode 100644
index 0000000000000..5bb40cddea56c
--- /dev/null
+++ b/tests/codegen/naked-fn/generics.rs
@@ -0,0 +1,117 @@
+//@ compile-flags: -O
+//@ only-x86_64
+
+#![crate_type = "lib"]
+#![feature(naked_functions, asm_const)]
+
+use std::arch::asm;
+
+#[no_mangle]
+fn test(x: u64) {
+    // just making sure these symbols get used
+    using_const_generics::<1>(x);
+    using_const_generics::<2>(x);
+
+    generic_function::<i64>(x as i64);
+
+    let foo = Foo(x);
+
+    foo.method();
+    foo.trait_method();
+}
+
+// CHECK: .balign 4
+// CHECK: add rax, 2
+// CHECK: add rax, 42
+
+// CHECK: .balign 4
+// CHECK: add rax, 1
+// CHECK: add rax, 42
+
+#[naked]
+pub extern "C" fn using_const_generics<const N: u64>(x: u64) -> u64 {
+    const M: u64 = 42;
+
+    unsafe {
+        asm!(
+            "xor rax, rax",
+            "add rax, rdi",
+            "add rax, {}",
+            "add rax, {}",
+            "ret",
+            const N,
+            const M,
+            options(noreturn),
+        )
+    }
+}
+
+trait Invert {
+    fn invert(self) -> Self;
+}
+
+impl Invert for i64 {
+    fn invert(self) -> Self {
+        -1 * self
+    }
+}
+
+// CHECK-LABEL: generic_function
+// CHECK: .balign 4
+// CHECK: call
+// CHECK: ret
+
+#[naked]
+pub extern "C" fn generic_function<T: Invert>(x: i64) -> i64 {
+    unsafe {
+        asm!(
+            "call {}",
+            "ret",
+            sym <T as Invert>::invert,
+            options(noreturn),
+        )
+    }
+}
+
+#[derive(Copy, Clone)]
+#[repr(transparent)]
+struct Foo(u64);
+
+// CHECK-LABEL: method
+// CHECK: .balign 4
+// CHECK: mov rax, rdi
+
+impl Foo {
+    #[naked]
+    #[no_mangle]
+    extern "C" fn method(self) -> u64 {
+        unsafe { asm!("mov rax, rdi", "ret", options(noreturn)) }
+    }
+}
+
+// CHECK-LABEL: trait_method
+// CHECK: .balign 4
+// CHECK: mov rax, rdi
+
+trait Bar {
+    extern "C" fn trait_method(self) -> u64;
+}
+
+impl Bar for Foo {
+    #[naked]
+    #[no_mangle]
+    extern "C" fn trait_method(self) -> u64 {
+        unsafe { asm!("mov rax, rdi", "ret", options(noreturn)) }
+    }
+}
+
+// CHECK-LABEL: naked_with_args_and_return
+// CHECK: .balign 4
+// CHECK: lea rax, [rdi + rsi]
+
+// this previously ICE'd, see https://github.com/rust-lang/rust/issues/124375
+#[naked]
+#[no_mangle]
+pub unsafe extern "C" fn naked_with_args_and_return(a: isize, b: isize) -> isize {
+    asm!("lea rax, [rdi + rsi]", "ret", options(noreturn));
+}
diff --git a/tests/codegen/naked-fn/instruction-set.rs b/tests/codegen/naked-fn/instruction-set.rs
new file mode 100644
index 0000000000000..509c24f9457cf
--- /dev/null
+++ b/tests/codegen/naked-fn/instruction-set.rs
@@ -0,0 +1,43 @@
+//@ compile-flags: --target armv5te-none-eabi
+//@ needs-llvm-components: arm
+
+#![crate_type = "lib"]
+#![feature(no_core, lang_items, rustc_attrs, naked_functions)]
+#![no_core]
+
+#[rustc_builtin_macro]
+macro_rules! asm {
+    () => {};
+}
+
+#[lang = "sized"]
+trait Sized {}
+#[lang = "copy"]
+trait Copy {}
+
+// CHECK-LABEL: test_unspecified:
+// CHECK: .arm
+#[no_mangle]
+#[naked]
+unsafe extern "C" fn test_unspecified() {
+    asm!("bx lr", options(noreturn));
+}
+
+// CHECK-LABEL: test_thumb:
+// CHECK: .thumb
+// CHECK: .thumb_func
+#[no_mangle]
+#[naked]
+#[instruction_set(arm::t32)]
+unsafe extern "C" fn test_thumb() {
+    asm!("bx lr", options(noreturn));
+}
+
+// CHECK-LABEL: test_arm:
+// CHECK: .arm
+#[no_mangle]
+#[naked]
+#[instruction_set(arm::t32)]
+unsafe extern "C" fn test_arm() {
+    asm!("bx lr", options(noreturn));
+}
diff --git a/tests/codegen/naked-fn/naked-functions.rs b/tests/codegen/naked-fn/naked-functions.rs
index 00d64089ad8bc..8b12693da8f66 100644
--- a/tests/codegen/naked-fn/naked-functions.rs
+++ b/tests/codegen/naked-fn/naked-functions.rs
@@ -1,49 +1,147 @@
-//@ compile-flags: -C no-prepopulate-passes -Copt-level=0
-//@ needs-asm-support
-//@ only-x86_64
+//@ revisions: linux windows macos thumb
+//
+//@[linux] compile-flags: --target x86_64-unknown-linux-gnu
+//@[linux] needs-llvm-components: x86
+//@[windows] compile-flags: --target x86_64-pc-windows-gnu
+//@[windows] needs-llvm-components: x86
+//@[macos] compile-flags: --target aarch64-apple-darwin
+//@[macos] needs-llvm-components: arm
+//@[thumb] compile-flags: --target thumbv7em-none-eabi
+//@[thumb] needs-llvm-components: arm
 
 #![crate_type = "lib"]
-#![feature(naked_functions)]
-use std::arch::naked_asm;
-
-// CHECK: module asm ".intel_syntax"
-// CHECK: .pushsection .text.naked_empty,\22ax\22, @progbits
-// CHECK: .balign 4"
-// CHECK: .globl naked_empty"
-// CHECK: .hidden naked_empty"
-// CHECK: .type naked_empty, @function"
+#![feature(no_core, lang_items, rustc_attrs, naked_functions)]
+#![no_core]
+
+#[rustc_builtin_macro]
+macro_rules! naked_asm {
+    () => {};
+}
+
+#[lang = "sized"]
+trait Sized {}
+#[lang = "copy"]
+trait Copy {}
+
+// linux,windows: .intel_syntax
+//
+// linux:   .pushsection .text.naked_empty,\22ax\22, @progbits
+// macos:   .pushsection __TEXT,__text,regular,pure_instructions
+// windows: .pushsection .text.naked_empty,\22xr\22
+// thumb:   .pushsection .text.naked_empty,\22ax\22, %progbits
+//
+// CHECK: .balign 4
+//
+// linux,windows,thumb: .globl naked_empty
+// macos: .globl _naked_empty
+//
+// CHECK-NOT: .private_extern
+// CHECK-NOT: .hidden
+//
+// linux: .type naked_empty, @function
+//
+// windows: .def naked_empty
+// windows: .scl 2
+// windows: .type 32
+// windows: .endef naked_empty
+//
+// thumb: .type naked_empty, %function
+// thumb: .thumb
+// thumb: .thumb_func
+//
 // CHECK-LABEL: naked_empty:
-// CHECK: ret
+//
+// linux,macos,windows: ret
+// thumb: bx lr
+//
 // CHECK: .popsection
-// CHECK: .att_syntax
+//
+// thumb: .thumb
+//
+// linux,windows: .att_syntax
 
 #[no_mangle]
 #[naked]
 pub unsafe extern "C" fn naked_empty() {
-    // CHECK-NEXT: {{.+}}:
-    // CHECK-NEXT: call void asm
-    // CHECK-NEXT: unreachable
+    #[cfg(not(all(target_arch = "arm", target_feature = "thumb-mode")))]
     naked_asm!("ret");
+
+    #[cfg(all(target_arch = "arm", target_feature = "thumb-mode"))]
+    naked_asm!("bx lr");
 }
 
-// CHECK: .intel_syntax
-// CHECK: .pushsection .text.naked_with_args_and_return,\22ax\22, @progbits
+// linux,windows: .intel_syntax
+//
+// linux:   .pushsection .text.naked_with_args_and_return,\22ax\22, @progbits
+// macos:   .pushsection __TEXT,__text,regular,pure_instructions
+// windows: .pushsection .text.naked_with_args_and_return,\22xr\22
+// thumb:   .pushsection .text.naked_with_args_and_return,\22ax\22, %progbits
+//
 // CHECK: .balign 4
-// CHECK: .globl naked_with_args_and_return
-// CHECK: .hidden naked_with_args_and_return
-// CHECK: .type naked_with_args_and_return, @function
+//
+// linux,windows,thumb: .globl naked_with_args_and_return
+// macos: .globl _naked_with_args_and_return
+//
+// CHECK-NOT: .private_extern
+// CHECK-NOT: .hidden
+//
+// linux: .type naked_with_args_and_return, @function
+//
+// windows: .def naked_with_args_and_return
+// windows: .scl 2
+// windows: .type 32
+// windows: .endef naked_with_args_and_return
+//
+// thumb: .type naked_with_args_and_return, %function
+// thumb: .thumb
+// thumb: .thumb_func
+//
 // CHECK-LABEL: naked_with_args_and_return:
-// CHECK: lea rax, [rdi + rsi]
-// CHECK: ret
-// CHECK: .size naked_with_args_and_return, . - naked_with_args_and_return
+//
+// linux, windows: lea rax, [rdi + rsi]
+// macos: add x0, x0, x1
+// thumb: adds r0, r0, r1
+//
+// linux,macos,windows: ret
+// thumb: bx lr
+//
 // CHECK: .popsection
-// CHECK: .att_syntax
+//
+// thumb: .thumb
+//
+// linux,windows: .att_syntax
 
 #[no_mangle]
 #[naked]
 pub unsafe extern "C" fn naked_with_args_and_return(a: isize, b: isize) -> isize {
-    // CHECK-NEXT: {{.+}}:
-    // CHECK-NEXT: call void asm
-    // CHECK-NEXT: unreachable
-    naked_asm!("lea rax, [rdi + rsi]", "ret");
+    #[cfg(any(target_os = "windows", target_os = "linux"))]
+    {
+        naked_asm!("lea rax, [rdi + rsi]", "ret")
+    }
+
+    #[cfg(target_os = "macos")]
+    {
+        naked_asm!("add x0, x0, x1", "ret")
+    }
+
+    #[cfg(all(target_arch = "arm", target_feature = "thumb-mode"))]
+    {
+        naked_asm!("adds r0, r0, r1", "bx lr")
+    }
+}
+
+// linux:   .pushsection .text.some_different_name,\22ax\22, @progbits
+// macos:   .pushsection .text.some_different_name,regular,pure_instructions
+// windows: .pushsection .text.some_different_name,\22xr\22
+// thumb:   .pushsection .text.some_different_name,\22ax\22, %progbits
+// CHECK-LABEL: test_link_section:
+#[no_mangle]
+#[naked]
+#[link_section = ".text.some_different_name"]
+pub unsafe extern "C" fn test_link_section() {
+    #[cfg(not(all(target_arch = "arm", target_feature = "thumb-mode")))]
+    naked_asm!("ret", options(noreturn));
+
+    #[cfg(all(target_arch = "arm", target_feature = "thumb-mode"))]
+    naked_asm!("bx lr", options(noreturn));
 }
diff --git a/tests/codegen/naked-fn/naked-nocoverage.rs b/tests/codegen/naked-fn/naked-nocoverage.rs
deleted file mode 100644
index f63661bcd3a7a..0000000000000
--- a/tests/codegen/naked-fn/naked-nocoverage.rs
+++ /dev/null
@@ -1,19 +0,0 @@
-// Checks that naked functions are not instrumented by -Cinstrument-coverage.
-// Regression test for issue #105170.
-//
-//@ needs-asm-support
-//@ compile-flags: -Zno-profiler-runtime
-//@ compile-flags: -Cinstrument-coverage
-#![crate_type = "lib"]
-#![feature(naked_functions)]
-use std::arch::naked_asm;
-
-#[naked]
-#[no_mangle]
-pub unsafe extern "C" fn f() {
-    // CHECK:       define {{(dso_local )?}}void @f()
-    // CHECK-NEXT:  start:
-    // CHECK-NEXT:    call void asm
-    // CHECK-NEXT:    unreachable
-    naked_asm!("");
-}
diff --git a/tests/crashes/124375.rs b/tests/crashes/124375.rs
deleted file mode 100644
index 1d877caeb8bc1..0000000000000
--- a/tests/crashes/124375.rs
+++ /dev/null
@@ -1,11 +0,0 @@
-//@ known-bug: #124375
-//@ compile-flags: -Zmir-opt-level=0
-//@ only-x86_64
-#![crate_type = "lib"]
-#![feature(naked_functions)]
-use std::arch::naked_asm;
-
-#[naked]
-pub unsafe extern "C" fn naked_with_args_and_return(a: isize, b: isize) -> isize {
-    naked_asm!("lea rax, [rdi + rsi]", "ret");
-}
diff --git a/tests/ui/asm/naked-functions-instruction-set.rs b/tests/ui/asm/naked-functions-instruction-set.rs
index 37c7b52c191cd..3a6e7a46ce5a7 100644
--- a/tests/ui/asm/naked-functions-instruction-set.rs
+++ b/tests/ui/asm/naked-functions-instruction-set.rs
@@ -24,7 +24,7 @@ unsafe extern "C" fn test_thumb() {
 
 #[no_mangle]
 #[naked]
-#[instruction_set(arm::t32)]
+#[instruction_set(arm::a32)]
 unsafe extern "C" fn test_arm() {
     naked_asm!("bx lr");
 }
diff --git a/tests/ui/asm/naked-functions.rs b/tests/ui/asm/naked-functions.rs
index 5c58f1498cc97..0939b5b57e5e1 100644
--- a/tests/ui/asm/naked-functions.rs
+++ b/tests/ui/asm/naked-functions.rs
@@ -183,6 +183,12 @@ pub unsafe extern "C" fn invalid_asm_syntax(a: u32) -> u32 {
     //~^ ERROR asm template must be a string literal
 }
 
+// this previously ICE'd, see https://github.com/rust-lang/rust/issues/124375
+#[naked]
+pub unsafe extern "C" fn naked_with_args_and_return(a: isize, b: isize) -> isize {
+    asm!("lea rax, [rdi + rsi]", "ret", options(noreturn));
+}
+
 #[cfg(target_arch = "x86_64")]
 #[cfg_attr(target_pointer_width = "64", no_mangle)]
 #[naked]

From 589ebb815d5e078de200155f207ab7fcc550cf9c Mon Sep 17 00:00:00 2001
From: Folkert <folkert@folkertdev.nl>
Date: Fri, 26 Jul 2024 16:54:15 +0200
Subject: [PATCH 09/30] make naked functions always have external linkage *in
 LLVM*. If we do it earlier, then some other logic causes invalid visibility
 for the item (exporting when it shouldn't).

---
 compiler/rustc_codegen_llvm/src/mono_item.rs | 10 +---------
 tests/ui/asm/naked-functions.rs              |  2 +-
 2 files changed, 2 insertions(+), 10 deletions(-)

diff --git a/compiler/rustc_codegen_llvm/src/mono_item.rs b/compiler/rustc_codegen_llvm/src/mono_item.rs
index 4d1704f2c998f..b91941396ed81 100644
--- a/compiler/rustc_codegen_llvm/src/mono_item.rs
+++ b/compiler/rustc_codegen_llvm/src/mono_item.rs
@@ -2,7 +2,6 @@ use rustc_codegen_ssa::traits::*;
 use rustc_hir::def::DefKind;
 use rustc_hir::def_id::{DefId, LOCAL_CRATE};
 use rustc_middle::bug;
-use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags;
 use rustc_middle::mir::mono::{Linkage, Visibility};
 use rustc_middle::ty::layout::{FnAbiOf, HasTypingEnv, LayoutOf};
 use rustc_middle::ty::{self, Instance, TypeVisitableExt};
@@ -60,14 +59,7 @@ impl<'tcx> PreDefineCodegenMethods<'tcx> for CodegenCx<'_, 'tcx> {
         let fn_abi = self.fn_abi_of_instance(instance, ty::List::empty());
         let lldecl = self.declare_fn(symbol_name, fn_abi, Some(instance));
         let attrs = self.tcx.codegen_fn_attrs(instance.def_id());
-        let llvm_linkage =
-            if attrs.flags.contains(CodegenFnAttrFlags::NAKED) && linkage == Linkage::Internal {
-                // this is effectively an extern fn, and must have external linkage
-                llvm::Linkage::ExternalLinkage
-            } else {
-                base::linkage_to_llvm(linkage)
-            };
-        llvm::set_linkage(lldecl, llvm_linkage);
+        llvm::set_linkage(lldecl, base::linkage_to_llvm(linkage));
         base::set_link_section(lldecl, attrs);
         if (linkage == Linkage::LinkOnceODR || linkage == Linkage::WeakODR)
             && self.tcx.sess.target.supports_comdat()
diff --git a/tests/ui/asm/naked-functions.rs b/tests/ui/asm/naked-functions.rs
index 0939b5b57e5e1..586645edac969 100644
--- a/tests/ui/asm/naked-functions.rs
+++ b/tests/ui/asm/naked-functions.rs
@@ -186,7 +186,7 @@ pub unsafe extern "C" fn invalid_asm_syntax(a: u32) -> u32 {
 // this previously ICE'd, see https://github.com/rust-lang/rust/issues/124375
 #[naked]
 pub unsafe extern "C" fn naked_with_args_and_return(a: isize, b: isize) -> isize {
-    asm!("lea rax, [rdi + rsi]", "ret", options(noreturn));
+    naked_asm!("lea rax, [rdi + rsi]", "ret");
 }
 
 #[cfg(target_arch = "x86_64")]

From 2e24cdbf30ca0ae5473cf0aa06140e044b805f1a Mon Sep 17 00:00:00 2001
From: Folkert <folkert@folkertdev.nl>
Date: Sun, 11 Aug 2024 12:21:42 +0200
Subject: [PATCH 10/30] squashed changes:

- codegen tests: change `windows` to `win`
- cleanup
- fix review comments
    - better way of checking for thumb
    - get the mangled name from the codegen backend
- propagate function alignment
- fix gcc backend
- fix asan test
- check that assembler mode restored
---
 compiler/rustc_codegen_gcc/src/asm.rs         |  7 +++
 compiler/rustc_codegen_llvm/src/asm.rs        |  8 +++
 .../rustc_codegen_ssa/src/mir/naked_asm.rs    | 31 ++++++------
 compiler/rustc_codegen_ssa/src/traits/asm.rs  |  7 +++
 tests/codegen/naked-asan.rs                   |  6 ++-
 tests/codegen/naked-fn/aligned.rs             |  9 ++--
 tests/codegen/naked-fn/generics.rs            | 14 +++---
 tests/codegen/naked-fn/instruction-set.rs     | 36 +++++++++----
 tests/codegen/naked-fn/naked-functions.rs     | 50 +++++++++----------
 9 files changed, 101 insertions(+), 67 deletions(-)

diff --git a/compiler/rustc_codegen_gcc/src/asm.rs b/compiler/rustc_codegen_gcc/src/asm.rs
index 341d1b9c179b7..199d22e02e287 100644
--- a/compiler/rustc_codegen_gcc/src/asm.rs
+++ b/compiler/rustc_codegen_gcc/src/asm.rs
@@ -865,6 +865,13 @@ impl<'gcc, 'tcx> AsmCodegenMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
         template_str.push_str("\n.popsection");
         self.context.add_top_level_asm(None, &template_str);
     }
+
+    fn mangled_name(&self, instance: Instance<'tcx>) -> String {
+        // TODO(@Amanieu): Additional mangling is needed on
+        // some targets to add a leading underscore (Mach-O)
+        // or byte count suffixes (x86 Windows).
+        self.tcx.symbol_name(instance).name.to_string()
+    }
 }
 
 fn modifier_to_gcc(
diff --git a/compiler/rustc_codegen_llvm/src/asm.rs b/compiler/rustc_codegen_llvm/src/asm.rs
index 9aa01bd1b956c..a6fa1fc3e19a4 100644
--- a/compiler/rustc_codegen_llvm/src/asm.rs
+++ b/compiler/rustc_codegen_llvm/src/asm.rs
@@ -442,6 +442,14 @@ impl<'tcx> AsmCodegenMethods<'tcx> for CodegenCx<'_, 'tcx> {
             );
         }
     }
+
+    fn mangled_name(&self, instance: Instance<'tcx>) -> String {
+        let llval = self.get_fn(instance);
+        llvm::build_string(|s| unsafe {
+            llvm::LLVMRustGetMangledName(llval, s);
+        })
+        .expect("symbol is not valid UTF-8")
+    }
 }
 
 pub(crate) fn inline_asm_call<'ll>(
diff --git a/compiler/rustc_codegen_ssa/src/mir/naked_asm.rs b/compiler/rustc_codegen_ssa/src/mir/naked_asm.rs
index b4eb6110da8ca..65470dd6d5371 100644
--- a/compiler/rustc_codegen_ssa/src/mir/naked_asm.rs
+++ b/compiler/rustc_codegen_ssa/src/mir/naked_asm.rs
@@ -4,7 +4,7 @@ use rustc_middle::mir::{Body, InlineAsmOperand};
 use rustc_middle::ty::layout::{HasTyCtxt, HasTypingEnv, LayoutOf};
 use rustc_middle::ty::{Instance, TyCtxt};
 use rustc_middle::{bug, ty};
-use rustc_target::asm::InlineAsmArch;
+use rustc_span::sym;
 
 use crate::common;
 use crate::traits::{AsmCodegenMethods, BuilderMethods, GlobalAsmOperandRef, MiscCodegenMethods};
@@ -31,7 +31,8 @@ pub(crate) fn codegen_naked_asm<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
         operands.iter().map(|op| inline_to_global_operand::<Bx>(cx, instance, op)).collect();
 
     let item_data = cx.codegen_unit().items().get(&MonoItem::Fn(instance)).unwrap();
-    let (begin, end) = crate::mir::naked_asm::prefix_and_suffix(cx.tcx(), instance, item_data);
+    let name = cx.mangled_name(instance);
+    let (begin, end) = prefix_and_suffix(cx.tcx(), instance, &name, item_data);
 
     let mut template_vec = Vec::new();
     template_vec.push(rustc_ast::ast::InlineAsmTemplatePiece::String(begin.into()));
@@ -108,7 +109,7 @@ impl AsmBinaryFormat {
     fn from_target(target: &rustc_target::spec::Target) -> Self {
         if target.is_like_windows {
             Self::Coff
-        } else if target.options.vendor == "apple" {
+        } else if target.is_like_osx {
             Self::Macho
         } else {
             Self::Elf
@@ -119,24 +120,20 @@ impl AsmBinaryFormat {
 fn prefix_and_suffix<'tcx>(
     tcx: TyCtxt<'tcx>,
     instance: Instance<'tcx>,
+    asm_name: &str,
     item_data: &MonoItemData,
 ) -> (String, String) {
     use std::fmt::Write;
 
-    let target = &tcx.sess.target;
-    let target_arch = tcx.sess.asm_arch;
-
-    let is_arm = target.arch == "arm";
-    let is_thumb = is_arm && target.llvm_target.contains("thumb");
-
-    let mangle = (target.is_like_windows && matches!(target_arch, Some(InlineAsmArch::X86)))
-        || target.options.vendor == "apple";
-
-    let asm_name = format!("{}{}", if mangle { "_" } else { "" }, tcx.symbol_name(instance).name);
+    let is_arm = tcx.sess.target.arch == "arm";
+    let is_thumb = tcx.sess.unstable_target_features.contains(&sym::thumb_mode);
 
     let attrs = tcx.codegen_fn_attrs(instance.def_id());
     let link_section = attrs.link_section.map(|symbol| symbol.as_str().to_string());
+    let align = attrs.alignment.map(|a| a.bytes()).unwrap_or(4);
 
+    // See https://sourceware.org/binutils/docs/as/ARM-Directives.html for info on these directives.
+    // In particular, `.arm` can also be written `.code 32` and `.thumb` as `.code 16`.
     let (arch_prefix, arch_suffix) = if is_arm {
         (
             match attrs.instruction_set {
@@ -144,8 +141,8 @@ fn prefix_and_suffix<'tcx>(
                     true => ".thumb\n.thumb_func",
                     false => ".arm",
                 },
-                Some(InstructionSetAttr::ArmA32) => ".arm",
                 Some(InstructionSetAttr::ArmT32) => ".thumb\n.thumb_func",
+                Some(InstructionSetAttr::ArmA32) => ".arm",
             },
             match is_thumb {
                 true => ".thumb",
@@ -173,7 +170,7 @@ fn prefix_and_suffix<'tcx>(
             };
 
             writeln!(begin, ".pushsection {section},\"ax\", {progbits}").unwrap();
-            writeln!(begin, ".balign 4").unwrap();
+            writeln!(begin, ".balign {align}").unwrap();
             writeln!(begin, ".globl {asm_name}").unwrap();
             if let Visibility::Hidden = item_data.visibility {
                 writeln!(begin, ".hidden {asm_name}").unwrap();
@@ -194,7 +191,7 @@ fn prefix_and_suffix<'tcx>(
         AsmBinaryFormat::Macho => {
             let section = link_section.unwrap_or("__TEXT,__text".to_string());
             writeln!(begin, ".pushsection {},regular,pure_instructions", section).unwrap();
-            writeln!(begin, ".balign 4").unwrap();
+            writeln!(begin, ".balign {align}").unwrap();
             writeln!(begin, ".globl {asm_name}").unwrap();
             if let Visibility::Hidden = item_data.visibility {
                 writeln!(begin, ".private_extern {asm_name}").unwrap();
@@ -210,7 +207,7 @@ fn prefix_and_suffix<'tcx>(
         AsmBinaryFormat::Coff => {
             let section = link_section.unwrap_or(format!(".text.{asm_name}"));
             writeln!(begin, ".pushsection {},\"xr\"", section).unwrap();
-            writeln!(begin, ".balign 4").unwrap();
+            writeln!(begin, ".balign {align}").unwrap();
             writeln!(begin, ".globl {asm_name}").unwrap();
             writeln!(begin, ".def {asm_name}").unwrap();
             writeln!(begin, ".scl 2").unwrap();
diff --git a/compiler/rustc_codegen_ssa/src/traits/asm.rs b/compiler/rustc_codegen_ssa/src/traits/asm.rs
index f4853da115648..7767bffbfbfd6 100644
--- a/compiler/rustc_codegen_ssa/src/traits/asm.rs
+++ b/compiler/rustc_codegen_ssa/src/traits/asm.rs
@@ -68,4 +68,11 @@ pub trait AsmCodegenMethods<'tcx> {
         options: InlineAsmOptions,
         line_spans: &[Span],
     );
+
+    /// The mangled name of this instance
+    ///
+    /// Additional mangling is used on
+    /// some targets to add a leading underscore (Mach-O)
+    /// or byte count suffixes (x86 Windows).
+    fn mangled_name(&self, instance: Instance<'tcx>) -> String;
 }
diff --git a/tests/codegen/naked-asan.rs b/tests/codegen/naked-asan.rs
index bcaa60baeffd8..639f069c0d9e5 100644
--- a/tests/codegen/naked-asan.rs
+++ b/tests/codegen/naked-asan.rs
@@ -8,7 +8,11 @@
 #![no_std]
 #![feature(abi_x86_interrupt, naked_functions)]
 
-// CHECK: define x86_intrcc void @page_fault_handler(ptr {{.*}}%0, i64 {{.*}}%1){{.*}}#[[ATTRS:[0-9]+]] {
+pub fn caller() {
+    page_fault_handler(1, 2);
+}
+
+// CHECK: declare x86_intrcc void @page_fault_handler(ptr {{.*}}, i64 {{.*}}){{.*}}#[[ATTRS:[0-9]+]]
 // CHECK-NOT: memcpy
 #[naked]
 #[no_mangle]
diff --git a/tests/codegen/naked-fn/aligned.rs b/tests/codegen/naked-fn/aligned.rs
index 3bbd67981e5bf..d9dcd7f6c3ef7 100644
--- a/tests/codegen/naked-fn/aligned.rs
+++ b/tests/codegen/naked-fn/aligned.rs
@@ -6,15 +6,12 @@
 #![feature(naked_functions, fn_align)]
 use std::arch::naked_asm;
 
-// CHECK: Function Attrs: naked
-// CHECK-NEXT: define{{.*}}void @naked_empty()
-// CHECK: align 16
+// CHECK: .balign 16
+// CHECK-LABEL: naked_empty:
 #[repr(align(16))]
 #[no_mangle]
 #[naked]
 pub unsafe extern "C" fn naked_empty() {
-    // CHECK-NEXT: start:
-    // CHECK-NEXT: call void asm
-    // CHECK-NEXT: unreachable
+    // CHECK: ret
     naked_asm!("ret");
 }
diff --git a/tests/codegen/naked-fn/generics.rs b/tests/codegen/naked-fn/generics.rs
index 5bb40cddea56c..23c7766203b9f 100644
--- a/tests/codegen/naked-fn/generics.rs
+++ b/tests/codegen/naked-fn/generics.rs
@@ -4,7 +4,7 @@
 #![crate_type = "lib"]
 #![feature(naked_functions, asm_const)]
 
-use std::arch::asm;
+use std::arch::naked_asm;
 
 #[no_mangle]
 fn test(x: u64) {
@@ -33,7 +33,7 @@ pub extern "C" fn using_const_generics<const N: u64>(x: u64) -> u64 {
     const M: u64 = 42;
 
     unsafe {
-        asm!(
+        naked_asm!(
             "xor rax, rax",
             "add rax, rdi",
             "add rax, {}",
@@ -41,7 +41,6 @@ pub extern "C" fn using_const_generics<const N: u64>(x: u64) -> u64 {
             "ret",
             const N,
             const M,
-            options(noreturn),
         )
     }
 }
@@ -64,11 +63,10 @@ impl Invert for i64 {
 #[naked]
 pub extern "C" fn generic_function<T: Invert>(x: i64) -> i64 {
     unsafe {
-        asm!(
+        naked_asm!(
             "call {}",
             "ret",
             sym <T as Invert>::invert,
-            options(noreturn),
         )
     }
 }
@@ -85,7 +83,7 @@ impl Foo {
     #[naked]
     #[no_mangle]
     extern "C" fn method(self) -> u64 {
-        unsafe { asm!("mov rax, rdi", "ret", options(noreturn)) }
+        unsafe { naked_asm!("mov rax, rdi", "ret") }
     }
 }
 
@@ -101,7 +99,7 @@ impl Bar for Foo {
     #[naked]
     #[no_mangle]
     extern "C" fn trait_method(self) -> u64 {
-        unsafe { asm!("mov rax, rdi", "ret", options(noreturn)) }
+        unsafe { naked_asm!("mov rax, rdi", "ret") }
     }
 }
 
@@ -113,5 +111,5 @@ impl Bar for Foo {
 #[naked]
 #[no_mangle]
 pub unsafe extern "C" fn naked_with_args_and_return(a: isize, b: isize) -> isize {
-    asm!("lea rax, [rdi + rsi]", "ret", options(noreturn));
+    naked_asm!("lea rax, [rdi + rsi]", "ret");
 }
diff --git a/tests/codegen/naked-fn/instruction-set.rs b/tests/codegen/naked-fn/instruction-set.rs
index 509c24f9457cf..5b790b2034c09 100644
--- a/tests/codegen/naked-fn/instruction-set.rs
+++ b/tests/codegen/naked-fn/instruction-set.rs
@@ -1,12 +1,15 @@
-//@ compile-flags: --target armv5te-none-eabi
-//@ needs-llvm-components: arm
+//@ revisions: arm-mode thumb-mode
+//@ [arm-mode] compile-flags: --target armv5te-none-eabi
+//@ [thumb-mode] compile-flags: --target thumbv5te-none-eabi
+//@ [arm-mode] needs-llvm-components: arm
+//@ [thumb-mode] needs-llvm-components: arm
 
 #![crate_type = "lib"]
 #![feature(no_core, lang_items, rustc_attrs, naked_functions)]
 #![no_core]
 
 #[rustc_builtin_macro]
-macro_rules! asm {
+macro_rules! naked_asm {
     () => {};
 }
 
@@ -15,29 +18,42 @@ trait Sized {}
 #[lang = "copy"]
 trait Copy {}
 
+// arm-mode: .arm
+// thumb-mode: .thumb
 // CHECK-LABEL: test_unspecified:
-// CHECK: .arm
+// CHECK: bx lr
+// CHECK: .popsection
+// arm-mode: .arm
+// thumb-mode: .thumb
 #[no_mangle]
 #[naked]
 unsafe extern "C" fn test_unspecified() {
-    asm!("bx lr", options(noreturn));
+    naked_asm!("bx lr");
 }
 
-// CHECK-LABEL: test_thumb:
 // CHECK: .thumb
 // CHECK: .thumb_func
+// CHECK-LABEL: test_thumb:
+// CHECK: bx lr
+// CHECK: .popsection
+// arm-mode: .arm
+// thumb-mode: .thumb
 #[no_mangle]
 #[naked]
 #[instruction_set(arm::t32)]
 unsafe extern "C" fn test_thumb() {
-    asm!("bx lr", options(noreturn));
+    naked_asm!("bx lr");
 }
 
-// CHECK-LABEL: test_arm:
 // CHECK: .arm
+// CHECK-LABEL: test_arm:
+// CHECK: bx lr
+// CHECK: .popsection
+// arm-mode: .arm
+// thumb-mode: .thumb
 #[no_mangle]
 #[naked]
-#[instruction_set(arm::t32)]
+#[instruction_set(arm::a32)]
 unsafe extern "C" fn test_arm() {
-    asm!("bx lr", options(noreturn));
+    naked_asm!("bx lr");
 }
diff --git a/tests/codegen/naked-fn/naked-functions.rs b/tests/codegen/naked-fn/naked-functions.rs
index 8b12693da8f66..f505d27d48c62 100644
--- a/tests/codegen/naked-fn/naked-functions.rs
+++ b/tests/codegen/naked-fn/naked-functions.rs
@@ -1,9 +1,9 @@
-//@ revisions: linux windows macos thumb
+//@ revisions: linux win macos thumb
 //
 //@[linux] compile-flags: --target x86_64-unknown-linux-gnu
 //@[linux] needs-llvm-components: x86
-//@[windows] compile-flags: --target x86_64-pc-windows-gnu
-//@[windows] needs-llvm-components: x86
+//@[win] compile-flags: --target x86_64-pc-windows-gnu
+//@[win] needs-llvm-components: x86
 //@[macos] compile-flags: --target aarch64-apple-darwin
 //@[macos] needs-llvm-components: arm
 //@[thumb] compile-flags: --target thumbv7em-none-eabi
@@ -23,16 +23,16 @@ trait Sized {}
 #[lang = "copy"]
 trait Copy {}
 
-// linux,windows: .intel_syntax
+// linux,win: .intel_syntax
 //
 // linux:   .pushsection .text.naked_empty,\22ax\22, @progbits
 // macos:   .pushsection __TEXT,__text,regular,pure_instructions
-// windows: .pushsection .text.naked_empty,\22xr\22
+// win: .pushsection .text.naked_empty,\22xr\22
 // thumb:   .pushsection .text.naked_empty,\22ax\22, %progbits
 //
 // CHECK: .balign 4
 //
-// linux,windows,thumb: .globl naked_empty
+// linux,win,thumb: .globl naked_empty
 // macos: .globl _naked_empty
 //
 // CHECK-NOT: .private_extern
@@ -40,10 +40,10 @@ trait Copy {}
 //
 // linux: .type naked_empty, @function
 //
-// windows: .def naked_empty
-// windows: .scl 2
-// windows: .type 32
-// windows: .endef naked_empty
+// win: .def naked_empty
+// win: .scl 2
+// win: .type 32
+// win: .endef naked_empty
 //
 // thumb: .type naked_empty, %function
 // thumb: .thumb
@@ -51,14 +51,14 @@ trait Copy {}
 //
 // CHECK-LABEL: naked_empty:
 //
-// linux,macos,windows: ret
+// linux,macos,win: ret
 // thumb: bx lr
 //
 // CHECK: .popsection
 //
 // thumb: .thumb
 //
-// linux,windows: .att_syntax
+// linux,win: .att_syntax
 
 #[no_mangle]
 #[naked]
@@ -70,16 +70,16 @@ pub unsafe extern "C" fn naked_empty() {
     naked_asm!("bx lr");
 }
 
-// linux,windows: .intel_syntax
+// linux,win: .intel_syntax
 //
 // linux:   .pushsection .text.naked_with_args_and_return,\22ax\22, @progbits
 // macos:   .pushsection __TEXT,__text,regular,pure_instructions
-// windows: .pushsection .text.naked_with_args_and_return,\22xr\22
+// win: .pushsection .text.naked_with_args_and_return,\22xr\22
 // thumb:   .pushsection .text.naked_with_args_and_return,\22ax\22, %progbits
 //
 // CHECK: .balign 4
 //
-// linux,windows,thumb: .globl naked_with_args_and_return
+// linux,win,thumb: .globl naked_with_args_and_return
 // macos: .globl _naked_with_args_and_return
 //
 // CHECK-NOT: .private_extern
@@ -87,10 +87,10 @@ pub unsafe extern "C" fn naked_empty() {
 //
 // linux: .type naked_with_args_and_return, @function
 //
-// windows: .def naked_with_args_and_return
-// windows: .scl 2
-// windows: .type 32
-// windows: .endef naked_with_args_and_return
+// win: .def naked_with_args_and_return
+// win: .scl 2
+// win: .type 32
+// win: .endef naked_with_args_and_return
 //
 // thumb: .type naked_with_args_and_return, %function
 // thumb: .thumb
@@ -98,18 +98,18 @@ pub unsafe extern "C" fn naked_empty() {
 //
 // CHECK-LABEL: naked_with_args_and_return:
 //
-// linux, windows: lea rax, [rdi + rsi]
+// linux, win: lea rax, [rdi + rsi]
 // macos: add x0, x0, x1
 // thumb: adds r0, r0, r1
 //
-// linux,macos,windows: ret
+// linux,macos,win: ret
 // thumb: bx lr
 //
 // CHECK: .popsection
 //
 // thumb: .thumb
 //
-// linux,windows: .att_syntax
+// linux,win: .att_syntax
 
 #[no_mangle]
 #[naked]
@@ -132,7 +132,7 @@ pub unsafe extern "C" fn naked_with_args_and_return(a: isize, b: isize) -> isize
 
 // linux:   .pushsection .text.some_different_name,\22ax\22, @progbits
 // macos:   .pushsection .text.some_different_name,regular,pure_instructions
-// windows: .pushsection .text.some_different_name,\22xr\22
+// win: .pushsection .text.some_different_name,\22xr\22
 // thumb:   .pushsection .text.some_different_name,\22ax\22, %progbits
 // CHECK-LABEL: test_link_section:
 #[no_mangle]
@@ -140,8 +140,8 @@ pub unsafe extern "C" fn naked_with_args_and_return(a: isize, b: isize) -> isize
 #[link_section = ".text.some_different_name"]
 pub unsafe extern "C" fn test_link_section() {
     #[cfg(not(all(target_arch = "arm", target_feature = "thumb-mode")))]
-    naked_asm!("ret", options(noreturn));
+    naked_asm!("ret");
 
     #[cfg(all(target_arch = "arm", target_feature = "thumb-mode"))]
-    naked_asm!("bx lr", options(noreturn));
+    naked_asm!("bx lr");
 }

From 64420b6ea81d9f7065421add9843ba22e876cd6c Mon Sep 17 00:00:00 2001
From: Folkert de Vries <folkert@folkertdev.nl>
Date: Sat, 30 Nov 2024 15:36:03 +0100
Subject: [PATCH 11/30] skip `predefine_fn` for naked functions

---
 compiler/rustc_codegen_llvm/src/mono_item.rs  |  2 +-
 .../rustc_codegen_ssa/src/mir/naked_asm.rs    | 40 +++++++++++++++++--
 compiler/rustc_codegen_ssa/src/mono_item.rs   |  9 ++---
 compiler/rustc_middle/src/mir/mono.rs         | 22 ----------
 4 files changed, 41 insertions(+), 32 deletions(-)

diff --git a/compiler/rustc_codegen_llvm/src/mono_item.rs b/compiler/rustc_codegen_llvm/src/mono_item.rs
index b91941396ed81..33789c6261f10 100644
--- a/compiler/rustc_codegen_llvm/src/mono_item.rs
+++ b/compiler/rustc_codegen_llvm/src/mono_item.rs
@@ -58,8 +58,8 @@ impl<'tcx> PreDefineCodegenMethods<'tcx> for CodegenCx<'_, 'tcx> {
 
         let fn_abi = self.fn_abi_of_instance(instance, ty::List::empty());
         let lldecl = self.declare_fn(symbol_name, fn_abi, Some(instance));
-        let attrs = self.tcx.codegen_fn_attrs(instance.def_id());
         llvm::set_linkage(lldecl, base::linkage_to_llvm(linkage));
+        let attrs = self.tcx.codegen_fn_attrs(instance.def_id());
         base::set_link_section(lldecl, attrs);
         if (linkage == Linkage::LinkOnceODR || linkage == Linkage::WeakODR)
             && self.tcx.sess.target.supports_comdat()
diff --git a/compiler/rustc_codegen_ssa/src/mir/naked_asm.rs b/compiler/rustc_codegen_ssa/src/mir/naked_asm.rs
index 65470dd6d5371..359cda19b8449 100644
--- a/compiler/rustc_codegen_ssa/src/mir/naked_asm.rs
+++ b/compiler/rustc_codegen_ssa/src/mir/naked_asm.rs
@@ -1,5 +1,5 @@
 use rustc_attr::InstructionSetAttr;
-use rustc_middle::mir::mono::{MonoItem, MonoItemData, Visibility};
+use rustc_middle::mir::mono::{Linkage, MonoItem, MonoItemData, Visibility};
 use rustc_middle::mir::{Body, InlineAsmOperand};
 use rustc_middle::ty::layout::{HasTyCtxt, HasTypingEnv, LayoutOf};
 use rustc_middle::ty::{Instance, TyCtxt};
@@ -153,6 +153,30 @@ fn prefix_and_suffix<'tcx>(
         ("", "")
     };
 
+    let emit_fatal = |msg| tcx.dcx().span_fatal(tcx.def_span(instance.def_id()), msg);
+
+    // see https://godbolt.org/z/cPK4sxKor.
+    // None means the default, which corresponds to internal linkage
+    let linkage = match item_data.linkage {
+        Linkage::External => Some(".globl"),
+        Linkage::LinkOnceAny => Some(".weak"),
+        Linkage::LinkOnceODR => Some(".weak"),
+        Linkage::WeakAny => Some(".weak"),
+        Linkage::WeakODR => Some(".weak"),
+        Linkage::Internal => None,
+        Linkage::Private => None,
+        Linkage::Appending => emit_fatal("Only global variables can have appending linkage!"),
+        Linkage::Common => emit_fatal("Functions may not have common linkage"),
+        Linkage::AvailableExternally => {
+            // this would make the function equal an extern definition
+            emit_fatal("Functions may not have available_externally linkage")
+        }
+        Linkage::ExternalWeak => {
+            // FIXME: actually this causes a SIGILL in LLVM
+            emit_fatal("Functions may not have external weak linkage")
+        }
+    };
+
     let mut begin = String::new();
     let mut end = String::new();
     match AsmBinaryFormat::from_target(&tcx.sess.target) {
@@ -171,7 +195,9 @@ fn prefix_and_suffix<'tcx>(
 
             writeln!(begin, ".pushsection {section},\"ax\", {progbits}").unwrap();
             writeln!(begin, ".balign {align}").unwrap();
-            writeln!(begin, ".globl {asm_name}").unwrap();
+            if let Some(linkage) = linkage {
+                writeln!(begin, "{linkage} {asm_name}").unwrap();
+            }
             if let Visibility::Hidden = item_data.visibility {
                 writeln!(begin, ".hidden {asm_name}").unwrap();
             }
@@ -181,6 +207,8 @@ fn prefix_and_suffix<'tcx>(
             }
             writeln!(begin, "{asm_name}:").unwrap();
 
+            eprintln!("{}", &begin);
+
             writeln!(end).unwrap();
             writeln!(end, ".size {asm_name}, . - {asm_name}").unwrap();
             writeln!(end, ".popsection").unwrap();
@@ -192,7 +220,9 @@ fn prefix_and_suffix<'tcx>(
             let section = link_section.unwrap_or("__TEXT,__text".to_string());
             writeln!(begin, ".pushsection {},regular,pure_instructions", section).unwrap();
             writeln!(begin, ".balign {align}").unwrap();
-            writeln!(begin, ".globl {asm_name}").unwrap();
+            if let Some(linkage) = linkage {
+                writeln!(begin, "{linkage} {asm_name}").unwrap();
+            }
             if let Visibility::Hidden = item_data.visibility {
                 writeln!(begin, ".private_extern {asm_name}").unwrap();
             }
@@ -208,7 +238,9 @@ fn prefix_and_suffix<'tcx>(
             let section = link_section.unwrap_or(format!(".text.{asm_name}"));
             writeln!(begin, ".pushsection {},\"xr\"", section).unwrap();
             writeln!(begin, ".balign {align}").unwrap();
-            writeln!(begin, ".globl {asm_name}").unwrap();
+            if let Some(linkage) = linkage {
+                writeln!(begin, "{linkage} {asm_name}").unwrap();
+            }
             writeln!(begin, ".def {asm_name}").unwrap();
             writeln!(begin, ".scl 2").unwrap();
             writeln!(begin, ".type 32").unwrap();
diff --git a/compiler/rustc_codegen_ssa/src/mono_item.rs b/compiler/rustc_codegen_ssa/src/mono_item.rs
index 085ef1cd8ea36..70ad5bee3e09c 100644
--- a/compiler/rustc_codegen_ssa/src/mono_item.rs
+++ b/compiler/rustc_codegen_ssa/src/mono_item.rs
@@ -137,13 +137,12 @@ impl<'a, 'tcx: 'a> MonoItemExt<'a, 'tcx> for MonoItem<'tcx> {
             }
             MonoItem::Fn(instance) => {
                 let attrs = cx.tcx().codegen_fn_attrs(instance.def_id());
-                let linkage = if attrs.flags.contains(CodegenFnAttrFlags::NAKED) {
-                    linkage_info.into_naked_linkage()
+
+                if attrs.flags.contains(CodegenFnAttrFlags::NAKED) {
+                    // do not define this function; it will become a global assembly block
                 } else {
-                    linkage_info.into_linkage()
+                    cx.predefine_fn(instance, linkage_info.into_linkage(), visibility, symbol_name);
                 };
-
-                cx.predefine_fn(instance, linkage, visibility, symbol_name);
             }
             MonoItem::GlobalAsm(..) => {}
         }
diff --git a/compiler/rustc_middle/src/mir/mono.rs b/compiler/rustc_middle/src/mir/mono.rs
index 4287b2c574ffe..01c66ecb570cb 100644
--- a/compiler/rustc_middle/src/mir/mono.rs
+++ b/compiler/rustc_middle/src/mir/mono.rs
@@ -299,28 +299,6 @@ impl LinkageInfo {
             Self::ImplicitInternal => Linkage::Internal,
         }
     }
-
-    /// Linkage when the MonoItem is a naked function
-    ///
-    /// Naked functions are generated as a separate declaration (effectively an extern fn) and
-    /// definition (using global assembly). To link them together, some flavor of external linkage
-    /// must be used.
-    ///
-    /// This should be just an implementation detail of the backend, which is why this translation
-    /// is made at the final moment.
-    pub const fn into_naked_linkage(self) -> Linkage {
-        match self {
-            // promote Weak linkage to ExternalWeak
-            Self::Explicit(Linkage::WeakAny | Linkage::WeakODR) => Linkage::ExternalWeak,
-            Self::Explicit(linkage) => linkage,
-
-            // the "implicit" means that linkage is picked by the partitioning algorithm.
-            // picking external should always be valid (given that we are in fact linking
-            // to the global assembly in the same CGU)
-            Self::ImplicitExternal => Linkage::External,
-            Self::ImplicitInternal => Linkage::External,
-        }
-    }
 }
 
 /// Specifies the linkage type for a `MonoItem`.

From cf738f6bfba45aa65e96eb2c9cce3d0ecd25f66c Mon Sep 17 00:00:00 2001
From: Folkert de Vries <folkert@folkertdev.nl>
Date: Sat, 30 Nov 2024 15:42:04 +0100
Subject: [PATCH 12/30] Revert "add `LinkageInfo` to keep track of how we
 figured out the linkage"

This reverts commit 9142cae7d5b86ac70f815c32c0f3b1223b62a947.
---
 .../rustc_codegen_cranelift/src/driver/mod.rs |  2 +-
 compiler/rustc_codegen_gcc/src/base.rs        |  2 +-
 compiler/rustc_codegen_llvm/src/base.rs       |  2 +-
 .../src/back/symbol_export.rs                 |  4 +-
 .../rustc_codegen_ssa/src/mir/naked_asm.rs    |  2 -
 compiler/rustc_codegen_ssa/src/mono_item.rs   | 10 ++--
 compiler/rustc_middle/src/mir/mono.rs         | 27 +---------
 .../rustc_monomorphize/src/partitioning.rs    | 49 +++++++++----------
 8 files changed, 34 insertions(+), 64 deletions(-)

diff --git a/compiler/rustc_codegen_cranelift/src/driver/mod.rs b/compiler/rustc_codegen_cranelift/src/driver/mod.rs
index dbc913528f44a..fb0eed07c1971 100644
--- a/compiler/rustc_codegen_cranelift/src/driver/mod.rs
+++ b/compiler/rustc_codegen_cranelift/src/driver/mod.rs
@@ -30,7 +30,7 @@ fn predefine_mono_items<'tcx>(
                         get_function_sig(tcx, module.target_config().default_call_conv, instance);
                     let linkage = crate::linkage::get_clif_linkage(
                         mono_item,
-                        data.linkage_info.into_linkage(),
+                        data.linkage,
                         data.visibility,
                         is_compiler_builtins,
                     );
diff --git a/compiler/rustc_codegen_gcc/src/base.rs b/compiler/rustc_codegen_gcc/src/base.rs
index 844871a714671..18aa32754e1d9 100644
--- a/compiler/rustc_codegen_gcc/src/base.rs
+++ b/compiler/rustc_codegen_gcc/src/base.rs
@@ -213,7 +213,7 @@ pub fn compile_codegen_unit(
 
             let mono_items = cgu.items_in_deterministic_order(tcx);
             for &(mono_item, data) in &mono_items {
-                mono_item.predefine::<Builder<'_, '_, '_>>(&cx, data.linkage_info, data.visibility);
+                mono_item.predefine::<Builder<'_, '_, '_>>(&cx, data.linkage, data.visibility);
             }
 
             // ... and now that we have everything pre-defined, fill out those definitions.
diff --git a/compiler/rustc_codegen_llvm/src/base.rs b/compiler/rustc_codegen_llvm/src/base.rs
index 82c3cfe9aa04a..f62310bd94808 100644
--- a/compiler/rustc_codegen_llvm/src/base.rs
+++ b/compiler/rustc_codegen_llvm/src/base.rs
@@ -86,7 +86,7 @@ pub(crate) fn compile_codegen_unit(
             let cx = CodegenCx::new(tcx, cgu, &llvm_module);
             let mono_items = cx.codegen_unit.items_in_deterministic_order(cx.tcx);
             for &(mono_item, data) in &mono_items {
-                mono_item.predefine::<Builder<'_, '_, '_>>(&cx, data.linkage_info, data.visibility);
+                mono_item.predefine::<Builder<'_, '_, '_>>(&cx, data.linkage, data.visibility);
             }
 
             // ... and now that we have everything pre-defined, fill out those definitions.
diff --git a/compiler/rustc_codegen_ssa/src/back/symbol_export.rs b/compiler/rustc_codegen_ssa/src/back/symbol_export.rs
index 0321a244f8683..788a8a13b3ee4 100644
--- a/compiler/rustc_codegen_ssa/src/back/symbol_export.rs
+++ b/compiler/rustc_codegen_ssa/src/back/symbol_export.rs
@@ -283,7 +283,7 @@ fn exported_symbols_provider_local(
     }
 
     if tcx.local_crate_exports_generics() {
-        use rustc_middle::mir::mono::{MonoItem, Visibility};
+        use rustc_middle::mir::mono::{Linkage, MonoItem, Visibility};
         use rustc_middle::ty::InstanceKind;
 
         // Normally, we require that shared monomorphizations are not hidden,
@@ -298,7 +298,7 @@ fn exported_symbols_provider_local(
         // The symbols created in this loop are sorted below it
         #[allow(rustc::potential_query_instability)]
         for (mono_item, data) in cgus.iter().flat_map(|cgu| cgu.items().iter()) {
-            if !data.linkage_info.is_external() {
+            if data.linkage != Linkage::External {
                 // We can only re-use things with external linkage, otherwise
                 // we'll get a linker error
                 continue;
diff --git a/compiler/rustc_codegen_ssa/src/mir/naked_asm.rs b/compiler/rustc_codegen_ssa/src/mir/naked_asm.rs
index 359cda19b8449..0767c002c5e06 100644
--- a/compiler/rustc_codegen_ssa/src/mir/naked_asm.rs
+++ b/compiler/rustc_codegen_ssa/src/mir/naked_asm.rs
@@ -207,8 +207,6 @@ fn prefix_and_suffix<'tcx>(
             }
             writeln!(begin, "{asm_name}:").unwrap();
 
-            eprintln!("{}", &begin);
-
             writeln!(end).unwrap();
             writeln!(end, ".size {asm_name}, . - {asm_name}").unwrap();
             writeln!(end, ".popsection").unwrap();
diff --git a/compiler/rustc_codegen_ssa/src/mono_item.rs b/compiler/rustc_codegen_ssa/src/mono_item.rs
index 70ad5bee3e09c..6749bc63327e4 100644
--- a/compiler/rustc_codegen_ssa/src/mono_item.rs
+++ b/compiler/rustc_codegen_ssa/src/mono_item.rs
@@ -1,7 +1,7 @@
 use rustc_hir as hir;
 use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags;
 use rustc_middle::mir::interpret::ErrorHandled;
-use rustc_middle::mir::mono::{LinkageInfo, MonoItem, Visibility};
+use rustc_middle::mir::mono::{Linkage, MonoItem, Visibility};
 use rustc_middle::ty::Instance;
 use rustc_middle::ty::layout::{HasTyCtxt, LayoutOf};
 use rustc_middle::{span_bug, ty};
@@ -15,7 +15,7 @@ pub trait MonoItemExt<'a, 'tcx> {
     fn predefine<Bx: BuilderMethods<'a, 'tcx>>(
         &self,
         cx: &'a Bx::CodegenCx,
-        linkage_info: LinkageInfo,
+        linkage: Linkage,
         visibility: Visibility,
     );
     fn to_raw_string(&self) -> String;
@@ -117,7 +117,7 @@ impl<'a, 'tcx: 'a> MonoItemExt<'a, 'tcx> for MonoItem<'tcx> {
     fn predefine<Bx: BuilderMethods<'a, 'tcx>>(
         &self,
         cx: &'a Bx::CodegenCx,
-        linkage_info: LinkageInfo,
+        linkage: Linkage,
         visibility: Visibility,
     ) {
         debug!(
@@ -133,7 +133,7 @@ impl<'a, 'tcx: 'a> MonoItemExt<'a, 'tcx> for MonoItem<'tcx> {
 
         match *self {
             MonoItem::Static(def_id) => {
-                cx.predefine_static(def_id, linkage_info.into_linkage(), visibility, symbol_name);
+                cx.predefine_static(def_id, linkage, visibility, symbol_name);
             }
             MonoItem::Fn(instance) => {
                 let attrs = cx.tcx().codegen_fn_attrs(instance.def_id());
@@ -141,7 +141,7 @@ impl<'a, 'tcx: 'a> MonoItemExt<'a, 'tcx> for MonoItem<'tcx> {
                 if attrs.flags.contains(CodegenFnAttrFlags::NAKED) {
                     // do not define this function; it will become a global assembly block
                 } else {
-                    cx.predefine_fn(instance, linkage_info.into_linkage(), visibility, symbol_name);
+                    cx.predefine_fn(instance, linkage, visibility, symbol_name);
                 };
             }
             MonoItem::GlobalAsm(..) => {}
diff --git a/compiler/rustc_middle/src/mir/mono.rs b/compiler/rustc_middle/src/mir/mono.rs
index 01c66ecb570cb..1f50b67cb50d5 100644
--- a/compiler/rustc_middle/src/mir/mono.rs
+++ b/compiler/rustc_middle/src/mir/mono.rs
@@ -269,38 +269,13 @@ pub struct MonoItemData {
     /// `GloballyShared` maps to `false` and `LocalCopy` maps to `true`.
     pub inlined: bool,
 
-    pub linkage_info: LinkageInfo,
+    pub linkage: Linkage,
     pub visibility: Visibility,
 
     /// A cached copy of the result of `MonoItem::size_estimate`.
     pub size_estimate: usize,
 }
 
-/// Stores how we know what linkage to use
-#[derive(Copy, Clone, PartialEq, Debug, TyEncodable, TyDecodable, HashStable)]
-pub enum LinkageInfo {
-    /// The linkage was specified explicitly (e.g. using #[linkage = "..."])
-    Explicit(Linkage),
-    /// Assume the symbol may be used from other CGUs, a safe default
-    ImplicitExternal,
-    /// We did not find any uses from other CGUs, so it's fine to make this internal
-    ImplicitInternal,
-}
-
-impl LinkageInfo {
-    pub const fn is_external(self) -> bool {
-        matches!(self.into_linkage(), Linkage::External)
-    }
-
-    pub const fn into_linkage(self) -> Linkage {
-        match self {
-            Self::Explicit(linkage) => linkage,
-            Self::ImplicitExternal => Linkage::External,
-            Self::ImplicitInternal => Linkage::Internal,
-        }
-    }
-}
-
 /// Specifies the linkage type for a `MonoItem`.
 ///
 /// See <https://llvm.org/docs/LangRef.html#linkage-types> for more details about these variants.
diff --git a/compiler/rustc_monomorphize/src/partitioning.rs b/compiler/rustc_monomorphize/src/partitioning.rs
index 2fd89e389e547..7ea4ded2b052c 100644
--- a/compiler/rustc_monomorphize/src/partitioning.rs
+++ b/compiler/rustc_monomorphize/src/partitioning.rs
@@ -109,8 +109,8 @@ use rustc_middle::bug;
 use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags;
 use rustc_middle::middle::exported_symbols::{SymbolExportInfo, SymbolExportLevel};
 use rustc_middle::mir::mono::{
-    CodegenUnit, CodegenUnitNameBuilder, InstantiationMode, Linkage, LinkageInfo, MonoItem,
-    MonoItemData, Visibility,
+    CodegenUnit, CodegenUnitNameBuilder, InstantiationMode, Linkage, MonoItem, MonoItemData,
+    Visibility,
 };
 use rustc_middle::ty::print::{characteristic_def_id_of_type, with_no_trimmed_paths};
 use rustc_middle::ty::visit::TypeVisitableExt;
@@ -245,7 +245,7 @@ where
         let cgu = codegen_units.entry(cgu_name).or_insert_with(|| CodegenUnit::new(cgu_name));
 
         let mut can_be_internalized = true;
-        let (linkage_info, visibility) = mono_item_linkage_info_and_visibility(
+        let (linkage, visibility) = mono_item_linkage_and_visibility(
             cx.tcx,
             &mono_item,
             &mut can_be_internalized,
@@ -259,7 +259,7 @@ where
 
         cgu.items_mut().insert(mono_item, MonoItemData {
             inlined: false,
-            linkage_info,
+            linkage,
             visibility,
             size_estimate,
         });
@@ -278,7 +278,7 @@ where
             // This is a CGU-private copy.
             cgu.items_mut().entry(inlined_item).or_insert_with(|| MonoItemData {
                 inlined: true,
-                linkage_info: LinkageInfo::ImplicitInternal,
+                linkage: Linkage::Internal,
                 visibility: Visibility::Default,
                 size_estimate: inlined_item.size_estimate(cx.tcx),
             });
@@ -589,8 +589,7 @@ fn internalize_symbols<'tcx>(
 
             // If we got here, we did not find any uses from other CGUs, so
             // it's fine to make this monomorphization internal.
-            debug_assert_eq!(data.linkage_info, LinkageInfo::ImplicitExternal);
-            data.linkage_info = LinkageInfo::ImplicitInternal;
+            data.linkage = Linkage::Internal;
             data.visibility = Visibility::Default;
         }
     }
@@ -608,7 +607,7 @@ fn mark_code_coverage_dead_code_cgu<'tcx>(codegen_units: &mut [CodegenUnit<'tcx>
     // function symbols to be included via `-u` or `/include` linker args.
     let dead_code_cgu = codegen_units
         .iter_mut()
-        .filter(|cgu| cgu.items().iter().any(|(_, data)| data.linkage_info.is_external()))
+        .filter(|cgu| cgu.items().iter().any(|(_, data)| data.linkage == Linkage::External))
         .min_by_key(|cgu| cgu.size_estimate());
 
     // If there are no CGUs that have externally linked items, then we just
@@ -737,26 +736,24 @@ fn fallback_cgu_name(name_builder: &mut CodegenUnitNameBuilder<'_>) -> Symbol {
     name_builder.build_cgu_name(LOCAL_CRATE, &["fallback"], Some("cgu"))
 }
 
-fn mono_item_linkage_info_and_visibility<'tcx>(
+fn mono_item_linkage_and_visibility<'tcx>(
     tcx: TyCtxt<'tcx>,
     mono_item: &MonoItem<'tcx>,
     can_be_internalized: &mut bool,
     can_export_generics: bool,
     always_export_generics: bool,
-) -> (LinkageInfo, Visibility) {
+) -> (Linkage, Visibility) {
     if let Some(explicit_linkage) = mono_item.explicit_linkage(tcx) {
-        (LinkageInfo::Explicit(explicit_linkage), Visibility::Default)
-    } else {
-        let vis = mono_item_visibility(
-            tcx,
-            mono_item,
-            can_be_internalized,
-            can_export_generics,
-            always_export_generics,
-        );
-
-        (LinkageInfo::ImplicitExternal, vis)
+        return (explicit_linkage, Visibility::Default);
     }
+    let vis = mono_item_visibility(
+        tcx,
+        mono_item,
+        can_be_internalized,
+        can_export_generics,
+        always_export_generics,
+    );
+    (Linkage::External, vis)
 }
 
 type CguNameCache = UnordMap<(DefId, bool), Symbol>;
@@ -1036,7 +1033,7 @@ fn debug_dump<'a, 'tcx: 'a>(tcx: TyCtxt<'tcx>, label: &str, cgus: &[CodegenUnit<
                 writeln!(s, "  - items: {num_items}, mean size: {mean_size:.1}, sizes: {sizes}",);
 
             for (item, data) in cgu.items_in_deterministic_order(tcx) {
-                let linkage_info = data.linkage_info;
+                let linkage = data.linkage;
                 let symbol_name = item.symbol_name(tcx).name;
                 let symbol_hash_start = symbol_name.rfind('h');
                 let symbol_hash = symbol_hash_start.map_or("<no hash>", |i| &symbol_name[i..]);
@@ -1044,7 +1041,7 @@ fn debug_dump<'a, 'tcx: 'a>(tcx: TyCtxt<'tcx>, label: &str, cgus: &[CodegenUnit<
                 let size = data.size_estimate;
                 let _ = with_no_trimmed_paths!(writeln!(
                     s,
-                    "  - {item} [{linkage_info:?}] [{symbol_hash}] ({kind}, size: {size})"
+                    "  - {item} [{linkage:?}] [{symbol_hash}] ({kind}, size: {size})"
                 ));
             }
 
@@ -1197,7 +1194,7 @@ fn collect_and_partition_mono_items(tcx: TyCtxt<'_>, (): ()) -> (&DefIdSet, &[Co
 
         for cgu in codegen_units {
             for (&mono_item, &data) in cgu.items() {
-                item_to_cgus.entry(mono_item).or_default().push((cgu.name(), data.linkage_info));
+                item_to_cgus.entry(mono_item).or_default().push((cgu.name(), data.linkage));
             }
         }
 
@@ -1210,11 +1207,11 @@ fn collect_and_partition_mono_items(tcx: TyCtxt<'_>, (): ()) -> (&DefIdSet, &[Co
                 let cgus = item_to_cgus.get_mut(i).unwrap_or(&mut empty);
                 cgus.sort_by_key(|(name, _)| *name);
                 cgus.dedup();
-                for &(ref cgu_name, linkage_info) in cgus.iter() {
+                for &(ref cgu_name, linkage) in cgus.iter() {
                     output.push(' ');
                     output.push_str(cgu_name.as_str());
 
-                    let linkage_abbrev = match linkage_info.into_linkage() {
+                    let linkage_abbrev = match linkage {
                         Linkage::External => "External",
                         Linkage::AvailableExternally => "Available",
                         Linkage::LinkOnceAny => "OnceAny",

From 868668e05dca0a6516f37e6fa2bfab3526f02868 Mon Sep 17 00:00:00 2001
From: clubby789 <jamie@hill-daniel.co.uk>
Date: Mon, 25 Nov 2024 15:06:43 +0000
Subject: [PATCH 13/30] Run `cargo update` and update licenses

---
 Cargo.lock                            | 580 +++++++++++++++-----------
 compiler/rustc_codegen_ssa/Cargo.toml |   2 +-
 library/Cargo.lock                    |  12 +-
 src/tools/run-make-support/Cargo.toml |   2 +-
 src/tools/rustbook/Cargo.lock         | 443 +++++++++++++++-----
 src/tools/tidy/src/deps.rs            |   4 +-
 6 files changed, 686 insertions(+), 357 deletions(-)

diff --git a/Cargo.lock b/Cargo.lock
index 8ccf05cc5b842..89e7d70d839ae 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -57,9 +57,9 @@ dependencies = [
 
 [[package]]
 name = "allocator-api2"
-version = "0.2.18"
+version = "0.2.20"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f"
+checksum = "45862d1c77f2228b9e10bc609d5bc203d86ebc9b87ad8d5d5167a6c9abf739d9"
 
 [[package]]
 name = "ammonia"
@@ -182,9 +182,9 @@ dependencies = [
 
 [[package]]
 name = "anyhow"
-version = "1.0.92"
+version = "1.0.93"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "74f37166d7d48a0284b99dd824694c26119c700b53bf0d1540cdb147dbdaaf13"
+checksum = "4c95c10ba0b00a02636238b814946408b1322d5ac4760326e6fb8ec956d85775"
 dependencies = [
  "backtrace",
 ]
@@ -255,12 +255,6 @@ dependencies = [
  "serde",
 ]
 
-[[package]]
-name = "bitflags"
-version = "1.3.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
-
 [[package]]
 name = "bitflags"
 version = "2.6.0"
@@ -269,9 +263,9 @@ checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de"
 
 [[package]]
 name = "blake3"
-version = "1.5.4"
+version = "1.5.5"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d82033247fd8e890df8f740e407ad4d038debb9eb1f40533fffb32e7d17dc6f7"
+checksum = "b8ee0c1824c4dea5b5f81736aff91bae041d2c07ee1192bec91054e10e3e601e"
 dependencies = [
  "arrayref",
  "arrayvec",
@@ -291,12 +285,12 @@ dependencies = [
 
 [[package]]
 name = "bstr"
-version = "1.10.0"
+version = "1.11.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "40723b8fb387abc38f4f4a37c09073622e41dd12327033091ef8950659e6dc0c"
+checksum = "1a68f1f47cdf0ec8ee4b941b2eee2a80cb796db73118c0dd09ac63fbe405be22"
 dependencies = [
  "memchr",
- "regex-automata 0.4.8",
+ "regex-automata 0.4.9",
  "serde",
 ]
 
@@ -356,9 +350,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b"
 
 [[package]]
 name = "bytes"
-version = "1.8.0"
+version = "1.9.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "9ac0150caa2ae65ca5bd83f25c7de183dea78d4d366469f148435e2acfbad0da"
+checksum = "325918d6fe32f23b19878fe4b34794ae41fc19ddbe53b10571a4874d44ffd39b"
 
 [[package]]
 name = "camino"
@@ -384,9 +378,9 @@ dependencies = [
 
 [[package]]
 name = "cargo-platform"
-version = "0.1.8"
+version = "0.1.9"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "24b1f0365a6c6bb4020cd05806fd0d33c44d38046b8bd7f0e40814b9763cabfc"
+checksum = "e35af189006b9c0f00a064685c727031e3ed2d8020f7ba284d78cc2671bd36ea"
 dependencies = [
  "serde",
 ]
@@ -411,9 +405,9 @@ version = "0.1.0"
 
 [[package]]
 name = "cc"
-version = "1.2.0"
+version = "1.2.2"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1aeb932158bd710538c73702db6945cb68a8fb08c519e6e12706b94263b36db8"
+checksum = "f34d93e62b03caf570cccc334cbc6c2fceca82f39211051345108adcba3eebdc"
 dependencies = [
  "shlex",
 ]
@@ -476,9 +470,9 @@ dependencies = [
 
 [[package]]
 name = "clap"
-version = "4.5.20"
+version = "4.5.21"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b97f376d85a664d5837dbae44bf546e6477a679ff6610010f17276f686d867e8"
+checksum = "fb3b4b9e5a7c7514dfa52869339ee98b3156b0bfb4e8a77c4ff4babb64b1604f"
 dependencies = [
  "clap_builder",
  "clap_derive",
@@ -496,9 +490,9 @@ dependencies = [
 
 [[package]]
 name = "clap_builder"
-version = "4.5.20"
+version = "4.5.21"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "19bc80abd44e4bed93ca373a0704ccbd1b710dc5749406201bb018272808dc54"
+checksum = "b17a95aa67cc7b5ebd32aa5370189aa0d79069ef1c64ce893bd30fb24bff20ec"
 dependencies = [
  "anstream",
  "anstyle",
@@ -509,9 +503,9 @@ dependencies = [
 
 [[package]]
 name = "clap_complete"
-version = "4.5.36"
+version = "4.5.38"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "86bc73de94bc81e52f3bebec71bc4463e9748f7a59166663e32044669577b0e2"
+checksum = "d9647a559c112175f17cf724dc72d3645680a883c58481332779192b0d8e7a01"
 dependencies = [
  "clap",
 ]
@@ -525,14 +519,14 @@ dependencies = [
  "heck 0.5.0",
  "proc-macro2",
  "quote",
- "syn 2.0.87",
+ "syn 2.0.90",
 ]
 
 [[package]]
 name = "clap_lex"
-version = "0.7.2"
+version = "0.7.3"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1462739cb27611015575c0c11df5df7601141071f07518d56fcc1be504cbec97"
+checksum = "afb84c814227b90d6895e01398aee0d8033c00e7466aca416fb6a8e0eb19d8a7"
 
 [[package]]
 name = "clippy"
@@ -556,7 +550,7 @@ dependencies = [
  "rustc_tools_util",
  "serde",
  "serde_json",
- "syn 2.0.87",
+ "syn 2.0.90",
  "tempfile",
  "termize",
  "tokio",
@@ -650,23 +644,23 @@ dependencies = [
 
 [[package]]
 name = "color-print"
-version = "0.3.6"
+version = "0.3.7"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1ee543c60ff3888934877a5671f45494dd27ed4ba25c6670b9a7576b7ed7a8c0"
+checksum = "3aa954171903797d5623e047d9ab69d91b493657917bdfb8c2c80ecaf9cdb6f4"
 dependencies = [
  "color-print-proc-macro",
 ]
 
 [[package]]
 name = "color-print-proc-macro"
-version = "0.3.6"
+version = "0.3.7"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "77ff1a80c5f3cb1ca7c06ffdd71b6a6dd6d8f896c42141fbd43f50ed28dcdb93"
+checksum = "692186b5ebe54007e45a59aea47ece9eb4108e141326c304cdc91699a7118a22"
 dependencies = [
  "nom",
  "proc-macro2",
  "quote",
- "syn 2.0.87",
+ "syn 2.0.90",
 ]
 
 [[package]]
@@ -770,9 +764,9 @@ dependencies = [
 
 [[package]]
 name = "cpufeatures"
-version = "0.2.14"
+version = "0.2.16"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "608697df725056feaccfa42cffdaeeec3fccc4ffc38358ecd19b243e716a78e0"
+checksum = "16b80225097f2e5ae4e7179dd2266824648f3e2f49d9134d584b76389d31c4c3"
 dependencies = [
  "libc",
 ]
@@ -857,9 +851,9 @@ dependencies = [
 
 [[package]]
 name = "curl-sys"
-version = "0.4.77+curl-8.10.1"
+version = "0.4.78+curl-8.11.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f469e8a5991f277a208224f6c7ad72ecb5f986e36d09ae1f2c1bb9259478a480"
+checksum = "8eec768341c5c7789611ae51cf6c459099f22e64a5d5d0ce4892434e33821eaf"
 dependencies = [
  "cc",
  "libc",
@@ -891,7 +885,7 @@ dependencies = [
  "proc-macro2",
  "quote",
  "strsim",
- "syn 2.0.87",
+ "syn 2.0.90",
 ]
 
 [[package]]
@@ -902,7 +896,7 @@ checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806"
 dependencies = [
  "darling_core",
  "quote",
- "syn 2.0.87",
+ "syn 2.0.90",
 ]
 
 [[package]]
@@ -939,7 +933,7 @@ checksum = "62d671cc41a825ebabc75757b62d3d168c577f9149b2d49ece1dad1f72119d25"
 dependencies = [
  "proc-macro2",
  "quote",
- "syn 2.0.87",
+ "syn 2.0.90",
 ]
 
 [[package]]
@@ -960,7 +954,7 @@ dependencies = [
  "darling",
  "proc-macro2",
  "quote",
- "syn 2.0.87",
+ "syn 2.0.90",
 ]
 
 [[package]]
@@ -970,7 +964,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "ab63b0e2bf4d5928aff72e83a7dace85d7bba5fe12dcc3c5a572d78caffd3f3c"
 dependencies = [
  "derive_builder_core",
- "syn 2.0.87",
+ "syn 2.0.90",
 ]
 
 [[package]]
@@ -982,7 +976,7 @@ dependencies = [
  "darling",
  "proc-macro2",
  "quote",
- "syn 2.0.87",
+ "syn 2.0.90",
 ]
 
 [[package]]
@@ -1060,7 +1054,7 @@ checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0"
 dependencies = [
  "proc-macro2",
  "quote",
- "syn 2.0.87",
+ "syn 2.0.90",
 ]
 
 [[package]]
@@ -1142,12 +1136,12 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5"
 
 [[package]]
 name = "errno"
-version = "0.3.9"
+version = "0.3.10"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba"
+checksum = "33d852cb9b869c2a9b3df2f71a3074817f01e1844f839a144f5fcef059a4eb5d"
 dependencies = [
  "libc",
- "windows-sys 0.52.0",
+ "windows-sys 0.59.0",
 ]
 
 [[package]]
@@ -1185,9 +1179,9 @@ checksum = "2acce4a10f12dc2fb14a218589d4f1f62ef011b2d0cc4b3cb1bba8e94da14649"
 
 [[package]]
 name = "fastrand"
-version = "2.1.1"
+version = "2.2.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e8c02a5121d4ea3eb16a80748c74f5549a5665e4c21333c6098f283870fbdea6"
+checksum = "486f806e73c5707928240ddc295403b1b93c96a02038563881c4a2fd84b81ac4"
 
 [[package]]
 name = "field-offset"
@@ -1213,9 +1207,9 @@ dependencies = [
 
 [[package]]
 name = "flate2"
-version = "1.0.34"
+version = "1.0.35"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a1b589b4dc103969ad3cf85c950899926ec64300a1a46d76c03a6072957036f0"
+checksum = "c936bfdafb507ebbf50b8074c54fa31c5be9a1e7e5f467dd659697041407d07c"
 dependencies = [
  "crc32fast",
  "miniz_oxide 0.8.0",
@@ -1357,7 +1351,7 @@ checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650"
 dependencies = [
  "proc-macro2",
  "quote",
- "syn 2.0.87",
+ "syn 2.0.90",
 ]
 
 [[package]]
@@ -1482,7 +1476,7 @@ dependencies = [
  "aho-corasick",
  "bstr",
  "log",
- "regex-automata 0.4.8",
+ "regex-automata 0.4.9",
  "regex-syntax 0.8.5",
 ]
 
@@ -1497,11 +1491,12 @@ dependencies = [
 
 [[package]]
 name = "handlebars"
-version = "5.1.2"
+version = "6.2.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d08485b96a0e6393e9e4d1b8d48cf74ad6c063cd905eb33f42c1ce3f0377539b"
+checksum = "fd4ccde012831f9a071a637b0d4e31df31c0f6c525784b35ae76a9ac6bc1e315"
 dependencies = [
  "log",
+ "num-order",
  "pest",
  "pest_derive",
  "serde",
@@ -1522,9 +1517,9 @@ dependencies = [
 
 [[package]]
 name = "hashbrown"
-version = "0.15.0"
+version = "0.15.2"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1e087f84d4f86bf4b218b927129862374b72199ae7d8657835f1e89000eea4fb"
+checksum = "bf151400ff0baff5465007dd2f3e717f3fe502074ca563069ce3a6629d07b289"
 dependencies = [
  "foldhash",
 ]
@@ -1590,7 +1585,7 @@ dependencies = [
  "markup5ever",
  "proc-macro2",
  "quote",
- "syn 2.0.87",
+ "syn 2.0.90",
 ]
 
 [[package]]
@@ -1631,6 +1626,18 @@ dependencies = [
  "cc",
 ]
 
+[[package]]
+name = "icu_collections"
+version = "1.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "db2fa452206ebee18c4b5c2274dbf1de17008e874b4dc4f0aea9d01ca79e4526"
+dependencies = [
+ "displaydoc",
+ "yoke",
+ "zerofrom",
+ "zerovec",
+]
+
 [[package]]
 name = "icu_list"
 version = "1.5.0"
@@ -1684,6 +1691,51 @@ version = "1.5.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "fdc8ff3388f852bede6b579ad4e978ab004f139284d7b28715f773507b946f6e"
 
+[[package]]
+name = "icu_normalizer"
+version = "1.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "19ce3e0da2ec68599d193c93d088142efd7f9c5d6fc9b803774855747dc6a84f"
+dependencies = [
+ "displaydoc",
+ "icu_collections",
+ "icu_normalizer_data",
+ "icu_properties",
+ "icu_provider",
+ "smallvec",
+ "utf16_iter",
+ "utf8_iter",
+ "write16",
+ "zerovec",
+]
+
+[[package]]
+name = "icu_normalizer_data"
+version = "1.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f8cafbf7aa791e9b22bec55a167906f9e1215fd475cd22adfcf660e03e989516"
+
+[[package]]
+name = "icu_properties"
+version = "1.5.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "93d6020766cfc6302c15dbbc9c8778c37e62c14427cb7f6e601d849e092aeef5"
+dependencies = [
+ "displaydoc",
+ "icu_collections",
+ "icu_locid_transform",
+ "icu_properties_data",
+ "icu_provider",
+ "tinystr",
+ "zerovec",
+]
+
+[[package]]
+name = "icu_properties_data"
+version = "1.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "67a8effbc3dd3e4ba1afa8ad918d5684b8868b3b26500753effea8d2eed19569"
+
 [[package]]
 name = "icu_provider"
 version = "1.5.0"
@@ -1722,7 +1774,7 @@ checksum = "1ec89e9337638ecdc08744df490b221a7399bf8d164eb52a665454e60e075ad6"
 dependencies = [
  "proc-macro2",
  "quote",
- "syn 2.0.87",
+ "syn 2.0.90",
 ]
 
 [[package]]
@@ -1739,12 +1791,23 @@ checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39"
 
 [[package]]
 name = "idna"
-version = "0.5.0"
+version = "1.0.3"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6"
+checksum = "686f825264d630750a544639377bae737628043f20d38bbc029e8f29ea968a7e"
 dependencies = [
- "unicode-bidi",
- "unicode-normalization",
+ "idna_adapter",
+ "smallvec",
+ "utf8_iter",
+]
+
+[[package]]
+name = "idna_adapter"
+version = "1.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "daca1df1c957320b2cf139ac61e7bd64fed304c5040df000a745aa1de3b4ef71"
+dependencies = [
+ "icu_normalizer",
+ "icu_properties",
 ]
 
 [[package]]
@@ -1763,7 +1826,7 @@ dependencies = [
  "globset",
  "log",
  "memchr",
- "regex-automata 0.4.8",
+ "regex-automata 0.4.9",
  "same-file",
  "walkdir",
  "winapi-util",
@@ -1777,27 +1840,27 @@ checksum = "ce23b50ad8242c51a442f3ff322d56b02f08852c77e4c0b4d3fd684abc89c683"
 
 [[package]]
 name = "indexmap"
-version = "2.6.0"
+version = "2.7.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "707907fe3c25f5424cce2cb7e1cbcafee6bdbe735ca90ef77c29e84591e5b9da"
+checksum = "62f822373a4fe84d4bb149bf54e584a7f4abec90e072ed49cda0edea5b95471f"
 dependencies = [
  "equivalent",
- "hashbrown 0.15.0",
+ "hashbrown 0.15.2",
  "rustc-rayon",
  "serde",
 ]
 
 [[package]]
 name = "indicatif"
-version = "0.17.8"
+version = "0.17.9"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "763a5a8f45087d6bcea4222e7b72c291a054edf80e4ef6efd2a4979878c7bea3"
+checksum = "cbf675b85ed934d3c67b5c5469701eec7db22689d0a2139d856e0925fa28b281"
 dependencies = [
  "console",
- "instant",
  "number_prefix",
  "portable-atomic",
- "unicode-width 0.1.14",
+ "unicode-width 0.2.0",
+ "web-time",
 ]
 
 [[package]]
@@ -1828,15 +1891,6 @@ dependencies = [
  "xz2",
 ]
 
-[[package]]
-name = "instant"
-version = "0.1.13"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e0242819d153cba4b4b05a5a8f2a7e9bbf97b6055b2a002b395c96b5ff3c0222"
-dependencies = [
- "cfg-if",
-]
-
 [[package]]
 name = "intl-memoizer"
 version = "0.5.2"
@@ -1873,9 +1927,9 @@ dependencies = [
 
 [[package]]
 name = "itoa"
-version = "1.0.11"
+version = "1.0.14"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b"
+checksum = "d75a2a4b1b190afb6f5425f10f6a8f959d2ea0b9c2b1d79553551850539e4674"
 
 [[package]]
 name = "jemalloc-sys"
@@ -1898,10 +1952,11 @@ dependencies = [
 
 [[package]]
 name = "js-sys"
-version = "0.3.72"
+version = "0.3.74"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6a88f1bda2bd75b0452a14784937d796722fdebfe50df998aeb3f0b7603019a9"
+checksum = "a865e038f7f6ed956f788f0d7d60c541fff74c7bd74272c5d4cf15c63743e705"
 dependencies = [
+ "once_cell",
  "wasm-bindgen",
 ]
 
@@ -1924,7 +1979,7 @@ dependencies = [
  "anyhow",
  "clap",
  "fs-err",
- "rustc-hash 2.0.0",
+ "rustc-hash 2.1.0",
  "rustdoc-json-types",
  "serde",
  "serde_json",
@@ -1967,9 +2022,9 @@ checksum = "baff4b617f7df3d896f97fe922b64817f6cd9a756bb81d40f8883f2f66dcb401"
 
 [[package]]
 name = "libc"
-version = "0.2.164"
+version = "0.2.167"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "433bfe06b8c75da9b2e3fbea6e5329ff87748f0b144ef75306e674c3f6f7c13f"
+checksum = "09d6582e104315a817dff97f75133544b2e094ee22447d2acf4a74e189ba06fc"
 
 [[package]]
 name = "libdbus-sys"
@@ -2002,9 +2057,9 @@ dependencies = [
 
 [[package]]
 name = "libloading"
-version = "0.8.5"
+version = "0.8.6"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4979f22fdb869068da03c9f7528f8297c6fd2606bc3a4affe42e6a823fdb8da4"
+checksum = "fc2f4eb4bc735547cfed7c0a4922cbd04a4655978c09b54f1f7b228750664c34"
 dependencies = [
  "cfg-if",
  "windows-targets 0.52.6",
@@ -2022,7 +2077,7 @@ version = "0.1.3"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d"
 dependencies = [
- "bitflags 2.6.0",
+ "bitflags",
  "libc",
  "redox_syscall",
 ]
@@ -2064,9 +2119,9 @@ checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89"
 
 [[package]]
 name = "litemap"
-version = "0.7.3"
+version = "0.7.4"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "643cb0b8d4fcc284004d5fd0d67ccf61dfffadb7f75e1e71bc420f4688a3a704"
+checksum = "4ee93343901ab17bd981295f2cf0026d4ad018c7c31ba84549a4ddbb47a45104"
 
 [[package]]
 name = "lld-wrapper"
@@ -2157,9 +2212,9 @@ dependencies = [
 
 [[package]]
 name = "mdbook"
-version = "0.4.40"
+version = "0.4.43"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b45a38e19bd200220ef07c892b0157ad3d2365e5b5a267ca01ad12182491eea5"
+checksum = "fe1f98b8d66e537d2f0ba06e7dec4f44001deec539a2d18bfc102d6a86189148"
 dependencies = [
  "ammonia",
  "anyhow",
@@ -2317,7 +2372,7 @@ version = "0.29.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "71e2746dc3a24dd78b3cfcb7be93368c6de9963d30f43a6a73998a9cf4b17b46"
 dependencies = [
- "bitflags 2.6.0",
+ "bitflags",
  "cfg-if",
  "cfg_aliases",
  "libc",
@@ -2420,6 +2475,21 @@ dependencies = [
  "num-traits",
 ]
 
+[[package]]
+name = "num-modular"
+version = "0.6.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "17bb261bf36fa7d83f4c294f834e91256769097b3cb505d44831e0a179ac647f"
+
+[[package]]
+name = "num-order"
+version = "1.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "537b596b97c40fcf8056d153049eb22f481c17ebce72a513ec9286e4986d1bb6"
+dependencies = [
+ "num-modular",
+]
+
 [[package]]
 name = "num-rational"
 version = "0.4.2"
@@ -2473,7 +2543,7 @@ checksum = "aedf0a2d09c573ed1d8d85b30c119153926a2b36dce0ab28322c09a117a4683e"
 dependencies = [
  "crc32fast",
  "flate2",
- "hashbrown 0.15.0",
+ "hashbrown 0.15.2",
  "indexmap",
  "memchr",
  "ruzstd",
@@ -2621,9 +2691,9 @@ dependencies = [
 
 [[package]]
 name = "pathdiff"
-version = "0.2.2"
+version = "0.2.3"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d61c5ce1153ab5b689d0c074c4e7fc613e942dfb7dd9eea5ab202d2ad91fe361"
+checksum = "df94ce210e5bc13cb6651479fa48d14f601d9858cfe0467f43ae157023b938d3"
 
 [[package]]
 name = "percent-encoding"
@@ -2671,7 +2741,7 @@ dependencies = [
  "pest_meta",
  "proc-macro2",
  "quote",
- "syn 2.0.87",
+ "syn 2.0.90",
 ]
 
 [[package]]
@@ -2773,9 +2843,9 @@ dependencies = [
 
 [[package]]
 name = "portable-atomic"
-version = "1.9.0"
+version = "1.10.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "cc9c68a3f6da06753e9335d63e27f6b9754dd1920d941135b7ea8224f141adb2"
+checksum = "280dc24453071f1b63954171985a0b0d30058d287960968b9b2aca264c8d4ee6"
 
 [[package]]
 name = "powerfmt"
@@ -2816,18 +2886,18 @@ checksum = "dc375e1527247fe1a97d8b7156678dfe7c1af2fc075c9a4db3690ecd2a148068"
 
 [[package]]
 name = "proc-macro2"
-version = "1.0.89"
+version = "1.0.92"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f139b0662de085916d1fb67d2b4169d1addddda1919e696f3252b740b629986e"
+checksum = "37d3544b3f2748c54e147655edb5025752e2303145b5aefb3c3ea2c78b973bb0"
 dependencies = [
  "unicode-ident",
 ]
 
 [[package]]
 name = "psm"
-version = "0.1.23"
+version = "0.1.24"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "aa37f80ca58604976033fae9515a8a2989fc13797d953f7c04fb8fa36a11f205"
+checksum = "200b9ff220857e53e184257720a14553b2f4aa02577d2ed9842d45d4b9654810"
 dependencies = [
  "cc",
 ]
@@ -2838,7 +2908,7 @@ version = "0.9.6"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "57206b407293d2bcd3af849ce869d52068623f19e1b5ff8e8778e3309439682b"
 dependencies = [
- "bitflags 2.6.0",
+ "bitflags",
  "memchr",
  "unicase",
 ]
@@ -2849,7 +2919,7 @@ version = "0.10.3"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "76979bea66e7875e7509c4ec5300112b316af87fa7a252ca91c448b32dfe3993"
 dependencies = [
- "bitflags 2.6.0",
+ "bitflags",
  "memchr",
  "pulldown-cmark-escape 0.10.1",
  "unicase",
@@ -2861,7 +2931,7 @@ version = "0.11.3"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "679341d22c78c6c649893cbd6c3278dcbe9fc4faa62fea3a9296ae2b50c14625"
 dependencies = [
- "bitflags 2.6.0",
+ "bitflags",
  "memchr",
  "pulldown-cmark-escape 0.11.0",
  "unicase",
@@ -2965,7 +3035,7 @@ version = "0.5.7"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "9b6dfecf2c74bce2466cabf93f6664d6998a69eb21e39f4207930065b27b771f"
 dependencies = [
- "bitflags 2.6.0",
+ "bitflags",
 ]
 
 [[package]]
@@ -2987,7 +3057,7 @@ checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191"
 dependencies = [
  "aho-corasick",
  "memchr",
- "regex-automata 0.4.8",
+ "regex-automata 0.4.9",
  "regex-syntax 0.8.5",
 ]
 
@@ -3011,9 +3081,9 @@ dependencies = [
 
 [[package]]
 name = "regex-automata"
-version = "0.4.8"
+version = "0.4.9"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "368758f23274712b504848e9d5a6f010445cc8b87a7cdb4d7cbee666c1288da3"
+checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908"
 dependencies = [
  "aho-corasick",
  "memchr",
@@ -3079,9 +3149,9 @@ dependencies = [
  "proc-macro2",
  "quote",
  "rinja_parser",
- "rustc-hash 2.0.0",
+ "rustc-hash 2.1.0",
  "serde",
- "syn 2.0.87",
+ "syn 2.0.90",
 ]
 
 [[package]]
@@ -3114,7 +3184,7 @@ dependencies = [
  "regex",
  "serde_json",
  "similar",
- "wasmparser 0.216.0",
+ "wasmparser 0.219.1",
 ]
 
 [[package]]
@@ -3143,9 +3213,9 @@ checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
 
 [[package]]
 name = "rustc-hash"
-version = "2.0.0"
+version = "2.1.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "583034fd73374156e66797ed8e5b0d5690409c9226b22d87cb7f19821c05d152"
+checksum = "c7fb8039b3032c191086b10f11f319a6e99e1e82889c5cc6046f515c9db1d497"
 
 [[package]]
 name = "rustc-main"
@@ -3210,7 +3280,7 @@ version = "1.0.1"
 name = "rustc_abi"
 version = "0.0.0"
 dependencies = [
- "bitflags 2.6.0",
+ "bitflags",
  "rand",
  "rand_xoshiro",
  "rustc_data_structures",
@@ -3224,11 +3294,11 @@ dependencies = [
 
 [[package]]
 name = "rustc_apfloat"
-version = "0.2.1+llvm-462a31f5a5ab"
+version = "0.2.2+llvm-462a31f5a5ab"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "886d94c63c812a8037c4faca2607453a0fa4cf82f734665266876b022244543f"
+checksum = "121e2195ff969977a4e2b5c9965ea867fce7e4cb5aee5b09dee698a7932d574f"
 dependencies = [
- "bitflags 1.3.2",
+ "bitflags",
  "smallvec",
 ]
 
@@ -3243,7 +3313,7 @@ dependencies = [
 name = "rustc_ast"
 version = "0.0.0"
 dependencies = [
- "bitflags 2.6.0",
+ "bitflags",
  "memchr",
  "rustc_ast_ir",
  "rustc_data_structures",
@@ -3406,7 +3476,7 @@ dependencies = [
 name = "rustc_codegen_llvm"
 version = "0.0.0"
 dependencies = [
- "bitflags 2.6.0",
+ "bitflags",
  "itertools",
  "libc",
  "measureme",
@@ -3444,7 +3514,7 @@ version = "0.0.0"
 dependencies = [
  "ar_archive_writer",
  "arrayvec",
- "bitflags 2.6.0",
+ "bitflags",
  "cc",
  "either",
  "itertools",
@@ -3481,7 +3551,7 @@ dependencies = [
  "thin-vec",
  "thorin-dwp",
  "tracing",
- "wasm-encoder 0.216.0",
+ "wasm-encoder 0.219.1",
  "windows",
 ]
 
@@ -3516,7 +3586,7 @@ name = "rustc_data_structures"
 version = "0.0.0"
 dependencies = [
  "arrayvec",
- "bitflags 2.6.0",
+ "bitflags",
  "either",
  "elsa",
  "ena",
@@ -3527,7 +3597,7 @@ dependencies = [
  "memmap2",
  "parking_lot",
  "portable-atomic",
- "rustc-hash 2.0.0",
+ "rustc-hash 2.1.0",
  "rustc-rayon",
  "rustc-stable-hash",
  "rustc_arena",
@@ -3700,7 +3770,7 @@ dependencies = [
  "fluent-syntax",
  "proc-macro2",
  "quote",
- "syn 2.0.87",
+ "syn 2.0.90",
  "unic-langid",
 ]
 
@@ -3834,7 +3904,7 @@ version = "0.0.0"
 dependencies = [
  "proc-macro2",
  "quote",
- "syn 2.0.87",
+ "syn 2.0.90",
 ]
 
 [[package]]
@@ -3982,7 +4052,7 @@ version = "0.0.0"
 dependencies = [
  "proc-macro2",
  "quote",
- "syn 2.0.87",
+ "syn 2.0.90",
  "synstructure",
 ]
 
@@ -3990,7 +4060,7 @@ dependencies = [
 name = "rustc_metadata"
 version = "0.0.0"
 dependencies = [
- "bitflags 2.6.0",
+ "bitflags",
  "libc",
  "libloading",
  "odht",
@@ -4021,7 +4091,7 @@ dependencies = [
 name = "rustc_middle"
 version = "0.0.0"
 dependencies = [
- "bitflags 2.6.0",
+ "bitflags",
  "derive-where",
  "either",
  "field-offset",
@@ -4172,7 +4242,7 @@ dependencies = [
 name = "rustc_parse"
 version = "0.0.0"
 dependencies = [
- "bitflags 2.6.0",
+ "bitflags",
  "rustc_ast",
  "rustc_ast_pretty",
  "rustc_data_structures",
@@ -4229,7 +4299,7 @@ dependencies = [
 name = "rustc_pattern_analysis"
 version = "0.0.0"
 dependencies = [
- "rustc-hash 2.0.0",
+ "rustc-hash 2.1.0",
  "rustc_abi",
  "rustc_apfloat",
  "rustc_arena",
@@ -4312,7 +4382,7 @@ dependencies = [
 name = "rustc_resolve"
 version = "0.0.0"
 dependencies = [
- "bitflags 2.6.0",
+ "bitflags",
  "pulldown-cmark 0.11.3",
  "rustc_arena",
  "rustc_ast",
@@ -4340,7 +4410,7 @@ dependencies = [
 name = "rustc_sanitizers"
 version = "0.0.0"
 dependencies = [
- "bitflags 2.6.0",
+ "bitflags",
  "rustc_abi",
  "rustc_data_structures",
  "rustc_hir",
@@ -4367,7 +4437,7 @@ dependencies = [
 name = "rustc_session"
 version = "0.0.0"
 dependencies = [
- "bitflags 2.6.0",
+ "bitflags",
  "getopts",
  "libc",
  "rustc_abi",
@@ -4448,7 +4518,7 @@ dependencies = [
 name = "rustc_target"
 version = "0.0.0"
 dependencies = [
- "bitflags 2.6.0",
+ "bitflags",
  "object 0.36.5",
  "rustc_abi",
  "rustc_data_structures",
@@ -4549,7 +4619,7 @@ dependencies = [
 name = "rustc_type_ir"
 version = "0.0.0"
 dependencies = [
- "bitflags 2.6.0",
+ "bitflags",
  "derive-where",
  "indexmap",
  "rustc-hash 1.1.0",
@@ -4571,7 +4641,7 @@ version = "0.0.0"
 dependencies = [
  "proc-macro2",
  "quote",
- "syn 2.0.87",
+ "syn 2.0.90",
  "synstructure",
 ]
 
@@ -4625,7 +4695,7 @@ name = "rustdoc-json-types"
 version = "0.1.0"
 dependencies = [
  "bincode",
- "rustc-hash 2.0.0",
+ "rustc-hash 2.1.0",
  "serde",
  "serde_json",
 ]
@@ -4660,7 +4730,7 @@ dependencies = [
  "proc-macro2",
  "quote",
  "serde",
- "syn 2.0.87",
+ "syn 2.0.90",
 ]
 
 [[package]]
@@ -4694,11 +4764,11 @@ dependencies = [
 
 [[package]]
 name = "rustix"
-version = "0.38.38"
+version = "0.38.41"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "aa260229e6538e52293eeb577aabd09945a09d6d9cc0fc550ed7529056c2e32a"
+checksum = "d7f649912bc1495e167a6edee79151c84b1bad49748cb4f1f1167f459f6224f6"
 dependencies = [
- "bitflags 2.6.0",
+ "bitflags",
  "errno",
  "libc",
  "linux-raw-sys",
@@ -4737,9 +4807,9 @@ dependencies = [
 
 [[package]]
 name = "schannel"
-version = "0.1.26"
+version = "0.1.27"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "01227be5826fa0690321a2ba6c5cd57a19cf3f6a09e76973b58e61de6ab9d1c1"
+checksum = "1f29ebaa345f945cec9fbbc532eb307f0fdad8161f281b6369539c8d84876b3d"
 dependencies = [
  "windows-sys 0.59.0",
 ]
@@ -4782,29 +4852,29 @@ dependencies = [
 
 [[package]]
 name = "serde"
-version = "1.0.214"
+version = "1.0.215"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f55c3193aca71c12ad7890f1785d2b73e1b9f63a0bbc353c08ef26fe03fc56b5"
+checksum = "6513c1ad0b11a9376da888e3e0baa0077f1aed55c17f50e7b2397136129fb88f"
 dependencies = [
  "serde_derive",
 ]
 
 [[package]]
 name = "serde_derive"
-version = "1.0.214"
+version = "1.0.215"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "de523f781f095e28fa605cdce0f8307e451cc0fd14e2eb4cd2e98a355b147766"
+checksum = "ad1e866f866923f252f05c889987993144fb74e722403468a4ebd70c3cd756c0"
 dependencies = [
  "proc-macro2",
  "quote",
- "syn 2.0.87",
+ "syn 2.0.90",
 ]
 
 [[package]]
 name = "serde_json"
-version = "1.0.132"
+version = "1.0.133"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d726bfaff4b320266d395898905d0eba0345aae23b54aee3a737e260fd46db03"
+checksum = "c7fceb2473b9166b2294ef05efcb65a3db80803f0b03ef86a5fc88a2b85ee377"
 dependencies = [
  "indexmap",
  "itoa",
@@ -4894,9 +4964,9 @@ checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67"
 
 [[package]]
 name = "socket2"
-version = "0.5.7"
+version = "0.5.8"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ce305eb0b4296696835b71df73eb912e0f1ffd2556a501fcede6e0c50349191c"
+checksum = "c970269d99b64e60ec3bd6ad27270092a5394c4e309314b18ae3fe575695fbe8"
 dependencies = [
  "libc",
  "windows-sys 0.52.0",
@@ -4914,9 +4984,9 @@ dependencies = [
 
 [[package]]
 name = "spdx"
-version = "0.10.6"
+version = "0.10.7"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "47317bbaf63785b53861e1ae2d11b80d6b624211d42cb20efcd210ee6f8a14bc"
+checksum = "bae30cc7bfe3656d60ee99bf6836f472b0c53dddcbf335e253329abb16e535a2"
 dependencies = [
  "smallvec",
 ]
@@ -5055,9 +5125,9 @@ dependencies = [
 
 [[package]]
 name = "syn"
-version = "2.0.87"
+version = "2.0.90"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "25aa4ce346d03a6dcd68dd8b4010bcb74e54e62c90c573f394c46eae99aba32d"
+checksum = "919d3b74a5dd0ccd15aeb8f93e7006bd9e14c295087c9896a110f490752bcf31"
 dependencies = [
  "proc-macro2",
  "quote",
@@ -5072,7 +5142,7 @@ checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971"
 dependencies = [
  "proc-macro2",
  "quote",
- "syn 2.0.87",
+ "syn 2.0.90",
 ]
 
 [[package]]
@@ -5109,9 +5179,9 @@ dependencies = [
 
 [[package]]
 name = "tempfile"
-version = "3.13.0"
+version = "3.14.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f0f2c9fc62d0beef6951ccffd757e241266a2c833136efbe35af6cd2567dca5b"
+checksum = "28cce251fcbc87fac86a866eeb0d6c2d536fc16d06f184bb61aeae11aa4cee0c"
 dependencies = [
  "cfg-if",
  "fastrand",
@@ -5153,9 +5223,9 @@ dependencies = [
 
 [[package]]
 name = "terminal_size"
-version = "0.4.0"
+version = "0.4.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4f599bd7ca042cfdf8f4512b277c02ba102247820f9d9d4a9f521f496751a6ef"
+checksum = "5352447f921fda68cf61b4101566c0bdb5104eff6804d0678e5227580ab6a4e9"
 dependencies = [
  "rustix",
  "windows-sys 0.59.0",
@@ -5190,22 +5260,22 @@ checksum = "a38c90d48152c236a3ab59271da4f4ae63d678c5d7ad6b7714d7cb9760be5e4b"
 
 [[package]]
 name = "thiserror"
-version = "1.0.66"
+version = "1.0.69"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5d171f59dbaa811dbbb1aee1e73db92ec2b122911a48e1390dfe327a821ddede"
+checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52"
 dependencies = [
  "thiserror-impl",
 ]
 
 [[package]]
 name = "thiserror-impl"
-version = "1.0.66"
+version = "1.0.69"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b08be0f17bd307950653ce45db00cd31200d82b624b36e181337d9c7d92765b5"
+checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1"
 dependencies = [
  "proc-macro2",
  "quote",
- "syn 2.0.87",
+ "syn 2.0.90",
 ]
 
 [[package]]
@@ -5249,7 +5319,7 @@ dependencies = [
  "ignore",
  "miropt-test-tools",
  "regex",
- "rustc-hash 2.0.0",
+ "rustc-hash 2.1.0",
  "semver",
  "similar",
  "termcolor",
@@ -5318,9 +5388,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20"
 
 [[package]]
 name = "tokio"
-version = "1.41.0"
+version = "1.41.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "145f3413504347a2be84393cc8a7d2fb4d863b375909ea59f2158261aa258bbb"
+checksum = "22cfb5bee7a6a52939ca9224d6ac897bb669134078daa8735560897f69de4d33"
 dependencies = [
  "backtrace",
  "bytes",
@@ -5390,13 +5460,13 @@ dependencies = [
 
 [[package]]
 name = "tracing-attributes"
-version = "0.1.27"
+version = "0.1.28"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7"
+checksum = "395ae124c09f9e6918a2310af6038fba074bcf474ac352496d5910dd59a2226d"
 dependencies = [
  "proc-macro2",
  "quote",
- "syn 2.0.87",
+ "syn 2.0.90",
 ]
 
 [[package]]
@@ -5411,9 +5481,9 @@ dependencies = [
 
 [[package]]
 name = "tracing-error"
-version = "0.2.0"
+version = "0.2.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d686ec1c0f384b1277f097b2f279a2ecc11afe8c133c1aabf036a27cb4cd206e"
+checksum = "8b1581020d7a273442f5b45074a6a57d5757ad0a47dac0e9f0bd57b81936f3db"
 dependencies = [
  "tracing",
  "tracing-subscriber",
@@ -5567,7 +5637,7 @@ checksum = "1ed7f4237ba393424195053097c1516bd4590dc82b84f2f97c5c69e12704555b"
 dependencies = [
  "proc-macro-hack",
  "quote",
- "syn 2.0.87",
+ "syn 2.0.90",
  "unic-langid-impl",
 ]
 
@@ -5577,17 +5647,11 @@ version = "2.8.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "7e51b68083f157f853b6379db119d1c1be0e6e4dec98101079dec41f6f5cf6df"
 
-[[package]]
-name = "unicode-bidi"
-version = "0.3.17"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5ab17db44d7388991a428b2ee655ce0c212e862eff1768a455c58f9aad6e7893"
-
 [[package]]
 name = "unicode-ident"
-version = "1.0.13"
+version = "1.0.14"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe"
+checksum = "adb9e6ca4f869e1180728b7950e35922a7fc6397f7b641499e8f3ef06e50dc83"
 
 [[package]]
 name = "unicode-normalization"
@@ -5670,9 +5734,9 @@ dependencies = [
 
 [[package]]
 name = "url"
-version = "2.5.2"
+version = "2.5.4"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "22784dbdf76fdde8af1aeda5622b546b422b6fc585325248a2bf9f5e41e94d6c"
+checksum = "32f8b686cadd1473f4bd0117a5d28d36b1ade384ea9b5069a1c40aefed7fda60"
 dependencies = [
  "form_urlencoded",
  "idna",
@@ -5685,12 +5749,24 @@ version = "0.7.6"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9"
 
+[[package]]
+name = "utf16_iter"
+version = "1.0.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c8232dd3cdaed5356e0f716d285e4b40b932ac434100fe9b7e0e8e935b9e6246"
+
 [[package]]
 name = "utf8-width"
 version = "0.1.7"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "86bd8d4e895da8537e5315b8254664e6b769c4ff3db18321b297a1e7004392e3"
 
+[[package]]
+name = "utf8_iter"
+version = "1.0.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be"
+
 [[package]]
 name = "utf8parse"
 version = "0.2.2"
@@ -5748,9 +5824,9 @@ checksum = "0f76d9fa52234153eeb40b088de91a8c13dc28a912cf6f31cd89ca4bac9024e0"
 
 [[package]]
 name = "wasm-bindgen"
-version = "0.2.95"
+version = "0.2.97"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "128d1e363af62632b8eb57219c8fd7877144af57558fb2ef0368d0087bddeb2e"
+checksum = "d15e63b4482863c109d70a7b8706c1e364eb6ea449b201a76c5b89cedcec2d5c"
 dependencies = [
  "cfg-if",
  "once_cell",
@@ -5759,24 +5835,24 @@ dependencies = [
 
 [[package]]
 name = "wasm-bindgen-backend"
-version = "0.2.95"
+version = "0.2.97"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "cb6dd4d3ca0ddffd1dd1c9c04f94b868c37ff5fac97c30b97cff2d74fce3a358"
+checksum = "8d36ef12e3aaca16ddd3f67922bc63e48e953f126de60bd33ccc0101ef9998cd"
 dependencies = [
  "bumpalo",
  "log",
  "once_cell",
  "proc-macro2",
  "quote",
- "syn 2.0.87",
+ "syn 2.0.90",
  "wasm-bindgen-shared",
 ]
 
 [[package]]
 name = "wasm-bindgen-macro"
-version = "0.2.95"
+version = "0.2.97"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e79384be7f8f5a9dd5d7167216f022090cf1f9ec128e6e6a482a2cb5c5422c56"
+checksum = "705440e08b42d3e4b36de7d66c944be628d579796b8090bfa3471478a2260051"
 dependencies = [
  "quote",
  "wasm-bindgen-macro-support",
@@ -5784,22 +5860,22 @@ dependencies = [
 
 [[package]]
 name = "wasm-bindgen-macro-support"
-version = "0.2.95"
+version = "0.2.97"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "26c6ab57572f7a24a4985830b120de1594465e5d500f24afe89e16b4e833ef68"
+checksum = "98c9ae5a76e46f4deecd0f0255cc223cfa18dc9b261213b8aa0c7b36f61b3f1d"
 dependencies = [
  "proc-macro2",
  "quote",
- "syn 2.0.87",
+ "syn 2.0.90",
  "wasm-bindgen-backend",
  "wasm-bindgen-shared",
 ]
 
 [[package]]
 name = "wasm-bindgen-shared"
-version = "0.2.95"
+version = "0.2.97"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "65fc09f10666a9f147042251e0dda9c18f166ff7de300607007e96bdebc1068d"
+checksum = "6ee99da9c5ba11bd675621338ef6fa52296b76b83305e9b6e5c77d4c286d6d49"
 
 [[package]]
 name = "wasm-component-ld"
@@ -5827,21 +5903,22 @@ dependencies = [
 
 [[package]]
 name = "wasm-encoder"
-version = "0.216.0"
+version = "0.219.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "04c23aebea22c8a75833ae08ed31ccc020835b12a41999e58c31464271b94a88"
+checksum = "29cbbd772edcb8e7d524a82ee8cef8dd046fc14033796a754c3ad246d019fa54"
 dependencies = [
  "leb128",
+ "wasmparser 0.219.1",
 ]
 
 [[package]]
 name = "wasm-encoder"
-version = "0.219.1"
+version = "0.221.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "29cbbd772edcb8e7d524a82ee8cef8dd046fc14033796a754c3ad246d019fa54"
+checksum = "de35b6c3ef1f53ac7a31b5e69bc00f1542ea337e7e7162dc34c68b537ff82690"
 dependencies = [
  "leb128",
- "wasmparser 0.219.1",
+ "wasmparser 0.221.0",
 ]
 
 [[package]]
@@ -5860,23 +5937,13 @@ dependencies = [
  "wasmparser 0.219.1",
 ]
 
-[[package]]
-name = "wasmparser"
-version = "0.216.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "bcdee6bea3619d311fb4b299721e89a986c3470f804b6d534340e412589028e3"
-dependencies = [
- "bitflags 2.6.0",
- "indexmap",
-]
-
 [[package]]
 name = "wasmparser"
 version = "0.218.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "b09e46c7fceceaa72b2dd1a8a137ea7fd8f93dfaa69806010a709918e496c5dc"
 dependencies = [
- "bitflags 2.6.0",
+ "bitflags",
 ]
 
 [[package]]
@@ -5886,35 +5953,56 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "5c771866898879073c53b565a6c7b49953795159836714ac56a5befb581227c5"
 dependencies = [
  "ahash",
- "bitflags 2.6.0",
+ "bitflags",
  "hashbrown 0.14.5",
  "indexmap",
  "semver",
  "serde",
 ]
 
+[[package]]
+name = "wasmparser"
+version = "0.221.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8659e755615170cfe20da468865c989da78c5da16d8652e69a75acda02406a92"
+dependencies = [
+ "bitflags",
+ "indexmap",
+ "semver",
+]
+
 [[package]]
 name = "wast"
-version = "219.0.1"
+version = "221.0.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4f79a9d9df79986a68689a6b40bcc8d5d40d807487b235bebc2ac69a242b54a1"
+checksum = "9d8eb1933d493dd07484a255c3f52236123333f5befaa3be36182a50d393ec54"
 dependencies = [
  "bumpalo",
  "leb128",
  "memchr",
- "unicode-width 0.1.14",
- "wasm-encoder 0.219.1",
+ "unicode-width 0.2.0",
+ "wasm-encoder 0.221.0",
 ]
 
 [[package]]
 name = "wat"
-version = "1.219.1"
+version = "1.221.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8bc3cf014fb336883a411cd662f987abf6a1d2a27f2f0008616a0070bbf6bd0d"
+checksum = "c813fd4e5b2b97242830b56e7b7dc5479bc17aaa8730109be35e61909af83993"
 dependencies = [
  "wast",
 ]
 
+[[package]]
+name = "web-time"
+version = "1.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5a6580f308b1fad9207618087a65c04e7a10bc77e02c8e84e9b00dd4b12fa0bb"
+dependencies = [
+ "js-sys",
+ "wasm-bindgen",
+]
+
 [[package]]
 name = "winapi"
 version = "0.3.9"
@@ -5966,7 +6054,7 @@ dependencies = [
  "rayon",
  "serde",
  "serde_json",
- "syn 2.0.87",
+ "syn 2.0.90",
  "windows-metadata",
 ]
 
@@ -5999,7 +6087,7 @@ checksum = "9107ddc059d5b6fbfbffdfa7a7fe3e22a226def0b2608f72e9d552763d3e1ad7"
 dependencies = [
  "proc-macro2",
  "quote",
- "syn 2.0.87",
+ "syn 2.0.90",
 ]
 
 [[package]]
@@ -6010,7 +6098,7 @@ checksum = "29bee4b38ea3cde66011baa44dba677c432a78593e202392d1e9070cf2a7fca7"
 dependencies = [
  "proc-macro2",
  "quote",
- "syn 2.0.87",
+ "syn 2.0.90",
 ]
 
 [[package]]
@@ -6192,7 +6280,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "ad1673163c0cb14a6a19ddbf44dd4efe6f015ec1ebb8156710ac32501f19fba2"
 dependencies = [
  "anyhow",
- "bitflags 2.6.0",
+ "bitflags",
  "indexmap",
  "log",
  "serde",
@@ -6222,6 +6310,12 @@ dependencies = [
  "wasmparser 0.219.1",
 ]
 
+[[package]]
+name = "write16"
+version = "1.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d1890f4022759daae28ed4fe62859b1236caebfc61ede2f63ed4e695f3f6d936"
+
 [[package]]
 name = "writeable"
 version = "0.5.5"
@@ -6259,9 +6353,9 @@ dependencies = [
 
 [[package]]
 name = "yoke"
-version = "0.7.4"
+version = "0.7.5"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6c5b1314b079b0930c31e3af543d8ee1757b1951ae1e1565ec704403a7240ca5"
+checksum = "120e6aef9aa629e3d4f52dc8cc43a015c7724194c97dfaf45180d2daf2b77f40"
 dependencies = [
  "serde",
  "stable_deref_trait",
@@ -6271,13 +6365,13 @@ dependencies = [
 
 [[package]]
 name = "yoke-derive"
-version = "0.7.4"
+version = "0.7.5"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "28cc31741b18cb6f1d5ff12f5b7523e3d6eb0852bbbad19d73905511d9849b95"
+checksum = "2380878cad4ac9aac1e2435f3eb4020e8374b5f13c296cb75b4620ff8e229154"
 dependencies = [
  "proc-macro2",
  "quote",
- "syn 2.0.87",
+ "syn 2.0.90",
  "synstructure",
 ]
 
@@ -6299,27 +6393,27 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e"
 dependencies = [
  "proc-macro2",
  "quote",
- "syn 2.0.87",
+ "syn 2.0.90",
 ]
 
 [[package]]
 name = "zerofrom"
-version = "0.1.4"
+version = "0.1.5"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "91ec111ce797d0e0784a1116d0ddcdbea84322cd79e5d5ad173daeba4f93ab55"
+checksum = "cff3ee08c995dee1859d998dea82f7374f2826091dd9cd47def953cae446cd2e"
 dependencies = [
  "zerofrom-derive",
 ]
 
 [[package]]
 name = "zerofrom-derive"
-version = "0.1.4"
+version = "0.1.5"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0ea7b4a3637ea8669cedf0f1fd5c286a17f3de97b8dd5a70a6c167a1730e63a5"
+checksum = "595eed982f7d355beb85837f651fa22e90b3c044842dc7f2c2842c086f295808"
 dependencies = [
  "proc-macro2",
  "quote",
- "syn 2.0.87",
+ "syn 2.0.90",
  "synstructure",
 ]
 
@@ -6342,5 +6436,5 @@ checksum = "6eafa6dfb17584ea3e2bd6e76e0cc15ad7af12b09abdd1ca55961bed9b1063c6"
 dependencies = [
  "proc-macro2",
  "quote",
- "syn 2.0.87",
+ "syn 2.0.90",
 ]
diff --git a/compiler/rustc_codegen_ssa/Cargo.toml b/compiler/rustc_codegen_ssa/Cargo.toml
index b898cfec79669..e40a2aa36129b 100644
--- a/compiler/rustc_codegen_ssa/Cargo.toml
+++ b/compiler/rustc_codegen_ssa/Cargo.toml
@@ -42,7 +42,7 @@ tempfile = "3.2"
 thin-vec = "0.2.12"
 thorin-dwp = "0.8"
 tracing = "0.1"
-wasm-encoder = "0.216.0"
+wasm-encoder = "0.219"
 # tidy-alphabetical-end
 
 [target.'cfg(unix)'.dependencies]
diff --git a/library/Cargo.lock b/library/Cargo.lock
index f9b0af2c6e84c..490c989300f58 100644
--- a/library/Cargo.lock
+++ b/library/Cargo.lock
@@ -36,15 +36,15 @@ dependencies = [
 
 [[package]]
 name = "allocator-api2"
-version = "0.2.18"
+version = "0.2.20"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f"
+checksum = "45862d1c77f2228b9e10bc609d5bc203d86ebc9b87ad8d5d5167a6c9abf739d9"
 
 [[package]]
 name = "cc"
-version = "1.2.0"
+version = "1.2.2"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1aeb932158bd710538c73702db6945cb68a8fb08c519e6e12706b94263b36db8"
+checksum = "f34d93e62b03caf570cccc334cbc6c2fceca82f39211051345108adcba3eebdc"
 dependencies = [
  "shlex",
 ]
@@ -403,9 +403,9 @@ dependencies = [
 
 [[package]]
 name = "unwinding"
-version = "0.2.3"
+version = "0.2.4"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "637d511437df708cee34bdec7ba2f1548d256b7acf3ff20e0a1c559f9bf3a987"
+checksum = "e2c6cb20f236dae10c69b0b45d82ef50af8b7e45c10e429e7901d26b49b4dbf3"
 dependencies = [
  "compiler_builtins",
  "gimli 0.31.1",
diff --git a/src/tools/run-make-support/Cargo.toml b/src/tools/run-make-support/Cargo.toml
index 3c172b2d956a7..15ed03ad5c23d 100644
--- a/src/tools/run-make-support/Cargo.toml
+++ b/src/tools/run-make-support/Cargo.toml
@@ -7,7 +7,7 @@ edition = "2021"
 bstr = "1.6.0"
 object = "0.36.2"
 similar = "2.5.0"
-wasmparser = { version = "0.216", default-features = false, features = ["std"] }
+wasmparser = { version = "0.219", default-features = false, features = ["std"] }
 regex = "1.8" # 1.8 to avoid memchr 2.6.0, as 2.5.0 is pinned in the workspace
 gimli = "0.31.0"
 build_helper = { path = "../../build_helper" }
diff --git a/src/tools/rustbook/Cargo.lock b/src/tools/rustbook/Cargo.lock
index 400eb7c5e0d7b..3d35779be90f3 100644
--- a/src/tools/rustbook/Cargo.lock
+++ b/src/tools/rustbook/Cargo.lock
@@ -47,9 +47,9 @@ dependencies = [
 
 [[package]]
 name = "anstream"
-version = "0.6.17"
+version = "0.6.18"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "23a1e53f0f5d86382dafe1cf314783b2044280f406e7e1506368220ad11b1338"
+checksum = "8acc5369981196006228e28809f761875c0327210a891e941f4c683b3a99529b"
 dependencies = [
  "anstyle",
  "anstyle-parse",
@@ -96,9 +96,9 @@ dependencies = [
 
 [[package]]
 name = "anyhow"
-version = "1.0.92"
+version = "1.0.93"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "74f37166d7d48a0284b99dd824694c26119c700b53bf0d1540cdb147dbdaaf13"
+checksum = "4c95c10ba0b00a02636238b814946408b1322d5ac4760326e6fb8ec956d85775"
 
 [[package]]
 name = "autocfg"
@@ -138,9 +138,9 @@ dependencies = [
 
 [[package]]
 name = "bstr"
-version = "1.10.0"
+version = "1.11.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "40723b8fb387abc38f4f4a37c09073622e41dd12327033091ef8950659e6dc0c"
+checksum = "1a68f1f47cdf0ec8ee4b941b2eee2a80cb796db73118c0dd09ac63fbe405be22"
 dependencies = [
  "memchr",
  "regex-automata",
@@ -161,9 +161,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b"
 
 [[package]]
 name = "cc"
-version = "1.2.0"
+version = "1.2.2"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1aeb932158bd710538c73702db6945cb68a8fb08c519e6e12706b94263b36db8"
+checksum = "f34d93e62b03caf570cccc334cbc6c2fceca82f39211051345108adcba3eebdc"
 dependencies = [
  "shlex",
 ]
@@ -190,9 +190,9 @@ dependencies = [
 
 [[package]]
 name = "clap"
-version = "4.5.20"
+version = "4.5.21"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b97f376d85a664d5837dbae44bf546e6477a679ff6610010f17276f686d867e8"
+checksum = "fb3b4b9e5a7c7514dfa52869339ee98b3156b0bfb4e8a77c4ff4babb64b1604f"
 dependencies = [
  "clap_builder",
  "clap_derive",
@@ -200,9 +200,9 @@ dependencies = [
 
 [[package]]
 name = "clap_builder"
-version = "4.5.20"
+version = "4.5.21"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "19bc80abd44e4bed93ca373a0704ccbd1b710dc5749406201bb018272808dc54"
+checksum = "b17a95aa67cc7b5ebd32aa5370189aa0d79069ef1c64ce893bd30fb24bff20ec"
 dependencies = [
  "anstream",
  "anstyle",
@@ -213,9 +213,9 @@ dependencies = [
 
 [[package]]
 name = "clap_complete"
-version = "4.5.36"
+version = "4.5.38"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "86bc73de94bc81e52f3bebec71bc4463e9748f7a59166663e32044669577b0e2"
+checksum = "d9647a559c112175f17cf724dc72d3645680a883c58481332779192b0d8e7a01"
 dependencies = [
  "clap",
 ]
@@ -234,9 +234,9 @@ dependencies = [
 
 [[package]]
 name = "clap_lex"
-version = "0.7.2"
+version = "0.7.3"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1462739cb27611015575c0c11df5df7601141071f07518d56fcc1be504cbec97"
+checksum = "afb84c814227b90d6895e01398aee0d8033c00e7466aca416fb6a8e0eb19d8a7"
 
 [[package]]
 name = "colorchoice"
@@ -252,9 +252,9 @@ checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b"
 
 [[package]]
 name = "cpufeatures"
-version = "0.2.14"
+version = "0.2.16"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "608697df725056feaccfa42cffdaeeec3fccc4ffc38358ecd19b243e716a78e0"
+checksum = "16b80225097f2e5ae4e7179dd2266824648f3e2f49d9134d584b76389d31c4c3"
 dependencies = [
  "libc",
 ]
@@ -311,6 +311,17 @@ dependencies = [
  "crypto-common",
 ]
 
+[[package]]
+name = "displaydoc"
+version = "0.2.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn",
+]
+
 [[package]]
 name = "doc-comment"
 version = "0.3.3"
@@ -360,25 +371,25 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5"
 
 [[package]]
 name = "errno"
-version = "0.3.9"
+version = "0.3.10"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba"
+checksum = "33d852cb9b869c2a9b3df2f71a3074817f01e1844f839a144f5fcef059a4eb5d"
 dependencies = [
  "libc",
- "windows-sys 0.52.0",
+ "windows-sys 0.59.0",
 ]
 
 [[package]]
 name = "fastrand"
-version = "2.1.1"
+version = "2.2.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e8c02a5121d4ea3eb16a80748c74f5549a5665e4c21333c6098f283870fbdea6"
+checksum = "486f806e73c5707928240ddc295403b1b93c96a02038563881c4a2fd84b81ac4"
 
 [[package]]
 name = "flate2"
-version = "1.0.34"
+version = "1.0.35"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a1b589b4dc103969ad3cf85c950899926ec64300a1a46d76c03a6072957036f0"
+checksum = "c936bfdafb507ebbf50b8074c54fa31c5be9a1e7e5f467dd659697041407d07c"
 dependencies = [
  "crc32fast",
  "miniz_oxide",
@@ -456,9 +467,9 @@ dependencies = [
 
 [[package]]
 name = "hashbrown"
-version = "0.15.0"
+version = "0.15.2"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1e087f84d4f86bf4b218b927129862374b72199ae7d8657835f1e89000eea4fb"
+checksum = "bf151400ff0baff5465007dd2f3e717f3fe502074ca563069ce3a6629d07b289"
 
 [[package]]
 name = "heck"
@@ -524,21 +535,150 @@ dependencies = [
  "cc",
 ]
 
+[[package]]
+name = "icu_collections"
+version = "1.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "db2fa452206ebee18c4b5c2274dbf1de17008e874b4dc4f0aea9d01ca79e4526"
+dependencies = [
+ "displaydoc",
+ "yoke",
+ "zerofrom",
+ "zerovec",
+]
+
+[[package]]
+name = "icu_locid"
+version = "1.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "13acbb8371917fc971be86fc8057c41a64b521c184808a698c02acc242dbf637"
+dependencies = [
+ "displaydoc",
+ "litemap",
+ "tinystr",
+ "writeable",
+ "zerovec",
+]
+
+[[package]]
+name = "icu_locid_transform"
+version = "1.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "01d11ac35de8e40fdeda00d9e1e9d92525f3f9d887cdd7aa81d727596788b54e"
+dependencies = [
+ "displaydoc",
+ "icu_locid",
+ "icu_locid_transform_data",
+ "icu_provider",
+ "tinystr",
+ "zerovec",
+]
+
+[[package]]
+name = "icu_locid_transform_data"
+version = "1.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "fdc8ff3388f852bede6b579ad4e978ab004f139284d7b28715f773507b946f6e"
+
+[[package]]
+name = "icu_normalizer"
+version = "1.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "19ce3e0da2ec68599d193c93d088142efd7f9c5d6fc9b803774855747dc6a84f"
+dependencies = [
+ "displaydoc",
+ "icu_collections",
+ "icu_normalizer_data",
+ "icu_properties",
+ "icu_provider",
+ "smallvec",
+ "utf16_iter",
+ "utf8_iter",
+ "write16",
+ "zerovec",
+]
+
+[[package]]
+name = "icu_normalizer_data"
+version = "1.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f8cafbf7aa791e9b22bec55a167906f9e1215fd475cd22adfcf660e03e989516"
+
+[[package]]
+name = "icu_properties"
+version = "1.5.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "93d6020766cfc6302c15dbbc9c8778c37e62c14427cb7f6e601d849e092aeef5"
+dependencies = [
+ "displaydoc",
+ "icu_collections",
+ "icu_locid_transform",
+ "icu_properties_data",
+ "icu_provider",
+ "tinystr",
+ "zerovec",
+]
+
+[[package]]
+name = "icu_properties_data"
+version = "1.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "67a8effbc3dd3e4ba1afa8ad918d5684b8868b3b26500753effea8d2eed19569"
+
+[[package]]
+name = "icu_provider"
+version = "1.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6ed421c8a8ef78d3e2dbc98a973be2f3770cb42b606e3ab18d6237c4dfde68d9"
+dependencies = [
+ "displaydoc",
+ "icu_locid",
+ "icu_provider_macros",
+ "stable_deref_trait",
+ "tinystr",
+ "writeable",
+ "yoke",
+ "zerofrom",
+ "zerovec",
+]
+
+[[package]]
+name = "icu_provider_macros"
+version = "1.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1ec89e9337638ecdc08744df490b221a7399bf8d164eb52a665454e60e075ad6"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn",
+]
+
 [[package]]
 name = "idna"
-version = "0.5.0"
+version = "1.0.3"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6"
+checksum = "686f825264d630750a544639377bae737628043f20d38bbc029e8f29ea968a7e"
 dependencies = [
- "unicode-bidi",
- "unicode-normalization",
+ "idna_adapter",
+ "smallvec",
+ "utf8_iter",
+]
+
+[[package]]
+name = "idna_adapter"
+version = "1.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "daca1df1c957320b2cf139ac61e7bd64fed304c5040df000a745aa1de3b4ef71"
+dependencies = [
+ "icu_normalizer",
+ "icu_properties",
 ]
 
 [[package]]
 name = "indexmap"
-version = "2.6.0"
+version = "2.7.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "707907fe3c25f5424cce2cb7e1cbcafee6bdbe735ca90ef77c29e84591e5b9da"
+checksum = "62f822373a4fe84d4bb149bf54e584a7f4abec90e072ed49cda0edea5b95471f"
 dependencies = [
  "equivalent",
  "hashbrown",
@@ -552,16 +692,17 @@ checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf"
 
 [[package]]
 name = "itoa"
-version = "1.0.11"
+version = "1.0.14"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b"
+checksum = "d75a2a4b1b190afb6f5425f10f6a8f959d2ea0b9c2b1d79553551850539e4674"
 
 [[package]]
 name = "js-sys"
-version = "0.3.72"
+version = "0.3.74"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6a88f1bda2bd75b0452a14784937d796722fdebfe50df998aeb3f0b7603019a9"
+checksum = "a865e038f7f6ed956f788f0d7d60c541fff74c7bd74272c5d4cf15c63743e705"
 dependencies = [
+ "once_cell",
  "wasm-bindgen",
 ]
 
@@ -573,9 +714,9 @@ checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe"
 
 [[package]]
 name = "libc"
-version = "0.2.161"
+version = "0.2.167"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8e9489c2807c139ffd9c1794f4af0ebe86a828db53ecdc7fea2111d0fed085d1"
+checksum = "09d6582e104315a817dff97f75133544b2e094ee22447d2acf4a74e189ba06fc"
 
 [[package]]
 name = "libdbus-sys"
@@ -602,6 +743,12 @@ version = "0.4.14"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89"
 
+[[package]]
+name = "litemap"
+version = "0.7.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4ee93343901ab17bd981295f2cf0026d4ad018c7c31ba84549a4ddbb47a45104"
+
 [[package]]
 name = "lock_api"
 version = "0.4.12"
@@ -646,9 +793,9 @@ dependencies = [
 
 [[package]]
 name = "mdbook"
-version = "0.4.42"
+version = "0.4.43"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7624879735513024d323e7267a0b3a7176aceb0db537939beb4ee31d9e8945e3"
+checksum = "fe1f98b8d66e537d2f0ba06e7dec4f44001deec539a2d18bfc102d6a86189148"
 dependencies = [
  "ammonia",
  "anyhow",
@@ -852,9 +999,9 @@ dependencies = [
 
 [[package]]
 name = "pathdiff"
-version = "0.2.2"
+version = "0.2.3"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d61c5ce1153ab5b689d0c074c4e7fc613e942dfb7dd9eea5ab202d2ad91fe361"
+checksum = "df94ce210e5bc13cb6651479fa48d14f601d9858cfe0467f43ae157023b938d3"
 
 [[package]]
 name = "percent-encoding"
@@ -996,9 +1143,9 @@ checksum = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c"
 
 [[package]]
 name = "proc-macro2"
-version = "1.0.89"
+version = "1.0.92"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f139b0662de085916d1fb67d2b4169d1addddda1919e696f3252b740b629986e"
+checksum = "37d3544b3f2748c54e147655edb5025752e2303145b5aefb3c3ea2c78b973bb0"
 dependencies = [
  "unicode-ident",
 ]
@@ -1120,9 +1267,9 @@ dependencies = [
 
 [[package]]
 name = "regex-automata"
-version = "0.4.8"
+version = "0.4.9"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "368758f23274712b504848e9d5a6f010445cc8b87a7cdb4d7cbee666c1288da3"
+checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908"
 dependencies = [
  "aho-corasick",
  "memchr",
@@ -1150,9 +1297,9 @@ dependencies = [
 
 [[package]]
 name = "rustix"
-version = "0.38.38"
+version = "0.38.41"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "aa260229e6538e52293eeb577aabd09945a09d6d9cc0fc550ed7529056c2e32a"
+checksum = "d7f649912bc1495e167a6edee79151c84b1bad49748cb4f1f1167f459f6224f6"
 dependencies = [
  "bitflags 2.6.0",
  "errno",
@@ -1190,18 +1337,18 @@ checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b"
 
 [[package]]
 name = "serde"
-version = "1.0.214"
+version = "1.0.215"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f55c3193aca71c12ad7890f1785d2b73e1b9f63a0bbc353c08ef26fe03fc56b5"
+checksum = "6513c1ad0b11a9376da888e3e0baa0077f1aed55c17f50e7b2397136129fb88f"
 dependencies = [
  "serde_derive",
 ]
 
 [[package]]
 name = "serde_derive"
-version = "1.0.214"
+version = "1.0.215"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "de523f781f095e28fa605cdce0f8307e451cc0fd14e2eb4cd2e98a355b147766"
+checksum = "ad1e866f866923f252f05c889987993144fb74e722403468a4ebd70c3cd756c0"
 dependencies = [
  "proc-macro2",
  "quote",
@@ -1210,9 +1357,9 @@ dependencies = [
 
 [[package]]
 name = "serde_json"
-version = "1.0.132"
+version = "1.0.133"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d726bfaff4b320266d395898905d0eba0345aae23b54aee3a737e260fd46db03"
+checksum = "c7fceb2473b9166b2294ef05efcb65a3db80803f0b03ef86a5fc88a2b85ee377"
 dependencies = [
  "itoa",
  "memchr",
@@ -1258,6 +1405,12 @@ version = "1.13.2"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67"
 
+[[package]]
+name = "stable_deref_trait"
+version = "1.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3"
+
 [[package]]
 name = "string_cache"
 version = "0.8.7"
@@ -1292,15 +1445,26 @@ checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f"
 
 [[package]]
 name = "syn"
-version = "2.0.87"
+version = "2.0.90"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "25aa4ce346d03a6dcd68dd8b4010bcb74e54e62c90c573f394c46eae99aba32d"
+checksum = "919d3b74a5dd0ccd15aeb8f93e7006bd9e14c295087c9896a110f490752bcf31"
 dependencies = [
  "proc-macro2",
  "quote",
  "unicode-ident",
 ]
 
+[[package]]
+name = "synstructure"
+version = "0.13.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn",
+]
+
 [[package]]
 name = "syntect"
 version = "5.2.0"
@@ -1323,9 +1487,9 @@ dependencies = [
 
 [[package]]
 name = "tempfile"
-version = "3.13.0"
+version = "3.14.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f0f2c9fc62d0beef6951ccffd757e241266a2c833136efbe35af6cd2567dca5b"
+checksum = "28cce251fcbc87fac86a866eeb0d6c2d536fc16d06f184bb61aeae11aa4cee0c"
 dependencies = [
  "cfg-if",
  "fastrand",
@@ -1347,9 +1511,9 @@ dependencies = [
 
 [[package]]
 name = "terminal_size"
-version = "0.4.0"
+version = "0.4.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4f599bd7ca042cfdf8f4512b277c02ba102247820f9d9d4a9f521f496751a6ef"
+checksum = "5352447f921fda68cf61b4101566c0bdb5104eff6804d0678e5227580ab6a4e9"
 dependencies = [
  "rustix",
  "windows-sys 0.59.0",
@@ -1363,18 +1527,18 @@ checksum = "23d434d3f8967a09480fb04132ebe0a3e088c173e6d0ee7897abbdf4eab0f8b9"
 
 [[package]]
 name = "thiserror"
-version = "1.0.66"
+version = "1.0.69"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5d171f59dbaa811dbbb1aee1e73db92ec2b122911a48e1390dfe327a821ddede"
+checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52"
 dependencies = [
  "thiserror-impl",
 ]
 
 [[package]]
 name = "thiserror-impl"
-version = "1.0.66"
+version = "1.0.69"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b08be0f17bd307950653ce45db00cd31200d82b624b36e181337d9c7d92765b5"
+checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1"
 dependencies = [
  "proc-macro2",
  "quote",
@@ -1382,20 +1546,15 @@ dependencies = [
 ]
 
 [[package]]
-name = "tinyvec"
-version = "1.8.0"
+name = "tinystr"
+version = "0.7.6"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "445e881f4f6d382d5f27c034e25eb92edd7c784ceab92a0937db7f2e9471b938"
+checksum = "9117f5d4db391c1cf6927e7bea3db74b9a1c1add8f7eda9ffd5364f40f57b82f"
 dependencies = [
- "tinyvec_macros",
+ "displaydoc",
+ "zerovec",
 ]
 
-[[package]]
-name = "tinyvec_macros"
-version = "0.1.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20"
-
 [[package]]
 name = "toml"
 version = "0.5.11"
@@ -1463,26 +1622,11 @@ version = "2.8.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "7e51b68083f157f853b6379db119d1c1be0e6e4dec98101079dec41f6f5cf6df"
 
-[[package]]
-name = "unicode-bidi"
-version = "0.3.17"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5ab17db44d7388991a428b2ee655ce0c212e862eff1768a455c58f9aad6e7893"
-
 [[package]]
 name = "unicode-ident"
-version = "1.0.13"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe"
-
-[[package]]
-name = "unicode-normalization"
-version = "0.1.24"
+version = "1.0.14"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5033c97c4262335cded6d6fc3e5c18ab755e1a3dc96376350f3d8e9f009ad956"
-dependencies = [
- "tinyvec",
-]
+checksum = "adb9e6ca4f869e1180728b7950e35922a7fc6397f7b641499e8f3ef06e50dc83"
 
 [[package]]
 name = "unicode-width"
@@ -1492,9 +1636,9 @@ checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af"
 
 [[package]]
 name = "url"
-version = "2.5.2"
+version = "2.5.4"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "22784dbdf76fdde8af1aeda5622b546b422b6fc585325248a2bf9f5e41e94d6c"
+checksum = "32f8b686cadd1473f4bd0117a5d28d36b1ade384ea9b5069a1c40aefed7fda60"
 dependencies = [
  "form_urlencoded",
  "idna",
@@ -1507,6 +1651,18 @@ version = "0.7.6"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9"
 
+[[package]]
+name = "utf16_iter"
+version = "1.0.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c8232dd3cdaed5356e0f716d285e4b40b932ac434100fe9b7e0e8e935b9e6246"
+
+[[package]]
+name = "utf8_iter"
+version = "1.0.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be"
+
 [[package]]
 name = "utf8parse"
 version = "0.2.2"
@@ -1537,9 +1693,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
 
 [[package]]
 name = "wasm-bindgen"
-version = "0.2.95"
+version = "0.2.97"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "128d1e363af62632b8eb57219c8fd7877144af57558fb2ef0368d0087bddeb2e"
+checksum = "d15e63b4482863c109d70a7b8706c1e364eb6ea449b201a76c5b89cedcec2d5c"
 dependencies = [
  "cfg-if",
  "once_cell",
@@ -1548,9 +1704,9 @@ dependencies = [
 
 [[package]]
 name = "wasm-bindgen-backend"
-version = "0.2.95"
+version = "0.2.97"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "cb6dd4d3ca0ddffd1dd1c9c04f94b868c37ff5fac97c30b97cff2d74fce3a358"
+checksum = "8d36ef12e3aaca16ddd3f67922bc63e48e953f126de60bd33ccc0101ef9998cd"
 dependencies = [
  "bumpalo",
  "log",
@@ -1563,9 +1719,9 @@ dependencies = [
 
 [[package]]
 name = "wasm-bindgen-macro"
-version = "0.2.95"
+version = "0.2.97"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e79384be7f8f5a9dd5d7167216f022090cf1f9ec128e6e6a482a2cb5c5422c56"
+checksum = "705440e08b42d3e4b36de7d66c944be628d579796b8090bfa3471478a2260051"
 dependencies = [
  "quote",
  "wasm-bindgen-macro-support",
@@ -1573,9 +1729,9 @@ dependencies = [
 
 [[package]]
 name = "wasm-bindgen-macro-support"
-version = "0.2.95"
+version = "0.2.97"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "26c6ab57572f7a24a4985830b120de1594465e5d500f24afe89e16b4e833ef68"
+checksum = "98c9ae5a76e46f4deecd0f0255cc223cfa18dc9b261213b8aa0c7b36f61b3f1d"
 dependencies = [
  "proc-macro2",
  "quote",
@@ -1586,9 +1742,9 @@ dependencies = [
 
 [[package]]
 name = "wasm-bindgen-shared"
-version = "0.2.95"
+version = "0.2.97"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "65fc09f10666a9f147042251e0dda9c18f166ff7de300607007e96bdebc1068d"
+checksum = "6ee99da9c5ba11bd675621338ef6fa52296b76b83305e9b6e5c77d4c286d6d49"
 
 [[package]]
 name = "winapi"
@@ -1721,6 +1877,42 @@ dependencies = [
  "memchr",
 ]
 
+[[package]]
+name = "write16"
+version = "1.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d1890f4022759daae28ed4fe62859b1236caebfc61ede2f63ed4e695f3f6d936"
+
+[[package]]
+name = "writeable"
+version = "0.5.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1e9df38ee2d2c3c5948ea468a8406ff0db0b29ae1ffde1bcf20ef305bcc95c51"
+
+[[package]]
+name = "yoke"
+version = "0.7.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "120e6aef9aa629e3d4f52dc8cc43a015c7724194c97dfaf45180d2daf2b77f40"
+dependencies = [
+ "serde",
+ "stable_deref_trait",
+ "yoke-derive",
+ "zerofrom",
+]
+
+[[package]]
+name = "yoke-derive"
+version = "0.7.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2380878cad4ac9aac1e2435f3eb4020e8374b5f13c296cb75b4620ff8e229154"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn",
+ "synstructure",
+]
+
 [[package]]
 name = "zerocopy"
 version = "0.7.35"
@@ -1741,3 +1933,46 @@ dependencies = [
  "quote",
  "syn",
 ]
+
+[[package]]
+name = "zerofrom"
+version = "0.1.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cff3ee08c995dee1859d998dea82f7374f2826091dd9cd47def953cae446cd2e"
+dependencies = [
+ "zerofrom-derive",
+]
+
+[[package]]
+name = "zerofrom-derive"
+version = "0.1.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "595eed982f7d355beb85837f651fa22e90b3c044842dc7f2c2842c086f295808"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn",
+ "synstructure",
+]
+
+[[package]]
+name = "zerovec"
+version = "0.10.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "aa2b893d79df23bfb12d5461018d408ea19dfafe76c2c7ef6d4eba614f8ff079"
+dependencies = [
+ "yoke",
+ "zerofrom",
+ "zerovec-derive",
+]
+
+[[package]]
+name = "zerovec-derive"
+version = "0.10.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6eafa6dfb17584ea3e2bd6e76e0cc15ad7af12b09abdd1ca55961bed9b1063c6"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn",
+]
diff --git a/src/tools/tidy/src/deps.rs b/src/tools/tidy/src/deps.rs
index e065f01ebba8b..493d9f5d5ec46 100644
--- a/src/tools/tidy/src/deps.rs
+++ b/src/tools/tidy/src/deps.rs
@@ -12,7 +12,8 @@ use cargo_metadata::{Metadata, Package, PackageId};
 #[rustfmt::skip]
 const LICENSES: &[&str] = &[
     // tidy-alphabetical-start
-    "(MIT OR Apache-2.0) AND Unicode-DFS-2016",            // unicode_ident
+    "(MIT OR Apache-2.0) AND Unicode-3.0",                 // unicode_ident (1.0.14)
+    "(MIT OR Apache-2.0) AND Unicode-DFS-2016",            // unicode_ident (1.0.12)
     "0BSD OR MIT OR Apache-2.0",                           // adler license
     "0BSD",
     "Apache-2.0 / MIT",
@@ -94,7 +95,6 @@ const EXCEPTIONS: ExceptionList = &[
     ("dissimilar", "Apache-2.0"),                            // rustdoc, rustc_lexer (few tests) via expect-test, (dev deps)
     ("fluent-langneg", "Apache-2.0"),                        // rustc (fluent translations)
     ("foldhash", "Zlib"),                                    // rustc
-    ("instant", "BSD-3-Clause"),                             // rustc_driver/tracing-subscriber/parking_lot
     ("mdbook", "MPL-2.0"),                                   // mdbook
     ("option-ext", "MPL-2.0"),                               // cargo-miri (via `directories`)
     ("rustc_apfloat", "Apache-2.0 WITH LLVM-exception"),     // rustc (license is the same as LLVM uses)

From 30847ebb255abbda590460e86a21b7b1c7c3b273 Mon Sep 17 00:00:00 2001
From: onur-ozkan <work@onurozkan.dev>
Date: Wed, 4 Dec 2024 15:58:23 +0300
Subject: [PATCH 14/30] use vendor sources by default on dist tarballs

Signed-off-by: onur-ozkan <work@onurozkan.dev>
---
 src/bootstrap/src/core/config/config.rs | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/bootstrap/src/core/config/config.rs b/src/bootstrap/src/core/config/config.rs
index b06147055f2a7..69aa6492eb682 100644
--- a/src/bootstrap/src/core/config/config.rs
+++ b/src/bootstrap/src/core/config/config.rs
@@ -1632,7 +1632,6 @@ impl Config {
         set(&mut config.docs_minification, docs_minification);
         set(&mut config.docs, docs);
         set(&mut config.locked_deps, locked_deps);
-        set(&mut config.vendor, vendor);
         set(&mut config.full_bootstrap, full_bootstrap);
         set(&mut config.extended, extended);
         config.tools = tools;
@@ -1711,6 +1710,12 @@ impl Config {
         config.in_tree_llvm_info = GitInfo::new(false, &config.src.join("src/llvm-project"));
         config.in_tree_gcc_info = GitInfo::new(false, &config.src.join("src/gcc"));
 
+        config.vendor = vendor.unwrap_or(
+            config.rust_info.is_from_tarball()
+                && config.src.join("vendor").exists()
+                && config.src.join(".cargo/config.toml").exists(),
+        );
+
         if let Some(rust) = toml.rust {
             let Rust {
                 optimize: optimize_toml,

From a6aaef14e6ea27b2051b2870acb62fd0553be17f Mon Sep 17 00:00:00 2001
From: onur-ozkan <work@onurozkan.dev>
Date: Wed, 4 Dec 2024 16:01:04 +0300
Subject: [PATCH 15/30] update `build.vendor` documentation

Signed-off-by: onur-ozkan <work@onurozkan.dev>
---
 config.example.toml | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/config.example.toml b/config.example.toml
index 9ec0d77e79b36..5ea6774ce035c 100644
--- a/config.example.toml
+++ b/config.example.toml
@@ -311,9 +311,8 @@
 # Indicate whether the vendored sources are used for Rust dependencies or not.
 #
 # Vendoring requires additional setup. We recommend using the pre-generated source tarballs if you
-# want to use vendoring. See
-# https://forge.rust-lang.org/infra/other-installation-methods.html#source-code.
-#vendor = false
+# want to use vendoring. See https://forge.rust-lang.org/infra/other-installation-methods.html#source-code.
+#vendor = if "is a tarball source" && "vendor" dir exists && ".cargo/config.toml" file exists { true } else { false }
 
 # Typically the build system will build the Rust compiler twice. The second
 # compiler, however, will simply use its own libraries to link against. If you

From 9ca9b41df2ca682c815b9bb3e580ce93b216a50d Mon Sep 17 00:00:00 2001
From: onur-ozkan <work@onurozkan.dev>
Date: Wed, 4 Dec 2024 16:08:37 +0300
Subject: [PATCH 16/30] add a change entry for new default on `build.vendor`

Signed-off-by: onur-ozkan <work@onurozkan.dev>
---
 src/bootstrap/src/utils/change_tracker.rs | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/bootstrap/src/utils/change_tracker.rs b/src/bootstrap/src/utils/change_tracker.rs
index 41a541d726940..f4f189c718a3d 100644
--- a/src/bootstrap/src/utils/change_tracker.rs
+++ b/src/bootstrap/src/utils/change_tracker.rs
@@ -310,4 +310,9 @@ pub const CONFIG_CHANGE_HISTORY: &[ChangeInfo] = &[
         severity: ChangeSeverity::Warning,
         summary: "Revert `rust.download-rustc` global default to `false` and only use `rust.download-rustc = \"if-unchanged\"` default for library and tools profile. As alt CI rustc is built without debug assertions, `rust.debug-assertions = true` will now inhibit downloading CI rustc.",
     },
+    ChangeInfo {
+        change_id: 133853,
+        severity: ChangeSeverity::Info,
+        summary: "`build.vendor` is now enabled by default for dist/tarball sources when 'vendor' directory and '.cargo/config.toml' file are present.",
+    },
 ];

From 18f8657415da5ebc480e63abe03f87d4b4ce4157 Mon Sep 17 00:00:00 2001
From: Kai Luo <lkail@cn.ibm.com>
Date: Thu, 8 Aug 2024 22:08:57 -0400
Subject: [PATCH 17/30] Pass -bnoipath when adding rust upstream dynamic crates

---
 compiler/rustc_codegen_ssa/src/back/link.rs | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/compiler/rustc_codegen_ssa/src/back/link.rs b/compiler/rustc_codegen_ssa/src/back/link.rs
index ad81ff272c62f..b3bb32bedf4b3 100644
--- a/compiler/rustc_codegen_ssa/src/back/link.rs
+++ b/compiler/rustc_codegen_ssa/src/back/link.rs
@@ -2753,6 +2753,13 @@ fn add_upstream_rust_crates(
         .find(|(ty, _)| *ty == crate_type)
         .expect("failed to find crate type in dependency format list");
 
+    if sess.target.is_like_aix {
+        // Unlike GNU's ld, AIX linker doesn't feature `-soname=...` when output
+        // a shared library. Instead, AIX linker offers `(no)ipath`. See
+        // https://www.ibm.com/docs/en/aix/7.3?topic=l-ld-command.
+        cmd.link_or_cc_arg("-bnoipath");
+    }
+
     for &cnum in &codegen_results.crate_info.used_crates {
         // We may not pass all crates through to the linker. Some crates may appear statically in
         // an existing dylib, meaning we'll pick up all the symbols from the dylib.

From 1ae1f8ce9cb327eaa22454bbf5a8e25123091ffb Mon Sep 17 00:00:00 2001
From: David Tenty <daltenty@ibm.com>
Date: Fri, 6 Dec 2024 10:53:26 -0500
Subject: [PATCH 18/30] Clarify comment

---
 compiler/rustc_codegen_ssa/src/back/link.rs | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/compiler/rustc_codegen_ssa/src/back/link.rs b/compiler/rustc_codegen_ssa/src/back/link.rs
index b3bb32bedf4b3..eb8f7cf6d407c 100644
--- a/compiler/rustc_codegen_ssa/src/back/link.rs
+++ b/compiler/rustc_codegen_ssa/src/back/link.rs
@@ -2754,8 +2754,10 @@ fn add_upstream_rust_crates(
         .expect("failed to find crate type in dependency format list");
 
     if sess.target.is_like_aix {
-        // Unlike GNU's ld, AIX linker doesn't feature `-soname=...` when output
-        // a shared library. Instead, AIX linker offers `(no)ipath`. See
+        // Unlike ELF linkers, AIX doesn't feature `DT_SONAME` to override
+        // the dependency name when outputing a shared library. Thus, `ld` will
+        // use the full path to shared libraries as the dependency if passed it
+        // by default unless `noipath` is passed.
         // https://www.ibm.com/docs/en/aix/7.3?topic=l-ld-command.
         cmd.link_or_cc_arg("-bnoipath");
     }

From 3109f07d855cd758aec574b009d339fe3e54cdb3 Mon Sep 17 00:00:00 2001
From: Xing Xue <xingxue@outlook.com>
Date: Fri, 6 Dec 2024 12:51:59 -0500
Subject: [PATCH 19/30] Replace sa_sigaction with sa_union.__su_sigaction for
 AIX.

---
 .../auxiliary/assert-sigpipe-disposition.rs              | 9 ++++++++-
 .../ui/runtime/on-broken-pipe/auxiliary/sigpipe-utils.rs | 9 ++++++++-
 tests/ui/runtime/signal-alternate-stack-cleanup.rs       | 9 ++++++++-
 3 files changed, 24 insertions(+), 3 deletions(-)

diff --git a/tests/ui/runtime/on-broken-pipe/auxiliary/assert-sigpipe-disposition.rs b/tests/ui/runtime/on-broken-pipe/auxiliary/assert-sigpipe-disposition.rs
index 117f6134b4e03..229408fb72474 100644
--- a/tests/ui/runtime/on-broken-pipe/auxiliary/assert-sigpipe-disposition.rs
+++ b/tests/ui/runtime/on-broken-pipe/auxiliary/assert-sigpipe-disposition.rs
@@ -25,7 +25,14 @@ fn start(argc: isize, argv: *const *const u8) -> isize {
     let actual = unsafe {
         let mut actual: libc::sigaction = std::mem::zeroed();
         libc::sigaction(libc::SIGPIPE, std::ptr::null(), &mut actual);
-        actual.sa_sigaction
+        #[cfg(not(target_os = "aix"))]
+        {
+            actual.sa_sigaction
+        }
+        #[cfg(target_os = "aix")]
+        {
+            actual.sa_union.__su_sigaction as libc::sighandler_t
+        }
     };
 
     assert_eq!(actual, expected, "actual and expected SIGPIPE disposition in child differs");
diff --git a/tests/ui/runtime/on-broken-pipe/auxiliary/sigpipe-utils.rs b/tests/ui/runtime/on-broken-pipe/auxiliary/sigpipe-utils.rs
index 3d93d50ca3fbb..d16a2b4d8c8ab 100644
--- a/tests/ui/runtime/on-broken-pipe/auxiliary/sigpipe-utils.rs
+++ b/tests/ui/runtime/on-broken-pipe/auxiliary/sigpipe-utils.rs
@@ -20,7 +20,14 @@ pub fn assert_sigpipe_handler(expected_handler: SignalHandler) {
         let actual = unsafe {
             let mut actual: libc::sigaction = std::mem::zeroed();
             libc::sigaction(libc::SIGPIPE, std::ptr::null(), &mut actual);
-            actual.sa_sigaction
+            #[cfg(not(target_os = "aix"))]
+            {
+                actual.sa_sigaction
+            }
+            #[cfg(target_os = "aix")]
+            {
+                actual.sa_union.__su_sigaction as libc::sighandler_t
+            }
         };
 
         let expected = match expected_handler {
diff --git a/tests/ui/runtime/signal-alternate-stack-cleanup.rs b/tests/ui/runtime/signal-alternate-stack-cleanup.rs
index f2af86be0a5f5..8fce092827318 100644
--- a/tests/ui/runtime/signal-alternate-stack-cleanup.rs
+++ b/tests/ui/runtime/signal-alternate-stack-cleanup.rs
@@ -29,7 +29,14 @@ fn main() {
         // Install signal handler that runs on alternate signal stack.
         let mut action: sigaction = std::mem::zeroed();
         action.sa_flags = (SA_ONSTACK | SA_SIGINFO) as _;
-        action.sa_sigaction = signal_handler as sighandler_t;
+        #[cfg(not(target_os = "aix"))]
+        {
+            action.sa_sigaction = signal_handler as sighandler_t;
+        }
+        #[cfg(target_os = "aix")]
+        {
+            action.sa_union.__su_sigaction = signal_handler as sighandler_t;
+        }
         sigaction(SIGWINCH, &action, std::ptr::null_mut());
 
         // Send SIGWINCH on exit.

From ab2ee7aa2f0eb8906b5d04104c93050e703b3936 Mon Sep 17 00:00:00 2001
From: Xing Xue <xingxue@outlook.com>
Date: Fri, 6 Dec 2024 15:22:46 -0500
Subject: [PATCH 20/30] Use option "-sf" for the AIX "ln" command.

---
 tests/run-make/libs-through-symlinks/Makefile | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/tests/run-make/libs-through-symlinks/Makefile b/tests/run-make/libs-through-symlinks/Makefile
index 592eae663a49a..c6ff566a0e86e 100644
--- a/tests/run-make/libs-through-symlinks/Makefile
+++ b/tests/run-make/libs-through-symlinks/Makefile
@@ -3,10 +3,20 @@ include ../tools.mk
 
 # ignore-windows
 
+# The option -n for the AIX ln command has a different purpose than it does
+# on Linux. On Linux, the -n option is used to treat the destination path as
+# normal file if it is a symbolic link to a directory, which is the default
+# behavior of the AIX ln command.
+ifeq ($(UNAME),AIX)
+LN_FLAGS := -sf
+else
+LN_FLAGS := -nsf
+endif
+
 NAME := $(shell $(RUSTC) --print file-names foo.rs)
 
 all:
 	mkdir -p $(TMPDIR)/outdir
 	$(RUSTC) foo.rs -o $(TMPDIR)/outdir/$(NAME)
-	ln -nsf outdir/$(NAME) $(TMPDIR)
+	ln $(LN_FLAGS) outdir/$(NAME) $(TMPDIR)
 	RUSTC_LOG=rustc_metadata::loader $(RUSTC) bar.rs

From f884f18151d63ac9ce7e573cadb165ecbe8d7f9b Mon Sep 17 00:00:00 2001
From: Zalathar <Zalathar@users.noreply.github.com>
Date: Sat, 7 Dec 2024 12:35:19 +1100
Subject: [PATCH 21/30] Move tests for `-l` and `#[link(..)]` into
 `tests/ui/link-native-libs`

---
 .../empty-kind-1.rs                                               | 0
 .../empty-kind-1.stderr                                           | 0
 .../empty-kind-2.rs                                               | 0
 .../empty-kind-2.stderr                                           | 0
 .../link-arg-error.rs                                             | 0
 .../link-arg-error.stderr                                         | 0
 .../link-arg-from-rs.rs                                           | 0
 .../link-arg-from-rs.stderr                                       | 0
 tests/ui/{manual => link-native-libs}/manual-link-bad-form.rs     | 0
 tests/ui/{manual => link-native-libs}/manual-link-bad-form.stderr | 0
 tests/ui/{manual => link-native-libs}/manual-link-bad-kind.rs     | 0
 tests/ui/{manual => link-native-libs}/manual-link-bad-kind.stderr | 0
 .../{manual => link-native-libs}/manual-link-bad-search-path.rs   | 0
 .../manual-link-bad-search-path.stderr                            | 0
 tests/ui/{manual => link-native-libs}/manual-link-framework.rs    | 0
 .../ui/{manual => link-native-libs}/manual-link-framework.stderr  | 0
 .../{manual => link-native-libs}/manual-link-unsupported-kind.rs  | 0
 .../manual-link-unsupported-kind.stderr                           | 0
 .../modifiers-bad.blank.stderr                                    | 0
 .../modifiers-bad.no-prefix.stderr                                | 0
 .../modifiers-bad.prefix-only.stderr                              | 0
 .../modifiers-bad.rs                                              | 0
 .../modifiers-bad.unknown.stderr                                  | 0
 .../modifiers-override-2.rs                                       | 0
 .../modifiers-override-2.stderr                                   | 0
 .../modifiers-override-3.rs                                       | 0
 .../modifiers-override-3.stderr                                   | 0
 .../modifiers-override.rs                                         | 0
 .../modifiers-override.stderr                                     | 0
 .../msvc-non-utf8-output.rs                                       | 0
 .../msvc-non-utf8-output.stderr                                   | 0
 .../suggest-libname-only-1.rs                                     | 0
 .../suggest-libname-only-1.stderr                                 | 0
 .../suggest-libname-only-2.rs                                     | 0
 .../suggest-libname-only-2.stderr                                 | 0
 35 files changed, 0 insertions(+), 0 deletions(-)
 rename tests/ui/{native-library-link-flags => link-native-libs}/empty-kind-1.rs (100%)
 rename tests/ui/{native-library-link-flags => link-native-libs}/empty-kind-1.stderr (100%)
 rename tests/ui/{native-library-link-flags => link-native-libs}/empty-kind-2.rs (100%)
 rename tests/ui/{native-library-link-flags => link-native-libs}/empty-kind-2.stderr (100%)
 rename tests/ui/{native-library-link-flags => link-native-libs}/link-arg-error.rs (100%)
 rename tests/ui/{native-library-link-flags => link-native-libs}/link-arg-error.stderr (100%)
 rename tests/ui/{native-library-link-flags => link-native-libs}/link-arg-from-rs.rs (100%)
 rename tests/ui/{native-library-link-flags => link-native-libs}/link-arg-from-rs.stderr (100%)
 rename tests/ui/{manual => link-native-libs}/manual-link-bad-form.rs (100%)
 rename tests/ui/{manual => link-native-libs}/manual-link-bad-form.stderr (100%)
 rename tests/ui/{manual => link-native-libs}/manual-link-bad-kind.rs (100%)
 rename tests/ui/{manual => link-native-libs}/manual-link-bad-kind.stderr (100%)
 rename tests/ui/{manual => link-native-libs}/manual-link-bad-search-path.rs (100%)
 rename tests/ui/{manual => link-native-libs}/manual-link-bad-search-path.stderr (100%)
 rename tests/ui/{manual => link-native-libs}/manual-link-framework.rs (100%)
 rename tests/ui/{manual => link-native-libs}/manual-link-framework.stderr (100%)
 rename tests/ui/{manual => link-native-libs}/manual-link-unsupported-kind.rs (100%)
 rename tests/ui/{manual => link-native-libs}/manual-link-unsupported-kind.stderr (100%)
 rename tests/ui/{native-library-link-flags => link-native-libs}/modifiers-bad.blank.stderr (100%)
 rename tests/ui/{native-library-link-flags => link-native-libs}/modifiers-bad.no-prefix.stderr (100%)
 rename tests/ui/{native-library-link-flags => link-native-libs}/modifiers-bad.prefix-only.stderr (100%)
 rename tests/ui/{native-library-link-flags => link-native-libs}/modifiers-bad.rs (100%)
 rename tests/ui/{native-library-link-flags => link-native-libs}/modifiers-bad.unknown.stderr (100%)
 rename tests/ui/{native-library-link-flags => link-native-libs}/modifiers-override-2.rs (100%)
 rename tests/ui/{native-library-link-flags => link-native-libs}/modifiers-override-2.stderr (100%)
 rename tests/ui/{native-library-link-flags => link-native-libs}/modifiers-override-3.rs (100%)
 rename tests/ui/{native-library-link-flags => link-native-libs}/modifiers-override-3.stderr (100%)
 rename tests/ui/{native-library-link-flags => link-native-libs}/modifiers-override.rs (100%)
 rename tests/ui/{native-library-link-flags => link-native-libs}/modifiers-override.stderr (100%)
 rename tests/ui/{native-library-link-flags => link-native-libs}/msvc-non-utf8-output.rs (100%)
 rename tests/ui/{native-library-link-flags => link-native-libs}/msvc-non-utf8-output.stderr (100%)
 rename tests/ui/{native-library-link-flags => link-native-libs}/suggest-libname-only-1.rs (100%)
 rename tests/ui/{native-library-link-flags => link-native-libs}/suggest-libname-only-1.stderr (100%)
 rename tests/ui/{native-library-link-flags => link-native-libs}/suggest-libname-only-2.rs (100%)
 rename tests/ui/{native-library-link-flags => link-native-libs}/suggest-libname-only-2.stderr (100%)

diff --git a/tests/ui/native-library-link-flags/empty-kind-1.rs b/tests/ui/link-native-libs/empty-kind-1.rs
similarity index 100%
rename from tests/ui/native-library-link-flags/empty-kind-1.rs
rename to tests/ui/link-native-libs/empty-kind-1.rs
diff --git a/tests/ui/native-library-link-flags/empty-kind-1.stderr b/tests/ui/link-native-libs/empty-kind-1.stderr
similarity index 100%
rename from tests/ui/native-library-link-flags/empty-kind-1.stderr
rename to tests/ui/link-native-libs/empty-kind-1.stderr
diff --git a/tests/ui/native-library-link-flags/empty-kind-2.rs b/tests/ui/link-native-libs/empty-kind-2.rs
similarity index 100%
rename from tests/ui/native-library-link-flags/empty-kind-2.rs
rename to tests/ui/link-native-libs/empty-kind-2.rs
diff --git a/tests/ui/native-library-link-flags/empty-kind-2.stderr b/tests/ui/link-native-libs/empty-kind-2.stderr
similarity index 100%
rename from tests/ui/native-library-link-flags/empty-kind-2.stderr
rename to tests/ui/link-native-libs/empty-kind-2.stderr
diff --git a/tests/ui/native-library-link-flags/link-arg-error.rs b/tests/ui/link-native-libs/link-arg-error.rs
similarity index 100%
rename from tests/ui/native-library-link-flags/link-arg-error.rs
rename to tests/ui/link-native-libs/link-arg-error.rs
diff --git a/tests/ui/native-library-link-flags/link-arg-error.stderr b/tests/ui/link-native-libs/link-arg-error.stderr
similarity index 100%
rename from tests/ui/native-library-link-flags/link-arg-error.stderr
rename to tests/ui/link-native-libs/link-arg-error.stderr
diff --git a/tests/ui/native-library-link-flags/link-arg-from-rs.rs b/tests/ui/link-native-libs/link-arg-from-rs.rs
similarity index 100%
rename from tests/ui/native-library-link-flags/link-arg-from-rs.rs
rename to tests/ui/link-native-libs/link-arg-from-rs.rs
diff --git a/tests/ui/native-library-link-flags/link-arg-from-rs.stderr b/tests/ui/link-native-libs/link-arg-from-rs.stderr
similarity index 100%
rename from tests/ui/native-library-link-flags/link-arg-from-rs.stderr
rename to tests/ui/link-native-libs/link-arg-from-rs.stderr
diff --git a/tests/ui/manual/manual-link-bad-form.rs b/tests/ui/link-native-libs/manual-link-bad-form.rs
similarity index 100%
rename from tests/ui/manual/manual-link-bad-form.rs
rename to tests/ui/link-native-libs/manual-link-bad-form.rs
diff --git a/tests/ui/manual/manual-link-bad-form.stderr b/tests/ui/link-native-libs/manual-link-bad-form.stderr
similarity index 100%
rename from tests/ui/manual/manual-link-bad-form.stderr
rename to tests/ui/link-native-libs/manual-link-bad-form.stderr
diff --git a/tests/ui/manual/manual-link-bad-kind.rs b/tests/ui/link-native-libs/manual-link-bad-kind.rs
similarity index 100%
rename from tests/ui/manual/manual-link-bad-kind.rs
rename to tests/ui/link-native-libs/manual-link-bad-kind.rs
diff --git a/tests/ui/manual/manual-link-bad-kind.stderr b/tests/ui/link-native-libs/manual-link-bad-kind.stderr
similarity index 100%
rename from tests/ui/manual/manual-link-bad-kind.stderr
rename to tests/ui/link-native-libs/manual-link-bad-kind.stderr
diff --git a/tests/ui/manual/manual-link-bad-search-path.rs b/tests/ui/link-native-libs/manual-link-bad-search-path.rs
similarity index 100%
rename from tests/ui/manual/manual-link-bad-search-path.rs
rename to tests/ui/link-native-libs/manual-link-bad-search-path.rs
diff --git a/tests/ui/manual/manual-link-bad-search-path.stderr b/tests/ui/link-native-libs/manual-link-bad-search-path.stderr
similarity index 100%
rename from tests/ui/manual/manual-link-bad-search-path.stderr
rename to tests/ui/link-native-libs/manual-link-bad-search-path.stderr
diff --git a/tests/ui/manual/manual-link-framework.rs b/tests/ui/link-native-libs/manual-link-framework.rs
similarity index 100%
rename from tests/ui/manual/manual-link-framework.rs
rename to tests/ui/link-native-libs/manual-link-framework.rs
diff --git a/tests/ui/manual/manual-link-framework.stderr b/tests/ui/link-native-libs/manual-link-framework.stderr
similarity index 100%
rename from tests/ui/manual/manual-link-framework.stderr
rename to tests/ui/link-native-libs/manual-link-framework.stderr
diff --git a/tests/ui/manual/manual-link-unsupported-kind.rs b/tests/ui/link-native-libs/manual-link-unsupported-kind.rs
similarity index 100%
rename from tests/ui/manual/manual-link-unsupported-kind.rs
rename to tests/ui/link-native-libs/manual-link-unsupported-kind.rs
diff --git a/tests/ui/manual/manual-link-unsupported-kind.stderr b/tests/ui/link-native-libs/manual-link-unsupported-kind.stderr
similarity index 100%
rename from tests/ui/manual/manual-link-unsupported-kind.stderr
rename to tests/ui/link-native-libs/manual-link-unsupported-kind.stderr
diff --git a/tests/ui/native-library-link-flags/modifiers-bad.blank.stderr b/tests/ui/link-native-libs/modifiers-bad.blank.stderr
similarity index 100%
rename from tests/ui/native-library-link-flags/modifiers-bad.blank.stderr
rename to tests/ui/link-native-libs/modifiers-bad.blank.stderr
diff --git a/tests/ui/native-library-link-flags/modifiers-bad.no-prefix.stderr b/tests/ui/link-native-libs/modifiers-bad.no-prefix.stderr
similarity index 100%
rename from tests/ui/native-library-link-flags/modifiers-bad.no-prefix.stderr
rename to tests/ui/link-native-libs/modifiers-bad.no-prefix.stderr
diff --git a/tests/ui/native-library-link-flags/modifiers-bad.prefix-only.stderr b/tests/ui/link-native-libs/modifiers-bad.prefix-only.stderr
similarity index 100%
rename from tests/ui/native-library-link-flags/modifiers-bad.prefix-only.stderr
rename to tests/ui/link-native-libs/modifiers-bad.prefix-only.stderr
diff --git a/tests/ui/native-library-link-flags/modifiers-bad.rs b/tests/ui/link-native-libs/modifiers-bad.rs
similarity index 100%
rename from tests/ui/native-library-link-flags/modifiers-bad.rs
rename to tests/ui/link-native-libs/modifiers-bad.rs
diff --git a/tests/ui/native-library-link-flags/modifiers-bad.unknown.stderr b/tests/ui/link-native-libs/modifiers-bad.unknown.stderr
similarity index 100%
rename from tests/ui/native-library-link-flags/modifiers-bad.unknown.stderr
rename to tests/ui/link-native-libs/modifiers-bad.unknown.stderr
diff --git a/tests/ui/native-library-link-flags/modifiers-override-2.rs b/tests/ui/link-native-libs/modifiers-override-2.rs
similarity index 100%
rename from tests/ui/native-library-link-flags/modifiers-override-2.rs
rename to tests/ui/link-native-libs/modifiers-override-2.rs
diff --git a/tests/ui/native-library-link-flags/modifiers-override-2.stderr b/tests/ui/link-native-libs/modifiers-override-2.stderr
similarity index 100%
rename from tests/ui/native-library-link-flags/modifiers-override-2.stderr
rename to tests/ui/link-native-libs/modifiers-override-2.stderr
diff --git a/tests/ui/native-library-link-flags/modifiers-override-3.rs b/tests/ui/link-native-libs/modifiers-override-3.rs
similarity index 100%
rename from tests/ui/native-library-link-flags/modifiers-override-3.rs
rename to tests/ui/link-native-libs/modifiers-override-3.rs
diff --git a/tests/ui/native-library-link-flags/modifiers-override-3.stderr b/tests/ui/link-native-libs/modifiers-override-3.stderr
similarity index 100%
rename from tests/ui/native-library-link-flags/modifiers-override-3.stderr
rename to tests/ui/link-native-libs/modifiers-override-3.stderr
diff --git a/tests/ui/native-library-link-flags/modifiers-override.rs b/tests/ui/link-native-libs/modifiers-override.rs
similarity index 100%
rename from tests/ui/native-library-link-flags/modifiers-override.rs
rename to tests/ui/link-native-libs/modifiers-override.rs
diff --git a/tests/ui/native-library-link-flags/modifiers-override.stderr b/tests/ui/link-native-libs/modifiers-override.stderr
similarity index 100%
rename from tests/ui/native-library-link-flags/modifiers-override.stderr
rename to tests/ui/link-native-libs/modifiers-override.stderr
diff --git a/tests/ui/native-library-link-flags/msvc-non-utf8-output.rs b/tests/ui/link-native-libs/msvc-non-utf8-output.rs
similarity index 100%
rename from tests/ui/native-library-link-flags/msvc-non-utf8-output.rs
rename to tests/ui/link-native-libs/msvc-non-utf8-output.rs
diff --git a/tests/ui/native-library-link-flags/msvc-non-utf8-output.stderr b/tests/ui/link-native-libs/msvc-non-utf8-output.stderr
similarity index 100%
rename from tests/ui/native-library-link-flags/msvc-non-utf8-output.stderr
rename to tests/ui/link-native-libs/msvc-non-utf8-output.stderr
diff --git a/tests/ui/native-library-link-flags/suggest-libname-only-1.rs b/tests/ui/link-native-libs/suggest-libname-only-1.rs
similarity index 100%
rename from tests/ui/native-library-link-flags/suggest-libname-only-1.rs
rename to tests/ui/link-native-libs/suggest-libname-only-1.rs
diff --git a/tests/ui/native-library-link-flags/suggest-libname-only-1.stderr b/tests/ui/link-native-libs/suggest-libname-only-1.stderr
similarity index 100%
rename from tests/ui/native-library-link-flags/suggest-libname-only-1.stderr
rename to tests/ui/link-native-libs/suggest-libname-only-1.stderr
diff --git a/tests/ui/native-library-link-flags/suggest-libname-only-2.rs b/tests/ui/link-native-libs/suggest-libname-only-2.rs
similarity index 100%
rename from tests/ui/native-library-link-flags/suggest-libname-only-2.rs
rename to tests/ui/link-native-libs/suggest-libname-only-2.rs
diff --git a/tests/ui/native-library-link-flags/suggest-libname-only-2.stderr b/tests/ui/link-native-libs/suggest-libname-only-2.stderr
similarity index 100%
rename from tests/ui/native-library-link-flags/suggest-libname-only-2.stderr
rename to tests/ui/link-native-libs/suggest-libname-only-2.stderr

From 0a48b96859d3d66138082ffad6a1057b54cd55c7 Mon Sep 17 00:00:00 2001
From: Zalathar <Zalathar@users.noreply.github.com>
Date: Sat, 7 Dec 2024 12:35:30 +1100
Subject: [PATCH 22/30] Move more tests into `tests/ui/link-native-libs`

---
 src/tools/tidy/src/issues.txt                          | 10 +++++-----
 src/tools/tidy/src/ui_tests.rs                         |  2 +-
 .../auxiliary/link-cfg-works-transitive-dylib.rs       |  0
 .../auxiliary/link-cfg-works-transitive-rlib.rs        |  0
 .../{linkage-attr => link-native-libs}/issue-109144.rs |  0
 .../issue-109144.stderr                                |  0
 tests/ui/{issues => link-native-libs}/issue-43925.rs   |  0
 .../ui/{issues => link-native-libs}/issue-43925.stderr |  0
 tests/ui/{issues => link-native-libs}/issue-43926.rs   |  0
 .../ui/{issues => link-native-libs}/issue-43926.stderr |  0
 .../issue-70093/issue-70093-link-directives.rs         |  0
 .../issue-70093/issue-70093.rs                         |  0
 .../kind-framework.rs                                  |  0
 .../kind-framework.stderr                              |  0
 .../link-attr-validation-early.rs                      |  0
 .../link-attr-validation-early.stderr                  |  0
 .../link-attr-validation-late.rs                       |  0
 .../link-attr-validation-late.stderr                   |  0
 .../link-cfg-works.rs                                  |  0
 .../uikit-framework.rs                                 |  0
 20 files changed, 6 insertions(+), 6 deletions(-)
 rename tests/ui/{linkage-attr => link-native-libs}/auxiliary/link-cfg-works-transitive-dylib.rs (100%)
 rename tests/ui/{linkage-attr => link-native-libs}/auxiliary/link-cfg-works-transitive-rlib.rs (100%)
 rename tests/ui/{linkage-attr => link-native-libs}/issue-109144.rs (100%)
 rename tests/ui/{linkage-attr => link-native-libs}/issue-109144.stderr (100%)
 rename tests/ui/{issues => link-native-libs}/issue-43925.rs (100%)
 rename tests/ui/{issues => link-native-libs}/issue-43925.stderr (100%)
 rename tests/ui/{issues => link-native-libs}/issue-43926.rs (100%)
 rename tests/ui/{issues => link-native-libs}/issue-43926.stderr (100%)
 rename tests/ui/{issues => link-native-libs}/issue-70093/issue-70093-link-directives.rs (100%)
 rename tests/ui/{issues => link-native-libs}/issue-70093/issue-70093.rs (100%)
 rename tests/ui/{linkage-attr => link-native-libs}/kind-framework.rs (100%)
 rename tests/ui/{linkage-attr => link-native-libs}/kind-framework.stderr (100%)
 rename tests/ui/{linkage-attr => link-native-libs}/link-attr-validation-early.rs (100%)
 rename tests/ui/{linkage-attr => link-native-libs}/link-attr-validation-early.stderr (100%)
 rename tests/ui/{linkage-attr => link-native-libs}/link-attr-validation-late.rs (100%)
 rename tests/ui/{linkage-attr => link-native-libs}/link-attr-validation-late.stderr (100%)
 rename tests/ui/{linkage-attr => link-native-libs}/link-cfg-works.rs (100%)
 rename tests/ui/{linkage-attr => link-native-libs}/uikit-framework.rs (100%)

diff --git a/src/tools/tidy/src/issues.txt b/src/tools/tidy/src/issues.txt
index ac82a17e1459f..4088b2de2cdbd 100644
--- a/src/tools/tidy/src/issues.txt
+++ b/src/tools/tidy/src/issues.txt
@@ -2297,8 +2297,6 @@ ui/issues/issue-43853.rs
 ui/issues/issue-4387.rs
 ui/issues/issue-43910.rs
 ui/issues/issue-43923.rs
-ui/issues/issue-43925.rs
-ui/issues/issue-43926.rs
 ui/issues/issue-43988.rs
 ui/issues/issue-44023.rs
 ui/issues/issue-44056.rs
@@ -2547,8 +2545,6 @@ ui/issues/issue-6936.rs
 ui/issues/issue-69455.rs
 ui/issues/issue-69602-type-err-during-codegen-ice.rs
 ui/issues/issue-69683.rs
-ui/issues/issue-70093/issue-70093-link-directives.rs
-ui/issues/issue-70093/issue-70093.rs
 ui/issues/issue-7012.rs
 ui/issues/issue-70381.rs
 ui/issues/issue-7044.rs
@@ -2713,11 +2709,15 @@ ui/limits/issue-17913.rs
 ui/limits/issue-55878.rs
 ui/limits/issue-69485-var-size-diffs-too-large.rs
 ui/limits/issue-75158-64.rs
+ui/link-native-libs/issue-109144.rs
+ui/link-native-libs/issue-43925.rs
+ui/link-native-libs/issue-43926.rs
+ui/link-native-libs/issue-70093/issue-70093-link-directives.rs
+ui/link-native-libs/issue-70093/issue-70093.rs
 ui/linkage-attr/auxiliary/issue-12133-dylib.rs
 ui/linkage-attr/auxiliary/issue-12133-dylib2.rs
 ui/linkage-attr/auxiliary/issue-12133-rlib.rs
 ui/linkage-attr/issue-10755.rs
-ui/linkage-attr/issue-109144.rs
 ui/linkage-attr/issue-12133-1.rs
 ui/linkage-attr/issue-12133-2.rs
 ui/linkage-attr/issue-12133-3.rs
diff --git a/src/tools/tidy/src/ui_tests.rs b/src/tools/tidy/src/ui_tests.rs
index 11f9d5bb03df7..401169c838f71 100644
--- a/src/tools/tidy/src/ui_tests.rs
+++ b/src/tools/tidy/src/ui_tests.rs
@@ -17,7 +17,7 @@ use ignore::Walk;
 const ENTRY_LIMIT: u32 = 901;
 // FIXME: The following limits should be reduced eventually.
 
-const ISSUES_ENTRY_LIMIT: u32 = 1672;
+const ISSUES_ENTRY_LIMIT: u32 = 1667;
 
 const EXPECTED_TEST_FILE_EXTENSIONS: &[&str] = &[
     "rs",     // test source files
diff --git a/tests/ui/linkage-attr/auxiliary/link-cfg-works-transitive-dylib.rs b/tests/ui/link-native-libs/auxiliary/link-cfg-works-transitive-dylib.rs
similarity index 100%
rename from tests/ui/linkage-attr/auxiliary/link-cfg-works-transitive-dylib.rs
rename to tests/ui/link-native-libs/auxiliary/link-cfg-works-transitive-dylib.rs
diff --git a/tests/ui/linkage-attr/auxiliary/link-cfg-works-transitive-rlib.rs b/tests/ui/link-native-libs/auxiliary/link-cfg-works-transitive-rlib.rs
similarity index 100%
rename from tests/ui/linkage-attr/auxiliary/link-cfg-works-transitive-rlib.rs
rename to tests/ui/link-native-libs/auxiliary/link-cfg-works-transitive-rlib.rs
diff --git a/tests/ui/linkage-attr/issue-109144.rs b/tests/ui/link-native-libs/issue-109144.rs
similarity index 100%
rename from tests/ui/linkage-attr/issue-109144.rs
rename to tests/ui/link-native-libs/issue-109144.rs
diff --git a/tests/ui/linkage-attr/issue-109144.stderr b/tests/ui/link-native-libs/issue-109144.stderr
similarity index 100%
rename from tests/ui/linkage-attr/issue-109144.stderr
rename to tests/ui/link-native-libs/issue-109144.stderr
diff --git a/tests/ui/issues/issue-43925.rs b/tests/ui/link-native-libs/issue-43925.rs
similarity index 100%
rename from tests/ui/issues/issue-43925.rs
rename to tests/ui/link-native-libs/issue-43925.rs
diff --git a/tests/ui/issues/issue-43925.stderr b/tests/ui/link-native-libs/issue-43925.stderr
similarity index 100%
rename from tests/ui/issues/issue-43925.stderr
rename to tests/ui/link-native-libs/issue-43925.stderr
diff --git a/tests/ui/issues/issue-43926.rs b/tests/ui/link-native-libs/issue-43926.rs
similarity index 100%
rename from tests/ui/issues/issue-43926.rs
rename to tests/ui/link-native-libs/issue-43926.rs
diff --git a/tests/ui/issues/issue-43926.stderr b/tests/ui/link-native-libs/issue-43926.stderr
similarity index 100%
rename from tests/ui/issues/issue-43926.stderr
rename to tests/ui/link-native-libs/issue-43926.stderr
diff --git a/tests/ui/issues/issue-70093/issue-70093-link-directives.rs b/tests/ui/link-native-libs/issue-70093/issue-70093-link-directives.rs
similarity index 100%
rename from tests/ui/issues/issue-70093/issue-70093-link-directives.rs
rename to tests/ui/link-native-libs/issue-70093/issue-70093-link-directives.rs
diff --git a/tests/ui/issues/issue-70093/issue-70093.rs b/tests/ui/link-native-libs/issue-70093/issue-70093.rs
similarity index 100%
rename from tests/ui/issues/issue-70093/issue-70093.rs
rename to tests/ui/link-native-libs/issue-70093/issue-70093.rs
diff --git a/tests/ui/linkage-attr/kind-framework.rs b/tests/ui/link-native-libs/kind-framework.rs
similarity index 100%
rename from tests/ui/linkage-attr/kind-framework.rs
rename to tests/ui/link-native-libs/kind-framework.rs
diff --git a/tests/ui/linkage-attr/kind-framework.stderr b/tests/ui/link-native-libs/kind-framework.stderr
similarity index 100%
rename from tests/ui/linkage-attr/kind-framework.stderr
rename to tests/ui/link-native-libs/kind-framework.stderr
diff --git a/tests/ui/linkage-attr/link-attr-validation-early.rs b/tests/ui/link-native-libs/link-attr-validation-early.rs
similarity index 100%
rename from tests/ui/linkage-attr/link-attr-validation-early.rs
rename to tests/ui/link-native-libs/link-attr-validation-early.rs
diff --git a/tests/ui/linkage-attr/link-attr-validation-early.stderr b/tests/ui/link-native-libs/link-attr-validation-early.stderr
similarity index 100%
rename from tests/ui/linkage-attr/link-attr-validation-early.stderr
rename to tests/ui/link-native-libs/link-attr-validation-early.stderr
diff --git a/tests/ui/linkage-attr/link-attr-validation-late.rs b/tests/ui/link-native-libs/link-attr-validation-late.rs
similarity index 100%
rename from tests/ui/linkage-attr/link-attr-validation-late.rs
rename to tests/ui/link-native-libs/link-attr-validation-late.rs
diff --git a/tests/ui/linkage-attr/link-attr-validation-late.stderr b/tests/ui/link-native-libs/link-attr-validation-late.stderr
similarity index 100%
rename from tests/ui/linkage-attr/link-attr-validation-late.stderr
rename to tests/ui/link-native-libs/link-attr-validation-late.stderr
diff --git a/tests/ui/linkage-attr/link-cfg-works.rs b/tests/ui/link-native-libs/link-cfg-works.rs
similarity index 100%
rename from tests/ui/linkage-attr/link-cfg-works.rs
rename to tests/ui/link-native-libs/link-cfg-works.rs
diff --git a/tests/ui/linkage-attr/uikit-framework.rs b/tests/ui/link-native-libs/uikit-framework.rs
similarity index 100%
rename from tests/ui/linkage-attr/uikit-framework.rs
rename to tests/ui/link-native-libs/uikit-framework.rs

From 88669aed22aeeef5fb7ecdb7f43ed33e674f8fcb Mon Sep 17 00:00:00 2001
From: Michael Goulet <michael@errs.io>
Date: Sat, 7 Dec 2024 23:54:10 +0000
Subject: [PATCH 23/30] Don't use AsyncFnOnce::CallOnceFuture bounds for
 signature deduction

---
 compiler/rustc_hir_typeck/src/closure.rs           | 12 ++++--------
 .../async-closures/call-once-deduction.rs          | 14 ++++++++++++++
 2 files changed, 18 insertions(+), 8 deletions(-)
 create mode 100644 tests/ui/async-await/async-closures/call-once-deduction.rs

diff --git a/compiler/rustc_hir_typeck/src/closure.rs b/compiler/rustc_hir_typeck/src/closure.rs
index e715a7f7e1588..9037caf0066fe 100644
--- a/compiler/rustc_hir_typeck/src/closure.rs
+++ b/compiler/rustc_hir_typeck/src/closure.rs
@@ -454,20 +454,16 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
         closure_kind: hir::ClosureKind,
         projection: ty::PolyProjectionPredicate<'tcx>,
     ) -> Option<ExpectedSig<'tcx>> {
-        let tcx = self.tcx;
-
-        let trait_def_id = projection.trait_def_id(tcx);
+        let def_id = projection.projection_def_id();
 
         // For now, we only do signature deduction based off of the `Fn` and `AsyncFn` traits,
         // for closures and async closures, respectively.
         match closure_kind {
-            hir::ClosureKind::Closure
-                if self.tcx.fn_trait_kind_from_def_id(trait_def_id).is_some() =>
-            {
+            hir::ClosureKind::Closure if self.tcx.is_lang_item(def_id, LangItem::FnOnceOutput) => {
                 self.extract_sig_from_projection(cause_span, projection)
             }
             hir::ClosureKind::CoroutineClosure(hir::CoroutineDesugaring::Async)
-                if self.tcx.async_fn_trait_kind_from_def_id(trait_def_id).is_some() =>
+                if self.tcx.is_lang_item(def_id, LangItem::AsyncFnOnceOutput) =>
             {
                 self.extract_sig_from_projection(cause_span, projection)
             }
@@ -475,7 +471,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
             // `F: FnOnce() -> Fut, Fut: Future<Output = T>` style bound. Let's still
             // guide inference here, since it's beneficial for the user.
             hir::ClosureKind::CoroutineClosure(hir::CoroutineDesugaring::Async)
-                if self.tcx.fn_trait_kind_from_def_id(trait_def_id).is_some() =>
+                if self.tcx.is_lang_item(def_id, LangItem::FnOnceOutput) =>
             {
                 self.extract_sig_from_projection_and_future_bound(cause_span, projection)
             }
diff --git a/tests/ui/async-await/async-closures/call-once-deduction.rs b/tests/ui/async-await/async-closures/call-once-deduction.rs
new file mode 100644
index 0000000000000..41d92bc3d786c
--- /dev/null
+++ b/tests/ui/async-await/async-closures/call-once-deduction.rs
@@ -0,0 +1,14 @@
+//@ edition: 2021
+//@ check-pass
+
+#![feature(async_closure, async_fn_traits, unboxed_closures)]
+
+fn bar<F, O>(_: F)
+where
+    F: AsyncFnOnce<(), CallOnceFuture = O>,
+{
+}
+
+fn main() {
+    bar(async move || {});
+}

From 9eb35a00baa0bb864c362eebd96e0447152887f6 Mon Sep 17 00:00:00 2001
From: Folkert de Vries <folkert@folkertdev.nl>
Date: Sun, 1 Dec 2024 14:55:17 +0100
Subject: [PATCH 24/30] fix the `naked-asan` test

we get these declarations

```
; opt level 0
declare x86_intrcc void @page_fault_handler(ptr byval([8 x i8]) align 8, i64) unnamed_addr #1
; opt level > 0
declare x86_intrcc void @page_fault_handler(ptr noalias nocapture noundef byval([8 x i8]) align 8 dereferenceable(8), i64 noundef) unnamed_addr #1
```

The space after `i64` in the original regex made the regex not match for
opt level 0. Removing the space fixes the issue.

```
declare x86_intrcc void @page_fault_handler(ptr {{.*}}, i64 {{.*}}){{.*}}#[[ATTRS:[0-9]+]]
```
---
 tests/codegen/naked-asan.rs | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/tests/codegen/naked-asan.rs b/tests/codegen/naked-asan.rs
index 639f069c0d9e5..8efedab6ea55d 100644
--- a/tests/codegen/naked-asan.rs
+++ b/tests/codegen/naked-asan.rs
@@ -12,14 +12,11 @@ pub fn caller() {
     page_fault_handler(1, 2);
 }
 
-// CHECK: declare x86_intrcc void @page_fault_handler(ptr {{.*}}, i64 {{.*}}){{.*}}#[[ATTRS:[0-9]+]]
-// CHECK-NOT: memcpy
+// CHECK: declare x86_intrcc void @page_fault_handler(ptr {{.*}}, i64{{.*}}){{.*}}#[[ATTRS:[0-9]+]]
 #[naked]
 #[no_mangle]
 pub extern "x86-interrupt" fn page_fault_handler(_: u64, _: u64) {
-    unsafe {
-        core::arch::naked_asm!("ud2");
-    }
+    unsafe { core::arch::naked_asm!("ud2") };
 }
 
 // CHECK: #[[ATTRS]] =

From c4d7f1d29f05e9655e3827529ba4da3438e3e1fb Mon Sep 17 00:00:00 2001
From: onur-ozkan <work@onurozkan.dev>
Date: Sun, 8 Dec 2024 18:27:22 +0300
Subject: [PATCH 25/30] implement `TargetSelection::is_cygwin` function

Signed-off-by: onur-ozkan <work@onurozkan.dev>
---
 src/bootstrap/src/core/config/config.rs | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/src/bootstrap/src/core/config/config.rs b/src/bootstrap/src/core/config/config.rs
index b06147055f2a7..a07d1597746c2 100644
--- a/src/bootstrap/src/core/config/config.rs
+++ b/src/bootstrap/src/core/config/config.rs
@@ -565,6 +565,12 @@ impl TargetSelection {
         self.ends_with("windows-gnu")
     }
 
+    pub fn is_cygwin(&self) -> bool {
+        self.is_windows() &&
+        // ref. https://cygwin.com/pipermail/cygwin/2022-February/250802.html
+        env::var("OSTYPE").is_ok_and(|v| v.to_lowercase().contains("cygwin"))
+    }
+
     /// Path to the file defining the custom target, if any.
     pub fn filepath(&self) -> Option<&Path> {
         self.file.as_ref().map(Path::new)

From d3b53408789ad749b027a1932459e22bc2685622 Mon Sep 17 00:00:00 2001
From: onur-ozkan <work@onurozkan.dev>
Date: Sun, 8 Dec 2024 18:27:46 +0300
Subject: [PATCH 26/30] handle cygwin environments in `install::sanitize_sh`

Signed-off-by: onur-ozkan <work@onurozkan.dev>
---
 src/bootstrap/src/core/build_steps/install.rs | 25 ++++++++++---------
 1 file changed, 13 insertions(+), 12 deletions(-)

diff --git a/src/bootstrap/src/core/build_steps/install.rs b/src/bootstrap/src/core/build_steps/install.rs
index 0ce86eadbce67..b6862c2d5c4a9 100644
--- a/src/bootstrap/src/core/build_steps/install.rs
+++ b/src/bootstrap/src/core/build_steps/install.rs
@@ -21,9 +21,9 @@ const SHELL: &str = "sh";
 
 /// We have to run a few shell scripts, which choke quite a bit on both `\`
 /// characters and on `C:\` paths, so normalize both of them away.
-fn sanitize_sh(path: &Path) -> String {
+fn sanitize_sh(path: &Path, is_cygwin: bool) -> String {
     let path = path.to_str().unwrap().replace('\\', "/");
-    return change_drive(unc_to_lfs(&path)).unwrap_or(path);
+    return if is_cygwin { path } else { change_drive(unc_to_lfs(&path)).unwrap_or(path) };
 
     fn unc_to_lfs(s: &str) -> &str {
         s.strip_prefix("//?/").unwrap_or(s)
@@ -71,6 +71,7 @@ fn install_sh(
     let prefix = default_path(&builder.config.prefix, "/usr/local");
     let sysconfdir = prefix.join(default_path(&builder.config.sysconfdir, "/etc"));
     let destdir_env = env::var_os("DESTDIR").map(PathBuf::from);
+    let is_cygwin = builder.config.build.is_cygwin();
 
     // Sanity checks on the write access of user.
     //
@@ -103,14 +104,14 @@ fn install_sh(
 
     let mut cmd = command(SHELL);
     cmd.current_dir(&empty_dir)
-        .arg(sanitize_sh(&tarball.decompressed_output().join("install.sh")))
-        .arg(format!("--prefix={}", prepare_dir(&destdir_env, prefix)))
-        .arg(format!("--sysconfdir={}", prepare_dir(&destdir_env, sysconfdir)))
-        .arg(format!("--datadir={}", prepare_dir(&destdir_env, datadir)))
-        .arg(format!("--docdir={}", prepare_dir(&destdir_env, docdir)))
-        .arg(format!("--bindir={}", prepare_dir(&destdir_env, bindir)))
-        .arg(format!("--libdir={}", prepare_dir(&destdir_env, libdir)))
-        .arg(format!("--mandir={}", prepare_dir(&destdir_env, mandir)))
+        .arg(sanitize_sh(&tarball.decompressed_output().join("install.sh"), is_cygwin))
+        .arg(format!("--prefix={}", prepare_dir(&destdir_env, prefix, is_cygwin)))
+        .arg(format!("--sysconfdir={}", prepare_dir(&destdir_env, sysconfdir, is_cygwin)))
+        .arg(format!("--datadir={}", prepare_dir(&destdir_env, datadir, is_cygwin)))
+        .arg(format!("--docdir={}", prepare_dir(&destdir_env, docdir, is_cygwin)))
+        .arg(format!("--bindir={}", prepare_dir(&destdir_env, bindir, is_cygwin)))
+        .arg(format!("--libdir={}", prepare_dir(&destdir_env, libdir, is_cygwin)))
+        .arg(format!("--mandir={}", prepare_dir(&destdir_env, mandir, is_cygwin)))
         .arg("--disable-ldconfig");
     cmd.run(builder);
     t!(fs::remove_dir_all(&empty_dir));
@@ -120,7 +121,7 @@ fn default_path(config: &Option<PathBuf>, default: &str) -> PathBuf {
     config.as_ref().cloned().unwrap_or_else(|| PathBuf::from(default))
 }
 
-fn prepare_dir(destdir_env: &Option<PathBuf>, mut path: PathBuf) -> String {
+fn prepare_dir(destdir_env: &Option<PathBuf>, mut path: PathBuf, is_cygwin: bool) -> String {
     // The DESTDIR environment variable is a standard way to install software in a subdirectory
     // while keeping the original directory structure, even if the prefix or other directories
     // contain absolute paths.
@@ -146,7 +147,7 @@ fn prepare_dir(destdir_env: &Option<PathBuf>, mut path: PathBuf) -> String {
         assert!(path.is_absolute(), "could not make the path relative");
     }
 
-    sanitize_sh(&path)
+    sanitize_sh(&path, is_cygwin)
 }
 
 macro_rules! install {

From 5e66869c65209b5555d78e9f96dab831ebc325af Mon Sep 17 00:00:00 2001
From: bjorn3 <17426603+bjorn3@users.noreply.github.com>
Date: Fri, 6 Dec 2024 12:05:25 +0000
Subject: [PATCH 27/30] Pass the arch rather than full target name to
 windows_registry::find_tool

The full target name can be anything with custom target specs. Passing
just the arch wasn't possible before cc 1.2, but is now.
---
 compiler/rustc_codegen_ssa/src/back/link.rs   | 8 ++------
 compiler/rustc_codegen_ssa/src/back/linker.rs | 3 +--
 2 files changed, 3 insertions(+), 8 deletions(-)

diff --git a/compiler/rustc_codegen_ssa/src/back/link.rs b/compiler/rustc_codegen_ssa/src/back/link.rs
index ad81ff272c62f..c3281c8c2e5c0 100644
--- a/compiler/rustc_codegen_ssa/src/back/link.rs
+++ b/compiler/rustc_codegen_ssa/src/back/link.rs
@@ -1021,12 +1021,8 @@ fn link_natively(
                         && (code < 1000 || code > 9999)
                     {
                         let is_vs_installed = windows_registry::find_vs_version().is_ok();
-                        // FIXME(cc-rs#1265) pass only target arch to find_tool()
-                        let has_linker = windows_registry::find_tool(
-                            sess.opts.target_triple.tuple(),
-                            "link.exe",
-                        )
-                        .is_some();
+                        let has_linker =
+                            windows_registry::find_tool(&sess.target.arch, "link.exe").is_some();
 
                         sess.dcx().emit_note(errors::LinkExeUnexpectedError);
                         if is_vs_installed && has_linker {
diff --git a/compiler/rustc_codegen_ssa/src/back/linker.rs b/compiler/rustc_codegen_ssa/src/back/linker.rs
index 05dfbd40a0ad6..17323f67ffa70 100644
--- a/compiler/rustc_codegen_ssa/src/back/linker.rs
+++ b/compiler/rustc_codegen_ssa/src/back/linker.rs
@@ -50,8 +50,7 @@ pub(crate) fn get_linker<'a>(
     self_contained: bool,
     target_cpu: &'a str,
 ) -> Box<dyn Linker + 'a> {
-    // FIXME(cc-rs#1265) pass only target arch to find_tool()
-    let msvc_tool = windows_registry::find_tool(sess.opts.target_triple.tuple(), "link.exe");
+    let msvc_tool = windows_registry::find_tool(&sess.target.arch, "link.exe");
 
     // If our linker looks like a batch script on Windows then to execute this
     // we'll need to spawn `cmd` explicitly. This is primarily done to handle

From 2d8a871d4b6e1d636ac7c44742c54551e0d3fc09 Mon Sep 17 00:00:00 2001
From: clubby789 <jamie@hill-daniel.co.uk>
Date: Sun, 8 Dec 2024 18:18:03 +0000
Subject: [PATCH 28/30] Downgrade cc

---
 Cargo.lock                    | 4 ++--
 library/Cargo.lock            | 4 ++--
 src/tools/rustbook/Cargo.lock | 4 ++--
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/Cargo.lock b/Cargo.lock
index 89e7d70d839ae..28478876a27a7 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -405,9 +405,9 @@ version = "0.1.0"
 
 [[package]]
 name = "cc"
-version = "1.2.2"
+version = "1.2.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f34d93e62b03caf570cccc334cbc6c2fceca82f39211051345108adcba3eebdc"
+checksum = "1aeb932158bd710538c73702db6945cb68a8fb08c519e6e12706b94263b36db8"
 dependencies = [
  "shlex",
 ]
diff --git a/library/Cargo.lock b/library/Cargo.lock
index 490c989300f58..03c2356e542a5 100644
--- a/library/Cargo.lock
+++ b/library/Cargo.lock
@@ -42,9 +42,9 @@ checksum = "45862d1c77f2228b9e10bc609d5bc203d86ebc9b87ad8d5d5167a6c9abf739d9"
 
 [[package]]
 name = "cc"
-version = "1.2.2"
+version = "1.2.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f34d93e62b03caf570cccc334cbc6c2fceca82f39211051345108adcba3eebdc"
+checksum = "1aeb932158bd710538c73702db6945cb68a8fb08c519e6e12706b94263b36db8"
 dependencies = [
  "shlex",
 ]
diff --git a/src/tools/rustbook/Cargo.lock b/src/tools/rustbook/Cargo.lock
index 3d35779be90f3..bab818899fbc5 100644
--- a/src/tools/rustbook/Cargo.lock
+++ b/src/tools/rustbook/Cargo.lock
@@ -161,9 +161,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b"
 
 [[package]]
 name = "cc"
-version = "1.2.2"
+version = "1.2.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f34d93e62b03caf570cccc334cbc6c2fceca82f39211051345108adcba3eebdc"
+checksum = "1aeb932158bd710538c73702db6945cb68a8fb08c519e6e12706b94263b36db8"
 dependencies = [
  "shlex",
 ]

From 999aed4bff113924393ca55f3d6498d5c723f037 Mon Sep 17 00:00:00 2001
From: Michael Howell <michael@notriddle.com>
Date: Sun, 8 Dec 2024 21:39:48 -0700
Subject: [PATCH 29/30] Add URL to test cases

---
 tests/rustdoc-ui/issues/issue-101076.rs | 1 +
 tests/rustdoc-ui/issues/issue-102986.rs | 1 +
 tests/rustdoc-ui/issues/issue-103997.rs | 1 +
 tests/rustdoc-ui/issues/issue-105334.rs | 1 +
 tests/rustdoc-ui/issues/issue-105737.rs | 1 +
 tests/rustdoc-ui/issues/issue-105742.rs | 1 +
 tests/rustdoc-ui/issues/issue-106213.rs | 1 +
 tests/rustdoc-ui/issues/issue-107918.rs | 1 +
 tests/rustdoc-ui/issues/issue-110900.rs | 1 +
 9 files changed, 9 insertions(+)

diff --git a/tests/rustdoc-ui/issues/issue-101076.rs b/tests/rustdoc-ui/issues/issue-101076.rs
index f9b93c408fd68..0c9a8b9175b3d 100644
--- a/tests/rustdoc-ui/issues/issue-101076.rs
+++ b/tests/rustdoc-ui/issues/issue-101076.rs
@@ -1,4 +1,5 @@
 //@ check-pass
+// https://github.com/rust-lang/rust/issues/101076
 
 const _: () = {
     #[macro_export]
diff --git a/tests/rustdoc-ui/issues/issue-102986.rs b/tests/rustdoc-ui/issues/issue-102986.rs
index 001784ac28561..8fcbfffe17246 100644
--- a/tests/rustdoc-ui/issues/issue-102986.rs
+++ b/tests/rustdoc-ui/issues/issue-102986.rs
@@ -1,3 +1,4 @@
+// https://github.com/rust-lang/rust/issues/102986
 struct Struct {
     y: (typeof("hey"),),
     //~^ `typeof` is a reserved keyword but unimplemented
diff --git a/tests/rustdoc-ui/issues/issue-103997.rs b/tests/rustdoc-ui/issues/issue-103997.rs
index ebd1d2e4447d8..b6ba4e48cffd6 100644
--- a/tests/rustdoc-ui/issues/issue-103997.rs
+++ b/tests/rustdoc-ui/issues/issue-103997.rs
@@ -1,4 +1,5 @@
 //@ check-pass
+// https://github.com/rust-lang/rust/issues/103997
 
 pub fn foo() {}
 
diff --git a/tests/rustdoc-ui/issues/issue-105334.rs b/tests/rustdoc-ui/issues/issue-105334.rs
index ee1adc6a02914..f18f0456fdde8 100644
--- a/tests/rustdoc-ui/issues/issue-105334.rs
+++ b/tests/rustdoc-ui/issues/issue-105334.rs
@@ -1,2 +1,3 @@
+// https://github.com/rust-lang/rust/issues/105334
 impl Vec< br##"*.."## > {}
 //~^ ERROR
diff --git a/tests/rustdoc-ui/issues/issue-105737.rs b/tests/rustdoc-ui/issues/issue-105737.rs
index 154f069d8ffac..651fd9ab4b8b3 100644
--- a/tests/rustdoc-ui/issues/issue-105737.rs
+++ b/tests/rustdoc-ui/issues/issue-105737.rs
@@ -1,3 +1,4 @@
+// https://github.com/rust-lang/rust/issues/105737
 impl Vec<lol> {}
 //~^ ERROR
 
diff --git a/tests/rustdoc-ui/issues/issue-105742.rs b/tests/rustdoc-ui/issues/issue-105742.rs
index bd8ec4e8b589e..027574923c7ad 100644
--- a/tests/rustdoc-ui/issues/issue-105742.rs
+++ b/tests/rustdoc-ui/issues/issue-105742.rs
@@ -1,4 +1,5 @@
 //@ compile-flags: -Znormalize-docs
+// https://github.com/rust-lang/rust/issues/105742
 use std::ops::Index;
 
 pub fn next<'a, T>(s: &'a mut dyn SVec<Item = T, Output = T>) {
diff --git a/tests/rustdoc-ui/issues/issue-106213.rs b/tests/rustdoc-ui/issues/issue-106213.rs
index 5c3a83902523f..c954162589d9e 100644
--- a/tests/rustdoc-ui/issues/issue-106213.rs
+++ b/tests/rustdoc-ui/issues/issue-106213.rs
@@ -1,5 +1,6 @@
 //@ compile-flags: --document-private-items
 //@ edition:2021
+// https://github.com/rust-lang/rust/issues/106213
 
 fn use_avx() -> dyn  {
     //~^ ERROR at least one trait is required for an object type
diff --git a/tests/rustdoc-ui/issues/issue-107918.rs b/tests/rustdoc-ui/issues/issue-107918.rs
index 19d53f84cb66e..ec35b52e33b0d 100644
--- a/tests/rustdoc-ui/issues/issue-107918.rs
+++ b/tests/rustdoc-ui/issues/issue-107918.rs
@@ -2,6 +2,7 @@
 //@ compile-flags: --document-private-items
 //@ build-pass
 //@ only-linux
+// https://github.com/rust-lang/rust/issues/107918
 
 #![no_std]
 #![no_main]
diff --git a/tests/rustdoc-ui/issues/issue-110900.rs b/tests/rustdoc-ui/issues/issue-110900.rs
index 5a8961670833f..4fa60f8878d1d 100644
--- a/tests/rustdoc-ui/issues/issue-110900.rs
+++ b/tests/rustdoc-ui/issues/issue-110900.rs
@@ -1,4 +1,5 @@
 //@ check-pass
+// https://github.com/rust-lang/rust/issues/110900
 
 #![crate_type="lib"]
 

From b5318549c701771bde8b06709a69d7e3eb860c1f Mon Sep 17 00:00:00 2001
From: Michael Howell <michael@notriddle.com>
Date: Sun, 8 Dec 2024 21:59:23 -0700
Subject: [PATCH 30/30] rustdoc: rename `issue-\d+.rs` tests to have meaningful
 names

---
 ...7918.rs => duplicate-panic-impl-107918.rs} |   0
 ...s => ice-associated-type-bounds-110900.rs} |   0
 ...issue-106213.rs => ice-bare-dyn-106213.rs} |   0
 ...6213.stderr => ice-bare-dyn-106213.stderr} |   2 +-
 ...42.rs => ice-generic-type-alias-105742.rs} |   0
 ...r => ice-generic-type-alias-105742.stderr} | 148 +++++++++---------
 ...05737.rs => ice-impl-fn-generic-105737.rs} |   0
 ...derr => ice-impl-fn-generic-105737.stderr} |   2 +-
 ...cro-hidden-exported-macro-defid-101076.rs} |   0
 ...s => ice-placeholder-type-alias-106226.rs} |   0
 ... ice-placeholder-type-alias-106226.stderr} |   2 +-
 ...{issue-105334.rs => ice-raw-str-105334.rs} |   0
 ...05334.stderr => ice-raw-str-105334.stderr} |   2 +-
 .../{issue-102986.rs => ice-typeof-102986.rs} |   0
 ...102986.stderr => ice-typeof-102986.stderr} |   2 +-
 ...03997.rs => ice-unresolved-self-103997.rs} |   0
 ...derr => ice-unresolved-self-103997.stderr} |   2 +-
 17 files changed, 80 insertions(+), 80 deletions(-)
 rename tests/rustdoc-ui/issues/{issue-107918.rs => duplicate-panic-impl-107918.rs} (100%)
 rename tests/rustdoc-ui/issues/{issue-110900.rs => ice-associated-type-bounds-110900.rs} (100%)
 rename tests/rustdoc-ui/issues/{issue-106213.rs => ice-bare-dyn-106213.rs} (100%)
 rename tests/rustdoc-ui/issues/{issue-106213.stderr => ice-bare-dyn-106213.stderr} (85%)
 rename tests/rustdoc-ui/issues/{issue-105742.rs => ice-generic-type-alias-105742.rs} (100%)
 rename tests/rustdoc-ui/issues/{issue-105742.stderr => ice-generic-type-alias-105742.stderr} (84%)
 rename tests/rustdoc-ui/issues/{issue-105737.rs => ice-impl-fn-generic-105737.rs} (100%)
 rename tests/rustdoc-ui/issues/{issue-105737.stderr => ice-impl-fn-generic-105737.stderr} (87%)
 rename tests/rustdoc-ui/issues/{issue-101076.rs => ice-macro-hidden-exported-macro-defid-101076.rs} (100%)
 rename tests/rustdoc-ui/issues/{issue-106226.rs => ice-placeholder-type-alias-106226.rs} (100%)
 rename tests/rustdoc-ui/issues/{issue-106226.stderr => ice-placeholder-type-alias-106226.stderr} (84%)
 rename tests/rustdoc-ui/issues/{issue-105334.rs => ice-raw-str-105334.rs} (100%)
 rename tests/rustdoc-ui/issues/{issue-105334.stderr => ice-raw-str-105334.stderr} (85%)
 rename tests/rustdoc-ui/issues/{issue-102986.rs => ice-typeof-102986.rs} (100%)
 rename tests/rustdoc-ui/issues/{issue-102986.stderr => ice-typeof-102986.stderr} (90%)
 rename tests/rustdoc-ui/issues/{issue-103997.rs => ice-unresolved-self-103997.rs} (100%)
 rename tests/rustdoc-ui/issues/{issue-103997.stderr => ice-unresolved-self-103997.stderr} (83%)

diff --git a/tests/rustdoc-ui/issues/issue-107918.rs b/tests/rustdoc-ui/issues/duplicate-panic-impl-107918.rs
similarity index 100%
rename from tests/rustdoc-ui/issues/issue-107918.rs
rename to tests/rustdoc-ui/issues/duplicate-panic-impl-107918.rs
diff --git a/tests/rustdoc-ui/issues/issue-110900.rs b/tests/rustdoc-ui/issues/ice-associated-type-bounds-110900.rs
similarity index 100%
rename from tests/rustdoc-ui/issues/issue-110900.rs
rename to tests/rustdoc-ui/issues/ice-associated-type-bounds-110900.rs
diff --git a/tests/rustdoc-ui/issues/issue-106213.rs b/tests/rustdoc-ui/issues/ice-bare-dyn-106213.rs
similarity index 100%
rename from tests/rustdoc-ui/issues/issue-106213.rs
rename to tests/rustdoc-ui/issues/ice-bare-dyn-106213.rs
diff --git a/tests/rustdoc-ui/issues/issue-106213.stderr b/tests/rustdoc-ui/issues/ice-bare-dyn-106213.stderr
similarity index 85%
rename from tests/rustdoc-ui/issues/issue-106213.stderr
rename to tests/rustdoc-ui/issues/ice-bare-dyn-106213.stderr
index fa79fe2e71c10..b029fee510ee9 100644
--- a/tests/rustdoc-ui/issues/issue-106213.stderr
+++ b/tests/rustdoc-ui/issues/ice-bare-dyn-106213.stderr
@@ -1,5 +1,5 @@
 error[E0224]: at least one trait is required for an object type
-  --> $DIR/issue-106213.rs:4:17
+  --> $DIR/ice-bare-dyn-106213.rs:5:17
    |
 LL | fn use_avx() -> dyn  {
    |                 ^^^
diff --git a/tests/rustdoc-ui/issues/issue-105742.rs b/tests/rustdoc-ui/issues/ice-generic-type-alias-105742.rs
similarity index 100%
rename from tests/rustdoc-ui/issues/issue-105742.rs
rename to tests/rustdoc-ui/issues/ice-generic-type-alias-105742.rs
diff --git a/tests/rustdoc-ui/issues/issue-105742.stderr b/tests/rustdoc-ui/issues/ice-generic-type-alias-105742.stderr
similarity index 84%
rename from tests/rustdoc-ui/issues/issue-105742.stderr
rename to tests/rustdoc-ui/issues/ice-generic-type-alias-105742.stderr
index 0f09d637f38fe..06a1cf6b118da 100644
--- a/tests/rustdoc-ui/issues/issue-105742.stderr
+++ b/tests/rustdoc-ui/issues/ice-generic-type-alias-105742.stderr
@@ -1,11 +1,11 @@
 error[E0107]: missing generics for associated type `SVec::Item`
-  --> $DIR/issue-105742.rs:15:21
+  --> $DIR/ice-generic-type-alias-105742.rs:16:21
    |
 LL |     <Self as SVec>::Item,
    |                     ^^^^ expected 1 lifetime argument
    |
 note: associated type defined here, with 1 lifetime parameter: `'a`
-  --> $DIR/issue-105742.rs:59:10
+  --> $DIR/ice-generic-type-alias-105742.rs:60:10
    |
 LL |     type Item<'a, T>;
    |          ^^^^ --
@@ -15,13 +15,13 @@ LL |     <Self as SVec>::Item<'a>,
    |                         ++++
 
 error[E0107]: missing generics for associated type `SVec::Item`
-  --> $DIR/issue-105742.rs:15:21
+  --> $DIR/ice-generic-type-alias-105742.rs:16:21
    |
 LL |     <Self as SVec>::Item,
    |                     ^^^^ expected 1 generic argument
    |
 note: associated type defined here, with 1 generic parameter: `T`
-  --> $DIR/issue-105742.rs:59:10
+  --> $DIR/ice-generic-type-alias-105742.rs:60:10
    |
 LL |     type Item<'a, T>;
    |          ^^^^     -
@@ -31,13 +31,13 @@ LL |     <Self as SVec>::Item<T>,
    |                         +++
 
 error[E0107]: missing generics for associated type `SVec::Item`
-  --> $DIR/issue-105742.rs:26:37
+  --> $DIR/ice-generic-type-alias-105742.rs:27:37
    |
 LL |     Output = <Index<<Self as SVec>::Item,
    |                                     ^^^^ expected 1 lifetime argument
    |
 note: associated type defined here, with 1 lifetime parameter: `'a`
-  --> $DIR/issue-105742.rs:59:10
+  --> $DIR/ice-generic-type-alias-105742.rs:60:10
    |
 LL |     type Item<'a, T>;
    |          ^^^^ --
@@ -47,13 +47,13 @@ LL |     Output = <Index<<Self as SVec>::Item<'a>,
    |                                         ++++
 
 error[E0107]: missing generics for associated type `SVec::Item`
-  --> $DIR/issue-105742.rs:26:37
+  --> $DIR/ice-generic-type-alias-105742.rs:27:37
    |
 LL |     Output = <Index<<Self as SVec>::Item,
    |                                     ^^^^ expected 1 generic argument
    |
 note: associated type defined here, with 1 generic parameter: `T`
-  --> $DIR/issue-105742.rs:59:10
+  --> $DIR/ice-generic-type-alias-105742.rs:60:10
    |
 LL |     type Item<'a, T>;
    |          ^^^^     -
@@ -63,13 +63,13 @@ LL |     Output = <Index<<Self as SVec>::Item<T>,
    |                                         +++
 
 error[E0107]: missing generics for associated type `SVec::Item`
-  --> $DIR/issue-105742.rs:37:30
+  --> $DIR/ice-generic-type-alias-105742.rs:38:30
    |
 LL |     Output = <Self as SVec>::Item> as SVec>::Item,
    |                              ^^^^ expected 1 lifetime argument
    |
 note: associated type defined here, with 1 lifetime parameter: `'a`
-  --> $DIR/issue-105742.rs:59:10
+  --> $DIR/ice-generic-type-alias-105742.rs:60:10
    |
 LL |     type Item<'a, T>;
    |          ^^^^ --
@@ -79,13 +79,13 @@ LL |     Output = <Self as SVec>::Item<'a>> as SVec>::Item,
    |                                  ++++
 
 error[E0107]: missing generics for associated type `SVec::Item`
-  --> $DIR/issue-105742.rs:37:30
+  --> $DIR/ice-generic-type-alias-105742.rs:38:30
    |
 LL |     Output = <Self as SVec>::Item> as SVec>::Item,
    |                              ^^^^ expected 1 generic argument
    |
 note: associated type defined here, with 1 generic parameter: `T`
-  --> $DIR/issue-105742.rs:59:10
+  --> $DIR/ice-generic-type-alias-105742.rs:60:10
    |
 LL |     type Item<'a, T>;
    |          ^^^^     -
@@ -95,13 +95,13 @@ LL |     Output = <Self as SVec>::Item<T>> as SVec>::Item,
    |                                  +++
 
 error[E0107]: missing generics for associated type `SVec::Item`
-  --> $DIR/issue-105742.rs:37:46
+  --> $DIR/ice-generic-type-alias-105742.rs:38:46
    |
 LL |     Output = <Self as SVec>::Item> as SVec>::Item,
    |                                              ^^^^ expected 1 lifetime argument
    |
 note: associated type defined here, with 1 lifetime parameter: `'a`
-  --> $DIR/issue-105742.rs:59:10
+  --> $DIR/ice-generic-type-alias-105742.rs:60:10
    |
 LL |     type Item<'a, T>;
    |          ^^^^ --
@@ -111,13 +111,13 @@ LL |     Output = <Self as SVec>::Item> as SVec>::Item<'a>,
    |                                                  ++++
 
 error[E0107]: missing generics for associated type `SVec::Item`
-  --> $DIR/issue-105742.rs:37:46
+  --> $DIR/ice-generic-type-alias-105742.rs:38:46
    |
 LL |     Output = <Self as SVec>::Item> as SVec>::Item,
    |                                              ^^^^ expected 1 generic argument
    |
 note: associated type defined here, with 1 generic parameter: `T`
-  --> $DIR/issue-105742.rs:59:10
+  --> $DIR/ice-generic-type-alias-105742.rs:60:10
    |
 LL |     type Item<'a, T>;
    |          ^^^^     -
@@ -127,13 +127,13 @@ LL |     Output = <Self as SVec>::Item> as SVec>::Item<T>,
    |                                                  +++
 
 error[E0107]: missing generics for associated type `SVec::Item`
-  --> $DIR/issue-105742.rs:4:40
+  --> $DIR/ice-generic-type-alias-105742.rs:5:40
    |
 LL | pub fn next<'a, T>(s: &'a mut dyn SVec<Item = T, Output = T>) {
    |                                        ^^^^ expected 1 lifetime argument
    |
 note: associated type defined here, with 1 lifetime parameter: `'a`
-  --> $DIR/issue-105742.rs:59:10
+  --> $DIR/ice-generic-type-alias-105742.rs:60:10
    |
 LL |     type Item<'a, T>;
    |          ^^^^ --
@@ -143,13 +143,13 @@ LL | pub fn next<'a, T>(s: &'a mut dyn SVec<Item<'_> = T, Output = T>) {
    |                                            ++++
 
 error[E0107]: missing generics for associated type `SVec::Item`
-  --> $DIR/issue-105742.rs:4:40
+  --> $DIR/ice-generic-type-alias-105742.rs:5:40
    |
 LL | pub fn next<'a, T>(s: &'a mut dyn SVec<Item = T, Output = T>) {
    |                                        ^^^^ expected 1 generic argument
    |
 note: associated type defined here, with 1 generic parameter: `T`
-  --> $DIR/issue-105742.rs:59:10
+  --> $DIR/ice-generic-type-alias-105742.rs:60:10
    |
 LL |     type Item<'a, T>;
    |          ^^^^     -
@@ -159,13 +159,13 @@ LL | pub fn next<'a, T>(s: &'a mut dyn SVec<Item<T> = T, Output = T>) {
    |                                            +++
 
 error[E0107]: missing generics for associated type `SVec::Item`
-  --> $DIR/issue-105742.rs:15:21
+  --> $DIR/ice-generic-type-alias-105742.rs:16:21
    |
 LL |     <Self as SVec>::Item,
    |                     ^^^^ expected 1 lifetime argument
    |
 note: associated type defined here, with 1 lifetime parameter: `'a`
-  --> $DIR/issue-105742.rs:59:10
+  --> $DIR/ice-generic-type-alias-105742.rs:60:10
    |
 LL |     type Item<'a, T>;
    |          ^^^^ --
@@ -176,13 +176,13 @@ LL |     <Self as SVec>::Item<'a>,
    |                         ++++
 
 error[E0107]: missing generics for associated type `SVec::Item`
-  --> $DIR/issue-105742.rs:15:21
+  --> $DIR/ice-generic-type-alias-105742.rs:16:21
    |
 LL |     <Self as SVec>::Item,
    |                     ^^^^ expected 1 generic argument
    |
 note: associated type defined here, with 1 generic parameter: `T`
-  --> $DIR/issue-105742.rs:59:10
+  --> $DIR/ice-generic-type-alias-105742.rs:60:10
    |
 LL |     type Item<'a, T>;
    |          ^^^^     -
@@ -193,13 +193,13 @@ LL |     <Self as SVec>::Item<T>,
    |                         +++
 
 error[E0107]: missing generics for associated type `SVec::Item`
-  --> $DIR/issue-105742.rs:26:37
+  --> $DIR/ice-generic-type-alias-105742.rs:27:37
    |
 LL |     Output = <Index<<Self as SVec>::Item,
    |                                     ^^^^ expected 1 lifetime argument
    |
 note: associated type defined here, with 1 lifetime parameter: `'a`
-  --> $DIR/issue-105742.rs:59:10
+  --> $DIR/ice-generic-type-alias-105742.rs:60:10
    |
 LL |     type Item<'a, T>;
    |          ^^^^ --
@@ -210,13 +210,13 @@ LL |     Output = <Index<<Self as SVec>::Item<'a>,
    |                                         ++++
 
 error[E0107]: missing generics for associated type `SVec::Item`
-  --> $DIR/issue-105742.rs:26:37
+  --> $DIR/ice-generic-type-alias-105742.rs:27:37
    |
 LL |     Output = <Index<<Self as SVec>::Item,
    |                                     ^^^^ expected 1 generic argument
    |
 note: associated type defined here, with 1 generic parameter: `T`
-  --> $DIR/issue-105742.rs:59:10
+  --> $DIR/ice-generic-type-alias-105742.rs:60:10
    |
 LL |     type Item<'a, T>;
    |          ^^^^     -
@@ -227,13 +227,13 @@ LL |     Output = <Index<<Self as SVec>::Item<T>,
    |                                         +++
 
 error[E0107]: missing generics for associated type `SVec::Item`
-  --> $DIR/issue-105742.rs:37:30
+  --> $DIR/ice-generic-type-alias-105742.rs:38:30
    |
 LL |     Output = <Self as SVec>::Item> as SVec>::Item,
    |                              ^^^^ expected 1 lifetime argument
    |
 note: associated type defined here, with 1 lifetime parameter: `'a`
-  --> $DIR/issue-105742.rs:59:10
+  --> $DIR/ice-generic-type-alias-105742.rs:60:10
    |
 LL |     type Item<'a, T>;
    |          ^^^^ --
@@ -244,13 +244,13 @@ LL |     Output = <Self as SVec>::Item<'a>> as SVec>::Item,
    |                                  ++++
 
 error[E0107]: missing generics for associated type `SVec::Item`
-  --> $DIR/issue-105742.rs:37:30
+  --> $DIR/ice-generic-type-alias-105742.rs:38:30
    |
 LL |     Output = <Self as SVec>::Item> as SVec>::Item,
    |                              ^^^^ expected 1 generic argument
    |
 note: associated type defined here, with 1 generic parameter: `T`
-  --> $DIR/issue-105742.rs:59:10
+  --> $DIR/ice-generic-type-alias-105742.rs:60:10
    |
 LL |     type Item<'a, T>;
    |          ^^^^     -
@@ -261,13 +261,13 @@ LL |     Output = <Self as SVec>::Item<T>> as SVec>::Item,
    |                                  +++
 
 error[E0107]: missing generics for associated type `SVec::Item`
-  --> $DIR/issue-105742.rs:37:46
+  --> $DIR/ice-generic-type-alias-105742.rs:38:46
    |
 LL |     Output = <Self as SVec>::Item> as SVec>::Item,
    |                                              ^^^^ expected 1 lifetime argument
    |
 note: associated type defined here, with 1 lifetime parameter: `'a`
-  --> $DIR/issue-105742.rs:59:10
+  --> $DIR/ice-generic-type-alias-105742.rs:60:10
    |
 LL |     type Item<'a, T>;
    |          ^^^^ --
@@ -278,13 +278,13 @@ LL |     Output = <Self as SVec>::Item> as SVec>::Item<'a>,
    |                                                  ++++
 
 error[E0107]: missing generics for associated type `SVec::Item`
-  --> $DIR/issue-105742.rs:37:46
+  --> $DIR/ice-generic-type-alias-105742.rs:38:46
    |
 LL |     Output = <Self as SVec>::Item> as SVec>::Item,
    |                                              ^^^^ expected 1 generic argument
    |
 note: associated type defined here, with 1 generic parameter: `T`
-  --> $DIR/issue-105742.rs:59:10
+  --> $DIR/ice-generic-type-alias-105742.rs:60:10
    |
 LL |     type Item<'a, T>;
    |          ^^^^     -
@@ -295,13 +295,13 @@ LL |     Output = <Self as SVec>::Item> as SVec>::Item<T>,
    |                                                  +++
 
 error[E0038]: the trait `SVec` cannot be made into an object
-  --> $DIR/issue-105742.rs:4:31
+  --> $DIR/ice-generic-type-alias-105742.rs:5:31
    |
 LL | pub fn next<'a, T>(s: &'a mut dyn SVec<Item = T, Output = T>) {
    |                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `SVec` cannot be made into an object
    |
 note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
-  --> $DIR/issue-105742.rs:14:17
+  --> $DIR/ice-generic-type-alias-105742.rs:15:17
    |
 LL |    pub trait SVec: Index<
    |  ____________----__^
@@ -329,13 +329,13 @@ LL | pub fn next<'a, T>(s: &'a mut impl SVec<Item = T, Output = T>) {
    |                               ~~~~
 
 error[E0107]: missing generics for associated type `SVec::Item`
-  --> $DIR/issue-105742.rs:15:21
+  --> $DIR/ice-generic-type-alias-105742.rs:16:21
    |
 LL |     <Self as SVec>::Item,
    |                     ^^^^ expected 1 lifetime argument
    |
 note: associated type defined here, with 1 lifetime parameter: `'a`
-  --> $DIR/issue-105742.rs:59:10
+  --> $DIR/ice-generic-type-alias-105742.rs:60:10
    |
 LL |     type Item<'a, T>;
    |          ^^^^ --
@@ -346,13 +346,13 @@ LL |     <Self as SVec>::Item<'a>,
    |                         ++++
 
 error[E0107]: missing generics for associated type `SVec::Item`
-  --> $DIR/issue-105742.rs:15:21
+  --> $DIR/ice-generic-type-alias-105742.rs:16:21
    |
 LL |     <Self as SVec>::Item,
    |                     ^^^^ expected 1 generic argument
    |
 note: associated type defined here, with 1 generic parameter: `T`
-  --> $DIR/issue-105742.rs:59:10
+  --> $DIR/ice-generic-type-alias-105742.rs:60:10
    |
 LL |     type Item<'a, T>;
    |          ^^^^     -
@@ -363,13 +363,13 @@ LL |     <Self as SVec>::Item<T>,
    |                         +++
 
 error[E0107]: missing generics for associated type `SVec::Item`
-  --> $DIR/issue-105742.rs:26:37
+  --> $DIR/ice-generic-type-alias-105742.rs:27:37
    |
 LL |     Output = <Index<<Self as SVec>::Item,
    |                                     ^^^^ expected 1 lifetime argument
    |
 note: associated type defined here, with 1 lifetime parameter: `'a`
-  --> $DIR/issue-105742.rs:59:10
+  --> $DIR/ice-generic-type-alias-105742.rs:60:10
    |
 LL |     type Item<'a, T>;
    |          ^^^^ --
@@ -380,13 +380,13 @@ LL |     Output = <Index<<Self as SVec>::Item<'a>,
    |                                         ++++
 
 error[E0107]: missing generics for associated type `SVec::Item`
-  --> $DIR/issue-105742.rs:26:37
+  --> $DIR/ice-generic-type-alias-105742.rs:27:37
    |
 LL |     Output = <Index<<Self as SVec>::Item,
    |                                     ^^^^ expected 1 generic argument
    |
 note: associated type defined here, with 1 generic parameter: `T`
-  --> $DIR/issue-105742.rs:59:10
+  --> $DIR/ice-generic-type-alias-105742.rs:60:10
    |
 LL |     type Item<'a, T>;
    |          ^^^^     -
@@ -397,13 +397,13 @@ LL |     Output = <Index<<Self as SVec>::Item<T>,
    |                                         +++
 
 error[E0107]: missing generics for associated type `SVec::Item`
-  --> $DIR/issue-105742.rs:37:30
+  --> $DIR/ice-generic-type-alias-105742.rs:38:30
    |
 LL |     Output = <Self as SVec>::Item> as SVec>::Item,
    |                              ^^^^ expected 1 lifetime argument
    |
 note: associated type defined here, with 1 lifetime parameter: `'a`
-  --> $DIR/issue-105742.rs:59:10
+  --> $DIR/ice-generic-type-alias-105742.rs:60:10
    |
 LL |     type Item<'a, T>;
    |          ^^^^ --
@@ -414,13 +414,13 @@ LL |     Output = <Self as SVec>::Item<'a>> as SVec>::Item,
    |                                  ++++
 
 error[E0107]: missing generics for associated type `SVec::Item`
-  --> $DIR/issue-105742.rs:37:30
+  --> $DIR/ice-generic-type-alias-105742.rs:38:30
    |
 LL |     Output = <Self as SVec>::Item> as SVec>::Item,
    |                              ^^^^ expected 1 generic argument
    |
 note: associated type defined here, with 1 generic parameter: `T`
-  --> $DIR/issue-105742.rs:59:10
+  --> $DIR/ice-generic-type-alias-105742.rs:60:10
    |
 LL |     type Item<'a, T>;
    |          ^^^^     -
@@ -431,13 +431,13 @@ LL |     Output = <Self as SVec>::Item<T>> as SVec>::Item,
    |                                  +++
 
 error[E0107]: missing generics for associated type `SVec::Item`
-  --> $DIR/issue-105742.rs:37:46
+  --> $DIR/ice-generic-type-alias-105742.rs:38:46
    |
 LL |     Output = <Self as SVec>::Item> as SVec>::Item,
    |                                              ^^^^ expected 1 lifetime argument
    |
 note: associated type defined here, with 1 lifetime parameter: `'a`
-  --> $DIR/issue-105742.rs:59:10
+  --> $DIR/ice-generic-type-alias-105742.rs:60:10
    |
 LL |     type Item<'a, T>;
    |          ^^^^ --
@@ -448,13 +448,13 @@ LL |     Output = <Self as SVec>::Item> as SVec>::Item<'a>,
    |                                                  ++++
 
 error[E0107]: missing generics for associated type `SVec::Item`
-  --> $DIR/issue-105742.rs:37:46
+  --> $DIR/ice-generic-type-alias-105742.rs:38:46
    |
 LL |     Output = <Self as SVec>::Item> as SVec>::Item,
    |                                              ^^^^ expected 1 generic argument
    |
 note: associated type defined here, with 1 generic parameter: `T`
-  --> $DIR/issue-105742.rs:59:10
+  --> $DIR/ice-generic-type-alias-105742.rs:60:10
    |
 LL |     type Item<'a, T>;
    |          ^^^^     -
@@ -465,13 +465,13 @@ LL |     Output = <Self as SVec>::Item> as SVec>::Item<T>,
    |                                                  +++
 
 error[E0107]: missing generics for associated type `SVec::Item`
-  --> $DIR/issue-105742.rs:15:21
+  --> $DIR/ice-generic-type-alias-105742.rs:16:21
    |
 LL |     <Self as SVec>::Item,
    |                     ^^^^ expected 1 lifetime argument
    |
 note: associated type defined here, with 1 lifetime parameter: `'a`
-  --> $DIR/issue-105742.rs:59:10
+  --> $DIR/ice-generic-type-alias-105742.rs:60:10
    |
 LL |     type Item<'a, T>;
    |          ^^^^ --
@@ -482,13 +482,13 @@ LL |     <Self as SVec>::Item<'a>,
    |                         ++++
 
 error[E0107]: missing generics for associated type `SVec::Item`
-  --> $DIR/issue-105742.rs:15:21
+  --> $DIR/ice-generic-type-alias-105742.rs:16:21
    |
 LL |     <Self as SVec>::Item,
    |                     ^^^^ expected 1 generic argument
    |
 note: associated type defined here, with 1 generic parameter: `T`
-  --> $DIR/issue-105742.rs:59:10
+  --> $DIR/ice-generic-type-alias-105742.rs:60:10
    |
 LL |     type Item<'a, T>;
    |          ^^^^     -
@@ -499,13 +499,13 @@ LL |     <Self as SVec>::Item<T>,
    |                         +++
 
 error[E0107]: missing generics for associated type `SVec::Item`
-  --> $DIR/issue-105742.rs:26:37
+  --> $DIR/ice-generic-type-alias-105742.rs:27:37
    |
 LL |     Output = <Index<<Self as SVec>::Item,
    |                                     ^^^^ expected 1 lifetime argument
    |
 note: associated type defined here, with 1 lifetime parameter: `'a`
-  --> $DIR/issue-105742.rs:59:10
+  --> $DIR/ice-generic-type-alias-105742.rs:60:10
    |
 LL |     type Item<'a, T>;
    |          ^^^^ --
@@ -516,13 +516,13 @@ LL |     Output = <Index<<Self as SVec>::Item<'a>,
    |                                         ++++
 
 error[E0107]: missing generics for associated type `SVec::Item`
-  --> $DIR/issue-105742.rs:26:37
+  --> $DIR/ice-generic-type-alias-105742.rs:27:37
    |
 LL |     Output = <Index<<Self as SVec>::Item,
    |                                     ^^^^ expected 1 generic argument
    |
 note: associated type defined here, with 1 generic parameter: `T`
-  --> $DIR/issue-105742.rs:59:10
+  --> $DIR/ice-generic-type-alias-105742.rs:60:10
    |
 LL |     type Item<'a, T>;
    |          ^^^^     -
@@ -533,13 +533,13 @@ LL |     Output = <Index<<Self as SVec>::Item<T>,
    |                                         +++
 
 error[E0107]: missing generics for associated type `SVec::Item`
-  --> $DIR/issue-105742.rs:37:30
+  --> $DIR/ice-generic-type-alias-105742.rs:38:30
    |
 LL |     Output = <Self as SVec>::Item> as SVec>::Item,
    |                              ^^^^ expected 1 lifetime argument
    |
 note: associated type defined here, with 1 lifetime parameter: `'a`
-  --> $DIR/issue-105742.rs:59:10
+  --> $DIR/ice-generic-type-alias-105742.rs:60:10
    |
 LL |     type Item<'a, T>;
    |          ^^^^ --
@@ -550,13 +550,13 @@ LL |     Output = <Self as SVec>::Item<'a>> as SVec>::Item,
    |                                  ++++
 
 error[E0107]: missing generics for associated type `SVec::Item`
-  --> $DIR/issue-105742.rs:37:30
+  --> $DIR/ice-generic-type-alias-105742.rs:38:30
    |
 LL |     Output = <Self as SVec>::Item> as SVec>::Item,
    |                              ^^^^ expected 1 generic argument
    |
 note: associated type defined here, with 1 generic parameter: `T`
-  --> $DIR/issue-105742.rs:59:10
+  --> $DIR/ice-generic-type-alias-105742.rs:60:10
    |
 LL |     type Item<'a, T>;
    |          ^^^^     -
@@ -567,13 +567,13 @@ LL |     Output = <Self as SVec>::Item<T>> as SVec>::Item,
    |                                  +++
 
 error[E0107]: missing generics for associated type `SVec::Item`
-  --> $DIR/issue-105742.rs:37:46
+  --> $DIR/ice-generic-type-alias-105742.rs:38:46
    |
 LL |     Output = <Self as SVec>::Item> as SVec>::Item,
    |                                              ^^^^ expected 1 lifetime argument
    |
 note: associated type defined here, with 1 lifetime parameter: `'a`
-  --> $DIR/issue-105742.rs:59:10
+  --> $DIR/ice-generic-type-alias-105742.rs:60:10
    |
 LL |     type Item<'a, T>;
    |          ^^^^ --
@@ -584,13 +584,13 @@ LL |     Output = <Self as SVec>::Item> as SVec>::Item<'a>,
    |                                                  ++++
 
 error[E0107]: missing generics for associated type `SVec::Item`
-  --> $DIR/issue-105742.rs:37:46
+  --> $DIR/ice-generic-type-alias-105742.rs:38:46
    |
 LL |     Output = <Self as SVec>::Item> as SVec>::Item,
    |                                              ^^^^ expected 1 generic argument
    |
 note: associated type defined here, with 1 generic parameter: `T`
-  --> $DIR/issue-105742.rs:59:10
+  --> $DIR/ice-generic-type-alias-105742.rs:60:10
    |
 LL |     type Item<'a, T>;
    |          ^^^^     -
@@ -601,13 +601,13 @@ LL |     Output = <Self as SVec>::Item> as SVec>::Item<T>,
    |                                                  +++
 
 error[E0107]: missing generics for associated type `SVec::Item`
-  --> $DIR/issue-105742.rs:61:38
+  --> $DIR/ice-generic-type-alias-105742.rs:62:38
    |
 LL |     fn len(&self) -> <Self as SVec>::Item;
    |                                      ^^^^ expected 1 lifetime argument
    |
 note: associated type defined here, with 1 lifetime parameter: `'a`
-  --> $DIR/issue-105742.rs:59:10
+  --> $DIR/ice-generic-type-alias-105742.rs:60:10
    |
 LL |     type Item<'a, T>;
    |          ^^^^ --
@@ -617,13 +617,13 @@ LL |     fn len(&self) -> <Self as SVec>::Item<'_>;
    |                                          ++++
 
 error[E0107]: missing generics for associated type `SVec::Item`
-  --> $DIR/issue-105742.rs:61:38
+  --> $DIR/ice-generic-type-alias-105742.rs:62:38
    |
 LL |     fn len(&self) -> <Self as SVec>::Item;
    |                                      ^^^^ expected 1 generic argument
    |
 note: associated type defined here, with 1 generic parameter: `T`
-  --> $DIR/issue-105742.rs:59:10
+  --> $DIR/ice-generic-type-alias-105742.rs:60:10
    |
 LL |     type Item<'a, T>;
    |          ^^^^     -
diff --git a/tests/rustdoc-ui/issues/issue-105737.rs b/tests/rustdoc-ui/issues/ice-impl-fn-generic-105737.rs
similarity index 100%
rename from tests/rustdoc-ui/issues/issue-105737.rs
rename to tests/rustdoc-ui/issues/ice-impl-fn-generic-105737.rs
diff --git a/tests/rustdoc-ui/issues/issue-105737.stderr b/tests/rustdoc-ui/issues/ice-impl-fn-generic-105737.stderr
similarity index 87%
rename from tests/rustdoc-ui/issues/issue-105737.stderr
rename to tests/rustdoc-ui/issues/ice-impl-fn-generic-105737.stderr
index 2c63c345e46a5..49cbebc91d982 100644
--- a/tests/rustdoc-ui/issues/issue-105737.stderr
+++ b/tests/rustdoc-ui/issues/ice-impl-fn-generic-105737.stderr
@@ -1,5 +1,5 @@
 error[E0747]: constant provided when a type was expected
-  --> $DIR/issue-105737.rs:1:10
+  --> $DIR/ice-impl-fn-generic-105737.rs:2:10
    |
 LL | impl Vec<lol> {}
    |          ^^^
diff --git a/tests/rustdoc-ui/issues/issue-101076.rs b/tests/rustdoc-ui/issues/ice-macro-hidden-exported-macro-defid-101076.rs
similarity index 100%
rename from tests/rustdoc-ui/issues/issue-101076.rs
rename to tests/rustdoc-ui/issues/ice-macro-hidden-exported-macro-defid-101076.rs
diff --git a/tests/rustdoc-ui/issues/issue-106226.rs b/tests/rustdoc-ui/issues/ice-placeholder-type-alias-106226.rs
similarity index 100%
rename from tests/rustdoc-ui/issues/issue-106226.rs
rename to tests/rustdoc-ui/issues/ice-placeholder-type-alias-106226.rs
diff --git a/tests/rustdoc-ui/issues/issue-106226.stderr b/tests/rustdoc-ui/issues/ice-placeholder-type-alias-106226.stderr
similarity index 84%
rename from tests/rustdoc-ui/issues/issue-106226.stderr
rename to tests/rustdoc-ui/issues/ice-placeholder-type-alias-106226.stderr
index 4d063b461883a..e90809254504e 100644
--- a/tests/rustdoc-ui/issues/issue-106226.stderr
+++ b/tests/rustdoc-ui/issues/ice-placeholder-type-alias-106226.stderr
@@ -1,5 +1,5 @@
 error[E0121]: the placeholder `_` is not allowed within types on item signatures for type aliases
-  --> $DIR/issue-106226.rs:2:11
+  --> $DIR/ice-placeholder-type-alias-106226.rs:2:11
    |
 LL | type F = [_; ()];
    |           ^ not allowed in type signatures
diff --git a/tests/rustdoc-ui/issues/issue-105334.rs b/tests/rustdoc-ui/issues/ice-raw-str-105334.rs
similarity index 100%
rename from tests/rustdoc-ui/issues/issue-105334.rs
rename to tests/rustdoc-ui/issues/ice-raw-str-105334.rs
diff --git a/tests/rustdoc-ui/issues/issue-105334.stderr b/tests/rustdoc-ui/issues/ice-raw-str-105334.stderr
similarity index 85%
rename from tests/rustdoc-ui/issues/issue-105334.stderr
rename to tests/rustdoc-ui/issues/ice-raw-str-105334.stderr
index d992b219b3bc2..2096757fbb98e 100644
--- a/tests/rustdoc-ui/issues/issue-105334.stderr
+++ b/tests/rustdoc-ui/issues/ice-raw-str-105334.stderr
@@ -1,5 +1,5 @@
 error[E0747]: constant provided when a type was expected
-  --> $DIR/issue-105334.rs:1:11
+  --> $DIR/ice-raw-str-105334.rs:2:11
    |
 LL | impl Vec< br##"*.."## > {}
    |           ^^^^^^^^^^^
diff --git a/tests/rustdoc-ui/issues/issue-102986.rs b/tests/rustdoc-ui/issues/ice-typeof-102986.rs
similarity index 100%
rename from tests/rustdoc-ui/issues/issue-102986.rs
rename to tests/rustdoc-ui/issues/ice-typeof-102986.rs
diff --git a/tests/rustdoc-ui/issues/issue-102986.stderr b/tests/rustdoc-ui/issues/ice-typeof-102986.stderr
similarity index 90%
rename from tests/rustdoc-ui/issues/issue-102986.stderr
rename to tests/rustdoc-ui/issues/ice-typeof-102986.stderr
index d91f93f394a5b..20dbb2661bc2e 100644
--- a/tests/rustdoc-ui/issues/issue-102986.stderr
+++ b/tests/rustdoc-ui/issues/ice-typeof-102986.stderr
@@ -1,5 +1,5 @@
 error[E0516]: `typeof` is a reserved keyword but unimplemented
-  --> $DIR/issue-102986.rs:2:9
+  --> $DIR/ice-typeof-102986.rs:3:9
    |
 LL |     y: (typeof("hey"),),
    |         ^^^^^^^^^^^^^ reserved keyword
diff --git a/tests/rustdoc-ui/issues/issue-103997.rs b/tests/rustdoc-ui/issues/ice-unresolved-self-103997.rs
similarity index 100%
rename from tests/rustdoc-ui/issues/issue-103997.rs
rename to tests/rustdoc-ui/issues/ice-unresolved-self-103997.rs
diff --git a/tests/rustdoc-ui/issues/issue-103997.stderr b/tests/rustdoc-ui/issues/ice-unresolved-self-103997.stderr
similarity index 83%
rename from tests/rustdoc-ui/issues/issue-103997.stderr
rename to tests/rustdoc-ui/issues/ice-unresolved-self-103997.stderr
index c06db91496f86..9cb64079c618c 100644
--- a/tests/rustdoc-ui/issues/issue-103997.stderr
+++ b/tests/rustdoc-ui/issues/ice-unresolved-self-103997.stderr
@@ -1,5 +1,5 @@
 warning: unresolved link to `Self::foo`
-  --> $DIR/issue-103997.rs:5:13
+  --> $DIR/ice-unresolved-self-103997.rs:6:13
    |
 LL | /// [`foo`](Self::foo)
    |             ^^^^^^^^^ no item named `Self` in scope