about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbjorn3 <17426603+bjorn3@users.noreply.github.com>2025-08-15 09:27:29 +0000
committerbjorn3 <17426603+bjorn3@users.noreply.github.com>2025-08-15 09:27:29 +0000
commitf3ef465ffb5cd3da61176ac67e7051eb55b62095 (patch)
treea61e022e5168f93f5fca8b4962c045d2d05c4549
parent4d62bf1634aad793631517559fe4d9e3e072a2bd (diff)
downloadrust-f3ef465ffb5cd3da61176ac67e7051eb55b62095.tar.gz
rust-f3ef465ffb5cd3da61176ac67e7051eb55b62095.zip
Combining no_mangle and rustc_std_internal_symbol is not allowed
-rw-r--r--compiler/rustc_symbol_mangling/src/lib.rs17
1 files changed, 6 insertions, 11 deletions
diff --git a/compiler/rustc_symbol_mangling/src/lib.rs b/compiler/rustc_symbol_mangling/src/lib.rs
index f3c96f64190..96a501fb0ea 100644
--- a/compiler/rustc_symbol_mangling/src/lib.rs
+++ b/compiler/rustc_symbol_mangling/src/lib.rs
@@ -193,13 +193,12 @@ fn compute_symbol_name<'tcx>(
         // defining crate.
         // Weak lang items automatically get #[rustc_std_internal_symbol]
         // applied by the code computing the CodegenFnAttrs.
-        // We are mangling all #[rustc_std_internal_symbol] items that don't
-        // also have #[no_mangle] as a combination of the rustc version and the
-        // unmangled linkage name. This is to ensure that if we link against a
-        // staticlib compiled by a different rustc version, we don't get symbol
-        // conflicts or even UB due to a different implementation/ABI. Rust
-        // staticlibs currently export all symbols, including those that are
-        // hidden in cdylibs.
+        // We are mangling all #[rustc_std_internal_symbol] items as a
+        // combination of the rustc version and the unmangled linkage name.
+        // This is to ensure that if we link against a staticlib compiled by a
+        // different rustc version, we don't get symbol conflicts or even UB
+        // due to a different implementation/ABI. Rust staticlibs currently
+        // export all symbols, including those that are hidden in cdylibs.
         // We are using the v0 symbol mangling scheme here as we need to be
         // consistent across all crates and in some contexts the legacy symbol
         // mangling scheme can't be used. For example both the GCC backend and
@@ -211,11 +210,7 @@ fn compute_symbol_name<'tcx>(
             if let Some(name) = attrs.export_name { name } else { tcx.item_name(def_id) }
         };
 
-        if attrs.flags.contains(CodegenFnAttrFlags::NO_MANGLE) {
-            return name.to_string();
-        } else {
             return v0::mangle_internal_symbol(tcx, name.as_str());
-        }
     }
 
     let wasm_import_module_exception_force_mangling = {