about summary refs log tree commit diff
path: root/compiler/rustc_codegen_ssa/src/base.rs
diff options
context:
space:
mode:
authorJieyou Xu <jieyouxu@outlook.com>2025-05-15 16:51:32 +0800
committerJosh Stone <cuviper@gmail.com>2025-05-22 15:39:14 -0700
commitfcdcea758ec03be56586d1e631f8b574a4626f6c (patch)
tree33b18779c5d47877c0757e8a9e723c2ee2773da8 /compiler/rustc_codegen_ssa/src/base.rs
parente39669866a746fc891f4285692e53ddb8d5c5d8d (diff)
downloadrust-fcdcea758ec03be56586d1e631f8b574a4626f6c.tar.gz
rust-fcdcea758ec03be56586d1e631f8b574a4626f6c.zip
Revert "Fix linking statics on Arm64EC #140176"
Unfortunately, multiple people are reporting linker warnings related to
`__rust_no_alloc_shim_is_unstable` after this change. The solution isn't
quite clear yet, let's revert to green for now, and try a reland with a
determined solution for `__rust_no_alloc_shim_is_unstable`.

This reverts commit c8b7f32434c0306db5c1b974ee43443746098a92, reversing
changes made to 667247db71ea18c4130dd018d060e7f09d589490.

(cherry picked from commit 734a5b1aa7888db3d86faffea1a15254022d68c9)
Diffstat (limited to 'compiler/rustc_codegen_ssa/src/base.rs')
-rw-r--r--compiler/rustc_codegen_ssa/src/base.rs47
1 files changed, 15 insertions, 32 deletions
diff --git a/compiler/rustc_codegen_ssa/src/base.rs b/compiler/rustc_codegen_ssa/src/base.rs
index 93cbd4cbb7c..775ab9071e7 100644
--- a/compiler/rustc_codegen_ssa/src/base.rs
+++ b/compiler/rustc_codegen_ssa/src/base.rs
@@ -12,9 +12,9 @@ use rustc_data_structures::fx::{FxHashMap, FxIndexSet};
 use rustc_data_structures::profiling::{get_resident_set_size, print_time_passes_entry};
 use rustc_data_structures::sync::{IntoDynSyncSend, par_map};
 use rustc_data_structures::unord::UnordMap;
+use rustc_hir::ItemId;
 use rustc_hir::def_id::{DefId, LOCAL_CRATE};
 use rustc_hir::lang_items::LangItem;
-use rustc_hir::{ItemId, Target};
 use rustc_metadata::EncodedMetadata;
 use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrs;
 use rustc_middle::middle::debugger_visualizer::{DebuggerVisualizerFile, DebuggerVisualizerType};
@@ -1038,35 +1038,21 @@ impl CrateInfo {
         // by the compiler, but that's ok because all this stuff is unstable anyway.
         let target = &tcx.sess.target;
         if !are_upstream_rust_objects_already_included(tcx.sess) {
-            let add_prefix = match (target.is_like_windows, target.arch.as_ref()) {
-                (true, "x86") => |name: String, _: SymbolExportKind| format!("_{name}"),
-                (true, "arm64ec") => {
-                    // Only functions are decorated for arm64ec.
-                    |name: String, export_kind: SymbolExportKind| match export_kind {
-                        SymbolExportKind::Text => format!("#{name}"),
-                        _ => name,
-                    }
-                }
-                _ => |name: String, _: SymbolExportKind| name,
-            };
-            let missing_weak_lang_items: FxIndexSet<(Symbol, SymbolExportKind)> = info
+            let missing_weak_lang_items: FxIndexSet<Symbol> = info
                 .used_crates
                 .iter()
                 .flat_map(|&cnum| tcx.missing_lang_items(cnum))
                 .filter(|l| l.is_weak())
                 .filter_map(|&l| {
                     let name = l.link_name()?;
-                    let export_kind = match l.target() {
-                        Target::Fn => SymbolExportKind::Text,
-                        Target::Static => SymbolExportKind::Data,
-                        _ => bug!(
-                            "Don't know what the export kind is for lang item of kind {:?}",
-                            l.target()
-                        ),
-                    };
-                    lang_items::required(tcx, l).then_some((name, export_kind))
+                    lang_items::required(tcx, l).then_some(name)
                 })
                 .collect();
+            let prefix = match (target.is_like_windows, target.arch.as_ref()) {
+                (true, "x86") => "_",
+                (true, "arm64ec") => "#",
+                _ => "",
+            };
 
             // This loop only adds new items to values of the hash map, so the order in which we
             // iterate over the values is not important.
@@ -1079,13 +1065,10 @@ impl CrateInfo {
                 .for_each(|(_, linked_symbols)| {
                     let mut symbols = missing_weak_lang_items
                         .iter()
-                        .map(|(item, export_kind)| {
+                        .map(|item| {
                             (
-                                add_prefix(
-                                    mangle_internal_symbol(tcx, item.as_str()),
-                                    *export_kind,
-                                ),
-                                *export_kind,
+                                format!("{prefix}{}", mangle_internal_symbol(tcx, item.as_str())),
+                                SymbolExportKind::Text,
                             )
                         })
                         .collect::<Vec<_>>();
@@ -1100,12 +1083,12 @@ impl CrateInfo {
                         // errors.
                         linked_symbols.extend(ALLOCATOR_METHODS.iter().map(|method| {
                             (
-                                add_prefix(
+                                format!(
+                                    "{prefix}{}",
                                     mangle_internal_symbol(
                                         tcx,
-                                        global_fn_name(method.name).as_str(),
-                                    ),
-                                    SymbolExportKind::Text,
+                                        global_fn_name(method.name).as_str()
+                                    )
                                 ),
                                 SymbolExportKind::Text,
                             )