gnu: cling: Wrap with GCC include paths.

(cling) [phases] <patch-paths>: Do not patch CLING_CXX_RLTV anymore; this is
now handled more correctly by wrapping the 'cling' executable.  Adjust file
name of clang lib directory.  <wrap-with-include-paths, fix-wrapper>: New
phases.
[inputs]: Add gcc-toolchain*, a delayed version of gcc-toolchain, used in the
wrap phase.

Fixes: https://issues.guix.gnu.org/57116
Change-Id: I29f9eee8f4a0e91eadc2eeff2a70d58db3ed0a26
This commit is contained in:
Maxim Cournoyer 2024-09-22 01:10:02 +09:00
parent a48605f6e9
commit 41c8506330
No known key found for this signature in database
GPG key ID: 1260E46482E63562

View file

@ -2390,12 +2390,6 @@ (define-public cling
(substitute* "lib/Interpreter/CIFactory.cpp"
(("\\bsed\\b")
(which "sed"))
;; This ensures that the default C++ library used by Cling is
;; that of the compiler that was used to build it, rather
;; than that of whatever g++ happens to be on PATH.
(("ReadCompilerIncludePaths\\(CLING_CXX_RLTV")
(format #f "ReadCompilerIncludePaths(~s"
(search-input-file inputs "bin/g++")))
;; Cling uses libclang's CompilerInvocation::GetResourcesPath
;; to resolve Clang's library prefix, but this fails on Guix
;; because it is relative to the output of cling rather than
@ -2427,9 +2421,28 @@ (define-public cling
(add-after 'install 'delete-static-libraries
;; This reduces the size from 17 MiB to 5.4 MiB.
(lambda _
(for-each delete-file (find-files #$output "\\.a$")))))))
(for-each delete-file (find-files #$output "\\.a$"))))
(add-after 'install 'wrap-with-include-paths
;; Cling is sensitive to miss-matched include directives; ensure
;; the GCC includes used match that of the GCC used to build
;; Cling.
(lambda* (#:key inputs #:allow-other-keys)
(let ((gcc-toolchain #$(this-package-input "gcc-toolchain")))
(wrap-program (string-append #$output "/bin/cling")
`("C_INCLUDE_PATH" prefix
(,(string-append gcc-toolchain "/include")))
`("CPLUS_INCLUDE_PATH" prefix
(,(string-append gcc-toolchain "/include/c++")
,(string-append gcc-toolchain "/include")))))))
(add-after 'wrap-with-include-paths 'fix-wrapper
(lambda _
;; When -a $0 is used, the cling executable segfauts (see:
;; https://issues.guix.gnu.org/73405).
(substitute* (string-append #$output "/bin/cling")
(("\"\\$0\"")
"\"${0##*/}\"")))))))
(native-inputs (list python python-lit))
(inputs (list clang-cling llvm-cling libxcrypt))
(inputs (list clang-cling (force gcc-toolchain*) llvm-cling libxcrypt))
(home-page "https://root.cern/cling/")
(synopsis "Interactive C++ interpreter")
(description "Cling is an interactive C++17 standard compliant