[Libreoffice-commits] core.git: external/libcdr external/libqxp

Stephan Bergmann (via logerrit) logerrit at kemper.freedesktop.org
Fri Jan 22 06:32:27 UTC 2021


 external/libcdr/UnpackedTarball_libcdr.mk      |    1 +
 external/libcdr/ax_gcc_func_attribute.m4.patch |   11 +++++++++++
 external/libqxp/UnpackedTarball_libqxp.mk      |    3 +++
 external/libqxp/ax_gcc_func_attribute.m4.patch |   11 +++++++++++
 4 files changed, 26 insertions(+)

New commits:
commit 05aedcba6672979d317b540bbfa74f5c9b409402
Author:     Stephan Bergmann <sbergman at redhat.com>
AuthorDate: Thu Jan 21 23:19:20 2021 +0100
Commit:     Stephan Bergmann <sbergman at redhat.com>
CommitDate: Fri Jan 22 07:31:49 2021 +0100

    Fix use of -fvisibility=hidden with Clang in external/libcdr, external/libqxp
    
    At least on macOS x86-64 you get a warning
    
    > [build LNK] Library/libwpftdrawlo.dylib
    > ld: warning: direct access in function 'std::__1::__shared_ptr_pointer<librevenge::RVNGInputStream*, std::__1::shared_ptr<librevenge::RVNGInputStream>::__shared_ptr_default_delete<librevenge::RVNGInputStream, librevenge::RVNGInputStream>, std::__1::allocator<librevenge::RVNGInputStream> >::__get_deleter(std::type_info const&) const' from file 'workdir/UnpackedTarball/libzmf/src/lib/.libs/libzmf-0.0.a(ZMFDocument.o)' to global weak symbol 'typeinfo for std::__1::shared_ptr<librevenge::RVNGInputStream>::__shared_ptr_default_delete<librevenge::RVNGInputStream, librevenge::RVNGInputStream>' from file 'workdir/UnpackedTarball/libcdr/src/lib/.libs/libcdr-0.1.a(CDRDocument.o)' means the weak symbol cannot be overridden at runtime. This was likely caused by different translation units being compiled with different visibility settings.
    
    The reason is that libzmf uses -fvisibility=hidden and generates
    
    > $ nm -m workdir/UnpackedTarball/libzmf/src/lib/.libs/libzmf-0.0.a | grep __ZTINSt3__110shared_ptrIN10librevenge15RVNGInputStreamEE27__shared_ptr_default_deleteIS2_S2_EE
    > 0000000000006dd8 (__DATA,__const) weak private external __ZTINSt3__110shared_ptrIN10librevenge15RVNGInputStreamEE27__shared_ptr_default_deleteIS2_S2_EE
    
    while libcdr erroneously does not use -fvisibility=hidden and generates
    
    > $ nm -m workdir/UnpackedTarball/libcdr/src/lib/.libs/libcdr-0.1.a | grep __ZTINSt3__110shared_ptrIN10librevenge15RVNGInputStreamEE27__shared_ptr_default_deleteIS2_S2_EE
    > 00000000000072b8 (__DATA,__const) weak external __ZTINSt3__110shared_ptrIN10librevenge15RVNGInputStreamEE27__shared_ptr_default_deleteIS2_S2_EE
    
    The reason for that error is as follows:
    workdir/UnpackedTarball/libcdr/configure.ac uses, among other things, the result
    of
    
      AX_GCC_FUNC_ATTRIBUTE([visibility])
    
    when deciding whether to use -fvisibility=hidden.  And the old ("serial 5")
    workdir/UnpackedTarball/libcdr/m4/ax_gcc_func_attribute.m4 decides "no" if its
    test compilation generates any warning output.  But Clang on macOS generates
    
    > conftest.cpp:34:56: warning: target does not support 'protected' visibility; using 'default' [-Wunsupported-visibility]
    >                     int foo_pro( void ) __attribute__((visibility("protected")));
    >                                                        ^
    
    and lots of
    
    > conftest.cpp:2:9: warning: macro is not used [-Wunused-macros]
    > #define PACKAGE_NAME "libcdr"
    >         ^
    
    (because of -Wunused-macros set for Clang in
    solenv/gbuild/platform/com_GCC_defs.mk).
    
    Same issue with external/libqxp, which would cause
    
    > [LNK] Library/libwpftdrawlo.dylib
    > ld: warning: direct access in function 'std::__1::__shared_ptr_pointer<librevenge::RVNGInputStream*, std::__1::shared_ptr<librevenge::RVNGInputStream>::__shared_ptr_default_delete<librevenge::RVNGInputStream, librevenge::RVNGInputStream>, std::__1::allocator<librevenge::RVNGInputStream> >::__get_deleter(std::type_info const&) const' from file 'workdir/UnpackedTarball/libcdr/src/lib/.libs/libcdr-0.1.a(CDRDocument.o)' to global weak symbol 'typeinfo for std::__1::shared_ptr<librevenge::RVNGInputStream>::__shared_ptr_default_delete<librevenge::RVNGInputStream, librevenge::RVNGInputStream>' from file 'workdir/UnpackedTarball/libqxp/src/lib/.libs/libqxp-0.0.a(QXPMacFileParser.o)' means the weak symbol cannot be overridden at runtime. This was likely caused by different translation units being compiled with different visibility settings.
    
    <http://git.savannah.gnu.org/gitweb/?p=autoconf-archive.git;a=commitdiff;
    h=df0894ad1a8195df67a52108b931e07d708cec9a> "ax_gcc_func_attribute: Revise the
    detection of unknown attributes", even though it was apparently meant to fix
    something different, nicely fixes this Clang issue, making AX_GCC_FUNC_ATTRIBUTE
    correctly detect support for visibility now.
    
    When building with Clang on Linux, there is no -Wunsupported-visibility about
    __attribute__((visibility("protected"))), but all the -Wunused-macros are
    present as well, which caused all the AX_GCC_FUNC_ATTRIBUTE checks to be mis-
    detected as "no" there, too.
    
    There are more uses of AX_GCC_FUNC_ATTRIBUTE in
    workdir/UnpackedTarball/libcdr/configure.ac and
    workdir/UnpackedTarball/libqxp/configure.ac, and there are many more
    workdir/UnpackedTarball/*/m4/ax_gcc_func_attribute.m4 in other external projects,
    all of which may cause similar AX_GCC_FUNC_ATTRIBUTE mis-detections.  However,
    they do not cause any noticeable traces like the "direct access" ld warning here,
    so I left those alone for now.  (Ultimately, all the upstream external projects
    should probably deploy the latest version of ax_gcc_func_attribute.m4 from
    <http://git.savannah.gnu.org/gitweb/?p=autoconf-archive.git;a=blob_plain;
    f=m4/ax_gcc_func_attribute.m4>.)
    
    Change-Id: Ia0560cace770ec7da9ee390566a01a5c592f9209
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109774
    Tested-by: Stephan Bergmann <sbergman at redhat.com>
    Reviewed-by: Stephan Bergmann <sbergman at redhat.com>

diff --git a/external/libcdr/UnpackedTarball_libcdr.mk b/external/libcdr/UnpackedTarball_libcdr.mk
index 778fd9eca123..d8742f3c5f5a 100644
--- a/external/libcdr/UnpackedTarball_libcdr.mk
+++ b/external/libcdr/UnpackedTarball_libcdr.mk
@@ -18,6 +18,7 @@ $(eval $(call gb_UnpackedTarball_update_autoconf_configs,libcdr))
 $(eval $(call gb_UnpackedTarball_add_patches,libcdr, \
     external/libcdr/libcdr-visibility-win.patch \
     external/libcdr/libcdr-no-icu-boolean.patch.1 \
+    external/libcdr/ax_gcc_func_attribute.m4.patch \
 ))
 
 # vim: set noet sw=4 ts=4:
diff --git a/external/libcdr/ax_gcc_func_attribute.m4.patch b/external/libcdr/ax_gcc_func_attribute.m4.patch
new file mode 100644
index 000000000000..37f4edf0bd46
--- /dev/null
+++ b/external/libcdr/ax_gcc_func_attribute.m4.patch
@@ -0,0 +1,11 @@
+--- configure
++++ configure
+@@ -19167,7 +19167,7 @@
+ 
+ _ACEOF
+ if ac_fn_cxx_try_link "$LINENO"; then :
+-                                      if test -s conftest.err; then :
++                                      if grep -- -Wattributes conftest.err; then :
+   ax_cv_have_func_attribute_visibility=no
+ else
+   ax_cv_have_func_attribute_visibility=yes
diff --git a/external/libqxp/UnpackedTarball_libqxp.mk b/external/libqxp/UnpackedTarball_libqxp.mk
index 0ac69bc6f079..9f111bcb2b81 100644
--- a/external/libqxp/UnpackedTarball_libqxp.mk
+++ b/external/libqxp/UnpackedTarball_libqxp.mk
@@ -13,8 +13,11 @@ $(eval $(call gb_UnpackedTarball_set_tarball,libqxp,$(QXP_TARBALL)))
 
 $(eval $(call gb_UnpackedTarball_update_autoconf_configs,libqxp))
 
+$(eval $(call gb_UnpackedTarball_set_patchlevel,libqxp,0))
+
 $(eval $(call gb_UnpackedTarball_add_patches,libqxp, \
 	external/libqxp/android-workaround.patch.1 \
+	external/libcdr/ax_gcc_func_attribute.m4.patch \
 ))
 
 # vim: set noet sw=4 ts=4:
diff --git a/external/libqxp/ax_gcc_func_attribute.m4.patch b/external/libqxp/ax_gcc_func_attribute.m4.patch
new file mode 100644
index 000000000000..8f7457816efd
--- /dev/null
+++ b/external/libqxp/ax_gcc_func_attribute.m4.patch
@@ -0,0 +1,11 @@
+--- configure
++++ configure
+@@ -18136,7 +18136,7 @@
+ 
+ _ACEOF
+ if ac_fn_cxx_try_link "$LINENO"; then :
+-                                      if test -s conftest.err; then :
++                                      if grep -- -Wattributes conftest.err; then :
+   ax_cv_have_func_attribute_visibility=no
+ else
+   ax_cv_have_func_attribute_visibility=yes


More information about the Libreoffice-commits mailing list