Only export public symbols on the qt libs
Submitted by Emilio Pozuelo Monfort
Assigned to poppler-bugs
Link to original bug (#103827)
Description
Created attachment 135614 Don't export private symbols
Hi,
The attached patch, based on an old patch from Pino Toscano, does two things:
Define -Dpoppler_qt5_EXPORTS so that POPPLER_QT5_EXPORT is set to something useful.
Build with -fvisibility=hidden -fvisibility-inlines-hidden, so that symbols don't get exported by default. All those marked as POPPLER_QT5_EXPORT get exported though. This has the nice benefit of reducing the number of exported symbols by about 600. E.g. these ones are exported without this patch:
_ZTVN7Poppler15LinkGotoPrivateE ZNK8QMapDataI7QStringPN7Poppler14OptContentItemEE8findNodeERKS0 _ZNK8QMapNodeI7QStringPN7Poppler14OptContentItemEE4copyEP8QMapDataIS0_S3_E _ZN9OutputDev18updateHorizScalingEP8GfxState _ZN7Poppler26HighlightAnnotationPrivateD1Ev
Some things to consider:
Do we want -fvisibility-inlines-hidden as well?
Should this be applied to GCC only? Not sure what's the support in other compilers.
One small issue with this: there are some symbols that are not public but are used by some tests. With this patch, those symbols don't get exported, so the tests fail to link as they try to test those private methods. E.g. qt4/src/poppler-private.h's Poppler::unicodeToQString is not marked as POPPLER_QT4_EXPORT so doesn't get exported in the shared library, so qt4/tests/check_strings.cpp fails to build. Some possible solutions would be:
- Disable those tests
- Export those symbols
- If those methods are self-contained, move them to their own .cpp and include that .cpp directly from the test case, so it gets built into the test case without linking against libpoppler... kind of a hack but I think it'd work :P
This patch has been in Debian for a long time and I'm not aware of any weird crashes or anything, fwiw.
Thoughts?
Patch 135614, "Don't export private symbols":
qt-visibility.diff