https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118961
Nathaniel Shead <nshead at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever confirmed|0 |1
Last reconfirmed| |2025-02-23
CC| |nshead at gcc dot gnu.org
--- Comment #2 from Nathaniel Shead <nshead at gcc dot gnu.org> ---
Confirmed. It looks like LTO in general doesn't work particularly well,
especially with header units. I'm not 100% sure if this is related but the
following sample fails with a link error:
// header.hpp
template <typename> struct S {
S() {}
};
template struct S<char>;
// main.cpp
import "header.hpp";
S<char> s;
int main() {}
g++ -flto -fmodules header.hpp main.cpp:
/usr/bin/ld: /tmp/ccDEUr8J.ltrans0.ltrans.o: in function
`__static_initialization_and_destruction_0()':
<artificial>:(.text+0x15): undefined reference to `S<char>::S()'
collect2: error: ld returned 1 exit status
So there's something going wrong with the determination of external symbols.