me
/
guix
Archived
1
0
Fork 0

gnu: cling: Use gexps.

* gnu/packages/llvm.scm (cling)[configure-flags]: Use gexps and search-input-file.
[phases]: Likewise.
{patch-paths}: Use search-input-file and this-package-input.
{delete-static-libraries}: Adjust for gexps.
master
Maxim Cournoyer 2022-09-02 23:52:40 -04:00
parent 34766a6631
commit ccba460ffd
No known key found for this signature in database
GPG Key ID: 1260E46482E63562
1 changed files with 59 additions and 60 deletions

View File

@ -21,7 +21,7 @@
;;; Copyright © 2021 Julien Lepiller <julien@lepiller.eu> ;;; Copyright © 2021 Julien Lepiller <julien@lepiller.eu>
;;; Copyright © 2021 Lars-Dominik Braun <lars@6xq.net> ;;; Copyright © 2021 Lars-Dominik Braun <lars@6xq.net>
;;; Copyright © 2021, 2022 Guillaume Le Vaillant <glv@posteo.net> ;;; Copyright © 2021, 2022 Guillaume Le Vaillant <glv@posteo.net>
;;; Copyright © 2021 Maxim Cournoyer <maxim.cournoyer@gmail.com> ;;; Copyright © 2021, 2022 Maxim Cournoyer <maxim.cournoyer@gmail.com>
;;; Copyright © 2022 Greg Hogan <code@greghogan.com> ;;; Copyright © 2022 Greg Hogan <code@greghogan.com>
;;; Copyright © 2022 John Kehayias <john.kehayias@protonmail.com> ;;; Copyright © 2022 John Kehayias <john.kehayias@protonmail.com>
;;; Copyright © 2022 Clément Lassieur <clement@lassieur.org> ;;; Copyright © 2022 Clément Lassieur <clement@lassieur.org>
@ -2158,65 +2158,64 @@ LLVM."))))
(patches (search-patches "cling-use-shared-library.patch")))) (patches (search-patches "cling-use-shared-library.patch"))))
(build-system cmake-build-system) (build-system cmake-build-system)
(arguments (arguments
`(#:build-type "Release" ;keep the build as lean as possible (list
#:tests? #f ;FIXME: 78 tests fail (out of ~200) #:build-type "Release" ;keep the build as lean as possible
#:test-target "check-cling" #:tests? #f ;FIXME: 78 tests fail (out of ~200)
#:configure-flags #:test-target "check-cling"
(list (string-append "-DCLING_CXX_PATH=" #:configure-flags
(assoc-ref %build-inputs "gcc") "/bin/g++") #~(list (string-append "-DCLING_CXX_PATH="
;; XXX: The AddLLVM.cmake module expects LLVM_EXTERNAL_LIT to (search-input-file %build-inputs "bin/g++"))
;; be a Python script, not a shell executable. ;; XXX: The AddLLVM.cmake module expects LLVM_EXTERNAL_LIT to
(string-append "-DLLVM_EXTERNAL_LIT=" ;; be a Python script, not a shell executable.
(assoc-ref %build-inputs "python-lit") (string-append "-DLLVM_EXTERNAL_LIT="
"/bin/.lit-real")) (search-input-file %build-inputs "bin/.lit-real")))
#:phases #:phases
(modify-phases %standard-phases #~(modify-phases %standard-phases
(add-after 'unpack 'set-version (add-after 'unpack 'set-version
(lambda _ (lambda _
(make-file-writable "VERSION") (make-file-writable "VERSION")
(call-with-output-file "VERSION" (call-with-output-file "VERSION"
(lambda (port) (lambda (port)
(format port "~a~%" ,version))))) (format port "~a~%" #$version)))))
(add-after 'unpack 'patch-paths (add-after 'unpack 'patch-paths
(lambda* (#:key inputs #:allow-other-keys) (lambda* (#:key inputs #:allow-other-keys)
(substitute* "lib/Interpreter/CIFactory.cpp" (substitute* "lib/Interpreter/CIFactory.cpp"
(("\bsed\b") (("\bsed\b")
(which "sed")) (which "sed"))
;; This ensures that the default C++ library used by Cling is ;; This ensures that the default C++ library used by Cling is
;; that of the compiler that was used to build it, rather ;; that of the compiler that was used to build it, rather
;; than that of whatever g++ happens to be on PATH. ;; than that of whatever g++ happens to be on PATH.
(("ReadCompilerIncludePaths\\(CLING_CXX_RLTV") (("ReadCompilerIncludePaths\\(CLING_CXX_RLTV")
(string-append "ReadCompilerIncludePaths(\"" (format #f "ReadCompilerIncludePaths(~s"
(assoc-ref inputs "gcc") "/bin/g++\"")) (search-input-file inputs "bin/g++")))
;; Cling uses libclang's CompilerInvocation::GetResourcesPath ;; Cling uses libclang's CompilerInvocation::GetResourcesPath
;; to resolve Clang's library prefix, but this fails on Guix ;; to resolve Clang's library prefix, but this fails on Guix
;; because it is relative to the output of cling rather than ;; because it is relative to the output of cling rather than
;; clang (see: ;; clang (see:
;; https://github.com/root-project/cling/issues/434). Fully ;; https://github.com/root-project/cling/issues/434). Fully
;; shortcut the logic in this method to return the correct ;; shortcut the logic in this method to return the correct
;; static location. ;; static location.
(("static std::string getResourceDir.*" all) (("static std::string getResourceDir.*" all)
(string-append all (string-append all
" return std::string(\"" " return std::string(\""
(assoc-ref inputs "clang-cling") #$(this-package-input "clang-cling")
"/lib/clang/" ,(package-version clang-cling) "/lib/clang/" #$(package-version clang-cling)
"\");"))) "\");")))
;; Check for the 'lit' command for the tests, not 'lit.py' ;; Check for the 'lit' command for the tests, not 'lit.py'
;; (see: https://github.com/root-project/cling/issues/432). ;; (see: https://github.com/root-project/cling/issues/432).
(substitute* "CMakeLists.txt" (substitute* "CMakeLists.txt"
(("lit.py") (("lit.py")
"lit")))) "lit"))))
(add-after 'unpack 'adjust-lit.cfg (add-after 'unpack 'adjust-lit.cfg
;; See: https://github.com/root-project/cling/issues/435. ;; See: https://github.com/root-project/cling/issues/435.
(lambda _ (lambda _
(substitute* "test/lit.cfg" (substitute* "test/lit.cfg"
(("config.llvm_tools_dir \\+ '") (("config.llvm_tools_dir \\+ '")
"config.cling_obj_root + '/bin")))) "config.cling_obj_root + '/bin"))))
(add-after 'install 'delete-static-libraries (add-after 'install 'delete-static-libraries
;; This reduces the size from 17 MiB to 5.4 MiB. ;; This reduces the size from 17 MiB to 5.4 MiB.
(lambda* (#:key outputs #:allow-other-keys) (lambda _
(let ((out (assoc-ref outputs "out"))) (for-each delete-file (find-files #$output "\\.a$")))))))
(for-each delete-file (find-files out "\\.a$"))))))))
(native-inputs (native-inputs
(list python python-lit)) (list python python-lit))
(inputs (inputs