This is an archive of the discontinued LLVM Phabricator instance.

[libunwind] Add _LIBUNWIND_DISABLE_VISIBILITY_ANNOTATIONS
ClosedPublic

Authored by thomasanderson on Jun 26 2017, 12:02 PM.

Details

Summary

It's useful to be able to disable visibility annotations entirely; for
example, if we're building libunwind static to include in another library,
and we don't want any libunwind functions getting exported out of that
library.

A macro to indicate static builds might make more sense, but for now
we want to be consistent with libc++/libc++abi. Reevaluate in the
future.

Diff Detail

Event Timeline

compnerd requested changes to this revision.Jun 26 2017, 5:30 PM
compnerd added inline comments.
src/config.h
47

If the intent is to prevent the symbols from being exported, then hidden visibility is still desirable. I think that having something like a check for a static build makes more sense rather than just disabling the visibility annotations.

This revision now requires changes to proceed.Jun 26 2017, 5:30 PM
thomasanderson added inline comments.Jun 26 2017, 5:33 PM
src/config.h
47

This is what libc++ and libc++abi do already. Search for _LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS and _LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS

thomasanderson added inline comments.Jun 26 2017, 5:42 PM
src/config.h
47

Forgot to say, for this use case, you're expected to link with -fvisibility=hidden.

compnerd added inline comments.Jun 26 2017, 9:58 PM
src/config.h
47

I assume you mean compile libunwind with -fvisibility=hidden, which makes the condition even weirder, because you really do want the visibility, just dont want to mark functions for export (basically, you want to use the visibility similar to DLL storage). Indicating a static build and conditionalizing it on that seems more inline with the intent and the desired behaviour.

compnerd accepted this revision.Jun 27 2017, 11:30 AM

Discussed with @thakis on IRC; we can go ahead with this, but this will change in the future to be conditionalised on whether you are building a static or shared library. The intention here is to build without the exports and maintain hidden visibility. Although this is different from libc++, it is due to the fact that the current libunwind interfaces dont make as much sense on Windows (the itanium model and the windows exception model are thoroughly different), so removing the visibility attributes doesn't make much sense.

This revision is now accepted and ready to land.Jun 27 2017, 11:30 AM
thomasanderson edited the summary of this revision. (Show Details)Jun 27 2017, 11:36 AM
thakis closed this revision.Jun 27 2017, 11:37 AM
thakis edited edge metadata.

r306442, thanks!