Combining no_mangle and rustc_std_internal_symbol is not allowed

This commit is contained in:
bjorn3 2025-08-15 09:27:29 +00:00
parent 4d62bf1634
commit f3ef465ffb

View file

@ -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 = {