guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

branch master updated: gnu: clang: Build 'clang-tools-extra'.


From: guix-commits
Subject: branch master updated: gnu: clang: Build 'clang-tools-extra'.
Date: Thu, 28 May 2020 06:50:40 -0400

This is an automated email from the git hooks/post-receive script.

civodul pushed a commit to branch master
in repository guix.

The following commit(s) were added to refs/heads/master by this push:
     new 77a87ad  gnu: clang: Build 'clang-tools-extra'.
77a87ad is described below

commit 77a87ad4aceed9d89d615540e0fd147e3a8b2f64
Author: Ludovic Courtès <ludovic.courtes@inria.fr>
AuthorDate: Thu May 28 11:46:59 2020 +0200

    gnu: clang: Build 'clang-tools-extra'.
    
    * gnu/packages/llvm.scm (clang-from-llvm): Add #:tools-extra.
    Add 'output' field.  In 'inputs', add TOOLS-EXTRA when it's given.
    In 'arguments', add 'add-tools-extra' and 'move-extra-tools' phases when
    TOOLS-EXTRA is given.
---
 gnu/packages/llvm.scm | 87 +++++++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 84 insertions(+), 3 deletions(-)

diff --git a/gnu/packages/llvm.scm b/gnu/packages/llvm.scm
index 47b490a..11e4cfb 100644
--- a/gnu/packages/llvm.scm
+++ b/gnu/packages/llvm.scm
@@ -201,7 +201,11 @@ compiler.  In LLVM this library is called 
\"compiler-rt\".")
     (supported-systems (delete "mips64el-linux" %supported-systems))))
 
 (define* (clang-from-llvm llvm clang-runtime hash
-                          #:key (patches '()))
+                          #:key (patches '()) tools-extra)
+  "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."
   (package
     (name "clang")
     (version (package-version llvm))
@@ -218,11 +222,15 @@ compiler.  In LLVM this library is called 
\"compiler-rt\".")
     ;; doesn't seem to be any way to do this with clang's autotools-based
     ;; build system.
     (build-system cmake-build-system)
+    (outputs (if tools-extra '("out" "extra") '("out")))
     (native-inputs (package-native-inputs llvm))
     (inputs
      `(("libxml2" ,libxml2)
        ("gcc-lib" ,gcc "lib")
-       ,@(package-inputs llvm)))
+       ,@(package-inputs llvm)
+       ,@(if tools-extra
+             `(("clang-tools-extra" ,tools-extra))
+             '())))
     (propagated-inputs
      `(("llvm" ,llvm)
        ("clang-runtime" ,clang-runtime)))
@@ -243,6 +251,71 @@ compiler.  In LLVM this library is called 
\"compiler-rt\".")
        #:build-type "Release"
 
        #:phases (modify-phases %standard-phases
+                  ,@(if tools-extra
+                        `((add-after 'unpack '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-"
+                                               (package-version llvm)
+                                               ".src")
+                                             "tools/extra")
+                                #t)))
+                          (add-after 'install 'move-extra-tools
+                            (lambda* (#:key outputs #:allow-other-keys)
+                              ;; Move the extra tools to the "extra" output.
+                              ;; These programs alone weigh in at 296 MiB,
+                              ;; because they statically-link a whole bunch of
+                              ;; Clang libraries.
+                              (let* ((out   (assoc-ref outputs "out"))
+                                     (extra (assoc-ref outputs "extra"))
+                                     (bin   (string-append out "/bin"))
+                                     (bin*  (string-append extra "/bin"))
+                                     (lib   (string-append out "/lib")))
+                                (define (move program)
+                                  (rename-file (string-append bin "/" program)
+                                               (string-append bin* "/"
+                                                              program)))
+
+                                (mkdir-p bin*)
+                                (for-each move
+                                          '("clang-apply-replacements"
+                                            "clang-change-namespace"
+                                            "clangd"
+                                            "clang-doc"
+                                            "clang-include-fixer"
+                                            "clang-move"
+                                            "clang-query"
+                                            "clang-reorder-fields"
+                                            "clang-tidy"
+                                            "find-all-symbols"
+                                            "modularize"
+                                            "pp-trace"))
+
+                                ;; Remove MiBs of .a files coming from
+                                ;; 'clang-tools-extra'.
+                                (for-each (lambda (component)
+                                            (delete-file
+                                             (string-append lib "/libclang"
+                                                            component ".a")))
+                                          '("ApplyReplacements"
+                                            "ChangeNamespace"
+                                            "Daemon"
+                                            "DaemonTweaks"
+                                            "Doc"
+                                            "IncludeFixer"
+                                            "IncludeFixerPlugin"
+                                            "Move"))
+                                (for-each delete-file
+                                          (find-files
+                                           lib
+                                           
"^(libfindAllSymbols|libclangTidy)"))
+                                #t))))
+                        '())
                   (add-after 'unpack 'add-missing-triplets
                     (lambda _
                       ;; Clang iterates through known triplets to search for
@@ -414,7 +487,15 @@ output), and Binutils.")
 (define-public clang-10
   (clang-from-llvm llvm-10 clang-runtime-10
                    "08fbxa2a0kr3ni35ckppj0kyvlcyaywrhpqwcdrdy0z900mhcnw8"
-                   #:patches '("clang-10.0-libc-search-path.patch")))
+                   #:patches '("clang-10.0-libc-search-path.patch")
+                   #:tools-extra
+                   (origin
+                     (method url-fetch)
+                     (uri (llvm-download-uri "clang-tools-extra"
+                                             (package-version llvm-10)))
+                     (sha256
+                      (base32
+                       
"074ija5s2jsdn0k035r2dzmryjmqxdnyg4xwvaqych2bazv8rpxc")))))
 
 (define-public clang-toolchain-10
   (make-clang-toolchain clang-10))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]