diff mbox series

[bug#59237,3/3] gnu: Add clang-15.

Message ID 20221113050200.27277-3-maxim.cournoyer@gmail.com
State New
Headers show
Series Add LLVM/Clang 15.0.4. | expand

Checks

Context Check Description
cbaines/comparison success View comparision
cbaines/git-branch success View Git branch
cbaines/applying patch success
cbaines/issue success View issue

Commit Message

Maxim Cournoyer Nov. 13, 2022, 5:02 a.m. UTC
* gnu/packages/llvm.scm (clang-from-llvm*): New helper.
(clang-15): New variable.
---
 gnu/packages/llvm.scm | 61 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 61 insertions(+)

Comments

Ludovic Courtès Nov. 15, 2022, 10:33 a.m. UTC | #1
Maxim Cournoyer <maxim.cournoyer@gmail.com> skribis:

> * gnu/packages/llvm.scm (clang-from-llvm*): New helper.
> (clang-15): New variable.

[...]

> +;;; TODO: Integrate into original on core-updates, perhaps with an extra
> +;;; option such as #:build-shared-libs? documented as a legacy feature.
> +(define* (clang-from-llvm* llvm clang-runtime
> +                           #:optional hash
> +                           #:key (patches '()) tools-extra
> +                           (properties
> +                            (append `((release-monitoring-url
> +                                       . ,%llvm-release-monitoring-url))
> +                                    (clang-properties (package-version llvm)))))

[...]

> +          #~(modify-phases #$phases
> +              ;; Like the original, sans BUILD_SHARED_LIBS patching.
> +              #$@(if tools-extra

How about making it an option of ‘clang-from-llvm’ then, like suggested
above?

In ‘clang-from-llvm’, we’d have:

  `((add-after 'unpack 'add-tools-extra
      (lambda* …
        ,@(if tools-need-build-shared-libs-patch?
              `((substitute* …))
              '()
        #t))))

That’d factorize things while avoiding a full rebuild.

Ludo’.
Ludovic Courtès Nov. 15, 2022, 10:34 a.m. UTC | #2
Maxim Cournoyer <maxim.cournoyer@gmail.com> skribis:

> * gnu/packages/llvm.scm (clang-from-llvm*): New helper.
> (clang-15): New variable.

I believe we’ll also need ‘libomp-15’ as discussed at
<https://issues.guix.gnu.org/56666>.

Ludo’.
diff mbox series

Patch

diff --git a/gnu/packages/llvm.scm b/gnu/packages/llvm.scm
index d7b6207dc4..12e1e642c6 100644
--- a/gnu/packages/llvm.scm
+++ b/gnu/packages/llvm.scm
@@ -422,6 +422,43 @@  (define* (clang-from-llvm llvm clang-runtime
                  license:asl2.0         ;with LLVM exceptions
                  license:ncsa))))
 
+;;; TODO: Integrate into original on core-updates, perhaps with an extra
+;;; option such as #:build-shared-libs? documented as a legacy feature.
+(define* (clang-from-llvm* llvm clang-runtime
+                           #:optional hash
+                           #:key (patches '()) tools-extra
+                           (properties
+                            (append `((release-monitoring-url
+                                       . ,%llvm-release-monitoring-url))
+                                    (clang-properties (package-version llvm)))))
+  "Produce Clang with dependencies on LLVM and CLANG-RUNTIME, and applying the
+given PATCHES.  When TOOLS-EXTRA is given, it must point to the
+'clang-tools-extra' tarball, which contains code for 'clang-tidy', 'pp-trace',
+'modularize', and other tools."
+  (let ((base (clang-from-llvm llvm clang-runtime hash
+                               #:patches patches #:tools-extra tools-extra
+                               #:properties properties)))
+    (package
+      (inherit base)
+      (arguments
+       (substitute-keyword-arguments (package-arguments base)
+         ((#:phases phases ''%standard-phases)
+          #~(modify-phases #$phases
+              ;; Like the original, sans BUILD_SHARED_LIBS patching.
+              #$@(if tools-extra
+                     #~((replace 'add-tools-extra
+                          (lambda* (#:key inputs #:allow-other-keys)
+                            ;; Unpack the 'clang-tools-extra' tarball under
+                            ;; tools/.
+                            (let ((extra (assoc-ref inputs "clang-tools-extra")))
+                              (invoke "tar" "xf" extra)
+                              (rename-file #$(string-append
+                                              "clang-tools-extra-"
+                                              (string-delete #\- (package-version llvm))
+                                              ".src")
+                                           "tools/extra")))))
+                     #~()))))))))
+
 (define (clang-properties version)
   "Return package properties for Clang VERSION."
   `((compiler-cpu-architectures
@@ -729,6 +766,30 @@  (define-public clang-runtime-14
          ("gcc" ,gcc-11)
          ,@(package-native-inputs template))))))
 
+(define-public clang-15
+  (let ((template
+         (clang-from-llvm*
+          llvm-15 clang-runtime-15
+          #:tools-extra
+          (origin
+            (method url-fetch)
+            (uri (llvm-uri "clang-tools-extra"
+                           (package-version llvm-15)))
+            (sha256
+             (base32
+              "03adxlh84if9p53m6izjsql500rjza9rng8akab2pdqibgrg73rh"))))))
+    (package
+      (inherit template)
+      (arguments
+       (substitute-keyword-arguments (package-arguments template)
+         ((#:configure-flags flags ''())
+          #~(cons "-DCLANG_LINK_CLANG_DYLIB=ON" #$flags))
+         ((#:phases phases '%standard-phases)
+          #~(modify-phases #$phases
+              (add-after 'unpack 'change-directory
+                (lambda _
+                  (chdir "clang"))))))))))
+
 (define-public clang-14
   (let ((template
          (clang-from-llvm llvm-14 clang-runtime-14