Subject: [PATCH 1/2] gnu: Update llvm-for-rocm to 5.1.3.

From: John Kehayias <[email-masked]>
Date: Mon, 13 Jun 2022 17:25:54 +0000

Empty Message

From a4e57b69b4de183952a85cdb0d86c3d952b9d990 Mon Sep 17 00:00:00 2001
From: John Kehayias <[email-masked]>
Date: Sun, 12 Jun 2022 17:03:40 -0400
Subject: [PATCH 1/2] gnu: Update llvm-for-rocm: Update to 5.1.3.

* gnu/packages/llvm.scm (llvm-for-rocm): Update to 5.1.3, now based on llvm-14.
[source]{patches}: Remove unneeded patches (add_Object and add_libraries) and add new one (linkdl).
* gnu/packages/patches/llvm-roc-3.0.0-add_libraries.patch,
gnu/packages/patches/llvm-roc-4.2.0-add_Object.patch: Delete files.
* gnu/packages/patches/llvm-roc-5.0.0-linkdl.patch: New file.
* gnu/local.mk (dist_patch_DATA): Update to match current patches.
---
 gnu/local.mk                                  |  3 +--
 gnu/packages/llvm.scm                         | 14 ++++++------
 .../llvm-roc-3.0.0-add_libraries.patch        | 22 -------------------
 .../patches/llvm-roc-4.2.0-add_Object.patch   | 13 -----------
 .../patches/llvm-roc-5.0.0-linkdl.patch       | 15 +++++++++++++
 5 files changed, 23 insertions(+), 44 deletions(-)
 delete mode 100644 gnu/packages/patches/llvm-roc-3.0.0-add_libraries.patch
 delete mode 100644 gnu/packages/patches/llvm-roc-4.2.0-add_Object.patch
 create mode 100644 gnu/packages/patches/llvm-roc-5.0.0-linkdl.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index 03e180cc85..ddf843ab3a 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1451,9 +1451,8 @@ dist_patch_DATA =						\
   %D%/packages/patches/llvm-9-fix-bitcast-miscompilation.patch	\
   %D%/packages/patches/llvm-9-fix-lpad-miscompilation.patch	\
   %D%/packages/patches/llvm-9-fix-scev-miscompilation.patch	\
-  %D%/packages/patches/llvm-roc-3.0.0-add_libraries.patch \
   %D%/packages/patches/llvm-roc-4.0.0-remove-isystem-usr-include.patch \
-  %D%/packages/patches/llvm-roc-4.2.0-add_Object.patch \
+  %D%/packages/patches/llvm-roc-5.0.0-linkdl.patch \
   %D%/packages/patches/lm-sensors-hwmon-attrs.patch		\
   %D%/packages/patches/lrcalc-includes.patch    		\
   %D%/packages/patches/lsh-fix-x11-forwarding.patch		\
diff --git a/gnu/packages/llvm.scm b/gnu/packages/llvm.scm
index 8bc9e8904c..98c4e0122d 100644
--- a/gnu/packages/llvm.scm
+++ b/gnu/packages/llvm.scm
@@ -23,6 +23,7 @@
 ;;; Copyright © 2021, 2022 Guillaume Le Vaillant <[email-masked]>
 ;;; Copyright © 2021 Maxim Cournoyer <[email-masked]>
 ;;; Copyright © 2022 Greg Hogan <[email-masked]>
