git: 2da3b360fc60 - 2022Q2 - editors/libreoffice: fix i386/powerpc libcxxrt ABI change detection

From: Tijl Coosemans <tijl_at_FreeBSD.org>
Date: Sun, 01 May 2022 09:12:20 UTC
The branch 2022Q2 has been updated by tijl:

URL: https://cgit.FreeBSD.org/ports/commit/?id=2da3b360fc609a03871e31c4c2c4830beeca478f

commit 2da3b360fc609a03871e31c4c2c4830beeca478f
Author:     Tijl Coosemans <tijl@FreeBSD.org>
AuthorDate: 2022-04-30 17:03:16 +0000
Commit:     Tijl Coosemans <tijl@FreeBSD.org>
CommitDate: 2022-05-01 09:09:13 +0000

    editors/libreoffice: fix i386/powerpc libcxxrt ABI change detection
    
    This makes the bundled bridgetest_server/bridgetest_client working.
    
    Recently the size of struct __cxa_exception changed on 32 bit
    architectures.  A patch committed in 35a5054819f1 lets libreoffice
    detect this by comparing a field of the struct against a known value.
    In the bridgetest it turns out this value isn't always the same, so use
    a different field instead.
    
    PR:             263596
    
    (cherry picked from commit ca1c4839224a639c0ddd602a21b942efa4ca0952)
---
 editors/libreoffice/Makefile                               |  2 +-
 ...h-bridges_source_cpp__uno_gcc3__linux__intel_except.cxx | 14 +++++++++-----
 ...ch-bridges-source-cpp_uno-gcc3_linux_powerpc-except.cxx | 10 +++++++---
 3 files changed, 17 insertions(+), 9 deletions(-)

diff --git a/editors/libreoffice/Makefile b/editors/libreoffice/Makefile
index 7f4d00fcc486..f0f1edd13c73 100644
--- a/editors/libreoffice/Makefile
+++ b/editors/libreoffice/Makefile
@@ -1,4 +1,4 @@
-PORTREVISION=	2
+PORTREVISION=	3
 
 .include "${.CURDIR}/Makefile.common"
 
diff --git a/editors/libreoffice/files/patch-bridges_source_cpp__uno_gcc3__linux__intel_except.cxx b/editors/libreoffice/files/patch-bridges_source_cpp__uno_gcc3__linux__intel_except.cxx
index 439b9ea3adf4..ad195a344ce0 100644
--- a/editors/libreoffice/files/patch-bridges_source_cpp__uno_gcc3__linux__intel_except.cxx
+++ b/editors/libreoffice/files/patch-bridges_source_cpp__uno_gcc3__linux__intel_except.cxx
@@ -18,7 +18,7 @@
      ::typelib_typedescription_getByName( &pTD, unoName.pData );
      assert(pTD && "### unknown exception type! leaving out destruction => leaking!!!");
      if (pTD)
-@@ -262,8 +268,19 @@ void fillUnoException(uno_Any * pUnoExc, uno_Mapping *
+@@ -262,8 +268,23 @@ void fillUnoException(uno_Any * pUnoExc, uno_Mapping *
  
  void fillUnoException(uno_Any * pUnoExc, uno_Mapping * pCpp2Uno)
  {
@@ -29,10 +29,14 @@
 +             __cxxabiv1::__cxa_current_primary_exception());
 +    if (header) {
 +        __cxxabiv1::__cxa_decrement_exception_refcount(header);
-+        if (header[-1].exceptionDestructor != &deleteException) {
++        uint64_t exc_class = header[-1].unwindHeader.exception_class
++                           & 0xffffffffffffff00;
++        if (exc_class != /* "GNUCC++" */ 0x474e5543432b2b00) {
 +            header = reinterpret_cast<__cxxabiv1::__cxa_exception *>(
 +                reinterpret_cast<char *>(header) - 12);
-+            if (header[-1].exceptionDestructor != &deleteException) {
++            exc_class = header[-1].unwindHeader.exception_class
++                      & 0xffffffffffffff00;
++            if (exc_class != /* "GNUCC++" */ 0x474e5543432b2b00) {
 +                header = nullptr;
 +            }
 +        }
@@ -40,7 +44,7 @@
      if (! header)
      {
          RuntimeException aRE( "no exception header!" );
-@@ -273,7 +290,7 @@ void fillUnoException(uno_Any * pUnoExc, uno_Mapping *
+@@ -273,7 +294,7 @@ void fillUnoException(uno_Any * pUnoExc, uno_Mapping *
          return;
      }
  
@@ -49,7 +53,7 @@
  
      typelib_TypeDescription * pExcTypeDescr = nullptr;
      OUString unoName( toUNOname( exceptionType->name() ) );
-@@ -292,7 +309,7 @@ void fillUnoException(uno_Any * pUnoExc, uno_Mapping *
+@@ -292,7 +313,7 @@ void fillUnoException(uno_Any * pUnoExc, uno_Mapping *
      else
      {
          // construct uno exception any
diff --git a/editors/libreoffice/files/powerpc64/patch-bridges-source-cpp_uno-gcc3_linux_powerpc-except.cxx b/editors/libreoffice/files/powerpc64/patch-bridges-source-cpp_uno-gcc3_linux_powerpc-except.cxx
index c656588cb0a5..4c6e5f0a6941 100644
--- a/editors/libreoffice/files/powerpc64/patch-bridges-source-cpp_uno-gcc3_linux_powerpc-except.cxx
+++ b/editors/libreoffice/files/powerpc64/patch-bridges-source-cpp_uno-gcc3_linux_powerpc-except.cxx
@@ -48,7 +48,7 @@
      ::typelib_typedescription_getByName( &pTD, unoName.pData );
      assert(pTD && "### unknown exception type! leaving out destruction => leaking!!!");
      if (pTD)
-@@ -218,39 +225,68 @@ void raiseException( uno_Any * pUnoExc, uno_Mapping * 
+@@ -218,39 +225,72 @@ void raiseException( uno_Any * pUnoExc, uno_Mapping * 
      if (! pTypeDescr)
          terminate();
  
@@ -86,10 +86,14 @@
 +             __cxxabiv1::__cxa_current_primary_exception());
 +    if (header) {
 +        __cxxabiv1::__cxa_decrement_exception_refcount(header);
-+        if (header[-1].exceptionDestructor != &deleteException) {
++        uint64_t exc_class = header[-1].unwindHeader.exception_class
++                           & 0xffffffffffffff00;
++        if (exc_class != /* "GNUCC++" */ 0x474e5543432b2b00) {
 +            header = reinterpret_cast<__cxxabiv1::__cxa_exception *>(
 +                reinterpret_cast<char *>(header) - 12);
-+            if (header[-1].exceptionDestructor != &deleteException) {
++            exc_class = header[-1].unwindHeader.exception_class
++                      & 0xffffffffffffff00;
++            if (exc_class != /* "GNUCC++" */ 0x474e5543432b2b00) {
 +                header = nullptr;
 +            }
 +        }