Subject: [PATCH v3 08/10] gnu: Add libcxxabi-9.

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

* gnu/packages/llvm.scm (libcxxabi-9): New variable.
(libcxxabi-6): Inherit from it.
---
 gnu/packages/llvm.scm | 66 +++++++++++++++++++++++++++++++------------
 1 file changed, 48 insertions(+), 18 deletions(-)

diff --git a/gnu/packages/llvm.scm b/gnu/packages/llvm.scm
index ba48897c8b..77c3ab73e0 100644
--- a/gnu/packages/llvm.scm
+++ b/gnu/packages/llvm.scm
@@ -1685,20 +1685,17 @@ (define-public libcxx-6
          "0rzw4qvxp6qx4l4h9amrq02gp7hbg8lw4m0sy3k60f50234gnm3n"))))
     (inputs (list llvm-6))))
 
-(define-public libcxxabi-6
+(define-public libcxxabi-9
   (package
     (name "libcxxabi")
-    (version "6.0.1")
+    (version (package-version clang-9))
     (source
      (origin
-       (method git-fetch)
-       (uri (git-reference
-             (url "https://github.com/llvm/llvm-project")
-             (commit (string-append "llvmorg-" version))))
-       (file-name (git-file-name name version))
+       (method url-fetch)
+       (uri (llvm-uri "libcxxabi" version))
        (sha256
         (base32
-         "0ki6796b5z08kh3a3rbysr5wwb2dkl6wal5dzd03i4li5xfkvx1g"))))
+         "1b4aiaa8cirx52vk2p5kfk57qmbqf1ipb4nqnjhdgqps9jm7iyg8"))))
     (build-system cmake-build-system)
     (arguments
      `(#:configure-flags
@@ -1709,8 +1706,6 @@ (define-public libcxxabi-6
              "-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)
@@ -1744,10 +1739,10 @@ (define (delete* what lst)
                                         (string-append gcc "/include/c++"))
                                   (string-split (getenv "CROSS_CPLUS_INCLUDE_PATH")
                                                 #\:)))
-                          ":"))
-                 (format #true
-                         "environment variable `CROSS_CPLUS_INCLUDE_PATH' changed to ~a~%"
-                         (getenv "CROSS_CPLUS_INCLUDE_PATH")))
+                          ":")))
+               (format #true
+                       "environment variable `CROSS_CPLUS_INCLUDE_PATH' changed to ~a~%"
+                       (getenv "CROSS_CPLUS_INCLUDE_PATH"))
                (format #true
                        "environment variable `CPLUS_INCLUDE_PATH' changed to ~a~%"
                        (getenv "CPLUS_INCLUDE_PATH")))))
@@ -1755,10 +1750,15 @@ (define (delete* what lst)
            (lambda* (#:key outputs #:allow-other-keys)
              (let ((include-dir (string-append
                                  (assoc-ref outputs "out") "/include")))
-               (install-file "../libcxxabi/include/__cxxabi_config.h" include-dir)
-               (install-file "../libcxxabi/include/cxxabi.h" include-dir)))))))
-    (inputs (list llvm-6 libcxx-6))
-    (native-inputs (list (clang-for-target clang-6)))
+               (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))
+    (native-inputs (list (clang-for-target clang-9)))
     (home-page "https://libcxxabi.llvm.org")
     (synopsis "C++ standard library support")
     (description
@@ -1766,6 +1766,36 @@ (define (delete* what lst)
 standard C++ library.")
     (license license:expat)))
 
+(define-public libcxxabi-6
+  (package
+    (inherit libcxxabi-9)
+    (name "libcxxabi")
+    (version "6.0.1")
+    (source
+     (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://github.com/llvm/llvm-project")
+             (commit (string-append "llvmorg-" version))))
+       (file-name (git-file-name name version))
+       (sha256
+        (base32
+         "0ki6796b5z08kh3a3rbysr5wwb2dkl6wal5dzd03i4li5xfkvx1g"))))
+    (arguments
+     (substitute-keyword-arguments (package-arguments libcxxabi-9)
+      ((#:phases phases)
+       `(modify-phases ,phases
+          (add-after 'unpack 'chdir
+            (lambda _ (chdir "libcxxabi")))
+          (replace 'install-headers
+            (lambda* (#:key outputs #:allow-other-keys)
+              (let ((include-dir (string-append
+                                  (assoc-ref outputs "out") "/include")))
+                (install-file "../libcxxabi/include/__cxxabi_config.h" include-dir)
+                (install-file "../libcxxabi/include/cxxabi.h" include-dir))))))))
+    (inputs (list llvm-6 libcxx-6))
+    (native-inputs (list (clang-for-target clang-6)))))
+
 (define-public libcxx+libcxxabi-6
   (package
     (inherit libcxx-6)
-- 
2.37.0