+;;; Copyright © 2022 John Kehayias <[email-masked]>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -1109,10 +1110,10 @@ (define-public clang-toolchain clang-toolchain-13)
 
 (define-public llvm-for-rocm
   (package
-    ;; Actually based on LLVM 13 as of v4.3, but llvm-12 works just fine.
-    (inherit llvm-12)
+    ;; Based on LLVM 14 as of v5.0.0
+    (inherit llvm-14)
     (name "llvm-for-rocm")
-    (version "4.3.0")                         ;this must match '%rocm-version'
+    (version "5.1.3")                         ;this must match '%rocm-version'
     (source (origin
               (method git-fetch)
               (uri (git-reference
@@ -1121,10 +1122,9 @@ (define-public llvm-for-rocm
               (file-name (git-file-name name version))
               (sha256
                (base32
-                "0p75nr1qpmy6crymdax5hm40wkimman4lnglz4x5cnbiqindya7s"))
+                "0j6ydfkwrxwskgnhxc3cmry42n5faqbnwf2747qgf7lz5id8h8g5"))
               (patches
-               (search-patches "llvm-roc-4.2.0-add_Object.patch"
-                               "llvm-roc-3.0.0-add_libraries.patch"
+               (search-patches "llvm-roc-5.0.0-linkdl.patch"
                                "llvm-roc-4.0.0-remove-isystem-usr-include.patch"))))
     (arguments
      (substitute-keyword-arguments (package-arguments llvm-12)
@@ -1141,7 +1141,7 @@ (define-public llvm-for-rocm
            "-DBUILD_SHARED_LIBS:BOOL=TRUE"
            "-DLLVM_VERSION_SUFFIX="))))
     (properties `((hidden? . #t)
-                  ,@(package-properties llvm-12)))))
+                  ,@(package-properties llvm-14)))))
 
 
 
diff --git a/gnu/packages/patches/llvm-roc-3.0.0-add_libraries.patch b/gnu/packages/patches/llvm-roc-3.0.0-add_libraries.patch
deleted file mode 100644
index f6bc639f33..0000000000
--- a/gnu/packages/patches/llvm-roc-3.0.0-add_libraries.patch
+++ /dev/null
@@ -1,22 +0,0 @@
-Taken from https://gitweb.gentoo.org/repo/gentoo.git/tree/sys-devel/llvm-roc/files
-
-diff -Naur a/clang/lib/Basic/CMakeLists.txt b/clang/lib/Basic/CMakeLists.txt
---- a/clang/lib/Basic/CMakeLists.txt	2019-12-28 07:42:49.119055933 +0100
-+++ b/clang/lib/Basic/CMakeLists.txt	2019-12-28 07:42:13.265056070 +0100
-@@ -2,6 +2,7 @@
-   Core
-   MC
-   Support
-+  Option
-   )
- 
- find_first_existing_vc_file("${LLVM_MAIN_SRC_DIR}" llvm_vc)
-diff -Naur a/clang/lib/Driver/CMakeLists.txt b/clang/lib/Driver/CMakeLists.txt
---- a/clang/lib/Driver/CMakeLists.txt	2019-12-28 07:41:39.521056199 +0100
-+++ b/clang/lib/Driver/CMakeLists.txt	2019-12-28 07:40:23.998056487 +0100
-@@ -79,4 +79,5 @@
-   LINK_LIBS
-   clangBasic
-   ${system_libs}
-+  pthread
-   )
diff --git a/gnu/packages/patches/llvm-roc-4.2.0-add_Object.patch b/gnu/packages/patches/llvm-roc-4.2.0-add_Object.patch
deleted file mode 100644
index f1762a558b..0000000000
--- a/gnu/packages/patches/llvm-roc-4.2.0-add_Object.patch
+++ /dev/null
@@ -1,13 +0,0 @@
-Taken from https://gitweb.gentoo.org/repo/gentoo.git/tree/sys-devel/llvm-roc/files
-
-diff --color -uprN orig/lib/Target/AMDGPU/Disassembler/CMakeLists.txt llvm/lib/Target/AMDGPU/Disassembler/CMakeLists.txt
---- a/llvm/lib/Target/AMDGPU/Disassembler/CMakeLists.txt	2021-06-14 11:57:54.222796911 +0800
-+++ b/llvm/lib/Target/AMDGPU/Disassembler/CMakeLists.txt	2021-06-14 11:58:35.206796875 +0800
-@@ -11,6 +11,7 @@ add_llvm_component_library(LLVMAMDGPUDis
-   MC
-   MCDisassembler
-   Support
-+  Object
- 
-   ADD_TO_COMPONENT
-   AMDGPU
diff --git a/gnu/packages/patches/llvm-roc-5.0.0-linkdl.patch b/gnu/packages/patches/llvm-roc-5.0.0-linkdl.patch
new file mode 100644
index 0000000000..d6ed3aef93
--- /dev/null
+++ b/gnu/packages/patches/llvm-roc-5.0.0-linkdl.patch
@@ -0,0 +1,15 @@
+Taken from the Gentoo patch:
+https://gitweb.gentoo.org/repo/gentoo.git/tree/sys-devel/llvm-roc/files/llvm-roc-5.0.0-linkdl.patch
+
+LLVMOffloadArch should link libdl to fix undefined symbol 'dlsym' when linking
+
+--- a/llvm/lib/OffloadArch/offload-arch/CMakeLists.txt
++++ b/llvm/lib/OffloadArch/offload-arch/CMakeLists.txt
+@@ -3,6 +3,7 @@ add_llvm_tool(offload-arch
+   ${CMAKE_CURRENT_SOURCE_DIR}/offload-arch.cpp
+   DEPENDS generated-table LLVMOffloadArch
+ )
++target_link_libraries(LLVMOffloadArch PRIVATE ${CMAKE_DL_LIBS})
+ target_link_libraries(offload-arch PRIVATE LLVMOffloadArch)
+ 
+ if(CMAKE_HOST_UNIX)
-- 
2.36.1