From b919565e3aab43e7383dbfb0c0fb76e4fa168f55 Mon Sep 17 00:00:00 2001
From: psykose <alice@ayaya.dev>
Date: Wed, 14 Jun 2023 23:18:29 +0000
Subject: [PATCH] main/llvm-runtimes: fix libcxx with gcc13

---
 main/llvm-runtimes/APKBUILD           |  4 +++-
 main/llvm-runtimes/gcc13-libcxx.patch | 26 ++++++++++++++++++++++++++
 2 files changed, 29 insertions(+), 1 deletion(-)
 create mode 100644 main/llvm-runtimes/gcc13-libcxx.patch

diff --git a/main/llvm-runtimes/APKBUILD b/main/llvm-runtimes/APKBUILD
index 15978dbf0b82..140c6afc11ae 100644
--- a/main/llvm-runtimes/APKBUILD
+++ b/main/llvm-runtimes/APKBUILD
@@ -6,7 +6,7 @@ pkgname=llvm-runtimes
 # Note: Update together with llvm.
 pkgver=16.0.6
 _llvmver=${pkgver%%.*}
-pkgrel=0
+pkgrel=1
 pkgdesc="LLVM Runtimes"
 url="https://llvm.org/"
 arch="all"
@@ -30,6 +30,7 @@ subpackages="
 	llvm-libunwind-dev:libunwind_dev
 	"
 source="https://github.com/llvm/llvm-project/releases/download/llvmorg-${pkgver//_/-}/llvm-project-${pkgver//_/}.src.tar.xz
+	gcc13-libcxx.patch
 	armv6-arch.patch.noauto
 	compiler-rt-lsan-dtp-offset.patch
 	compiler-rt-ppc-fixes.patch
@@ -143,6 +144,7 @@ libcxx_dev() {
 
 sha512sums="
 89a67ebfbbc764cc456e8825ecfa90707741f8835b1b2adffae0b227ab1fe5ca9cce75b0efaffc9ca8431cae528dc54fd838867a56a2b645344d9e82d19ab1b7  llvm-project-16.0.6.src.tar.xz
+10abdde31e16ce919f9ef89656601c8d925b63d06c6b43dcba880766cb937cd329de2b177856e2a6e767c7e5f01efaefe4ef6ab8981a61e870202f654faa208f  gcc13-libcxx.patch
 5e7bbddbaea902e5ba5cd4db78bedbeef216f44fdd9b8f73efde6c09f40115c078649a109ffa61fefa0ee2f26655c038a48589ecac83068a47d60e9248c5dff1  armv6-arch.patch.noauto
 7c2cbd095b863f735842aaa8f0daecbf0282200fc58f1394139cee30d53c4a738757e38cbf0ec734398ee827e8a47314592bd7dc9768ef5c3664db682680e5a1  compiler-rt-lsan-dtp-offset.patch
 aaef886f71c5499da18ff18937404ab641cbc3a540ee9e4eed7ae6895970863e6d01ed598f8b2f1512936f33d6dd122cd7a00545afaf710a8026c729a3af720c  compiler-rt-ppc-fixes.patch
diff --git a/main/llvm-runtimes/gcc13-libcxx.patch b/main/llvm-runtimes/gcc13-libcxx.patch
new file mode 100644
index 000000000000..9a05e5d3053b
--- /dev/null
+++ b/main/llvm-runtimes/gcc13-libcxx.patch
@@ -0,0 +1,26 @@
+Patch-Source: https://reviews.llvm.org/D149313
+--
+diff --git a/libcxx/include/__type_traits/is_convertible.h b/libcxx/include/__type_traits/is_convertible.h
+--- a/libcxx/include/__type_traits/is_convertible.h
++++ b/libcxx/include/__type_traits/is_convertible.h
+@@ -24,11 +24,18 @@
+ 
+ _LIBCPP_BEGIN_NAMESPACE_STD
+ 
+-#if __has_builtin(__is_convertible_to) && !defined(_LIBCPP_USE_IS_CONVERTIBLE_FALLBACK)
++#if __has_builtin(__is_convertible) && !defined(_LIBCPP_USE_IS_CONVERTIBLE_FALLBACK)
++
++template <class _T1, class _T2>
++struct _LIBCPP_TEMPLATE_VIS is_convertible : public integral_constant<bool, __is_convertible(_T1, _T2)> {};
++
++#elif __has_builtin(__is_convertible_to) && !defined(_LIBCPP_USE_IS_CONVERTIBLE_FALLBACK)
+ 
+ template <class _T1, class _T2> struct _LIBCPP_TEMPLATE_VIS is_convertible
+     : public integral_constant<bool, __is_convertible_to(_T1, _T2)> {};
+ 
++// TODO: Remove this fallback when GCC < 13 support is no longer required.
++// GCC 13 has the __is_convertible built-in.
+ #else  // __has_builtin(__is_convertible_to) && !defined(_LIBCPP_USE_IS_CONVERTIBLE_FALLBACK)
+ 
+ namespace __is_convertible_imp
+
-- 
GitLab