codemaker/source/cppumaker/cpputype.cxx |    4 ++++
 include/rtl/alloc.h                     |    3 ++-
 include/rtl/ustring.h                   |    3 ++-
 include/sal/types.h                     |    8 ++++++--
 include/xmloff/xmlimppr.hxx             |    4 ++++
 5 files changed, 18 insertions(+), 4 deletions(-)

New commits:
commit e8b9bcf021c1733c0def6043e4032d4f07bb889b
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Mon Mar 4 14:42:25 2024 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Tue Mar 5 14:39:06 2024 +0100

    map SAL_DLLPUBLIC_RTTI to visibility:default for gcc
    
    Because I want to make more symbols private, but that runs into a
    problem with the special symbol "typeinfo for Foo" which is required for
    dynamic_cast.
    
    For clang, we can use SAL_DLLPUBLIC_RTTI to make just that magic
    "typeinfo for Foo" symbol visible.
    
    But for gcc, we are left with no option but to make the whole class
    visible via <MODULE>_DLLPUBLIC.
    (I have a feature request logged against gcc to support something like
    that at https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113958)
    
    But I also don't want to use <MODULE>_DLLPUBLIC, since that blocks
    progress of reducing symbol visibility for platforms other than gcc.
    
    So map SAL_DLLPUBLIC_RTTI to visiblity:default for gcc, which means that
    only gcc suffers the negative affects of not having that annotation.
    
    However, that runs into the problem that gcc does not like
    visibility:default in a couple of places, so I have to introduce some
    extra preprocessor stuff.
    
    Change-Id: Ib4fc5c1d2a1f8cf87d5159a4b5684137ec061605
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164356
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/codemaker/source/cppumaker/cpputype.cxx 
b/codemaker/source/cppumaker/cpputype.cxx
index 9ae5d689072e..b2ba3413402c 100644
--- a/codemaker/source/cppumaker/cpputype.cxx
+++ b/codemaker/source/cppumaker/cpputype.cxx
@@ -3328,7 +3328,11 @@ void EnumType::addComprehensiveGetCppuTypeIncludes(
 void EnumType::dumpDeclaration(FileStream& o)
 {
     o << "
#if defined LIBO_INTERNAL_ONLY
";
+    o << "
#if defined __GNUC__
"; // gcc does not like visibility annotation on enum
+    o << "
enum class " << id_ << "
{
";
+    o << "
#else
";
     o << "
enum class SAL_DLLPUBLIC_RTTI " << id_ << "
{
";
+    o << "
#endif
";
     o << "
#else
";
     o << "
enum SAL_DLLPUBLIC_RTTI " << id_ << "
{
";
     o << "
#endif
";
diff --git a/include/rtl/alloc.h b/include/rtl/alloc.h
index 4ce01cf1bcb4..1dc9cefacb0d 100644
--- a/include/rtl/alloc.h
+++ b/include/rtl/alloc.h
@@ -153,7 +153,8 @@ SAL_DLLPUBLIC void SAL_CALL rtl_freeAlignedMemory (
 
 /** Opaque rtl_arena_type.
  */
-typedef struct SAL_DLLPUBLIC_RTTI rtl_arena_st rtl_arena_type;
+struct SAL_DLLPUBLIC_RTTI rtl_arena_st;
+typedef struct rtl_arena_st rtl_arena_type;
 
 #define RTL_ARENA_NAME_LENGTH 31
 
diff --git a/include/rtl/ustring.h b/include/rtl/ustring.h
index 303aff446023..ddc87e29205d 100644
--- a/include/rtl/ustring.h
+++ b/include/rtl/ustring.h
@@ -1197,7 +1197,8 @@ SAL_DLLPUBLIC double SAL_CALL rtl_ustr_toDouble(
 /** @cond INTERNAL */
 /** The implementation of a Unicode string.
 */
-typedef struct SAL_DLLPUBLIC_RTTI _rtl_uString
+struct SAL_DLLPUBLIC_RTTI _rtl_uString;
+typedef struct _rtl_uString
 {
     oslInterlockedCount refCount; /* opaque */
     sal_Int32           length;
diff --git a/include/sal/types.h b/include/sal/types.h
index c61956f647d7..a2ef256239e1 100644
--- a/include/sal/types.h
+++ b/include/sal/types.h
@@ -220,7 +220,7 @@ 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
+#       define SAL_DLLPUBLIC_RTTI     __attribute__ ((visibility("default")))
 #     else
 #       define SAL_DLLPUBLIC_EXPORT  __attribute__ ((visibility("default")))
 #       define SAL_JNI_EXPORT        __attribute__ ((visibility("default")))
@@ -234,7 +234,11 @@ typedef void *                   sal_Handle;
 #           define SAL_DLLPUBLIC_RTTI  __attribute__ ((visibility("default")))
 #         endif
 #       else
-#         define SAL_DLLPUBLIC_RTTI
+// GCC does not have currently have equivalent functionality to clang's 
type_visibility
+// but I have a feature request for that at 
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113958
+// Until that is implemented, just make the whole class visible, which is what 
I would need to
+// do anyhow if something wants to import the typeinfo symbol.
+#         define SAL_DLLPUBLIC_RTTI  __attribute__ ((visibility("default")))
 #       endif
 #     endif
 #   else
diff --git a/include/xmloff/xmlimppr.hxx b/include/xmloff/xmlimppr.hxx
index adfba4eadc60..1f537a322eea 100644
--- a/include/xmloff/xmlimppr.hxx
+++ b/include/xmloff/xmlimppr.hxx
@@ -39,7 +39,11 @@ namespace com::sun::star::uno { template <typename > class 
Reference; }
 namespace com::sun::star::uno { template <typename > class Sequence; }
 namespace com::sun::star::xml::sax { class XAttributeList; }
 namespace com::sun::star::xml::sax { class XFastAttributeList; }
+#if defined __GNUC__ // gcc does not like visibility annotation on enum
+namespace com::sun::star::drawing { enum class FillStyle; }
+#else
 namespace com::sun::star::drawing { enum class SAL_DLLPUBLIC_RTTI FillStyle; }
+#endif
 
 struct XMLPropertyState;
 class XMLPropertySetMapper;

Reply via email to