diff options
Diffstat (limited to 'gnu/packages/cpp.scm')
-rw-r--r-- | gnu/packages/cpp.scm | 240 |
1 files changed, 227 insertions, 13 deletions
diff --git a/gnu/packages/cpp.scm b/gnu/packages/cpp.scm index 9520a164f1..3b10b89aaa 100644 --- a/gnu/packages/cpp.scm +++ b/gnu/packages/cpp.scm @@ -18,6 +18,11 @@ ;;; Copyright © 2020 Brett Gilio <brettg@gnu.org> ;;; Copyright © 2020 Milkey Mouse <milkeymouse@meme.institute> ;;; Copyright © 2021 Raghav Gururajan <rg@raghavgururajan.name> +;;; Copyright © 2021 Felix Gruber <felgru@posteo.net> +;;; Copyright © 2021 Nicolò Balzarotti <nicolo@nixo.xyz> +;;; Copyright © 2021 Guillaume Le Vaillant <glv@posteo.net> +;;; Copyright © 2021 Maxim Cournoyer <maxim.cournoyer@gmail.com> + ;;; ;;; This file is part of GNU Guix. ;;; @@ -40,6 +45,7 @@ #:use-module (guix download) #:use-module (guix utils) #:use-module (guix git-download) + #:use-module ((guix build utils) #:hide (delete)) #:use-module (guix build-system cmake) #:use-module (guix build-system gnu) #:use-module (guix build-system python) @@ -58,6 +64,7 @@ #:use-module (gnu packages documentation) #:use-module (gnu packages gcc) #:use-module (gnu packages libevent) + #:use-module (gnu packages libffi) #:use-module (gnu packages libunwind) #:use-module (gnu packages linux) #:use-module (gnu packages llvm) @@ -69,10 +76,12 @@ #:use-module (gnu packages pkg-config) #:use-module (gnu packages popt) #:use-module (gnu packages pretty-print) + #:use-module (gnu packages python) #:use-module (gnu packages pulseaudio) #:use-module (gnu packages tls) #:use-module (gnu packages web) - #:use-module (gnu packages xml)) + #:use-module (gnu packages xml) + #:use-module (srfi srfi-1)) (define-public range-v3 (package @@ -87,11 +96,13 @@ (commit version))) (file-name (git-file-name name version)) + (patches (search-patches "range-v3-build-with-gcc10.patch")) (sha256 (base32 "18230bg4rq9pmm5f8f65j444jpq56rld4fhmpham8q3vr1c1bdjh")))) (build-system cmake-build-system) (native-inputs `(("doxygen" ,doxygen) + ("gcc" ,gcc-9) ("perl" ,perl))) (inputs `(("boost" ,boost))) @@ -129,7 +140,8 @@ range-v3 ranges are an abstraction layer on top of iterators.") (git-file-name name version)) (patches (search-patches - "c++-gsl-find-system-gtest.patch")) + "c++-gsl-find-system-gtest.patch" + "c++-gsl-move-array-bounds-tests.patch")) (sha256 (base32 "0gbvr48f03830g3154bjhw92b8ggmg6wwh5xyb8nppk9v6w752l0")))) (build-system cmake-build-system) @@ -365,10 +377,8 @@ functions, class methods, and stl containers. (lambda* (#:key outputs #:allow-other-keys) (let* ((out (assoc-ref outputs "out")) (inc (string-append out "/include/fifo_map"))) - (with-directory-excursion - (string-append "../" ,name "-" ,version "-checkout") - (install-file "src/fifo_map.hpp" inc) - #t))))))) + (with-directory-excursion "../source" + (install-file "src/fifo_map.hpp" inc)))))))) (synopsis "FIFO-ordered associative container for C++") (description "Fifo_map is a C++ header only library for associative container which uses the order in which keys were inserted to the container @@ -703,7 +713,7 @@ code and retrieving their output.") (define-public sobjectizer (package (name "sobjectizer") - (version "5.6.1") + (version "5.7.2.6") (source (origin (method git-fetch) @@ -711,7 +721,7 @@ code and retrieving their output.") (url "https://github.com/Stiffstream/sobjectizer") (commit (string-append "v." version)))) (sha256 - (base32 "0jfai7sqxnnjkms38krm7mssj5l79nb3pllkbyj4j581a7l5j6l5")) + (base32 "0n6smpjkkkw0xab8wcpy3p0dpw2v9sxgwl6azl3am6abmv4mff12")) (file-name (git-file-name name version)))) (build-system cmake-build-system) (arguments @@ -759,7 +769,8 @@ other values of screen objects, by setting their values as the tween starting point and then, after each tween step, plugging back the result.") (license license:expat))) -(define-public abseil-cpp +;;; This older LTS release is kept for tensorflow. +(define-public abseil-cpp-20200923.3 (package (name "abseil-cpp") (version "20200923.3") @@ -772,11 +783,8 @@ point and then, after each tween step, plugging back the result.") (sha256 (base32 "1p4djhm1f011ficbjjxx3n8428p8481p20j4glpaawnpsi362hkl")) - ;; Remove after next googletest release and update. (patches - (search-patches - "abseil-cpp-fix-gtest.patch" - "abseil-cpp-fix-strerror_test.patch")))) + (search-patches "abseil-cpp-fix-strerror_test.patch")))) (build-system cmake-build-system) (arguments `(#:configure-flags (list "-DBUILD_SHARED_LIBS=ON" @@ -809,6 +817,26 @@ augment the C++ standard library. The Abseil library code is collected from Google's C++ code base.") (license license:asl2.0))) +(define-public abseil-cpp + (let ((base abseil-cpp-20200923.3)) + (package/inherit base + (name "abseil-cpp") + (version "20210324.2") + (source (origin + (method git-fetch) + (uri (git-reference + (url "https://github.com/abseil/abseil-cpp") + (commit version))) + (file-name (git-file-name name version)) + (sha256 + (base32 + "0g9rbhk3mwjdfxk7cscd04vm8fphd5flz9yykpgvyy1nwa34zk3x")))) + (arguments + (substitute-keyword-arguments (package-arguments base) + ((#:configure-flags flags) + `(cons* "-DBUILD_TESTING=ON" + (delete "-DABSL_RUN_TESTS=ON" ,flags)))))))) + (define-public pegtl (package (name "pegtl") @@ -1335,6 +1363,192 @@ of reading and writing XML.") ;; details. (license license:gpl2+))) +(define %cling-version "0.9") + +(define llvm-cling ;LLVM 9 with approximately 10 patches for cling + (let ((base llvm-9)) + (package/inherit base + (name "llvm-cling") + (source + (origin + (inherit (package-source base)) + (method git-fetch) + (uri (git-reference + (url "http://root.cern/git/llvm.git") + (commit (string-append "cling-v" %cling-version)))) + (file-name (git-file-name "llvm-cling" %cling-version)) + (sha256 + (base32 + "0y3iwv3c9152kybmdrwvadggjs163r25h7rmlxzr3hfpr463pnwf")) + (modules '((guix build utils))) + (snippet + ;; The source is missing an include directive (see: + ;; https://github.com/vgvassilev/cling/issues/219). + '(substitute* "utils/benchmark/src/benchmark_register.h" + (("^#include <vector>.*" all) + (string-append all "#include <limits>\n")))))) + (outputs '("out")) + (arguments + (substitute-keyword-arguments (package-arguments base) + ((#:configure-flags _ ''()) + '(list "-DLLVM_PARALLEL_LINK_JOBS=1" ;cater to smaller build machines + ;; Only enable compiler support for the host architecture to + ;; save on build time. + "-DLLVM_TARGETS_TO_BUILD=host;NVPTX" + "-DLLVM_INSTALL_UTILS=ON" + "-DLLVM_ENABLE_RTTI=ON" + "-DLLVM_ENABLE_FFI=ON" + "-DLLVM_BUILD_LLVM_DYLIB=ON" + "-DLLVM_LINK_LLVM_DYLIB=ON")) + ((#:phases phases '%standard-phases) + `(modify-phases ,phases + (delete 'shared-lib-workaround) + (delete 'install-opt-viewer)))))))) + +(define clang-cling-runtime + (let ((base clang-runtime-9)) + (package/inherit base + (name "clang-cling-runtime") + (arguments + (substitute-keyword-arguments (package-arguments base) + ((#:phases phases '%standard-phases) + `(modify-phases ,phases + (add-after 'install 'delete-static-libraries + ;; This reduces the size from 22 MiB to 4 MiB. + (lambda* (#:key outputs #:allow-other-keys) + (let ((out (assoc-ref outputs "out"))) + (for-each delete-file (find-files out "\\.a$"))))))))) + (inputs (alist-replace "llvm" `(,llvm-cling) + (package-inputs base)))))) + +(define clang-cling ;modified clang 9 with ~ 60 patches for cling + (let ((base clang-9)) + (package/inherit base + (name "clang-cling") + (source + (origin + (inherit (package-source base)) + (method git-fetch) + (uri (git-reference + (url "http://root.cern/git/clang.git") + (commit (string-append "cling-v" %cling-version)))) + (file-name (git-file-name "clang-cling" %cling-version)) + (sha256 + (base32 + "128mxkwghss6589wvm6amzv183aq88rdrnfxjiyjcji5hx84vpby")))) + (arguments + (substitute-keyword-arguments (package-arguments base) + ((#:phases phases '%standard-phases) + `(modify-phases ,phases + (add-after 'install 'delete-static-libraries + ;; This reduces the size by half, from 220 MiB to 112 MiB. + (lambda* (#:key outputs #:allow-other-keys) + (let ((out (assoc-ref outputs "out"))) + (for-each delete-file (find-files out "\\.a$"))))))))) + (propagated-inputs (fold alist-replace + (package-propagated-inputs base) + '("llvm" "clang-runtime") + `((,llvm-cling) (,clang-cling-runtime))))))) + +(define-public cling + ;; The tagged v0.9 release doesn't build, so use the latest commit. + (let ((commit "d78d1a03fedfd2bf6d2b6ff295aca576d98940df") + (revision "1") + (version* "0.9")) + (package + (name "cling") + (version (git-version version* revision commit)) + (source (origin + (method git-fetch) + (uri (git-reference + (url "http://root.cern/git/cling.git") + (commit commit))) + (file-name (git-file-name name version)) + (sha256 + (base32 + "0lsbxv21b4qw11xkw9iipdpca64jjwwqxm0qf5v2cgdlibf8m8n9")) + ;; Patch submitted upstream here: + ;; https://github.com/root-project/cling/pull/433. + (patches (search-patches "cling-use-shared-library.patch")))) + (build-system cmake-build-system) + (arguments + `(#:build-type "Release" ;keep the build as lean as possible + #:tests? #f ;FIXME: 78 tests fail (out of ~200) + #:test-target "check-cling" + #:configure-flags + (list (string-append "-DCLING_CXX_PATH=" + (assoc-ref %build-inputs "gcc") "/bin/g++") + ;; XXX: The AddLLVM.cmake module expects LLVM_EXTERNAL_LIT to + ;; be a Python script, not a shell executable. + (string-append "-DLLVM_EXTERNAL_LIT=" + (assoc-ref %build-inputs "python-lit") + "/bin/.lit-real")) + #:phases + (modify-phases %standard-phases + (add-after 'unpack 'set-version + (lambda _ + (make-file-writable "VERSION") + (call-with-output-file "VERSION" + (lambda (port) + (format port "~a~%" ,version))))) + (add-after 'unpack 'patch-paths + (lambda* (#:key inputs #:allow-other-keys) + (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") + (string-append "ReadCompilerIncludePaths(\"" + (assoc-ref inputs "gcc") "/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 + ;; clang (see: + ;; https://github.com/root-project/cling/issues/434). Fully + ;; shortcut the logic in this method to return the correct + ;; static location. + (("static std::string getResourceDir.*" all) + (string-append all + " return std::string(\"" + (assoc-ref inputs "clang-cling") + "/lib/clang/" ,(package-version clang-cling) + "\");"))) + ;; Check for the 'lit' command for the tests, not 'lit.py' + ;; (see: https://github.com/root-project/cling/issues/432). + (substitute* "CMakeLists.txt" + (("lit.py") + "lit")))) + (add-after 'unpack 'adjust-lit.cfg + ;; See: https://github.com/root-project/cling/issues/435. + (lambda _ + (substitute* "test/lit.cfg" + (("config.llvm_tools_dir \\+ '") + "config.cling_obj_root + '/bin")))) + (add-after 'install 'delete-static-libraries + ;; This reduces the size from 17 MiB to 5.4 MiB. + (lambda* (#:key outputs #:allow-other-keys) + (let ((out (assoc-ref outputs "out"))) + (for-each delete-file (find-files out "\\.a$")))))))) + (native-inputs + `(("python" ,python) + ("python-lit" ,python-lit))) + (inputs + `(("clang-cling" ,clang-cling) + ("llvm-cling" ,llvm-cling))) + (home-page "https://root.cern/cling/") + (synopsis "Interactive C++ interpreter") + (description "Cling is an interactive C++17 standard compliant +interpreter, built on top of LLVM and Clang. Cling can be used as a +read-eval-print loop (REPL) to assist with rapid application development. +Here's how to print @samp{\"Hello World!\"} using @command{cling}: + +@example +cling '#include <stdio.h>' 'printf(\"Hello World!\\n\");' +@end example") + (license license:lgpl2.1+)))) ;for the combined work + (define-public jsonnet (package (name "jsonnet") |