Hello,
Liliana Marie Prikler <liliana.prikler@ist.tugraz.at> writes:
Toggle quote (5 lines)
> Am Dienstag, dem 09.08.2022 um 15:32 -0700 schrieb Gang Liang:
>> I had a fresh installation of cling from guix, and got the following
>> error. Seems some system headers are missing.
> You probably need gcc-toolchain installed alongside cling.
Indeed:
$ guix shell --pure cling -- cling '#include <iostream>'
In file included from input_line_3:1:
In file included from /gnu/store/069aq2v993kpc41yabp5b6vm4wb9jkhg-gcc-10.3.0/include/c++/iostream:39:
In file included from /gnu/store/069aq2v993kpc41yabp5b6vm4wb9jkhg-gcc-10.3.0/include/c++/ostream:38:
In file included from /gnu/store/069aq2v993kpc41yabp5b6vm4wb9jkhg-gcc-10.3.0/include/c++/ios:42:
In file included from /gnu/store/069aq2v993kpc41yabp5b6vm4wb9jkhg-gcc-10.3.0/include/c++/bits/ios_base.h:41:
In file included from /gnu/store/069aq2v993kpc41yabp5b6vm4wb9jkhg-gcc-10.3.0/include/c++/bits/locale_classes.h:40:
In file included from /gnu/store/069aq2v993kpc41yabp5b6vm4wb9jkhg-gcc-10.3.0/include/c++/string:55:
In file included from /gnu/store/069aq2v993kpc41yabp5b6vm4wb9jkhg-gcc-10.3.0/include/c++/bits/basic_string.h:6545:
In file included from /gnu/store/069aq2v993kpc41yabp5b6vm4wb9jkhg-gcc-10.3.0/include/c++/ext/string_conversions.h:44:
In file included from /gnu/store/069aq2v993kpc41yabp5b6vm4wb9jkhg-gcc-10.3.0/include/c++/cerrno:42:
In file included from /gnu/store/5h2w4qi9hk1qzzgi1w83220ydslinr4s-glibc-2.33/include/errno.h:28:
/gnu/store/5h2w4qi9hk1qzzgi1w83220ydslinr4s-glibc-2.33/include/bits/errno.h:26:11: fatal error: 'linux/errno.h' file not found
# include <linux/errno.h>
^~~~~~~~~~~~~~~
But:
$ guix shell --pure cling gcc-toolchain -- cling '#include <iostream>'
runs fine.
I tried this:
Toggle snippet (44 lines)
modified gnu/packages/llvm.scm
@@ -79,6 +79,12 @@ (define-module (gnu packages llvm)
#:export (make-lld-wrapper
system->llvm-target))
+;;; Lazily resolve to avoid top-level cycles between modules.
+(define gcc-toolchain*
+ (delay (module-ref (resolve-interface '(gnu packages commencement))
+ 'gcc-toolchain)))
+
+
(define* (system->llvm-target #:optional
(system (or (and=> (%current-target-system)
gnu-triplet->nix-system)
@@ -2215,11 +2221,25 @@ (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-cling
+ ;; Wrap the 'cling' command so that it can locate the GCC
+ ;; toolchain provided headers. Use 'suffix so as to allow users
+ ;; to override which headers are used.
+ (lambda* (#:key outputs #:allow-other-keys)
+ (define gcc-toolchain #$(this-package-input "gcc-toolchain"))
+ (wrap-program (search-input-file outputs "bin/cling")
+ `("C_INCLUDE_PATH" suffix
+ (,(string-append gcc-toolchain "/include")))
+ `("CPLUS_INCLUDE_PATH" suffix
+ (,(string-append gcc-toolchain "/include/c++")
+ ,(string-append gcc-toolchain "/include")))
+ `("LIBRARY_PATH" suffix
+ (,(string-append gcc-toolchain "/lib")))))))))
(native-inputs
(list python python-lit))
(inputs
- (list clang-cling llvm-cling))
+ (list clang-cling (force gcc-toolchain*) llvm-cling))
(home-page "https://root.cern/cling/")
(synopsis "Interactive C++ interpreter")
(description "Cling is an interactive C++17 standard compliant
Toggle snippet (9 lines)
/gnu/store/lpwfmh4v2w2qbpdmmva0si32c9havn95-llvm-cling-9.0.1/lib/libLLVM-9.so(_ZN4llvm3sys15PrintStackTraceERNS_11raw_ostreamE+0x1a)[0x7f76e20ea81a]
/gnu/store/lpwfmh4v2w2qbpdmmva0si32c9havn95-llvm-cling-9.0.1/lib/libLLVM-9.so(_ZN4llvm3sys17RunSignalHandlersEv+0x34)[0x7f76e20e8894]
/gnu/store/lpwfmh4v2w2qbpdmmva0si32c9havn95-llvm-cling-9.0.1/lib/libLLVM-9.so(+0x7129c2)[0x7f76e20e89c2]
/gnu/store/5h2w4qi9hk1qzzgi1w83220ydslinr4s-glibc-2.33/lib/libpthread.so.0(+0x11d80)[0x7f76e6c3fd80]
/gnu/store/094bbaq6glba86h1d4cj16xhdi6fk2jl-gcc-10.3.0-lib/lib/libstdc++.so.6(_ZTVN10__cxxabiv120__si_class_type_infoE+0x10)[0x7f76e19c0c78]
Stack dump:
0. Program arguments: /gnu/store/x48h88ckmkk5vh9g36d2cnmhw23x9ql5-profile/bin/cling #include <iostream>
I'm not sure why.
Should we close it as 'notabug', or persist with the attempt to wrap the
cling binary with the include paths required to ease its setup?
Thanks,
Maxim