mirror of
https://codeberg.org/guix/guix.git
synced 2025-10-02 02:15:12 +00: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 @@ compiler. In LLVM this library is called \"compiler-rt\".")
|
||||||
(supported-systems (delete "mips64el-linux" %supported-systems))))
|
(supported-systems (delete "mips64el-linux" %supported-systems))))
|
||||||
|
|
||||||
(define* (clang-from-llvm llvm clang-runtime hash
|
(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
|
(package
|
||||||
(name "clang")
|
(name "clang")
|
||||||
(version (package-version llvm))
|
(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
|
;; doesn't seem to be any way to do this with clang's autotools-based
|
||||||
;; build system.
|
;; build system.
|
||||||
(build-system cmake-build-system)
|
(build-system cmake-build-system)
|
||||||
|
(outputs (if tools-extra '("out" "extra") '("out")))
|
||||||
(native-inputs (package-native-inputs llvm))
|
(native-inputs (package-native-inputs llvm))
|
||||||
(inputs
|
(inputs
|
||||||
`(("libxml2" ,libxml2)
|
`(("libxml2" ,libxml2)
|
||||||
("gcc-lib" ,gcc "lib")
|
("gcc-lib" ,gcc "lib")
|
||||||
,@(package-inputs llvm)))
|
,@(package-inputs llvm)
|
||||||
|
,@(if tools-extra
|
||||||
|
`(("clang-tools-extra" ,tools-extra))
|
||||||
|
'())))
|
||||||
(propagated-inputs
|
(propagated-inputs
|
||||||
`(("llvm" ,llvm)
|
`(("llvm" ,llvm)
|
||||||
("clang-runtime" ,clang-runtime)))
|
("clang-runtime" ,clang-runtime)))
|
||||||
|
@ -243,6 +251,71 @@ compiler. In LLVM this library is called \"compiler-rt\".")
|
||||||
#:build-type "Release"
|
#:build-type "Release"
|
||||||
|
|
||||||
#:phases (modify-phases %standard-phases
|
#: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
|
(add-after 'unpack 'add-missing-triplets
|
||||||
(lambda _
|
(lambda _
|
||||||
;; Clang iterates through known triplets to search for
|
;; Clang iterates through known triplets to search for
|
||||||
|
@ -414,7 +487,15 @@ output), and Binutils.")
|
||||||
(define-public clang-10
|
(define-public clang-10
|
||||||
(clang-from-llvm llvm-10 clang-runtime-10
|
(clang-from-llvm llvm-10 clang-runtime-10
|
||||||
"08fbxa2a0kr3ni35ckppj0kyvlcyaywrhpqwcdrdy0z900mhcnw8"
|
"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
|
(define-public clang-toolchain-10
|
||||||
(make-clang-toolchain clang-10))
|
(make-clang-toolchain clang-10))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue