mirror of
https://git.in.rschanz.org/ryan77627/guix.git
synced 2025-01-11 13:49:23 -05:00
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.
This commit is contained in:
parent
ccd9107ed9
commit
77a87ad4ac
1 changed files with 84 additions and 3 deletions
|
@ -201,7 +201,11 @@ (define* (clang-runtime-from-llvm llvm hash
|
|||
(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 @@ (define* (clang-from-llvm llvm clang-runtime hash
|
|||
;; 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 @@ (define* (clang-from-llvm llvm clang-runtime hash
|
|||
#: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 @@ (define-public clang-runtime-10
|
|||
(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))
|
||||
|
|
Loading…
Reference in a new issue