How to ensure C++ classes don't go missing with -flto?

Jeffrey Walton noloader@gmail.com
Fri Jan 25 01:34:00 GMT 2019


This question on Stack Overflow caught my eye:
https://stackoverflow.com/q/54345531/608639 . In the question a
program compiles and links fine without -flto. With -flto symbols go
missing.

One of the classes that go missing is RSAFunction, which performs
exponentiation with a public key. The source code is available at
https://github.com/weidai11/cryptopp/blob/master/rsa.h and
https://github.com/weidai11/cryptopp/blob/master/rsa.cpp.

There does not seem to be anything special about rsa.h and rsa.cpp
from my view of the issue. The header declares the classes, and then
the source file implements the classes.

How does one ensure a class does not go missing when using -flto?

(Is this like implicit template instantiations? Is there a way to
declare it so that it does not go missing?)



More information about the Gcc-help mailing list