New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MAINT: hide symbols on Linux when using GNU linker #8463
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This solution seems more sustainable than a case-by-case enforcement of symbol hiding as in #8451. Perhaps @stuartarchibald can briefly confirm given comments on the previously proposed solution.
I'm guessing we won't have tests to enforce "stable" symbol exposure on different platforms anytime soon--I wonder if that is a good practice or just overkill, in terms of guaranteeing what other libraries have low-level access to, etc.
Use -Wl,--version-script linker flag to restrict symbols exported in the built .so files, if we are using a GNU linker on Linux. Do this by overriding the built_ext command, so that the fix is applied to all extensions.
Added a test on Travis that checks the number of exported symbols. |
I'll note that it doesn't work out-of-the box since the default linker on OSX doesn't support version scripts. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM & there's a test now in CI for linux symbol exposure
@tylerjereddy I think this will achieve what is desired on Linux with GNU ld. |
* MAINT: integrate: export symbols with pycapsules in _test_multivariate * BLD: control exported symbols, on Linux with GNU linker Use -Wl,--version-script linker flag to restrict symbols exported in the built .so files, if we are using a GNU linker on Linux. Do this by overriding the built_ext command, so that the fix is applied to all extensions. * CI: check symbol hiding on linux
Hide unnecessary symbols in .so libraries, using a GNU linker version script on linux.
This is a general solution to the discussion in #8451
Overriding the distutils logic by a custom build_ext seemed the cleanest option. The logic of detecting when a GNU linker is similar to what distutils does internally, didn't find a nicer way and this information doesn't seem to be available otherwise.
There was a testing module
scipy.integrate._test_multivariate
that tried to look up some test symbols with ctypes --- rewrote that to use a different approach.This may also work on OSX, but I'll leave that to someone else.
(Windows already does something like this in standard Python distutils with MSVC, so no changes necessary for that platform.)