Archived
1
0
Fork 0

gnu: clang: Move version conditionals out of the builder.

* gnu/packages/llvm.scm (clang-from-llvm)[arguments]: Rewrite phase
'set-glibc-file-names' to use VERSION>=? from (guix utils) and splice in the
relevant build code, instead of doing the comparison at build time.
This commit is contained in:
Marius Bakke 2020-02-26 21:06:01 +01:00
parent f5cc5de8b6
commit 5041cc28cb
No known key found for this signature in database
GPG key ID: A2A06DF2A33A54FA

View file

@ -226,18 +226,14 @@ compiler. In LLVM this library is called \"compiler-rt\".")
(string-append "\"i686-unknown-linux-gnu\", " (string-append "\"i686-unknown-linux-gnu\", "
all))) all)))
#t)) #t))
(add-after (add-after 'unpack 'set-glibc-file-names
'unpack 'set-glibc-file-names
(lambda* (#:key inputs #:allow-other-keys) (lambda* (#:key inputs #:allow-other-keys)
(let ((libc (assoc-ref inputs "libc")) (let ((libc (assoc-ref inputs "libc"))
(compiler-rt (assoc-ref inputs "clang-runtime")) (compiler-rt (assoc-ref inputs "clang-runtime"))
(gcc (assoc-ref inputs "gcc")) (gcc (assoc-ref inputs "gcc")))
(version ,@(cond
(string->number ((version>=? version "6.0")
,(version-major (package-version clang-runtime))))) `(;; Link to libclang_rt files from clang-runtime.
(cond
((> version 3)
;; Link to libclang_rt files from clang-runtime.
(substitute* "lib/Driver/ToolChain.cpp" (substitute* "lib/Driver/ToolChain.cpp"
(("getDriver\\(\\)\\.ResourceDir") (("getDriver\\(\\)\\.ResourceDir")
(string-append "\"" compiler-rt "\""))) (string-append "\"" compiler-rt "\"")))
@ -252,14 +248,15 @@ compiler. In LLVM this library is called \"compiler-rt\".")
;; location. ;; location.
(("LibStdCXXIncludePathCandidates\\[\\] = \\{") (("LibStdCXXIncludePathCandidates\\[\\] = \\{")
(string-append (string-append
"LibStdCXXIncludePathCandidates[] = { \"" gcc "/include/c++\",")) "LibStdCXXIncludePathCandidates[] = { \"" gcc
"/include/c++\","))
;; Make sure libc's libdir is on the search path, to ;; Make sure libc's libdir is on the search path, to
;; allow crt1.o & co. to be found. ;; allow crt1.o & co. to be found.
(("@GLIBC_LIBDIR@") (("@GLIBC_LIBDIR@")
(string-append libc "/lib")))) (string-append libc "/lib")))))
(else (else
(substitute* "lib/Driver/Tools.cpp" `((substitute* "lib/Driver/Tools.cpp"
;; Patch the 'getLinuxDynamicLinker' function so that ;; Patch the 'getLinuxDynamicLinker' function so that
;; it uses the right dynamic linker file name. ;; it uses the right dynamic linker file name.
(("/lib64/ld-linux-x86-64.so.2") (("/lib64/ld-linux-x86-64.so.2")
@ -268,21 +265,19 @@ compiler. In LLVM this library is called \"compiler-rt\".")
;; Link to libclang_rt files from clang-runtime. ;; Link to libclang_rt files from clang-runtime.
;; This substitution needed slight adjustment in 3.8. ;; This substitution needed slight adjustment in 3.8.
(if (< 3.8 (string->number ,(version-major+minor ,@(if (version>=? version "3.8")
(package-version '((substitute* "lib/Driver/Tools.cpp"
clang-runtime))))
(substitute* "lib/Driver/Tools.cpp"
(("TC\\.getDriver\\(\\)\\.ResourceDir") (("TC\\.getDriver\\(\\)\\.ResourceDir")
(string-append "\"" compiler-rt "\"")))
(substitute* "lib/Driver/ToolChain.cpp"
(("getDriver\\(\\)\\.ResourceDir")
(string-append "\"" compiler-rt "\"")))) (string-append "\"" compiler-rt "\""))))
'((substitute* "lib/Driver/ToolChain.cpp"
(("getDriver\\(\\)\\.ResourceDir")
(string-append "\"" compiler-rt "\"")))))
;; Make sure libc's libdir is on the search path, to ;; Make sure libc's libdir is on the search path, to
;; allow crt1.o & co. to be found. ;; allow crt1.o & co. to be found.
(substitute* "lib/Driver/ToolChains.cpp" (substitute* "lib/Driver/ToolChains.cpp"
(("@GLIBC_LIBDIR@") (("@GLIBC_LIBDIR@")
(string-append libc "/lib"))))) (string-append libc "/lib"))))))
#t))) #t)))
(add-after 'install 'install-clean-up-/share/clang (add-after 'install 'install-clean-up-/share/clang
(lambda* (#:key outputs #:allow-other-keys) (lambda* (#:key outputs #:allow-other-keys)