Failure to link rust dependency with LTO-enabled C FFI code built with GCC #138681
Labels
A-FFI
Area: Foreign function interface (FFI)
A-linkage
Area: linking into static, shared libraries and binaries
A-LTO
Area: Link-time optimization (LTO)
C-bug
Category: This is a bug.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
STR:
Cargo.toml
src/main.rs
foolib/Cargo.toml
foolib/build.rs
foolib/foo.c
foolib/src/lib.rs
CFLAGS=-flto cargo build
I expected to see this happen: success.
Instead, this happened:
Notes:
ranlib /tmp/foo/target/debug/deps/libfoolib-591acb1d5285dc4c.rlib
after the first failure, and trying again. IOW, what's missing is running a GCC-LTO-aware ranlib for the rlib's symbol table to be filled properly.Meta
rustc --version --verbose
:(this happens with today's nightly too, rustc 1.87.0-nightly (75530e9 2025-03-18))
The text was updated successfully, but these errors were encountered: