linking issue on x86_64-pc-windows-gnu target + thinLTO related to static function pointers #98302
Closed
Description
opened on Jun 20, 2022
// lib.rs
#[inline]
pub fn aaa() {
static mut F: fn() = || {};
unsafe { F() };
}
// main.rs
fn main() {
lto::aaa();
}
errors on link with
C:\Users\user\crate\target\release\deps\crate-85a417bb6cdac81e.crate.684d89f7-cgu.1.rcgu.o:crate.684d:(.text+0x3): undefined reference to `__imp__ZN5inner3aaa3AAA17h6072a64b61f520c1E'
and it only occurs:
• on x86_64-pc-windows-gnu
• With thin LTO
• With #[inline]
• With a static mut or UnsafeCell
• With a function pointer
Meta
rustc --version --verbose
:
rustc 1.61.0 (fe5b13d68 2022-05-18)
binary: rustc
commit-hash: fe5b13d681f25ee6474be29d748c65adcd91f69e
commit-date: 2022-05-18
host: x86_64-pc-windows-gnu
release: 1.61.0
LLVM version: 14.0.0
Closest I could find: #71720
Activity