commit:     40d66f4bcbe00db8b13ef9548f298e82ec111928
Author:     Ionen Wolkens <ionen <AT> gentoo <DOT> org>
AuthorDate: Tue Sep 13 01:50:10 2022 +0000
Commit:     Ionen Wolkens <ionen <AT> gentoo <DOT> org>
CommitDate: Tue Sep 13 04:17:54 2022 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=40d66f4b

app-emulation/wine-proton: fix clang + USE=-llvm-libunwind build

_Unwind_Find_FDE doesn't exist in libunwind but does in gcc's rtlib,
clang instead expects it from llvm-libunwind which leads to undefined
references even with USE=-unwind.

Messy but add extra guards around it.

Signed-off-by: Ionen Wolkens <ionen <AT> gentoo.org>

 .../files/wine-proton-7.0.4-llvm-libunwind.patch   |  9 -----
 .../files/wine-proton-7.0.4-unwind.patch           | 40 ++++++++++++++++++++++
 app-emulation/wine-proton/wine-proton-7.0.4.ebuild |  2 +-
 .../wine-proton/wine-proton-7.0.9999.ebuild        |  2 +-
 4 files changed, 42 insertions(+), 11 deletions(-)

diff --git 
a/app-emulation/wine-proton/files/wine-proton-7.0.4-llvm-libunwind.patch 
b/app-emulation/wine-proton/files/wine-proton-7.0.4-llvm-libunwind.patch
deleted file mode 100644
index 0086fa5e0353..000000000000
--- a/app-emulation/wine-proton/files/wine-proton-7.0.4-llvm-libunwind.patch
+++ /dev/null
@@ -1,9 +0,0 @@
-Note the dodgy _CONFIG_H_ check can be removed when >=llvm-libunwind-15
-(which adds _VERSION) is well established: https://reviews.llvm.org/D121015
---- a/dlls/ntdll/unix/signal_x86_64.c
-+++ b/dlls/ntdll/unix/signal_x86_64.c
-@@ -1370,3 +1370,3 @@
- 
--#ifdef __APPLE__
-+#if defined(__APPLE__) || defined(_LIBUNWIND_VERSION) || 
defined(____LIBUNWIND_CONFIG_H__)
-     rc = unw_getcontext( &unw_context );

diff --git a/app-emulation/wine-proton/files/wine-proton-7.0.4-unwind.patch 
b/app-emulation/wine-proton/files/wine-proton-7.0.4-unwind.patch
new file mode 100644
index 000000000000..372def52ba0c
--- /dev/null
+++ b/app-emulation/wine-proton/files/wine-proton-7.0.4-unwind.patch
@@ -0,0 +1,40 @@
+Fix build with llvm-libunwind, and also fix for non-llvm libunwind
+when using clang+bfd given clang doesn't have _Unwind_Find_FDE in
+its rtlib and expects it from llvm-libunwind.
+
+The _CONFIG_H_ check is for <llvm-libunwind-15 (adds _VERSION).
+--- a/dlls/ntdll/unix/signal_x86_64.c
++++ b/dlls/ntdll/unix/signal_x86_64.c
+@@ -646,7 +646,9 @@
+     unsigned int cie_offset;
+ };
+ 
++#if defined(_LIBUNWIND_VERSION) || defined(____LIBUNWIND_CONFIG_H__) || 
!defined(__clang__)
+ extern const struct dwarf_fde *_Unwind_Find_FDE (void *, struct 
dwarf_eh_bases *);
++#endif
+ 
+ static unsigned char dwarf_get_u1( const unsigned char **p )
+ {
+@@ -1368,7 +1370,7 @@
+     unw_proc_info_t info;
+     int rc;
+ 
+-#ifdef __APPLE__
++#if defined(__APPLE__) || defined(_LIBUNWIND_VERSION) || 
defined(____LIBUNWIND_CONFIG_H__)
+     rc = unw_getcontext( &unw_context );
+     if (rc == UNW_ESUCCESS)
+         rc = unw_init_local( &cursor, &unw_context );
+@@ -1491,11 +1493,13 @@
+ NTSTATUS CDECL unwind_builtin_dll( ULONG type, DISPATCHER_CONTEXT *dispatch, 
CONTEXT *context )
+ {
+     struct dwarf_eh_bases bases;
++#if defined(_LIBUNWIND_VERSION) || defined(____LIBUNWIND_CONFIG_H__) || 
!defined(__clang__)
+     const struct dwarf_fde *fde = _Unwind_Find_FDE( (void *)(context->Rip - 
1), &bases );
+ 
+     if (fde)
+         return dwarf_virtual_unwind( context->Rip, 
&dispatch->EstablisherFrame, context, fde,
+                                      &bases, &dispatch->LanguageHandler, 
&dispatch->HandlerData );
++#endif
+ #ifdef HAVE_LIBUNWIND
+     return libunwind_virtual_unwind( context->Rip, 
&dispatch->EstablisherFrame, context,
+                                      &dispatch->LanguageHandler, 
&dispatch->HandlerData );

diff --git a/app-emulation/wine-proton/wine-proton-7.0.4.ebuild 
b/app-emulation/wine-proton/wine-proton-7.0.4.ebuild
index 9101a5f62172..4d1b0a1aa939 100644
--- a/app-emulation/wine-proton/wine-proton-7.0.4.ebuild
+++ b/app-emulation/wine-proton/wine-proton-7.0.4.ebuild
@@ -106,10 +106,10 @@ IDEPEND=">=app-eselect/eselect-wine-1.2.2-r1"
 QA_TEXTRELS="usr/lib/*/wine/i386-unix/*.so" # uses -fno-PIC -Wl,-z,notext
 
 PATCHES=(
-       "${FILESDIR}"/${PN}-7.0.4-llvm-libunwind.patch
        "${FILESDIR}"/${PN}-7.0.4-musl.patch
        "${FILESDIR}"/${PN}-7.0.4-noexecstack.patch
        "${FILESDIR}"/${PN}-7.0.4-restore-menubuilder.patch
+       "${FILESDIR}"/${PN}-7.0.4-unwind.patch
 )
 
 pkg_pretend() {

diff --git a/app-emulation/wine-proton/wine-proton-7.0.9999.ebuild 
b/app-emulation/wine-proton/wine-proton-7.0.9999.ebuild
index ea37d6fbf06a..0df6fada339d 100644
--- a/app-emulation/wine-proton/wine-proton-7.0.9999.ebuild
+++ b/app-emulation/wine-proton/wine-proton-7.0.9999.ebuild
@@ -106,10 +106,10 @@ IDEPEND=">=app-eselect/eselect-wine-1.2.2-r1"
 QA_TEXTRELS="usr/lib/*/wine/i386-unix/*.so" # uses -fno-PIC -Wl,-z,notext
 
 PATCHES=(
-       "${FILESDIR}"/${PN}-7.0.4-llvm-libunwind.patch
        "${FILESDIR}"/${PN}-7.0.4-musl.patch
        "${FILESDIR}"/${PN}-7.0.4-noexecstack.patch
        "${FILESDIR}"/${PN}-7.0.4-restore-menubuilder.patch
+       "${FILESDIR}"/${PN}-7.0.4-unwind.patch
 )
 
 pkg_pretend() {

Reply via email to