Skip to content

Commit f3ef465

Browse files
committed
Combining no_mangle and rustc_std_internal_symbol is not allowed
1 parent 4d62bf1 commit f3ef465

File tree

1 file changed

+6
-11
lines changed
  • compiler/rustc_symbol_mangling/src

1 file changed

+6
-11
lines changed

compiler/rustc_symbol_mangling/src/lib.rs

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -193,13 +193,12 @@ fn compute_symbol_name<'tcx>(
193193
// defining crate.
194194
// Weak lang items automatically get #[rustc_std_internal_symbol]
195195
// applied by the code computing the CodegenFnAttrs.
196-
// We are mangling all #[rustc_std_internal_symbol] items that don't
197-
// also have #[no_mangle] as a combination of the rustc version and the
198-
// unmangled linkage name. This is to ensure that if we link against a
199-
// staticlib compiled by a different rustc version, we don't get symbol
200-
// conflicts or even UB due to a different implementation/ABI. Rust
201-
// staticlibs currently export all symbols, including those that are
202-
// hidden in cdylibs.
196+
// We are mangling all #[rustc_std_internal_symbol] items as a
197+
// combination of the rustc version and the unmangled linkage name.
198+
// This is to ensure that if we link against a staticlib compiled by a
199+
// different rustc version, we don't get symbol conflicts or even UB
200+
// due to a different implementation/ABI. Rust staticlibs currently
201+
// export all symbols, including those that are hidden in cdylibs.
203202
// We are using the v0 symbol mangling scheme here as we need to be
204203
// consistent across all crates and in some contexts the legacy symbol
205204
// mangling scheme can't be used. For example both the GCC backend and
@@ -211,11 +210,7 @@ fn compute_symbol_name<'tcx>(
211210
if let Some(name) = attrs.export_name { name } else { tcx.item_name(def_id) }
212211
};
213212

214-
if attrs.flags.contains(CodegenFnAttrFlags::NO_MANGLE) {
215-
return name.to_string();
216-
} else {
217213
return v0::mangle_internal_symbol(tcx, name.as_str());
218-
}
219214
}
220215

221216
let wasm_import_module_exception_force_mangling = {

0 commit comments

Comments
 (0)