This is an archive of the discontinued LLVM Phabricator instance.

[CMake][lldb] add_lldb_library's functions require default visibility
Needs ReviewPublic

Authored by radford on Apr 20 2021, 3:29 PM.

Details

Summary

Compiling lldb, in a cmake sub-project that compiles with visibility
hidden, will generate a "cannot export hidden symbol" error because we
require default visibility. Even though we export using
-Wl,-exported_symbols_list,liblldb.exports, if each .cpp file is
compiled with -fvisibility=hidden, then you'll get this warning and
linking will fail. Essentially -exported_symbols_list is not strong
enough to reverse the -fvisibility=hidden.

Diff Detail

Event Timeline

radford created this revision.Apr 20 2021, 3:29 PM
radford requested review of this revision.Apr 20 2021, 3:29 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 20 2021, 3:29 PM
labath added a subscriber: labath.Apr 20 2021, 11:58 PM

Is there a way to address this through the preprocessor? We already have the LLDB_API macro, which expands to __declspec(dllexport/import) on windows. Would expanding it do __attribute__((visibility("default"))) (or something) on other platforms help with anything?

Yes, this IMO should eventually be addressed by explicitly exporting each meant-to-be-exported function with LLDB_ABI and then changing the line this patch adds to use hidden instead of default.

This patch is meant to be a band-aid until that can be done.