Bug 103827 - Only export public symbols on the qt libs
Summary: Only export public symbols on the qt libs
Status: RESOLVED MOVED
Alias: None
Product: poppler
Classification: Unclassified
Component: general (show other bugs)
Version: unspecified
Hardware: Other All
: medium normal
Assignee: poppler-bugs
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-11-20 18:41 UTC by Emilio Pozuelo Monfort
Modified: 2018-08-21 10:37 UTC (History)
2 users (show)

See Also:
i915 platform:
i915 features:


Attachments
Don't export private symbols (735 bytes, patch)
2017-11-20 18:41 UTC, Emilio Pozuelo Monfort
Details | Splinter Review

Description Emilio Pozuelo Monfort 2017-11-20 18:41:32 UTC
Created attachment 135614 [details] [review]
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?
Comment 1 Albert Astals Cid 2017-11-20 20:55:37 UTC
> - Disable those tests

We don't shoot ourselves on the foot

Also, this is not how you do visibility stuff in cmake

set(CMAKE_C_VISIBILITY_PRESET hidden)
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
set(CMAKE_VISIBILITY_INLINES_HIDDEN 1)

is what you want.
Comment 2 GitLab Migration User 2018-08-21 10:37:27 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/poppler/poppler/issues/293.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.