Binary build fails if two crates exported same function with #[no_mangle] and LTO enabled #98666
Labels
C-bug
Category: This is a bug.
needs-triage-legacy
Old issue that were never triaged. Remove this label once the issue has been sufficiently triaged.
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: