Binary build fails if two crates exported same function with #[no_mangle] and LTO enabled #98666
Labels
A-linkage
Area: linking into static, shared libraries and binaries
C-bug
Category: This is a bug.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
When linking crates which both export function with the same name with
#[no_mangle]
, LTO fails to process it and emits a message that cannot be understood without looking into rustc sources. For simplicity, i put a minimal reproducible example into a repo https://github.com/ValeryAntopol/rust-lto-bug. Thehelper
crate builds to a library with default settings,rust-lto-bug
builds to a binary with default settings + LTO enabled, links with thehelper
crate.I tried this code:
helper/lib.rs:
main.rs:
I expected to see this happen:
One of the following:
I also expect that the behavior will be the same for both enabled and disabled LTO, but i understand that it could be too difficult to achieve.
Instead, this happened:
cargo build
, LTO enabled:cargo build --release
, LTO enabled:cargo build
, LTO disabled:Meta
Versions checked:
On all of them behavior is the same, only the module hash changes. But it is the same on different compilations with the same version.
RUST_BACKTACE=1
adds nothing to the output.The text was updated successfully, but these errors were encountered: