Merge branch 'master' into core-updates-frozen
[jackhill/guix/guix.git] / gnu / packages / llvm.scm
index b510f31..7cfa02e 100644 (file)
@@ -1,13 +1,13 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2014, 2016, 2018 Eric Bavier <bavier@member.fsf.org>
 ;;; Copyright © 2015 Mark H Weaver <mhw@netris.org>
-;;; Copyright © 2015, 2017, 2018, 2019, 2020 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2015, 2017, 2018, 2019, 2020, 2021 Ludovic Courtès <ludo@gnu.org>
 ;;; Copyright © 2016 Dennis Mungai <dmngaie@gmail.com>
 ;;; Copyright © 2016, 2018, 2019, 2020, 2021 Ricardo Wurmus <rekado@elephly.net>
 ;;; Copyright © 2017 Roel Janssen <roel@gnu.org>
 ;;; Copyright © 2018, 2019, 2020 Marius Bakke <mbakke@fastmail.com>
 ;;; Copyright © 2018, 2019 Tobias Geerinckx-Rice <me@tobias.gr>
-;;; Copyright © 2018 Efraim Flashner <efraim@flashner.co.il>
+;;; Copyright © 2018, 2021 Efraim Flashner <efraim@flashner.co.il>
 ;;; Copyright © 2018 Tim Gesthuizen <tim.gesthuizen@yahoo.de>
 ;;; Copyright © 2018 Pierre Neidhardt <mail@ambrevar.xyz>
 ;;; Copyright © 2019 Rutger Helling <rhelling@mykolab.com>
@@ -18,6 +18,7 @@
 ;;; Copyright © 2020 Jakub Kądziołka <kuba@kadziolka.net>
 ;;; Copyright © 2020 Maxim Cournoyer <maxim.cournoyer@gmail.com>
 ;;; Copyright © 2021 Julien Lepiller <julien@lepiller.eu>
+;;; Copyright © 2021 Lars-Dominik Braun <lars@6xq.net>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -490,7 +491,7 @@ output), and Binutils.")
     (build-system cmake-build-system)
     (outputs '("out" "opt-viewer"))
     (native-inputs
-     `(("python" ,python)
+     `(("python" ,python-wrapper)
        ("perl"   ,perl)))
     (inputs
      `(("libffi" ,libffi)))
@@ -571,11 +572,7 @@ of programming tools as well as libraries with equivalent functionality.")
       (uri (llvm-uri "llvm" version))
       (sha256
        (base32
-        "0s94lwil98w7zb7cjrbnxli0z7gklb312pkw74xs1d6zk346hgwi"))))
-    (native-inputs
-     `(;; TODO: Switch to Python 3 in the next rebuild cycle.
-       ("python" ,python-2)
-       ("perl"   ,perl)))))
+        "0s94lwil98w7zb7cjrbnxli0z7gklb312pkw74xs1d6zk346hgwi"))))))
 
 (define-public clang-runtime-11
   (clang-runtime-from-llvm
@@ -601,23 +598,23 @@ of programming tools as well as libraries with equivalent functionality.")
 (define-public llvm-10
   (package
     (inherit llvm-11)
-    (version "10.0.0")
+    (version "10.0.1")
     (source
      (origin
       (method url-fetch)
       (uri (llvm-uri "llvm" version))
       (sha256
        (base32
-        "1pwgm6cr0xr5a0hrbqs1zvsvvjvy0yq1y47c96804wcs795s90yz"))))))
+        "1wydhbp9kyjp5y0rc627imxgkgqiv3dfirbqil9dgpnbaw5y7n65"))))))
 
 (define-public clang-runtime-10
   (clang-runtime-from-llvm
    llvm-10
-   "0x9c531k6ww21s2mkdwqx1vbdjmx6d4wmfb8gdbj0wqa796sczba"))
+   "1yjqjri753w0fzmxcyz687nvd97sbc9rsqrxzpq720na47hwh3fr"))
 
 (define-public clang-10
   (clang-from-llvm llvm-10 clang-runtime-10
-                   "08fbxa2a0kr3ni35ckppj0kyvlcyaywrhpqwcdrdy0z900mhcnw8"
+                   "091bvcny2lh32zy8f3m9viayyhb2zannrndni7325rl85cwgr6pr"
                    #:patches '("clang-10.0-libc-search-path.patch")
                    #:tools-extra
                    (origin
@@ -626,7 +623,7 @@ of programming tools as well as libraries with equivalent functionality.")
                                              (package-version llvm-10)))
                      (sha256
                       (base32
-                       "074ija5s2jsdn0k035r2dzmryjmqxdnyg4xwvaqych2bazv8rpxc")))))
+                       "06n1yp638rh24xdxv9v2df0qajxbjz4w59b7dd4ky36drwmpi4yh")))))
 
 (define-public clang-toolchain-10
   (make-clang-toolchain clang-10))
@@ -690,23 +687,23 @@ of programming tools as well as libraries with equivalent functionality.")
 (define-public llvm-7
   (package
     (inherit llvm-8)
-    (version "7.0.1")
+    (version "7.1.0")
     (source (origin
               (method url-fetch)
               (uri (llvm-uri "llvm" version))
               (sha256
                (base32
-                "16s196wqzdw4pmri15hadzqgdi926zln3an2viwyq0kini6zr3d3"))))))
+                "0r1p5didv4rkgxyvbkyz671xddg6i3dxvbpsi1xxipkla0l9pk0v"))))))
 
 (define-public clang-runtime-7
   (clang-runtime-from-llvm
    llvm-7
-   "065ybd8fsc4h2hikbdyricj6pyv4r7r7kpcikhb2y5zf370xybkq"
+   "1n48p8gjarihkws0i2bay5w9bdwyxyxxbpwyng7ba58jb30dlyq5"
    '("clang-runtime-9-libsanitizer-mode-field.patch")))
 
 (define-public clang-7
   (clang-from-llvm llvm-7 clang-runtime-7
-                   "067lwggnbg0w1dfrps790r5l6k8n5zwhlsw7zb6zvmfpwpfn4nx4"
+                   "0vc4i87qwxnw9lci4ayws9spakg0z6w5w670snj9f8g5m9rc8zg9"
                    #:patches '("clang-7.0-libc-search-path.patch")))
 
 (define-public clang-toolchain-7
@@ -859,14 +856,13 @@ of programming tools as well as libraries with equivalent functionality.")
              (add-after 'unpack 'find-rpc-includes
                (lambda* (#:key inputs #:allow-other-keys)
                  (setenv "CPATH"
-                         (string-append (assoc-ref inputs "libtirpc")
-                                        "/include/tirpc/:"
-                                        (or (getenv "CPATH") "")))
+                         (string-append
+                          (search-input-directory inputs "/include/tirpc")
+                          ":" (or (getenv "CPATH") "")))
                  (setenv "CPLUS_INCLUDE_PATH"
-                         (string-append (assoc-ref inputs "libtirpc")
-                                        "/include/tirpc/:"
-                                        (or (getenv "CPLUS_INCLUDE_PATH") "")))
-                 #t))))))
+                         (string-append
+                          (search-input-directory inputs "/include/tirpc")
+                          ":" (or (getenv "CPLUS_INCLUDE_PATH") "")))))))))
       (inputs
        `(("libtirpc" ,libtirpc)
          ("llvm" ,llvm-3.5))))))
@@ -882,6 +878,43 @@ of programming tools as well as libraries with equivalent functionality.")
 (define-public clang clang-9)
 (define-public clang-toolchain clang-toolchain-9)
 
+(define-public llvm-for-rocm
+  (package
+    ;; Actually based on LLVM 13 as of v4.3, but llvm-12 works just fine.
+    (inherit llvm-12)
+    (name "llvm-for-rocm")
+    (version "4.3.0")                         ;this must match '%rocm-version'
+    (source (origin
+              (method git-fetch)
+              (uri (git-reference
+                    (url "https://github.com/RadeonOpenCompute/llvm-project.git")
+                    (commit (string-append "rocm-" version))))
+              (file-name (git-file-name name version))
+              (sha256
+               (base32
+                "0p75nr1qpmy6crymdax5hm40wkimman4lnglz4x5cnbiqindya7s"))
+              (patches
+               (search-patches "llvm-roc-4.2.0-add_Object.patch"
+                               "llvm-roc-3.0.0-add_libraries.patch"
+                               "llvm-roc-4.0.0-remove-isystem-usr-include.patch"))))
+    (arguments
+     (substitute-keyword-arguments (package-arguments llvm-12)
+       ((#:phases phases '%standard-phases)
+        `(modify-phases ,phases
+           (add-after 'unpack 'chdir
+             (lambda _
+               (chdir "llvm")))))
+       ((#:configure-flags flags)
+        ''("-DLLVM_ENABLE_PROJECTS=llvm;clang;lld"
+           "-DLLVM_TARGETS_TO_BUILD=AMDGPU;X86"
+           "-DCMAKE_SKIP_BUILD_RPATH=FALSE"
+           "-DCMAKE_BUILD_WITH_INSTALL_RPATH=FALSE"
+           "-DBUILD_SHARED_LIBS:BOOL=TRUE"
+           "-DLLVM_VERSION_SUFFIX="))))
+    (properties `((hidden? . #t)
+                  ,@(package-properties llvm-12)))))
+
+\f
 (define-public lld
   (package
     (name "lld")
@@ -1258,6 +1291,45 @@ with that of libgomp, the GNU Offloading and Multi Processing Library.")
      "This package provides a Python binding to LLVM for use in Numba.")
     (license license:bsd-3)))
 
+(define-public (clang-python-bindings clang)
+  "Return a package for the Python bindings of CLANG."
+  (package
+    (inherit clang)
+    (name "python-clang")
+    (build-system python-build-system)
+    (outputs '("out"))
+    (arguments
+     '(#:phases (modify-phases %standard-phases
+                  (add-before 'build 'change-directory
+                    (lambda _
+                      (chdir "bindings/python")))
+                  (add-before 'build 'create-setup-py
+                    (lambda _
+                      ;; Generate a basic "setup.py", enough so it can be
+                      ;; built and installed.
+                      (with-output-to-file "setup.py"
+                        (lambda ()
+                          (display "from setuptools import setup
+setup(name=\"clang\", packages=[\"clang\"])\n")))))
+                  (add-before 'build 'set-libclang-file-name
+                    (lambda* (#:key inputs #:allow-other-keys)
+                      ;; Record the absolute file name of libclang.so.
+                      (let ((clang (assoc-ref inputs "clang")))
+                        (substitute* "clang/cindex.py"
+                          (("libclang\\.so")
+                           (string-append clang "/lib/libclang.so")))))))))
+    (inputs `(("clang" ,clang)))
+    (synopsis "Python bindings to libclang")))
+
+(define-public python-clang-10
+  (clang-python-bindings clang-10))
+
+(define-public python-clang-11
+  (clang-python-bindings clang-11))
+
+(define-public python-clang-12
+  (clang-python-bindings clang-12))
+
 (define-public emacs-clang-format
   (package
     (inherit clang)