[PATCH] D55404: [libcxx] Support building static library with hidden visibility
Petr Hosek via Phabricator
reviews at reviews.llvm.org
Fri Dec 7 11:34:40 PST 2018
phosek added a comment.
In D55404#1323155 <https://reviews.llvm.org/D55404#1323155>, @ldionne wrote:
> So... the way we planned on tackling the hidden visibility problem is https://reviews.llvm.org/D54810 (which is blocked on a couple of Clang bugs w.r.t. visibility attributes). Would https://reviews.llvm.org/D54810 solve your problem?
> Also, if your intent is to make _all_ symbols hidden, I don't think this patch achieves it because we still explicitly annotate symbols in the dylib as having default visibility. Am I mistaken?
Our use case is static library while D54810 <https://reviews.llvm.org/D54810> seems to focusing on shared case. Specifically, we need to link statically libc++ into various shared libraries and executables (e.g. drivers in Fuchsia) which might co-exist with other shared libraries and we need to ensure that no libc++ symbols are being exported. I suspect this might be also useful for other cases of "private libc++" such as libFuzzer.
The way this change achieves that is if you set the `LIBCXX_HIDDEN_VISIBILITY_IN_STATIC_LIBRARY` option, it defines `_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS` which should disable all existing annotations and then explicitly sets `-fvisibility=hidden -fvisibility-global-new-delete-hidden` (only for static library, shared library is unaffected). Does this make sense?
CHANGES SINCE LAST ACTION
More information about the libcxx-commits