Subject: [bug#54239] [PATCH v3 10/10] gnu: Add libcxxabi-12.

From: Julien Lepiller <[email-masked]>
Date: Sat, 16 Jul 2022 21:48:07 +0200

* gnu/packages/llvm.scm (libcxxabi-12): New variable.
(libcxxabi-9): Inherit from it.
---
 gnu/packages/llvm.scm | 53 +++++++++++++++++++++++++++++++++----------
 1 file changed, 41 insertions(+), 12 deletions(-)

diff --git a/gnu/packages/llvm.scm b/gnu/packages/llvm.scm
index 4f0b57a990..72fef43a5f 100644
--- a/gnu/packages/llvm.scm
+++ b/gnu/packages/llvm.scm
@@ -1707,17 +1707,17 @@ (define-public libcxx-6
          "0rzw4qvxp6qx4l4h9amrq02gp7hbg8lw4m0sy3k60f50234gnm3n"))))
     (inputs (list llvm-6))))
 
-(define-public libcxxabi-9
+(define-public libcxxabi-12
   (package
     (name "libcxxabi")
-    (version (package-version clang-9))
+    (version (package-version clang-12))
     (source
      (origin
        (method url-fetch)
-       (uri (llvm-uri "libcxxabi" version))
+       (uri (llvm-uri "llvm-project" version))
        (sha256
         (base32
-         "1b4aiaa8cirx52vk2p5kfk57qmbqf1ipb4nqnjhdgqps9jm7iyg8"))))
+         "03ps7akvbkxxa4xzal49v7lw3bz41zmjsp6fa7cslxrns5fb570j"))))
     (build-system cmake-build-system)
     (arguments
      `(#:configure-flags
@@ -1728,6 +1728,9 @@ (define-public libcxxabi-9
              "-DCMAKE_CXX_COMPILER=clang++")
        #:phases
        (modify-phases (@ (guix build cmake-build-system) %standard-phases)
+         (add-after 'unpack 'chdir
+           (lambda _
+             (chdir "libcxxabi")))
          (add-after 'unpack 'adjust-CPLUS_INCLUDE_PATH
            (lambda* (#:key inputs native-inputs #:allow-other-keys)
              (define (delete* what lst)
@@ -1773,14 +1776,10 @@ (define (delete* what lst)
              (let ((include-dir (string-append
                                  (assoc-ref outputs "out") "/include")))
                (mkdir-p include-dir)
-               (install-file ,(string-append "../libcxxabi-" version
-                                             ".src/include/__cxxabi_config.h")
-                             include-dir)
-               (install-file ,(string-append "../libcxxabi-" version
-                                             ".src/include/cxxabi.h")
-                             include-dir)))))))
-    (inputs (list llvm-9 libcxx-9))
-    (native-inputs (list (clang-for-target clang-9)))
+               (install-file "../libcxxabi/include/__cxxabi_config.h" include-dir)
+               (install-file "../libcxxabi/include/cxxabi.h" include-dir)))))))
+    (inputs (list llvm-12 libcxx-12))
+    (native-inputs (list (clang-for-target clang-12) python))
     (home-page "https://libcxxabi.llvm.org")
     (synopsis "C++ standard library support")
     (description
@@ -1788,6 +1787,36 @@ (define (delete* what lst)
 standard C++ library.")
     (license license:expat)))
 
+(define-public libcxxabi-9
+  (package
+    (inherit libcxxabi-12)
+    (version (package-version clang-9))
+    (source
+     (origin
+       (method url-fetch)
+       (uri (llvm-uri "libcxxabi" version))
+       (sha256
+        (base32
+         "1b4aiaa8cirx52vk2p5kfk57qmbqf1ipb4nqnjhdgqps9jm7iyg8"))))
+    (arguments
+     (substitute-keyword-arguments (package-arguments libcxxabi-12)
+       ((#:phases phases)
+        `(modify-phases ,phases
+           (delete 'chdir)
+           (replace 'install-headers
+             (lambda* (#:key outputs #:allow-other-keys)
+               (let ((include-dir (string-append
+                                   (assoc-ref outputs "out") "/include")))
+                 (mkdir-p include-dir)
+                 (install-file ,(string-append "../libcxxabi-" version
+                                               ".src/include/__cxxabi_config.h")
+                               include-dir)
+                 (install-file ,(string-append "../libcxxabi-" version
+                                               ".src/include/cxxabi.h")
+                               include-dir))))))))
+    (inputs (list llvm-9 libcxx-9))
+    (native-inputs (list (clang-for-target clang-9)))))
+
 (define-public libcxxabi-6
   (package
     (inherit libcxxabi-9)
-- 
2.37.0