summaryrefslogtreecommitdiff
path: root/gnu/packages/llvm.scm
diff options
context:
space:
mode:
authorJean-Baptiste Note <jean-baptiste.note@m4x.org>2025-09-25 16:15:47 +0200
committerRutherther <rutherther@ditigal.xyz>2026-01-25 21:23:27 +0100
commita6306eb0bcb7fa19a830830691573aeb15483641 (patch)
treeceff5f78169634e584f27027a5e9e66d7b1dbb17 /gnu/packages/llvm.scm
parenta43d32577de300113f25577f27a9c002b69757b5 (diff)
gnu: Bump rocm to version 7.1.0
* gnu/packages/llvm.scm (%rocm-llvm-version): New variable. (make-llvm-rocm): New procedure. (llvm-rocm): New variable. (make-clang-runtime-rocm): New procedure. (clang-runtime-rocm): New variable. (make-clang-rocm): New procedure. (clang-rocm): New variable. (rocm-device-libs): New variable. (rocm-comgr): New variable. (rocm-hipcc): New variable. (make-lld-rocm): New procedure. (lld-rocm): New variable. * gnu/packages/rocm.scm: Add perl to imports. (%rocm-version): Update to 7.1.0. (%rocm-systems-url, %rocm-systems-origin): New variables. (rocr-runtime): Use %rocm-systems-origin and update build. (rocm-opencl-runtime): Use %rocm-systems-origin and update build. (rocm-hip-runtime): New variable. (rocminfo): Use %rocm-systems-origin and update build. (%default-amdgpu-targets, %default-amdgpu-targets-property): New variables. (%amdgpu-targets): New syntax. (rocm-bandwidth-test): Update and add comprehensive build support. * gnu/local.mk: Add rocm-bandwidth-test patches. * gnu/packages/patches/rocm-bandwidth-test-fix-external-packages-search.patch, gnu/packages/patches/rocm-bandwidth-test-fix-hsa-include-file-lookup.patch, gnu/packages/patches/rocm-bandwidth-test-take-default-gpus-from-environment.patch: New files. * gnu/packages/patches/rocclr-5.6.0-enable-gfx800.patch, gnu/packages/patches/rocm-opencl-runtime-4.3-noclinfo.patch: Update patch paths. Change-Id: I43f162b9f8ab898e25d8ecbe4ea30be84a29eb0d Signed-off-by: Ludovic Courtès <ludo@gnu.org> Signed-off-by: Rutherther <rutherther@ditigal.xyz>
Diffstat (limited to 'gnu/packages/llvm.scm')
-rw-r--r--gnu/packages/llvm.scm306
1 files changed, 285 insertions, 21 deletions
diff --git a/gnu/packages/llvm.scm b/gnu/packages/llvm.scm
index 44d5478346d..5ae9f19f0b4 100644
--- a/gnu/packages/llvm.scm
+++ b/gnu/packages/llvm.scm
@@ -67,6 +67,7 @@
67 #:use-module (gnu packages autotools) 67 #:use-module (gnu packages autotools)
68 #:use-module (gnu packages base) 68 #:use-module (gnu packages base)
69 #:use-module (gnu packages cmake) 69 #:use-module (gnu packages cmake)
70 #:use-module (gnu packages bash)
70 #:use-module (gnu packages crypto) 71 #:use-module (gnu packages crypto)
71 #:use-module (gnu packages gcc) 72 #:use-module (gnu packages gcc)
72 #:use-module (gnu packages bootstrap) ;glibc-dynamic-linker 73 #:use-module (gnu packages bootstrap) ;glibc-dynamic-linker
@@ -86,6 +87,7 @@
86 #:use-module (gnu packages pkg-config) 87 #:use-module (gnu packages pkg-config)
87 #:use-module (gnu packages python) 88 #:use-module (gnu packages python)
88 #:use-module (gnu packages python-build) 89 #:use-module (gnu packages python-build)
90 #:use-module (gnu packages rocm)
89 #:use-module (gnu packages swig) 91 #:use-module (gnu packages swig)
90 #:use-module (gnu packages vulkan) 92 #:use-module (gnu packages vulkan)
91 #:use-module (gnu packages xml) 93 #:use-module (gnu packages xml)
@@ -1283,40 +1285,282 @@ Library.")
1283(define-public clang clang-13) 1285(define-public clang clang-13)
1284(define-public clang-toolchain clang-toolchain-13) 1286(define-public clang-toolchain clang-toolchain-13)
1285 1287
1286(define-public llvm-for-rocm 1288
1289
1290;; ROCm compiler infrastructure elements are compiled from a monorepo at
1291;; https://github.com/ROCm/llvm-project. Due to some of these parts
1292;; referencing both a common origin and llvm helpers (in particular related to
1293;; patches and base packages). Other ROCm elements are part of rocm.scm
1294
1295;; This must match '%rocm-version' in rocm.scm. They cannot be shared because
1296;; toplevel variables cannot be called from one file to another.
1297(define %rocm-llvm-version "7.1.0")
1298
1299(define (make-llvm-rocm llvm-base)
1287 (package 1300 (package
1288 ;; Currently based on LLVM 19. 1301 (inherit llvm-base)
1289 (inherit llvm-19) 1302 ;; XXX A lot of llvm package phases are dependent on llvm version. Are
1290 (name "llvm-for-rocm") 1303 ;; these resolved early, so that we can override the package version easily?
1291 (version "6.4.2") ;this must match '%rocm-version' 1304 (version %rocm-llvm-version)
1305 (name "llvm-rocm")
1292 (source (origin 1306 (source (origin
1293 (method git-fetch) 1307 (method git-fetch)
1294 (uri (git-reference 1308 (uri (git-reference
1295 (url "https://github.com/ROCm/llvm-project.git") 1309 (url "https://github.com/ROCm/llvm-project")
1296 (commit (string-append "rocm-" version)))) 1310 (commit (string-append "rocm-" %rocm-llvm-version))))
1297 (file-name (git-file-name name version)) 1311 (file-name (git-file-name "rocm-llvm" %rocm-llvm-version))
1298 (sha256 1312 (sha256
1299 (base32 1313 (base32
1300 "1j2cr362k7snsh5c1z38ikyihmjvy0088rj0f0dhng6cjwgysryp")))) 1314 "1nwbj2cz99psgq9s9l4wbsxj41l2d2dga5l9rw9jndk05jsn4n7s"))
1315 ;; Some of these patches require a further dynamic substitution during
1316 ;; package build. Therefore, it is important to derive from the base
1317 ;; packages or to duplicate such substitutions. Additionally, some of
1318 ;; those substitutions are only applied on specific subcomponents
1319 ;; (llvm-clang), so duplicating the base-llvm structure with subcomponents
1320 ;; is necessary.
1321 (patches
1322 (map search-patch
1323 (assoc-ref %llvm-patches (package-version llvm-base))))))
1301 (arguments 1324 (arguments
1302 (substitute-keyword-arguments (package-arguments llvm-19) 1325 (substitute-keyword-arguments (package-arguments llvm-base)
1303 ((#:configure-flags flags) 1326 ((#:configure-flags flags)
1304 #~(list "-DLLVM_ENABLE_PROJECTS=llvm;clang;lld" 1327 #~(append #$flags
1305 "-DLLVM_TARGETS_TO_BUILD=AMDGPU;X86" 1328 (list "-DLLVM_TARGETS_TO_BUILD=AMDGPU;X86"
1306 "-DCMAKE_SKIP_BUILD_RPATH=FALSE" 1329 "-DLLVM_VERSION_SUFFIX=")))))
1307 "-DCMAKE_BUILD_WITH_INSTALL_RPATH=FALSE"
1308 "-DBUILD_SHARED_LIBS:BOOL=TRUE"
1309 "-DLLVM_VERSION_SUFFIX="))))
1310 (properties `((hidden? . #t) 1330 (properties `((hidden? . #t)
1311 ,@(package-properties llvm-19))) 1331 ,@(package-properties llvm-base)))
1312 (home-page "https://github.com/ROCm/llvm-project") 1332 (home-page "https://github.com/ROCm/llvm-project")
1313 (synopsis 1333 (synopsis
1314 (string-append (package-synopsis llvm-19) " (AMD fork)")) 1334 (string-append (package-synopsis llvm-base) " (AMD fork)"))
1315 (description 1335 (description
1316 (string-append (package-description llvm-19) " 1336 (string-append (package-description llvm-base) "
1317 1337
1318This AMD fork includes AMD-specific additions.")))) 1338This AMD fork includes AMD-specific additions."))))
1319 1339
1340(define-public llvm-rocm (make-llvm-rocm llvm-20))
1341
1342(define (make-clang-runtime-rocm clang-runtime-base)
1343 (package
1344 (inherit clang-runtime-base)
1345 (name "clang-runtime-rocm")
1346 (version (package-version llvm-rocm))
1347 (source (package-source llvm-rocm))
1348 (inputs (modify-inputs (package-inputs clang-runtime-base)
1349 (replace "llvm" llvm-rocm)))))
1350
1351(define-public clang-runtime-rocm (make-clang-runtime-rocm clang-runtime-20))
1352
1353(define (make-clang-rocm clang-base)
1354 ;; note: tools-extra is embedded in the checkout
1355 (package
1356 (inherit clang-base)
1357 (name "clang-rocm")
1358 (version (package-version llvm-rocm))
1359 (source (package-source llvm-rocm))
1360 (inputs (modify-inputs (package-inputs clang-base)
1361 (delete "clang-tools-extra")))
1362 (propagated-inputs
1363 (modify-inputs (package-propagated-inputs clang-base)
1364 (replace "llvm" llvm-rocm)
1365 (replace "clang-runtime" clang-runtime-rocm)
1366 (append python-lit)))
1367 (arguments
1368 (substitute-keyword-arguments (package-arguments clang-base)
1369 ;; The tests can be run, as allowed by check phase rewrite and
1370 ;; LLVM_EXTERNAL_LIT setting. However, 84/46171 are failing. Most
1371 ;; should probably be disabled.
1372 ;;
1373 ;; - CUDA tests are failing.
1374 ;;
1375 ;; - Checking for some -L[[SYSROOT]] is failing, which I guess is
1376 ;; expected, given the patches we apply, which are mangling directory
1377 ;; searching for libraries.
1378 ;;
1379 ;; Getting the test suite to pass doesn't seem out of reach. We
1380 ;; probably should start with the standard llvm-clang-20x package.
1381 ((#:tests? _ #t) #f)
1382 ((#:configure-flags flags)
1383 #~(append #$flags
1384 (list
1385 "-DLLVM_TARGETS_TO_BUILD=AMDGPU;X86"
1386 ;; WARNING: we could patch
1387 ;; #$llvm-rocm/lib/cmake/llvm/AddLLVM.cmake to simplify, by
1388 ;; substituting set(LIT_COMMAND
1389 ;; "${Python3_EXECUTABLE};${lit_base_dir}/${lit_file_name}")
1390 ;; pending this, having a correct python script here is a
1391 ;; must-have.
1392 ;; TODO: test this on llvm-rocm.
1393 (string-append
1394 "-DLLVM_EXTERNAL_LIT="
1395 (search-input-file %build-inputs "bin/.lit-real"))
1396 ;; Disable clang wrapper which depends on lld as well.
1397 "-DCLANG_ENABLE_AMDCLANG=OFF")))
1398 ((#:phases phases '%standard-phases)
1399 #~(modify-phases #$phases
1400 (replace 'check
1401 (lambda* (#:rest args)
1402 (setenv "HOME" "/tmp")
1403 (apply (assoc-ref
1404 (@ (guix build gnu-build-system) %standard-phases)
1405 'check)
1406 #:test-target "check-clang" args)))
1407 (replace 'add-tools-extra
1408 (lambda _
1409 (copy-recursively "../clang-tools-extra" "tools/extra")))))))))
1410
1411(define-public clang-rocm (make-clang-rocm clang-20))
1412
1413(define-public rocm-device-libs
1414 (package
1415 (name "rocm-device-libs")
1416 (version (package-version llvm-rocm))
1417 (source (package-source llvm-rocm))
1418 (build-system cmake-build-system)
1419 (arguments
1420 (list
1421 #:tests? #f ; Not sure how to run them.
1422 #:build-type "Release"
1423 #:phases
1424 #~(modify-phases %standard-phases
1425 (add-after 'unpack 'chdir
1426 (lambda _
1427 (chdir "amd/device-libs")))
1428 (add-after 'install 'copy-include-directories
1429 (lambda _
1430 ;; at this point we're within amd/build; i guess the build
1431 ;; directory should be at the same level as source, but due to
1432 ;; the chdir above...
1433 (with-directory-excursion "../device-libs"
1434 (for-each
1435 (lambda (directory)
1436 (let ((include-directory (string-append directory "/inc")))
1437 (copy-recursively
1438 include-directory
1439 (string-append #$output "/" include-directory))))
1440 (list "irif" "oclc" "ockl" "ocml"))))))))
1441 (inputs (list clang-rocm))
1442 (home-page "https://github.com/ROCm/llvm-project/")
1443 (synopsis "ROCm Device libraries")
1444 (description "ROCm device libraries provide AMD-specific device-side language runtime
1445libraries, namely oclc, ocml, ockl, opencl, hip and hc.")
1446 (license license:ncsa)))
1447
1448;; Usage note from amd/comgr/src/comgr-env.cpp: at runtime, comgr either needs
1449;; the awful ROCM_PATH set, or the more palatable LLVM_PATH and HIP_PATH, set.
1450(define-public rocm-comgr
1451 (package
1452 (name "rocm-comgr")
1453 (version (package-version llvm-rocm))
1454 (source (package-source llvm-rocm))
1455 (build-system cmake-build-system)
1456 (arguments
1457 (list
1458 #:build-type "Release"
1459 #:phases
1460 #~(modify-phases %standard-phases
1461 (add-after 'unpack 'prepare-to-build
1462 (lambda _
1463 (chdir "amd/comgr")
1464 (setenv "ROCM_PATH"
1465 #$(this-package-input "rocm-device-libs")))))))
1466 (inputs (list libffi rocm-device-libs))
1467 (native-inputs (list
1468 clang-rocm
1469 lld-rocm
1470 python))
1471 (home-page "https://github.com/ROCm/ROCm-CompilerSupport")
1472 (synopsis "ROCm Code Object Manager")
1473 (description "The Comgr library provides APIs for compiling and inspecting
1474AMDGPU code objects.")
1475 (license license:ncsa)))
1476
1477(define-public rocm-hipcc
1478 (package
1479 (name "rocm-hipcc")
1480 (version (package-version llvm-rocm))
1481 (source (package-source llvm-rocm))
1482 (build-system cmake-build-system)
1483 (arguments
1484 (list
1485 #:tests? #f ; Not sure how to run them.
1486 #:build-type "Release"
1487 #:phases
1488 #~(modify-phases %standard-phases
1489 (add-after 'unpack 'chdir
1490 (lambda _
1491 (chdir "amd/hipcc")))
1492 (add-after 'chdir 'patch-rocm-path
1493 (lambda* (#:key inputs #:allow-other-keys)
1494 (substitute* (find-files "src" "\\.h$")
1495 (("roccmPath \\+ \"/bin/rocm_agent_enumerator\"")
1496 (format #f "~s" (search-input-file
1497 inputs
1498 "/bin/rocm_agent_enumerator"))))))
1499 ;; This version file very important, as it is parsed under
1500 ;; $#{llvm-rocm}/clang/lib/Driver/ToolChains/AMDGPU.cpp and its
1501 ;; contents decides on some includes for hipcc.
1502 (add-after 'install 'info-version
1503 (lambda _
1504 (let ((hip-version-dir (string-append #$output "/share/hip")))
1505 (mkdir hip-version-dir)
1506 (with-directory-excursion hip-version-dir
1507 (with-output-to-file "version"
1508 (lambda _
1509 (apply format #t
1510 "HIP_VERSION_MAJOR=~a~%~
1511 HIP_VERSION_MINOR=~a~%~
1512 HIP_VERSION_PATCH=~a~%~
1513 HIP_VERSION_GITHASH=0~%"
1514 (string-split
1515 #$(version-major+minor+point version) #\.))))))))
1516 (add-after 'install 'wrap-programs
1517 (lambda* (#:key inputs outputs #:allow-other-keys)
1518 (let ((output-bindir (string-append (assoc-ref outputs "out") "/bin")))
1519 (for-each
1520 (lambda (file)
1521 (wrap-program (string-append output-bindir "/" file)
1522 ;; The following definitions and their meaning can be
1523 ;; found in hibBin_base.h. We've defined neither
1524 ;; HIP_RUNTIME nor HIP_ROCCLR_HOME.
1525
1526 ;; HIP_ROCCLR_HOME unfortunately cannot be set here
1527 ;; (circular dependency problem) -- it should be set to
1528 ;; #$rocm-hip-runtime.
1529
1530 ;;(list "HIP_ROCCLR_HOME" '= (list #$rocm-hip-runtime))
1531 (list "HIP_PATH" '= (list #$output))
1532 (list "HIP_CLANG_PATH"
1533 '=
1534 (list (string-append
1535 #$(this-package-input "clang-rocm")
1536 "/bin")))
1537 (list "DEVICE_LIB_PATH"
1538 '=
1539 (list (string-append
1540 #$(this-package-input "rocm-device-libs")
1541 "/amdgcn/bitcode")))
1542
1543 ;; This is done in order to please check_config, which
1544 ;; checks that HSA_PATH is in LD_LIBRARY_PATH
1545 (list "LD_LIBRARY_PATH"
1546 'suffix
1547 (list #$(this-package-input "rocr-runtime")))
1548 ;; checks hipconfig is in PATH
1549 (list "PATH" 'suffix (list output-bindir))))
1550 '( "hipcc" "hipconfig" ))))))))
1551 (inputs (list clang-rocm
1552 rocm-device-libs
1553 rocr-runtime
1554 rocminfo
1555 perl
1556 bash-minimal))
1557 (home-page "https://github.com/ROCm/llvm-project/")
1558 (synopsis "ROCm HIP compiler driver (@command{hipcc})")
1559 (description "The HIP compiler driver (@command{hipcc}) is a compiler utility that will
1560call @command{clang} and pass the appropriate include and library options for
1561the target compiler and HIP infrastructure.")
1562 (license license:expat)))
1563
1320 1564
1321 1565
1322(define-public libunwind-headers 1566(define-public libunwind-headers
@@ -1727,6 +1971,26 @@ existing compilers together.")
1727(define-public python-clang-13 1971(define-public python-clang-13
1728 (clang-python-bindings clang-13)) 1972 (clang-python-bindings clang-13))
1729 1973
1974;; XXX
1975;; I would move all of rocm packages here and define a ROCm section.
1976
1977(define (make-lld-rocm lld-base)
1978 (package
1979 (inherit lld-base)
1980 (name "lld-rocm")
1981 (version (package-version llvm-rocm))
1982 (source (package-source llvm-rocm))
1983 (inputs (list llvm-rocm))
1984 (arguments
1985 (substitute-keyword-arguments (package-arguments lld-base)
1986 ((#:configure-flags flags)
1987 #~(append #$flags
1988 '("-DLLVM_TARGETS_TO_BUILD=AMDGPU;X86")))))))
1989
1990(define-public lld-rocm (make-lld-rocm lld-20))
1991
1992
1993
1730(define-public include-what-you-use 1994(define-public include-what-you-use
1731 (package 1995 (package
1732 (name "include-what-you-use") 1996 (name "include-what-you-use")
@@ -1737,8 +2001,8 @@ existing compilers together.")
1737 (origin 2001 (origin
1738 (method git-fetch) 2002 (method git-fetch)
1739 (uri (git-reference 2003 (uri (git-reference
1740 (url "https://github.com/include-what-you-use/include-what-you-use") 2004 (url "https://github.com/include-what-you-use/include-what-you-use")
1741 (commit version))) 2005 (commit version)))
1742 (file-name (git-file-name name version)) 2006 (file-name (git-file-name name version))
1743 (sha256 2007 (sha256
1744 (base32 "0dkk65y6abf7bzv10q1ch3dyzj4d5y89qhh43jn189l861d6pzs0")))) 2008 (base32 "0dkk65y6abf7bzv10q1ch3dyzj4d5y89qhh43jn189l861d6pzs0"))))