summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2015-01-22 09:26:38 +0100
committerStephan Bergmann <sbergman@redhat.com>2015-01-22 10:18:20 +0100
commitb4f6b26b5a1a78fecfa95ec2eb7ac8b80495d8aa (patch)
tree2f7d758692154bcab85048f488793263d8326402 /include
parent8289191302749f91924fbff847fbf06f0998f85f (diff)
SAL_DLLPUBLIC_RTTI for proper RTTI visibility for LLVM
The Itanium C++ ABI mandates that for a unique (complete) C++ type a single unique symbol for the type's RTTI name is used across a process's dynamic objects (so type equivalence can be determined via pointer comparison on the RTTI names). GCC nowadays deviates from that, using strcmp to determine equivalence, so it is resilient to RTTI names being bound locally within dynamic objects (which has performance benefits, but also makes it impossible to have unrelated types that happen to have the same name "encapsulated" in individual dynamic objects--- whether or not that would violate the ODR would be open to interpretation of how dynamic objects fit into the C++ Standard). LLVM sticks to the Itanium ABI, which becomes notable in at least two places: For one, libc++abi's __dynamic_cast uses strict checking. It still has a _LIBCXX_DYNAMIC_FALLBACK for now that additionally uses strcmp checking and syslogs visibility violations. Mac OS X uses libc++abi with _LIBCXX_DYNAMIC_FALLBACK enabled, and running LO routinely logs dynamic_cast errors to the Console there. For another, RTTI-based UBSan checks unconditionally only use strict checking (cf. isDerivedFromAtOffset in lib/ubsan/ubsan_type_hash.cc). This causes false positives from Clang -fsanitize=function and -fsanitize=vptr even on Linux not using libc++abi. Therefore, introduce SAL_DLLPUBLIC_RTTI to mark types for which RTTI needs to have default visibility under the Itanium/LLVM semantics. There is unfortunately no way to mark only the (implicitly generated) RTTI symbols for default visibility, but at least with the cases where SAL_DLLPUBLIC_RTTI is used for now that is no real problem---any class type marked SAL_DLLPUBLIC_RTTI only has inline (covered by -fvisibility-inlines-hidden) or undefined pure virtual functions. It appears that even the vtables of those classes remain hidden, at least with Mach-O on Mac OS X. (That also means there is no need for a SAL_DLLPRIVATE_RTTI marker analoguous to the---also superfluous in retrospect--- CPPU_GCC_DLLPRIVATE one.) Nevertheless, the number of exported symbols of course increases when SAL_DLLPUBLIC_RTTI is "active." For a full-blown --enable-dbgutil build on Mac OS X, find instdir/LibreOffice.app/Contents -name \*.dylib\* -exec nm -gU {} \; \ wc -l increased from 125541 to 139239. For Linux, an option might be to "activate" SAL_DLLPUBLIC_RTTI only for __clang__ plus !ENABLE_RUNTIME_OPTIMIZATIONS. The set of types marked SAL_DLLPUBLIC_RTTI with this patch (wholesale cppumaker- generated UNO enum, struct, and interface types; plus some IEmbeddedHelper and IUndoManager) is chosen so that a full "make check" on Mac OS X no longer syslogs any dynamic_cast errors to the Console. Change-Id: I42fa6ec01c2503ec24bcd9c0518abb112afa3235
Diffstat (limited to 'include')
-rw-r--r--include/comphelper/embeddedobjectcontainer.hxx2
-rw-r--r--include/sal/types.h8
-rw-r--r--include/svl/undo.hxx2
3 files changed, 10 insertions, 2 deletions
diff --git a/include/comphelper/embeddedobjectcontainer.hxx b/include/comphelper/embeddedobjectcontainer.hxx
index 2c8e25f5e8a5..842a3e7f804c 100644
--- a/include/comphelper/embeddedobjectcontainer.hxx
+++ b/include/comphelper/embeddedobjectcontainer.hxx
@@ -36,7 +36,7 @@ namespace comphelper
class EmbeddedObjectContainer;
/** Helper interface to give access to some common object which replace the SfxObjectShell
*/
- class SAL_NO_VTABLE IEmbeddedHelper
+ class SAL_NO_VTABLE SAL_DLLPUBLIC_RTTI IEmbeddedHelper
{
public:
virtual EmbeddedObjectContainer& getEmbeddedObjectContainer() const = 0;
diff --git a/include/sal/types.h b/include/sal/types.h
index e77407b8355b..3d75f67ff920 100644
--- a/include/sal/types.h
+++ b/include/sal/types.h
@@ -249,6 +249,7 @@ typedef void * sal_Handle;
#endif // defined(_MSC_VER)
# define SAL_DLLPRIVATE
# define SAL_DLLPUBLIC_TEMPLATE
+# define SAL_DLLPUBLIC_RTTI
# define SAL_CALL __cdecl
# define SAL_CALL_ELLIPSE __cdecl
#elif defined SAL_UNX
@@ -259,12 +260,18 @@ typedef void * sal_Handle;
# define SAL_DLLPUBLIC_IMPORT __attribute__ ((visibility("hidden")))
# define SAL_DLLPRIVATE __attribute__ ((visibility("hidden")))
# define SAL_DLLPUBLIC_TEMPLATE __attribute__ ((visibility("hidden")))
+# define SAL_DLLPUBLIC_RTTI
# else
# define SAL_DLLPUBLIC_EXPORT __attribute__ ((visibility("default")))
# define SAL_JNI_EXPORT __attribute__ ((visibility("default")))
# define SAL_DLLPUBLIC_IMPORT __attribute__ ((visibility("default")))
# define SAL_DLLPRIVATE __attribute__ ((visibility("hidden")))
# define SAL_DLLPUBLIC_TEMPLATE __attribute__ ((visibility("default")))
+# if defined __clang__
+# define SAL_DLLPUBLIC_RTTI __attribute__ ((visibility("default")))
+# else
+# define SAL_DLLPUBLIC_RTTI
+# endif
# endif
# else
# define SAL_DLLPUBLIC_EXPORT
@@ -272,6 +279,7 @@ typedef void * sal_Handle;
# define SAL_DLLPUBLIC_IMPORT
# define SAL_DLLPRIVATE
# define SAL_DLLPUBLIC_TEMPLATE
+# define SAL_DLLPUBLIC_RTTI
# endif
# define SAL_CALL
# define SAL_CALL_ELLIPSE
diff --git a/include/svl/undo.hxx b/include/svl/undo.hxx
index 41fe58841163..92a9907db0f2 100644
--- a/include/svl/undo.hxx
+++ b/include/svl/undo.hxx
@@ -188,7 +188,7 @@ protected:
namespace svl
{
- class SAL_NO_VTABLE IUndoManager
+ class SAL_NO_VTABLE SAL_DLLPUBLIC_RTTI IUndoManager
{
public:
static bool const CurrentLevel = true;