This is an archive of the discontinued LLVM Phabricator instance.

[cmake] Pass -Wl,-z,nodelete on Linux to prevent unloading
ClosedPublic

Authored by mgorny on Nov 25 2017, 3:22 PM.

Details

Summary

Prevent unloading shared libraries on Linux when dlclose() is called.
This is necessary since command-line option parsing API relies on
registering the global option instances in the option parser instance
which can be loaded in a different shared library.

Given that we can't reliably remove those options when a library is
unloaded, the parser ends up containing dangling references. Since glibc
has relatively complex library unloading rules, some of the LLVM
libraries can be unloaded while others (including the Support library)
stay loaded causing quite a mayhem. To reliably prevent that, just
forbid unloading all libraries -- it's a very bad idea anyway.

While the issue arguably happens only with BUILD_SHARED_LIBS, it may
affect any library reusing llvm::cl interface.

Based on patch provided Ross Hayward on https://bugs.gentoo.org/617154.
Previously hit by Fedora back in Feb 2016:
https://lists.freedesktop.org/archives/mesa-dev/2016-February/107242.html

Diff Detail

Event Timeline

mgorny created this revision.Nov 25 2017, 3:22 PM
beanz accepted this revision.Nov 27 2017, 10:26 AM

LGTM

This revision is now accepted and ready to land.Nov 27 2017, 10:26 AM
This revision was automatically updated to reflect the committed changes.
mgorny updated this revision to Diff 124462.Nov 27 2017, 1:50 PM

Updated to fix unittest failure.

mgorny reopened this revision.Nov 27 2017, 1:51 PM
This revision is now accepted and ready to land.Nov 27 2017, 1:51 PM
beanz accepted this revision.Nov 27 2017, 2:22 PM

LGTM.

This revision was automatically updated to reflect the committed changes.