-
Notifications
You must be signed in to change notification settings - Fork 78
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
Prevent needless symbol exports #413
Comments
^^ That’s the fix for CryptX. Would someone more knowledgeable than myself about all of this be willing to comment on the feasibility of applying this to XS modules in general? |
Of note:
NB: This reduced CryptX.so’s size by about 15%. |
We actually do exactly this sort of thing on a few operating systems (windows, aix, vms, os2). Most of the infrastructure is already there, we just need to
|
@rafl had a go at doing this to core some time ago for GNU ld on ELF platforms: https://github.com/Perl/perl5/commits/rafl/ld_export This never got merged, and I think the difficulty was that it depends on your linker, not your compiler, and your linker may have come with your compiler, or it may have come with the OS, and there are a variety of different ways of enforcing strict linking, so it's pretty intimidating to try to do this portably. For extension building, item 2 above is just as difficult as it would be in core, but item 1 is easier. At least as far as I can remember the symbol "list" is really just From a recent build of blead on VMS, the Fcntl extension gets a "linker options file" called Fcntl.opt with the following contents:
On Windows with MSVC, you get a symbol definition file called Fcntl.def that contains this:
So identifying that one symbol you need to export is not the hard part. But portably deducing whether and how the linker can consume a symbol list and in what format sounds like work :-). Excluding symbols from external libraries is a little more narrow a problem and would still be helpful, but I don't know how universal |
I think that adding support for gcc (and clang) is all we really need here, and we already have a |
Indeed. Having symbol table full of excessive bloat causes;
|
From DCIT/perl-CryptX#79 (comment) …
Right now EU::MM causes the generated CryptX.so to export all manner of symbols that nothing needs and that can potentially conflict with other libraries. (The conflicts appear to happen only when Perl is embedded such that the conflicting library is loaded outside of Perl, e.g., mod_perl or perlcc.)
I’m seeing this kind of thing in other XS libraries, too, e.g., CBOR::Free.
It seems like, since only Perl loads these libraries, the only things exported should be the actual XS interface.
There are two potential fixes; we’re not sure which is ultimately best:
-Wl,--exclude-libs,ALL
-fvisibility=hidden
The text was updated successfully, but these errors were encountered: