Github messages for voidlinux
 help / color / mirror / Atom feed
* [PR PATCH] New packages: ROCm core and OpenCL
@ 2020-04-19 13:34 ahesford
  2020-04-19 15:24 ` [PR PATCH] [Updated] " ahesford
                   ` (59 more replies)
  0 siblings, 60 replies; 61+ messages in thread
From: ahesford @ 2020-04-19 13:34 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 3503 bytes --]

There is a new pull request by ahesford against master on the void-packages repository

https://github.com/ahesford/void-packages rocm
https://github.com/void-linux/void-packages/pull/21153

New packages: ROCm core and OpenCL
This PR includes several packages designed to bring the OpenCL portion of the
AMD ROCm ecosystem to Void. It addresses Issue #19507. There are many other
packages that AMD provides for GPGPU computing, but these can be added
piecemeal as users demand.

The packages are currently only for `x86_64*`. While at least some of the
packages will compile on other 64-bit architectures, I have no hardware to
test. They are certainly not suitable for 32-bit architectures; some internal
data structures rely on `uint64_t` values that are cast to pointers. At a
minimum, a thorough audit would be necessary to ensure that these casts are
safe (e.g., that the values stored were only ever upcast from 32-bit
pointers). More extensive work may be necessary to support 32-bit
architectures, probably without significant benefit.

The packages successfully identify a Radeon RX 580 on an `x86_64` installation
using both `clinfo` and `rocminfo` as provided. Furthermore, a version of
`pyopencl` linked against these ROCm packages successfully runs a simple
program that validates arithmetic on GPU-bound arrays.

There are caveats with this set of packages, almost all of which revolve
around the incompatibilities between the Void-provided `ocl-icd` and the
[Khronos OpenCL ICD loader](https://github.com/KhronosGroup/OpenCL-ICD-Loader)
required by (and built into) `rocm-opencl-runtime`.
1. All packages install into `/opt/rocm`. This keeps the environment closer to
that officially sanctioned by AMD and helps avoid conflicts between other
packages and those provided here. (For example, `clinfo` and the ICD loader
itself.) Eventually, we may be able to move the files into `/usr`.
2. The Khronos OpenCL ICD loader built into `rocm-opencl-runtime` is an
outdated, pre-release commit. If AMD can update its sources to use the release
version of that loader (which has a backward-incompatible API change), we may
be able to make ROCm compatible with `ocl-icd` or replace `ocl-icd` with the
official Khronos loader.
3. In the meantime, to avoid `shlibs` conflicts, the OpenCL ICD loader is
installed as `/opt/rocm/lib/libOpenCL-ROCm.so` (and an appropriately versioned
shared library), which means that programs wishing to use the ROCm OpenCL must
explicitly link against this library instead of the generic `libOpenCL.so`.
4. I do **not** recommend making any Void packages link against this specific
library, because it will make those packages ROCm-only. For the time being,
ROCm is intended for end-users to specifically link against. This, too,
requires the ICD loader used by ROCm be compatible with `ocl-icd`, or
`ocl-icd` be replaced by the Khronos loader. However, because the Khronos
loader changed its API for the release version, such a change is not yet
appropriate.

Hopefully, if AMD updates its dependence on the Khronos ICD loader, we can resolve some of these caveats in the future and make ROCm a more natural Void component.

Some patches were made to relocate some files in `/opt/rocm` and make everyting build on `x86_64-musl`. Where appropriate, these patches will be pushed upstream to clean up the distribution and packaging.

A patch file from https://github.com/void-linux/void-packages/pull/21153.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-rocm-21153.patch --]
[-- Type: text/x-diff, Size: 72717 bytes --]

From 6bc676c5571eb8445510366bd8c8cb3b0ea4b418 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Mon, 13 Apr 2020 13:08:09 -0400
Subject: [PATCH 1/7] New package: roct-thunk-interface-3.3.0

---
 common/shlibs                                 |  1 +
 srcpkgs/roct-thunk-interface-devel            |  1 +
 .../patches/cmake-dev-libdir.patch            | 10 ++++++
 .../roct-thunk-interface/patches/musl.patch   | 29 +++++++++++++++
 srcpkgs/roct-thunk-interface/template         | 35 +++++++++++++++++++
 5 files changed, 76 insertions(+)
 create mode 120000 srcpkgs/roct-thunk-interface-devel
 create mode 100644 srcpkgs/roct-thunk-interface/patches/cmake-dev-libdir.patch
 create mode 100644 srcpkgs/roct-thunk-interface/patches/musl.patch
 create mode 100644 srcpkgs/roct-thunk-interface/template

diff --git a/common/shlibs b/common/shlibs
index 53a59b7303b..78863e0f7b8 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3862,3 +3862,4 @@ libstk-4.6.1.so libstk-4.6.1_1
 libc++utilities.so.5 cpp-utilities-5.2.0_1
 libtagparser.so.9 tagparser-9.1.2_1
 libqtutilities.so.6 qtutilities-6.0.4_1
+libhsakmt.so.1 roct-thunk-interface-3.3.0_1
diff --git a/srcpkgs/roct-thunk-interface-devel b/srcpkgs/roct-thunk-interface-devel
new file mode 120000
index 00000000000..ac3f2cc684c
--- /dev/null
+++ b/srcpkgs/roct-thunk-interface-devel
@@ -0,0 +1 @@
+roct-thunk-interface
\ No newline at end of file
diff --git a/srcpkgs/roct-thunk-interface/patches/cmake-dev-libdir.patch b/srcpkgs/roct-thunk-interface/patches/cmake-dev-libdir.patch
new file mode 100644
index 00000000000..98c7f1e459c
--- /dev/null
+++ b/srcpkgs/roct-thunk-interface/patches/cmake-dev-libdir.patch
@@ -0,0 +1,10 @@
+--- CMakeLists.txt.old	2020-04-18 19:45:17.306081135 -0400
++++ CMakeLists.txt	2020-04-18 19:46:51.300753636 -0400
+@@ -146,6 +146,7 @@
+     COMMAND ${CMAKE_COMMAND}
+         -DSOURCE_DIR="${SOURCE_DIR}"
+         -DCMAKE_INSTALL_PREFIX="${CMAKE_INSTALL_PREFIX}"
++        -DCMAKE_INSTALL_LIBDIR="${CMAKE_INSTALL_LIBDIR}"
+         -DCPACK_RPM_PACKAGE_REQUIRES="hsakmt-roct"
+         -DCPACK_PACKAGING_INSTALL_PREFIX="${CPACK_PACKAGING_INSTALL_PREFIX}"
+         -DVERSION="${BUILD_VERSION_STRING}"
diff --git a/srcpkgs/roct-thunk-interface/patches/musl.patch b/srcpkgs/roct-thunk-interface/patches/musl.patch
new file mode 100644
index 00000000000..aeea9832411
--- /dev/null
+++ b/srcpkgs/roct-thunk-interface/patches/musl.patch
@@ -0,0 +1,29 @@
+diff -r -u old/src/libhsakmt.h new/src/libhsakmt.h
+--- src/libhsakmt.h	2020-03-04 15:00:47.000000000 -0500
++++ src/libhsakmt.h	2020-04-13 12:58:30.444865992 -0400
+@@ -54,6 +54,10 @@
+ #define CHECK_KFD_OPEN() \
+ 	do { if (kfd_open_count == 0 || hsakmt_forked) return HSAKMT_STATUS_KERNEL_IO_CHANNEL_NOT_OPENED; } while (0)
+ 
++/*On some platforms, a PAGE_SIZE macro eclipses the extern variable*/
++#ifdef PAGE_SIZE
++#undef PAGE_SIZE
++#endif
+ extern int PAGE_SIZE;
+ extern int PAGE_SHIFT;
+ 
+diff -r -u old/src/topology.c new/src/topology.c
+--- src/topology.c	2020-03-04 15:00:47.000000000 -0500
++++ src/topology.c	2020-04-13 13:01:31.209870701 -0400
+@@ -38,6 +38,11 @@
+ #include "libhsakmt.h"
+ #include "fmm.h"
+ 
++/*Needed on MUSL*/
++#ifndef MAXNAMLEN
++#define MAXNAMLEN PATH_MAX
++#endif
++
+ /* Number of memory banks added by thunk on top of topology
+  * This only includes static heaps like LDS, scratch and SVM,
+  * not for MMIO_REMAP heap. MMIO_REMAP memory bank is reported
diff --git a/srcpkgs/roct-thunk-interface/template b/srcpkgs/roct-thunk-interface/template
new file mode 100644
index 00000000000..b3a1e3dc929
--- /dev/null
+++ b/srcpkgs/roct-thunk-interface/template
@@ -0,0 +1,35 @@
+# Template file for 'roct-thunk-interface'
+pkgname=roct-thunk-interface
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="ROCT-Thunk-Interface-roc-${version}"
+build_style=cmake
+configure_args="-DCMAKE_INSTALL_PREFIX:PATH=/opt/rocm
+	-DCMAKE_INSTALL_RPATH:PATH='\$ORIGIN:\$ORIGIN/../lib'"
+make_build_target="all build-dev"
+make_install_target="install install-dev"
+hostmakedepends="cmake pkg-config"
+makedepends="pciutils-devel libnuma-devel"
+short_desc="Radeon Open Compute Thunk Interface"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute/ROCT-Thunk-Interface"
+distfiles="${homepage}/archive/roc-${version}.tar.gz"
+checksum=2cabe9d2cfa72031c05d11290837c476182e72d8dec2049298f691143fdd212b
+nocross=yes
+
+post_install() {
+	vlicense LICENSE.md
+}
+
+roct-thunk-interface-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove opt/rocm/include
+		vmove "opt/rocm/lib/*.so"
+		vmove opt/rocm/share/pkgconfig
+		vmove opt/rocm/lib/cmake
+	}
+}

From cae98b4ec2343998783cafd2169b0928c0c69763 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Mon, 13 Apr 2020 15:27:27 -0400
Subject: [PATCH 2/7] New package: rocr-runtime-3.3.0

---
 common/shlibs                            |  1 +
 srcpkgs/rocr-runtime-devel               |  1 +
 srcpkgs/rocr-runtime/patches/cmake.patch | 27 +++++++++++++++++++
 srcpkgs/rocr-runtime/template            | 33 ++++++++++++++++++++++++
 4 files changed, 62 insertions(+)
 create mode 120000 srcpkgs/rocr-runtime-devel
 create mode 100644 srcpkgs/rocr-runtime/patches/cmake.patch
 create mode 100644 srcpkgs/rocr-runtime/template

diff --git a/common/shlibs b/common/shlibs
index 78863e0f7b8..ec34c0df9fa 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3863,3 +3863,4 @@ libc++utilities.so.5 cpp-utilities-5.2.0_1
 libtagparser.so.9 tagparser-9.1.2_1
 libqtutilities.so.6 qtutilities-6.0.4_1
 libhsakmt.so.1 roct-thunk-interface-3.3.0_1
+libhsa-runtime64.so.1 rocr-runtime-3.3.0_1
diff --git a/srcpkgs/rocr-runtime-devel b/srcpkgs/rocr-runtime-devel
new file mode 120000
index 00000000000..be838f22d81
--- /dev/null
+++ b/srcpkgs/rocr-runtime-devel
@@ -0,0 +1 @@
+rocr-runtime
\ No newline at end of file
diff --git a/srcpkgs/rocr-runtime/patches/cmake.patch b/srcpkgs/rocr-runtime/patches/cmake.patch
new file mode 100644
index 00000000000..93b74cd2297
--- /dev/null
+++ b/srcpkgs/rocr-runtime/patches/cmake.patch
@@ -0,0 +1,27 @@
+--- src/CMakeLists.txt.old	2020-04-18 20:01:48.549636995 -0400
++++ src/CMakeLists.txt	2020-04-18 20:04:00.177179781 -0400
+@@ -108,8 +108,8 @@
+ ## ROCr build internal versioning
+ add_definitions ( -DROCR_BUILD_ID=${PACKAGE_VERSION_STRING} )
+ 
+-## Set RUNPATH - ../../lib covers use of the legacy symlink in /hsa/lib/
+-set(CMAKE_INSTALL_RPATH "$ORIGIN;$ORIGIN/../../lib;$ORIGIN/../../lib64;$ORIGIN/../lib64")
++## Set RUNPATH
++set(CMAKE_INSTALL_RPATH "$ORIGIN;$ORIGIN/../lib")
+ 
+ ## ------------------------- Linux Compiler and Linker options -------------------------
+ set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -fexceptions -fno-rtti -fvisibility=hidden -Wno-error=sign-compare -Wno-sign-compare -Wno-write-strings -Wno-conversion-null -fno-math-errno -fno-threadsafe-statics -fmerge-all-constants -fms-extensions -Wno-error=comment -Wno-comment -Wno-error=pointer-arith -Wno-pointer-arith -Wno-error=unused-variable -Wno-error=unused-function" )
+@@ -185,11 +185,8 @@
+ add_custom_target ( hsa_lib_link2 ALL WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMAND ${CMAKE_COMMAND} -E create_symlink ../hsa/lib/${CORE_RUNTIME_LIBRARY}.so.${SO_MAJOR} ${CORE_RUNTIME_LIBRARY}-link.so.${SO_MAJOR} )
+ 
+ ## Set install information
+-install ( TARGETS ${CORE_RUNTIME_TARGET} LIBRARY DESTINATION hsa/lib )
+-install ( DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/inc/ DESTINATION hsa/include/hsa )
+-install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/hsa_include_link DESTINATION include PERMISSIONS OWNER_WRITE OWNER_READ RENAME hsa )
+-install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/${CORE_RUNTIME_LIBRARY}-link.so DESTINATION lib PERMISSIONS OWNER_WRITE OWNER_READ RENAME ${CORE_RUNTIME_LIBRARY}.so )
+-install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/${CORE_RUNTIME_LIBRARY}-link.so.${SO_MAJOR} DESTINATION lib PERMISSIONS OWNER_WRITE OWNER_READ RENAME ${CORE_RUNTIME_LIBRARY}.so.${SO_MAJOR} )
++install ( TARGETS ${CORE_RUNTIME_TARGET} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} )
++install ( DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/inc/ DESTINATION include/hsa )
+ 
+ ## Packaging directives
+ set ( CPACK_GENERATOR "DEB;RPM" CACHE STRING "Package types to build")
diff --git a/srcpkgs/rocr-runtime/template b/srcpkgs/rocr-runtime/template
new file mode 100644
index 00000000000..3588211584c
--- /dev/null
+++ b/srcpkgs/rocr-runtime/template
@@ -0,0 +1,33 @@
+# Template file for 'rocr-runtime'
+pkgname=rocr-runtime
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="ROCR-Runtime-rocm-${version}"
+build_wrksrc="src"
+build_style=cmake
+configure_args="-DCMAKE_INSTALL_PREFIX:PATH=/opt/rocm
+	-DHSAKMT_INC_PATH:PATH=/opt/rocm/include
+	-DHSAKMT_LIB_PATH:PATH=/opt/rocm/lib"
+hostmakedepends="cmake pkg-config"
+makedepends="roct-thunk-interface-devel elfutils-devel"
+short_desc="Radeon Open Compute HSA Runtime"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute/ROCR-Runtime"
+distfiles="${homepage}/archive/rocm-${version}.tar.gz"
+checksum=fa2d2d1f8a61d8a6952d377cf288d78c61776c3c2a666f163cafc3aa19ab0b61
+nocross=yes
+
+post_install() {
+	vlicense ../LICENSE.txt
+}
+
+rocr-runtime-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove opt/rocm/include
+		vmove "opt/rocm/lib/*.so"
+	}
+}

From 52f0657ead04c144f6e10a979e035fe929bcaa65 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Mon, 13 Apr 2020 18:07:34 -0400
Subject: [PATCH 3/7] New package: rocm-llvm-3.3.0

---
 srcpkgs/rocm-llvm/template | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)
 create mode 100644 srcpkgs/rocm-llvm/template

diff --git a/srcpkgs/rocm-llvm/template b/srcpkgs/rocm-llvm/template
new file mode 100644
index 00000000000..0919e24b514
--- /dev/null
+++ b/srcpkgs/rocm-llvm/template
@@ -0,0 +1,25 @@
+# Template file for 'rocm-llvm'
+pkgname=rocm-llvm
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="llvm-project-rocm-ocl-${version}"
+build_wrksrc=llvm
+build_style=cmake
+configure_args="-DCMAKE_INSTALL_PREFIX:PATH=/opt/rocm/llvm
+	-DLLVM_ENABLE_PROJECTS='llvm;clang;lld' -DLLVM_TARGETS_TO_BUILD='AMDGPU'
+	-DLLVM_BUILD_DOCS=NO -DLLVM_ENABLE_OCAMLDOC=OFF
+	-DLLVM_ENABLE_SPHINX=NO -DLLVM_ENABLE_DOXYGEN=OFF
+	-DLLVM_INSTALL_UTILS=ON -DLLVM_VERSION_SUFFIX=roc -DOCAMLFIND=NO"
+hostmakedepends="cmake pkg-config python3"
+short_desc="Radeon Open Compute LLVM toolchain"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="Custom"
+homepage="https://github.com/RadeonOpenCompute/llvm-project"
+distfiles="${homepage}/archive/rocm-ocl-${version}.tar.gz"
+checksum=a2bef7042e8e2f2cd8548cb246b88322e1c77188839983dcac8312d56f544dc8
+nocross=yes
+
+post_install() {
+	vlicense LICENSE.TXT
+}

From a2b682db2d64ece9ed4a24d1ed6cde98c5f65f1c Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Tue, 14 Apr 2020 10:25:31 -0400
Subject: [PATCH 4/7] New package: rocm-device-libs-3.3.0

---
 srcpkgs/rocm-device-libs/template | 32 +++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)
 create mode 100644 srcpkgs/rocm-device-libs/template

diff --git a/srcpkgs/rocm-device-libs/template b/srcpkgs/rocm-device-libs/template
new file mode 100644
index 00000000000..94b3be580c0
--- /dev/null
+++ b/srcpkgs/rocm-device-libs/template
@@ -0,0 +1,32 @@
+# Template file for 'rocm-device-libs'
+pkgname=rocm-device-libs
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="ROCm-Device-Libs-rocm-ocl-${version}"
+build_style=cmake
+configure_args="-DCMAKE_INSTALL_PREFIX:PATH=/opt/rocm -DLLVM_DIR:PATH=/opt/rocm/llvm"
+hostmakedepends="cmake rocm-llvm"
+short_desc="Radeon Open Compute device libraries"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute/ROCm-Device-Libs"
+distfiles="${homepage}/archive/rocm-ocl-${version}.tar.gz"
+checksum=706b08230790e08ca6a7a2fb7687d6131fd39a562148340e00fa37a6c06769c5
+nocross=yes
+
+pre_configure() {
+	# Build the prepare-builtins executable with native compiler
+	mkdir -p utils/build
+	cd utils/build
+	_prepare_builtins="$PWD/prepare-builtins/prepare-builtins"
+	cmake ${configure_args} ..
+	make ${makejobs}
+
+	# Add path to prepare-builtins for cmake
+	configure_args+=" -DPREPARE_BUILTINS='${_prepare_builtins}'"
+}
+
+post_install() {
+	vlicense LICENSE
+}

From c1eaeb4b90fd6947ae4025017c4f31ef38f14b20 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Mon, 13 Apr 2020 18:30:00 -0400
Subject: [PATCH 5/7] New package: rocm-comgr-3.3.0

---
 common/shlibs               |  1 +
 srcpkgs/rocm-comgr-devel    |  1 +
 srcpkgs/rocm-comgr/template | 34 ++++++++++++++++++++++++++++++++++
 3 files changed, 36 insertions(+)
 create mode 120000 srcpkgs/rocm-comgr-devel
 create mode 100644 srcpkgs/rocm-comgr/template

diff --git a/common/shlibs b/common/shlibs
index ec34c0df9fa..509755bd8b9 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3864,3 +3864,4 @@ libtagparser.so.9 tagparser-9.1.2_1
 libqtutilities.so.6 qtutilities-6.0.4_1
 libhsakmt.so.1 roct-thunk-interface-3.3.0_1
 libhsa-runtime64.so.1 rocr-runtime-3.3.0_1
+libamd_comgr.so.1 rocm-comgr-3.3.0_1
diff --git a/srcpkgs/rocm-comgr-devel b/srcpkgs/rocm-comgr-devel
new file mode 120000
index 00000000000..3f5ce255e07
--- /dev/null
+++ b/srcpkgs/rocm-comgr-devel
@@ -0,0 +1 @@
+rocm-comgr
\ No newline at end of file
diff --git a/srcpkgs/rocm-comgr/template b/srcpkgs/rocm-comgr/template
new file mode 100644
index 00000000000..fb6580f2f8b
--- /dev/null
+++ b/srcpkgs/rocm-comgr/template
@@ -0,0 +1,34 @@
+# Template file for 'rocm-comgr'
+pkgname=rocm-comgr
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="ROCm-CompilerSupport-rocm-${version}"
+build_wrksrc="lib/comgr"
+build_style=cmake
+configure_args="-DCMAKE_INSTALL_PREFIX:PATH=/opt/rocm
+	-DClang_DIR:PATH=/opt/rocm/llvm/lib/cmake/clang
+	-DCMAKE_INSTALL_RPATH:PATH='\$ORIGIN:\$ORIGIN/../lib'"
+hostmakedepends="cmake pkg-config rocm-llvm"
+makedepends="rocm-device-libs"
+short_desc="Radeon Open Compute Code Object Manager"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="BSD-3-clause"
+homepage="https://github.com/RadeonOpenCompute/ROCm-CompilerSupport"
+distfiles="${homepage}/archive/rocm-${version}.tar.gz"
+checksum=01e2524e0f28ecd6f46c9720f279207de935d826b0172158792aa3ec86af9ca7
+nocross=yes
+
+post_install() {
+	vlicense LICENSE.txt
+}
+
+rocm-comgr-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove opt/rocm/include
+		vmove "opt/rocm/lib/*.so"
+		vmove opt/rocm/lib/cmake
+	}
+}

From 5fb6d398f4d4bce91c2df546ed13e3b1dc58a53a Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Fri, 17 Apr 2020 12:11:25 -0400
Subject: [PATCH 6/7] New package: rocminfo-3.3.0

---
 srcpkgs/rocminfo/template | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
 create mode 100644 srcpkgs/rocminfo/template

diff --git a/srcpkgs/rocminfo/template b/srcpkgs/rocminfo/template
new file mode 100644
index 00000000000..91128a766f3
--- /dev/null
+++ b/srcpkgs/rocminfo/template
@@ -0,0 +1,21 @@
+# Template file for 'rocminfo'
+pkgname=rocminfo
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="rocminfo-rocm-${version}"
+build_style=cmake
+configure_args="-DCMAKE_INSTALL_PREFIX:PATH=/opt/rocm -DROCM_DIR=/opt/rocm"
+hostmakedepends="cmake pkg-config"
+makedepends="rocr-runtime-devel"
+short_desc="Radeon Open Compute system information reporter"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute/rocminfo"
+distfiles="${homepage}/archive/rocm-${version}.tar.gz"
+checksum=e666f662c9e465aaabbbd0b109d87e017243cdf1a0898fabf5a90947bb3dbcd7
+nocross=yes
+
+post_install() {
+	vlicense License.txt
+}

From 87fa69bae6e6aceda0448914a24af63c02702a4e Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Tue, 14 Apr 2020 10:25:54 -0400
Subject: [PATCH 7/7] New package: rocm-opencl-runtime-3.3.0

---
 common/shlibs                                 |   1 +
 srcpkgs/rocm-opencl-runtime-devel             |   1 +
 .../files/libelf-musl.patch                   | 688 ++++++++++++++++++
 .../files/runtime-musl.patch                  |  11 +
 srcpkgs/rocm-opencl-runtime/files/sys_queue.h | 574 +++++++++++++++
 .../rocm-opencl-runtime/patches/cmake.patch   | 123 ++++
 srcpkgs/rocm-opencl-runtime/template          |  78 ++
 7 files changed, 1476 insertions(+)
 create mode 120000 srcpkgs/rocm-opencl-runtime-devel
 create mode 100644 srcpkgs/rocm-opencl-runtime/files/libelf-musl.patch
 create mode 100644 srcpkgs/rocm-opencl-runtime/files/runtime-musl.patch
 create mode 100644 srcpkgs/rocm-opencl-runtime/files/sys_queue.h
 create mode 100644 srcpkgs/rocm-opencl-runtime/patches/cmake.patch
 create mode 100644 srcpkgs/rocm-opencl-runtime/template

diff --git a/common/shlibs b/common/shlibs
index 509755bd8b9..d087fa3ab4b 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3865,3 +3865,4 @@ libqtutilities.so.6 qtutilities-6.0.4_1
 libhsakmt.so.1 roct-thunk-interface-3.3.0_1
 libhsa-runtime64.so.1 rocr-runtime-3.3.0_1
 libamd_comgr.so.1 rocm-comgr-3.3.0_1
+libOpenCL-ROCm.so.1 rocm-opencl-runtime-3.3.0_1
diff --git a/srcpkgs/rocm-opencl-runtime-devel b/srcpkgs/rocm-opencl-runtime-devel
new file mode 120000
index 00000000000..b2cda7e229d
--- /dev/null
+++ b/srcpkgs/rocm-opencl-runtime-devel
@@ -0,0 +1 @@
+rocm-opencl-runtime
\ No newline at end of file
diff --git a/srcpkgs/rocm-opencl-runtime/files/libelf-musl.patch b/srcpkgs/rocm-opencl-runtime/files/libelf-musl.patch
new file mode 100644
index 00000000000..a3705c259a9
--- /dev/null
+++ b/srcpkgs/rocm-opencl-runtime/files/libelf-musl.patch
@@ -0,0 +1,688 @@
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/_libelf.h compiler/lib/loaders/elf/utils/libelf/_libelf.h
+--- compiler/lib/loaders/elf/utils/libelf.orig/_libelf.h	2020-04-19 08:59:34.201386585 -0400
++++ compiler/lib/loaders/elf/utils/libelf/_libelf.h	2020-04-19 09:04:12.950433528 -0400
+@@ -30,7 +30,7 @@
+ #define	__LIBELF_H_
+ 
+ #include <limits.h>
+-#include <sys/queue.h>
++#include "sys_queue.h"
+ 
+ #include "_libelf_config.h"
+ 
+@@ -179,7 +179,9 @@
+  * Function Prototypes.
+  */
+ 
+-__BEGIN_DECLS
++#ifdef __cplusplus
++extern "C" {
++#endif
+ Elf_Data *_libelf_allocate_data(Elf_Scn *_s);
+ Elf	*_libelf_allocate_elf(Elf_Mem *mem);
+ Elf_Scn	*_libelf_allocate_scn(Elf *_e, size_t _ndx);
+@@ -213,6 +215,8 @@
+ Elf_Data *_libelf_xlate(Elf_Data *_d, const Elf_Data *_s,
+     unsigned int _encoding, int _elfclass, int _direction);
+ int	_libelf_xlate_shtype(uint32_t _sht);
+-__END_DECLS
++#ifdef __cplusplus
++}
++#endif
+ 
+ #endif	/* __LIBELF_H_ */
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_begin.c compiler/lib/loaders/elf/utils/libelf/elf_begin.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_begin.c	2020-04-19 08:59:34.201386585 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_begin.c	2020-04-19 09:01:04.313212042 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <sys/types.h>
+ #if !defined(WIN32)
+ #include <sys/errno.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_end.c compiler/lib/loaders/elf/utils/libelf/elf_end.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_end.c	2020-04-19 08:59:34.201386585 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_end.c	2020-04-19 09:01:14.895204681 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #if !defined(WIN32)
+ #include <sys/mman.h>
+ #endif
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_errmsg.c compiler/lib/loaders/elf/utils/libelf/elf_errmsg.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_errmsg.c	2020-04-19 08:59:34.201386585 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_errmsg.c	2020-04-19 09:01:16.753207065 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ #include <stdio.h>
+ #include <string.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_errno.c compiler/lib/loaders/elf/utils/libelf/elf_errno.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_errno.c	2020-04-19 08:59:34.201386585 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_errno.c	2020-04-19 09:01:18.669209528 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_fill.c compiler/lib/loaders/elf/utils/libelf/elf_fill.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_fill.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_fill.c	2020-04-19 09:01:21.109212667 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_flag.c compiler/lib/loaders/elf/utils/libelf/elf_flag.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_flag.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_flag.c	2020-04-19 09:01:23.376215579 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_getarhdr.c compiler/lib/loaders/elf/utils/libelf/elf_getarhdr.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_getarhdr.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_getarhdr.c	2020-04-19 09:01:25.414218197 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_getarsym.c compiler/lib/loaders/elf/utils/libelf/elf_getarsym.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_getarsym.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_getarsym.c	2020-04-19 09:01:27.575220978 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_getbase.c compiler/lib/loaders/elf/utils/libelf/elf_getbase.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_getbase.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_getbase.c	2020-04-19 09:01:29.963224043 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_getident.c compiler/lib/loaders/elf/utils/libelf/elf_getident.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_getident.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_getident.c	2020-04-19 09:01:31.912226551 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <ar.h>
+ #include <assert.h>
+ #include <libelf.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_hash.c compiler/lib/loaders/elf/utils/libelf/elf_hash.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_hash.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_hash.c	2020-04-19 09:01:33.877229069 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ #include "_libelf_config.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_kind.c compiler/lib/loaders/elf/utils/libelf/elf_kind.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_kind.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_kind.c	2020-04-19 09:01:35.940231721 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_memory.c compiler/lib/loaders/elf/utils/libelf/elf_memory.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_memory.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_memory.c	2020-04-19 09:01:38.171234596 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <ar.h>
+ #include <libelf.h>
+ #include <string.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_next.c compiler/lib/loaders/elf/utils/libelf/elf_next.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_next.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_next.c	2020-04-19 09:01:40.063237028 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <ar.h>
+ #include <assert.h>
+ #include <libelf.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_phnum.c compiler/lib/loaders/elf/utils/libelf/elf_phnum.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_phnum.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_phnum.c	2020-04-19 09:01:42.480240134 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <ar.h>
+ #include <libelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_rand.c compiler/lib/loaders/elf/utils/libelf/elf_rand.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_rand.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_rand.c	2020-04-19 09:01:45.061243452 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <ar.h>
+ #include <libelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_rawfile.c compiler/lib/loaders/elf/utils/libelf/elf_rawfile.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_rawfile.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_rawfile.c	2020-04-19 09:01:46.988245928 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_scn.c compiler/lib/loaders/elf/utils/libelf/elf_scn.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_scn.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_scn.c	2020-04-19 09:00:19.724298403 -0400
+@@ -24,8 +24,7 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-#include <sys/queue.h>
++#include "sys_queue.h"
+ 
+ #include <assert.h>
+ #include <errno.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_shnum.c compiler/lib/loaders/elf/utils/libelf/elf_shnum.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_shnum.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_shnum.c	2020-04-19 09:01:51.763252060 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <ar.h>
+ #include <libelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_shstrndx.c compiler/lib/loaders/elf/utils/libelf/elf_shstrndx.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_shstrndx.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_shstrndx.c	2020-04-19 09:01:53.532254340 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <ar.h>
+ #include <libelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_version.c compiler/lib/loaders/elf/utils/libelf/elf_version.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_version.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_version.c	2020-04-19 09:02:01.337264370 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf.h compiler/lib/loaders/elf/utils/libelf/gelf.h
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf.h	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf.h	2020-04-19 09:04:29.669455020 -0400
+@@ -29,8 +29,6 @@
+ #ifndef	_GELF_H_
+ #define	_GELF_H_
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ typedef Elf64_Addr	GElf_Addr;	/* Addresses */
+@@ -72,7 +70,9 @@
+ #define	GELF_ST_TYPE			ELF64_ST_TYPE
+ #define	GELF_ST_VISIBILITY		ELF64_ST_VISIBILITY
+ 
+-__BEGIN_DECLS
++#ifdef __cplusplus
++extern "C" {
++#endif
+ long		gelf_checksum(Elf *_elf);
+ size_t		gelf_fsize(Elf *_elf, Elf_Type _type, size_t _count,
+ 			unsigned int _version);
+@@ -109,6 +109,8 @@
+ int		gelf_update_move(Elf_Data *_dst, int _index, GElf_Move *_src);
+ int		gelf_update_syminfo(Elf_Data *_dst, int _index, GElf_Syminfo *_src);
+ #endif
+-__END_DECLS
++#ifdef __cplusplus
++}
++#endif
+ 
+ #endif	/* _GELF_H_ */
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_cap.c compiler/lib/loaders/elf/utils/libelf/gelf_cap.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_cap.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_cap.c	2020-04-19 09:02:05.429269632 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_checksum.c compiler/lib/loaders/elf/utils/libelf/gelf_checksum.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_checksum.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_checksum.c	2020-04-19 09:02:08.192273183 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <gelf.h>
+ #include <libelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_dyn.c compiler/lib/loaders/elf/utils/libelf/gelf_dyn.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_dyn.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_dyn.c	2020-04-19 09:02:10.020275525 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_ehdr.c compiler/lib/loaders/elf/utils/libelf/gelf_ehdr.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_ehdr.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_ehdr.c	2020-04-19 09:02:11.882277926 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ #include <libelf.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_fsize.c compiler/lib/loaders/elf/utils/libelf/gelf_fsize.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_fsize.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_fsize.c	2020-04-19 09:02:14.139280827 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <gelf.h>
+ #include <libelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_getclass.c compiler/lib/loaders/elf/utils/libelf/gelf_getclass.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_getclass.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_getclass.c	2020-04-19 09:02:17.269284848 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <gelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_move.c compiler/lib/loaders/elf/utils/libelf/gelf_move.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_move.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_move.c	2020-04-19 09:02:18.974287034 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_phdr.c compiler/lib/loaders/elf/utils/libelf/gelf_phdr.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_phdr.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_phdr.c	2020-04-19 09:02:20.676289227 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <gelf.h>
+ #include <libelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_rel.c compiler/lib/loaders/elf/utils/libelf/gelf_rel.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_rel.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_rel.c	2020-04-19 09:02:23.177292435 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_rela.c compiler/lib/loaders/elf/utils/libelf/gelf_rela.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_rela.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_rela.c	2020-04-19 09:02:25.246295100 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_shdr.c compiler/lib/loaders/elf/utils/libelf/gelf_shdr.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_shdr.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_shdr.c	2020-04-19 09:02:28.325299060 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ #include <libelf.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_sym.c compiler/lib/loaders/elf/utils/libelf/gelf_sym.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_sym.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_sym.c	2020-04-19 09:02:30.113301356 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_syminfo.c compiler/lib/loaders/elf/utils/libelf/gelf_syminfo.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_syminfo.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_syminfo.c	2020-04-19 09:02:31.906303662 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_symshndx.c compiler/lib/loaders/elf/utils/libelf/gelf_symshndx.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_symshndx.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_symshndx.c	2020-04-19 09:02:33.626305873 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_xlate.c compiler/lib/loaders/elf/utils/libelf/gelf_xlate.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_xlate.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_xlate.c	2020-04-19 09:02:35.921308822 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <gelf.h>
+ #include <libelf.h>
+ #include <string.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf.h compiler/lib/loaders/elf/utils/libelf/libelf.h
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf.h	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf.h	2020-04-19 09:04:38.760466706 -0400
+@@ -30,7 +30,7 @@
+ #define	_LIBELF_H_
+ 
+ #include <sys/types.h>
+-#include <sys/queue.h>
++#include "sys_queue.h"
+ #include <elfdefinitions.h>
+ #ifndef EM_HSAIL
+ #define EM_HSAIL 0xAF5A
+@@ -187,7 +187,9 @@
+ #define	ELF_F_ARCHIVE	   0x100U /* archive creation */
+ #define	ELF_F_ARCHIVE_SYSV 0x200U /* SYSV style archive */
+ 
+-__BEGIN_DECLS
++#ifdef __cplusplus
++extern "C" {
++#endif
+ Elf		*elf_begin(int _fd, Elf_Cmd _cmd, Elf *_elf, Elf_Mem *_mem);
+ int		elf_cntl(Elf *_elf, Elf_Cmd _cmd);
+ int		elf_end(Elf *_elf);
+@@ -257,6 +259,8 @@
+ 			unsigned int _enc);
+ Elf_Data	*elf64_xlatetom(Elf_Data *_dst, const Elf_Data *_src,
+ 			unsigned int _enc);
+-__END_DECLS
++#ifdef __cplusplus
++}
++#endif
+ 
+ #endif	/* _LIBELF_H_ */
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_align.c compiler/lib/loaders/elf/utils/libelf/libelf_align.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_align.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_align.c	2020-04-19 09:02:40.660314911 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <sys/types.h>
+ 
+ #include <libelf.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_allocate.c compiler/lib/loaders/elf/utils/libelf/libelf_allocate.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_allocate.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_allocate.c	2020-04-19 09:02:43.079318019 -0400
+@@ -28,8 +28,6 @@
+  * Internal APIs
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #if !defined(WIN32)
+ #include <sys/errno.h>
+ #endif
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_ar.c compiler/lib/loaders/elf/utils/libelf/libelf_ar.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_ar.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_ar.c	2020-04-19 09:02:44.763320187 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <ctype.h>
+ #include <libelf.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_ar_util.c compiler/lib/loaders/elf/utils/libelf/libelf_ar_util.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_ar_util.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_ar_util.c	2020-04-19 09:02:46.461322369 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <libelf.h>
+ #include <stdlib.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_checksum.c compiler/lib/loaders/elf/utils/libelf/libelf_checksum.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_checksum.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_checksum.c	2020-04-19 09:02:48.645325173 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <gelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_convert.c compiler/lib/loaders/elf/utils/libelf/libelf_convert.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_convert.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_convert.c	2020-04-19 09:02:50.883328053 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <libelf.h>
+ #include <string.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_data.c compiler/lib/loaders/elf/utils/libelf/libelf_data.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_data.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_data.c	2020-04-19 09:02:52.951330708 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_ehdr.c compiler/lib/loaders/elf/utils/libelf/libelf_ehdr.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_ehdr.c	2020-04-19 08:59:34.204386579 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_ehdr.c	2020-04-19 09:02:55.176333563 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ #include <libelf.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_extended.c compiler/lib/loaders/elf/utils/libelf/libelf_extended.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_extended.c	2020-04-19 08:59:34.204386579 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_extended.c	2020-04-19 09:02:57.932337110 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <libelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_msize.c compiler/lib/loaders/elf/utils/libelf/libelf_msize.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_msize.c	2020-04-19 08:59:34.204386579 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_msize.c	2020-04-19 09:03:02.201342598 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <libelf.h>
+ #include <string.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_phdr.c compiler/lib/loaders/elf/utils/libelf/libelf_phdr.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_phdr.c	2020-04-19 08:59:34.204386579 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_phdr.c	2020-04-19 09:03:04.194345160 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ #include <libelf.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_shdr.c compiler/lib/loaders/elf/utils/libelf/libelf_shdr.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_shdr.c	2020-04-19 08:59:34.204386579 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_shdr.c	2020-04-19 09:03:05.795347218 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <gelf.h>
+ #include <libelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_xlate.c compiler/lib/loaders/elf/utils/libelf/libelf_xlate.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_xlate.c	2020-04-19 08:59:34.204386579 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_xlate.c	2020-04-19 09:03:09.472351944 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <libelf.h>
+ 
diff --git a/srcpkgs/rocm-opencl-runtime/files/runtime-musl.patch b/srcpkgs/rocm-opencl-runtime/files/runtime-musl.patch
new file mode 100644
index 00000000000..ea18e90e09c
--- /dev/null
+++ b/srcpkgs/rocm-opencl-runtime/files/runtime-musl.patch
@@ -0,0 +1,11 @@
+--- runtime/os/os_posix.cpp.orig	2020-04-19 09:13:51.701982901 -0400
++++ runtime/os/os_posix.cpp	2020-04-19 09:14:04.156947422 -0400
+@@ -44,6 +44,8 @@
+ #include <algorithm>
+ #include <mutex>
+ 
++#include <libgen.h> // for basename
++
+ 
+ namespace amd {
+ 
diff --git a/srcpkgs/rocm-opencl-runtime/files/sys_queue.h b/srcpkgs/rocm-opencl-runtime/files/sys_queue.h
new file mode 100644
index 00000000000..daf4553d33e
--- /dev/null
+++ b/srcpkgs/rocm-opencl-runtime/files/sys_queue.h
@@ -0,0 +1,574 @@
+/*
+ * Copyright (c) 1991, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *	@(#)queue.h	8.5 (Berkeley) 8/20/94
+ */
+
+#ifndef	_SYS_QUEUE_H_
+#define	_SYS_QUEUE_H_
+
+/*
+ * This file defines five types of data structures: singly-linked lists,
+ * lists, simple queues, tail queues, and circular queues.
+ *
+ * A singly-linked list is headed by a single forward pointer. The
+ * elements are singly linked for minimum space and pointer manipulation
+ * overhead at the expense of O(n) removal for arbitrary elements. New
+ * elements can be added to the list after an existing element or at the
+ * head of the list.  Elements being removed from the head of the list
+ * should use the explicit macro for this purpose for optimum
+ * efficiency. A singly-linked list may only be traversed in the forward
+ * direction.  Singly-linked lists are ideal for applications with large
+ * datasets and few or no removals or for implementing a LIFO queue.
+ *
+ * A list is headed by a single forward pointer (or an array of forward
+ * pointers for a hash table header). The elements are doubly linked
+ * so that an arbitrary element can be removed without a need to
+ * traverse the list. New elements can be added to the list before
+ * or after an existing element or at the head of the list. A list
+ * may only be traversed in the forward direction.
+ *
+ * A simple queue is headed by a pair of pointers, one the head of the
+ * list and the other to the tail of the list. The elements are singly
+ * linked to save space, so elements can only be removed from the
+ * head of the list. New elements can be added to the list after
+ * an existing element, at the head of the list, or at the end of the
+ * list. A simple queue may only be traversed in the forward direction.
+ *
+ * A tail queue is headed by a pair of pointers, one to the head of the
+ * list and the other to the tail of the list. The elements are doubly
+ * linked so that an arbitrary element can be removed without a need to
+ * traverse the list. New elements can be added to the list before or
+ * after an existing element, at the head of the list, or at the end of
+ * the list. A tail queue may be traversed in either direction.
+ *
+ * A circle queue is headed by a pair of pointers, one to the head of the
+ * list and the other to the tail of the list. The elements are doubly
+ * linked so that an arbitrary element can be removed without a need to
+ * traverse the list. New elements can be added to the list before or after
+ * an existing element, at the head of the list, or at the end of the list.
+ * A circle queue may be traversed in either direction, but has a more
+ * complex end of list detection.
+ *
+ * For details on the use of these macros, see the queue(3) manual page.
+ */
+
+/*
+ * List definitions.
+ */
+#define	LIST_HEAD(name, type)						\
+struct name {								\
+	struct type *lh_first;	/* first element */			\
+}
+
+#define	LIST_HEAD_INITIALIZER(head)					\
+	{ NULL }
+
+#define	LIST_ENTRY(type)						\
+struct {								\
+	struct type *le_next;	/* next element */			\
+	struct type **le_prev;	/* address of previous next element */	\
+}
+
+/*
+ * List functions.
+ */
+#define	LIST_INIT(head) do {						\
+	(head)->lh_first = NULL;					\
+} while (/*CONSTCOND*/0)
+
+#define	LIST_INSERT_AFTER(listelm, elm, field) do {			\
+	if (((elm)->field.le_next = (listelm)->field.le_next) != NULL)	\
+		(listelm)->field.le_next->field.le_prev =		\
+		    &(elm)->field.le_next;				\
+	(listelm)->field.le_next = (elm);				\
+	(elm)->field.le_prev = &(listelm)->field.le_next;		\
+} while (/*CONSTCOND*/0)
+
+#define	LIST_INSERT_BEFORE(listelm, elm, field) do {			\
+	(elm)->field.le_prev = (listelm)->field.le_prev;		\
+	(elm)->field.le_next = (listelm);				\
+	*(listelm)->field.le_prev = (elm);				\
+	(listelm)->field.le_prev = &(elm)->field.le_next;		\
+} while (/*CONSTCOND*/0)
+
+#define	LIST_INSERT_HEAD(head, elm, field) do {				\
+	if (((elm)->field.le_next = (head)->lh_first) != NULL)		\
+		(head)->lh_first->field.le_prev = &(elm)->field.le_next;\
+	(head)->lh_first = (elm);					\
+	(elm)->field.le_prev = &(head)->lh_first;			\
+} while (/*CONSTCOND*/0)
+
+#define	LIST_REMOVE(elm, field) do {					\
+	if ((elm)->field.le_next != NULL)				\
+		(elm)->field.le_next->field.le_prev = 			\
+		    (elm)->field.le_prev;				\
+	*(elm)->field.le_prev = (elm)->field.le_next;			\
+} while (/*CONSTCOND*/0)
+
+#define	LIST_FOREACH(var, head, field)					\
+	for ((var) = ((head)->lh_first);				\
+		(var);							\
+		(var) = ((var)->field.le_next))
+
+/*
+ * List access methods.
+ */
+#define	LIST_EMPTY(head)		((head)->lh_first == NULL)
+#define	LIST_FIRST(head)		((head)->lh_first)
+#define	LIST_NEXT(elm, field)		((elm)->field.le_next)
+
+
+/*
+ * Singly-linked List definitions.
+ */
+#define	SLIST_HEAD(name, type)						\
+struct name {								\
+	struct type *slh_first;	/* first element */			\
+}
+
+#define	SLIST_HEAD_INITIALIZER(head)					\
+	{ NULL }
+
+#define	SLIST_ENTRY(type)						\
+struct {								\
+	struct type *sle_next;	/* next element */			\
+}
+
+/*
+ * Singly-linked List functions.
+ */
+#define	SLIST_INIT(head) do {						\
+	(head)->slh_first = NULL;					\
+} while (/*CONSTCOND*/0)
+
+#define	SLIST_INSERT_AFTER(slistelm, elm, field) do {			\
+	(elm)->field.sle_next = (slistelm)->field.sle_next;		\
+	(slistelm)->field.sle_next = (elm);				\
+} while (/*CONSTCOND*/0)
+
+#define	SLIST_INSERT_HEAD(head, elm, field) do {			\
+	(elm)->field.sle_next = (head)->slh_first;			\
+	(head)->slh_first = (elm);					\
+} while (/*CONSTCOND*/0)
+
+#define	SLIST_REMOVE_HEAD(head, field) do {				\
+	(head)->slh_first = (head)->slh_first->field.sle_next;		\
+} while (/*CONSTCOND*/0)
+
+#define	SLIST_REMOVE(head, elm, type, field) do {			\
+	if ((head)->slh_first == (elm)) {				\
+		SLIST_REMOVE_HEAD((head), field);			\
+	}								\
+	else {								\
+		struct type *curelm = (head)->slh_first;		\
+		while(curelm->field.sle_next != (elm))			\
+			curelm = curelm->field.sle_next;		\
+		curelm->field.sle_next =				\
+		    curelm->field.sle_next->field.sle_next;		\
+	}								\
+} while (/*CONSTCOND*/0)
+
+#define	SLIST_FOREACH(var, head, field)					\
+	for((var) = (head)->slh_first; (var); (var) = (var)->field.sle_next)
+
+/*
+ * Singly-linked List access methods.
+ */
+#define	SLIST_EMPTY(head)	((head)->slh_first == NULL)
+#define	SLIST_FIRST(head)	((head)->slh_first)
+#define	SLIST_NEXT(elm, field)	((elm)->field.sle_next)
+
+
+/*
+ * Singly-linked Tail queue declarations.
+ */
+#define	STAILQ_HEAD(name, type)					\
+struct name {								\
+	struct type *stqh_first;	/* first element */			\
+	struct type **stqh_last;	/* addr of last next element */		\
+}
+
+#define	STAILQ_HEAD_INITIALIZER(head)					\
+	{ NULL, &(head).stqh_first }
+
+#define	STAILQ_ENTRY(type)						\
+struct {								\
+	struct type *stqe_next;	/* next element */			\
+}
+
+/*
+ * Singly-linked Tail queue functions.
+ */
+#define	STAILQ_INIT(head) do {						\
+	(head)->stqh_first = NULL;					\
+	(head)->stqh_last = &(head)->stqh_first;				\
+} while (/*CONSTCOND*/0)
+
+#define	STAILQ_INSERT_HEAD(head, elm, field) do {			\
+	if (((elm)->field.stqe_next = (head)->stqh_first) == NULL)	\
+		(head)->stqh_last = &(elm)->field.stqe_next;		\
+	(head)->stqh_first = (elm);					\
+} while (/*CONSTCOND*/0)
+
+#define	STAILQ_INSERT_TAIL(head, elm, field) do {			\
+	(elm)->field.stqe_next = NULL;					\
+	*(head)->stqh_last = (elm);					\
+	(head)->stqh_last = &(elm)->field.stqe_next;			\
+} while (/*CONSTCOND*/0)
+
+#define	STAILQ_INSERT_AFTER(head, listelm, elm, field) do {		\
+	if (((elm)->field.stqe_next = (listelm)->field.stqe_next) == NULL)\
+		(head)->stqh_last = &(elm)->field.stqe_next;		\
+	(listelm)->field.stqe_next = (elm);				\
+} while (/*CONSTCOND*/0)
+
+#define	STAILQ_REMOVE_HEAD(head, field) do {				\
+	if (((head)->stqh_first = (head)->stqh_first->field.stqe_next) == NULL) \
+		(head)->stqh_last = &(head)->stqh_first;			\
+} while (/*CONSTCOND*/0)
+
+#define	STAILQ_REMOVE(head, elm, type, field) do {			\
+	if ((head)->stqh_first == (elm)) {				\
+		STAILQ_REMOVE_HEAD((head), field);			\
+	} else {							\
+		struct type *curelm = (head)->stqh_first;		\
+		while (curelm->field.stqe_next != (elm))			\
+			curelm = curelm->field.stqe_next;		\
+		if ((curelm->field.stqe_next =				\
+			curelm->field.stqe_next->field.stqe_next) == NULL) \
+			    (head)->stqh_last = &(curelm)->field.stqe_next; \
+	}								\
+} while (/*CONSTCOND*/0)
+
+#define	STAILQ_FOREACH(var, head, field)				\
+	for ((var) = ((head)->stqh_first);				\
+		(var);							\
+		(var) = ((var)->field.stqe_next))
+
+#define	STAILQ_CONCAT(head1, head2) do {				\
+	if (!STAILQ_EMPTY((head2))) {					\
+		*(head1)->stqh_last = (head2)->stqh_first;		\
+		(head1)->stqh_last = (head2)->stqh_last;		\
+		STAILQ_INIT((head2));					\
+	}								\
+} while (/*CONSTCOND*/0)
+
+/*
+ * Singly-linked Tail queue access methods.
+ */
+#define	STAILQ_EMPTY(head)	((head)->stqh_first == NULL)
+#define	STAILQ_FIRST(head)	((head)->stqh_first)
+#define	STAILQ_NEXT(elm, field)	((elm)->field.stqe_next)
+
+
+/*
+ * Simple queue definitions.
+ */
+#define	SIMPLEQ_HEAD(name, type)					\
+struct name {								\
+	struct type *sqh_first;	/* first element */			\
+	struct type **sqh_last;	/* addr of last next element */		\
+}
+
+#define	SIMPLEQ_HEAD_INITIALIZER(head)					\
+	{ NULL, &(head).sqh_first }
+
+#define	SIMPLEQ_ENTRY(type)						\
+struct {								\
+	struct type *sqe_next;	/* next element */			\
+}
+
+/*
+ * Simple queue functions.
+ */
+#define	SIMPLEQ_INIT(head) do {						\
+	(head)->sqh_first = NULL;					\
+	(head)->sqh_last = &(head)->sqh_first;				\
+} while (/*CONSTCOND*/0)
+
+#define	SIMPLEQ_INSERT_HEAD(head, elm, field) do {			\
+	if (((elm)->field.sqe_next = (head)->sqh_first) == NULL)	\
+		(head)->sqh_last = &(elm)->field.sqe_next;		\
+	(head)->sqh_first = (elm);					\
+} while (/*CONSTCOND*/0)
+
+#define	SIMPLEQ_INSERT_TAIL(head, elm, field) do {			\
+	(elm)->field.sqe_next = NULL;					\
+	*(head)->sqh_last = (elm);					\
+	(head)->sqh_last = &(elm)->field.sqe_next;			\
+} while (/*CONSTCOND*/0)
+
+#define	SIMPLEQ_INSERT_AFTER(head, listelm, elm, field) do {		\
+	if (((elm)->field.sqe_next = (listelm)->field.sqe_next) == NULL)\
+		(head)->sqh_last = &(elm)->field.sqe_next;		\
+	(listelm)->field.sqe_next = (elm);				\
+} while (/*CONSTCOND*/0)
+
+#define	SIMPLEQ_REMOVE_HEAD(head, field) do {				\
+	if (((head)->sqh_first = (head)->sqh_first->field.sqe_next) == NULL) \
+		(head)->sqh_last = &(head)->sqh_first;			\
+} while (/*CONSTCOND*/0)
+
+#define	SIMPLEQ_REMOVE(head, elm, type, field) do {			\
+	if ((head)->sqh_first == (elm)) {				\
+		SIMPLEQ_REMOVE_HEAD((head), field);			\
+	} else {							\
+		struct type *curelm = (head)->sqh_first;		\
+		while (curelm->field.sqe_next != (elm))			\
+			curelm = curelm->field.sqe_next;		\
+		if ((curelm->field.sqe_next =				\
+			curelm->field.sqe_next->field.sqe_next) == NULL) \
+			    (head)->sqh_last = &(curelm)->field.sqe_next; \
+	}								\
+} while (/*CONSTCOND*/0)
+
+#define	SIMPLEQ_FOREACH(var, head, field)				\
+	for ((var) = ((head)->sqh_first);				\
+		(var);							\
+		(var) = ((var)->field.sqe_next))
+
+/*
+ * Simple queue access methods.
+ */
+#define	SIMPLEQ_EMPTY(head)		((head)->sqh_first == NULL)
+#define	SIMPLEQ_FIRST(head)		((head)->sqh_first)
+#define	SIMPLEQ_NEXT(elm, field)	((elm)->field.sqe_next)
+
+
+/*
+ * Tail queue definitions.
+ */
+#define	_TAILQ_HEAD(name, type, qual)					\
+struct name {								\
+	qual type *tqh_first;		/* first element */		\
+	qual type *qual *tqh_last;	/* addr of last next element */	\
+}
+#define TAILQ_HEAD(name, type)	_TAILQ_HEAD(name, struct type,)
+
+#define	TAILQ_HEAD_INITIALIZER(head)					\
+	{ NULL, &(head).tqh_first }
+
+#define	_TAILQ_ENTRY(type, qual)					\
+struct {								\
+	qual type *tqe_next;		/* next element */		\
+	qual type *qual *tqe_prev;	/* address of previous next element */\
+}
+#define TAILQ_ENTRY(type)	_TAILQ_ENTRY(struct type,)
+
+/*
+ * Tail queue functions.
+ */
+#define	TAILQ_INIT(head) do {						\
+	(head)->tqh_first = NULL;					\
+	(head)->tqh_last = &(head)->tqh_first;				\
+} while (/*CONSTCOND*/0)
+
+#define	TAILQ_INSERT_HEAD(head, elm, field) do {			\
+	if (((elm)->field.tqe_next = (head)->tqh_first) != NULL)	\
+		(head)->tqh_first->field.tqe_prev =			\
+		    &(elm)->field.tqe_next;				\
+	else								\
+		(head)->tqh_last = &(elm)->field.tqe_next;		\
+	(head)->tqh_first = (elm);					\
+	(elm)->field.tqe_prev = &(head)->tqh_first;			\
+} while (/*CONSTCOND*/0)
+
+#define	TAILQ_INSERT_TAIL(head, elm, field) do {			\
+	(elm)->field.tqe_next = NULL;					\
+	(elm)->field.tqe_prev = (head)->tqh_last;			\
+	*(head)->tqh_last = (elm);					\
+	(head)->tqh_last = &(elm)->field.tqe_next;			\
+} while (/*CONSTCOND*/0)
+
+#define	TAILQ_INSERT_AFTER(head, listelm, elm, field) do {		\
+	if (((elm)->field.tqe_next = (listelm)->field.tqe_next) != NULL)\
+		(elm)->field.tqe_next->field.tqe_prev = 		\
+		    &(elm)->field.tqe_next;				\
+	else								\
+		(head)->tqh_last = &(elm)->field.tqe_next;		\
+	(listelm)->field.tqe_next = (elm);				\
+	(elm)->field.tqe_prev = &(listelm)->field.tqe_next;		\
+} while (/*CONSTCOND*/0)
+
+#define	TAILQ_INSERT_BEFORE(listelm, elm, field) do {			\
+	(elm)->field.tqe_prev = (listelm)->field.tqe_prev;		\
+	(elm)->field.tqe_next = (listelm);				\
+	*(listelm)->field.tqe_prev = (elm);				\
+	(listelm)->field.tqe_prev = &(elm)->field.tqe_next;		\
+} while (/*CONSTCOND*/0)
+
+#define	TAILQ_REMOVE(head, elm, field) do {				\
+	if (((elm)->field.tqe_next) != NULL)				\
+		(elm)->field.tqe_next->field.tqe_prev = 		\
+		    (elm)->field.tqe_prev;				\
+	else								\
+		(head)->tqh_last = (elm)->field.tqe_prev;		\
+	*(elm)->field.tqe_prev = (elm)->field.tqe_next;			\
+} while (/*CONSTCOND*/0)
+
+#define	TAILQ_FOREACH(var, head, field)					\
+	for ((var) = ((head)->tqh_first);				\
+		(var);							\
+		(var) = ((var)->field.tqe_next))
+
+#define	TAILQ_FOREACH_REVERSE(var, head, headname, field)		\
+	for ((var) = (*(((struct headname *)((head)->tqh_last))->tqh_last));	\
+		(var);							\
+		(var) = (*(((struct headname *)((var)->field.tqe_prev))->tqh_last)))
+
+#define	TAILQ_CONCAT(head1, head2, field) do {				\
+	if (!TAILQ_EMPTY(head2)) {					\
+		*(head1)->tqh_last = (head2)->tqh_first;		\
+		(head2)->tqh_first->field.tqe_prev = (head1)->tqh_last;	\
+		(head1)->tqh_last = (head2)->tqh_last;			\
+		TAILQ_INIT((head2));					\
+	}								\
+} while (/*CONSTCOND*/0)
+
+/*
+ * Tail queue access methods.
+ */
+#define	TAILQ_EMPTY(head)		((head)->tqh_first == NULL)
+#define	TAILQ_FIRST(head)		((head)->tqh_first)
+#define	TAILQ_NEXT(elm, field)		((elm)->field.tqe_next)
+
+#define	TAILQ_LAST(head, headname) \
+	(*(((struct headname *)((head)->tqh_last))->tqh_last))
+#define	TAILQ_PREV(elm, headname, field) \
+	(*(((struct headname *)((elm)->field.tqe_prev))->tqh_last))
+
+
+/*
+ * Circular queue definitions.
+ */
+#define	CIRCLEQ_HEAD(name, type)					\
+struct name {								\
+	struct type *cqh_first;		/* first element */		\
+	struct type *cqh_last;		/* last element */		\
+}
+
+#define	CIRCLEQ_HEAD_INITIALIZER(head)					\
+	{ (void *)&head, (void *)&head }
+
+#define	CIRCLEQ_ENTRY(type)						\
+struct {								\
+	struct type *cqe_next;		/* next element */		\
+	struct type *cqe_prev;		/* previous element */		\
+}
+
+/*
+ * Circular queue functions.
+ */
+#define	CIRCLEQ_INIT(head) do {						\
+	(head)->cqh_first = (void *)(head);				\
+	(head)->cqh_last = (void *)(head);				\
+} while (/*CONSTCOND*/0)
+
+#define	CIRCLEQ_INSERT_AFTER(head, listelm, elm, field) do {		\
+	(elm)->field.cqe_next = (listelm)->field.cqe_next;		\
+	(elm)->field.cqe_prev = (listelm);				\
+	if ((listelm)->field.cqe_next == (void *)(head))		\
+		(head)->cqh_last = (elm);				\
+	else								\
+		(listelm)->field.cqe_next->field.cqe_prev = (elm);	\
+	(listelm)->field.cqe_next = (elm);				\
+} while (/*CONSTCOND*/0)
+
+#define	CIRCLEQ_INSERT_BEFORE(head, listelm, elm, field) do {		\
+	(elm)->field.cqe_next = (listelm);				\
+	(elm)->field.cqe_prev = (listelm)->field.cqe_prev;		\
+	if ((listelm)->field.cqe_prev == (void *)(head))		\
+		(head)->cqh_first = (elm);				\
+	else								\
+		(listelm)->field.cqe_prev->field.cqe_next = (elm);	\
+	(listelm)->field.cqe_prev = (elm);				\
+} while (/*CONSTCOND*/0)
+
+#define	CIRCLEQ_INSERT_HEAD(head, elm, field) do {			\
+	(elm)->field.cqe_next = (head)->cqh_first;			\
+	(elm)->field.cqe_prev = (void *)(head);				\
+	if ((head)->cqh_last == (void *)(head))				\
+		(head)->cqh_last = (elm);				\
+	else								\
+		(head)->cqh_first->field.cqe_prev = (elm);		\
+	(head)->cqh_first = (elm);					\
+} while (/*CONSTCOND*/0)
+
+#define	CIRCLEQ_INSERT_TAIL(head, elm, field) do {			\
+	(elm)->field.cqe_next = (void *)(head);				\
+	(elm)->field.cqe_prev = (head)->cqh_last;			\
+	if ((head)->cqh_first == (void *)(head))			\
+		(head)->cqh_first = (elm);				\
+	else								\
+		(head)->cqh_last->field.cqe_next = (elm);		\
+	(head)->cqh_last = (elm);					\
+} while (/*CONSTCOND*/0)
+
+#define	CIRCLEQ_REMOVE(head, elm, field) do {				\
+	if ((elm)->field.cqe_next == (void *)(head))			\
+		(head)->cqh_last = (elm)->field.cqe_prev;		\
+	else								\
+		(elm)->field.cqe_next->field.cqe_prev =			\
+		    (elm)->field.cqe_prev;				\
+	if ((elm)->field.cqe_prev == (void *)(head))			\
+		(head)->cqh_first = (elm)->field.cqe_next;		\
+	else								\
+		(elm)->field.cqe_prev->field.cqe_next =			\
+		    (elm)->field.cqe_next;				\
+} while (/*CONSTCOND*/0)
+
+#define	CIRCLEQ_FOREACH(var, head, field)				\
+	for ((var) = ((head)->cqh_first);				\
+		(var) != (const void *)(head);				\
+		(var) = ((var)->field.cqe_next))
+
+#define	CIRCLEQ_FOREACH_REVERSE(var, head, field)			\
+	for ((var) = ((head)->cqh_last);				\
+		(var) != (const void *)(head);				\
+		(var) = ((var)->field.cqe_prev))
+
+/*
+ * Circular queue access methods.
+ */
+#define	CIRCLEQ_EMPTY(head)		((head)->cqh_first == (void *)(head))
+#define	CIRCLEQ_FIRST(head)		((head)->cqh_first)
+#define	CIRCLEQ_LAST(head)		((head)->cqh_last)
+#define	CIRCLEQ_NEXT(elm, field)	((elm)->field.cqe_next)
+#define	CIRCLEQ_PREV(elm, field)	((elm)->field.cqe_prev)
+
+#define CIRCLEQ_LOOP_NEXT(head, elm, field)				\
+	(((elm)->field.cqe_next == (void *)(head))			\
+	    ? ((head)->cqh_first)					\
+	    : (elm->field.cqe_next))
+#define CIRCLEQ_LOOP_PREV(head, elm, field)				\
+	(((elm)->field.cqe_prev == (void *)(head))			\
+	    ? ((head)->cqh_last)					\
+	    : (elm->field.cqe_prev))
+
+#endif	/* sys/queue.h */
diff --git a/srcpkgs/rocm-opencl-runtime/patches/cmake.patch b/srcpkgs/rocm-opencl-runtime/patches/cmake.patch
new file mode 100644
index 00000000000..2b3354f3eeb
--- /dev/null
+++ b/srcpkgs/rocm-opencl-runtime/patches/cmake.patch
@@ -0,0 +1,123 @@
+diff -u -r ../original/OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/CMakeLists.txt ./OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/CMakeLists.txt
+--- OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/CMakeLists.txt	2019-09-10 11:53:28.000000000 -0400
++++ OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/CMakeLists.txt	2020-04-16 20:16:13.481180757 -0400
+@@ -73,11 +73,11 @@
+ 
+ set (OPENCL_ICD_LOADER_HEADERS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/inc CACHE PATH "Path to OpenCL Headers")
+ 
+-add_library (OpenCL ${OPENCL_ICD_LOADER_SOURCES})
+-set_target_properties (OpenCL PROPERTIES VERSION "1.2" SOVERSION "1")
++add_library (OpenCL-ROCm ${OPENCL_ICD_LOADER_SOURCES})
++set_target_properties (OpenCL-ROCm PROPERTIES VERSION "1.2" SOVERSION "1")
+ 
+ if (WIN32)
+-    target_link_libraries (OpenCL cfgmgr32.lib)
++    target_link_libraries (OpenCL-ROCm cfgmgr32.lib)
+ 
+     option (OPENCL_ICD_LOADER_REQUIRE_WDK "Build with D3DKMT support, which requires the Windows WDK." ON)
+     if (OPENCL_ICD_LOADER_REQUIRE_WDK)
+@@ -92,10 +92,10 @@
+             get_filename_component(WDK_DIRECTORY ${LATEST_D3DKMT_HEADER} DIRECTORY)
+             get_filename_component(WDK_DIRECTORY ${WDK_DIRECTORY} DIRECTORY)
+             message(STATUS "Found the Windows WDK in: ${WDK_DIRECTORY}")
+-            target_compile_definitions(OpenCL PRIVATE OPENCL_ICD_LOADER_REQUIRE_WDK)
+-            target_include_directories(OpenCL PRIVATE ${WDK_DIRECTORY}/um)
+-            target_include_directories(OpenCL PRIVATE ${WDK_DIRECTORY}/km)
+-            target_include_directories(OpenCL PRIVATE ${WDK_DIRECTORY}/shared)
++	    target_compile_definitions(OpenCL-ROCm PRIVATE OPENCL_ICD_LOADER_REQUIRE_WDK)
++	    target_include_directories(OpenCL-ROCm PRIVATE ${WDK_DIRECTORY}/um)
++	    target_include_directories(OpenCL-ROCm PRIVATE ${WDK_DIRECTORY}/km)
++	    target_include_directories(OpenCL-ROCm PRIVATE ${WDK_DIRECTORY}/shared)
+         else()
+             message(FATAL_ERROR "The Windows WDK was not found. Consider disabling OPENCL_ICD_LOADER_REQUIRE_WDK. Aborting.")
+         endif()
+@@ -113,25 +113,25 @@
+     endif()
+ else()
+     if (APPLE)
+-        target_link_libraries (OpenCL ${CMAKE_THREAD_LIBS_INIT})
++        target_link_libraries (OpenCL-ROCm ${CMAKE_THREAD_LIBS_INIT})
+     else ()
+-        set_target_properties (OpenCL PROPERTIES LINK_FLAGS "-Wl,--version-script -Wl,${CMAKE_CURRENT_SOURCE_DIR}/loader/linux/icd_exports.map")
+-        target_link_libraries (OpenCL ${CMAKE_THREAD_LIBS_INIT})
++        set_target_properties (OpenCL-ROCm PROPERTIES LINK_FLAGS "-Wl,--version-script -Wl,${CMAKE_CURRENT_SOURCE_DIR}/loader/linux/icd_exports.map")
++	target_link_libraries (OpenCL-ROCm ${CMAKE_THREAD_LIBS_INIT})
+     endif ()
+ endif ()
+ 
+ include_directories (${OPENCL_ICD_LOADER_HEADERS_DIR})
+ add_definitions (-DCL_TARGET_OPENCL_VERSION=220)
+ 
+-target_include_directories (OpenCL PRIVATE ${CMAKE_CURRENT_BINARY_DIR} loader)
+-target_link_libraries (OpenCL ${CMAKE_DL_LIBS})
++target_include_directories (OpenCL-ROCm PRIVATE ${CMAKE_CURRENT_BINARY_DIR} loader)
++target_link_libraries (OpenCL-ROCm ${CMAKE_DL_LIBS})
+ 
+ include (CTest)
+ if (BUILD_TESTING)
+     add_subdirectory (test)
+ endif()
+ 
+-install (TARGETS OpenCL
++install (TARGETS OpenCL-ROCm
+     RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+     ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
+     LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
+diff -u -r ../original/OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/test/loader_test/CMakeLists.txt ./OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/test/loader_test/CMakeLists.txt
+--- OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/test/loader_test/CMakeLists.txt	2019-09-10 11:53:28.000000000 -0400
++++ OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/test/loader_test/CMakeLists.txt	2020-04-16 20:16:56.647026589 -0400
+@@ -12,4 +12,4 @@
+     test_clgl.c
+     test_image_objects.c )
+ 
+-target_link_libraries (icd_loader_test OpenCL IcdLog)
++target_link_libraries (icd_loader_test OpenCL-ROCm IcdLog)
+diff -u -r ../original/ROCm-OpenCL-Runtime-roc-3.3.0/CMakeLists.txt ./ROCm-OpenCL-Runtime-roc-3.3.0/CMakeLists.txt
+--- ROCm-OpenCL-Runtime-roc-3.3.0/CMakeLists.txt	2020-04-18 20:16:13.452670818 -0400
++++ ROCm-OpenCL-Runtime-roc-3.3.0/CMakeLists.txt	2020-04-18 20:20:09.798862321 -0400
+@@ -102,16 +102,16 @@
+ 
+ # MAIN package
+ install(PROGRAMS $<TARGET_FILE:clinfo>
+-        DESTINATION bin/x86_64
++        DESTINATION bin
+         COMPONENT MAIN)
+ install(PROGRAMS $<TARGET_FILE:amdocl64>
+-        DESTINATION lib/x86_64
++        DESTINATION lib
+         COMPONENT MAIN)
+-install(PROGRAMS $<TARGET_FILE:OpenCL>
+-        DESTINATION lib/x86_64
++install(PROGRAMS $<TARGET_FILE:OpenCL-ROCm>
++        DESTINATION lib
+         COMPONENT MAIN)
+-install(PROGRAMS $<TARGET_SONAME_FILE:OpenCL>
+-        DESTINATION lib/x86_64
++install(PROGRAMS $<TARGET_SONAME_FILE:OpenCL-ROCm>
++        DESTINATION lib
+         COMPONENT MAIN)
+ 
+ # DEV package
+@@ -123,8 +123,8 @@
+         PATTERN cl_d3d11.h EXCLUDE
+         PATTERN cl_dx9_media_sharing.h EXCLUDE
+         PATTERN cl_egl.h EXCLUDE)
+-install(PROGRAMS $<TARGET_LINKER_FILE:OpenCL>
+-        DESTINATION lib/x86_64
++install(PROGRAMS $<TARGET_LINKER_FILE:OpenCL-ROCm>
++        DESTINATION lib
+         COMPONENT DEV)
+ 
+ # Generic CPACK variables
+diff -u -r ../original/ROCm-OpenCL-Runtime-roc-3.3.0/tools/clinfo/CMakeLists.txt ./ROCm-OpenCL-Runtime-roc-3.3.0/tools/clinfo/CMakeLists.txt
+--- ROCm-OpenCL-Runtime-roc-3.3.0/tools/clinfo/CMakeLists.txt	2020-04-01 13:05:07.000000000 -0400
++++ ROCm-OpenCL-Runtime-roc-3.3.0/tools/clinfo/CMakeLists.txt	2020-04-16 20:17:33.735894123 -0400
+@@ -8,4 +8,7 @@
+ 
+ add_executable(clinfo clinfo.cpp)
+ 
+-target_link_libraries(clinfo OpenCL)
++target_link_libraries(clinfo OpenCL-ROCm)
++
++# Make sure the clinfo rpath does not point to build directory
++set_target_properties(clinfo PROPERTIES BUILD_WITH_INSTALL_RPATH ON)
diff --git a/srcpkgs/rocm-opencl-runtime/template b/srcpkgs/rocm-opencl-runtime/template
new file mode 100644
index 00000000000..832ec7566ff
--- /dev/null
+++ b/srcpkgs/rocm-opencl-runtime/template
@@ -0,0 +1,78 @@
+# Template file for 'rocm-opencl-runtime'
+pkgname=rocm-opencl-runtime
+version=3.3.0
+revision=1
+_ocl_icd_name="OpenCL-ICD-Loader"
+_ocl_icd_ver="6c03f8b58fafd9dd693eaac826749a5cfad515f8"
+archs="x86_64*"
+create_wrksrc=yes
+build_wrksrc="ROCm-OpenCL-Runtime-roc-${version}"
+build_style=cmake
+configure_args="-DCMAKE_INSTALL_PREFIX:PATH=/opt/rocm
+	-DCMAKE_PREFIX_PATH:PATH=/opt/rocm/lib/cmake
+	-DCMAKE_INSTALL_RPATH:PATH='\$ORIGIN:\$ORIGIN/../lib'
+	-DUSE_COMGR_LIBRARY=yes"
+hostmakedepends="cmake pkg-config"
+makedepends="libglvnd-devel rocm-comgr-devel
+	roct-thunk-interface-devel rocr-runtime-devel"
+depends="rocm-comgr"
+short_desc="Radeon Open Compute OpenCL runtime"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="MIT"
+homepage="https://github.com/RadeonOpenCompute/ROCm-OpenCL-Runtime"
+_rocroot="https://github.com/RadeonOpenCompute"
+distfiles="${_rocroot}/ROCm-OpenCL-Runtime/archive/roc-${version}.tar.gz
+	${_rocroot}/rocm-cmake/archive/rocm-${version}.tar.gz
+	https://github.com/KhronosGroup/${_ocl_icd_name}/archive/${_ocl_icd_ver}.tar.gz"
+checksum="ac6999f1a491ab066286c2bd6adf50f08f831286f56e267879f9f7eced22f98e
+	76ed3ee8e56cf3246011cf7723c2abda539e1136e7e7f6909bfa45d268b8644f
+	c94d5bb6dc980c4d41d73e2b81663a19aabe494e923e2d0eec72a4c95b318438"
+nocross=yes
+
+post_patch() {
+	if [ "$XBPS_LIBC" = "musl" ]; then
+		# Copy sys/queue.h locally for MUSL builds
+		libelf_dir="compiler/lib/loaders/elf/utils/libelf"
+		cp "${FILESDIR}/sys_queue.h" "${libelf_dir}"
+
+		# Remove dependence on glibc
+		patch -Np0 < ${FILESDIR}/libelf-musl.patch
+		patch -Np0 < ${FILESDIR}/runtime-musl.patch
+		vsed -e '/glibc_functions.cpp/d' -i api/opencl/amdocl/CMakeLists.txt
+	fi
+}
+
+pre_configure() {
+	# ROCm requires a very specific Khronos ICD loader version in the tree
+	# Keep the ICD loader config in /opt/rocm to avoid conflicts
+	_ocl_icd_dir="${_ocl_icd_name}-${_ocl_icd_ver}"
+	ln -sf "${wrksrc}/${_ocl_icd_dir}" api/opencl/khronos/icd
+	vsed -i "${wrksrc}/${_ocl_icd_dir}/loader/icd_platform.h" \
+		-e 's@/etc/OpenCL/vendors/@/opt/rocm&@g'
+
+	# CMake modules probably not useful anywhere but for this build
+	ln -sf "${wrksrc}/rocm-cmake-rocm-${version}/share/rocm/cmake"/*.cmake cmake
+
+	# Fix the dlopen macro to point to versioned libamd_comgr shared object
+	vsed -i 'runtime/device/comgrctx.cpp' \
+		-e 's/\blibamd_comgr\(32\)\?.so\b/&.1/g'
+}
+
+post_install() {
+	vlicense License
+
+	# Create descriptor to allow the ICD loader to find the driver
+	_ocl_icd_dir="opt/rocm/etc/OpenCL/vendors"
+	vmkdir "${_ocl_icd_dir}"
+	echo "/opt/rocm/lib/libamdocl64.so" \
+		> "${DESTDIR}/${_ocl_icd_dir}/amdocl64.icd"
+}
+
+rocm-opencl-runtime-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove opt/rocm/include
+		vmove opt/rocm/lib/libOpenCL-ROCm.so
+	}
+}

^ permalink raw reply	[flat|nested] 61+ messages in thread

* Re: [PR PATCH] [Updated] New packages: ROCm core and OpenCL
  2020-04-19 13:34 [PR PATCH] New packages: ROCm core and OpenCL ahesford
@ 2020-04-19 15:24 ` ahesford
  2020-04-19 15:57 ` ahesford
                   ` (58 subsequent siblings)
  59 siblings, 0 replies; 61+ messages in thread
From: ahesford @ 2020-04-19 15:24 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 3508 bytes --]

There is an updated pull request by ahesford against master on the void-packages repository

https://github.com/ahesford/void-packages rocm
https://github.com/void-linux/void-packages/pull/21153

New packages: ROCm core and OpenCL
This PR includes several packages designed to bring the OpenCL portion of the
AMD ROCm ecosystem to Void. It addresses Issue #19507. There are many other
packages that AMD provides for GPGPU computing, but these can be added
piecemeal as users demand.

The packages are currently only for `x86_64*`. While at least some of the
packages will compile on other 64-bit architectures, I have no hardware to
test. They are certainly not suitable for 32-bit architectures; some internal
data structures rely on `uint64_t` values that are cast to pointers. At a
minimum, a thorough audit would be necessary to ensure that these casts are
safe (e.g., that the values stored were only ever upcast from 32-bit
pointers). More extensive work may be necessary to support 32-bit
architectures, probably without significant benefit.

The packages successfully identify a Radeon RX 580 on an `x86_64` installation
using both `clinfo` and `rocminfo` as provided. Furthermore, a version of
`pyopencl` linked against these ROCm packages successfully runs a simple
program that validates arithmetic on GPU-bound arrays.

There are caveats with this set of packages, almost all of which revolve
around the incompatibilities between the Void-provided `ocl-icd` and the
[Khronos OpenCL ICD loader](https://github.com/KhronosGroup/OpenCL-ICD-Loader)
required by (and built into) `rocm-opencl-runtime`.
1. All packages install into `/opt/rocm`. This keeps the environment closer to
that officially sanctioned by AMD and helps avoid conflicts between other
packages and those provided here. (For example, `clinfo` and the ICD loader
itself.) Eventually, we may be able to move the files into `/usr`.
2. The Khronos OpenCL ICD loader built into `rocm-opencl-runtime` is an
outdated, pre-release commit. If AMD can update its sources to use the release
version of that loader (which has a backward-incompatible API change), we may
be able to make ROCm compatible with `ocl-icd` or replace `ocl-icd` with the
official Khronos loader.
3. In the meantime, to avoid `shlibs` conflicts, the OpenCL ICD loader is
installed as `/opt/rocm/lib/libOpenCL-ROCm.so` (and an appropriately versioned
shared library), which means that programs wishing to use the ROCm OpenCL must
explicitly link against this library instead of the generic `libOpenCL.so`.
4. I do **not** recommend making any Void packages link against this specific
library, because it will make those packages ROCm-only. For the time being,
ROCm is intended for end-users to specifically link against. This, too,
requires the ICD loader used by ROCm be compatible with `ocl-icd`, or
`ocl-icd` be replaced by the Khronos loader. However, because the Khronos
loader changed its API for the release version, such a change is not yet
appropriate.

Hopefully, if AMD updates its dependence on the Khronos ICD loader, we can resolve some of these caveats in the future and make ROCm a more natural Void component.

Some patches were made to relocate some files in `/opt/rocm` and make everyting build on `x86_64-musl`. Where appropriate, these patches will be pushed upstream to clean up the distribution and packaging.

A patch file from https://github.com/void-linux/void-packages/pull/21153.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-rocm-21153.patch --]
[-- Type: text/x-diff, Size: 72761 bytes --]

From 6bc676c5571eb8445510366bd8c8cb3b0ea4b418 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Mon, 13 Apr 2020 13:08:09 -0400
Subject: [PATCH 1/7] New package: roct-thunk-interface-3.3.0

---
 common/shlibs                                 |  1 +
 srcpkgs/roct-thunk-interface-devel            |  1 +
 .../patches/cmake-dev-libdir.patch            | 10 ++++++
 .../roct-thunk-interface/patches/musl.patch   | 29 +++++++++++++++
 srcpkgs/roct-thunk-interface/template         | 35 +++++++++++++++++++
 5 files changed, 76 insertions(+)
 create mode 120000 srcpkgs/roct-thunk-interface-devel
 create mode 100644 srcpkgs/roct-thunk-interface/patches/cmake-dev-libdir.patch
 create mode 100644 srcpkgs/roct-thunk-interface/patches/musl.patch
 create mode 100644 srcpkgs/roct-thunk-interface/template

diff --git a/common/shlibs b/common/shlibs
index 53a59b7303b..78863e0f7b8 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3862,3 +3862,4 @@ libstk-4.6.1.so libstk-4.6.1_1
 libc++utilities.so.5 cpp-utilities-5.2.0_1
 libtagparser.so.9 tagparser-9.1.2_1
 libqtutilities.so.6 qtutilities-6.0.4_1
+libhsakmt.so.1 roct-thunk-interface-3.3.0_1
diff --git a/srcpkgs/roct-thunk-interface-devel b/srcpkgs/roct-thunk-interface-devel
new file mode 120000
index 00000000000..ac3f2cc684c
--- /dev/null
+++ b/srcpkgs/roct-thunk-interface-devel
@@ -0,0 +1 @@
+roct-thunk-interface
\ No newline at end of file
diff --git a/srcpkgs/roct-thunk-interface/patches/cmake-dev-libdir.patch b/srcpkgs/roct-thunk-interface/patches/cmake-dev-libdir.patch
new file mode 100644
index 00000000000..98c7f1e459c
--- /dev/null
+++ b/srcpkgs/roct-thunk-interface/patches/cmake-dev-libdir.patch
@@ -0,0 +1,10 @@
+--- CMakeLists.txt.old	2020-04-18 19:45:17.306081135 -0400
++++ CMakeLists.txt	2020-04-18 19:46:51.300753636 -0400
+@@ -146,6 +146,7 @@
+     COMMAND ${CMAKE_COMMAND}
+         -DSOURCE_DIR="${SOURCE_DIR}"
+         -DCMAKE_INSTALL_PREFIX="${CMAKE_INSTALL_PREFIX}"
++        -DCMAKE_INSTALL_LIBDIR="${CMAKE_INSTALL_LIBDIR}"
+         -DCPACK_RPM_PACKAGE_REQUIRES="hsakmt-roct"
+         -DCPACK_PACKAGING_INSTALL_PREFIX="${CPACK_PACKAGING_INSTALL_PREFIX}"
+         -DVERSION="${BUILD_VERSION_STRING}"
diff --git a/srcpkgs/roct-thunk-interface/patches/musl.patch b/srcpkgs/roct-thunk-interface/patches/musl.patch
new file mode 100644
index 00000000000..aeea9832411
--- /dev/null
+++ b/srcpkgs/roct-thunk-interface/patches/musl.patch
@@ -0,0 +1,29 @@
+diff -r -u old/src/libhsakmt.h new/src/libhsakmt.h
+--- src/libhsakmt.h	2020-03-04 15:00:47.000000000 -0500
++++ src/libhsakmt.h	2020-04-13 12:58:30.444865992 -0400
+@@ -54,6 +54,10 @@
+ #define CHECK_KFD_OPEN() \
+ 	do { if (kfd_open_count == 0 || hsakmt_forked) return HSAKMT_STATUS_KERNEL_IO_CHANNEL_NOT_OPENED; } while (0)
+ 
++/*On some platforms, a PAGE_SIZE macro eclipses the extern variable*/
++#ifdef PAGE_SIZE
++#undef PAGE_SIZE
++#endif
+ extern int PAGE_SIZE;
+ extern int PAGE_SHIFT;
+ 
+diff -r -u old/src/topology.c new/src/topology.c
+--- src/topology.c	2020-03-04 15:00:47.000000000 -0500
++++ src/topology.c	2020-04-13 13:01:31.209870701 -0400
+@@ -38,6 +38,11 @@
+ #include "libhsakmt.h"
+ #include "fmm.h"
+ 
++/*Needed on MUSL*/
++#ifndef MAXNAMLEN
++#define MAXNAMLEN PATH_MAX
++#endif
++
+ /* Number of memory banks added by thunk on top of topology
+  * This only includes static heaps like LDS, scratch and SVM,
+  * not for MMIO_REMAP heap. MMIO_REMAP memory bank is reported
diff --git a/srcpkgs/roct-thunk-interface/template b/srcpkgs/roct-thunk-interface/template
new file mode 100644
index 00000000000..b3a1e3dc929
--- /dev/null
+++ b/srcpkgs/roct-thunk-interface/template
@@ -0,0 +1,35 @@
+# Template file for 'roct-thunk-interface'
+pkgname=roct-thunk-interface
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="ROCT-Thunk-Interface-roc-${version}"
+build_style=cmake
+configure_args="-DCMAKE_INSTALL_PREFIX:PATH=/opt/rocm
+	-DCMAKE_INSTALL_RPATH:PATH='\$ORIGIN:\$ORIGIN/../lib'"
+make_build_target="all build-dev"
+make_install_target="install install-dev"
+hostmakedepends="cmake pkg-config"
+makedepends="pciutils-devel libnuma-devel"
+short_desc="Radeon Open Compute Thunk Interface"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute/ROCT-Thunk-Interface"
+distfiles="${homepage}/archive/roc-${version}.tar.gz"
+checksum=2cabe9d2cfa72031c05d11290837c476182e72d8dec2049298f691143fdd212b
+nocross=yes
+
+post_install() {
+	vlicense LICENSE.md
+}
+
+roct-thunk-interface-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove opt/rocm/include
+		vmove "opt/rocm/lib/*.so"
+		vmove opt/rocm/share/pkgconfig
+		vmove opt/rocm/lib/cmake
+	}
+}

From cae98b4ec2343998783cafd2169b0928c0c69763 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Mon, 13 Apr 2020 15:27:27 -0400
Subject: [PATCH 2/7] New package: rocr-runtime-3.3.0

---
 common/shlibs                            |  1 +
 srcpkgs/rocr-runtime-devel               |  1 +
 srcpkgs/rocr-runtime/patches/cmake.patch | 27 +++++++++++++++++++
 srcpkgs/rocr-runtime/template            | 33 ++++++++++++++++++++++++
 4 files changed, 62 insertions(+)
 create mode 120000 srcpkgs/rocr-runtime-devel
 create mode 100644 srcpkgs/rocr-runtime/patches/cmake.patch
 create mode 100644 srcpkgs/rocr-runtime/template

diff --git a/common/shlibs b/common/shlibs
index 78863e0f7b8..ec34c0df9fa 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3863,3 +3863,4 @@ libc++utilities.so.5 cpp-utilities-5.2.0_1
 libtagparser.so.9 tagparser-9.1.2_1
 libqtutilities.so.6 qtutilities-6.0.4_1
 libhsakmt.so.1 roct-thunk-interface-3.3.0_1
+libhsa-runtime64.so.1 rocr-runtime-3.3.0_1
diff --git a/srcpkgs/rocr-runtime-devel b/srcpkgs/rocr-runtime-devel
new file mode 120000
index 00000000000..be838f22d81
--- /dev/null
+++ b/srcpkgs/rocr-runtime-devel
@@ -0,0 +1 @@
+rocr-runtime
\ No newline at end of file
diff --git a/srcpkgs/rocr-runtime/patches/cmake.patch b/srcpkgs/rocr-runtime/patches/cmake.patch
new file mode 100644
index 00000000000..93b74cd2297
--- /dev/null
+++ b/srcpkgs/rocr-runtime/patches/cmake.patch
@@ -0,0 +1,27 @@
+--- src/CMakeLists.txt.old	2020-04-18 20:01:48.549636995 -0400
++++ src/CMakeLists.txt	2020-04-18 20:04:00.177179781 -0400
+@@ -108,8 +108,8 @@
+ ## ROCr build internal versioning
+ add_definitions ( -DROCR_BUILD_ID=${PACKAGE_VERSION_STRING} )
+ 
+-## Set RUNPATH - ../../lib covers use of the legacy symlink in /hsa/lib/
+-set(CMAKE_INSTALL_RPATH "$ORIGIN;$ORIGIN/../../lib;$ORIGIN/../../lib64;$ORIGIN/../lib64")
++## Set RUNPATH
++set(CMAKE_INSTALL_RPATH "$ORIGIN;$ORIGIN/../lib")
+ 
+ ## ------------------------- Linux Compiler and Linker options -------------------------
+ set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -fexceptions -fno-rtti -fvisibility=hidden -Wno-error=sign-compare -Wno-sign-compare -Wno-write-strings -Wno-conversion-null -fno-math-errno -fno-threadsafe-statics -fmerge-all-constants -fms-extensions -Wno-error=comment -Wno-comment -Wno-error=pointer-arith -Wno-pointer-arith -Wno-error=unused-variable -Wno-error=unused-function" )
+@@ -185,11 +185,8 @@
+ add_custom_target ( hsa_lib_link2 ALL WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMAND ${CMAKE_COMMAND} -E create_symlink ../hsa/lib/${CORE_RUNTIME_LIBRARY}.so.${SO_MAJOR} ${CORE_RUNTIME_LIBRARY}-link.so.${SO_MAJOR} )
+ 
+ ## Set install information
+-install ( TARGETS ${CORE_RUNTIME_TARGET} LIBRARY DESTINATION hsa/lib )
+-install ( DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/inc/ DESTINATION hsa/include/hsa )
+-install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/hsa_include_link DESTINATION include PERMISSIONS OWNER_WRITE OWNER_READ RENAME hsa )
+-install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/${CORE_RUNTIME_LIBRARY}-link.so DESTINATION lib PERMISSIONS OWNER_WRITE OWNER_READ RENAME ${CORE_RUNTIME_LIBRARY}.so )
+-install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/${CORE_RUNTIME_LIBRARY}-link.so.${SO_MAJOR} DESTINATION lib PERMISSIONS OWNER_WRITE OWNER_READ RENAME ${CORE_RUNTIME_LIBRARY}.so.${SO_MAJOR} )
++install ( TARGETS ${CORE_RUNTIME_TARGET} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} )
++install ( DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/inc/ DESTINATION include/hsa )
+ 
+ ## Packaging directives
+ set ( CPACK_GENERATOR "DEB;RPM" CACHE STRING "Package types to build")
diff --git a/srcpkgs/rocr-runtime/template b/srcpkgs/rocr-runtime/template
new file mode 100644
index 00000000000..3588211584c
--- /dev/null
+++ b/srcpkgs/rocr-runtime/template
@@ -0,0 +1,33 @@
+# Template file for 'rocr-runtime'
+pkgname=rocr-runtime
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="ROCR-Runtime-rocm-${version}"
+build_wrksrc="src"
+build_style=cmake
+configure_args="-DCMAKE_INSTALL_PREFIX:PATH=/opt/rocm
+	-DHSAKMT_INC_PATH:PATH=/opt/rocm/include
+	-DHSAKMT_LIB_PATH:PATH=/opt/rocm/lib"
+hostmakedepends="cmake pkg-config"
+makedepends="roct-thunk-interface-devel elfutils-devel"
+short_desc="Radeon Open Compute HSA Runtime"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute/ROCR-Runtime"
+distfiles="${homepage}/archive/rocm-${version}.tar.gz"
+checksum=fa2d2d1f8a61d8a6952d377cf288d78c61776c3c2a666f163cafc3aa19ab0b61
+nocross=yes
+
+post_install() {
+	vlicense ../LICENSE.txt
+}
+
+rocr-runtime-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove opt/rocm/include
+		vmove "opt/rocm/lib/*.so"
+	}
+}

From 1c2428c53053a61a13324e1dfb7822421a332ba9 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Mon, 13 Apr 2020 18:07:34 -0400
Subject: [PATCH 3/7] New package: rocm-llvm-3.3.0

---
 srcpkgs/rocm-llvm/template | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)
 create mode 100644 srcpkgs/rocm-llvm/template

diff --git a/srcpkgs/rocm-llvm/template b/srcpkgs/rocm-llvm/template
new file mode 100644
index 00000000000..487a845c733
--- /dev/null
+++ b/srcpkgs/rocm-llvm/template
@@ -0,0 +1,25 @@
+# Template file for 'rocm-llvm'
+pkgname=rocm-llvm
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="llvm-project-rocm-ocl-${version}"
+build_wrksrc=llvm
+build_style=cmake
+configure_args="-DCMAKE_INSTALL_PREFIX:PATH=/opt/rocm/llvm
+	-DLLVM_ENABLE_PROJECTS='llvm;clang;lld' -DLLVM_TARGETS_TO_BUILD='AMDGPU'
+	-DLLVM_BUILD_DOCS=NO -DLLVM_ENABLE_OCAMLDOC=OFF
+	-DLLVM_ENABLE_SPHINX=NO -DLLVM_ENABLE_DOXYGEN=OFF
+	-DLLVM_INSTALL_UTILS=ON -DLLVM_VERSION_SUFFIX=roc -DOCAMLFIND=NO"
+hostmakedepends="cmake pkg-config python3"
+short_desc="Radeon Open Compute LLVM toolchain"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="Apache-2.0, NCSA, custom:LLVM-Exceptions"
+homepage="https://github.com/RadeonOpenCompute/llvm-project"
+distfiles="${homepage}/archive/rocm-ocl-${version}.tar.gz"
+checksum=a2bef7042e8e2f2cd8548cb246b88322e1c77188839983dcac8312d56f544dc8
+nocross=yes
+
+post_install() {
+	vlicense LICENSE.TXT
+}

From 08f69a19fe86a03c04f9690783a59d0b6d6f2838 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Tue, 14 Apr 2020 10:25:31 -0400
Subject: [PATCH 4/7] New package: rocm-device-libs-3.3.0

---
 srcpkgs/rocm-device-libs/template | 32 +++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)
 create mode 100644 srcpkgs/rocm-device-libs/template

diff --git a/srcpkgs/rocm-device-libs/template b/srcpkgs/rocm-device-libs/template
new file mode 100644
index 00000000000..94b3be580c0
--- /dev/null
+++ b/srcpkgs/rocm-device-libs/template
@@ -0,0 +1,32 @@
+# Template file for 'rocm-device-libs'
+pkgname=rocm-device-libs
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="ROCm-Device-Libs-rocm-ocl-${version}"
+build_style=cmake
+configure_args="-DCMAKE_INSTALL_PREFIX:PATH=/opt/rocm -DLLVM_DIR:PATH=/opt/rocm/llvm"
+hostmakedepends="cmake rocm-llvm"
+short_desc="Radeon Open Compute device libraries"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute/ROCm-Device-Libs"
+distfiles="${homepage}/archive/rocm-ocl-${version}.tar.gz"
+checksum=706b08230790e08ca6a7a2fb7687d6131fd39a562148340e00fa37a6c06769c5
+nocross=yes
+
+pre_configure() {
+	# Build the prepare-builtins executable with native compiler
+	mkdir -p utils/build
+	cd utils/build
+	_prepare_builtins="$PWD/prepare-builtins/prepare-builtins"
+	cmake ${configure_args} ..
+	make ${makejobs}
+
+	# Add path to prepare-builtins for cmake
+	configure_args+=" -DPREPARE_BUILTINS='${_prepare_builtins}'"
+}
+
+post_install() {
+	vlicense LICENSE
+}

From 16b38b32c675039744b15a204116952d0e5e1b4e Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Mon, 13 Apr 2020 18:30:00 -0400
Subject: [PATCH 5/7] New package: rocm-comgr-3.3.0

---
 common/shlibs               |  1 +
 srcpkgs/rocm-comgr-devel    |  1 +
 srcpkgs/rocm-comgr/template | 34 ++++++++++++++++++++++++++++++++++
 3 files changed, 36 insertions(+)
 create mode 120000 srcpkgs/rocm-comgr-devel
 create mode 100644 srcpkgs/rocm-comgr/template

diff --git a/common/shlibs b/common/shlibs
index ec34c0df9fa..509755bd8b9 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3864,3 +3864,4 @@ libtagparser.so.9 tagparser-9.1.2_1
 libqtutilities.so.6 qtutilities-6.0.4_1
 libhsakmt.so.1 roct-thunk-interface-3.3.0_1
 libhsa-runtime64.so.1 rocr-runtime-3.3.0_1
+libamd_comgr.so.1 rocm-comgr-3.3.0_1
diff --git a/srcpkgs/rocm-comgr-devel b/srcpkgs/rocm-comgr-devel
new file mode 120000
index 00000000000..3f5ce255e07
--- /dev/null
+++ b/srcpkgs/rocm-comgr-devel
@@ -0,0 +1 @@
+rocm-comgr
\ No newline at end of file
diff --git a/srcpkgs/rocm-comgr/template b/srcpkgs/rocm-comgr/template
new file mode 100644
index 00000000000..4bbc930073c
--- /dev/null
+++ b/srcpkgs/rocm-comgr/template
@@ -0,0 +1,34 @@
+# Template file for 'rocm-comgr'
+pkgname=rocm-comgr
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="ROCm-CompilerSupport-rocm-${version}"
+build_wrksrc="lib/comgr"
+build_style=cmake
+configure_args="-DCMAKE_INSTALL_PREFIX:PATH=/opt/rocm
+	-DClang_DIR:PATH=/opt/rocm/llvm/lib/cmake/clang
+	-DCMAKE_INSTALL_RPATH:PATH='\$ORIGIN:\$ORIGIN/../lib'"
+hostmakedepends="cmake pkg-config rocm-llvm"
+makedepends="rocm-device-libs"
+short_desc="Radeon Open Compute Code Object Manager"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="BSD-3-Clause"
+homepage="https://github.com/RadeonOpenCompute/ROCm-CompilerSupport"
+distfiles="${homepage}/archive/rocm-${version}.tar.gz"
+checksum=01e2524e0f28ecd6f46c9720f279207de935d826b0172158792aa3ec86af9ca7
+nocross=yes
+
+post_install() {
+	vlicense LICENSE.txt
+}
+
+rocm-comgr-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove opt/rocm/include
+		vmove "opt/rocm/lib/*.so"
+		vmove opt/rocm/lib/cmake
+	}
+}

From 3bc326fbe2daf9696b569db28480d0823e6b7da6 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Fri, 17 Apr 2020 12:11:25 -0400
Subject: [PATCH 6/7] New package: rocminfo-3.3.0

---
 srcpkgs/rocminfo/template | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
 create mode 100644 srcpkgs/rocminfo/template

diff --git a/srcpkgs/rocminfo/template b/srcpkgs/rocminfo/template
new file mode 100644
index 00000000000..91128a766f3
--- /dev/null
+++ b/srcpkgs/rocminfo/template
@@ -0,0 +1,21 @@
+# Template file for 'rocminfo'
+pkgname=rocminfo
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="rocminfo-rocm-${version}"
+build_style=cmake
+configure_args="-DCMAKE_INSTALL_PREFIX:PATH=/opt/rocm -DROCM_DIR=/opt/rocm"
+hostmakedepends="cmake pkg-config"
+makedepends="rocr-runtime-devel"
+short_desc="Radeon Open Compute system information reporter"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute/rocminfo"
+distfiles="${homepage}/archive/rocm-${version}.tar.gz"
+checksum=e666f662c9e465aaabbbd0b109d87e017243cdf1a0898fabf5a90947bb3dbcd7
+nocross=yes
+
+post_install() {
+	vlicense License.txt
+}

From f4d87b23ea6c75d2e08faa8c23141fbb63af8994 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Tue, 14 Apr 2020 10:25:54 -0400
Subject: [PATCH 7/7] New package: rocm-opencl-runtime-3.3.0 [ci skip]

---
 common/shlibs                                 |   1 +
 srcpkgs/rocm-opencl-runtime-devel             |   1 +
 .../files/libelf-musl.patch                   | 688 ++++++++++++++++++
 .../files/runtime-musl.patch                  |  11 +
 srcpkgs/rocm-opencl-runtime/files/sys_queue.h | 574 +++++++++++++++
 .../rocm-opencl-runtime/patches/cmake.patch   | 123 ++++
 srcpkgs/rocm-opencl-runtime/template          |  78 ++
 7 files changed, 1476 insertions(+)
 create mode 120000 srcpkgs/rocm-opencl-runtime-devel
 create mode 100644 srcpkgs/rocm-opencl-runtime/files/libelf-musl.patch
 create mode 100644 srcpkgs/rocm-opencl-runtime/files/runtime-musl.patch
 create mode 100644 srcpkgs/rocm-opencl-runtime/files/sys_queue.h
 create mode 100644 srcpkgs/rocm-opencl-runtime/patches/cmake.patch
 create mode 100644 srcpkgs/rocm-opencl-runtime/template

diff --git a/common/shlibs b/common/shlibs
index 509755bd8b9..d087fa3ab4b 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3865,3 +3865,4 @@ libqtutilities.so.6 qtutilities-6.0.4_1
 libhsakmt.so.1 roct-thunk-interface-3.3.0_1
 libhsa-runtime64.so.1 rocr-runtime-3.3.0_1
 libamd_comgr.so.1 rocm-comgr-3.3.0_1
+libOpenCL-ROCm.so.1 rocm-opencl-runtime-3.3.0_1
diff --git a/srcpkgs/rocm-opencl-runtime-devel b/srcpkgs/rocm-opencl-runtime-devel
new file mode 120000
index 00000000000..b2cda7e229d
--- /dev/null
+++ b/srcpkgs/rocm-opencl-runtime-devel
@@ -0,0 +1 @@
+rocm-opencl-runtime
\ No newline at end of file
diff --git a/srcpkgs/rocm-opencl-runtime/files/libelf-musl.patch b/srcpkgs/rocm-opencl-runtime/files/libelf-musl.patch
new file mode 100644
index 00000000000..a3705c259a9
--- /dev/null
+++ b/srcpkgs/rocm-opencl-runtime/files/libelf-musl.patch
@@ -0,0 +1,688 @@
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/_libelf.h compiler/lib/loaders/elf/utils/libelf/_libelf.h
+--- compiler/lib/loaders/elf/utils/libelf.orig/_libelf.h	2020-04-19 08:59:34.201386585 -0400
++++ compiler/lib/loaders/elf/utils/libelf/_libelf.h	2020-04-19 09:04:12.950433528 -0400
+@@ -30,7 +30,7 @@
+ #define	__LIBELF_H_
+ 
+ #include <limits.h>
+-#include <sys/queue.h>
++#include "sys_queue.h"
+ 
+ #include "_libelf_config.h"
+ 
+@@ -179,7 +179,9 @@
+  * Function Prototypes.
+  */
+ 
+-__BEGIN_DECLS
++#ifdef __cplusplus
++extern "C" {
++#endif
+ Elf_Data *_libelf_allocate_data(Elf_Scn *_s);
+ Elf	*_libelf_allocate_elf(Elf_Mem *mem);
+ Elf_Scn	*_libelf_allocate_scn(Elf *_e, size_t _ndx);
+@@ -213,6 +215,8 @@
+ Elf_Data *_libelf_xlate(Elf_Data *_d, const Elf_Data *_s,
+     unsigned int _encoding, int _elfclass, int _direction);
+ int	_libelf_xlate_shtype(uint32_t _sht);
+-__END_DECLS
++#ifdef __cplusplus
++}
++#endif
+ 
+ #endif	/* __LIBELF_H_ */
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_begin.c compiler/lib/loaders/elf/utils/libelf/elf_begin.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_begin.c	2020-04-19 08:59:34.201386585 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_begin.c	2020-04-19 09:01:04.313212042 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <sys/types.h>
+ #if !defined(WIN32)
+ #include <sys/errno.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_end.c compiler/lib/loaders/elf/utils/libelf/elf_end.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_end.c	2020-04-19 08:59:34.201386585 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_end.c	2020-04-19 09:01:14.895204681 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #if !defined(WIN32)
+ #include <sys/mman.h>
+ #endif
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_errmsg.c compiler/lib/loaders/elf/utils/libelf/elf_errmsg.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_errmsg.c	2020-04-19 08:59:34.201386585 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_errmsg.c	2020-04-19 09:01:16.753207065 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ #include <stdio.h>
+ #include <string.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_errno.c compiler/lib/loaders/elf/utils/libelf/elf_errno.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_errno.c	2020-04-19 08:59:34.201386585 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_errno.c	2020-04-19 09:01:18.669209528 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_fill.c compiler/lib/loaders/elf/utils/libelf/elf_fill.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_fill.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_fill.c	2020-04-19 09:01:21.109212667 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_flag.c compiler/lib/loaders/elf/utils/libelf/elf_flag.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_flag.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_flag.c	2020-04-19 09:01:23.376215579 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_getarhdr.c compiler/lib/loaders/elf/utils/libelf/elf_getarhdr.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_getarhdr.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_getarhdr.c	2020-04-19 09:01:25.414218197 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_getarsym.c compiler/lib/loaders/elf/utils/libelf/elf_getarsym.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_getarsym.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_getarsym.c	2020-04-19 09:01:27.575220978 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_getbase.c compiler/lib/loaders/elf/utils/libelf/elf_getbase.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_getbase.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_getbase.c	2020-04-19 09:01:29.963224043 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_getident.c compiler/lib/loaders/elf/utils/libelf/elf_getident.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_getident.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_getident.c	2020-04-19 09:01:31.912226551 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <ar.h>
+ #include <assert.h>
+ #include <libelf.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_hash.c compiler/lib/loaders/elf/utils/libelf/elf_hash.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_hash.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_hash.c	2020-04-19 09:01:33.877229069 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ #include "_libelf_config.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_kind.c compiler/lib/loaders/elf/utils/libelf/elf_kind.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_kind.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_kind.c	2020-04-19 09:01:35.940231721 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_memory.c compiler/lib/loaders/elf/utils/libelf/elf_memory.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_memory.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_memory.c	2020-04-19 09:01:38.171234596 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <ar.h>
+ #include <libelf.h>
+ #include <string.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_next.c compiler/lib/loaders/elf/utils/libelf/elf_next.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_next.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_next.c	2020-04-19 09:01:40.063237028 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <ar.h>
+ #include <assert.h>
+ #include <libelf.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_phnum.c compiler/lib/loaders/elf/utils/libelf/elf_phnum.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_phnum.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_phnum.c	2020-04-19 09:01:42.480240134 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <ar.h>
+ #include <libelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_rand.c compiler/lib/loaders/elf/utils/libelf/elf_rand.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_rand.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_rand.c	2020-04-19 09:01:45.061243452 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <ar.h>
+ #include <libelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_rawfile.c compiler/lib/loaders/elf/utils/libelf/elf_rawfile.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_rawfile.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_rawfile.c	2020-04-19 09:01:46.988245928 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_scn.c compiler/lib/loaders/elf/utils/libelf/elf_scn.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_scn.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_scn.c	2020-04-19 09:00:19.724298403 -0400
+@@ -24,8 +24,7 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-#include <sys/queue.h>
++#include "sys_queue.h"
+ 
+ #include <assert.h>
+ #include <errno.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_shnum.c compiler/lib/loaders/elf/utils/libelf/elf_shnum.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_shnum.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_shnum.c	2020-04-19 09:01:51.763252060 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <ar.h>
+ #include <libelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_shstrndx.c compiler/lib/loaders/elf/utils/libelf/elf_shstrndx.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_shstrndx.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_shstrndx.c	2020-04-19 09:01:53.532254340 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <ar.h>
+ #include <libelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_version.c compiler/lib/loaders/elf/utils/libelf/elf_version.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_version.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_version.c	2020-04-19 09:02:01.337264370 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf.h compiler/lib/loaders/elf/utils/libelf/gelf.h
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf.h	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf.h	2020-04-19 09:04:29.669455020 -0400
+@@ -29,8 +29,6 @@
+ #ifndef	_GELF_H_
+ #define	_GELF_H_
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ typedef Elf64_Addr	GElf_Addr;	/* Addresses */
+@@ -72,7 +70,9 @@
+ #define	GELF_ST_TYPE			ELF64_ST_TYPE
+ #define	GELF_ST_VISIBILITY		ELF64_ST_VISIBILITY
+ 
+-__BEGIN_DECLS
++#ifdef __cplusplus
++extern "C" {
++#endif
+ long		gelf_checksum(Elf *_elf);
+ size_t		gelf_fsize(Elf *_elf, Elf_Type _type, size_t _count,
+ 			unsigned int _version);
+@@ -109,6 +109,8 @@
+ int		gelf_update_move(Elf_Data *_dst, int _index, GElf_Move *_src);
+ int		gelf_update_syminfo(Elf_Data *_dst, int _index, GElf_Syminfo *_src);
+ #endif
+-__END_DECLS
++#ifdef __cplusplus
++}
++#endif
+ 
+ #endif	/* _GELF_H_ */
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_cap.c compiler/lib/loaders/elf/utils/libelf/gelf_cap.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_cap.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_cap.c	2020-04-19 09:02:05.429269632 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_checksum.c compiler/lib/loaders/elf/utils/libelf/gelf_checksum.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_checksum.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_checksum.c	2020-04-19 09:02:08.192273183 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <gelf.h>
+ #include <libelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_dyn.c compiler/lib/loaders/elf/utils/libelf/gelf_dyn.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_dyn.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_dyn.c	2020-04-19 09:02:10.020275525 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_ehdr.c compiler/lib/loaders/elf/utils/libelf/gelf_ehdr.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_ehdr.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_ehdr.c	2020-04-19 09:02:11.882277926 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ #include <libelf.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_fsize.c compiler/lib/loaders/elf/utils/libelf/gelf_fsize.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_fsize.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_fsize.c	2020-04-19 09:02:14.139280827 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <gelf.h>
+ #include <libelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_getclass.c compiler/lib/loaders/elf/utils/libelf/gelf_getclass.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_getclass.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_getclass.c	2020-04-19 09:02:17.269284848 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <gelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_move.c compiler/lib/loaders/elf/utils/libelf/gelf_move.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_move.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_move.c	2020-04-19 09:02:18.974287034 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_phdr.c compiler/lib/loaders/elf/utils/libelf/gelf_phdr.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_phdr.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_phdr.c	2020-04-19 09:02:20.676289227 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <gelf.h>
+ #include <libelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_rel.c compiler/lib/loaders/elf/utils/libelf/gelf_rel.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_rel.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_rel.c	2020-04-19 09:02:23.177292435 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_rela.c compiler/lib/loaders/elf/utils/libelf/gelf_rela.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_rela.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_rela.c	2020-04-19 09:02:25.246295100 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_shdr.c compiler/lib/loaders/elf/utils/libelf/gelf_shdr.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_shdr.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_shdr.c	2020-04-19 09:02:28.325299060 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ #include <libelf.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_sym.c compiler/lib/loaders/elf/utils/libelf/gelf_sym.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_sym.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_sym.c	2020-04-19 09:02:30.113301356 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_syminfo.c compiler/lib/loaders/elf/utils/libelf/gelf_syminfo.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_syminfo.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_syminfo.c	2020-04-19 09:02:31.906303662 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_symshndx.c compiler/lib/loaders/elf/utils/libelf/gelf_symshndx.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_symshndx.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_symshndx.c	2020-04-19 09:02:33.626305873 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_xlate.c compiler/lib/loaders/elf/utils/libelf/gelf_xlate.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_xlate.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_xlate.c	2020-04-19 09:02:35.921308822 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <gelf.h>
+ #include <libelf.h>
+ #include <string.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf.h compiler/lib/loaders/elf/utils/libelf/libelf.h
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf.h	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf.h	2020-04-19 09:04:38.760466706 -0400
+@@ -30,7 +30,7 @@
+ #define	_LIBELF_H_
+ 
+ #include <sys/types.h>
+-#include <sys/queue.h>
++#include "sys_queue.h"
+ #include <elfdefinitions.h>
+ #ifndef EM_HSAIL
+ #define EM_HSAIL 0xAF5A
+@@ -187,7 +187,9 @@
+ #define	ELF_F_ARCHIVE	   0x100U /* archive creation */
+ #define	ELF_F_ARCHIVE_SYSV 0x200U /* SYSV style archive */
+ 
+-__BEGIN_DECLS
++#ifdef __cplusplus
++extern "C" {
++#endif
+ Elf		*elf_begin(int _fd, Elf_Cmd _cmd, Elf *_elf, Elf_Mem *_mem);
+ int		elf_cntl(Elf *_elf, Elf_Cmd _cmd);
+ int		elf_end(Elf *_elf);
+@@ -257,6 +259,8 @@
+ 			unsigned int _enc);
+ Elf_Data	*elf64_xlatetom(Elf_Data *_dst, const Elf_Data *_src,
+ 			unsigned int _enc);
+-__END_DECLS
++#ifdef __cplusplus
++}
++#endif
+ 
+ #endif	/* _LIBELF_H_ */
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_align.c compiler/lib/loaders/elf/utils/libelf/libelf_align.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_align.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_align.c	2020-04-19 09:02:40.660314911 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <sys/types.h>
+ 
+ #include <libelf.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_allocate.c compiler/lib/loaders/elf/utils/libelf/libelf_allocate.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_allocate.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_allocate.c	2020-04-19 09:02:43.079318019 -0400
+@@ -28,8 +28,6 @@
+  * Internal APIs
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #if !defined(WIN32)
+ #include <sys/errno.h>
+ #endif
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_ar.c compiler/lib/loaders/elf/utils/libelf/libelf_ar.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_ar.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_ar.c	2020-04-19 09:02:44.763320187 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <ctype.h>
+ #include <libelf.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_ar_util.c compiler/lib/loaders/elf/utils/libelf/libelf_ar_util.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_ar_util.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_ar_util.c	2020-04-19 09:02:46.461322369 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <libelf.h>
+ #include <stdlib.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_checksum.c compiler/lib/loaders/elf/utils/libelf/libelf_checksum.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_checksum.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_checksum.c	2020-04-19 09:02:48.645325173 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <gelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_convert.c compiler/lib/loaders/elf/utils/libelf/libelf_convert.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_convert.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_convert.c	2020-04-19 09:02:50.883328053 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <libelf.h>
+ #include <string.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_data.c compiler/lib/loaders/elf/utils/libelf/libelf_data.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_data.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_data.c	2020-04-19 09:02:52.951330708 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_ehdr.c compiler/lib/loaders/elf/utils/libelf/libelf_ehdr.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_ehdr.c	2020-04-19 08:59:34.204386579 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_ehdr.c	2020-04-19 09:02:55.176333563 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ #include <libelf.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_extended.c compiler/lib/loaders/elf/utils/libelf/libelf_extended.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_extended.c	2020-04-19 08:59:34.204386579 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_extended.c	2020-04-19 09:02:57.932337110 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <libelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_msize.c compiler/lib/loaders/elf/utils/libelf/libelf_msize.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_msize.c	2020-04-19 08:59:34.204386579 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_msize.c	2020-04-19 09:03:02.201342598 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <libelf.h>
+ #include <string.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_phdr.c compiler/lib/loaders/elf/utils/libelf/libelf_phdr.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_phdr.c	2020-04-19 08:59:34.204386579 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_phdr.c	2020-04-19 09:03:04.194345160 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ #include <libelf.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_shdr.c compiler/lib/loaders/elf/utils/libelf/libelf_shdr.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_shdr.c	2020-04-19 08:59:34.204386579 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_shdr.c	2020-04-19 09:03:05.795347218 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <gelf.h>
+ #include <libelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_xlate.c compiler/lib/loaders/elf/utils/libelf/libelf_xlate.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_xlate.c	2020-04-19 08:59:34.204386579 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_xlate.c	2020-04-19 09:03:09.472351944 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <libelf.h>
+ 
diff --git a/srcpkgs/rocm-opencl-runtime/files/runtime-musl.patch b/srcpkgs/rocm-opencl-runtime/files/runtime-musl.patch
new file mode 100644
index 00000000000..ea18e90e09c
--- /dev/null
+++ b/srcpkgs/rocm-opencl-runtime/files/runtime-musl.patch
@@ -0,0 +1,11 @@
+--- runtime/os/os_posix.cpp.orig	2020-04-19 09:13:51.701982901 -0400
++++ runtime/os/os_posix.cpp	2020-04-19 09:14:04.156947422 -0400
+@@ -44,6 +44,8 @@
+ #include <algorithm>
+ #include <mutex>
+ 
++#include <libgen.h> // for basename
++
+ 
+ namespace amd {
+ 
diff --git a/srcpkgs/rocm-opencl-runtime/files/sys_queue.h b/srcpkgs/rocm-opencl-runtime/files/sys_queue.h
new file mode 100644
index 00000000000..daf4553d33e
--- /dev/null
+++ b/srcpkgs/rocm-opencl-runtime/files/sys_queue.h
@@ -0,0 +1,574 @@
+/*
+ * Copyright (c) 1991, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *	@(#)queue.h	8.5 (Berkeley) 8/20/94
+ */
+
+#ifndef	_SYS_QUEUE_H_
+#define	_SYS_QUEUE_H_
+
+/*
+ * This file defines five types of data structures: singly-linked lists,
+ * lists, simple queues, tail queues, and circular queues.
+ *
+ * A singly-linked list is headed by a single forward pointer. The
+ * elements are singly linked for minimum space and pointer manipulation
+ * overhead at the expense of O(n) removal for arbitrary elements. New
+ * elements can be added to the list after an existing element or at the
+ * head of the list.  Elements being removed from the head of the list
+ * should use the explicit macro for this purpose for optimum
+ * efficiency. A singly-linked list may only be traversed in the forward
+ * direction.  Singly-linked lists are ideal for applications with large
+ * datasets and few or no removals or for implementing a LIFO queue.
+ *
+ * A list is headed by a single forward pointer (or an array of forward
+ * pointers for a hash table header). The elements are doubly linked
+ * so that an arbitrary element can be removed without a need to
+ * traverse the list. New elements can be added to the list before
+ * or after an existing element or at the head of the list. A list
+ * may only be traversed in the forward direction.
+ *
+ * A simple queue is headed by a pair of pointers, one the head of the
+ * list and the other to the tail of the list. The elements are singly
+ * linked to save space, so elements can only be removed from the
+ * head of the list. New elements can be added to the list after
+ * an existing element, at the head of the list, or at the end of the
+ * list. A simple queue may only be traversed in the forward direction.
+ *
+ * A tail queue is headed by a pair of pointers, one to the head of the
+ * list and the other to the tail of the list. The elements are doubly
+ * linked so that an arbitrary element can be removed without a need to
+ * traverse the list. New elements can be added to the list before or
+ * after an existing element, at the head of the list, or at the end of
+ * the list. A tail queue may be traversed in either direction.
+ *
+ * A circle queue is headed by a pair of pointers, one to the head of the
+ * list and the other to the tail of the list. The elements are doubly
+ * linked so that an arbitrary element can be removed without a need to
+ * traverse the list. New elements can be added to the list before or after
+ * an existing element, at the head of the list, or at the end of the list.
+ * A circle queue may be traversed in either direction, but has a more
+ * complex end of list detection.
+ *
+ * For details on the use of these macros, see the queue(3) manual page.
+ */
+
+/*
+ * List definitions.
+ */
+#define	LIST_HEAD(name, type)						\
+struct name {								\
+	struct type *lh_first;	/* first element */			\
+}
+
+#define	LIST_HEAD_INITIALIZER(head)					\
+	{ NULL }
+
+#define	LIST_ENTRY(type)						\
+struct {								\
+	struct type *le_next;	/* next element */			\
+	struct type **le_prev;	/* address of previous next element */	\
+}
+
+/*
+ * List functions.
+ */
+#define	LIST_INIT(head) do {						\
+	(head)->lh_first = NULL;					\
+} while (/*CONSTCOND*/0)
+
+#define	LIST_INSERT_AFTER(listelm, elm, field) do {			\
+	if (((elm)->field.le_next = (listelm)->field.le_next) != NULL)	\
+		(listelm)->field.le_next->field.le_prev =		\
+		    &(elm)->field.le_next;				\
+	(listelm)->field.le_next = (elm);				\
+	(elm)->field.le_prev = &(listelm)->field.le_next;		\
+} while (/*CONSTCOND*/0)
+
+#define	LIST_INSERT_BEFORE(listelm, elm, field) do {			\
+	(elm)->field.le_prev = (listelm)->field.le_prev;		\
+	(elm)->field.le_next = (listelm);				\
+	*(listelm)->field.le_prev = (elm);				\
+	(listelm)->field.le_prev = &(elm)->field.le_next;		\
+} while (/*CONSTCOND*/0)
+
+#define	LIST_INSERT_HEAD(head, elm, field) do {				\
+	if (((elm)->field.le_next = (head)->lh_first) != NULL)		\
+		(head)->lh_first->field.le_prev = &(elm)->field.le_next;\
+	(head)->lh_first = (elm);					\
+	(elm)->field.le_prev = &(head)->lh_first;			\
+} while (/*CONSTCOND*/0)
+
+#define	LIST_REMOVE(elm, field) do {					\
+	if ((elm)->field.le_next != NULL)				\
+		(elm)->field.le_next->field.le_prev = 			\
+		    (elm)->field.le_prev;				\
+	*(elm)->field.le_prev = (elm)->field.le_next;			\
+} while (/*CONSTCOND*/0)
+
+#define	LIST_FOREACH(var, head, field)					\
+	for ((var) = ((head)->lh_first);				\
+		(var);							\
+		(var) = ((var)->field.le_next))
+
+/*
+ * List access methods.
+ */
+#define	LIST_EMPTY(head)		((head)->lh_first == NULL)
+#define	LIST_FIRST(head)		((head)->lh_first)
+#define	LIST_NEXT(elm, field)		((elm)->field.le_next)
+
+
+/*
+ * Singly-linked List definitions.
+ */
+#define	SLIST_HEAD(name, type)						\
+struct name {								\
+	struct type *slh_first;	/* first element */			\
+}
+
+#define	SLIST_HEAD_INITIALIZER(head)					\
+	{ NULL }
+
+#define	SLIST_ENTRY(type)						\
+struct {								\
+	struct type *sle_next;	/* next element */			\
+}
+
+/*
+ * Singly-linked List functions.
+ */
+#define	SLIST_INIT(head) do {						\
+	(head)->slh_first = NULL;					\
+} while (/*CONSTCOND*/0)
+
+#define	SLIST_INSERT_AFTER(slistelm, elm, field) do {			\
+	(elm)->field.sle_next = (slistelm)->field.sle_next;		\
+	(slistelm)->field.sle_next = (elm);				\
+} while (/*CONSTCOND*/0)
+
+#define	SLIST_INSERT_HEAD(head, elm, field) do {			\
+	(elm)->field.sle_next = (head)->slh_first;			\
+	(head)->slh_first = (elm);					\
+} while (/*CONSTCOND*/0)
+
+#define	SLIST_REMOVE_HEAD(head, field) do {				\
+	(head)->slh_first = (head)->slh_first->field.sle_next;		\
+} while (/*CONSTCOND*/0)
+
+#define	SLIST_REMOVE(head, elm, type, field) do {			\
+	if ((head)->slh_first == (elm)) {				\
+		SLIST_REMOVE_HEAD((head), field);			\
+	}								\
+	else {								\
+		struct type *curelm = (head)->slh_first;		\
+		while(curelm->field.sle_next != (elm))			\
+			curelm = curelm->field.sle_next;		\
+		curelm->field.sle_next =				\
+		    curelm->field.sle_next->field.sle_next;		\
+	}								\
+} while (/*CONSTCOND*/0)
+
+#define	SLIST_FOREACH(var, head, field)					\
+	for((var) = (head)->slh_first; (var); (var) = (var)->field.sle_next)
+
+/*
+ * Singly-linked List access methods.
+ */
+#define	SLIST_EMPTY(head)	((head)->slh_first == NULL)
+#define	SLIST_FIRST(head)	((head)->slh_first)
+#define	SLIST_NEXT(elm, field)	((elm)->field.sle_next)
+
+
+/*
+ * Singly-linked Tail queue declarations.
+ */
+#define	STAILQ_HEAD(name, type)					\
+struct name {								\
+	struct type *stqh_first;	/* first element */			\
+	struct type **stqh_last;	/* addr of last next element */		\
+}
+
+#define	STAILQ_HEAD_INITIALIZER(head)					\
+	{ NULL, &(head).stqh_first }
+
+#define	STAILQ_ENTRY(type)						\
+struct {								\
+	struct type *stqe_next;	/* next element */			\
+}
+
+/*
+ * Singly-linked Tail queue functions.
+ */
+#define	STAILQ_INIT(head) do {						\
+	(head)->stqh_first = NULL;					\
+	(head)->stqh_last = &(head)->stqh_first;				\
+} while (/*CONSTCOND*/0)
+
+#define	STAILQ_INSERT_HEAD(head, elm, field) do {			\
+	if (((elm)->field.stqe_next = (head)->stqh_first) == NULL)	\
+		(head)->stqh_last = &(elm)->field.stqe_next;		\
+	(head)->stqh_first = (elm);					\
+} while (/*CONSTCOND*/0)
+
+#define	STAILQ_INSERT_TAIL(head, elm, field) do {			\
+	(elm)->field.stqe_next = NULL;					\
+	*(head)->stqh_last = (elm);					\
+	(head)->stqh_last = &(elm)->field.stqe_next;			\
+} while (/*CONSTCOND*/0)
+
+#define	STAILQ_INSERT_AFTER(head, listelm, elm, field) do {		\
+	if (((elm)->field.stqe_next = (listelm)->field.stqe_next) == NULL)\
+		(head)->stqh_last = &(elm)->field.stqe_next;		\
+	(listelm)->field.stqe_next = (elm);				\
+} while (/*CONSTCOND*/0)
+
+#define	STAILQ_REMOVE_HEAD(head, field) do {				\
+	if (((head)->stqh_first = (head)->stqh_first->field.stqe_next) == NULL) \
+		(head)->stqh_last = &(head)->stqh_first;			\
+} while (/*CONSTCOND*/0)
+
+#define	STAILQ_REMOVE(head, elm, type, field) do {			\
+	if ((head)->stqh_first == (elm)) {				\
+		STAILQ_REMOVE_HEAD((head), field);			\
+	} else {							\
+		struct type *curelm = (head)->stqh_first;		\
+		while (curelm->field.stqe_next != (elm))			\
+			curelm = curelm->field.stqe_next;		\
+		if ((curelm->field.stqe_next =				\
+			curelm->field.stqe_next->field.stqe_next) == NULL) \
+			    (head)->stqh_last = &(curelm)->field.stqe_next; \
+	}								\
+} while (/*CONSTCOND*/0)
+
+#define	STAILQ_FOREACH(var, head, field)				\
+	for ((var) = ((head)->stqh_first);				\
+		(var);							\
+		(var) = ((var)->field.stqe_next))
+
+#define	STAILQ_CONCAT(head1, head2) do {				\
+	if (!STAILQ_EMPTY((head2))) {					\
+		*(head1)->stqh_last = (head2)->stqh_first;		\
+		(head1)->stqh_last = (head2)->stqh_last;		\
+		STAILQ_INIT((head2));					\
+	}								\
+} while (/*CONSTCOND*/0)
+
+/*
+ * Singly-linked Tail queue access methods.
+ */
+#define	STAILQ_EMPTY(head)	((head)->stqh_first == NULL)
+#define	STAILQ_FIRST(head)	((head)->stqh_first)
+#define	STAILQ_NEXT(elm, field)	((elm)->field.stqe_next)
+
+
+/*
+ * Simple queue definitions.
+ */
+#define	SIMPLEQ_HEAD(name, type)					\
+struct name {								\
+	struct type *sqh_first;	/* first element */			\
+	struct type **sqh_last;	/* addr of last next element */		\
+}
+
+#define	SIMPLEQ_HEAD_INITIALIZER(head)					\
+	{ NULL, &(head).sqh_first }
+
+#define	SIMPLEQ_ENTRY(type)						\
+struct {								\
+	struct type *sqe_next;	/* next element */			\
+}
+
+/*
+ * Simple queue functions.
+ */
+#define	SIMPLEQ_INIT(head) do {						\
+	(head)->sqh_first = NULL;					\
+	(head)->sqh_last = &(head)->sqh_first;				\
+} while (/*CONSTCOND*/0)
+
+#define	SIMPLEQ_INSERT_HEAD(head, elm, field) do {			\
+	if (((elm)->field.sqe_next = (head)->sqh_first) == NULL)	\
+		(head)->sqh_last = &(elm)->field.sqe_next;		\
+	(head)->sqh_first = (elm);					\
+} while (/*CONSTCOND*/0)
+
+#define	SIMPLEQ_INSERT_TAIL(head, elm, field) do {			\
+	(elm)->field.sqe_next = NULL;					\
+	*(head)->sqh_last = (elm);					\
+	(head)->sqh_last = &(elm)->field.sqe_next;			\
+} while (/*CONSTCOND*/0)
+
+#define	SIMPLEQ_INSERT_AFTER(head, listelm, elm, field) do {		\
+	if (((elm)->field.sqe_next = (listelm)->field.sqe_next) == NULL)\
+		(head)->sqh_last = &(elm)->field.sqe_next;		\
+	(listelm)->field.sqe_next = (elm);				\
+} while (/*CONSTCOND*/0)
+
+#define	SIMPLEQ_REMOVE_HEAD(head, field) do {				\
+	if (((head)->sqh_first = (head)->sqh_first->field.sqe_next) == NULL) \
+		(head)->sqh_last = &(head)->sqh_first;			\
+} while (/*CONSTCOND*/0)
+
+#define	SIMPLEQ_REMOVE(head, elm, type, field) do {			\
+	if ((head)->sqh_first == (elm)) {				\
+		SIMPLEQ_REMOVE_HEAD((head), field);			\
+	} else {							\
+		struct type *curelm = (head)->sqh_first;		\
+		while (curelm->field.sqe_next != (elm))			\
+			curelm = curelm->field.sqe_next;		\
+		if ((curelm->field.sqe_next =				\
+			curelm->field.sqe_next->field.sqe_next) == NULL) \
+			    (head)->sqh_last = &(curelm)->field.sqe_next; \
+	}								\
+} while (/*CONSTCOND*/0)
+
+#define	SIMPLEQ_FOREACH(var, head, field)				\
+	for ((var) = ((head)->sqh_first);				\
+		(var);							\
+		(var) = ((var)->field.sqe_next))
+
+/*
+ * Simple queue access methods.
+ */
+#define	SIMPLEQ_EMPTY(head)		((head)->sqh_first == NULL)
+#define	SIMPLEQ_FIRST(head)		((head)->sqh_first)
+#define	SIMPLEQ_NEXT(elm, field)	((elm)->field.sqe_next)
+
+
+/*
+ * Tail queue definitions.
+ */
+#define	_TAILQ_HEAD(name, type, qual)					\
+struct name {								\
+	qual type *tqh_first;		/* first element */		\
+	qual type *qual *tqh_last;	/* addr of last next element */	\
+}
+#define TAILQ_HEAD(name, type)	_TAILQ_HEAD(name, struct type,)
+
+#define	TAILQ_HEAD_INITIALIZER(head)					\
+	{ NULL, &(head).tqh_first }
+
+#define	_TAILQ_ENTRY(type, qual)					\
+struct {								\
+	qual type *tqe_next;		/* next element */		\
+	qual type *qual *tqe_prev;	/* address of previous next element */\
+}
+#define TAILQ_ENTRY(type)	_TAILQ_ENTRY(struct type,)
+
+/*
+ * Tail queue functions.
+ */
+#define	TAILQ_INIT(head) do {						\
+	(head)->tqh_first = NULL;					\
+	(head)->tqh_last = &(head)->tqh_first;				\
+} while (/*CONSTCOND*/0)
+
+#define	TAILQ_INSERT_HEAD(head, elm, field) do {			\
+	if (((elm)->field.tqe_next = (head)->tqh_first) != NULL)	\
+		(head)->tqh_first->field.tqe_prev =			\
+		    &(elm)->field.tqe_next;				\
+	else								\
+		(head)->tqh_last = &(elm)->field.tqe_next;		\
+	(head)->tqh_first = (elm);					\
+	(elm)->field.tqe_prev = &(head)->tqh_first;			\
+} while (/*CONSTCOND*/0)
+
+#define	TAILQ_INSERT_TAIL(head, elm, field) do {			\
+	(elm)->field.tqe_next = NULL;					\
+	(elm)->field.tqe_prev = (head)->tqh_last;			\
+	*(head)->tqh_last = (elm);					\
+	(head)->tqh_last = &(elm)->field.tqe_next;			\
+} while (/*CONSTCOND*/0)
+
+#define	TAILQ_INSERT_AFTER(head, listelm, elm, field) do {		\
+	if (((elm)->field.tqe_next = (listelm)->field.tqe_next) != NULL)\
+		(elm)->field.tqe_next->field.tqe_prev = 		\
+		    &(elm)->field.tqe_next;				\
+	else								\
+		(head)->tqh_last = &(elm)->field.tqe_next;		\
+	(listelm)->field.tqe_next = (elm);				\
+	(elm)->field.tqe_prev = &(listelm)->field.tqe_next;		\
+} while (/*CONSTCOND*/0)
+
+#define	TAILQ_INSERT_BEFORE(listelm, elm, field) do {			\
+	(elm)->field.tqe_prev = (listelm)->field.tqe_prev;		\
+	(elm)->field.tqe_next = (listelm);				\
+	*(listelm)->field.tqe_prev = (elm);				\
+	(listelm)->field.tqe_prev = &(elm)->field.tqe_next;		\
+} while (/*CONSTCOND*/0)
+
+#define	TAILQ_REMOVE(head, elm, field) do {				\
+	if (((elm)->field.tqe_next) != NULL)				\
+		(elm)->field.tqe_next->field.tqe_prev = 		\
+		    (elm)->field.tqe_prev;				\
+	else								\
+		(head)->tqh_last = (elm)->field.tqe_prev;		\
+	*(elm)->field.tqe_prev = (elm)->field.tqe_next;			\
+} while (/*CONSTCOND*/0)
+
+#define	TAILQ_FOREACH(var, head, field)					\
+	for ((var) = ((head)->tqh_first);				\
+		(var);							\
+		(var) = ((var)->field.tqe_next))
+
+#define	TAILQ_FOREACH_REVERSE(var, head, headname, field)		\
+	for ((var) = (*(((struct headname *)((head)->tqh_last))->tqh_last));	\
+		(var);							\
+		(var) = (*(((struct headname *)((var)->field.tqe_prev))->tqh_last)))
+
+#define	TAILQ_CONCAT(head1, head2, field) do {				\
+	if (!TAILQ_EMPTY(head2)) {					\
+		*(head1)->tqh_last = (head2)->tqh_first;		\
+		(head2)->tqh_first->field.tqe_prev = (head1)->tqh_last;	\
+		(head1)->tqh_last = (head2)->tqh_last;			\
+		TAILQ_INIT((head2));					\
+	}								\
+} while (/*CONSTCOND*/0)
+
+/*
+ * Tail queue access methods.
+ */
+#define	TAILQ_EMPTY(head)		((head)->tqh_first == NULL)
+#define	TAILQ_FIRST(head)		((head)->tqh_first)
+#define	TAILQ_NEXT(elm, field)		((elm)->field.tqe_next)
+
+#define	TAILQ_LAST(head, headname) \
+	(*(((struct headname *)((head)->tqh_last))->tqh_last))
+#define	TAILQ_PREV(elm, headname, field) \
+	(*(((struct headname *)((elm)->field.tqe_prev))->tqh_last))
+
+
+/*
+ * Circular queue definitions.
+ */
+#define	CIRCLEQ_HEAD(name, type)					\
+struct name {								\
+	struct type *cqh_first;		/* first element */		\
+	struct type *cqh_last;		/* last element */		\
+}
+
+#define	CIRCLEQ_HEAD_INITIALIZER(head)					\
+	{ (void *)&head, (void *)&head }
+
+#define	CIRCLEQ_ENTRY(type)						\
+struct {								\
+	struct type *cqe_next;		/* next element */		\
+	struct type *cqe_prev;		/* previous element */		\
+}
+
+/*
+ * Circular queue functions.
+ */
+#define	CIRCLEQ_INIT(head) do {						\
+	(head)->cqh_first = (void *)(head);				\
+	(head)->cqh_last = (void *)(head);				\
+} while (/*CONSTCOND*/0)
+
+#define	CIRCLEQ_INSERT_AFTER(head, listelm, elm, field) do {		\
+	(elm)->field.cqe_next = (listelm)->field.cqe_next;		\
+	(elm)->field.cqe_prev = (listelm);				\
+	if ((listelm)->field.cqe_next == (void *)(head))		\
+		(head)->cqh_last = (elm);				\
+	else								\
+		(listelm)->field.cqe_next->field.cqe_prev = (elm);	\
+	(listelm)->field.cqe_next = (elm);				\
+} while (/*CONSTCOND*/0)
+
+#define	CIRCLEQ_INSERT_BEFORE(head, listelm, elm, field) do {		\
+	(elm)->field.cqe_next = (listelm);				\
+	(elm)->field.cqe_prev = (listelm)->field.cqe_prev;		\
+	if ((listelm)->field.cqe_prev == (void *)(head))		\
+		(head)->cqh_first = (elm);				\
+	else								\
+		(listelm)->field.cqe_prev->field.cqe_next = (elm);	\
+	(listelm)->field.cqe_prev = (elm);				\
+} while (/*CONSTCOND*/0)
+
+#define	CIRCLEQ_INSERT_HEAD(head, elm, field) do {			\
+	(elm)->field.cqe_next = (head)->cqh_first;			\
+	(elm)->field.cqe_prev = (void *)(head);				\
+	if ((head)->cqh_last == (void *)(head))				\
+		(head)->cqh_last = (elm);				\
+	else								\
+		(head)->cqh_first->field.cqe_prev = (elm);		\
+	(head)->cqh_first = (elm);					\
+} while (/*CONSTCOND*/0)
+
+#define	CIRCLEQ_INSERT_TAIL(head, elm, field) do {			\
+	(elm)->field.cqe_next = (void *)(head);				\
+	(elm)->field.cqe_prev = (head)->cqh_last;			\
+	if ((head)->cqh_first == (void *)(head))			\
+		(head)->cqh_first = (elm);				\
+	else								\
+		(head)->cqh_last->field.cqe_next = (elm);		\
+	(head)->cqh_last = (elm);					\
+} while (/*CONSTCOND*/0)
+
+#define	CIRCLEQ_REMOVE(head, elm, field) do {				\
+	if ((elm)->field.cqe_next == (void *)(head))			\
+		(head)->cqh_last = (elm)->field.cqe_prev;		\
+	else								\
+		(elm)->field.cqe_next->field.cqe_prev =			\
+		    (elm)->field.cqe_prev;				\
+	if ((elm)->field.cqe_prev == (void *)(head))			\
+		(head)->cqh_first = (elm)->field.cqe_next;		\
+	else								\
+		(elm)->field.cqe_prev->field.cqe_next =			\
+		    (elm)->field.cqe_next;				\
+} while (/*CONSTCOND*/0)
+
+#define	CIRCLEQ_FOREACH(var, head, field)				\
+	for ((var) = ((head)->cqh_first);				\
+		(var) != (const void *)(head);				\
+		(var) = ((var)->field.cqe_next))
+
+#define	CIRCLEQ_FOREACH_REVERSE(var, head, field)			\
+	for ((var) = ((head)->cqh_last);				\
+		(var) != (const void *)(head);				\
+		(var) = ((var)->field.cqe_prev))
+
+/*
+ * Circular queue access methods.
+ */
+#define	CIRCLEQ_EMPTY(head)		((head)->cqh_first == (void *)(head))
+#define	CIRCLEQ_FIRST(head)		((head)->cqh_first)
+#define	CIRCLEQ_LAST(head)		((head)->cqh_last)
+#define	CIRCLEQ_NEXT(elm, field)	((elm)->field.cqe_next)
+#define	CIRCLEQ_PREV(elm, field)	((elm)->field.cqe_prev)
+
+#define CIRCLEQ_LOOP_NEXT(head, elm, field)				\
+	(((elm)->field.cqe_next == (void *)(head))			\
+	    ? ((head)->cqh_first)					\
+	    : (elm->field.cqe_next))
+#define CIRCLEQ_LOOP_PREV(head, elm, field)				\
+	(((elm)->field.cqe_prev == (void *)(head))			\
+	    ? ((head)->cqh_last)					\
+	    : (elm->field.cqe_prev))
+
+#endif	/* sys/queue.h */
diff --git a/srcpkgs/rocm-opencl-runtime/patches/cmake.patch b/srcpkgs/rocm-opencl-runtime/patches/cmake.patch
new file mode 100644
index 00000000000..2b3354f3eeb
--- /dev/null
+++ b/srcpkgs/rocm-opencl-runtime/patches/cmake.patch
@@ -0,0 +1,123 @@
+diff -u -r ../original/OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/CMakeLists.txt ./OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/CMakeLists.txt
+--- OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/CMakeLists.txt	2019-09-10 11:53:28.000000000 -0400
++++ OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/CMakeLists.txt	2020-04-16 20:16:13.481180757 -0400
+@@ -73,11 +73,11 @@
+ 
+ set (OPENCL_ICD_LOADER_HEADERS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/inc CACHE PATH "Path to OpenCL Headers")
+ 
+-add_library (OpenCL ${OPENCL_ICD_LOADER_SOURCES})
+-set_target_properties (OpenCL PROPERTIES VERSION "1.2" SOVERSION "1")
++add_library (OpenCL-ROCm ${OPENCL_ICD_LOADER_SOURCES})
++set_target_properties (OpenCL-ROCm PROPERTIES VERSION "1.2" SOVERSION "1")
+ 
+ if (WIN32)
+-    target_link_libraries (OpenCL cfgmgr32.lib)
++    target_link_libraries (OpenCL-ROCm cfgmgr32.lib)
+ 
+     option (OPENCL_ICD_LOADER_REQUIRE_WDK "Build with D3DKMT support, which requires the Windows WDK." ON)
+     if (OPENCL_ICD_LOADER_REQUIRE_WDK)
+@@ -92,10 +92,10 @@
+             get_filename_component(WDK_DIRECTORY ${LATEST_D3DKMT_HEADER} DIRECTORY)
+             get_filename_component(WDK_DIRECTORY ${WDK_DIRECTORY} DIRECTORY)
+             message(STATUS "Found the Windows WDK in: ${WDK_DIRECTORY}")
+-            target_compile_definitions(OpenCL PRIVATE OPENCL_ICD_LOADER_REQUIRE_WDK)
+-            target_include_directories(OpenCL PRIVATE ${WDK_DIRECTORY}/um)
+-            target_include_directories(OpenCL PRIVATE ${WDK_DIRECTORY}/km)
+-            target_include_directories(OpenCL PRIVATE ${WDK_DIRECTORY}/shared)
++	    target_compile_definitions(OpenCL-ROCm PRIVATE OPENCL_ICD_LOADER_REQUIRE_WDK)
++	    target_include_directories(OpenCL-ROCm PRIVATE ${WDK_DIRECTORY}/um)
++	    target_include_directories(OpenCL-ROCm PRIVATE ${WDK_DIRECTORY}/km)
++	    target_include_directories(OpenCL-ROCm PRIVATE ${WDK_DIRECTORY}/shared)
+         else()
+             message(FATAL_ERROR "The Windows WDK was not found. Consider disabling OPENCL_ICD_LOADER_REQUIRE_WDK. Aborting.")
+         endif()
+@@ -113,25 +113,25 @@
+     endif()
+ else()
+     if (APPLE)
+-        target_link_libraries (OpenCL ${CMAKE_THREAD_LIBS_INIT})
++        target_link_libraries (OpenCL-ROCm ${CMAKE_THREAD_LIBS_INIT})
+     else ()
+-        set_target_properties (OpenCL PROPERTIES LINK_FLAGS "-Wl,--version-script -Wl,${CMAKE_CURRENT_SOURCE_DIR}/loader/linux/icd_exports.map")
+-        target_link_libraries (OpenCL ${CMAKE_THREAD_LIBS_INIT})
++        set_target_properties (OpenCL-ROCm PROPERTIES LINK_FLAGS "-Wl,--version-script -Wl,${CMAKE_CURRENT_SOURCE_DIR}/loader/linux/icd_exports.map")
++	target_link_libraries (OpenCL-ROCm ${CMAKE_THREAD_LIBS_INIT})
+     endif ()
+ endif ()
+ 
+ include_directories (${OPENCL_ICD_LOADER_HEADERS_DIR})
+ add_definitions (-DCL_TARGET_OPENCL_VERSION=220)
+ 
+-target_include_directories (OpenCL PRIVATE ${CMAKE_CURRENT_BINARY_DIR} loader)
+-target_link_libraries (OpenCL ${CMAKE_DL_LIBS})
++target_include_directories (OpenCL-ROCm PRIVATE ${CMAKE_CURRENT_BINARY_DIR} loader)
++target_link_libraries (OpenCL-ROCm ${CMAKE_DL_LIBS})
+ 
+ include (CTest)
+ if (BUILD_TESTING)
+     add_subdirectory (test)
+ endif()
+ 
+-install (TARGETS OpenCL
++install (TARGETS OpenCL-ROCm
+     RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+     ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
+     LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
+diff -u -r ../original/OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/test/loader_test/CMakeLists.txt ./OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/test/loader_test/CMakeLists.txt
+--- OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/test/loader_test/CMakeLists.txt	2019-09-10 11:53:28.000000000 -0400
++++ OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/test/loader_test/CMakeLists.txt	2020-04-16 20:16:56.647026589 -0400
+@@ -12,4 +12,4 @@
+     test_clgl.c
+     test_image_objects.c )
+ 
+-target_link_libraries (icd_loader_test OpenCL IcdLog)
++target_link_libraries (icd_loader_test OpenCL-ROCm IcdLog)
+diff -u -r ../original/ROCm-OpenCL-Runtime-roc-3.3.0/CMakeLists.txt ./ROCm-OpenCL-Runtime-roc-3.3.0/CMakeLists.txt
+--- ROCm-OpenCL-Runtime-roc-3.3.0/CMakeLists.txt	2020-04-18 20:16:13.452670818 -0400
++++ ROCm-OpenCL-Runtime-roc-3.3.0/CMakeLists.txt	2020-04-18 20:20:09.798862321 -0400
+@@ -102,16 +102,16 @@
+ 
+ # MAIN package
+ install(PROGRAMS $<TARGET_FILE:clinfo>
+-        DESTINATION bin/x86_64
++        DESTINATION bin
+         COMPONENT MAIN)
+ install(PROGRAMS $<TARGET_FILE:amdocl64>
+-        DESTINATION lib/x86_64
++        DESTINATION lib
+         COMPONENT MAIN)
+-install(PROGRAMS $<TARGET_FILE:OpenCL>
+-        DESTINATION lib/x86_64
++install(PROGRAMS $<TARGET_FILE:OpenCL-ROCm>
++        DESTINATION lib
+         COMPONENT MAIN)
+-install(PROGRAMS $<TARGET_SONAME_FILE:OpenCL>
+-        DESTINATION lib/x86_64
++install(PROGRAMS $<TARGET_SONAME_FILE:OpenCL-ROCm>
++        DESTINATION lib
+         COMPONENT MAIN)
+ 
+ # DEV package
+@@ -123,8 +123,8 @@
+         PATTERN cl_d3d11.h EXCLUDE
+         PATTERN cl_dx9_media_sharing.h EXCLUDE
+         PATTERN cl_egl.h EXCLUDE)
+-install(PROGRAMS $<TARGET_LINKER_FILE:OpenCL>
+-        DESTINATION lib/x86_64
++install(PROGRAMS $<TARGET_LINKER_FILE:OpenCL-ROCm>
++        DESTINATION lib
+         COMPONENT DEV)
+ 
+ # Generic CPACK variables
+diff -u -r ../original/ROCm-OpenCL-Runtime-roc-3.3.0/tools/clinfo/CMakeLists.txt ./ROCm-OpenCL-Runtime-roc-3.3.0/tools/clinfo/CMakeLists.txt
+--- ROCm-OpenCL-Runtime-roc-3.3.0/tools/clinfo/CMakeLists.txt	2020-04-01 13:05:07.000000000 -0400
++++ ROCm-OpenCL-Runtime-roc-3.3.0/tools/clinfo/CMakeLists.txt	2020-04-16 20:17:33.735894123 -0400
+@@ -8,4 +8,7 @@
+ 
+ add_executable(clinfo clinfo.cpp)
+ 
+-target_link_libraries(clinfo OpenCL)
++target_link_libraries(clinfo OpenCL-ROCm)
++
++# Make sure the clinfo rpath does not point to build directory
++set_target_properties(clinfo PROPERTIES BUILD_WITH_INSTALL_RPATH ON)
diff --git a/srcpkgs/rocm-opencl-runtime/template b/srcpkgs/rocm-opencl-runtime/template
new file mode 100644
index 00000000000..832ec7566ff
--- /dev/null
+++ b/srcpkgs/rocm-opencl-runtime/template
@@ -0,0 +1,78 @@
+# Template file for 'rocm-opencl-runtime'
+pkgname=rocm-opencl-runtime
+version=3.3.0
+revision=1
+_ocl_icd_name="OpenCL-ICD-Loader"
+_ocl_icd_ver="6c03f8b58fafd9dd693eaac826749a5cfad515f8"
+archs="x86_64*"
+create_wrksrc=yes
+build_wrksrc="ROCm-OpenCL-Runtime-roc-${version}"
+build_style=cmake
+configure_args="-DCMAKE_INSTALL_PREFIX:PATH=/opt/rocm
+	-DCMAKE_PREFIX_PATH:PATH=/opt/rocm/lib/cmake
+	-DCMAKE_INSTALL_RPATH:PATH='\$ORIGIN:\$ORIGIN/../lib'
+	-DUSE_COMGR_LIBRARY=yes"
+hostmakedepends="cmake pkg-config"
+makedepends="libglvnd-devel rocm-comgr-devel
+	roct-thunk-interface-devel rocr-runtime-devel"
+depends="rocm-comgr"
+short_desc="Radeon Open Compute OpenCL runtime"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="MIT"
+homepage="https://github.com/RadeonOpenCompute/ROCm-OpenCL-Runtime"
+_rocroot="https://github.com/RadeonOpenCompute"
+distfiles="${_rocroot}/ROCm-OpenCL-Runtime/archive/roc-${version}.tar.gz
+	${_rocroot}/rocm-cmake/archive/rocm-${version}.tar.gz
+	https://github.com/KhronosGroup/${_ocl_icd_name}/archive/${_ocl_icd_ver}.tar.gz"
+checksum="ac6999f1a491ab066286c2bd6adf50f08f831286f56e267879f9f7eced22f98e
+	76ed3ee8e56cf3246011cf7723c2abda539e1136e7e7f6909bfa45d268b8644f
+	c94d5bb6dc980c4d41d73e2b81663a19aabe494e923e2d0eec72a4c95b318438"
+nocross=yes
+
+post_patch() {
+	if [ "$XBPS_LIBC" = "musl" ]; then
+		# Copy sys/queue.h locally for MUSL builds
+		libelf_dir="compiler/lib/loaders/elf/utils/libelf"
+		cp "${FILESDIR}/sys_queue.h" "${libelf_dir}"
+
+		# Remove dependence on glibc
+		patch -Np0 < ${FILESDIR}/libelf-musl.patch
+		patch -Np0 < ${FILESDIR}/runtime-musl.patch
+		vsed -e '/glibc_functions.cpp/d' -i api/opencl/amdocl/CMakeLists.txt
+	fi
+}
+
+pre_configure() {
+	# ROCm requires a very specific Khronos ICD loader version in the tree
+	# Keep the ICD loader config in /opt/rocm to avoid conflicts
+	_ocl_icd_dir="${_ocl_icd_name}-${_ocl_icd_ver}"
+	ln -sf "${wrksrc}/${_ocl_icd_dir}" api/opencl/khronos/icd
+	vsed -i "${wrksrc}/${_ocl_icd_dir}/loader/icd_platform.h" \
+		-e 's@/etc/OpenCL/vendors/@/opt/rocm&@g'
+
+	# CMake modules probably not useful anywhere but for this build
+	ln -sf "${wrksrc}/rocm-cmake-rocm-${version}/share/rocm/cmake"/*.cmake cmake
+
+	# Fix the dlopen macro to point to versioned libamd_comgr shared object
+	vsed -i 'runtime/device/comgrctx.cpp' \
+		-e 's/\blibamd_comgr\(32\)\?.so\b/&.1/g'
+}
+
+post_install() {
+	vlicense License
+
+	# Create descriptor to allow the ICD loader to find the driver
+	_ocl_icd_dir="opt/rocm/etc/OpenCL/vendors"
+	vmkdir "${_ocl_icd_dir}"
+	echo "/opt/rocm/lib/libamdocl64.so" \
+		> "${DESTDIR}/${_ocl_icd_dir}/amdocl64.icd"
+}
+
+rocm-opencl-runtime-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove opt/rocm/include
+		vmove opt/rocm/lib/libOpenCL-ROCm.so
+	}
+}

^ permalink raw reply	[flat|nested] 61+ messages in thread

* Re: [PR PATCH] [Updated] New packages: ROCm core and OpenCL
  2020-04-19 13:34 [PR PATCH] New packages: ROCm core and OpenCL ahesford
  2020-04-19 15:24 ` [PR PATCH] [Updated] " ahesford
@ 2020-04-19 15:57 ` ahesford
  2020-04-19 19:02 ` ahesford
                   ` (57 subsequent siblings)
  59 siblings, 0 replies; 61+ messages in thread
From: ahesford @ 2020-04-19 15:57 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 3893 bytes --]

There is an updated pull request by ahesford against master on the void-packages repository

https://github.com/ahesford/void-packages rocm
https://github.com/void-linux/void-packages/pull/21153

New packages: ROCm core and OpenCL
This PR includes several packages designed to bring the OpenCL portion of the AMD ROCm ecosystem to Void. It addresses Issue #19507. There are many other packages that AMD provides for GPGPU computing, but these can be added piecemeal as users demand.

The packages are currently only for `x86_64*`. While at least some of the packages will compile on other 64-bit architectures, I have no hardware to test. They are certainly not suitable for 32-bit architectures; some internal data structures rely on `uint64_t` values that are cast to pointers. At a
minimum, a thorough audit would be necessary to ensure that these casts are safe (e.g., that the values stored were only ever upcast from 32-bit pointers). More extensive work may be necessary to support 32-bit architectures, probably without significant benefit.

The packages successfully identify a Radeon RX 580 on an `x86_64` installation using both `clinfo` and `rocminfo` as provided. Furthermore, a version of `pyopencl` linked against these ROCm packages successfully runs a simple program that validates arithmetic on GPU-bound arrays.

There are caveats with this set of packages, almost all of which revolve around the incompatibilities between the Void-provided `ocl-icd` and the [Khronos OpenCL ICD loader](https://github.com/KhronosGroup/OpenCL-ID-Loader) required by (and built into) `rocm-opencl-runtime`.
1. All packages install into `/opt/rocm`. This keeps the environment closer to that officially sanctioned by AMD and helps avoid conflicts between other packages and those provided here. (For example, `clinfo` and the ICD loader itself.) Eventually, we may be able to move the files into `/usr`.
2. The Khronos OpenCL ICD loader built into `rocm-opencl-runtime` is an outdated, pre-release commit. If AMD can update its sources to use the release version of that loader (which has a backward-incompatible API change), we may be able to make ROCm compatible with `ocl-icd` or replace `ocl-icd` with the official Khronos loader.
3. In the meantime, to avoid `shlibs` conflicts, the OpenCL ICD loader is installed as `/opt/rocm/lib/libOpenCL-ROCm.so` (and an appropriately versioned shared library), which means that programs wishing to use the ROCm OpenCL must explicitly link against this library instead of the generic `libOpenCL.so`.
4. I do **not** recommend making any Void packages link against this specific library, because it will make those packages ROCm-only. For the time being, ROCm is intended for end-users to specifically link against. Linking Void packages against ROCm would requires the ICD loader used by ROCm be compatible with `ocl-icd`, or `ocl-icd` be replaced by the Khronos loader. However, because the Khronos loader changed its API for the release version, such a change is not yet appropriate.

Hopefully, if AMD updates its dependence on the Khronos ICD loader, we can resolve some of these caveats in the future and make ROCm a more natural Void component. For now, these packages are useful for those who need an AMD OpenCL solution and would rather custom-link software against the AMD ICD loader than hack the `amdgpu-pro` driver into an ICD compatible with `ocl-icd`.

Some patches were made to relocate some files in `/opt/rocm` and make everyting build on x86_64-musl`. Where appropriate, these patches will be pushed upstream to clean up the distribution and packaging.

Update: I pushed some new commits to update license information that triggerd an `xlint` failure. I've also disabled CI builds because they will time out on `rocm-llvm`.

A patch file from https://github.com/void-linux/void-packages/pull/21153.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-rocm-21153.patch --]
[-- Type: text/x-diff, Size: 72760 bytes --]

From 316d26679fb04d0ff3222e88a12a0d9bee598664 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Mon, 13 Apr 2020 13:08:09 -0400
Subject: [PATCH 1/7] New package: roct-thunk-interface-3.3.0

---
 common/shlibs                                 |  1 +
 srcpkgs/roct-thunk-interface-devel            |  1 +
 .../patches/cmake-dev-libdir.patch            | 10 ++++++
 .../roct-thunk-interface/patches/musl.patch   | 29 +++++++++++++++
 srcpkgs/roct-thunk-interface/template         | 35 +++++++++++++++++++
 5 files changed, 76 insertions(+)
 create mode 120000 srcpkgs/roct-thunk-interface-devel
 create mode 100644 srcpkgs/roct-thunk-interface/patches/cmake-dev-libdir.patch
 create mode 100644 srcpkgs/roct-thunk-interface/patches/musl.patch
 create mode 100644 srcpkgs/roct-thunk-interface/template

diff --git a/common/shlibs b/common/shlibs
index 53a59b7303b..78863e0f7b8 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3862,3 +3862,4 @@ libstk-4.6.1.so libstk-4.6.1_1
 libc++utilities.so.5 cpp-utilities-5.2.0_1
 libtagparser.so.9 tagparser-9.1.2_1
 libqtutilities.so.6 qtutilities-6.0.4_1
+libhsakmt.so.1 roct-thunk-interface-3.3.0_1
diff --git a/srcpkgs/roct-thunk-interface-devel b/srcpkgs/roct-thunk-interface-devel
new file mode 120000
index 00000000000..ac3f2cc684c
--- /dev/null
+++ b/srcpkgs/roct-thunk-interface-devel
@@ -0,0 +1 @@
+roct-thunk-interface
\ No newline at end of file
diff --git a/srcpkgs/roct-thunk-interface/patches/cmake-dev-libdir.patch b/srcpkgs/roct-thunk-interface/patches/cmake-dev-libdir.patch
new file mode 100644
index 00000000000..98c7f1e459c
--- /dev/null
+++ b/srcpkgs/roct-thunk-interface/patches/cmake-dev-libdir.patch
@@ -0,0 +1,10 @@
+--- CMakeLists.txt.old	2020-04-18 19:45:17.306081135 -0400
++++ CMakeLists.txt	2020-04-18 19:46:51.300753636 -0400
+@@ -146,6 +146,7 @@
+     COMMAND ${CMAKE_COMMAND}
+         -DSOURCE_DIR="${SOURCE_DIR}"
+         -DCMAKE_INSTALL_PREFIX="${CMAKE_INSTALL_PREFIX}"
++        -DCMAKE_INSTALL_LIBDIR="${CMAKE_INSTALL_LIBDIR}"
+         -DCPACK_RPM_PACKAGE_REQUIRES="hsakmt-roct"
+         -DCPACK_PACKAGING_INSTALL_PREFIX="${CPACK_PACKAGING_INSTALL_PREFIX}"
+         -DVERSION="${BUILD_VERSION_STRING}"
diff --git a/srcpkgs/roct-thunk-interface/patches/musl.patch b/srcpkgs/roct-thunk-interface/patches/musl.patch
new file mode 100644
index 00000000000..aeea9832411
--- /dev/null
+++ b/srcpkgs/roct-thunk-interface/patches/musl.patch
@@ -0,0 +1,29 @@
+diff -r -u old/src/libhsakmt.h new/src/libhsakmt.h
+--- src/libhsakmt.h	2020-03-04 15:00:47.000000000 -0500
++++ src/libhsakmt.h	2020-04-13 12:58:30.444865992 -0400
+@@ -54,6 +54,10 @@
+ #define CHECK_KFD_OPEN() \
+ 	do { if (kfd_open_count == 0 || hsakmt_forked) return HSAKMT_STATUS_KERNEL_IO_CHANNEL_NOT_OPENED; } while (0)
+ 
++/*On some platforms, a PAGE_SIZE macro eclipses the extern variable*/
++#ifdef PAGE_SIZE
++#undef PAGE_SIZE
++#endif
+ extern int PAGE_SIZE;
+ extern int PAGE_SHIFT;
+ 
+diff -r -u old/src/topology.c new/src/topology.c
+--- src/topology.c	2020-03-04 15:00:47.000000000 -0500
++++ src/topology.c	2020-04-13 13:01:31.209870701 -0400
+@@ -38,6 +38,11 @@
+ #include "libhsakmt.h"
+ #include "fmm.h"
+ 
++/*Needed on MUSL*/
++#ifndef MAXNAMLEN
++#define MAXNAMLEN PATH_MAX
++#endif
++
+ /* Number of memory banks added by thunk on top of topology
+  * This only includes static heaps like LDS, scratch and SVM,
+  * not for MMIO_REMAP heap. MMIO_REMAP memory bank is reported
diff --git a/srcpkgs/roct-thunk-interface/template b/srcpkgs/roct-thunk-interface/template
new file mode 100644
index 00000000000..f4320075c73
--- /dev/null
+++ b/srcpkgs/roct-thunk-interface/template
@@ -0,0 +1,35 @@
+# Template file for 'roct-thunk-interface'
+pkgname=roct-thunk-interface
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="ROCT-Thunk-Interface-roc-${version}"
+build_style=cmake
+configure_args="-DCMAKE_INSTALL_PREFIX:PATH=/opt/rocm
+	-DCMAKE_INSTALL_RPATH:PATH='\$ORIGIN:\$ORIGIN/../lib'"
+make_build_target="all build-dev"
+make_install_target="install install-dev"
+hostmakedepends="cmake pkg-config"
+makedepends="pciutils-devel libnuma-devel"
+short_desc="Radeon Open Compute Thunk Interface"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="MIT"
+homepage="https://github.com/RadeonOpenCompute/ROCT-Thunk-Interface"
+distfiles="${homepage}/archive/roc-${version}.tar.gz"
+checksum=2cabe9d2cfa72031c05d11290837c476182e72d8dec2049298f691143fdd212b
+nocross=yes
+
+post_install() {
+	vlicense LICENSE.md
+}
+
+roct-thunk-interface-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove opt/rocm/include
+		vmove "opt/rocm/lib/*.so"
+		vmove opt/rocm/share/pkgconfig
+		vmove opt/rocm/lib/cmake
+	}
+}

From 716bf0d64be8fad18c290e095f75d8c9ea0d7329 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Mon, 13 Apr 2020 15:27:27 -0400
Subject: [PATCH 2/7] New package: rocr-runtime-3.3.0

---
 common/shlibs                            |  1 +
 srcpkgs/rocr-runtime-devel               |  1 +
 srcpkgs/rocr-runtime/patches/cmake.patch | 27 +++++++++++++++++++
 srcpkgs/rocr-runtime/template            | 33 ++++++++++++++++++++++++
 4 files changed, 62 insertions(+)
 create mode 120000 srcpkgs/rocr-runtime-devel
 create mode 100644 srcpkgs/rocr-runtime/patches/cmake.patch
 create mode 100644 srcpkgs/rocr-runtime/template

diff --git a/common/shlibs b/common/shlibs
index 78863e0f7b8..ec34c0df9fa 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3863,3 +3863,4 @@ libc++utilities.so.5 cpp-utilities-5.2.0_1
 libtagparser.so.9 tagparser-9.1.2_1
 libqtutilities.so.6 qtutilities-6.0.4_1
 libhsakmt.so.1 roct-thunk-interface-3.3.0_1
+libhsa-runtime64.so.1 rocr-runtime-3.3.0_1
diff --git a/srcpkgs/rocr-runtime-devel b/srcpkgs/rocr-runtime-devel
new file mode 120000
index 00000000000..be838f22d81
--- /dev/null
+++ b/srcpkgs/rocr-runtime-devel
@@ -0,0 +1 @@
+rocr-runtime
\ No newline at end of file
diff --git a/srcpkgs/rocr-runtime/patches/cmake.patch b/srcpkgs/rocr-runtime/patches/cmake.patch
new file mode 100644
index 00000000000..93b74cd2297
--- /dev/null
+++ b/srcpkgs/rocr-runtime/patches/cmake.patch
@@ -0,0 +1,27 @@
+--- src/CMakeLists.txt.old	2020-04-18 20:01:48.549636995 -0400
++++ src/CMakeLists.txt	2020-04-18 20:04:00.177179781 -0400
+@@ -108,8 +108,8 @@
+ ## ROCr build internal versioning
+ add_definitions ( -DROCR_BUILD_ID=${PACKAGE_VERSION_STRING} )
+ 
+-## Set RUNPATH - ../../lib covers use of the legacy symlink in /hsa/lib/
+-set(CMAKE_INSTALL_RPATH "$ORIGIN;$ORIGIN/../../lib;$ORIGIN/../../lib64;$ORIGIN/../lib64")
++## Set RUNPATH
++set(CMAKE_INSTALL_RPATH "$ORIGIN;$ORIGIN/../lib")
+ 
+ ## ------------------------- Linux Compiler and Linker options -------------------------
+ set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -fexceptions -fno-rtti -fvisibility=hidden -Wno-error=sign-compare -Wno-sign-compare -Wno-write-strings -Wno-conversion-null -fno-math-errno -fno-threadsafe-statics -fmerge-all-constants -fms-extensions -Wno-error=comment -Wno-comment -Wno-error=pointer-arith -Wno-pointer-arith -Wno-error=unused-variable -Wno-error=unused-function" )
+@@ -185,11 +185,8 @@
+ add_custom_target ( hsa_lib_link2 ALL WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMAND ${CMAKE_COMMAND} -E create_symlink ../hsa/lib/${CORE_RUNTIME_LIBRARY}.so.${SO_MAJOR} ${CORE_RUNTIME_LIBRARY}-link.so.${SO_MAJOR} )
+ 
+ ## Set install information
+-install ( TARGETS ${CORE_RUNTIME_TARGET} LIBRARY DESTINATION hsa/lib )
+-install ( DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/inc/ DESTINATION hsa/include/hsa )
+-install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/hsa_include_link DESTINATION include PERMISSIONS OWNER_WRITE OWNER_READ RENAME hsa )
+-install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/${CORE_RUNTIME_LIBRARY}-link.so DESTINATION lib PERMISSIONS OWNER_WRITE OWNER_READ RENAME ${CORE_RUNTIME_LIBRARY}.so )
+-install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/${CORE_RUNTIME_LIBRARY}-link.so.${SO_MAJOR} DESTINATION lib PERMISSIONS OWNER_WRITE OWNER_READ RENAME ${CORE_RUNTIME_LIBRARY}.so.${SO_MAJOR} )
++install ( TARGETS ${CORE_RUNTIME_TARGET} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} )
++install ( DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/inc/ DESTINATION include/hsa )
+ 
+ ## Packaging directives
+ set ( CPACK_GENERATOR "DEB;RPM" CACHE STRING "Package types to build")
diff --git a/srcpkgs/rocr-runtime/template b/srcpkgs/rocr-runtime/template
new file mode 100644
index 00000000000..3588211584c
--- /dev/null
+++ b/srcpkgs/rocr-runtime/template
@@ -0,0 +1,33 @@
+# Template file for 'rocr-runtime'
+pkgname=rocr-runtime
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="ROCR-Runtime-rocm-${version}"
+build_wrksrc="src"
+build_style=cmake
+configure_args="-DCMAKE_INSTALL_PREFIX:PATH=/opt/rocm
+	-DHSAKMT_INC_PATH:PATH=/opt/rocm/include
+	-DHSAKMT_LIB_PATH:PATH=/opt/rocm/lib"
+hostmakedepends="cmake pkg-config"
+makedepends="roct-thunk-interface-devel elfutils-devel"
+short_desc="Radeon Open Compute HSA Runtime"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute/ROCR-Runtime"
+distfiles="${homepage}/archive/rocm-${version}.tar.gz"
+checksum=fa2d2d1f8a61d8a6952d377cf288d78c61776c3c2a666f163cafc3aa19ab0b61
+nocross=yes
+
+post_install() {
+	vlicense ../LICENSE.txt
+}
+
+rocr-runtime-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove opt/rocm/include
+		vmove "opt/rocm/lib/*.so"
+	}
+}

From e1e57ae8ded92527d1cbc5a85d914f015ffe544c Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Mon, 13 Apr 2020 18:07:34 -0400
Subject: [PATCH 3/7] New package: rocm-llvm-3.3.0

---
 srcpkgs/rocm-llvm/template | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)
 create mode 100644 srcpkgs/rocm-llvm/template

diff --git a/srcpkgs/rocm-llvm/template b/srcpkgs/rocm-llvm/template
new file mode 100644
index 00000000000..487a845c733
--- /dev/null
+++ b/srcpkgs/rocm-llvm/template
@@ -0,0 +1,25 @@
+# Template file for 'rocm-llvm'
+pkgname=rocm-llvm
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="llvm-project-rocm-ocl-${version}"
+build_wrksrc=llvm
+build_style=cmake
+configure_args="-DCMAKE_INSTALL_PREFIX:PATH=/opt/rocm/llvm
+	-DLLVM_ENABLE_PROJECTS='llvm;clang;lld' -DLLVM_TARGETS_TO_BUILD='AMDGPU'
+	-DLLVM_BUILD_DOCS=NO -DLLVM_ENABLE_OCAMLDOC=OFF
+	-DLLVM_ENABLE_SPHINX=NO -DLLVM_ENABLE_DOXYGEN=OFF
+	-DLLVM_INSTALL_UTILS=ON -DLLVM_VERSION_SUFFIX=roc -DOCAMLFIND=NO"
+hostmakedepends="cmake pkg-config python3"
+short_desc="Radeon Open Compute LLVM toolchain"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="Apache-2.0, NCSA, custom:LLVM-Exceptions"
+homepage="https://github.com/RadeonOpenCompute/llvm-project"
+distfiles="${homepage}/archive/rocm-ocl-${version}.tar.gz"
+checksum=a2bef7042e8e2f2cd8548cb246b88322e1c77188839983dcac8312d56f544dc8
+nocross=yes
+
+post_install() {
+	vlicense LICENSE.TXT
+}

From 09cd8414ed8ae86d3f0b4d548c809744ea44fd43 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Tue, 14 Apr 2020 10:25:31 -0400
Subject: [PATCH 4/7] New package: rocm-device-libs-3.3.0

---
 srcpkgs/rocm-device-libs/template | 32 +++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)
 create mode 100644 srcpkgs/rocm-device-libs/template

diff --git a/srcpkgs/rocm-device-libs/template b/srcpkgs/rocm-device-libs/template
new file mode 100644
index 00000000000..94b3be580c0
--- /dev/null
+++ b/srcpkgs/rocm-device-libs/template
@@ -0,0 +1,32 @@
+# Template file for 'rocm-device-libs'
+pkgname=rocm-device-libs
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="ROCm-Device-Libs-rocm-ocl-${version}"
+build_style=cmake
+configure_args="-DCMAKE_INSTALL_PREFIX:PATH=/opt/rocm -DLLVM_DIR:PATH=/opt/rocm/llvm"
+hostmakedepends="cmake rocm-llvm"
+short_desc="Radeon Open Compute device libraries"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute/ROCm-Device-Libs"
+distfiles="${homepage}/archive/rocm-ocl-${version}.tar.gz"
+checksum=706b08230790e08ca6a7a2fb7687d6131fd39a562148340e00fa37a6c06769c5
+nocross=yes
+
+pre_configure() {
+	# Build the prepare-builtins executable with native compiler
+	mkdir -p utils/build
+	cd utils/build
+	_prepare_builtins="$PWD/prepare-builtins/prepare-builtins"
+	cmake ${configure_args} ..
+	make ${makejobs}
+
+	# Add path to prepare-builtins for cmake
+	configure_args+=" -DPREPARE_BUILTINS='${_prepare_builtins}'"
+}
+
+post_install() {
+	vlicense LICENSE
+}

From 8e0b895f02b68a2fc2a6b20d77efa634a201ebaf Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Mon, 13 Apr 2020 18:30:00 -0400
Subject: [PATCH 5/7] New package: rocm-comgr-3.3.0

---
 common/shlibs               |  1 +
 srcpkgs/rocm-comgr-devel    |  1 +
 srcpkgs/rocm-comgr/template | 34 ++++++++++++++++++++++++++++++++++
 3 files changed, 36 insertions(+)
 create mode 120000 srcpkgs/rocm-comgr-devel
 create mode 100644 srcpkgs/rocm-comgr/template

diff --git a/common/shlibs b/common/shlibs
index ec34c0df9fa..509755bd8b9 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3864,3 +3864,4 @@ libtagparser.so.9 tagparser-9.1.2_1
 libqtutilities.so.6 qtutilities-6.0.4_1
 libhsakmt.so.1 roct-thunk-interface-3.3.0_1
 libhsa-runtime64.so.1 rocr-runtime-3.3.0_1
+libamd_comgr.so.1 rocm-comgr-3.3.0_1
diff --git a/srcpkgs/rocm-comgr-devel b/srcpkgs/rocm-comgr-devel
new file mode 120000
index 00000000000..3f5ce255e07
--- /dev/null
+++ b/srcpkgs/rocm-comgr-devel
@@ -0,0 +1 @@
+rocm-comgr
\ No newline at end of file
diff --git a/srcpkgs/rocm-comgr/template b/srcpkgs/rocm-comgr/template
new file mode 100644
index 00000000000..4bbc930073c
--- /dev/null
+++ b/srcpkgs/rocm-comgr/template
@@ -0,0 +1,34 @@
+# Template file for 'rocm-comgr'
+pkgname=rocm-comgr
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="ROCm-CompilerSupport-rocm-${version}"
+build_wrksrc="lib/comgr"
+build_style=cmake
+configure_args="-DCMAKE_INSTALL_PREFIX:PATH=/opt/rocm
+	-DClang_DIR:PATH=/opt/rocm/llvm/lib/cmake/clang
+	-DCMAKE_INSTALL_RPATH:PATH='\$ORIGIN:\$ORIGIN/../lib'"
+hostmakedepends="cmake pkg-config rocm-llvm"
+makedepends="rocm-device-libs"
+short_desc="Radeon Open Compute Code Object Manager"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="BSD-3-Clause"
+homepage="https://github.com/RadeonOpenCompute/ROCm-CompilerSupport"
+distfiles="${homepage}/archive/rocm-${version}.tar.gz"
+checksum=01e2524e0f28ecd6f46c9720f279207de935d826b0172158792aa3ec86af9ca7
+nocross=yes
+
+post_install() {
+	vlicense LICENSE.txt
+}
+
+rocm-comgr-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove opt/rocm/include
+		vmove "opt/rocm/lib/*.so"
+		vmove opt/rocm/lib/cmake
+	}
+}

From b01f6c102c83273e07650a5b1c02809bd363aadf Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Fri, 17 Apr 2020 12:11:25 -0400
Subject: [PATCH 6/7] New package: rocminfo-3.3.0

---
 srcpkgs/rocminfo/template | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
 create mode 100644 srcpkgs/rocminfo/template

diff --git a/srcpkgs/rocminfo/template b/srcpkgs/rocminfo/template
new file mode 100644
index 00000000000..91128a766f3
--- /dev/null
+++ b/srcpkgs/rocminfo/template
@@ -0,0 +1,21 @@
+# Template file for 'rocminfo'
+pkgname=rocminfo
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="rocminfo-rocm-${version}"
+build_style=cmake
+configure_args="-DCMAKE_INSTALL_PREFIX:PATH=/opt/rocm -DROCM_DIR=/opt/rocm"
+hostmakedepends="cmake pkg-config"
+makedepends="rocr-runtime-devel"
+short_desc="Radeon Open Compute system information reporter"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute/rocminfo"
+distfiles="${homepage}/archive/rocm-${version}.tar.gz"
+checksum=e666f662c9e465aaabbbd0b109d87e017243cdf1a0898fabf5a90947bb3dbcd7
+nocross=yes
+
+post_install() {
+	vlicense License.txt
+}

From 476a842d41bb89cd0e4b6d02ff4981564bffe1fc Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Tue, 14 Apr 2020 10:25:54 -0400
Subject: [PATCH 7/7] New package: rocm-opencl-runtime-3.3.0 [ci skip]

---
 common/shlibs                                 |   1 +
 srcpkgs/rocm-opencl-runtime-devel             |   1 +
 .../files/libelf-musl.patch                   | 688 ++++++++++++++++++
 .../files/runtime-musl.patch                  |  11 +
 srcpkgs/rocm-opencl-runtime/files/sys_queue.h | 574 +++++++++++++++
 .../rocm-opencl-runtime/patches/cmake.patch   | 123 ++++
 srcpkgs/rocm-opencl-runtime/template          |  78 ++
 7 files changed, 1476 insertions(+)
 create mode 120000 srcpkgs/rocm-opencl-runtime-devel
 create mode 100644 srcpkgs/rocm-opencl-runtime/files/libelf-musl.patch
 create mode 100644 srcpkgs/rocm-opencl-runtime/files/runtime-musl.patch
 create mode 100644 srcpkgs/rocm-opencl-runtime/files/sys_queue.h
 create mode 100644 srcpkgs/rocm-opencl-runtime/patches/cmake.patch
 create mode 100644 srcpkgs/rocm-opencl-runtime/template

diff --git a/common/shlibs b/common/shlibs
index 509755bd8b9..d087fa3ab4b 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3865,3 +3865,4 @@ libqtutilities.so.6 qtutilities-6.0.4_1
 libhsakmt.so.1 roct-thunk-interface-3.3.0_1
 libhsa-runtime64.so.1 rocr-runtime-3.3.0_1
 libamd_comgr.so.1 rocm-comgr-3.3.0_1
+libOpenCL-ROCm.so.1 rocm-opencl-runtime-3.3.0_1
diff --git a/srcpkgs/rocm-opencl-runtime-devel b/srcpkgs/rocm-opencl-runtime-devel
new file mode 120000
index 00000000000..b2cda7e229d
--- /dev/null
+++ b/srcpkgs/rocm-opencl-runtime-devel
@@ -0,0 +1 @@
+rocm-opencl-runtime
\ No newline at end of file
diff --git a/srcpkgs/rocm-opencl-runtime/files/libelf-musl.patch b/srcpkgs/rocm-opencl-runtime/files/libelf-musl.patch
new file mode 100644
index 00000000000..a3705c259a9
--- /dev/null
+++ b/srcpkgs/rocm-opencl-runtime/files/libelf-musl.patch
@@ -0,0 +1,688 @@
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/_libelf.h compiler/lib/loaders/elf/utils/libelf/_libelf.h
+--- compiler/lib/loaders/elf/utils/libelf.orig/_libelf.h	2020-04-19 08:59:34.201386585 -0400
++++ compiler/lib/loaders/elf/utils/libelf/_libelf.h	2020-04-19 09:04:12.950433528 -0400
+@@ -30,7 +30,7 @@
+ #define	__LIBELF_H_
+ 
+ #include <limits.h>
+-#include <sys/queue.h>
++#include "sys_queue.h"
+ 
+ #include "_libelf_config.h"
+ 
+@@ -179,7 +179,9 @@
+  * Function Prototypes.
+  */
+ 
+-__BEGIN_DECLS
++#ifdef __cplusplus
++extern "C" {
++#endif
+ Elf_Data *_libelf_allocate_data(Elf_Scn *_s);
+ Elf	*_libelf_allocate_elf(Elf_Mem *mem);
+ Elf_Scn	*_libelf_allocate_scn(Elf *_e, size_t _ndx);
+@@ -213,6 +215,8 @@
+ Elf_Data *_libelf_xlate(Elf_Data *_d, const Elf_Data *_s,
+     unsigned int _encoding, int _elfclass, int _direction);
+ int	_libelf_xlate_shtype(uint32_t _sht);
+-__END_DECLS
++#ifdef __cplusplus
++}
++#endif
+ 
+ #endif	/* __LIBELF_H_ */
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_begin.c compiler/lib/loaders/elf/utils/libelf/elf_begin.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_begin.c	2020-04-19 08:59:34.201386585 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_begin.c	2020-04-19 09:01:04.313212042 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <sys/types.h>
+ #if !defined(WIN32)
+ #include <sys/errno.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_end.c compiler/lib/loaders/elf/utils/libelf/elf_end.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_end.c	2020-04-19 08:59:34.201386585 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_end.c	2020-04-19 09:01:14.895204681 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #if !defined(WIN32)
+ #include <sys/mman.h>
+ #endif
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_errmsg.c compiler/lib/loaders/elf/utils/libelf/elf_errmsg.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_errmsg.c	2020-04-19 08:59:34.201386585 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_errmsg.c	2020-04-19 09:01:16.753207065 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ #include <stdio.h>
+ #include <string.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_errno.c compiler/lib/loaders/elf/utils/libelf/elf_errno.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_errno.c	2020-04-19 08:59:34.201386585 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_errno.c	2020-04-19 09:01:18.669209528 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_fill.c compiler/lib/loaders/elf/utils/libelf/elf_fill.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_fill.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_fill.c	2020-04-19 09:01:21.109212667 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_flag.c compiler/lib/loaders/elf/utils/libelf/elf_flag.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_flag.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_flag.c	2020-04-19 09:01:23.376215579 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_getarhdr.c compiler/lib/loaders/elf/utils/libelf/elf_getarhdr.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_getarhdr.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_getarhdr.c	2020-04-19 09:01:25.414218197 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_getarsym.c compiler/lib/loaders/elf/utils/libelf/elf_getarsym.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_getarsym.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_getarsym.c	2020-04-19 09:01:27.575220978 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_getbase.c compiler/lib/loaders/elf/utils/libelf/elf_getbase.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_getbase.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_getbase.c	2020-04-19 09:01:29.963224043 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_getident.c compiler/lib/loaders/elf/utils/libelf/elf_getident.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_getident.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_getident.c	2020-04-19 09:01:31.912226551 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <ar.h>
+ #include <assert.h>
+ #include <libelf.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_hash.c compiler/lib/loaders/elf/utils/libelf/elf_hash.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_hash.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_hash.c	2020-04-19 09:01:33.877229069 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ #include "_libelf_config.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_kind.c compiler/lib/loaders/elf/utils/libelf/elf_kind.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_kind.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_kind.c	2020-04-19 09:01:35.940231721 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_memory.c compiler/lib/loaders/elf/utils/libelf/elf_memory.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_memory.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_memory.c	2020-04-19 09:01:38.171234596 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <ar.h>
+ #include <libelf.h>
+ #include <string.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_next.c compiler/lib/loaders/elf/utils/libelf/elf_next.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_next.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_next.c	2020-04-19 09:01:40.063237028 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <ar.h>
+ #include <assert.h>
+ #include <libelf.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_phnum.c compiler/lib/loaders/elf/utils/libelf/elf_phnum.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_phnum.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_phnum.c	2020-04-19 09:01:42.480240134 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <ar.h>
+ #include <libelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_rand.c compiler/lib/loaders/elf/utils/libelf/elf_rand.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_rand.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_rand.c	2020-04-19 09:01:45.061243452 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <ar.h>
+ #include <libelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_rawfile.c compiler/lib/loaders/elf/utils/libelf/elf_rawfile.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_rawfile.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_rawfile.c	2020-04-19 09:01:46.988245928 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_scn.c compiler/lib/loaders/elf/utils/libelf/elf_scn.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_scn.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_scn.c	2020-04-19 09:00:19.724298403 -0400
+@@ -24,8 +24,7 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-#include <sys/queue.h>
++#include "sys_queue.h"
+ 
+ #include <assert.h>
+ #include <errno.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_shnum.c compiler/lib/loaders/elf/utils/libelf/elf_shnum.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_shnum.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_shnum.c	2020-04-19 09:01:51.763252060 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <ar.h>
+ #include <libelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_shstrndx.c compiler/lib/loaders/elf/utils/libelf/elf_shstrndx.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_shstrndx.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_shstrndx.c	2020-04-19 09:01:53.532254340 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <ar.h>
+ #include <libelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_version.c compiler/lib/loaders/elf/utils/libelf/elf_version.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_version.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_version.c	2020-04-19 09:02:01.337264370 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf.h compiler/lib/loaders/elf/utils/libelf/gelf.h
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf.h	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf.h	2020-04-19 09:04:29.669455020 -0400
+@@ -29,8 +29,6 @@
+ #ifndef	_GELF_H_
+ #define	_GELF_H_
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ typedef Elf64_Addr	GElf_Addr;	/* Addresses */
+@@ -72,7 +70,9 @@
+ #define	GELF_ST_TYPE			ELF64_ST_TYPE
+ #define	GELF_ST_VISIBILITY		ELF64_ST_VISIBILITY
+ 
+-__BEGIN_DECLS
++#ifdef __cplusplus
++extern "C" {
++#endif
+ long		gelf_checksum(Elf *_elf);
+ size_t		gelf_fsize(Elf *_elf, Elf_Type _type, size_t _count,
+ 			unsigned int _version);
+@@ -109,6 +109,8 @@
+ int		gelf_update_move(Elf_Data *_dst, int _index, GElf_Move *_src);
+ int		gelf_update_syminfo(Elf_Data *_dst, int _index, GElf_Syminfo *_src);
+ #endif
+-__END_DECLS
++#ifdef __cplusplus
++}
++#endif
+ 
+ #endif	/* _GELF_H_ */
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_cap.c compiler/lib/loaders/elf/utils/libelf/gelf_cap.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_cap.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_cap.c	2020-04-19 09:02:05.429269632 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_checksum.c compiler/lib/loaders/elf/utils/libelf/gelf_checksum.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_checksum.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_checksum.c	2020-04-19 09:02:08.192273183 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <gelf.h>
+ #include <libelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_dyn.c compiler/lib/loaders/elf/utils/libelf/gelf_dyn.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_dyn.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_dyn.c	2020-04-19 09:02:10.020275525 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_ehdr.c compiler/lib/loaders/elf/utils/libelf/gelf_ehdr.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_ehdr.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_ehdr.c	2020-04-19 09:02:11.882277926 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ #include <libelf.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_fsize.c compiler/lib/loaders/elf/utils/libelf/gelf_fsize.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_fsize.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_fsize.c	2020-04-19 09:02:14.139280827 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <gelf.h>
+ #include <libelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_getclass.c compiler/lib/loaders/elf/utils/libelf/gelf_getclass.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_getclass.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_getclass.c	2020-04-19 09:02:17.269284848 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <gelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_move.c compiler/lib/loaders/elf/utils/libelf/gelf_move.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_move.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_move.c	2020-04-19 09:02:18.974287034 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_phdr.c compiler/lib/loaders/elf/utils/libelf/gelf_phdr.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_phdr.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_phdr.c	2020-04-19 09:02:20.676289227 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <gelf.h>
+ #include <libelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_rel.c compiler/lib/loaders/elf/utils/libelf/gelf_rel.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_rel.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_rel.c	2020-04-19 09:02:23.177292435 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_rela.c compiler/lib/loaders/elf/utils/libelf/gelf_rela.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_rela.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_rela.c	2020-04-19 09:02:25.246295100 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_shdr.c compiler/lib/loaders/elf/utils/libelf/gelf_shdr.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_shdr.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_shdr.c	2020-04-19 09:02:28.325299060 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ #include <libelf.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_sym.c compiler/lib/loaders/elf/utils/libelf/gelf_sym.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_sym.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_sym.c	2020-04-19 09:02:30.113301356 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_syminfo.c compiler/lib/loaders/elf/utils/libelf/gelf_syminfo.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_syminfo.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_syminfo.c	2020-04-19 09:02:31.906303662 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_symshndx.c compiler/lib/loaders/elf/utils/libelf/gelf_symshndx.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_symshndx.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_symshndx.c	2020-04-19 09:02:33.626305873 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_xlate.c compiler/lib/loaders/elf/utils/libelf/gelf_xlate.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_xlate.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_xlate.c	2020-04-19 09:02:35.921308822 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <gelf.h>
+ #include <libelf.h>
+ #include <string.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf.h compiler/lib/loaders/elf/utils/libelf/libelf.h
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf.h	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf.h	2020-04-19 09:04:38.760466706 -0400
+@@ -30,7 +30,7 @@
+ #define	_LIBELF_H_
+ 
+ #include <sys/types.h>
+-#include <sys/queue.h>
++#include "sys_queue.h"
+ #include <elfdefinitions.h>
+ #ifndef EM_HSAIL
+ #define EM_HSAIL 0xAF5A
+@@ -187,7 +187,9 @@
+ #define	ELF_F_ARCHIVE	   0x100U /* archive creation */
+ #define	ELF_F_ARCHIVE_SYSV 0x200U /* SYSV style archive */
+ 
+-__BEGIN_DECLS
++#ifdef __cplusplus
++extern "C" {
++#endif
+ Elf		*elf_begin(int _fd, Elf_Cmd _cmd, Elf *_elf, Elf_Mem *_mem);
+ int		elf_cntl(Elf *_elf, Elf_Cmd _cmd);
+ int		elf_end(Elf *_elf);
+@@ -257,6 +259,8 @@
+ 			unsigned int _enc);
+ Elf_Data	*elf64_xlatetom(Elf_Data *_dst, const Elf_Data *_src,
+ 			unsigned int _enc);
+-__END_DECLS
++#ifdef __cplusplus
++}
++#endif
+ 
+ #endif	/* _LIBELF_H_ */
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_align.c compiler/lib/loaders/elf/utils/libelf/libelf_align.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_align.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_align.c	2020-04-19 09:02:40.660314911 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <sys/types.h>
+ 
+ #include <libelf.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_allocate.c compiler/lib/loaders/elf/utils/libelf/libelf_allocate.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_allocate.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_allocate.c	2020-04-19 09:02:43.079318019 -0400
+@@ -28,8 +28,6 @@
+  * Internal APIs
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #if !defined(WIN32)
+ #include <sys/errno.h>
+ #endif
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_ar.c compiler/lib/loaders/elf/utils/libelf/libelf_ar.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_ar.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_ar.c	2020-04-19 09:02:44.763320187 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <ctype.h>
+ #include <libelf.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_ar_util.c compiler/lib/loaders/elf/utils/libelf/libelf_ar_util.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_ar_util.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_ar_util.c	2020-04-19 09:02:46.461322369 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <libelf.h>
+ #include <stdlib.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_checksum.c compiler/lib/loaders/elf/utils/libelf/libelf_checksum.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_checksum.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_checksum.c	2020-04-19 09:02:48.645325173 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <gelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_convert.c compiler/lib/loaders/elf/utils/libelf/libelf_convert.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_convert.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_convert.c	2020-04-19 09:02:50.883328053 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <libelf.h>
+ #include <string.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_data.c compiler/lib/loaders/elf/utils/libelf/libelf_data.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_data.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_data.c	2020-04-19 09:02:52.951330708 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_ehdr.c compiler/lib/loaders/elf/utils/libelf/libelf_ehdr.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_ehdr.c	2020-04-19 08:59:34.204386579 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_ehdr.c	2020-04-19 09:02:55.176333563 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ #include <libelf.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_extended.c compiler/lib/loaders/elf/utils/libelf/libelf_extended.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_extended.c	2020-04-19 08:59:34.204386579 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_extended.c	2020-04-19 09:02:57.932337110 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <libelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_msize.c compiler/lib/loaders/elf/utils/libelf/libelf_msize.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_msize.c	2020-04-19 08:59:34.204386579 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_msize.c	2020-04-19 09:03:02.201342598 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <libelf.h>
+ #include <string.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_phdr.c compiler/lib/loaders/elf/utils/libelf/libelf_phdr.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_phdr.c	2020-04-19 08:59:34.204386579 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_phdr.c	2020-04-19 09:03:04.194345160 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ #include <libelf.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_shdr.c compiler/lib/loaders/elf/utils/libelf/libelf_shdr.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_shdr.c	2020-04-19 08:59:34.204386579 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_shdr.c	2020-04-19 09:03:05.795347218 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <gelf.h>
+ #include <libelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_xlate.c compiler/lib/loaders/elf/utils/libelf/libelf_xlate.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_xlate.c	2020-04-19 08:59:34.204386579 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_xlate.c	2020-04-19 09:03:09.472351944 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <libelf.h>
+ 
diff --git a/srcpkgs/rocm-opencl-runtime/files/runtime-musl.patch b/srcpkgs/rocm-opencl-runtime/files/runtime-musl.patch
new file mode 100644
index 00000000000..ea18e90e09c
--- /dev/null
+++ b/srcpkgs/rocm-opencl-runtime/files/runtime-musl.patch
@@ -0,0 +1,11 @@
+--- runtime/os/os_posix.cpp.orig	2020-04-19 09:13:51.701982901 -0400
++++ runtime/os/os_posix.cpp	2020-04-19 09:14:04.156947422 -0400
+@@ -44,6 +44,8 @@
+ #include <algorithm>
+ #include <mutex>
+ 
++#include <libgen.h> // for basename
++
+ 
+ namespace amd {
+ 
diff --git a/srcpkgs/rocm-opencl-runtime/files/sys_queue.h b/srcpkgs/rocm-opencl-runtime/files/sys_queue.h
new file mode 100644
index 00000000000..daf4553d33e
--- /dev/null
+++ b/srcpkgs/rocm-opencl-runtime/files/sys_queue.h
@@ -0,0 +1,574 @@
+/*
+ * Copyright (c) 1991, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *	@(#)queue.h	8.5 (Berkeley) 8/20/94
+ */
+
+#ifndef	_SYS_QUEUE_H_
+#define	_SYS_QUEUE_H_
+
+/*
+ * This file defines five types of data structures: singly-linked lists,
+ * lists, simple queues, tail queues, and circular queues.
+ *
+ * A singly-linked list is headed by a single forward pointer. The
+ * elements are singly linked for minimum space and pointer manipulation
+ * overhead at the expense of O(n) removal for arbitrary elements. New
+ * elements can be added to the list after an existing element or at the
+ * head of the list.  Elements being removed from the head of the list
+ * should use the explicit macro for this purpose for optimum
+ * efficiency. A singly-linked list may only be traversed in the forward
+ * direction.  Singly-linked lists are ideal for applications with large
+ * datasets and few or no removals or for implementing a LIFO queue.
+ *
+ * A list is headed by a single forward pointer (or an array of forward
+ * pointers for a hash table header). The elements are doubly linked
+ * so that an arbitrary element can be removed without a need to
+ * traverse the list. New elements can be added to the list before
+ * or after an existing element or at the head of the list. A list
+ * may only be traversed in the forward direction.
+ *
+ * A simple queue is headed by a pair of pointers, one the head of the
+ * list and the other to the tail of the list. The elements are singly
+ * linked to save space, so elements can only be removed from the
+ * head of the list. New elements can be added to the list after
+ * an existing element, at the head of the list, or at the end of the
+ * list. A simple queue may only be traversed in the forward direction.
+ *
+ * A tail queue is headed by a pair of pointers, one to the head of the
+ * list and the other to the tail of the list. The elements are doubly
+ * linked so that an arbitrary element can be removed without a need to
+ * traverse the list. New elements can be added to the list before or
+ * after an existing element, at the head of the list, or at the end of
+ * the list. A tail queue may be traversed in either direction.
+ *
+ * A circle queue is headed by a pair of pointers, one to the head of the
+ * list and the other to the tail of the list. The elements are doubly
+ * linked so that an arbitrary element can be removed without a need to
+ * traverse the list. New elements can be added to the list before or after
+ * an existing element, at the head of the list, or at the end of the list.
+ * A circle queue may be traversed in either direction, but has a more
+ * complex end of list detection.
+ *
+ * For details on the use of these macros, see the queue(3) manual page.
+ */
+
+/*
+ * List definitions.
+ */
+#define	LIST_HEAD(name, type)						\
+struct name {								\
+	struct type *lh_first;	/* first element */			\
+}
+
+#define	LIST_HEAD_INITIALIZER(head)					\
+	{ NULL }
+
+#define	LIST_ENTRY(type)						\
+struct {								\
+	struct type *le_next;	/* next element */			\
+	struct type **le_prev;	/* address of previous next element */	\
+}
+
+/*
+ * List functions.
+ */
+#define	LIST_INIT(head) do {						\
+	(head)->lh_first = NULL;					\
+} while (/*CONSTCOND*/0)
+
+#define	LIST_INSERT_AFTER(listelm, elm, field) do {			\
+	if (((elm)->field.le_next = (listelm)->field.le_next) != NULL)	\
+		(listelm)->field.le_next->field.le_prev =		\
+		    &(elm)->field.le_next;				\
+	(listelm)->field.le_next = (elm);				\
+	(elm)->field.le_prev = &(listelm)->field.le_next;		\
+} while (/*CONSTCOND*/0)
+
+#define	LIST_INSERT_BEFORE(listelm, elm, field) do {			\
+	(elm)->field.le_prev = (listelm)->field.le_prev;		\
+	(elm)->field.le_next = (listelm);				\
+	*(listelm)->field.le_prev = (elm);				\
+	(listelm)->field.le_prev = &(elm)->field.le_next;		\
+} while (/*CONSTCOND*/0)
+
+#define	LIST_INSERT_HEAD(head, elm, field) do {				\
+	if (((elm)->field.le_next = (head)->lh_first) != NULL)		\
+		(head)->lh_first->field.le_prev = &(elm)->field.le_next;\
+	(head)->lh_first = (elm);					\
+	(elm)->field.le_prev = &(head)->lh_first;			\
+} while (/*CONSTCOND*/0)
+
+#define	LIST_REMOVE(elm, field) do {					\
+	if ((elm)->field.le_next != NULL)				\
+		(elm)->field.le_next->field.le_prev = 			\
+		    (elm)->field.le_prev;				\
+	*(elm)->field.le_prev = (elm)->field.le_next;			\
+} while (/*CONSTCOND*/0)
+
+#define	LIST_FOREACH(var, head, field)					\
+	for ((var) = ((head)->lh_first);				\
+		(var);							\
+		(var) = ((var)->field.le_next))
+
+/*
+ * List access methods.
+ */
+#define	LIST_EMPTY(head)		((head)->lh_first == NULL)
+#define	LIST_FIRST(head)		((head)->lh_first)
+#define	LIST_NEXT(elm, field)		((elm)->field.le_next)
+
+
+/*
+ * Singly-linked List definitions.
+ */
+#define	SLIST_HEAD(name, type)						\
+struct name {								\
+	struct type *slh_first;	/* first element */			\
+}
+
+#define	SLIST_HEAD_INITIALIZER(head)					\
+	{ NULL }
+
+#define	SLIST_ENTRY(type)						\
+struct {								\
+	struct type *sle_next;	/* next element */			\
+}
+
+/*
+ * Singly-linked List functions.
+ */
+#define	SLIST_INIT(head) do {						\
+	(head)->slh_first = NULL;					\
+} while (/*CONSTCOND*/0)
+
+#define	SLIST_INSERT_AFTER(slistelm, elm, field) do {			\
+	(elm)->field.sle_next = (slistelm)->field.sle_next;		\
+	(slistelm)->field.sle_next = (elm);				\
+} while (/*CONSTCOND*/0)
+
+#define	SLIST_INSERT_HEAD(head, elm, field) do {			\
+	(elm)->field.sle_next = (head)->slh_first;			\
+	(head)->slh_first = (elm);					\
+} while (/*CONSTCOND*/0)
+
+#define	SLIST_REMOVE_HEAD(head, field) do {				\
+	(head)->slh_first = (head)->slh_first->field.sle_next;		\
+} while (/*CONSTCOND*/0)
+
+#define	SLIST_REMOVE(head, elm, type, field) do {			\
+	if ((head)->slh_first == (elm)) {				\
+		SLIST_REMOVE_HEAD((head), field);			\
+	}								\
+	else {								\
+		struct type *curelm = (head)->slh_first;		\
+		while(curelm->field.sle_next != (elm))			\
+			curelm = curelm->field.sle_next;		\
+		curelm->field.sle_next =				\
+		    curelm->field.sle_next->field.sle_next;		\
+	}								\
+} while (/*CONSTCOND*/0)
+
+#define	SLIST_FOREACH(var, head, field)					\
+	for((var) = (head)->slh_first; (var); (var) = (var)->field.sle_next)
+
+/*
+ * Singly-linked List access methods.
+ */
+#define	SLIST_EMPTY(head)	((head)->slh_first == NULL)
+#define	SLIST_FIRST(head)	((head)->slh_first)
+#define	SLIST_NEXT(elm, field)	((elm)->field.sle_next)
+
+
+/*
+ * Singly-linked Tail queue declarations.
+ */
+#define	STAILQ_HEAD(name, type)					\
+struct name {								\
+	struct type *stqh_first;	/* first element */			\
+	struct type **stqh_last;	/* addr of last next element */		\
+}
+
+#define	STAILQ_HEAD_INITIALIZER(head)					\
+	{ NULL, &(head).stqh_first }
+
+#define	STAILQ_ENTRY(type)						\
+struct {								\
+	struct type *stqe_next;	/* next element */			\
+}
+
+/*
+ * Singly-linked Tail queue functions.
+ */
+#define	STAILQ_INIT(head) do {						\
+	(head)->stqh_first = NULL;					\
+	(head)->stqh_last = &(head)->stqh_first;				\
+} while (/*CONSTCOND*/0)
+
+#define	STAILQ_INSERT_HEAD(head, elm, field) do {			\
+	if (((elm)->field.stqe_next = (head)->stqh_first) == NULL)	\
+		(head)->stqh_last = &(elm)->field.stqe_next;		\
+	(head)->stqh_first = (elm);					\
+} while (/*CONSTCOND*/0)
+
+#define	STAILQ_INSERT_TAIL(head, elm, field) do {			\
+	(elm)->field.stqe_next = NULL;					\
+	*(head)->stqh_last = (elm);					\
+	(head)->stqh_last = &(elm)->field.stqe_next;			\
+} while (/*CONSTCOND*/0)
+
+#define	STAILQ_INSERT_AFTER(head, listelm, elm, field) do {		\
+	if (((elm)->field.stqe_next = (listelm)->field.stqe_next) == NULL)\
+		(head)->stqh_last = &(elm)->field.stqe_next;		\
+	(listelm)->field.stqe_next = (elm);				\
+} while (/*CONSTCOND*/0)
+
+#define	STAILQ_REMOVE_HEAD(head, field) do {				\
+	if (((head)->stqh_first = (head)->stqh_first->field.stqe_next) == NULL) \
+		(head)->stqh_last = &(head)->stqh_first;			\
+} while (/*CONSTCOND*/0)
+
+#define	STAILQ_REMOVE(head, elm, type, field) do {			\
+	if ((head)->stqh_first == (elm)) {				\
+		STAILQ_REMOVE_HEAD((head), field);			\
+	} else {							\
+		struct type *curelm = (head)->stqh_first;		\
+		while (curelm->field.stqe_next != (elm))			\
+			curelm = curelm->field.stqe_next;		\
+		if ((curelm->field.stqe_next =				\
+			curelm->field.stqe_next->field.stqe_next) == NULL) \
+			    (head)->stqh_last = &(curelm)->field.stqe_next; \
+	}								\
+} while (/*CONSTCOND*/0)
+
+#define	STAILQ_FOREACH(var, head, field)				\
+	for ((var) = ((head)->stqh_first);				\
+		(var);							\
+		(var) = ((var)->field.stqe_next))
+
+#define	STAILQ_CONCAT(head1, head2) do {				\
+	if (!STAILQ_EMPTY((head2))) {					\
+		*(head1)->stqh_last = (head2)->stqh_first;		\
+		(head1)->stqh_last = (head2)->stqh_last;		\
+		STAILQ_INIT((head2));					\
+	}								\
+} while (/*CONSTCOND*/0)
+
+/*
+ * Singly-linked Tail queue access methods.
+ */
+#define	STAILQ_EMPTY(head)	((head)->stqh_first == NULL)
+#define	STAILQ_FIRST(head)	((head)->stqh_first)
+#define	STAILQ_NEXT(elm, field)	((elm)->field.stqe_next)
+
+
+/*
+ * Simple queue definitions.
+ */
+#define	SIMPLEQ_HEAD(name, type)					\
+struct name {								\
+	struct type *sqh_first;	/* first element */			\
+	struct type **sqh_last;	/* addr of last next element */		\
+}
+
+#define	SIMPLEQ_HEAD_INITIALIZER(head)					\
+	{ NULL, &(head).sqh_first }
+
+#define	SIMPLEQ_ENTRY(type)						\
+struct {								\
+	struct type *sqe_next;	/* next element */			\
+}
+
+/*
+ * Simple queue functions.
+ */
+#define	SIMPLEQ_INIT(head) do {						\
+	(head)->sqh_first = NULL;					\
+	(head)->sqh_last = &(head)->sqh_first;				\
+} while (/*CONSTCOND*/0)
+
+#define	SIMPLEQ_INSERT_HEAD(head, elm, field) do {			\
+	if (((elm)->field.sqe_next = (head)->sqh_first) == NULL)	\
+		(head)->sqh_last = &(elm)->field.sqe_next;		\
+	(head)->sqh_first = (elm);					\
+} while (/*CONSTCOND*/0)
+
+#define	SIMPLEQ_INSERT_TAIL(head, elm, field) do {			\
+	(elm)->field.sqe_next = NULL;					\
+	*(head)->sqh_last = (elm);					\
+	(head)->sqh_last = &(elm)->field.sqe_next;			\
+} while (/*CONSTCOND*/0)
+
+#define	SIMPLEQ_INSERT_AFTER(head, listelm, elm, field) do {		\
+	if (((elm)->field.sqe_next = (listelm)->field.sqe_next) == NULL)\
+		(head)->sqh_last = &(elm)->field.sqe_next;		\
+	(listelm)->field.sqe_next = (elm);				\
+} while (/*CONSTCOND*/0)
+
+#define	SIMPLEQ_REMOVE_HEAD(head, field) do {				\
+	if (((head)->sqh_first = (head)->sqh_first->field.sqe_next) == NULL) \
+		(head)->sqh_last = &(head)->sqh_first;			\
+} while (/*CONSTCOND*/0)
+
+#define	SIMPLEQ_REMOVE(head, elm, type, field) do {			\
+	if ((head)->sqh_first == (elm)) {				\
+		SIMPLEQ_REMOVE_HEAD((head), field);			\
+	} else {							\
+		struct type *curelm = (head)->sqh_first;		\
+		while (curelm->field.sqe_next != (elm))			\
+			curelm = curelm->field.sqe_next;		\
+		if ((curelm->field.sqe_next =				\
+			curelm->field.sqe_next->field.sqe_next) == NULL) \
+			    (head)->sqh_last = &(curelm)->field.sqe_next; \
+	}								\
+} while (/*CONSTCOND*/0)
+
+#define	SIMPLEQ_FOREACH(var, head, field)				\
+	for ((var) = ((head)->sqh_first);				\
+		(var);							\
+		(var) = ((var)->field.sqe_next))
+
+/*
+ * Simple queue access methods.
+ */
+#define	SIMPLEQ_EMPTY(head)		((head)->sqh_first == NULL)
+#define	SIMPLEQ_FIRST(head)		((head)->sqh_first)
+#define	SIMPLEQ_NEXT(elm, field)	((elm)->field.sqe_next)
+
+
+/*
+ * Tail queue definitions.
+ */
+#define	_TAILQ_HEAD(name, type, qual)					\
+struct name {								\
+	qual type *tqh_first;		/* first element */		\
+	qual type *qual *tqh_last;	/* addr of last next element */	\
+}
+#define TAILQ_HEAD(name, type)	_TAILQ_HEAD(name, struct type,)
+
+#define	TAILQ_HEAD_INITIALIZER(head)					\
+	{ NULL, &(head).tqh_first }
+
+#define	_TAILQ_ENTRY(type, qual)					\
+struct {								\
+	qual type *tqe_next;		/* next element */		\
+	qual type *qual *tqe_prev;	/* address of previous next element */\
+}
+#define TAILQ_ENTRY(type)	_TAILQ_ENTRY(struct type,)
+
+/*
+ * Tail queue functions.
+ */
+#define	TAILQ_INIT(head) do {						\
+	(head)->tqh_first = NULL;					\
+	(head)->tqh_last = &(head)->tqh_first;				\
+} while (/*CONSTCOND*/0)
+
+#define	TAILQ_INSERT_HEAD(head, elm, field) do {			\
+	if (((elm)->field.tqe_next = (head)->tqh_first) != NULL)	\
+		(head)->tqh_first->field.tqe_prev =			\
+		    &(elm)->field.tqe_next;				\
+	else								\
+		(head)->tqh_last = &(elm)->field.tqe_next;		\
+	(head)->tqh_first = (elm);					\
+	(elm)->field.tqe_prev = &(head)->tqh_first;			\
+} while (/*CONSTCOND*/0)
+
+#define	TAILQ_INSERT_TAIL(head, elm, field) do {			\
+	(elm)->field.tqe_next = NULL;					\
+	(elm)->field.tqe_prev = (head)->tqh_last;			\
+	*(head)->tqh_last = (elm);					\
+	(head)->tqh_last = &(elm)->field.tqe_next;			\
+} while (/*CONSTCOND*/0)
+
+#define	TAILQ_INSERT_AFTER(head, listelm, elm, field) do {		\
+	if (((elm)->field.tqe_next = (listelm)->field.tqe_next) != NULL)\
+		(elm)->field.tqe_next->field.tqe_prev = 		\
+		    &(elm)->field.tqe_next;				\
+	else								\
+		(head)->tqh_last = &(elm)->field.tqe_next;		\
+	(listelm)->field.tqe_next = (elm);				\
+	(elm)->field.tqe_prev = &(listelm)->field.tqe_next;		\
+} while (/*CONSTCOND*/0)
+
+#define	TAILQ_INSERT_BEFORE(listelm, elm, field) do {			\
+	(elm)->field.tqe_prev = (listelm)->field.tqe_prev;		\
+	(elm)->field.tqe_next = (listelm);				\
+	*(listelm)->field.tqe_prev = (elm);				\
+	(listelm)->field.tqe_prev = &(elm)->field.tqe_next;		\
+} while (/*CONSTCOND*/0)
+
+#define	TAILQ_REMOVE(head, elm, field) do {				\
+	if (((elm)->field.tqe_next) != NULL)				\
+		(elm)->field.tqe_next->field.tqe_prev = 		\
+		    (elm)->field.tqe_prev;				\
+	else								\
+		(head)->tqh_last = (elm)->field.tqe_prev;		\
+	*(elm)->field.tqe_prev = (elm)->field.tqe_next;			\
+} while (/*CONSTCOND*/0)
+
+#define	TAILQ_FOREACH(var, head, field)					\
+	for ((var) = ((head)->tqh_first);				\
+		(var);							\
+		(var) = ((var)->field.tqe_next))
+
+#define	TAILQ_FOREACH_REVERSE(var, head, headname, field)		\
+	for ((var) = (*(((struct headname *)((head)->tqh_last))->tqh_last));	\
+		(var);							\
+		(var) = (*(((struct headname *)((var)->field.tqe_prev))->tqh_last)))
+
+#define	TAILQ_CONCAT(head1, head2, field) do {				\
+	if (!TAILQ_EMPTY(head2)) {					\
+		*(head1)->tqh_last = (head2)->tqh_first;		\
+		(head2)->tqh_first->field.tqe_prev = (head1)->tqh_last;	\
+		(head1)->tqh_last = (head2)->tqh_last;			\
+		TAILQ_INIT((head2));					\
+	}								\
+} while (/*CONSTCOND*/0)
+
+/*
+ * Tail queue access methods.
+ */
+#define	TAILQ_EMPTY(head)		((head)->tqh_first == NULL)
+#define	TAILQ_FIRST(head)		((head)->tqh_first)
+#define	TAILQ_NEXT(elm, field)		((elm)->field.tqe_next)
+
+#define	TAILQ_LAST(head, headname) \
+	(*(((struct headname *)((head)->tqh_last))->tqh_last))
+#define	TAILQ_PREV(elm, headname, field) \
+	(*(((struct headname *)((elm)->field.tqe_prev))->tqh_last))
+
+
+/*
+ * Circular queue definitions.
+ */
+#define	CIRCLEQ_HEAD(name, type)					\
+struct name {								\
+	struct type *cqh_first;		/* first element */		\
+	struct type *cqh_last;		/* last element */		\
+}
+
+#define	CIRCLEQ_HEAD_INITIALIZER(head)					\
+	{ (void *)&head, (void *)&head }
+
+#define	CIRCLEQ_ENTRY(type)						\
+struct {								\
+	struct type *cqe_next;		/* next element */		\
+	struct type *cqe_prev;		/* previous element */		\
+}
+
+/*
+ * Circular queue functions.
+ */
+#define	CIRCLEQ_INIT(head) do {						\
+	(head)->cqh_first = (void *)(head);				\
+	(head)->cqh_last = (void *)(head);				\
+} while (/*CONSTCOND*/0)
+
+#define	CIRCLEQ_INSERT_AFTER(head, listelm, elm, field) do {		\
+	(elm)->field.cqe_next = (listelm)->field.cqe_next;		\
+	(elm)->field.cqe_prev = (listelm);				\
+	if ((listelm)->field.cqe_next == (void *)(head))		\
+		(head)->cqh_last = (elm);				\
+	else								\
+		(listelm)->field.cqe_next->field.cqe_prev = (elm);	\
+	(listelm)->field.cqe_next = (elm);				\
+} while (/*CONSTCOND*/0)
+
+#define	CIRCLEQ_INSERT_BEFORE(head, listelm, elm, field) do {		\
+	(elm)->field.cqe_next = (listelm);				\
+	(elm)->field.cqe_prev = (listelm)->field.cqe_prev;		\
+	if ((listelm)->field.cqe_prev == (void *)(head))		\
+		(head)->cqh_first = (elm);				\
+	else								\
+		(listelm)->field.cqe_prev->field.cqe_next = (elm);	\
+	(listelm)->field.cqe_prev = (elm);				\
+} while (/*CONSTCOND*/0)
+
+#define	CIRCLEQ_INSERT_HEAD(head, elm, field) do {			\
+	(elm)->field.cqe_next = (head)->cqh_first;			\
+	(elm)->field.cqe_prev = (void *)(head);				\
+	if ((head)->cqh_last == (void *)(head))				\
+		(head)->cqh_last = (elm);				\
+	else								\
+		(head)->cqh_first->field.cqe_prev = (elm);		\
+	(head)->cqh_first = (elm);					\
+} while (/*CONSTCOND*/0)
+
+#define	CIRCLEQ_INSERT_TAIL(head, elm, field) do {			\
+	(elm)->field.cqe_next = (void *)(head);				\
+	(elm)->field.cqe_prev = (head)->cqh_last;			\
+	if ((head)->cqh_first == (void *)(head))			\
+		(head)->cqh_first = (elm);				\
+	else								\
+		(head)->cqh_last->field.cqe_next = (elm);		\
+	(head)->cqh_last = (elm);					\
+} while (/*CONSTCOND*/0)
+
+#define	CIRCLEQ_REMOVE(head, elm, field) do {				\
+	if ((elm)->field.cqe_next == (void *)(head))			\
+		(head)->cqh_last = (elm)->field.cqe_prev;		\
+	else								\
+		(elm)->field.cqe_next->field.cqe_prev =			\
+		    (elm)->field.cqe_prev;				\
+	if ((elm)->field.cqe_prev == (void *)(head))			\
+		(head)->cqh_first = (elm)->field.cqe_next;		\
+	else								\
+		(elm)->field.cqe_prev->field.cqe_next =			\
+		    (elm)->field.cqe_next;				\
+} while (/*CONSTCOND*/0)
+
+#define	CIRCLEQ_FOREACH(var, head, field)				\
+	for ((var) = ((head)->cqh_first);				\
+		(var) != (const void *)(head);				\
+		(var) = ((var)->field.cqe_next))
+
+#define	CIRCLEQ_FOREACH_REVERSE(var, head, field)			\
+	for ((var) = ((head)->cqh_last);				\
+		(var) != (const void *)(head);				\
+		(var) = ((var)->field.cqe_prev))
+
+/*
+ * Circular queue access methods.
+ */
+#define	CIRCLEQ_EMPTY(head)		((head)->cqh_first == (void *)(head))
+#define	CIRCLEQ_FIRST(head)		((head)->cqh_first)
+#define	CIRCLEQ_LAST(head)		((head)->cqh_last)
+#define	CIRCLEQ_NEXT(elm, field)	((elm)->field.cqe_next)
+#define	CIRCLEQ_PREV(elm, field)	((elm)->field.cqe_prev)
+
+#define CIRCLEQ_LOOP_NEXT(head, elm, field)				\
+	(((elm)->field.cqe_next == (void *)(head))			\
+	    ? ((head)->cqh_first)					\
+	    : (elm->field.cqe_next))
+#define CIRCLEQ_LOOP_PREV(head, elm, field)				\
+	(((elm)->field.cqe_prev == (void *)(head))			\
+	    ? ((head)->cqh_last)					\
+	    : (elm->field.cqe_prev))
+
+#endif	/* sys/queue.h */
diff --git a/srcpkgs/rocm-opencl-runtime/patches/cmake.patch b/srcpkgs/rocm-opencl-runtime/patches/cmake.patch
new file mode 100644
index 00000000000..2b3354f3eeb
--- /dev/null
+++ b/srcpkgs/rocm-opencl-runtime/patches/cmake.patch
@@ -0,0 +1,123 @@
+diff -u -r ../original/OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/CMakeLists.txt ./OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/CMakeLists.txt
+--- OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/CMakeLists.txt	2019-09-10 11:53:28.000000000 -0400
++++ OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/CMakeLists.txt	2020-04-16 20:16:13.481180757 -0400
+@@ -73,11 +73,11 @@
+ 
+ set (OPENCL_ICD_LOADER_HEADERS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/inc CACHE PATH "Path to OpenCL Headers")
+ 
+-add_library (OpenCL ${OPENCL_ICD_LOADER_SOURCES})
+-set_target_properties (OpenCL PROPERTIES VERSION "1.2" SOVERSION "1")
++add_library (OpenCL-ROCm ${OPENCL_ICD_LOADER_SOURCES})
++set_target_properties (OpenCL-ROCm PROPERTIES VERSION "1.2" SOVERSION "1")
+ 
+ if (WIN32)
+-    target_link_libraries (OpenCL cfgmgr32.lib)
++    target_link_libraries (OpenCL-ROCm cfgmgr32.lib)
+ 
+     option (OPENCL_ICD_LOADER_REQUIRE_WDK "Build with D3DKMT support, which requires the Windows WDK." ON)
+     if (OPENCL_ICD_LOADER_REQUIRE_WDK)
+@@ -92,10 +92,10 @@
+             get_filename_component(WDK_DIRECTORY ${LATEST_D3DKMT_HEADER} DIRECTORY)
+             get_filename_component(WDK_DIRECTORY ${WDK_DIRECTORY} DIRECTORY)
+             message(STATUS "Found the Windows WDK in: ${WDK_DIRECTORY}")
+-            target_compile_definitions(OpenCL PRIVATE OPENCL_ICD_LOADER_REQUIRE_WDK)
+-            target_include_directories(OpenCL PRIVATE ${WDK_DIRECTORY}/um)
+-            target_include_directories(OpenCL PRIVATE ${WDK_DIRECTORY}/km)
+-            target_include_directories(OpenCL PRIVATE ${WDK_DIRECTORY}/shared)
++	    target_compile_definitions(OpenCL-ROCm PRIVATE OPENCL_ICD_LOADER_REQUIRE_WDK)
++	    target_include_directories(OpenCL-ROCm PRIVATE ${WDK_DIRECTORY}/um)
++	    target_include_directories(OpenCL-ROCm PRIVATE ${WDK_DIRECTORY}/km)
++	    target_include_directories(OpenCL-ROCm PRIVATE ${WDK_DIRECTORY}/shared)
+         else()
+             message(FATAL_ERROR "The Windows WDK was not found. Consider disabling OPENCL_ICD_LOADER_REQUIRE_WDK. Aborting.")
+         endif()
+@@ -113,25 +113,25 @@
+     endif()
+ else()
+     if (APPLE)
+-        target_link_libraries (OpenCL ${CMAKE_THREAD_LIBS_INIT})
++        target_link_libraries (OpenCL-ROCm ${CMAKE_THREAD_LIBS_INIT})
+     else ()
+-        set_target_properties (OpenCL PROPERTIES LINK_FLAGS "-Wl,--version-script -Wl,${CMAKE_CURRENT_SOURCE_DIR}/loader/linux/icd_exports.map")
+-        target_link_libraries (OpenCL ${CMAKE_THREAD_LIBS_INIT})
++        set_target_properties (OpenCL-ROCm PROPERTIES LINK_FLAGS "-Wl,--version-script -Wl,${CMAKE_CURRENT_SOURCE_DIR}/loader/linux/icd_exports.map")
++	target_link_libraries (OpenCL-ROCm ${CMAKE_THREAD_LIBS_INIT})
+     endif ()
+ endif ()
+ 
+ include_directories (${OPENCL_ICD_LOADER_HEADERS_DIR})
+ add_definitions (-DCL_TARGET_OPENCL_VERSION=220)
+ 
+-target_include_directories (OpenCL PRIVATE ${CMAKE_CURRENT_BINARY_DIR} loader)
+-target_link_libraries (OpenCL ${CMAKE_DL_LIBS})
++target_include_directories (OpenCL-ROCm PRIVATE ${CMAKE_CURRENT_BINARY_DIR} loader)
++target_link_libraries (OpenCL-ROCm ${CMAKE_DL_LIBS})
+ 
+ include (CTest)
+ if (BUILD_TESTING)
+     add_subdirectory (test)
+ endif()
+ 
+-install (TARGETS OpenCL
++install (TARGETS OpenCL-ROCm
+     RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+     ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
+     LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
+diff -u -r ../original/OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/test/loader_test/CMakeLists.txt ./OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/test/loader_test/CMakeLists.txt
+--- OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/test/loader_test/CMakeLists.txt	2019-09-10 11:53:28.000000000 -0400
++++ OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/test/loader_test/CMakeLists.txt	2020-04-16 20:16:56.647026589 -0400
+@@ -12,4 +12,4 @@
+     test_clgl.c
+     test_image_objects.c )
+ 
+-target_link_libraries (icd_loader_test OpenCL IcdLog)
++target_link_libraries (icd_loader_test OpenCL-ROCm IcdLog)
+diff -u -r ../original/ROCm-OpenCL-Runtime-roc-3.3.0/CMakeLists.txt ./ROCm-OpenCL-Runtime-roc-3.3.0/CMakeLists.txt
+--- ROCm-OpenCL-Runtime-roc-3.3.0/CMakeLists.txt	2020-04-18 20:16:13.452670818 -0400
++++ ROCm-OpenCL-Runtime-roc-3.3.0/CMakeLists.txt	2020-04-18 20:20:09.798862321 -0400
+@@ -102,16 +102,16 @@
+ 
+ # MAIN package
+ install(PROGRAMS $<TARGET_FILE:clinfo>
+-        DESTINATION bin/x86_64
++        DESTINATION bin
+         COMPONENT MAIN)
+ install(PROGRAMS $<TARGET_FILE:amdocl64>
+-        DESTINATION lib/x86_64
++        DESTINATION lib
+         COMPONENT MAIN)
+-install(PROGRAMS $<TARGET_FILE:OpenCL>
+-        DESTINATION lib/x86_64
++install(PROGRAMS $<TARGET_FILE:OpenCL-ROCm>
++        DESTINATION lib
+         COMPONENT MAIN)
+-install(PROGRAMS $<TARGET_SONAME_FILE:OpenCL>
+-        DESTINATION lib/x86_64
++install(PROGRAMS $<TARGET_SONAME_FILE:OpenCL-ROCm>
++        DESTINATION lib
+         COMPONENT MAIN)
+ 
+ # DEV package
+@@ -123,8 +123,8 @@
+         PATTERN cl_d3d11.h EXCLUDE
+         PATTERN cl_dx9_media_sharing.h EXCLUDE
+         PATTERN cl_egl.h EXCLUDE)
+-install(PROGRAMS $<TARGET_LINKER_FILE:OpenCL>
+-        DESTINATION lib/x86_64
++install(PROGRAMS $<TARGET_LINKER_FILE:OpenCL-ROCm>
++        DESTINATION lib
+         COMPONENT DEV)
+ 
+ # Generic CPACK variables
+diff -u -r ../original/ROCm-OpenCL-Runtime-roc-3.3.0/tools/clinfo/CMakeLists.txt ./ROCm-OpenCL-Runtime-roc-3.3.0/tools/clinfo/CMakeLists.txt
+--- ROCm-OpenCL-Runtime-roc-3.3.0/tools/clinfo/CMakeLists.txt	2020-04-01 13:05:07.000000000 -0400
++++ ROCm-OpenCL-Runtime-roc-3.3.0/tools/clinfo/CMakeLists.txt	2020-04-16 20:17:33.735894123 -0400
+@@ -8,4 +8,7 @@
+ 
+ add_executable(clinfo clinfo.cpp)
+ 
+-target_link_libraries(clinfo OpenCL)
++target_link_libraries(clinfo OpenCL-ROCm)
++
++# Make sure the clinfo rpath does not point to build directory
++set_target_properties(clinfo PROPERTIES BUILD_WITH_INSTALL_RPATH ON)
diff --git a/srcpkgs/rocm-opencl-runtime/template b/srcpkgs/rocm-opencl-runtime/template
new file mode 100644
index 00000000000..832ec7566ff
--- /dev/null
+++ b/srcpkgs/rocm-opencl-runtime/template
@@ -0,0 +1,78 @@
+# Template file for 'rocm-opencl-runtime'
+pkgname=rocm-opencl-runtime
+version=3.3.0
+revision=1
+_ocl_icd_name="OpenCL-ICD-Loader"
+_ocl_icd_ver="6c03f8b58fafd9dd693eaac826749a5cfad515f8"
+archs="x86_64*"
+create_wrksrc=yes
+build_wrksrc="ROCm-OpenCL-Runtime-roc-${version}"
+build_style=cmake
+configure_args="-DCMAKE_INSTALL_PREFIX:PATH=/opt/rocm
+	-DCMAKE_PREFIX_PATH:PATH=/opt/rocm/lib/cmake
+	-DCMAKE_INSTALL_RPATH:PATH='\$ORIGIN:\$ORIGIN/../lib'
+	-DUSE_COMGR_LIBRARY=yes"
+hostmakedepends="cmake pkg-config"
+makedepends="libglvnd-devel rocm-comgr-devel
+	roct-thunk-interface-devel rocr-runtime-devel"
+depends="rocm-comgr"
+short_desc="Radeon Open Compute OpenCL runtime"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="MIT"
+homepage="https://github.com/RadeonOpenCompute/ROCm-OpenCL-Runtime"
+_rocroot="https://github.com/RadeonOpenCompute"
+distfiles="${_rocroot}/ROCm-OpenCL-Runtime/archive/roc-${version}.tar.gz
+	${_rocroot}/rocm-cmake/archive/rocm-${version}.tar.gz
+	https://github.com/KhronosGroup/${_ocl_icd_name}/archive/${_ocl_icd_ver}.tar.gz"
+checksum="ac6999f1a491ab066286c2bd6adf50f08f831286f56e267879f9f7eced22f98e
+	76ed3ee8e56cf3246011cf7723c2abda539e1136e7e7f6909bfa45d268b8644f
+	c94d5bb6dc980c4d41d73e2b81663a19aabe494e923e2d0eec72a4c95b318438"
+nocross=yes
+
+post_patch() {
+	if [ "$XBPS_LIBC" = "musl" ]; then
+		# Copy sys/queue.h locally for MUSL builds
+		libelf_dir="compiler/lib/loaders/elf/utils/libelf"
+		cp "${FILESDIR}/sys_queue.h" "${libelf_dir}"
+
+		# Remove dependence on glibc
+		patch -Np0 < ${FILESDIR}/libelf-musl.patch
+		patch -Np0 < ${FILESDIR}/runtime-musl.patch
+		vsed -e '/glibc_functions.cpp/d' -i api/opencl/amdocl/CMakeLists.txt
+	fi
+}
+
+pre_configure() {
+	# ROCm requires a very specific Khronos ICD loader version in the tree
+	# Keep the ICD loader config in /opt/rocm to avoid conflicts
+	_ocl_icd_dir="${_ocl_icd_name}-${_ocl_icd_ver}"
+	ln -sf "${wrksrc}/${_ocl_icd_dir}" api/opencl/khronos/icd
+	vsed -i "${wrksrc}/${_ocl_icd_dir}/loader/icd_platform.h" \
+		-e 's@/etc/OpenCL/vendors/@/opt/rocm&@g'
+
+	# CMake modules probably not useful anywhere but for this build
+	ln -sf "${wrksrc}/rocm-cmake-rocm-${version}/share/rocm/cmake"/*.cmake cmake
+
+	# Fix the dlopen macro to point to versioned libamd_comgr shared object
+	vsed -i 'runtime/device/comgrctx.cpp' \
+		-e 's/\blibamd_comgr\(32\)\?.so\b/&.1/g'
+}
+
+post_install() {
+	vlicense License
+
+	# Create descriptor to allow the ICD loader to find the driver
+	_ocl_icd_dir="opt/rocm/etc/OpenCL/vendors"
+	vmkdir "${_ocl_icd_dir}"
+	echo "/opt/rocm/lib/libamdocl64.so" \
+		> "${DESTDIR}/${_ocl_icd_dir}/amdocl64.icd"
+}
+
+rocm-opencl-runtime-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove opt/rocm/include
+		vmove opt/rocm/lib/libOpenCL-ROCm.so
+	}
+}

^ permalink raw reply	[flat|nested] 61+ messages in thread

* Re: [PR PATCH] [Updated] New packages: ROCm core and OpenCL
  2020-04-19 13:34 [PR PATCH] New packages: ROCm core and OpenCL ahesford
  2020-04-19 15:24 ` [PR PATCH] [Updated] " ahesford
  2020-04-19 15:57 ` ahesford
@ 2020-04-19 19:02 ` ahesford
  2020-04-20  2:02 ` ahesford
                   ` (56 subsequent siblings)
  59 siblings, 0 replies; 61+ messages in thread
From: ahesford @ 2020-04-19 19:02 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 3893 bytes --]

There is an updated pull request by ahesford against master on the void-packages repository

https://github.com/ahesford/void-packages rocm
https://github.com/void-linux/void-packages/pull/21153

New packages: ROCm core and OpenCL
This PR includes several packages designed to bring the OpenCL portion of the AMD ROCm ecosystem to Void. It addresses Issue #19507. There are many other packages that AMD provides for GPGPU computing, but these can be added piecemeal as users demand.

The packages are currently only for `x86_64*`. While at least some of the packages will compile on other 64-bit architectures, I have no hardware to test. They are certainly not suitable for 32-bit architectures; some internal data structures rely on `uint64_t` values that are cast to pointers. At a
minimum, a thorough audit would be necessary to ensure that these casts are safe (e.g., that the values stored were only ever upcast from 32-bit pointers). More extensive work may be necessary to support 32-bit architectures, probably without significant benefit.

The packages successfully identify a Radeon RX 580 on an `x86_64` installation using both `clinfo` and `rocminfo` as provided. Furthermore, a version of `pyopencl` linked against these ROCm packages successfully runs a simple program that validates arithmetic on GPU-bound arrays.

There are caveats with this set of packages, almost all of which revolve around the incompatibilities between the Void-provided `ocl-icd` and the [Khronos OpenCL ICD loader](https://github.com/KhronosGroup/OpenCL-ID-Loader) required by (and built into) `rocm-opencl-runtime`.
1. All packages install into `/opt/rocm`. This keeps the environment closer to that officially sanctioned by AMD and helps avoid conflicts between other packages and those provided here. (For example, `clinfo` and the ICD loader itself.) Eventually, we may be able to move the files into `/usr`.
2. The Khronos OpenCL ICD loader built into `rocm-opencl-runtime` is an outdated, pre-release commit. If AMD can update its sources to use the release version of that loader (which has a backward-incompatible API change), we may be able to make ROCm compatible with `ocl-icd` or replace `ocl-icd` with the official Khronos loader.
3. In the meantime, to avoid `shlibs` conflicts, the OpenCL ICD loader is installed as `/opt/rocm/lib/libOpenCL-ROCm.so` (and an appropriately versioned shared library), which means that programs wishing to use the ROCm OpenCL must explicitly link against this library instead of the generic `libOpenCL.so`.
4. I do **not** recommend making any Void packages link against this specific library, because it will make those packages ROCm-only. For the time being, ROCm is intended for end-users to specifically link against. Linking Void packages against ROCm would requires the ICD loader used by ROCm be compatible with `ocl-icd`, or `ocl-icd` be replaced by the Khronos loader. However, because the Khronos loader changed its API for the release version, such a change is not yet appropriate.

Hopefully, if AMD updates its dependence on the Khronos ICD loader, we can resolve some of these caveats in the future and make ROCm a more natural Void component. For now, these packages are useful for those who need an AMD OpenCL solution and would rather custom-link software against the AMD ICD loader than hack the `amdgpu-pro` driver into an ICD compatible with `ocl-icd`.

Some patches were made to relocate some files in `/opt/rocm` and make everyting build on x86_64-musl`. Where appropriate, these patches will be pushed upstream to clean up the distribution and packaging.

Update: I pushed some new commits to update license information that triggerd an `xlint` failure. I've also disabled CI builds because they will time out on `rocm-llvm`.

A patch file from https://github.com/void-linux/void-packages/pull/21153.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-rocm-21153.patch --]
[-- Type: text/x-diff, Size: 74107 bytes --]

From 316d26679fb04d0ff3222e88a12a0d9bee598664 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Mon, 13 Apr 2020 13:08:09 -0400
Subject: [PATCH 1/8] New package: roct-thunk-interface-3.3.0

---
 common/shlibs                                 |  1 +
 srcpkgs/roct-thunk-interface-devel            |  1 +
 .../patches/cmake-dev-libdir.patch            | 10 ++++++
 .../roct-thunk-interface/patches/musl.patch   | 29 +++++++++++++++
 srcpkgs/roct-thunk-interface/template         | 35 +++++++++++++++++++
 5 files changed, 76 insertions(+)
 create mode 120000 srcpkgs/roct-thunk-interface-devel
 create mode 100644 srcpkgs/roct-thunk-interface/patches/cmake-dev-libdir.patch
 create mode 100644 srcpkgs/roct-thunk-interface/patches/musl.patch
 create mode 100644 srcpkgs/roct-thunk-interface/template

diff --git a/common/shlibs b/common/shlibs
index 53a59b7303b..78863e0f7b8 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3862,3 +3862,4 @@ libstk-4.6.1.so libstk-4.6.1_1
 libc++utilities.so.5 cpp-utilities-5.2.0_1
 libtagparser.so.9 tagparser-9.1.2_1
 libqtutilities.so.6 qtutilities-6.0.4_1
+libhsakmt.so.1 roct-thunk-interface-3.3.0_1
diff --git a/srcpkgs/roct-thunk-interface-devel b/srcpkgs/roct-thunk-interface-devel
new file mode 120000
index 00000000000..ac3f2cc684c
--- /dev/null
+++ b/srcpkgs/roct-thunk-interface-devel
@@ -0,0 +1 @@
+roct-thunk-interface
\ No newline at end of file
diff --git a/srcpkgs/roct-thunk-interface/patches/cmake-dev-libdir.patch b/srcpkgs/roct-thunk-interface/patches/cmake-dev-libdir.patch
new file mode 100644
index 00000000000..98c7f1e459c
--- /dev/null
+++ b/srcpkgs/roct-thunk-interface/patches/cmake-dev-libdir.patch
@@ -0,0 +1,10 @@
+--- CMakeLists.txt.old	2020-04-18 19:45:17.306081135 -0400
++++ CMakeLists.txt	2020-04-18 19:46:51.300753636 -0400
+@@ -146,6 +146,7 @@
+     COMMAND ${CMAKE_COMMAND}
+         -DSOURCE_DIR="${SOURCE_DIR}"
+         -DCMAKE_INSTALL_PREFIX="${CMAKE_INSTALL_PREFIX}"
++        -DCMAKE_INSTALL_LIBDIR="${CMAKE_INSTALL_LIBDIR}"
+         -DCPACK_RPM_PACKAGE_REQUIRES="hsakmt-roct"
+         -DCPACK_PACKAGING_INSTALL_PREFIX="${CPACK_PACKAGING_INSTALL_PREFIX}"
+         -DVERSION="${BUILD_VERSION_STRING}"
diff --git a/srcpkgs/roct-thunk-interface/patches/musl.patch b/srcpkgs/roct-thunk-interface/patches/musl.patch
new file mode 100644
index 00000000000..aeea9832411
--- /dev/null
+++ b/srcpkgs/roct-thunk-interface/patches/musl.patch
@@ -0,0 +1,29 @@
+diff -r -u old/src/libhsakmt.h new/src/libhsakmt.h
+--- src/libhsakmt.h	2020-03-04 15:00:47.000000000 -0500
++++ src/libhsakmt.h	2020-04-13 12:58:30.444865992 -0400
+@@ -54,6 +54,10 @@
+ #define CHECK_KFD_OPEN() \
+ 	do { if (kfd_open_count == 0 || hsakmt_forked) return HSAKMT_STATUS_KERNEL_IO_CHANNEL_NOT_OPENED; } while (0)
+ 
++/*On some platforms, a PAGE_SIZE macro eclipses the extern variable*/
++#ifdef PAGE_SIZE
++#undef PAGE_SIZE
++#endif
+ extern int PAGE_SIZE;
+ extern int PAGE_SHIFT;
+ 
+diff -r -u old/src/topology.c new/src/topology.c
+--- src/topology.c	2020-03-04 15:00:47.000000000 -0500
++++ src/topology.c	2020-04-13 13:01:31.209870701 -0400
+@@ -38,6 +38,11 @@
+ #include "libhsakmt.h"
+ #include "fmm.h"
+ 
++/*Needed on MUSL*/
++#ifndef MAXNAMLEN
++#define MAXNAMLEN PATH_MAX
++#endif
++
+ /* Number of memory banks added by thunk on top of topology
+  * This only includes static heaps like LDS, scratch and SVM,
+  * not for MMIO_REMAP heap. MMIO_REMAP memory bank is reported
diff --git a/srcpkgs/roct-thunk-interface/template b/srcpkgs/roct-thunk-interface/template
new file mode 100644
index 00000000000..f4320075c73
--- /dev/null
+++ b/srcpkgs/roct-thunk-interface/template
@@ -0,0 +1,35 @@
+# Template file for 'roct-thunk-interface'
+pkgname=roct-thunk-interface
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="ROCT-Thunk-Interface-roc-${version}"
+build_style=cmake
+configure_args="-DCMAKE_INSTALL_PREFIX:PATH=/opt/rocm
+	-DCMAKE_INSTALL_RPATH:PATH='\$ORIGIN:\$ORIGIN/../lib'"
+make_build_target="all build-dev"
+make_install_target="install install-dev"
+hostmakedepends="cmake pkg-config"
+makedepends="pciutils-devel libnuma-devel"
+short_desc="Radeon Open Compute Thunk Interface"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="MIT"
+homepage="https://github.com/RadeonOpenCompute/ROCT-Thunk-Interface"
+distfiles="${homepage}/archive/roc-${version}.tar.gz"
+checksum=2cabe9d2cfa72031c05d11290837c476182e72d8dec2049298f691143fdd212b
+nocross=yes
+
+post_install() {
+	vlicense LICENSE.md
+}
+
+roct-thunk-interface-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove opt/rocm/include
+		vmove "opt/rocm/lib/*.so"
+		vmove opt/rocm/share/pkgconfig
+		vmove opt/rocm/lib/cmake
+	}
+}

From 716bf0d64be8fad18c290e095f75d8c9ea0d7329 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Mon, 13 Apr 2020 15:27:27 -0400
Subject: [PATCH 2/8] New package: rocr-runtime-3.3.0

---
 common/shlibs                            |  1 +
 srcpkgs/rocr-runtime-devel               |  1 +
 srcpkgs/rocr-runtime/patches/cmake.patch | 27 +++++++++++++++++++
 srcpkgs/rocr-runtime/template            | 33 ++++++++++++++++++++++++
 4 files changed, 62 insertions(+)
 create mode 120000 srcpkgs/rocr-runtime-devel
 create mode 100644 srcpkgs/rocr-runtime/patches/cmake.patch
 create mode 100644 srcpkgs/rocr-runtime/template

diff --git a/common/shlibs b/common/shlibs
index 78863e0f7b8..ec34c0df9fa 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3863,3 +3863,4 @@ libc++utilities.so.5 cpp-utilities-5.2.0_1
 libtagparser.so.9 tagparser-9.1.2_1
 libqtutilities.so.6 qtutilities-6.0.4_1
 libhsakmt.so.1 roct-thunk-interface-3.3.0_1
+libhsa-runtime64.so.1 rocr-runtime-3.3.0_1
diff --git a/srcpkgs/rocr-runtime-devel b/srcpkgs/rocr-runtime-devel
new file mode 120000
index 00000000000..be838f22d81
--- /dev/null
+++ b/srcpkgs/rocr-runtime-devel
@@ -0,0 +1 @@
+rocr-runtime
\ No newline at end of file
diff --git a/srcpkgs/rocr-runtime/patches/cmake.patch b/srcpkgs/rocr-runtime/patches/cmake.patch
new file mode 100644
index 00000000000..93b74cd2297
--- /dev/null
+++ b/srcpkgs/rocr-runtime/patches/cmake.patch
@@ -0,0 +1,27 @@
+--- src/CMakeLists.txt.old	2020-04-18 20:01:48.549636995 -0400
++++ src/CMakeLists.txt	2020-04-18 20:04:00.177179781 -0400
+@@ -108,8 +108,8 @@
+ ## ROCr build internal versioning
+ add_definitions ( -DROCR_BUILD_ID=${PACKAGE_VERSION_STRING} )
+ 
+-## Set RUNPATH - ../../lib covers use of the legacy symlink in /hsa/lib/
+-set(CMAKE_INSTALL_RPATH "$ORIGIN;$ORIGIN/../../lib;$ORIGIN/../../lib64;$ORIGIN/../lib64")
++## Set RUNPATH
++set(CMAKE_INSTALL_RPATH "$ORIGIN;$ORIGIN/../lib")
+ 
+ ## ------------------------- Linux Compiler and Linker options -------------------------
+ set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -fexceptions -fno-rtti -fvisibility=hidden -Wno-error=sign-compare -Wno-sign-compare -Wno-write-strings -Wno-conversion-null -fno-math-errno -fno-threadsafe-statics -fmerge-all-constants -fms-extensions -Wno-error=comment -Wno-comment -Wno-error=pointer-arith -Wno-pointer-arith -Wno-error=unused-variable -Wno-error=unused-function" )
+@@ -185,11 +185,8 @@
+ add_custom_target ( hsa_lib_link2 ALL WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMAND ${CMAKE_COMMAND} -E create_symlink ../hsa/lib/${CORE_RUNTIME_LIBRARY}.so.${SO_MAJOR} ${CORE_RUNTIME_LIBRARY}-link.so.${SO_MAJOR} )
+ 
+ ## Set install information
+-install ( TARGETS ${CORE_RUNTIME_TARGET} LIBRARY DESTINATION hsa/lib )
+-install ( DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/inc/ DESTINATION hsa/include/hsa )
+-install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/hsa_include_link DESTINATION include PERMISSIONS OWNER_WRITE OWNER_READ RENAME hsa )
+-install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/${CORE_RUNTIME_LIBRARY}-link.so DESTINATION lib PERMISSIONS OWNER_WRITE OWNER_READ RENAME ${CORE_RUNTIME_LIBRARY}.so )
+-install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/${CORE_RUNTIME_LIBRARY}-link.so.${SO_MAJOR} DESTINATION lib PERMISSIONS OWNER_WRITE OWNER_READ RENAME ${CORE_RUNTIME_LIBRARY}.so.${SO_MAJOR} )
++install ( TARGETS ${CORE_RUNTIME_TARGET} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} )
++install ( DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/inc/ DESTINATION include/hsa )
+ 
+ ## Packaging directives
+ set ( CPACK_GENERATOR "DEB;RPM" CACHE STRING "Package types to build")
diff --git a/srcpkgs/rocr-runtime/template b/srcpkgs/rocr-runtime/template
new file mode 100644
index 00000000000..3588211584c
--- /dev/null
+++ b/srcpkgs/rocr-runtime/template
@@ -0,0 +1,33 @@
+# Template file for 'rocr-runtime'
+pkgname=rocr-runtime
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="ROCR-Runtime-rocm-${version}"
+build_wrksrc="src"
+build_style=cmake
+configure_args="-DCMAKE_INSTALL_PREFIX:PATH=/opt/rocm
+	-DHSAKMT_INC_PATH:PATH=/opt/rocm/include
+	-DHSAKMT_LIB_PATH:PATH=/opt/rocm/lib"
+hostmakedepends="cmake pkg-config"
+makedepends="roct-thunk-interface-devel elfutils-devel"
+short_desc="Radeon Open Compute HSA Runtime"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute/ROCR-Runtime"
+distfiles="${homepage}/archive/rocm-${version}.tar.gz"
+checksum=fa2d2d1f8a61d8a6952d377cf288d78c61776c3c2a666f163cafc3aa19ab0b61
+nocross=yes
+
+post_install() {
+	vlicense ../LICENSE.txt
+}
+
+rocr-runtime-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove opt/rocm/include
+		vmove "opt/rocm/lib/*.so"
+	}
+}

From e1e57ae8ded92527d1cbc5a85d914f015ffe544c Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Mon, 13 Apr 2020 18:07:34 -0400
Subject: [PATCH 3/8] New package: rocm-llvm-3.3.0

---
 srcpkgs/rocm-llvm/template | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)
 create mode 100644 srcpkgs/rocm-llvm/template

diff --git a/srcpkgs/rocm-llvm/template b/srcpkgs/rocm-llvm/template
new file mode 100644
index 00000000000..487a845c733
--- /dev/null
+++ b/srcpkgs/rocm-llvm/template
@@ -0,0 +1,25 @@
+# Template file for 'rocm-llvm'
+pkgname=rocm-llvm
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="llvm-project-rocm-ocl-${version}"
+build_wrksrc=llvm
+build_style=cmake
+configure_args="-DCMAKE_INSTALL_PREFIX:PATH=/opt/rocm/llvm
+	-DLLVM_ENABLE_PROJECTS='llvm;clang;lld' -DLLVM_TARGETS_TO_BUILD='AMDGPU'
+	-DLLVM_BUILD_DOCS=NO -DLLVM_ENABLE_OCAMLDOC=OFF
+	-DLLVM_ENABLE_SPHINX=NO -DLLVM_ENABLE_DOXYGEN=OFF
+	-DLLVM_INSTALL_UTILS=ON -DLLVM_VERSION_SUFFIX=roc -DOCAMLFIND=NO"
+hostmakedepends="cmake pkg-config python3"
+short_desc="Radeon Open Compute LLVM toolchain"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="Apache-2.0, NCSA, custom:LLVM-Exceptions"
+homepage="https://github.com/RadeonOpenCompute/llvm-project"
+distfiles="${homepage}/archive/rocm-ocl-${version}.tar.gz"
+checksum=a2bef7042e8e2f2cd8548cb246b88322e1c77188839983dcac8312d56f544dc8
+nocross=yes
+
+post_install() {
+	vlicense LICENSE.TXT
+}

From 09cd8414ed8ae86d3f0b4d548c809744ea44fd43 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Tue, 14 Apr 2020 10:25:31 -0400
Subject: [PATCH 4/8] New package: rocm-device-libs-3.3.0

---
 srcpkgs/rocm-device-libs/template | 32 +++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)
 create mode 100644 srcpkgs/rocm-device-libs/template

diff --git a/srcpkgs/rocm-device-libs/template b/srcpkgs/rocm-device-libs/template
new file mode 100644
index 00000000000..94b3be580c0
--- /dev/null
+++ b/srcpkgs/rocm-device-libs/template
@@ -0,0 +1,32 @@
+# Template file for 'rocm-device-libs'
+pkgname=rocm-device-libs
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="ROCm-Device-Libs-rocm-ocl-${version}"
+build_style=cmake
+configure_args="-DCMAKE_INSTALL_PREFIX:PATH=/opt/rocm -DLLVM_DIR:PATH=/opt/rocm/llvm"
+hostmakedepends="cmake rocm-llvm"
+short_desc="Radeon Open Compute device libraries"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute/ROCm-Device-Libs"
+distfiles="${homepage}/archive/rocm-ocl-${version}.tar.gz"
+checksum=706b08230790e08ca6a7a2fb7687d6131fd39a562148340e00fa37a6c06769c5
+nocross=yes
+
+pre_configure() {
+	# Build the prepare-builtins executable with native compiler
+	mkdir -p utils/build
+	cd utils/build
+	_prepare_builtins="$PWD/prepare-builtins/prepare-builtins"
+	cmake ${configure_args} ..
+	make ${makejobs}
+
+	# Add path to prepare-builtins for cmake
+	configure_args+=" -DPREPARE_BUILTINS='${_prepare_builtins}'"
+}
+
+post_install() {
+	vlicense LICENSE
+}

From 8e0b895f02b68a2fc2a6b20d77efa634a201ebaf Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Mon, 13 Apr 2020 18:30:00 -0400
Subject: [PATCH 5/8] New package: rocm-comgr-3.3.0

---
 common/shlibs               |  1 +
 srcpkgs/rocm-comgr-devel    |  1 +
 srcpkgs/rocm-comgr/template | 34 ++++++++++++++++++++++++++++++++++
 3 files changed, 36 insertions(+)
 create mode 120000 srcpkgs/rocm-comgr-devel
 create mode 100644 srcpkgs/rocm-comgr/template

diff --git a/common/shlibs b/common/shlibs
index ec34c0df9fa..509755bd8b9 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3864,3 +3864,4 @@ libtagparser.so.9 tagparser-9.1.2_1
 libqtutilities.so.6 qtutilities-6.0.4_1
 libhsakmt.so.1 roct-thunk-interface-3.3.0_1
 libhsa-runtime64.so.1 rocr-runtime-3.3.0_1
+libamd_comgr.so.1 rocm-comgr-3.3.0_1
diff --git a/srcpkgs/rocm-comgr-devel b/srcpkgs/rocm-comgr-devel
new file mode 120000
index 00000000000..3f5ce255e07
--- /dev/null
+++ b/srcpkgs/rocm-comgr-devel
@@ -0,0 +1 @@
+rocm-comgr
\ No newline at end of file
diff --git a/srcpkgs/rocm-comgr/template b/srcpkgs/rocm-comgr/template
new file mode 100644
index 00000000000..4bbc930073c
--- /dev/null
+++ b/srcpkgs/rocm-comgr/template
@@ -0,0 +1,34 @@
+# Template file for 'rocm-comgr'
+pkgname=rocm-comgr
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="ROCm-CompilerSupport-rocm-${version}"
+build_wrksrc="lib/comgr"
+build_style=cmake
+configure_args="-DCMAKE_INSTALL_PREFIX:PATH=/opt/rocm
+	-DClang_DIR:PATH=/opt/rocm/llvm/lib/cmake/clang
+	-DCMAKE_INSTALL_RPATH:PATH='\$ORIGIN:\$ORIGIN/../lib'"
+hostmakedepends="cmake pkg-config rocm-llvm"
+makedepends="rocm-device-libs"
+short_desc="Radeon Open Compute Code Object Manager"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="BSD-3-Clause"
+homepage="https://github.com/RadeonOpenCompute/ROCm-CompilerSupport"
+distfiles="${homepage}/archive/rocm-${version}.tar.gz"
+checksum=01e2524e0f28ecd6f46c9720f279207de935d826b0172158792aa3ec86af9ca7
+nocross=yes
+
+post_install() {
+	vlicense LICENSE.txt
+}
+
+rocm-comgr-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove opt/rocm/include
+		vmove "opt/rocm/lib/*.so"
+		vmove opt/rocm/lib/cmake
+	}
+}

From b01f6c102c83273e07650a5b1c02809bd363aadf Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Fri, 17 Apr 2020 12:11:25 -0400
Subject: [PATCH 6/8] New package: rocminfo-3.3.0

---
 srcpkgs/rocminfo/template | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
 create mode 100644 srcpkgs/rocminfo/template

diff --git a/srcpkgs/rocminfo/template b/srcpkgs/rocminfo/template
new file mode 100644
index 00000000000..91128a766f3
--- /dev/null
+++ b/srcpkgs/rocminfo/template
@@ -0,0 +1,21 @@
+# Template file for 'rocminfo'
+pkgname=rocminfo
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="rocminfo-rocm-${version}"
+build_style=cmake
+configure_args="-DCMAKE_INSTALL_PREFIX:PATH=/opt/rocm -DROCM_DIR=/opt/rocm"
+hostmakedepends="cmake pkg-config"
+makedepends="rocr-runtime-devel"
+short_desc="Radeon Open Compute system information reporter"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute/rocminfo"
+distfiles="${homepage}/archive/rocm-${version}.tar.gz"
+checksum=e666f662c9e465aaabbbd0b109d87e017243cdf1a0898fabf5a90947bb3dbcd7
+nocross=yes
+
+post_install() {
+	vlicense License.txt
+}

From 48bf1287557baec568cb7ae7992032edfd654e9a Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Sun, 19 Apr 2020 15:01:40 -0400
Subject: [PATCH 7/8] New package: rocm-bandwidth-test-3.3.0

---
 srcpkgs/rocm-bandwidth-test/template | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
 create mode 100644 srcpkgs/rocm-bandwidth-test/template

diff --git a/srcpkgs/rocm-bandwidth-test/template b/srcpkgs/rocm-bandwidth-test/template
new file mode 100644
index 00000000000..b44a8646ab2
--- /dev/null
+++ b/srcpkgs/rocm-bandwidth-test/template
@@ -0,0 +1,22 @@
+# Template file for 'rocm-bandwidth-test'
+pkgname=rocm-bandwidth-test
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="rocm_bandwidth_test-rocm-${version}"
+build_style=cmake
+configure_args="-DCMAKE_INSTALL_PREFIX:PATH=/opt/rocm
+	-DCMAKE_INSTALL_RPATH:PATH='\$ORIGIN:\$ORIGIN/../lib'"
+hostmakedepends="cmake"
+makedepends="rocr-runtime-devel roct-thunk-interface-devel"
+short_desc="Radeon Open Compute bandwidth test"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute/rocm_bandwidth_test"
+distfiles="${homepage}/archive/rocm-${version}.tar.gz"
+checksum=f5f914073018619dc91662d5bf630903dfa4db9136d603591917fdfb3c9164ce
+nocross=yes
+
+post_install() {
+	vlicense LICENSE.txt
+}

From 7ebde26a3af0fe554232a868475b3c173e930837 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Tue, 14 Apr 2020 10:25:54 -0400
Subject: [PATCH 8/8] New package: rocm-opencl-runtime-3.3.0 [ci skip]

---
 common/shlibs                                 |   1 +
 srcpkgs/rocm-opencl-runtime-devel             |   1 +
 .../files/libelf-musl.patch                   | 688 ++++++++++++++++++
 .../files/runtime-musl.patch                  |  11 +
 srcpkgs/rocm-opencl-runtime/files/sys_queue.h | 574 +++++++++++++++
 .../rocm-opencl-runtime/patches/cmake.patch   | 123 ++++
 srcpkgs/rocm-opencl-runtime/template          |  78 ++
 7 files changed, 1476 insertions(+)
 create mode 120000 srcpkgs/rocm-opencl-runtime-devel
 create mode 100644 srcpkgs/rocm-opencl-runtime/files/libelf-musl.patch
 create mode 100644 srcpkgs/rocm-opencl-runtime/files/runtime-musl.patch
 create mode 100644 srcpkgs/rocm-opencl-runtime/files/sys_queue.h
 create mode 100644 srcpkgs/rocm-opencl-runtime/patches/cmake.patch
 create mode 100644 srcpkgs/rocm-opencl-runtime/template

diff --git a/common/shlibs b/common/shlibs
index 509755bd8b9..d087fa3ab4b 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3865,3 +3865,4 @@ libqtutilities.so.6 qtutilities-6.0.4_1
 libhsakmt.so.1 roct-thunk-interface-3.3.0_1
 libhsa-runtime64.so.1 rocr-runtime-3.3.0_1
 libamd_comgr.so.1 rocm-comgr-3.3.0_1
+libOpenCL-ROCm.so.1 rocm-opencl-runtime-3.3.0_1
diff --git a/srcpkgs/rocm-opencl-runtime-devel b/srcpkgs/rocm-opencl-runtime-devel
new file mode 120000
index 00000000000..b2cda7e229d
--- /dev/null
+++ b/srcpkgs/rocm-opencl-runtime-devel
@@ -0,0 +1 @@
+rocm-opencl-runtime
\ No newline at end of file
diff --git a/srcpkgs/rocm-opencl-runtime/files/libelf-musl.patch b/srcpkgs/rocm-opencl-runtime/files/libelf-musl.patch
new file mode 100644
index 00000000000..a3705c259a9
--- /dev/null
+++ b/srcpkgs/rocm-opencl-runtime/files/libelf-musl.patch
@@ -0,0 +1,688 @@
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/_libelf.h compiler/lib/loaders/elf/utils/libelf/_libelf.h
+--- compiler/lib/loaders/elf/utils/libelf.orig/_libelf.h	2020-04-19 08:59:34.201386585 -0400
++++ compiler/lib/loaders/elf/utils/libelf/_libelf.h	2020-04-19 09:04:12.950433528 -0400
+@@ -30,7 +30,7 @@
+ #define	__LIBELF_H_
+ 
+ #include <limits.h>
+-#include <sys/queue.h>
++#include "sys_queue.h"
+ 
+ #include "_libelf_config.h"
+ 
+@@ -179,7 +179,9 @@
+  * Function Prototypes.
+  */
+ 
+-__BEGIN_DECLS
++#ifdef __cplusplus
++extern "C" {
++#endif
+ Elf_Data *_libelf_allocate_data(Elf_Scn *_s);
+ Elf	*_libelf_allocate_elf(Elf_Mem *mem);
+ Elf_Scn	*_libelf_allocate_scn(Elf *_e, size_t _ndx);
+@@ -213,6 +215,8 @@
+ Elf_Data *_libelf_xlate(Elf_Data *_d, const Elf_Data *_s,
+     unsigned int _encoding, int _elfclass, int _direction);
+ int	_libelf_xlate_shtype(uint32_t _sht);
+-__END_DECLS
++#ifdef __cplusplus
++}
++#endif
+ 
+ #endif	/* __LIBELF_H_ */
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_begin.c compiler/lib/loaders/elf/utils/libelf/elf_begin.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_begin.c	2020-04-19 08:59:34.201386585 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_begin.c	2020-04-19 09:01:04.313212042 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <sys/types.h>
+ #if !defined(WIN32)
+ #include <sys/errno.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_end.c compiler/lib/loaders/elf/utils/libelf/elf_end.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_end.c	2020-04-19 08:59:34.201386585 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_end.c	2020-04-19 09:01:14.895204681 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #if !defined(WIN32)
+ #include <sys/mman.h>
+ #endif
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_errmsg.c compiler/lib/loaders/elf/utils/libelf/elf_errmsg.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_errmsg.c	2020-04-19 08:59:34.201386585 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_errmsg.c	2020-04-19 09:01:16.753207065 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ #include <stdio.h>
+ #include <string.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_errno.c compiler/lib/loaders/elf/utils/libelf/elf_errno.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_errno.c	2020-04-19 08:59:34.201386585 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_errno.c	2020-04-19 09:01:18.669209528 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_fill.c compiler/lib/loaders/elf/utils/libelf/elf_fill.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_fill.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_fill.c	2020-04-19 09:01:21.109212667 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_flag.c compiler/lib/loaders/elf/utils/libelf/elf_flag.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_flag.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_flag.c	2020-04-19 09:01:23.376215579 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_getarhdr.c compiler/lib/loaders/elf/utils/libelf/elf_getarhdr.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_getarhdr.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_getarhdr.c	2020-04-19 09:01:25.414218197 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_getarsym.c compiler/lib/loaders/elf/utils/libelf/elf_getarsym.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_getarsym.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_getarsym.c	2020-04-19 09:01:27.575220978 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_getbase.c compiler/lib/loaders/elf/utils/libelf/elf_getbase.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_getbase.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_getbase.c	2020-04-19 09:01:29.963224043 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_getident.c compiler/lib/loaders/elf/utils/libelf/elf_getident.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_getident.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_getident.c	2020-04-19 09:01:31.912226551 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <ar.h>
+ #include <assert.h>
+ #include <libelf.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_hash.c compiler/lib/loaders/elf/utils/libelf/elf_hash.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_hash.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_hash.c	2020-04-19 09:01:33.877229069 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ #include "_libelf_config.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_kind.c compiler/lib/loaders/elf/utils/libelf/elf_kind.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_kind.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_kind.c	2020-04-19 09:01:35.940231721 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_memory.c compiler/lib/loaders/elf/utils/libelf/elf_memory.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_memory.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_memory.c	2020-04-19 09:01:38.171234596 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <ar.h>
+ #include <libelf.h>
+ #include <string.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_next.c compiler/lib/loaders/elf/utils/libelf/elf_next.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_next.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_next.c	2020-04-19 09:01:40.063237028 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <ar.h>
+ #include <assert.h>
+ #include <libelf.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_phnum.c compiler/lib/loaders/elf/utils/libelf/elf_phnum.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_phnum.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_phnum.c	2020-04-19 09:01:42.480240134 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <ar.h>
+ #include <libelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_rand.c compiler/lib/loaders/elf/utils/libelf/elf_rand.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_rand.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_rand.c	2020-04-19 09:01:45.061243452 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <ar.h>
+ #include <libelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_rawfile.c compiler/lib/loaders/elf/utils/libelf/elf_rawfile.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_rawfile.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_rawfile.c	2020-04-19 09:01:46.988245928 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_scn.c compiler/lib/loaders/elf/utils/libelf/elf_scn.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_scn.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_scn.c	2020-04-19 09:00:19.724298403 -0400
+@@ -24,8 +24,7 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-#include <sys/queue.h>
++#include "sys_queue.h"
+ 
+ #include <assert.h>
+ #include <errno.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_shnum.c compiler/lib/loaders/elf/utils/libelf/elf_shnum.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_shnum.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_shnum.c	2020-04-19 09:01:51.763252060 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <ar.h>
+ #include <libelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_shstrndx.c compiler/lib/loaders/elf/utils/libelf/elf_shstrndx.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_shstrndx.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_shstrndx.c	2020-04-19 09:01:53.532254340 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <ar.h>
+ #include <libelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_version.c compiler/lib/loaders/elf/utils/libelf/elf_version.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_version.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_version.c	2020-04-19 09:02:01.337264370 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf.h compiler/lib/loaders/elf/utils/libelf/gelf.h
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf.h	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf.h	2020-04-19 09:04:29.669455020 -0400
+@@ -29,8 +29,6 @@
+ #ifndef	_GELF_H_
+ #define	_GELF_H_
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ typedef Elf64_Addr	GElf_Addr;	/* Addresses */
+@@ -72,7 +70,9 @@
+ #define	GELF_ST_TYPE			ELF64_ST_TYPE
+ #define	GELF_ST_VISIBILITY		ELF64_ST_VISIBILITY
+ 
+-__BEGIN_DECLS
++#ifdef __cplusplus
++extern "C" {
++#endif
+ long		gelf_checksum(Elf *_elf);
+ size_t		gelf_fsize(Elf *_elf, Elf_Type _type, size_t _count,
+ 			unsigned int _version);
+@@ -109,6 +109,8 @@
+ int		gelf_update_move(Elf_Data *_dst, int _index, GElf_Move *_src);
+ int		gelf_update_syminfo(Elf_Data *_dst, int _index, GElf_Syminfo *_src);
+ #endif
+-__END_DECLS
++#ifdef __cplusplus
++}
++#endif
+ 
+ #endif	/* _GELF_H_ */
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_cap.c compiler/lib/loaders/elf/utils/libelf/gelf_cap.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_cap.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_cap.c	2020-04-19 09:02:05.429269632 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_checksum.c compiler/lib/loaders/elf/utils/libelf/gelf_checksum.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_checksum.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_checksum.c	2020-04-19 09:02:08.192273183 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <gelf.h>
+ #include <libelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_dyn.c compiler/lib/loaders/elf/utils/libelf/gelf_dyn.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_dyn.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_dyn.c	2020-04-19 09:02:10.020275525 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_ehdr.c compiler/lib/loaders/elf/utils/libelf/gelf_ehdr.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_ehdr.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_ehdr.c	2020-04-19 09:02:11.882277926 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ #include <libelf.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_fsize.c compiler/lib/loaders/elf/utils/libelf/gelf_fsize.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_fsize.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_fsize.c	2020-04-19 09:02:14.139280827 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <gelf.h>
+ #include <libelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_getclass.c compiler/lib/loaders/elf/utils/libelf/gelf_getclass.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_getclass.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_getclass.c	2020-04-19 09:02:17.269284848 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <gelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_move.c compiler/lib/loaders/elf/utils/libelf/gelf_move.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_move.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_move.c	2020-04-19 09:02:18.974287034 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_phdr.c compiler/lib/loaders/elf/utils/libelf/gelf_phdr.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_phdr.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_phdr.c	2020-04-19 09:02:20.676289227 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <gelf.h>
+ #include <libelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_rel.c compiler/lib/loaders/elf/utils/libelf/gelf_rel.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_rel.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_rel.c	2020-04-19 09:02:23.177292435 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_rela.c compiler/lib/loaders/elf/utils/libelf/gelf_rela.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_rela.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_rela.c	2020-04-19 09:02:25.246295100 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_shdr.c compiler/lib/loaders/elf/utils/libelf/gelf_shdr.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_shdr.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_shdr.c	2020-04-19 09:02:28.325299060 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ #include <libelf.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_sym.c compiler/lib/loaders/elf/utils/libelf/gelf_sym.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_sym.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_sym.c	2020-04-19 09:02:30.113301356 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_syminfo.c compiler/lib/loaders/elf/utils/libelf/gelf_syminfo.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_syminfo.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_syminfo.c	2020-04-19 09:02:31.906303662 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_symshndx.c compiler/lib/loaders/elf/utils/libelf/gelf_symshndx.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_symshndx.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_symshndx.c	2020-04-19 09:02:33.626305873 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_xlate.c compiler/lib/loaders/elf/utils/libelf/gelf_xlate.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_xlate.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_xlate.c	2020-04-19 09:02:35.921308822 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <gelf.h>
+ #include <libelf.h>
+ #include <string.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf.h compiler/lib/loaders/elf/utils/libelf/libelf.h
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf.h	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf.h	2020-04-19 09:04:38.760466706 -0400
+@@ -30,7 +30,7 @@
+ #define	_LIBELF_H_
+ 
+ #include <sys/types.h>
+-#include <sys/queue.h>
++#include "sys_queue.h"
+ #include <elfdefinitions.h>
+ #ifndef EM_HSAIL
+ #define EM_HSAIL 0xAF5A
+@@ -187,7 +187,9 @@
+ #define	ELF_F_ARCHIVE	   0x100U /* archive creation */
+ #define	ELF_F_ARCHIVE_SYSV 0x200U /* SYSV style archive */
+ 
+-__BEGIN_DECLS
++#ifdef __cplusplus
++extern "C" {
++#endif
+ Elf		*elf_begin(int _fd, Elf_Cmd _cmd, Elf *_elf, Elf_Mem *_mem);
+ int		elf_cntl(Elf *_elf, Elf_Cmd _cmd);
+ int		elf_end(Elf *_elf);
+@@ -257,6 +259,8 @@
+ 			unsigned int _enc);
+ Elf_Data	*elf64_xlatetom(Elf_Data *_dst, const Elf_Data *_src,
+ 			unsigned int _enc);
+-__END_DECLS
++#ifdef __cplusplus
++}
++#endif
+ 
+ #endif	/* _LIBELF_H_ */
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_align.c compiler/lib/loaders/elf/utils/libelf/libelf_align.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_align.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_align.c	2020-04-19 09:02:40.660314911 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <sys/types.h>
+ 
+ #include <libelf.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_allocate.c compiler/lib/loaders/elf/utils/libelf/libelf_allocate.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_allocate.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_allocate.c	2020-04-19 09:02:43.079318019 -0400
+@@ -28,8 +28,6 @@
+  * Internal APIs
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #if !defined(WIN32)
+ #include <sys/errno.h>
+ #endif
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_ar.c compiler/lib/loaders/elf/utils/libelf/libelf_ar.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_ar.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_ar.c	2020-04-19 09:02:44.763320187 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <ctype.h>
+ #include <libelf.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_ar_util.c compiler/lib/loaders/elf/utils/libelf/libelf_ar_util.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_ar_util.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_ar_util.c	2020-04-19 09:02:46.461322369 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <libelf.h>
+ #include <stdlib.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_checksum.c compiler/lib/loaders/elf/utils/libelf/libelf_checksum.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_checksum.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_checksum.c	2020-04-19 09:02:48.645325173 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <gelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_convert.c compiler/lib/loaders/elf/utils/libelf/libelf_convert.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_convert.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_convert.c	2020-04-19 09:02:50.883328053 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <libelf.h>
+ #include <string.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_data.c compiler/lib/loaders/elf/utils/libelf/libelf_data.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_data.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_data.c	2020-04-19 09:02:52.951330708 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_ehdr.c compiler/lib/loaders/elf/utils/libelf/libelf_ehdr.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_ehdr.c	2020-04-19 08:59:34.204386579 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_ehdr.c	2020-04-19 09:02:55.176333563 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ #include <libelf.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_extended.c compiler/lib/loaders/elf/utils/libelf/libelf_extended.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_extended.c	2020-04-19 08:59:34.204386579 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_extended.c	2020-04-19 09:02:57.932337110 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <libelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_msize.c compiler/lib/loaders/elf/utils/libelf/libelf_msize.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_msize.c	2020-04-19 08:59:34.204386579 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_msize.c	2020-04-19 09:03:02.201342598 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <libelf.h>
+ #include <string.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_phdr.c compiler/lib/loaders/elf/utils/libelf/libelf_phdr.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_phdr.c	2020-04-19 08:59:34.204386579 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_phdr.c	2020-04-19 09:03:04.194345160 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ #include <libelf.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_shdr.c compiler/lib/loaders/elf/utils/libelf/libelf_shdr.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_shdr.c	2020-04-19 08:59:34.204386579 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_shdr.c	2020-04-19 09:03:05.795347218 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <gelf.h>
+ #include <libelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_xlate.c compiler/lib/loaders/elf/utils/libelf/libelf_xlate.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_xlate.c	2020-04-19 08:59:34.204386579 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_xlate.c	2020-04-19 09:03:09.472351944 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <libelf.h>
+ 
diff --git a/srcpkgs/rocm-opencl-runtime/files/runtime-musl.patch b/srcpkgs/rocm-opencl-runtime/files/runtime-musl.patch
new file mode 100644
index 00000000000..ea18e90e09c
--- /dev/null
+++ b/srcpkgs/rocm-opencl-runtime/files/runtime-musl.patch
@@ -0,0 +1,11 @@
+--- runtime/os/os_posix.cpp.orig	2020-04-19 09:13:51.701982901 -0400
++++ runtime/os/os_posix.cpp	2020-04-19 09:14:04.156947422 -0400
+@@ -44,6 +44,8 @@
+ #include <algorithm>
+ #include <mutex>
+ 
++#include <libgen.h> // for basename
++
+ 
+ namespace amd {
+ 
diff --git a/srcpkgs/rocm-opencl-runtime/files/sys_queue.h b/srcpkgs/rocm-opencl-runtime/files/sys_queue.h
new file mode 100644
index 00000000000..daf4553d33e
--- /dev/null
+++ b/srcpkgs/rocm-opencl-runtime/files/sys_queue.h
@@ -0,0 +1,574 @@
+/*
+ * Copyright (c) 1991, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *	@(#)queue.h	8.5 (Berkeley) 8/20/94
+ */
+
+#ifndef	_SYS_QUEUE_H_
+#define	_SYS_QUEUE_H_
+
+/*
+ * This file defines five types of data structures: singly-linked lists,
+ * lists, simple queues, tail queues, and circular queues.
+ *
+ * A singly-linked list is headed by a single forward pointer. The
+ * elements are singly linked for minimum space and pointer manipulation
+ * overhead at the expense of O(n) removal for arbitrary elements. New
+ * elements can be added to the list after an existing element or at the
+ * head of the list.  Elements being removed from the head of the list
+ * should use the explicit macro for this purpose for optimum
+ * efficiency. A singly-linked list may only be traversed in the forward
+ * direction.  Singly-linked lists are ideal for applications with large
+ * datasets and few or no removals or for implementing a LIFO queue.
+ *
+ * A list is headed by a single forward pointer (or an array of forward
+ * pointers for a hash table header). The elements are doubly linked
+ * so that an arbitrary element can be removed without a need to
+ * traverse the list. New elements can be added to the list before
+ * or after an existing element or at the head of the list. A list
+ * may only be traversed in the forward direction.
+ *
+ * A simple queue is headed by a pair of pointers, one the head of the
+ * list and the other to the tail of the list. The elements are singly
+ * linked to save space, so elements can only be removed from the
+ * head of the list. New elements can be added to the list after
+ * an existing element, at the head of the list, or at the end of the
+ * list. A simple queue may only be traversed in the forward direction.
+ *
+ * A tail queue is headed by a pair of pointers, one to the head of the
+ * list and the other to the tail of the list. The elements are doubly
+ * linked so that an arbitrary element can be removed without a need to
+ * traverse the list. New elements can be added to the list before or
+ * after an existing element, at the head of the list, or at the end of
+ * the list. A tail queue may be traversed in either direction.
+ *
+ * A circle queue is headed by a pair of pointers, one to the head of the
+ * list and the other to the tail of the list. The elements are doubly
+ * linked so that an arbitrary element can be removed without a need to
+ * traverse the list. New elements can be added to the list before or after
+ * an existing element, at the head of the list, or at the end of the list.
+ * A circle queue may be traversed in either direction, but has a more
+ * complex end of list detection.
+ *
+ * For details on the use of these macros, see the queue(3) manual page.
+ */
+
+/*
+ * List definitions.
+ */
+#define	LIST_HEAD(name, type)						\
+struct name {								\
+	struct type *lh_first;	/* first element */			\
+}
+
+#define	LIST_HEAD_INITIALIZER(head)					\
+	{ NULL }
+
+#define	LIST_ENTRY(type)						\
+struct {								\
+	struct type *le_next;	/* next element */			\
+	struct type **le_prev;	/* address of previous next element */	\
+}
+
+/*
+ * List functions.
+ */
+#define	LIST_INIT(head) do {						\
+	(head)->lh_first = NULL;					\
+} while (/*CONSTCOND*/0)
+
+#define	LIST_INSERT_AFTER(listelm, elm, field) do {			\
+	if (((elm)->field.le_next = (listelm)->field.le_next) != NULL)	\
+		(listelm)->field.le_next->field.le_prev =		\
+		    &(elm)->field.le_next;				\
+	(listelm)->field.le_next = (elm);				\
+	(elm)->field.le_prev = &(listelm)->field.le_next;		\
+} while (/*CONSTCOND*/0)
+
+#define	LIST_INSERT_BEFORE(listelm, elm, field) do {			\
+	(elm)->field.le_prev = (listelm)->field.le_prev;		\
+	(elm)->field.le_next = (listelm);				\
+	*(listelm)->field.le_prev = (elm);				\
+	(listelm)->field.le_prev = &(elm)->field.le_next;		\
+} while (/*CONSTCOND*/0)
+
+#define	LIST_INSERT_HEAD(head, elm, field) do {				\
+	if (((elm)->field.le_next = (head)->lh_first) != NULL)		\
+		(head)->lh_first->field.le_prev = &(elm)->field.le_next;\
+	(head)->lh_first = (elm);					\
+	(elm)->field.le_prev = &(head)->lh_first;			\
+} while (/*CONSTCOND*/0)
+
+#define	LIST_REMOVE(elm, field) do {					\
+	if ((elm)->field.le_next != NULL)				\
+		(elm)->field.le_next->field.le_prev = 			\
+		    (elm)->field.le_prev;				\
+	*(elm)->field.le_prev = (elm)->field.le_next;			\
+} while (/*CONSTCOND*/0)
+
+#define	LIST_FOREACH(var, head, field)					\
+	for ((var) = ((head)->lh_first);				\
+		(var);							\
+		(var) = ((var)->field.le_next))
+
+/*
+ * List access methods.
+ */
+#define	LIST_EMPTY(head)		((head)->lh_first == NULL)
+#define	LIST_FIRST(head)		((head)->lh_first)
+#define	LIST_NEXT(elm, field)		((elm)->field.le_next)
+
+
+/*
+ * Singly-linked List definitions.
+ */
+#define	SLIST_HEAD(name, type)						\
+struct name {								\
+	struct type *slh_first;	/* first element */			\
+}
+
+#define	SLIST_HEAD_INITIALIZER(head)					\
+	{ NULL }
+
+#define	SLIST_ENTRY(type)						\
+struct {								\
+	struct type *sle_next;	/* next element */			\
+}
+
+/*
+ * Singly-linked List functions.
+ */
+#define	SLIST_INIT(head) do {						\
+	(head)->slh_first = NULL;					\
+} while (/*CONSTCOND*/0)
+
+#define	SLIST_INSERT_AFTER(slistelm, elm, field) do {			\
+	(elm)->field.sle_next = (slistelm)->field.sle_next;		\
+	(slistelm)->field.sle_next = (elm);				\
+} while (/*CONSTCOND*/0)
+
+#define	SLIST_INSERT_HEAD(head, elm, field) do {			\
+	(elm)->field.sle_next = (head)->slh_first;			\
+	(head)->slh_first = (elm);					\
+} while (/*CONSTCOND*/0)
+
+#define	SLIST_REMOVE_HEAD(head, field) do {				\
+	(head)->slh_first = (head)->slh_first->field.sle_next;		\
+} while (/*CONSTCOND*/0)
+
+#define	SLIST_REMOVE(head, elm, type, field) do {			\
+	if ((head)->slh_first == (elm)) {				\
+		SLIST_REMOVE_HEAD((head), field);			\
+	}								\
+	else {								\
+		struct type *curelm = (head)->slh_first;		\
+		while(curelm->field.sle_next != (elm))			\
+			curelm = curelm->field.sle_next;		\
+		curelm->field.sle_next =				\
+		    curelm->field.sle_next->field.sle_next;		\
+	}								\
+} while (/*CONSTCOND*/0)
+
+#define	SLIST_FOREACH(var, head, field)					\
+	for((var) = (head)->slh_first; (var); (var) = (var)->field.sle_next)
+
+/*
+ * Singly-linked List access methods.
+ */
+#define	SLIST_EMPTY(head)	((head)->slh_first == NULL)
+#define	SLIST_FIRST(head)	((head)->slh_first)
+#define	SLIST_NEXT(elm, field)	((elm)->field.sle_next)
+
+
+/*
+ * Singly-linked Tail queue declarations.
+ */
+#define	STAILQ_HEAD(name, type)					\
+struct name {								\
+	struct type *stqh_first;	/* first element */			\
+	struct type **stqh_last;	/* addr of last next element */		\
+}
+
+#define	STAILQ_HEAD_INITIALIZER(head)					\
+	{ NULL, &(head).stqh_first }
+
+#define	STAILQ_ENTRY(type)						\
+struct {								\
+	struct type *stqe_next;	/* next element */			\
+}
+
+/*
+ * Singly-linked Tail queue functions.
+ */
+#define	STAILQ_INIT(head) do {						\
+	(head)->stqh_first = NULL;					\
+	(head)->stqh_last = &(head)->stqh_first;				\
+} while (/*CONSTCOND*/0)
+
+#define	STAILQ_INSERT_HEAD(head, elm, field) do {			\
+	if (((elm)->field.stqe_next = (head)->stqh_first) == NULL)	\
+		(head)->stqh_last = &(elm)->field.stqe_next;		\
+	(head)->stqh_first = (elm);					\
+} while (/*CONSTCOND*/0)
+
+#define	STAILQ_INSERT_TAIL(head, elm, field) do {			\
+	(elm)->field.stqe_next = NULL;					\
+	*(head)->stqh_last = (elm);					\
+	(head)->stqh_last = &(elm)->field.stqe_next;			\
+} while (/*CONSTCOND*/0)
+
+#define	STAILQ_INSERT_AFTER(head, listelm, elm, field) do {		\
+	if (((elm)->field.stqe_next = (listelm)->field.stqe_next) == NULL)\
+		(head)->stqh_last = &(elm)->field.stqe_next;		\
+	(listelm)->field.stqe_next = (elm);				\
+} while (/*CONSTCOND*/0)
+
+#define	STAILQ_REMOVE_HEAD(head, field) do {				\
+	if (((head)->stqh_first = (head)->stqh_first->field.stqe_next) == NULL) \
+		(head)->stqh_last = &(head)->stqh_first;			\
+} while (/*CONSTCOND*/0)
+
+#define	STAILQ_REMOVE(head, elm, type, field) do {			\
+	if ((head)->stqh_first == (elm)) {				\
+		STAILQ_REMOVE_HEAD((head), field);			\
+	} else {							\
+		struct type *curelm = (head)->stqh_first;		\
+		while (curelm->field.stqe_next != (elm))			\
+			curelm = curelm->field.stqe_next;		\
+		if ((curelm->field.stqe_next =				\
+			curelm->field.stqe_next->field.stqe_next) == NULL) \
+			    (head)->stqh_last = &(curelm)->field.stqe_next; \
+	}								\
+} while (/*CONSTCOND*/0)
+
+#define	STAILQ_FOREACH(var, head, field)				\
+	for ((var) = ((head)->stqh_first);				\
+		(var);							\
+		(var) = ((var)->field.stqe_next))
+
+#define	STAILQ_CONCAT(head1, head2) do {				\
+	if (!STAILQ_EMPTY((head2))) {					\
+		*(head1)->stqh_last = (head2)->stqh_first;		\
+		(head1)->stqh_last = (head2)->stqh_last;		\
+		STAILQ_INIT((head2));					\
+	}								\
+} while (/*CONSTCOND*/0)
+
+/*
+ * Singly-linked Tail queue access methods.
+ */
+#define	STAILQ_EMPTY(head)	((head)->stqh_first == NULL)
+#define	STAILQ_FIRST(head)	((head)->stqh_first)
+#define	STAILQ_NEXT(elm, field)	((elm)->field.stqe_next)
+
+
+/*
+ * Simple queue definitions.
+ */
+#define	SIMPLEQ_HEAD(name, type)					\
+struct name {								\
+	struct type *sqh_first;	/* first element */			\
+	struct type **sqh_last;	/* addr of last next element */		\
+}
+
+#define	SIMPLEQ_HEAD_INITIALIZER(head)					\
+	{ NULL, &(head).sqh_first }
+
+#define	SIMPLEQ_ENTRY(type)						\
+struct {								\
+	struct type *sqe_next;	/* next element */			\
+}
+
+/*
+ * Simple queue functions.
+ */
+#define	SIMPLEQ_INIT(head) do {						\
+	(head)->sqh_first = NULL;					\
+	(head)->sqh_last = &(head)->sqh_first;				\
+} while (/*CONSTCOND*/0)
+
+#define	SIMPLEQ_INSERT_HEAD(head, elm, field) do {			\
+	if (((elm)->field.sqe_next = (head)->sqh_first) == NULL)	\
+		(head)->sqh_last = &(elm)->field.sqe_next;		\
+	(head)->sqh_first = (elm);					\
+} while (/*CONSTCOND*/0)
+
+#define	SIMPLEQ_INSERT_TAIL(head, elm, field) do {			\
+	(elm)->field.sqe_next = NULL;					\
+	*(head)->sqh_last = (elm);					\
+	(head)->sqh_last = &(elm)->field.sqe_next;			\
+} while (/*CONSTCOND*/0)
+
+#define	SIMPLEQ_INSERT_AFTER(head, listelm, elm, field) do {		\
+	if (((elm)->field.sqe_next = (listelm)->field.sqe_next) == NULL)\
+		(head)->sqh_last = &(elm)->field.sqe_next;		\
+	(listelm)->field.sqe_next = (elm);				\
+} while (/*CONSTCOND*/0)
+
+#define	SIMPLEQ_REMOVE_HEAD(head, field) do {				\
+	if (((head)->sqh_first = (head)->sqh_first->field.sqe_next) == NULL) \
+		(head)->sqh_last = &(head)->sqh_first;			\
+} while (/*CONSTCOND*/0)
+
+#define	SIMPLEQ_REMOVE(head, elm, type, field) do {			\
+	if ((head)->sqh_first == (elm)) {				\
+		SIMPLEQ_REMOVE_HEAD((head), field);			\
+	} else {							\
+		struct type *curelm = (head)->sqh_first;		\
+		while (curelm->field.sqe_next != (elm))			\
+			curelm = curelm->field.sqe_next;		\
+		if ((curelm->field.sqe_next =				\
+			curelm->field.sqe_next->field.sqe_next) == NULL) \
+			    (head)->sqh_last = &(curelm)->field.sqe_next; \
+	}								\
+} while (/*CONSTCOND*/0)
+
+#define	SIMPLEQ_FOREACH(var, head, field)				\
+	for ((var) = ((head)->sqh_first);				\
+		(var);							\
+		(var) = ((var)->field.sqe_next))
+
+/*
+ * Simple queue access methods.
+ */
+#define	SIMPLEQ_EMPTY(head)		((head)->sqh_first == NULL)
+#define	SIMPLEQ_FIRST(head)		((head)->sqh_first)
+#define	SIMPLEQ_NEXT(elm, field)	((elm)->field.sqe_next)
+
+
+/*
+ * Tail queue definitions.
+ */
+#define	_TAILQ_HEAD(name, type, qual)					\
+struct name {								\
+	qual type *tqh_first;		/* first element */		\
+	qual type *qual *tqh_last;	/* addr of last next element */	\
+}
+#define TAILQ_HEAD(name, type)	_TAILQ_HEAD(name, struct type,)
+
+#define	TAILQ_HEAD_INITIALIZER(head)					\
+	{ NULL, &(head).tqh_first }
+
+#define	_TAILQ_ENTRY(type, qual)					\
+struct {								\
+	qual type *tqe_next;		/* next element */		\
+	qual type *qual *tqe_prev;	/* address of previous next element */\
+}
+#define TAILQ_ENTRY(type)	_TAILQ_ENTRY(struct type,)
+
+/*
+ * Tail queue functions.
+ */
+#define	TAILQ_INIT(head) do {						\
+	(head)->tqh_first = NULL;					\
+	(head)->tqh_last = &(head)->tqh_first;				\
+} while (/*CONSTCOND*/0)
+
+#define	TAILQ_INSERT_HEAD(head, elm, field) do {			\
+	if (((elm)->field.tqe_next = (head)->tqh_first) != NULL)	\
+		(head)->tqh_first->field.tqe_prev =			\
+		    &(elm)->field.tqe_next;				\
+	else								\
+		(head)->tqh_last = &(elm)->field.tqe_next;		\
+	(head)->tqh_first = (elm);					\
+	(elm)->field.tqe_prev = &(head)->tqh_first;			\
+} while (/*CONSTCOND*/0)
+
+#define	TAILQ_INSERT_TAIL(head, elm, field) do {			\
+	(elm)->field.tqe_next = NULL;					\
+	(elm)->field.tqe_prev = (head)->tqh_last;			\
+	*(head)->tqh_last = (elm);					\
+	(head)->tqh_last = &(elm)->field.tqe_next;			\
+} while (/*CONSTCOND*/0)
+
+#define	TAILQ_INSERT_AFTER(head, listelm, elm, field) do {		\
+	if (((elm)->field.tqe_next = (listelm)->field.tqe_next) != NULL)\
+		(elm)->field.tqe_next->field.tqe_prev = 		\
+		    &(elm)->field.tqe_next;				\
+	else								\
+		(head)->tqh_last = &(elm)->field.tqe_next;		\
+	(listelm)->field.tqe_next = (elm);				\
+	(elm)->field.tqe_prev = &(listelm)->field.tqe_next;		\
+} while (/*CONSTCOND*/0)
+
+#define	TAILQ_INSERT_BEFORE(listelm, elm, field) do {			\
+	(elm)->field.tqe_prev = (listelm)->field.tqe_prev;		\
+	(elm)->field.tqe_next = (listelm);				\
+	*(listelm)->field.tqe_prev = (elm);				\
+	(listelm)->field.tqe_prev = &(elm)->field.tqe_next;		\
+} while (/*CONSTCOND*/0)
+
+#define	TAILQ_REMOVE(head, elm, field) do {				\
+	if (((elm)->field.tqe_next) != NULL)				\
+		(elm)->field.tqe_next->field.tqe_prev = 		\
+		    (elm)->field.tqe_prev;				\
+	else								\
+		(head)->tqh_last = (elm)->field.tqe_prev;		\
+	*(elm)->field.tqe_prev = (elm)->field.tqe_next;			\
+} while (/*CONSTCOND*/0)
+
+#define	TAILQ_FOREACH(var, head, field)					\
+	for ((var) = ((head)->tqh_first);				\
+		(var);							\
+		(var) = ((var)->field.tqe_next))
+
+#define	TAILQ_FOREACH_REVERSE(var, head, headname, field)		\
+	for ((var) = (*(((struct headname *)((head)->tqh_last))->tqh_last));	\
+		(var);							\
+		(var) = (*(((struct headname *)((var)->field.tqe_prev))->tqh_last)))
+
+#define	TAILQ_CONCAT(head1, head2, field) do {				\
+	if (!TAILQ_EMPTY(head2)) {					\
+		*(head1)->tqh_last = (head2)->tqh_first;		\
+		(head2)->tqh_first->field.tqe_prev = (head1)->tqh_last;	\
+		(head1)->tqh_last = (head2)->tqh_last;			\
+		TAILQ_INIT((head2));					\
+	}								\
+} while (/*CONSTCOND*/0)
+
+/*
+ * Tail queue access methods.
+ */
+#define	TAILQ_EMPTY(head)		((head)->tqh_first == NULL)
+#define	TAILQ_FIRST(head)		((head)->tqh_first)
+#define	TAILQ_NEXT(elm, field)		((elm)->field.tqe_next)
+
+#define	TAILQ_LAST(head, headname) \
+	(*(((struct headname *)((head)->tqh_last))->tqh_last))
+#define	TAILQ_PREV(elm, headname, field) \
+	(*(((struct headname *)((elm)->field.tqe_prev))->tqh_last))
+
+
+/*
+ * Circular queue definitions.
+ */
+#define	CIRCLEQ_HEAD(name, type)					\
+struct name {								\
+	struct type *cqh_first;		/* first element */		\
+	struct type *cqh_last;		/* last element */		\
+}
+
+#define	CIRCLEQ_HEAD_INITIALIZER(head)					\
+	{ (void *)&head, (void *)&head }
+
+#define	CIRCLEQ_ENTRY(type)						\
+struct {								\
+	struct type *cqe_next;		/* next element */		\
+	struct type *cqe_prev;		/* previous element */		\
+}
+
+/*
+ * Circular queue functions.
+ */
+#define	CIRCLEQ_INIT(head) do {						\
+	(head)->cqh_first = (void *)(head);				\
+	(head)->cqh_last = (void *)(head);				\
+} while (/*CONSTCOND*/0)
+
+#define	CIRCLEQ_INSERT_AFTER(head, listelm, elm, field) do {		\
+	(elm)->field.cqe_next = (listelm)->field.cqe_next;		\
+	(elm)->field.cqe_prev = (listelm);				\
+	if ((listelm)->field.cqe_next == (void *)(head))		\
+		(head)->cqh_last = (elm);				\
+	else								\
+		(listelm)->field.cqe_next->field.cqe_prev = (elm);	\
+	(listelm)->field.cqe_next = (elm);				\
+} while (/*CONSTCOND*/0)
+
+#define	CIRCLEQ_INSERT_BEFORE(head, listelm, elm, field) do {		\
+	(elm)->field.cqe_next = (listelm);				\
+	(elm)->field.cqe_prev = (listelm)->field.cqe_prev;		\
+	if ((listelm)->field.cqe_prev == (void *)(head))		\
+		(head)->cqh_first = (elm);				\
+	else								\
+		(listelm)->field.cqe_prev->field.cqe_next = (elm);	\
+	(listelm)->field.cqe_prev = (elm);				\
+} while (/*CONSTCOND*/0)
+
+#define	CIRCLEQ_INSERT_HEAD(head, elm, field) do {			\
+	(elm)->field.cqe_next = (head)->cqh_first;			\
+	(elm)->field.cqe_prev = (void *)(head);				\
+	if ((head)->cqh_last == (void *)(head))				\
+		(head)->cqh_last = (elm);				\
+	else								\
+		(head)->cqh_first->field.cqe_prev = (elm);		\
+	(head)->cqh_first = (elm);					\
+} while (/*CONSTCOND*/0)
+
+#define	CIRCLEQ_INSERT_TAIL(head, elm, field) do {			\
+	(elm)->field.cqe_next = (void *)(head);				\
+	(elm)->field.cqe_prev = (head)->cqh_last;			\
+	if ((head)->cqh_first == (void *)(head))			\
+		(head)->cqh_first = (elm);				\
+	else								\
+		(head)->cqh_last->field.cqe_next = (elm);		\
+	(head)->cqh_last = (elm);					\
+} while (/*CONSTCOND*/0)
+
+#define	CIRCLEQ_REMOVE(head, elm, field) do {				\
+	if ((elm)->field.cqe_next == (void *)(head))			\
+		(head)->cqh_last = (elm)->field.cqe_prev;		\
+	else								\
+		(elm)->field.cqe_next->field.cqe_prev =			\
+		    (elm)->field.cqe_prev;				\
+	if ((elm)->field.cqe_prev == (void *)(head))			\
+		(head)->cqh_first = (elm)->field.cqe_next;		\
+	else								\
+		(elm)->field.cqe_prev->field.cqe_next =			\
+		    (elm)->field.cqe_next;				\
+} while (/*CONSTCOND*/0)
+
+#define	CIRCLEQ_FOREACH(var, head, field)				\
+	for ((var) = ((head)->cqh_first);				\
+		(var) != (const void *)(head);				\
+		(var) = ((var)->field.cqe_next))
+
+#define	CIRCLEQ_FOREACH_REVERSE(var, head, field)			\
+	for ((var) = ((head)->cqh_last);				\
+		(var) != (const void *)(head);				\
+		(var) = ((var)->field.cqe_prev))
+
+/*
+ * Circular queue access methods.
+ */
+#define	CIRCLEQ_EMPTY(head)		((head)->cqh_first == (void *)(head))
+#define	CIRCLEQ_FIRST(head)		((head)->cqh_first)
+#define	CIRCLEQ_LAST(head)		((head)->cqh_last)
+#define	CIRCLEQ_NEXT(elm, field)	((elm)->field.cqe_next)
+#define	CIRCLEQ_PREV(elm, field)	((elm)->field.cqe_prev)
+
+#define CIRCLEQ_LOOP_NEXT(head, elm, field)				\
+	(((elm)->field.cqe_next == (void *)(head))			\
+	    ? ((head)->cqh_first)					\
+	    : (elm->field.cqe_next))
+#define CIRCLEQ_LOOP_PREV(head, elm, field)				\
+	(((elm)->field.cqe_prev == (void *)(head))			\
+	    ? ((head)->cqh_last)					\
+	    : (elm->field.cqe_prev))
+
+#endif	/* sys/queue.h */
diff --git a/srcpkgs/rocm-opencl-runtime/patches/cmake.patch b/srcpkgs/rocm-opencl-runtime/patches/cmake.patch
new file mode 100644
index 00000000000..2b3354f3eeb
--- /dev/null
+++ b/srcpkgs/rocm-opencl-runtime/patches/cmake.patch
@@ -0,0 +1,123 @@
+diff -u -r ../original/OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/CMakeLists.txt ./OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/CMakeLists.txt
+--- OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/CMakeLists.txt	2019-09-10 11:53:28.000000000 -0400
++++ OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/CMakeLists.txt	2020-04-16 20:16:13.481180757 -0400
+@@ -73,11 +73,11 @@
+ 
+ set (OPENCL_ICD_LOADER_HEADERS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/inc CACHE PATH "Path to OpenCL Headers")
+ 
+-add_library (OpenCL ${OPENCL_ICD_LOADER_SOURCES})
+-set_target_properties (OpenCL PROPERTIES VERSION "1.2" SOVERSION "1")
++add_library (OpenCL-ROCm ${OPENCL_ICD_LOADER_SOURCES})
++set_target_properties (OpenCL-ROCm PROPERTIES VERSION "1.2" SOVERSION "1")
+ 
+ if (WIN32)
+-    target_link_libraries (OpenCL cfgmgr32.lib)
++    target_link_libraries (OpenCL-ROCm cfgmgr32.lib)
+ 
+     option (OPENCL_ICD_LOADER_REQUIRE_WDK "Build with D3DKMT support, which requires the Windows WDK." ON)
+     if (OPENCL_ICD_LOADER_REQUIRE_WDK)
+@@ -92,10 +92,10 @@
+             get_filename_component(WDK_DIRECTORY ${LATEST_D3DKMT_HEADER} DIRECTORY)
+             get_filename_component(WDK_DIRECTORY ${WDK_DIRECTORY} DIRECTORY)
+             message(STATUS "Found the Windows WDK in: ${WDK_DIRECTORY}")
+-            target_compile_definitions(OpenCL PRIVATE OPENCL_ICD_LOADER_REQUIRE_WDK)
+-            target_include_directories(OpenCL PRIVATE ${WDK_DIRECTORY}/um)
+-            target_include_directories(OpenCL PRIVATE ${WDK_DIRECTORY}/km)
+-            target_include_directories(OpenCL PRIVATE ${WDK_DIRECTORY}/shared)
++	    target_compile_definitions(OpenCL-ROCm PRIVATE OPENCL_ICD_LOADER_REQUIRE_WDK)
++	    target_include_directories(OpenCL-ROCm PRIVATE ${WDK_DIRECTORY}/um)
++	    target_include_directories(OpenCL-ROCm PRIVATE ${WDK_DIRECTORY}/km)
++	    target_include_directories(OpenCL-ROCm PRIVATE ${WDK_DIRECTORY}/shared)
+         else()
+             message(FATAL_ERROR "The Windows WDK was not found. Consider disabling OPENCL_ICD_LOADER_REQUIRE_WDK. Aborting.")
+         endif()
+@@ -113,25 +113,25 @@
+     endif()
+ else()
+     if (APPLE)
+-        target_link_libraries (OpenCL ${CMAKE_THREAD_LIBS_INIT})
++        target_link_libraries (OpenCL-ROCm ${CMAKE_THREAD_LIBS_INIT})
+     else ()
+-        set_target_properties (OpenCL PROPERTIES LINK_FLAGS "-Wl,--version-script -Wl,${CMAKE_CURRENT_SOURCE_DIR}/loader/linux/icd_exports.map")
+-        target_link_libraries (OpenCL ${CMAKE_THREAD_LIBS_INIT})
++        set_target_properties (OpenCL-ROCm PROPERTIES LINK_FLAGS "-Wl,--version-script -Wl,${CMAKE_CURRENT_SOURCE_DIR}/loader/linux/icd_exports.map")
++	target_link_libraries (OpenCL-ROCm ${CMAKE_THREAD_LIBS_INIT})
+     endif ()
+ endif ()
+ 
+ include_directories (${OPENCL_ICD_LOADER_HEADERS_DIR})
+ add_definitions (-DCL_TARGET_OPENCL_VERSION=220)
+ 
+-target_include_directories (OpenCL PRIVATE ${CMAKE_CURRENT_BINARY_DIR} loader)
+-target_link_libraries (OpenCL ${CMAKE_DL_LIBS})
++target_include_directories (OpenCL-ROCm PRIVATE ${CMAKE_CURRENT_BINARY_DIR} loader)
++target_link_libraries (OpenCL-ROCm ${CMAKE_DL_LIBS})
+ 
+ include (CTest)
+ if (BUILD_TESTING)
+     add_subdirectory (test)
+ endif()
+ 
+-install (TARGETS OpenCL
++install (TARGETS OpenCL-ROCm
+     RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+     ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
+     LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
+diff -u -r ../original/OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/test/loader_test/CMakeLists.txt ./OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/test/loader_test/CMakeLists.txt
+--- OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/test/loader_test/CMakeLists.txt	2019-09-10 11:53:28.000000000 -0400
++++ OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/test/loader_test/CMakeLists.txt	2020-04-16 20:16:56.647026589 -0400
+@@ -12,4 +12,4 @@
+     test_clgl.c
+     test_image_objects.c )
+ 
+-target_link_libraries (icd_loader_test OpenCL IcdLog)
++target_link_libraries (icd_loader_test OpenCL-ROCm IcdLog)
+diff -u -r ../original/ROCm-OpenCL-Runtime-roc-3.3.0/CMakeLists.txt ./ROCm-OpenCL-Runtime-roc-3.3.0/CMakeLists.txt
+--- ROCm-OpenCL-Runtime-roc-3.3.0/CMakeLists.txt	2020-04-18 20:16:13.452670818 -0400
++++ ROCm-OpenCL-Runtime-roc-3.3.0/CMakeLists.txt	2020-04-18 20:20:09.798862321 -0400
+@@ -102,16 +102,16 @@
+ 
+ # MAIN package
+ install(PROGRAMS $<TARGET_FILE:clinfo>
+-        DESTINATION bin/x86_64
++        DESTINATION bin
+         COMPONENT MAIN)
+ install(PROGRAMS $<TARGET_FILE:amdocl64>
+-        DESTINATION lib/x86_64
++        DESTINATION lib
+         COMPONENT MAIN)
+-install(PROGRAMS $<TARGET_FILE:OpenCL>
+-        DESTINATION lib/x86_64
++install(PROGRAMS $<TARGET_FILE:OpenCL-ROCm>
++        DESTINATION lib
+         COMPONENT MAIN)
+-install(PROGRAMS $<TARGET_SONAME_FILE:OpenCL>
+-        DESTINATION lib/x86_64
++install(PROGRAMS $<TARGET_SONAME_FILE:OpenCL-ROCm>
++        DESTINATION lib
+         COMPONENT MAIN)
+ 
+ # DEV package
+@@ -123,8 +123,8 @@
+         PATTERN cl_d3d11.h EXCLUDE
+         PATTERN cl_dx9_media_sharing.h EXCLUDE
+         PATTERN cl_egl.h EXCLUDE)
+-install(PROGRAMS $<TARGET_LINKER_FILE:OpenCL>
+-        DESTINATION lib/x86_64
++install(PROGRAMS $<TARGET_LINKER_FILE:OpenCL-ROCm>
++        DESTINATION lib
+         COMPONENT DEV)
+ 
+ # Generic CPACK variables
+diff -u -r ../original/ROCm-OpenCL-Runtime-roc-3.3.0/tools/clinfo/CMakeLists.txt ./ROCm-OpenCL-Runtime-roc-3.3.0/tools/clinfo/CMakeLists.txt
+--- ROCm-OpenCL-Runtime-roc-3.3.0/tools/clinfo/CMakeLists.txt	2020-04-01 13:05:07.000000000 -0400
++++ ROCm-OpenCL-Runtime-roc-3.3.0/tools/clinfo/CMakeLists.txt	2020-04-16 20:17:33.735894123 -0400
+@@ -8,4 +8,7 @@
+ 
+ add_executable(clinfo clinfo.cpp)
+ 
+-target_link_libraries(clinfo OpenCL)
++target_link_libraries(clinfo OpenCL-ROCm)
++
++# Make sure the clinfo rpath does not point to build directory
++set_target_properties(clinfo PROPERTIES BUILD_WITH_INSTALL_RPATH ON)
diff --git a/srcpkgs/rocm-opencl-runtime/template b/srcpkgs/rocm-opencl-runtime/template
new file mode 100644
index 00000000000..832ec7566ff
--- /dev/null
+++ b/srcpkgs/rocm-opencl-runtime/template
@@ -0,0 +1,78 @@
+# Template file for 'rocm-opencl-runtime'
+pkgname=rocm-opencl-runtime
+version=3.3.0
+revision=1
+_ocl_icd_name="OpenCL-ICD-Loader"
+_ocl_icd_ver="6c03f8b58fafd9dd693eaac826749a5cfad515f8"
+archs="x86_64*"
+create_wrksrc=yes
+build_wrksrc="ROCm-OpenCL-Runtime-roc-${version}"
+build_style=cmake
+configure_args="-DCMAKE_INSTALL_PREFIX:PATH=/opt/rocm
+	-DCMAKE_PREFIX_PATH:PATH=/opt/rocm/lib/cmake
+	-DCMAKE_INSTALL_RPATH:PATH='\$ORIGIN:\$ORIGIN/../lib'
+	-DUSE_COMGR_LIBRARY=yes"
+hostmakedepends="cmake pkg-config"
+makedepends="libglvnd-devel rocm-comgr-devel
+	roct-thunk-interface-devel rocr-runtime-devel"
+depends="rocm-comgr"
+short_desc="Radeon Open Compute OpenCL runtime"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="MIT"
+homepage="https://github.com/RadeonOpenCompute/ROCm-OpenCL-Runtime"
+_rocroot="https://github.com/RadeonOpenCompute"
+distfiles="${_rocroot}/ROCm-OpenCL-Runtime/archive/roc-${version}.tar.gz
+	${_rocroot}/rocm-cmake/archive/rocm-${version}.tar.gz
+	https://github.com/KhronosGroup/${_ocl_icd_name}/archive/${_ocl_icd_ver}.tar.gz"
+checksum="ac6999f1a491ab066286c2bd6adf50f08f831286f56e267879f9f7eced22f98e
+	76ed3ee8e56cf3246011cf7723c2abda539e1136e7e7f6909bfa45d268b8644f
+	c94d5bb6dc980c4d41d73e2b81663a19aabe494e923e2d0eec72a4c95b318438"
+nocross=yes
+
+post_patch() {
+	if [ "$XBPS_LIBC" = "musl" ]; then
+		# Copy sys/queue.h locally for MUSL builds
+		libelf_dir="compiler/lib/loaders/elf/utils/libelf"
+		cp "${FILESDIR}/sys_queue.h" "${libelf_dir}"
+
+		# Remove dependence on glibc
+		patch -Np0 < ${FILESDIR}/libelf-musl.patch
+		patch -Np0 < ${FILESDIR}/runtime-musl.patch
+		vsed -e '/glibc_functions.cpp/d' -i api/opencl/amdocl/CMakeLists.txt
+	fi
+}
+
+pre_configure() {
+	# ROCm requires a very specific Khronos ICD loader version in the tree
+	# Keep the ICD loader config in /opt/rocm to avoid conflicts
+	_ocl_icd_dir="${_ocl_icd_name}-${_ocl_icd_ver}"
+	ln -sf "${wrksrc}/${_ocl_icd_dir}" api/opencl/khronos/icd
+	vsed -i "${wrksrc}/${_ocl_icd_dir}/loader/icd_platform.h" \
+		-e 's@/etc/OpenCL/vendors/@/opt/rocm&@g'
+
+	# CMake modules probably not useful anywhere but for this build
+	ln -sf "${wrksrc}/rocm-cmake-rocm-${version}/share/rocm/cmake"/*.cmake cmake
+
+	# Fix the dlopen macro to point to versioned libamd_comgr shared object
+	vsed -i 'runtime/device/comgrctx.cpp' \
+		-e 's/\blibamd_comgr\(32\)\?.so\b/&.1/g'
+}
+
+post_install() {
+	vlicense License
+
+	# Create descriptor to allow the ICD loader to find the driver
+	_ocl_icd_dir="opt/rocm/etc/OpenCL/vendors"
+	vmkdir "${_ocl_icd_dir}"
+	echo "/opt/rocm/lib/libamdocl64.so" \
+		> "${DESTDIR}/${_ocl_icd_dir}/amdocl64.icd"
+}
+
+rocm-opencl-runtime-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove opt/rocm/include
+		vmove opt/rocm/lib/libOpenCL-ROCm.so
+	}
+}

^ permalink raw reply	[flat|nested] 61+ messages in thread

* Re: [PR PATCH] [Updated] New packages: ROCm core and OpenCL
  2020-04-19 13:34 [PR PATCH] New packages: ROCm core and OpenCL ahesford
                   ` (2 preceding siblings ...)
  2020-04-19 19:02 ` ahesford
@ 2020-04-20  2:02 ` ahesford
  2020-04-28 14:00 ` ahesford
                   ` (55 subsequent siblings)
  59 siblings, 0 replies; 61+ messages in thread
From: ahesford @ 2020-04-20  2:02 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 3893 bytes --]

There is an updated pull request by ahesford against master on the void-packages repository

https://github.com/ahesford/void-packages rocm
https://github.com/void-linux/void-packages/pull/21153

New packages: ROCm core and OpenCL
This PR includes several packages designed to bring the OpenCL portion of the AMD ROCm ecosystem to Void. It addresses Issue #19507. There are many other packages that AMD provides for GPGPU computing, but these can be added piecemeal as users demand.

The packages are currently only for `x86_64*`. While at least some of the packages will compile on other 64-bit architectures, I have no hardware to test. They are certainly not suitable for 32-bit architectures; some internal data structures rely on `uint64_t` values that are cast to pointers. At a
minimum, a thorough audit would be necessary to ensure that these casts are safe (e.g., that the values stored were only ever upcast from 32-bit pointers). More extensive work may be necessary to support 32-bit architectures, probably without significant benefit.

The packages successfully identify a Radeon RX 580 on an `x86_64` installation using both `clinfo` and `rocminfo` as provided. Furthermore, a version of `pyopencl` linked against these ROCm packages successfully runs a simple program that validates arithmetic on GPU-bound arrays.

There are caveats with this set of packages, almost all of which revolve around the incompatibilities between the Void-provided `ocl-icd` and the [Khronos OpenCL ICD loader](https://github.com/KhronosGroup/OpenCL-ID-Loader) required by (and built into) `rocm-opencl-runtime`.
1. All packages install into `/opt/rocm`. This keeps the environment closer to that officially sanctioned by AMD and helps avoid conflicts between other packages and those provided here. (For example, `clinfo` and the ICD loader itself.) Eventually, we may be able to move the files into `/usr`.
2. The Khronos OpenCL ICD loader built into `rocm-opencl-runtime` is an outdated, pre-release commit. If AMD can update its sources to use the release version of that loader (which has a backward-incompatible API change), we may be able to make ROCm compatible with `ocl-icd` or replace `ocl-icd` with the official Khronos loader.
3. In the meantime, to avoid `shlibs` conflicts, the OpenCL ICD loader is installed as `/opt/rocm/lib/libOpenCL-ROCm.so` (and an appropriately versioned shared library), which means that programs wishing to use the ROCm OpenCL must explicitly link against this library instead of the generic `libOpenCL.so`.
4. I do **not** recommend making any Void packages link against this specific library, because it will make those packages ROCm-only. For the time being, ROCm is intended for end-users to specifically link against. Linking Void packages against ROCm would requires the ICD loader used by ROCm be compatible with `ocl-icd`, or `ocl-icd` be replaced by the Khronos loader. However, because the Khronos loader changed its API for the release version, such a change is not yet appropriate.

Hopefully, if AMD updates its dependence on the Khronos ICD loader, we can resolve some of these caveats in the future and make ROCm a more natural Void component. For now, these packages are useful for those who need an AMD OpenCL solution and would rather custom-link software against the AMD ICD loader than hack the `amdgpu-pro` driver into an ICD compatible with `ocl-icd`.

Some patches were made to relocate some files in `/opt/rocm` and make everyting build on x86_64-musl`. Where appropriate, these patches will be pushed upstream to clean up the distribution and packaging.

Update: I pushed some new commits to update license information that triggerd an `xlint` failure. I've also disabled CI builds because they will time out on `rocm-llvm`.

A patch file from https://github.com/void-linux/void-packages/pull/21153.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-rocm-21153.patch --]
[-- Type: text/x-diff, Size: 74126 bytes --]

From ab4b3f9dcbccaaa15388bcaeac683a401e4fba7d Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Mon, 13 Apr 2020 13:08:09 -0400
Subject: [PATCH 1/8] New package: roct-thunk-interface-3.3.0

---
 common/shlibs                                 |  1 +
 srcpkgs/roct-thunk-interface-devel            |  1 +
 .../patches/cmake-dev-libdir.patch            | 10 ++++++
 .../roct-thunk-interface/patches/musl.patch   | 29 +++++++++++++++
 srcpkgs/roct-thunk-interface/template         | 35 +++++++++++++++++++
 5 files changed, 76 insertions(+)
 create mode 120000 srcpkgs/roct-thunk-interface-devel
 create mode 100644 srcpkgs/roct-thunk-interface/patches/cmake-dev-libdir.patch
 create mode 100644 srcpkgs/roct-thunk-interface/patches/musl.patch
 create mode 100644 srcpkgs/roct-thunk-interface/template

diff --git a/common/shlibs b/common/shlibs
index 53a59b7303b..78863e0f7b8 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3862,3 +3862,4 @@ libstk-4.6.1.so libstk-4.6.1_1
 libc++utilities.so.5 cpp-utilities-5.2.0_1
 libtagparser.so.9 tagparser-9.1.2_1
 libqtutilities.so.6 qtutilities-6.0.4_1
+libhsakmt.so.1 roct-thunk-interface-3.3.0_1
diff --git a/srcpkgs/roct-thunk-interface-devel b/srcpkgs/roct-thunk-interface-devel
new file mode 120000
index 00000000000..ac3f2cc684c
--- /dev/null
+++ b/srcpkgs/roct-thunk-interface-devel
@@ -0,0 +1 @@
+roct-thunk-interface
\ No newline at end of file
diff --git a/srcpkgs/roct-thunk-interface/patches/cmake-dev-libdir.patch b/srcpkgs/roct-thunk-interface/patches/cmake-dev-libdir.patch
new file mode 100644
index 00000000000..98c7f1e459c
--- /dev/null
+++ b/srcpkgs/roct-thunk-interface/patches/cmake-dev-libdir.patch
@@ -0,0 +1,10 @@
+--- CMakeLists.txt.old	2020-04-18 19:45:17.306081135 -0400
++++ CMakeLists.txt	2020-04-18 19:46:51.300753636 -0400
+@@ -146,6 +146,7 @@
+     COMMAND ${CMAKE_COMMAND}
+         -DSOURCE_DIR="${SOURCE_DIR}"
+         -DCMAKE_INSTALL_PREFIX="${CMAKE_INSTALL_PREFIX}"
++        -DCMAKE_INSTALL_LIBDIR="${CMAKE_INSTALL_LIBDIR}"
+         -DCPACK_RPM_PACKAGE_REQUIRES="hsakmt-roct"
+         -DCPACK_PACKAGING_INSTALL_PREFIX="${CPACK_PACKAGING_INSTALL_PREFIX}"
+         -DVERSION="${BUILD_VERSION_STRING}"
diff --git a/srcpkgs/roct-thunk-interface/patches/musl.patch b/srcpkgs/roct-thunk-interface/patches/musl.patch
new file mode 100644
index 00000000000..aeea9832411
--- /dev/null
+++ b/srcpkgs/roct-thunk-interface/patches/musl.patch
@@ -0,0 +1,29 @@
+diff -r -u old/src/libhsakmt.h new/src/libhsakmt.h
+--- src/libhsakmt.h	2020-03-04 15:00:47.000000000 -0500
++++ src/libhsakmt.h	2020-04-13 12:58:30.444865992 -0400
+@@ -54,6 +54,10 @@
+ #define CHECK_KFD_OPEN() \
+ 	do { if (kfd_open_count == 0 || hsakmt_forked) return HSAKMT_STATUS_KERNEL_IO_CHANNEL_NOT_OPENED; } while (0)
+ 
++/*On some platforms, a PAGE_SIZE macro eclipses the extern variable*/
++#ifdef PAGE_SIZE
++#undef PAGE_SIZE
++#endif
+ extern int PAGE_SIZE;
+ extern int PAGE_SHIFT;
+ 
+diff -r -u old/src/topology.c new/src/topology.c
+--- src/topology.c	2020-03-04 15:00:47.000000000 -0500
++++ src/topology.c	2020-04-13 13:01:31.209870701 -0400
+@@ -38,6 +38,11 @@
+ #include "libhsakmt.h"
+ #include "fmm.h"
+ 
++/*Needed on MUSL*/
++#ifndef MAXNAMLEN
++#define MAXNAMLEN PATH_MAX
++#endif
++
+ /* Number of memory banks added by thunk on top of topology
+  * This only includes static heaps like LDS, scratch and SVM,
+  * not for MMIO_REMAP heap. MMIO_REMAP memory bank is reported
diff --git a/srcpkgs/roct-thunk-interface/template b/srcpkgs/roct-thunk-interface/template
new file mode 100644
index 00000000000..f4320075c73
--- /dev/null
+++ b/srcpkgs/roct-thunk-interface/template
@@ -0,0 +1,35 @@
+# Template file for 'roct-thunk-interface'
+pkgname=roct-thunk-interface
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="ROCT-Thunk-Interface-roc-${version}"
+build_style=cmake
+configure_args="-DCMAKE_INSTALL_PREFIX:PATH=/opt/rocm
+	-DCMAKE_INSTALL_RPATH:PATH='\$ORIGIN:\$ORIGIN/../lib'"
+make_build_target="all build-dev"
+make_install_target="install install-dev"
+hostmakedepends="cmake pkg-config"
+makedepends="pciutils-devel libnuma-devel"
+short_desc="Radeon Open Compute Thunk Interface"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="MIT"
+homepage="https://github.com/RadeonOpenCompute/ROCT-Thunk-Interface"
+distfiles="${homepage}/archive/roc-${version}.tar.gz"
+checksum=2cabe9d2cfa72031c05d11290837c476182e72d8dec2049298f691143fdd212b
+nocross=yes
+
+post_install() {
+	vlicense LICENSE.md
+}
+
+roct-thunk-interface-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove opt/rocm/include
+		vmove "opt/rocm/lib/*.so"
+		vmove opt/rocm/share/pkgconfig
+		vmove opt/rocm/lib/cmake
+	}
+}

From 2e5b777645342c99f520ca8dbcad11ebedce52d1 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Mon, 13 Apr 2020 15:27:27 -0400
Subject: [PATCH 2/8] New package: rocr-runtime-3.3.0

---
 common/shlibs                            |  1 +
 srcpkgs/rocr-runtime-devel               |  1 +
 srcpkgs/rocr-runtime/patches/cmake.patch | 27 +++++++++++++++++++
 srcpkgs/rocr-runtime/template            | 33 ++++++++++++++++++++++++
 4 files changed, 62 insertions(+)
 create mode 120000 srcpkgs/rocr-runtime-devel
 create mode 100644 srcpkgs/rocr-runtime/patches/cmake.patch
 create mode 100644 srcpkgs/rocr-runtime/template

diff --git a/common/shlibs b/common/shlibs
index 78863e0f7b8..ec34c0df9fa 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3863,3 +3863,4 @@ libc++utilities.so.5 cpp-utilities-5.2.0_1
 libtagparser.so.9 tagparser-9.1.2_1
 libqtutilities.so.6 qtutilities-6.0.4_1
 libhsakmt.so.1 roct-thunk-interface-3.3.0_1
+libhsa-runtime64.so.1 rocr-runtime-3.3.0_1
diff --git a/srcpkgs/rocr-runtime-devel b/srcpkgs/rocr-runtime-devel
new file mode 120000
index 00000000000..be838f22d81
--- /dev/null
+++ b/srcpkgs/rocr-runtime-devel
@@ -0,0 +1 @@
+rocr-runtime
\ No newline at end of file
diff --git a/srcpkgs/rocr-runtime/patches/cmake.patch b/srcpkgs/rocr-runtime/patches/cmake.patch
new file mode 100644
index 00000000000..93b74cd2297
--- /dev/null
+++ b/srcpkgs/rocr-runtime/patches/cmake.patch
@@ -0,0 +1,27 @@
+--- src/CMakeLists.txt.old	2020-04-18 20:01:48.549636995 -0400
++++ src/CMakeLists.txt	2020-04-18 20:04:00.177179781 -0400
+@@ -108,8 +108,8 @@
+ ## ROCr build internal versioning
+ add_definitions ( -DROCR_BUILD_ID=${PACKAGE_VERSION_STRING} )
+ 
+-## Set RUNPATH - ../../lib covers use of the legacy symlink in /hsa/lib/
+-set(CMAKE_INSTALL_RPATH "$ORIGIN;$ORIGIN/../../lib;$ORIGIN/../../lib64;$ORIGIN/../lib64")
++## Set RUNPATH
++set(CMAKE_INSTALL_RPATH "$ORIGIN;$ORIGIN/../lib")
+ 
+ ## ------------------------- Linux Compiler and Linker options -------------------------
+ set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -fexceptions -fno-rtti -fvisibility=hidden -Wno-error=sign-compare -Wno-sign-compare -Wno-write-strings -Wno-conversion-null -fno-math-errno -fno-threadsafe-statics -fmerge-all-constants -fms-extensions -Wno-error=comment -Wno-comment -Wno-error=pointer-arith -Wno-pointer-arith -Wno-error=unused-variable -Wno-error=unused-function" )
+@@ -185,11 +185,8 @@
+ add_custom_target ( hsa_lib_link2 ALL WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMAND ${CMAKE_COMMAND} -E create_symlink ../hsa/lib/${CORE_RUNTIME_LIBRARY}.so.${SO_MAJOR} ${CORE_RUNTIME_LIBRARY}-link.so.${SO_MAJOR} )
+ 
+ ## Set install information
+-install ( TARGETS ${CORE_RUNTIME_TARGET} LIBRARY DESTINATION hsa/lib )
+-install ( DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/inc/ DESTINATION hsa/include/hsa )
+-install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/hsa_include_link DESTINATION include PERMISSIONS OWNER_WRITE OWNER_READ RENAME hsa )
+-install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/${CORE_RUNTIME_LIBRARY}-link.so DESTINATION lib PERMISSIONS OWNER_WRITE OWNER_READ RENAME ${CORE_RUNTIME_LIBRARY}.so )
+-install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/${CORE_RUNTIME_LIBRARY}-link.so.${SO_MAJOR} DESTINATION lib PERMISSIONS OWNER_WRITE OWNER_READ RENAME ${CORE_RUNTIME_LIBRARY}.so.${SO_MAJOR} )
++install ( TARGETS ${CORE_RUNTIME_TARGET} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} )
++install ( DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/inc/ DESTINATION include/hsa )
+ 
+ ## Packaging directives
+ set ( CPACK_GENERATOR "DEB;RPM" CACHE STRING "Package types to build")
diff --git a/srcpkgs/rocr-runtime/template b/srcpkgs/rocr-runtime/template
new file mode 100644
index 00000000000..3588211584c
--- /dev/null
+++ b/srcpkgs/rocr-runtime/template
@@ -0,0 +1,33 @@
+# Template file for 'rocr-runtime'
+pkgname=rocr-runtime
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="ROCR-Runtime-rocm-${version}"
+build_wrksrc="src"
+build_style=cmake
+configure_args="-DCMAKE_INSTALL_PREFIX:PATH=/opt/rocm
+	-DHSAKMT_INC_PATH:PATH=/opt/rocm/include
+	-DHSAKMT_LIB_PATH:PATH=/opt/rocm/lib"
+hostmakedepends="cmake pkg-config"
+makedepends="roct-thunk-interface-devel elfutils-devel"
+short_desc="Radeon Open Compute HSA Runtime"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute/ROCR-Runtime"
+distfiles="${homepage}/archive/rocm-${version}.tar.gz"
+checksum=fa2d2d1f8a61d8a6952d377cf288d78c61776c3c2a666f163cafc3aa19ab0b61
+nocross=yes
+
+post_install() {
+	vlicense ../LICENSE.txt
+}
+
+rocr-runtime-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove opt/rocm/include
+		vmove "opt/rocm/lib/*.so"
+	}
+}

From c4755c07d40f1818a107722b2f1ebfbf2e585cde Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Mon, 13 Apr 2020 18:07:34 -0400
Subject: [PATCH 3/8] New package: rocm-llvm-3.3.0

---
 srcpkgs/rocm-llvm/template | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)
 create mode 100644 srcpkgs/rocm-llvm/template

diff --git a/srcpkgs/rocm-llvm/template b/srcpkgs/rocm-llvm/template
new file mode 100644
index 00000000000..487a845c733
--- /dev/null
+++ b/srcpkgs/rocm-llvm/template
@@ -0,0 +1,25 @@
+# Template file for 'rocm-llvm'
+pkgname=rocm-llvm
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="llvm-project-rocm-ocl-${version}"
+build_wrksrc=llvm
+build_style=cmake
+configure_args="-DCMAKE_INSTALL_PREFIX:PATH=/opt/rocm/llvm
+	-DLLVM_ENABLE_PROJECTS='llvm;clang;lld' -DLLVM_TARGETS_TO_BUILD='AMDGPU'
+	-DLLVM_BUILD_DOCS=NO -DLLVM_ENABLE_OCAMLDOC=OFF
+	-DLLVM_ENABLE_SPHINX=NO -DLLVM_ENABLE_DOXYGEN=OFF
+	-DLLVM_INSTALL_UTILS=ON -DLLVM_VERSION_SUFFIX=roc -DOCAMLFIND=NO"
+hostmakedepends="cmake pkg-config python3"
+short_desc="Radeon Open Compute LLVM toolchain"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="Apache-2.0, NCSA, custom:LLVM-Exceptions"
+homepage="https://github.com/RadeonOpenCompute/llvm-project"
+distfiles="${homepage}/archive/rocm-ocl-${version}.tar.gz"
+checksum=a2bef7042e8e2f2cd8548cb246b88322e1c77188839983dcac8312d56f544dc8
+nocross=yes
+
+post_install() {
+	vlicense LICENSE.TXT
+}

From faff603687d7e7710bcd39caf22b7727247216ac Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Tue, 14 Apr 2020 10:25:31 -0400
Subject: [PATCH 4/8] New package: rocm-device-libs-3.3.0

---
 srcpkgs/rocm-device-libs/template | 32 +++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)
 create mode 100644 srcpkgs/rocm-device-libs/template

diff --git a/srcpkgs/rocm-device-libs/template b/srcpkgs/rocm-device-libs/template
new file mode 100644
index 00000000000..94b3be580c0
--- /dev/null
+++ b/srcpkgs/rocm-device-libs/template
@@ -0,0 +1,32 @@
+# Template file for 'rocm-device-libs'
+pkgname=rocm-device-libs
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="ROCm-Device-Libs-rocm-ocl-${version}"
+build_style=cmake
+configure_args="-DCMAKE_INSTALL_PREFIX:PATH=/opt/rocm -DLLVM_DIR:PATH=/opt/rocm/llvm"
+hostmakedepends="cmake rocm-llvm"
+short_desc="Radeon Open Compute device libraries"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute/ROCm-Device-Libs"
+distfiles="${homepage}/archive/rocm-ocl-${version}.tar.gz"
+checksum=706b08230790e08ca6a7a2fb7687d6131fd39a562148340e00fa37a6c06769c5
+nocross=yes
+
+pre_configure() {
+	# Build the prepare-builtins executable with native compiler
+	mkdir -p utils/build
+	cd utils/build
+	_prepare_builtins="$PWD/prepare-builtins/prepare-builtins"
+	cmake ${configure_args} ..
+	make ${makejobs}
+
+	# Add path to prepare-builtins for cmake
+	configure_args+=" -DPREPARE_BUILTINS='${_prepare_builtins}'"
+}
+
+post_install() {
+	vlicense LICENSE
+}

From 67fb1d394538ee8049e341b8d835b95e3022a8b1 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Mon, 13 Apr 2020 18:30:00 -0400
Subject: [PATCH 5/8] New package: rocm-comgr-3.3.0

---
 common/shlibs               |  1 +
 srcpkgs/rocm-comgr-devel    |  1 +
 srcpkgs/rocm-comgr/template | 34 ++++++++++++++++++++++++++++++++++
 3 files changed, 36 insertions(+)
 create mode 120000 srcpkgs/rocm-comgr-devel
 create mode 100644 srcpkgs/rocm-comgr/template

diff --git a/common/shlibs b/common/shlibs
index ec34c0df9fa..509755bd8b9 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3864,3 +3864,4 @@ libtagparser.so.9 tagparser-9.1.2_1
 libqtutilities.so.6 qtutilities-6.0.4_1
 libhsakmt.so.1 roct-thunk-interface-3.3.0_1
 libhsa-runtime64.so.1 rocr-runtime-3.3.0_1
+libamd_comgr.so.1 rocm-comgr-3.3.0_1
diff --git a/srcpkgs/rocm-comgr-devel b/srcpkgs/rocm-comgr-devel
new file mode 120000
index 00000000000..3f5ce255e07
--- /dev/null
+++ b/srcpkgs/rocm-comgr-devel
@@ -0,0 +1 @@
+rocm-comgr
\ No newline at end of file
diff --git a/srcpkgs/rocm-comgr/template b/srcpkgs/rocm-comgr/template
new file mode 100644
index 00000000000..4bbc930073c
--- /dev/null
+++ b/srcpkgs/rocm-comgr/template
@@ -0,0 +1,34 @@
+# Template file for 'rocm-comgr'
+pkgname=rocm-comgr
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="ROCm-CompilerSupport-rocm-${version}"
+build_wrksrc="lib/comgr"
+build_style=cmake
+configure_args="-DCMAKE_INSTALL_PREFIX:PATH=/opt/rocm
+	-DClang_DIR:PATH=/opt/rocm/llvm/lib/cmake/clang
+	-DCMAKE_INSTALL_RPATH:PATH='\$ORIGIN:\$ORIGIN/../lib'"
+hostmakedepends="cmake pkg-config rocm-llvm"
+makedepends="rocm-device-libs"
+short_desc="Radeon Open Compute Code Object Manager"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="BSD-3-Clause"
+homepage="https://github.com/RadeonOpenCompute/ROCm-CompilerSupport"
+distfiles="${homepage}/archive/rocm-${version}.tar.gz"
+checksum=01e2524e0f28ecd6f46c9720f279207de935d826b0172158792aa3ec86af9ca7
+nocross=yes
+
+post_install() {
+	vlicense LICENSE.txt
+}
+
+rocm-comgr-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove opt/rocm/include
+		vmove "opt/rocm/lib/*.so"
+		vmove opt/rocm/lib/cmake
+	}
+}

From 28e82d4c5ba5729bbce498dab9f2e78a9e9eb197 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Fri, 17 Apr 2020 12:11:25 -0400
Subject: [PATCH 6/8] New package: rocminfo-3.3.0

---
 srcpkgs/rocminfo/template | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
 create mode 100644 srcpkgs/rocminfo/template

diff --git a/srcpkgs/rocminfo/template b/srcpkgs/rocminfo/template
new file mode 100644
index 00000000000..7e39b7da3cd
--- /dev/null
+++ b/srcpkgs/rocminfo/template
@@ -0,0 +1,22 @@
+# Template file for 'rocminfo'
+pkgname=rocminfo
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="rocminfo-rocm-${version}"
+build_style=cmake
+configure_args="-DCMAKE_INSTALL_PREFIX:PATH=/opt/rocm -DROCM_DIR=/opt/rocm"
+hostmakedepends="cmake pkg-config"
+makedepends="rocr-runtime-devel"
+short_desc="Radeon Open Compute system information reporter"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute/rocminfo"
+distfiles="${homepage}/archive/rocm-${version}.tar.gz"
+checksum=e666f662c9e465aaabbbd0b109d87e017243cdf1a0898fabf5a90947bb3dbcd7
+nocross=yes
+python_version=3
+
+post_install() {
+	vlicense License.txt
+}

From 692a4c101a03e5e1f46deee8d5a86d754b485a7e Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Sun, 19 Apr 2020 15:01:40 -0400
Subject: [PATCH 7/8] New package: rocm-bandwidth-test-3.3.0

---
 srcpkgs/rocm-bandwidth-test/template | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
 create mode 100644 srcpkgs/rocm-bandwidth-test/template

diff --git a/srcpkgs/rocm-bandwidth-test/template b/srcpkgs/rocm-bandwidth-test/template
new file mode 100644
index 00000000000..b44a8646ab2
--- /dev/null
+++ b/srcpkgs/rocm-bandwidth-test/template
@@ -0,0 +1,22 @@
+# Template file for 'rocm-bandwidth-test'
+pkgname=rocm-bandwidth-test
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="rocm_bandwidth_test-rocm-${version}"
+build_style=cmake
+configure_args="-DCMAKE_INSTALL_PREFIX:PATH=/opt/rocm
+	-DCMAKE_INSTALL_RPATH:PATH='\$ORIGIN:\$ORIGIN/../lib'"
+hostmakedepends="cmake"
+makedepends="rocr-runtime-devel roct-thunk-interface-devel"
+short_desc="Radeon Open Compute bandwidth test"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute/rocm_bandwidth_test"
+distfiles="${homepage}/archive/rocm-${version}.tar.gz"
+checksum=f5f914073018619dc91662d5bf630903dfa4db9136d603591917fdfb3c9164ce
+nocross=yes
+
+post_install() {
+	vlicense LICENSE.txt
+}

From 804feb8658076db61f1ced380b278e24a9ff19ee Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Tue, 14 Apr 2020 10:25:54 -0400
Subject: [PATCH 8/8] New package: rocm-opencl-runtime-3.3.0 [ci skip]

---
 common/shlibs                                 |   1 +
 srcpkgs/rocm-opencl-runtime-devel             |   1 +
 .../files/libelf-musl.patch                   | 688 ++++++++++++++++++
 .../files/runtime-musl.patch                  |  11 +
 srcpkgs/rocm-opencl-runtime/files/sys_queue.h | 574 +++++++++++++++
 .../rocm-opencl-runtime/patches/cmake.patch   | 123 ++++
 srcpkgs/rocm-opencl-runtime/template          |  78 ++
 7 files changed, 1476 insertions(+)
 create mode 120000 srcpkgs/rocm-opencl-runtime-devel
 create mode 100644 srcpkgs/rocm-opencl-runtime/files/libelf-musl.patch
 create mode 100644 srcpkgs/rocm-opencl-runtime/files/runtime-musl.patch
 create mode 100644 srcpkgs/rocm-opencl-runtime/files/sys_queue.h
 create mode 100644 srcpkgs/rocm-opencl-runtime/patches/cmake.patch
 create mode 100644 srcpkgs/rocm-opencl-runtime/template

diff --git a/common/shlibs b/common/shlibs
index 509755bd8b9..d087fa3ab4b 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3865,3 +3865,4 @@ libqtutilities.so.6 qtutilities-6.0.4_1
 libhsakmt.so.1 roct-thunk-interface-3.3.0_1
 libhsa-runtime64.so.1 rocr-runtime-3.3.0_1
 libamd_comgr.so.1 rocm-comgr-3.3.0_1
+libOpenCL-ROCm.so.1 rocm-opencl-runtime-3.3.0_1
diff --git a/srcpkgs/rocm-opencl-runtime-devel b/srcpkgs/rocm-opencl-runtime-devel
new file mode 120000
index 00000000000..b2cda7e229d
--- /dev/null
+++ b/srcpkgs/rocm-opencl-runtime-devel
@@ -0,0 +1 @@
+rocm-opencl-runtime
\ No newline at end of file
diff --git a/srcpkgs/rocm-opencl-runtime/files/libelf-musl.patch b/srcpkgs/rocm-opencl-runtime/files/libelf-musl.patch
new file mode 100644
index 00000000000..a3705c259a9
--- /dev/null
+++ b/srcpkgs/rocm-opencl-runtime/files/libelf-musl.patch
@@ -0,0 +1,688 @@
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/_libelf.h compiler/lib/loaders/elf/utils/libelf/_libelf.h
+--- compiler/lib/loaders/elf/utils/libelf.orig/_libelf.h	2020-04-19 08:59:34.201386585 -0400
++++ compiler/lib/loaders/elf/utils/libelf/_libelf.h	2020-04-19 09:04:12.950433528 -0400
+@@ -30,7 +30,7 @@
+ #define	__LIBELF_H_
+ 
+ #include <limits.h>
+-#include <sys/queue.h>
++#include "sys_queue.h"
+ 
+ #include "_libelf_config.h"
+ 
+@@ -179,7 +179,9 @@
+  * Function Prototypes.
+  */
+ 
+-__BEGIN_DECLS
++#ifdef __cplusplus
++extern "C" {
++#endif
+ Elf_Data *_libelf_allocate_data(Elf_Scn *_s);
+ Elf	*_libelf_allocate_elf(Elf_Mem *mem);
+ Elf_Scn	*_libelf_allocate_scn(Elf *_e, size_t _ndx);
+@@ -213,6 +215,8 @@
+ Elf_Data *_libelf_xlate(Elf_Data *_d, const Elf_Data *_s,
+     unsigned int _encoding, int _elfclass, int _direction);
+ int	_libelf_xlate_shtype(uint32_t _sht);
+-__END_DECLS
++#ifdef __cplusplus
++}
++#endif
+ 
+ #endif	/* __LIBELF_H_ */
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_begin.c compiler/lib/loaders/elf/utils/libelf/elf_begin.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_begin.c	2020-04-19 08:59:34.201386585 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_begin.c	2020-04-19 09:01:04.313212042 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <sys/types.h>
+ #if !defined(WIN32)
+ #include <sys/errno.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_end.c compiler/lib/loaders/elf/utils/libelf/elf_end.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_end.c	2020-04-19 08:59:34.201386585 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_end.c	2020-04-19 09:01:14.895204681 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #if !defined(WIN32)
+ #include <sys/mman.h>
+ #endif
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_errmsg.c compiler/lib/loaders/elf/utils/libelf/elf_errmsg.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_errmsg.c	2020-04-19 08:59:34.201386585 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_errmsg.c	2020-04-19 09:01:16.753207065 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ #include <stdio.h>
+ #include <string.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_errno.c compiler/lib/loaders/elf/utils/libelf/elf_errno.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_errno.c	2020-04-19 08:59:34.201386585 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_errno.c	2020-04-19 09:01:18.669209528 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_fill.c compiler/lib/loaders/elf/utils/libelf/elf_fill.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_fill.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_fill.c	2020-04-19 09:01:21.109212667 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_flag.c compiler/lib/loaders/elf/utils/libelf/elf_flag.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_flag.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_flag.c	2020-04-19 09:01:23.376215579 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_getarhdr.c compiler/lib/loaders/elf/utils/libelf/elf_getarhdr.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_getarhdr.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_getarhdr.c	2020-04-19 09:01:25.414218197 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_getarsym.c compiler/lib/loaders/elf/utils/libelf/elf_getarsym.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_getarsym.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_getarsym.c	2020-04-19 09:01:27.575220978 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_getbase.c compiler/lib/loaders/elf/utils/libelf/elf_getbase.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_getbase.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_getbase.c	2020-04-19 09:01:29.963224043 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_getident.c compiler/lib/loaders/elf/utils/libelf/elf_getident.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_getident.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_getident.c	2020-04-19 09:01:31.912226551 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <ar.h>
+ #include <assert.h>
+ #include <libelf.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_hash.c compiler/lib/loaders/elf/utils/libelf/elf_hash.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_hash.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_hash.c	2020-04-19 09:01:33.877229069 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ #include "_libelf_config.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_kind.c compiler/lib/loaders/elf/utils/libelf/elf_kind.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_kind.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_kind.c	2020-04-19 09:01:35.940231721 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_memory.c compiler/lib/loaders/elf/utils/libelf/elf_memory.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_memory.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_memory.c	2020-04-19 09:01:38.171234596 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <ar.h>
+ #include <libelf.h>
+ #include <string.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_next.c compiler/lib/loaders/elf/utils/libelf/elf_next.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_next.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_next.c	2020-04-19 09:01:40.063237028 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <ar.h>
+ #include <assert.h>
+ #include <libelf.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_phnum.c compiler/lib/loaders/elf/utils/libelf/elf_phnum.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_phnum.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_phnum.c	2020-04-19 09:01:42.480240134 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <ar.h>
+ #include <libelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_rand.c compiler/lib/loaders/elf/utils/libelf/elf_rand.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_rand.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_rand.c	2020-04-19 09:01:45.061243452 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <ar.h>
+ #include <libelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_rawfile.c compiler/lib/loaders/elf/utils/libelf/elf_rawfile.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_rawfile.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_rawfile.c	2020-04-19 09:01:46.988245928 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_scn.c compiler/lib/loaders/elf/utils/libelf/elf_scn.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_scn.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_scn.c	2020-04-19 09:00:19.724298403 -0400
+@@ -24,8 +24,7 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-#include <sys/queue.h>
++#include "sys_queue.h"
+ 
+ #include <assert.h>
+ #include <errno.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_shnum.c compiler/lib/loaders/elf/utils/libelf/elf_shnum.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_shnum.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_shnum.c	2020-04-19 09:01:51.763252060 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <ar.h>
+ #include <libelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_shstrndx.c compiler/lib/loaders/elf/utils/libelf/elf_shstrndx.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_shstrndx.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_shstrndx.c	2020-04-19 09:01:53.532254340 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <ar.h>
+ #include <libelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_version.c compiler/lib/loaders/elf/utils/libelf/elf_version.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_version.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_version.c	2020-04-19 09:02:01.337264370 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf.h compiler/lib/loaders/elf/utils/libelf/gelf.h
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf.h	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf.h	2020-04-19 09:04:29.669455020 -0400
+@@ -29,8 +29,6 @@
+ #ifndef	_GELF_H_
+ #define	_GELF_H_
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ typedef Elf64_Addr	GElf_Addr;	/* Addresses */
+@@ -72,7 +70,9 @@
+ #define	GELF_ST_TYPE			ELF64_ST_TYPE
+ #define	GELF_ST_VISIBILITY		ELF64_ST_VISIBILITY
+ 
+-__BEGIN_DECLS
++#ifdef __cplusplus
++extern "C" {
++#endif
+ long		gelf_checksum(Elf *_elf);
+ size_t		gelf_fsize(Elf *_elf, Elf_Type _type, size_t _count,
+ 			unsigned int _version);
+@@ -109,6 +109,8 @@
+ int		gelf_update_move(Elf_Data *_dst, int _index, GElf_Move *_src);
+ int		gelf_update_syminfo(Elf_Data *_dst, int _index, GElf_Syminfo *_src);
+ #endif
+-__END_DECLS
++#ifdef __cplusplus
++}
++#endif
+ 
+ #endif	/* _GELF_H_ */
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_cap.c compiler/lib/loaders/elf/utils/libelf/gelf_cap.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_cap.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_cap.c	2020-04-19 09:02:05.429269632 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_checksum.c compiler/lib/loaders/elf/utils/libelf/gelf_checksum.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_checksum.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_checksum.c	2020-04-19 09:02:08.192273183 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <gelf.h>
+ #include <libelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_dyn.c compiler/lib/loaders/elf/utils/libelf/gelf_dyn.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_dyn.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_dyn.c	2020-04-19 09:02:10.020275525 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_ehdr.c compiler/lib/loaders/elf/utils/libelf/gelf_ehdr.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_ehdr.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_ehdr.c	2020-04-19 09:02:11.882277926 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ #include <libelf.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_fsize.c compiler/lib/loaders/elf/utils/libelf/gelf_fsize.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_fsize.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_fsize.c	2020-04-19 09:02:14.139280827 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <gelf.h>
+ #include <libelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_getclass.c compiler/lib/loaders/elf/utils/libelf/gelf_getclass.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_getclass.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_getclass.c	2020-04-19 09:02:17.269284848 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <gelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_move.c compiler/lib/loaders/elf/utils/libelf/gelf_move.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_move.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_move.c	2020-04-19 09:02:18.974287034 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_phdr.c compiler/lib/loaders/elf/utils/libelf/gelf_phdr.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_phdr.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_phdr.c	2020-04-19 09:02:20.676289227 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <gelf.h>
+ #include <libelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_rel.c compiler/lib/loaders/elf/utils/libelf/gelf_rel.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_rel.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_rel.c	2020-04-19 09:02:23.177292435 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_rela.c compiler/lib/loaders/elf/utils/libelf/gelf_rela.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_rela.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_rela.c	2020-04-19 09:02:25.246295100 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_shdr.c compiler/lib/loaders/elf/utils/libelf/gelf_shdr.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_shdr.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_shdr.c	2020-04-19 09:02:28.325299060 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ #include <libelf.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_sym.c compiler/lib/loaders/elf/utils/libelf/gelf_sym.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_sym.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_sym.c	2020-04-19 09:02:30.113301356 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_syminfo.c compiler/lib/loaders/elf/utils/libelf/gelf_syminfo.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_syminfo.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_syminfo.c	2020-04-19 09:02:31.906303662 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_symshndx.c compiler/lib/loaders/elf/utils/libelf/gelf_symshndx.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_symshndx.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_symshndx.c	2020-04-19 09:02:33.626305873 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_xlate.c compiler/lib/loaders/elf/utils/libelf/gelf_xlate.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_xlate.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_xlate.c	2020-04-19 09:02:35.921308822 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <gelf.h>
+ #include <libelf.h>
+ #include <string.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf.h compiler/lib/loaders/elf/utils/libelf/libelf.h
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf.h	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf.h	2020-04-19 09:04:38.760466706 -0400
+@@ -30,7 +30,7 @@
+ #define	_LIBELF_H_
+ 
+ #include <sys/types.h>
+-#include <sys/queue.h>
++#include "sys_queue.h"
+ #include <elfdefinitions.h>
+ #ifndef EM_HSAIL
+ #define EM_HSAIL 0xAF5A
+@@ -187,7 +187,9 @@
+ #define	ELF_F_ARCHIVE	   0x100U /* archive creation */
+ #define	ELF_F_ARCHIVE_SYSV 0x200U /* SYSV style archive */
+ 
+-__BEGIN_DECLS
++#ifdef __cplusplus
++extern "C" {
++#endif
+ Elf		*elf_begin(int _fd, Elf_Cmd _cmd, Elf *_elf, Elf_Mem *_mem);
+ int		elf_cntl(Elf *_elf, Elf_Cmd _cmd);
+ int		elf_end(Elf *_elf);
+@@ -257,6 +259,8 @@
+ 			unsigned int _enc);
+ Elf_Data	*elf64_xlatetom(Elf_Data *_dst, const Elf_Data *_src,
+ 			unsigned int _enc);
+-__END_DECLS
++#ifdef __cplusplus
++}
++#endif
+ 
+ #endif	/* _LIBELF_H_ */
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_align.c compiler/lib/loaders/elf/utils/libelf/libelf_align.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_align.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_align.c	2020-04-19 09:02:40.660314911 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <sys/types.h>
+ 
+ #include <libelf.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_allocate.c compiler/lib/loaders/elf/utils/libelf/libelf_allocate.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_allocate.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_allocate.c	2020-04-19 09:02:43.079318019 -0400
+@@ -28,8 +28,6 @@
+  * Internal APIs
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #if !defined(WIN32)
+ #include <sys/errno.h>
+ #endif
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_ar.c compiler/lib/loaders/elf/utils/libelf/libelf_ar.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_ar.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_ar.c	2020-04-19 09:02:44.763320187 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <ctype.h>
+ #include <libelf.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_ar_util.c compiler/lib/loaders/elf/utils/libelf/libelf_ar_util.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_ar_util.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_ar_util.c	2020-04-19 09:02:46.461322369 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <libelf.h>
+ #include <stdlib.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_checksum.c compiler/lib/loaders/elf/utils/libelf/libelf_checksum.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_checksum.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_checksum.c	2020-04-19 09:02:48.645325173 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <gelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_convert.c compiler/lib/loaders/elf/utils/libelf/libelf_convert.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_convert.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_convert.c	2020-04-19 09:02:50.883328053 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <libelf.h>
+ #include <string.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_data.c compiler/lib/loaders/elf/utils/libelf/libelf_data.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_data.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_data.c	2020-04-19 09:02:52.951330708 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_ehdr.c compiler/lib/loaders/elf/utils/libelf/libelf_ehdr.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_ehdr.c	2020-04-19 08:59:34.204386579 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_ehdr.c	2020-04-19 09:02:55.176333563 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ #include <libelf.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_extended.c compiler/lib/loaders/elf/utils/libelf/libelf_extended.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_extended.c	2020-04-19 08:59:34.204386579 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_extended.c	2020-04-19 09:02:57.932337110 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <libelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_msize.c compiler/lib/loaders/elf/utils/libelf/libelf_msize.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_msize.c	2020-04-19 08:59:34.204386579 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_msize.c	2020-04-19 09:03:02.201342598 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <libelf.h>
+ #include <string.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_phdr.c compiler/lib/loaders/elf/utils/libelf/libelf_phdr.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_phdr.c	2020-04-19 08:59:34.204386579 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_phdr.c	2020-04-19 09:03:04.194345160 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ #include <libelf.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_shdr.c compiler/lib/loaders/elf/utils/libelf/libelf_shdr.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_shdr.c	2020-04-19 08:59:34.204386579 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_shdr.c	2020-04-19 09:03:05.795347218 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <gelf.h>
+ #include <libelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_xlate.c compiler/lib/loaders/elf/utils/libelf/libelf_xlate.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_xlate.c	2020-04-19 08:59:34.204386579 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_xlate.c	2020-04-19 09:03:09.472351944 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <libelf.h>
+ 
diff --git a/srcpkgs/rocm-opencl-runtime/files/runtime-musl.patch b/srcpkgs/rocm-opencl-runtime/files/runtime-musl.patch
new file mode 100644
index 00000000000..ea18e90e09c
--- /dev/null
+++ b/srcpkgs/rocm-opencl-runtime/files/runtime-musl.patch
@@ -0,0 +1,11 @@
+--- runtime/os/os_posix.cpp.orig	2020-04-19 09:13:51.701982901 -0400
++++ runtime/os/os_posix.cpp	2020-04-19 09:14:04.156947422 -0400
+@@ -44,6 +44,8 @@
+ #include <algorithm>
+ #include <mutex>
+ 
++#include <libgen.h> // for basename
++
+ 
+ namespace amd {
+ 
diff --git a/srcpkgs/rocm-opencl-runtime/files/sys_queue.h b/srcpkgs/rocm-opencl-runtime/files/sys_queue.h
new file mode 100644
index 00000000000..daf4553d33e
--- /dev/null
+++ b/srcpkgs/rocm-opencl-runtime/files/sys_queue.h
@@ -0,0 +1,574 @@
+/*
+ * Copyright (c) 1991, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *	@(#)queue.h	8.5 (Berkeley) 8/20/94
+ */
+
+#ifndef	_SYS_QUEUE_H_
+#define	_SYS_QUEUE_H_
+
+/*
+ * This file defines five types of data structures: singly-linked lists,
+ * lists, simple queues, tail queues, and circular queues.
+ *
+ * A singly-linked list is headed by a single forward pointer. The
+ * elements are singly linked for minimum space and pointer manipulation
+ * overhead at the expense of O(n) removal for arbitrary elements. New
+ * elements can be added to the list after an existing element or at the
+ * head of the list.  Elements being removed from the head of the list
+ * should use the explicit macro for this purpose for optimum
+ * efficiency. A singly-linked list may only be traversed in the forward
+ * direction.  Singly-linked lists are ideal for applications with large
+ * datasets and few or no removals or for implementing a LIFO queue.
+ *
+ * A list is headed by a single forward pointer (or an array of forward
+ * pointers for a hash table header). The elements are doubly linked
+ * so that an arbitrary element can be removed without a need to
+ * traverse the list. New elements can be added to the list before
+ * or after an existing element or at the head of the list. A list
+ * may only be traversed in the forward direction.
+ *
+ * A simple queue is headed by a pair of pointers, one the head of the
+ * list and the other to the tail of the list. The elements are singly
+ * linked to save space, so elements can only be removed from the
+ * head of the list. New elements can be added to the list after
+ * an existing element, at the head of the list, or at the end of the
+ * list. A simple queue may only be traversed in the forward direction.
+ *
+ * A tail queue is headed by a pair of pointers, one to the head of the
+ * list and the other to the tail of the list. The elements are doubly
+ * linked so that an arbitrary element can be removed without a need to
+ * traverse the list. New elements can be added to the list before or
+ * after an existing element, at the head of the list, or at the end of
+ * the list. A tail queue may be traversed in either direction.
+ *
+ * A circle queue is headed by a pair of pointers, one to the head of the
+ * list and the other to the tail of the list. The elements are doubly
+ * linked so that an arbitrary element can be removed without a need to
+ * traverse the list. New elements can be added to the list before or after
+ * an existing element, at the head of the list, or at the end of the list.
+ * A circle queue may be traversed in either direction, but has a more
+ * complex end of list detection.
+ *
+ * For details on the use of these macros, see the queue(3) manual page.
+ */
+
+/*
+ * List definitions.
+ */
+#define	LIST_HEAD(name, type)						\
+struct name {								\
+	struct type *lh_first;	/* first element */			\
+}
+
+#define	LIST_HEAD_INITIALIZER(head)					\
+	{ NULL }
+
+#define	LIST_ENTRY(type)						\
+struct {								\
+	struct type *le_next;	/* next element */			\
+	struct type **le_prev;	/* address of previous next element */	\
+}
+
+/*
+ * List functions.
+ */
+#define	LIST_INIT(head) do {						\
+	(head)->lh_first = NULL;					\
+} while (/*CONSTCOND*/0)
+
+#define	LIST_INSERT_AFTER(listelm, elm, field) do {			\
+	if (((elm)->field.le_next = (listelm)->field.le_next) != NULL)	\
+		(listelm)->field.le_next->field.le_prev =		\
+		    &(elm)->field.le_next;				\
+	(listelm)->field.le_next = (elm);				\
+	(elm)->field.le_prev = &(listelm)->field.le_next;		\
+} while (/*CONSTCOND*/0)
+
+#define	LIST_INSERT_BEFORE(listelm, elm, field) do {			\
+	(elm)->field.le_prev = (listelm)->field.le_prev;		\
+	(elm)->field.le_next = (listelm);				\
+	*(listelm)->field.le_prev = (elm);				\
+	(listelm)->field.le_prev = &(elm)->field.le_next;		\
+} while (/*CONSTCOND*/0)
+
+#define	LIST_INSERT_HEAD(head, elm, field) do {				\
+	if (((elm)->field.le_next = (head)->lh_first) != NULL)		\
+		(head)->lh_first->field.le_prev = &(elm)->field.le_next;\
+	(head)->lh_first = (elm);					\
+	(elm)->field.le_prev = &(head)->lh_first;			\
+} while (/*CONSTCOND*/0)
+
+#define	LIST_REMOVE(elm, field) do {					\
+	if ((elm)->field.le_next != NULL)				\
+		(elm)->field.le_next->field.le_prev = 			\
+		    (elm)->field.le_prev;				\
+	*(elm)->field.le_prev = (elm)->field.le_next;			\
+} while (/*CONSTCOND*/0)
+
+#define	LIST_FOREACH(var, head, field)					\
+	for ((var) = ((head)->lh_first);				\
+		(var);							\
+		(var) = ((var)->field.le_next))
+
+/*
+ * List access methods.
+ */
+#define	LIST_EMPTY(head)		((head)->lh_first == NULL)
+#define	LIST_FIRST(head)		((head)->lh_first)
+#define	LIST_NEXT(elm, field)		((elm)->field.le_next)
+
+
+/*
+ * Singly-linked List definitions.
+ */
+#define	SLIST_HEAD(name, type)						\
+struct name {								\
+	struct type *slh_first;	/* first element */			\
+}
+
+#define	SLIST_HEAD_INITIALIZER(head)					\
+	{ NULL }
+
+#define	SLIST_ENTRY(type)						\
+struct {								\
+	struct type *sle_next;	/* next element */			\
+}
+
+/*
+ * Singly-linked List functions.
+ */
+#define	SLIST_INIT(head) do {						\
+	(head)->slh_first = NULL;					\
+} while (/*CONSTCOND*/0)
+
+#define	SLIST_INSERT_AFTER(slistelm, elm, field) do {			\
+	(elm)->field.sle_next = (slistelm)->field.sle_next;		\
+	(slistelm)->field.sle_next = (elm);				\
+} while (/*CONSTCOND*/0)
+
+#define	SLIST_INSERT_HEAD(head, elm, field) do {			\
+	(elm)->field.sle_next = (head)->slh_first;			\
+	(head)->slh_first = (elm);					\
+} while (/*CONSTCOND*/0)
+
+#define	SLIST_REMOVE_HEAD(head, field) do {				\
+	(head)->slh_first = (head)->slh_first->field.sle_next;		\
+} while (/*CONSTCOND*/0)
+
+#define	SLIST_REMOVE(head, elm, type, field) do {			\
+	if ((head)->slh_first == (elm)) {				\
+		SLIST_REMOVE_HEAD((head), field);			\
+	}								\
+	else {								\
+		struct type *curelm = (head)->slh_first;		\
+		while(curelm->field.sle_next != (elm))			\
+			curelm = curelm->field.sle_next;		\
+		curelm->field.sle_next =				\
+		    curelm->field.sle_next->field.sle_next;		\
+	}								\
+} while (/*CONSTCOND*/0)
+
+#define	SLIST_FOREACH(var, head, field)					\
+	for((var) = (head)->slh_first; (var); (var) = (var)->field.sle_next)
+
+/*
+ * Singly-linked List access methods.
+ */
+#define	SLIST_EMPTY(head)	((head)->slh_first == NULL)
+#define	SLIST_FIRST(head)	((head)->slh_first)
+#define	SLIST_NEXT(elm, field)	((elm)->field.sle_next)
+
+
+/*
+ * Singly-linked Tail queue declarations.
+ */
+#define	STAILQ_HEAD(name, type)					\
+struct name {								\
+	struct type *stqh_first;	/* first element */			\
+	struct type **stqh_last;	/* addr of last next element */		\
+}
+
+#define	STAILQ_HEAD_INITIALIZER(head)					\
+	{ NULL, &(head).stqh_first }
+
+#define	STAILQ_ENTRY(type)						\
+struct {								\
+	struct type *stqe_next;	/* next element */			\
+}
+
+/*
+ * Singly-linked Tail queue functions.
+ */
+#define	STAILQ_INIT(head) do {						\
+	(head)->stqh_first = NULL;					\
+	(head)->stqh_last = &(head)->stqh_first;				\
+} while (/*CONSTCOND*/0)
+
+#define	STAILQ_INSERT_HEAD(head, elm, field) do {			\
+	if (((elm)->field.stqe_next = (head)->stqh_first) == NULL)	\
+		(head)->stqh_last = &(elm)->field.stqe_next;		\
+	(head)->stqh_first = (elm);					\
+} while (/*CONSTCOND*/0)
+
+#define	STAILQ_INSERT_TAIL(head, elm, field) do {			\
+	(elm)->field.stqe_next = NULL;					\
+	*(head)->stqh_last = (elm);					\
+	(head)->stqh_last = &(elm)->field.stqe_next;			\
+} while (/*CONSTCOND*/0)
+
+#define	STAILQ_INSERT_AFTER(head, listelm, elm, field) do {		\
+	if (((elm)->field.stqe_next = (listelm)->field.stqe_next) == NULL)\
+		(head)->stqh_last = &(elm)->field.stqe_next;		\
+	(listelm)->field.stqe_next = (elm);				\
+} while (/*CONSTCOND*/0)
+
+#define	STAILQ_REMOVE_HEAD(head, field) do {				\
+	if (((head)->stqh_first = (head)->stqh_first->field.stqe_next) == NULL) \
+		(head)->stqh_last = &(head)->stqh_first;			\
+} while (/*CONSTCOND*/0)
+
+#define	STAILQ_REMOVE(head, elm, type, field) do {			\
+	if ((head)->stqh_first == (elm)) {				\
+		STAILQ_REMOVE_HEAD((head), field);			\
+	} else {							\
+		struct type *curelm = (head)->stqh_first;		\
+		while (curelm->field.stqe_next != (elm))			\
+			curelm = curelm->field.stqe_next;		\
+		if ((curelm->field.stqe_next =				\
+			curelm->field.stqe_next->field.stqe_next) == NULL) \
+			    (head)->stqh_last = &(curelm)->field.stqe_next; \
+	}								\
+} while (/*CONSTCOND*/0)
+
+#define	STAILQ_FOREACH(var, head, field)				\
+	for ((var) = ((head)->stqh_first);				\
+		(var);							\
+		(var) = ((var)->field.stqe_next))
+
+#define	STAILQ_CONCAT(head1, head2) do {				\
+	if (!STAILQ_EMPTY((head2))) {					\
+		*(head1)->stqh_last = (head2)->stqh_first;		\
+		(head1)->stqh_last = (head2)->stqh_last;		\
+		STAILQ_INIT((head2));					\
+	}								\
+} while (/*CONSTCOND*/0)
+
+/*
+ * Singly-linked Tail queue access methods.
+ */
+#define	STAILQ_EMPTY(head)	((head)->stqh_first == NULL)
+#define	STAILQ_FIRST(head)	((head)->stqh_first)
+#define	STAILQ_NEXT(elm, field)	((elm)->field.stqe_next)
+
+
+/*
+ * Simple queue definitions.
+ */
+#define	SIMPLEQ_HEAD(name, type)					\
+struct name {								\
+	struct type *sqh_first;	/* first element */			\
+	struct type **sqh_last;	/* addr of last next element */		\
+}
+
+#define	SIMPLEQ_HEAD_INITIALIZER(head)					\
+	{ NULL, &(head).sqh_first }
+
+#define	SIMPLEQ_ENTRY(type)						\
+struct {								\
+	struct type *sqe_next;	/* next element */			\
+}
+
+/*
+ * Simple queue functions.
+ */
+#define	SIMPLEQ_INIT(head) do {						\
+	(head)->sqh_first = NULL;					\
+	(head)->sqh_last = &(head)->sqh_first;				\
+} while (/*CONSTCOND*/0)
+
+#define	SIMPLEQ_INSERT_HEAD(head, elm, field) do {			\
+	if (((elm)->field.sqe_next = (head)->sqh_first) == NULL)	\
+		(head)->sqh_last = &(elm)->field.sqe_next;		\
+	(head)->sqh_first = (elm);					\
+} while (/*CONSTCOND*/0)
+
+#define	SIMPLEQ_INSERT_TAIL(head, elm, field) do {			\
+	(elm)->field.sqe_next = NULL;					\
+	*(head)->sqh_last = (elm);					\
+	(head)->sqh_last = &(elm)->field.sqe_next;			\
+} while (/*CONSTCOND*/0)
+
+#define	SIMPLEQ_INSERT_AFTER(head, listelm, elm, field) do {		\
+	if (((elm)->field.sqe_next = (listelm)->field.sqe_next) == NULL)\
+		(head)->sqh_last = &(elm)->field.sqe_next;		\
+	(listelm)->field.sqe_next = (elm);				\
+} while (/*CONSTCOND*/0)
+
+#define	SIMPLEQ_REMOVE_HEAD(head, field) do {				\
+	if (((head)->sqh_first = (head)->sqh_first->field.sqe_next) == NULL) \
+		(head)->sqh_last = &(head)->sqh_first;			\
+} while (/*CONSTCOND*/0)
+
+#define	SIMPLEQ_REMOVE(head, elm, type, field) do {			\
+	if ((head)->sqh_first == (elm)) {				\
+		SIMPLEQ_REMOVE_HEAD((head), field);			\
+	} else {							\
+		struct type *curelm = (head)->sqh_first;		\
+		while (curelm->field.sqe_next != (elm))			\
+			curelm = curelm->field.sqe_next;		\
+		if ((curelm->field.sqe_next =				\
+			curelm->field.sqe_next->field.sqe_next) == NULL) \
+			    (head)->sqh_last = &(curelm)->field.sqe_next; \
+	}								\
+} while (/*CONSTCOND*/0)
+
+#define	SIMPLEQ_FOREACH(var, head, field)				\
+	for ((var) = ((head)->sqh_first);				\
+		(var);							\
+		(var) = ((var)->field.sqe_next))
+
+/*
+ * Simple queue access methods.
+ */
+#define	SIMPLEQ_EMPTY(head)		((head)->sqh_first == NULL)
+#define	SIMPLEQ_FIRST(head)		((head)->sqh_first)
+#define	SIMPLEQ_NEXT(elm, field)	((elm)->field.sqe_next)
+
+
+/*
+ * Tail queue definitions.
+ */
+#define	_TAILQ_HEAD(name, type, qual)					\
+struct name {								\
+	qual type *tqh_first;		/* first element */		\
+	qual type *qual *tqh_last;	/* addr of last next element */	\
+}
+#define TAILQ_HEAD(name, type)	_TAILQ_HEAD(name, struct type,)
+
+#define	TAILQ_HEAD_INITIALIZER(head)					\
+	{ NULL, &(head).tqh_first }
+
+#define	_TAILQ_ENTRY(type, qual)					\
+struct {								\
+	qual type *tqe_next;		/* next element */		\
+	qual type *qual *tqe_prev;	/* address of previous next element */\
+}
+#define TAILQ_ENTRY(type)	_TAILQ_ENTRY(struct type,)
+
+/*
+ * Tail queue functions.
+ */
+#define	TAILQ_INIT(head) do {						\
+	(head)->tqh_first = NULL;					\
+	(head)->tqh_last = &(head)->tqh_first;				\
+} while (/*CONSTCOND*/0)
+
+#define	TAILQ_INSERT_HEAD(head, elm, field) do {			\
+	if (((elm)->field.tqe_next = (head)->tqh_first) != NULL)	\
+		(head)->tqh_first->field.tqe_prev =			\
+		    &(elm)->field.tqe_next;				\
+	else								\
+		(head)->tqh_last = &(elm)->field.tqe_next;		\
+	(head)->tqh_first = (elm);					\
+	(elm)->field.tqe_prev = &(head)->tqh_first;			\
+} while (/*CONSTCOND*/0)
+
+#define	TAILQ_INSERT_TAIL(head, elm, field) do {			\
+	(elm)->field.tqe_next = NULL;					\
+	(elm)->field.tqe_prev = (head)->tqh_last;			\
+	*(head)->tqh_last = (elm);					\
+	(head)->tqh_last = &(elm)->field.tqe_next;			\
+} while (/*CONSTCOND*/0)
+
+#define	TAILQ_INSERT_AFTER(head, listelm, elm, field) do {		\
+	if (((elm)->field.tqe_next = (listelm)->field.tqe_next) != NULL)\
+		(elm)->field.tqe_next->field.tqe_prev = 		\
+		    &(elm)->field.tqe_next;				\
+	else								\
+		(head)->tqh_last = &(elm)->field.tqe_next;		\
+	(listelm)->field.tqe_next = (elm);				\
+	(elm)->field.tqe_prev = &(listelm)->field.tqe_next;		\
+} while (/*CONSTCOND*/0)
+
+#define	TAILQ_INSERT_BEFORE(listelm, elm, field) do {			\
+	(elm)->field.tqe_prev = (listelm)->field.tqe_prev;		\
+	(elm)->field.tqe_next = (listelm);				\
+	*(listelm)->field.tqe_prev = (elm);				\
+	(listelm)->field.tqe_prev = &(elm)->field.tqe_next;		\
+} while (/*CONSTCOND*/0)
+
+#define	TAILQ_REMOVE(head, elm, field) do {				\
+	if (((elm)->field.tqe_next) != NULL)				\
+		(elm)->field.tqe_next->field.tqe_prev = 		\
+		    (elm)->field.tqe_prev;				\
+	else								\
+		(head)->tqh_last = (elm)->field.tqe_prev;		\
+	*(elm)->field.tqe_prev = (elm)->field.tqe_next;			\
+} while (/*CONSTCOND*/0)
+
+#define	TAILQ_FOREACH(var, head, field)					\
+	for ((var) = ((head)->tqh_first);				\
+		(var);							\
+		(var) = ((var)->field.tqe_next))
+
+#define	TAILQ_FOREACH_REVERSE(var, head, headname, field)		\
+	for ((var) = (*(((struct headname *)((head)->tqh_last))->tqh_last));	\
+		(var);							\
+		(var) = (*(((struct headname *)((var)->field.tqe_prev))->tqh_last)))
+
+#define	TAILQ_CONCAT(head1, head2, field) do {				\
+	if (!TAILQ_EMPTY(head2)) {					\
+		*(head1)->tqh_last = (head2)->tqh_first;		\
+		(head2)->tqh_first->field.tqe_prev = (head1)->tqh_last;	\
+		(head1)->tqh_last = (head2)->tqh_last;			\
+		TAILQ_INIT((head2));					\
+	}								\
+} while (/*CONSTCOND*/0)
+
+/*
+ * Tail queue access methods.
+ */
+#define	TAILQ_EMPTY(head)		((head)->tqh_first == NULL)
+#define	TAILQ_FIRST(head)		((head)->tqh_first)
+#define	TAILQ_NEXT(elm, field)		((elm)->field.tqe_next)
+
+#define	TAILQ_LAST(head, headname) \
+	(*(((struct headname *)((head)->tqh_last))->tqh_last))
+#define	TAILQ_PREV(elm, headname, field) \
+	(*(((struct headname *)((elm)->field.tqe_prev))->tqh_last))
+
+
+/*
+ * Circular queue definitions.
+ */
+#define	CIRCLEQ_HEAD(name, type)					\
+struct name {								\
+	struct type *cqh_first;		/* first element */		\
+	struct type *cqh_last;		/* last element */		\
+}
+
+#define	CIRCLEQ_HEAD_INITIALIZER(head)					\
+	{ (void *)&head, (void *)&head }
+
+#define	CIRCLEQ_ENTRY(type)						\
+struct {								\
+	struct type *cqe_next;		/* next element */		\
+	struct type *cqe_prev;		/* previous element */		\
+}
+
+/*
+ * Circular queue functions.
+ */
+#define	CIRCLEQ_INIT(head) do {						\
+	(head)->cqh_first = (void *)(head);				\
+	(head)->cqh_last = (void *)(head);				\
+} while (/*CONSTCOND*/0)
+
+#define	CIRCLEQ_INSERT_AFTER(head, listelm, elm, field) do {		\
+	(elm)->field.cqe_next = (listelm)->field.cqe_next;		\
+	(elm)->field.cqe_prev = (listelm);				\
+	if ((listelm)->field.cqe_next == (void *)(head))		\
+		(head)->cqh_last = (elm);				\
+	else								\
+		(listelm)->field.cqe_next->field.cqe_prev = (elm);	\
+	(listelm)->field.cqe_next = (elm);				\
+} while (/*CONSTCOND*/0)
+
+#define	CIRCLEQ_INSERT_BEFORE(head, listelm, elm, field) do {		\
+	(elm)->field.cqe_next = (listelm);				\
+	(elm)->field.cqe_prev = (listelm)->field.cqe_prev;		\
+	if ((listelm)->field.cqe_prev == (void *)(head))		\
+		(head)->cqh_first = (elm);				\
+	else								\
+		(listelm)->field.cqe_prev->field.cqe_next = (elm);	\
+	(listelm)->field.cqe_prev = (elm);				\
+} while (/*CONSTCOND*/0)
+
+#define	CIRCLEQ_INSERT_HEAD(head, elm, field) do {			\
+	(elm)->field.cqe_next = (head)->cqh_first;			\
+	(elm)->field.cqe_prev = (void *)(head);				\
+	if ((head)->cqh_last == (void *)(head))				\
+		(head)->cqh_last = (elm);				\
+	else								\
+		(head)->cqh_first->field.cqe_prev = (elm);		\
+	(head)->cqh_first = (elm);					\
+} while (/*CONSTCOND*/0)
+
+#define	CIRCLEQ_INSERT_TAIL(head, elm, field) do {			\
+	(elm)->field.cqe_next = (void *)(head);				\
+	(elm)->field.cqe_prev = (head)->cqh_last;			\
+	if ((head)->cqh_first == (void *)(head))			\
+		(head)->cqh_first = (elm);				\
+	else								\
+		(head)->cqh_last->field.cqe_next = (elm);		\
+	(head)->cqh_last = (elm);					\
+} while (/*CONSTCOND*/0)
+
+#define	CIRCLEQ_REMOVE(head, elm, field) do {				\
+	if ((elm)->field.cqe_next == (void *)(head))			\
+		(head)->cqh_last = (elm)->field.cqe_prev;		\
+	else								\
+		(elm)->field.cqe_next->field.cqe_prev =			\
+		    (elm)->field.cqe_prev;				\
+	if ((elm)->field.cqe_prev == (void *)(head))			\
+		(head)->cqh_first = (elm)->field.cqe_next;		\
+	else								\
+		(elm)->field.cqe_prev->field.cqe_next =			\
+		    (elm)->field.cqe_next;				\
+} while (/*CONSTCOND*/0)
+
+#define	CIRCLEQ_FOREACH(var, head, field)				\
+	for ((var) = ((head)->cqh_first);				\
+		(var) != (const void *)(head);				\
+		(var) = ((var)->field.cqe_next))
+
+#define	CIRCLEQ_FOREACH_REVERSE(var, head, field)			\
+	for ((var) = ((head)->cqh_last);				\
+		(var) != (const void *)(head);				\
+		(var) = ((var)->field.cqe_prev))
+
+/*
+ * Circular queue access methods.
+ */
+#define	CIRCLEQ_EMPTY(head)		((head)->cqh_first == (void *)(head))
+#define	CIRCLEQ_FIRST(head)		((head)->cqh_first)
+#define	CIRCLEQ_LAST(head)		((head)->cqh_last)
+#define	CIRCLEQ_NEXT(elm, field)	((elm)->field.cqe_next)
+#define	CIRCLEQ_PREV(elm, field)	((elm)->field.cqe_prev)
+
+#define CIRCLEQ_LOOP_NEXT(head, elm, field)				\
+	(((elm)->field.cqe_next == (void *)(head))			\
+	    ? ((head)->cqh_first)					\
+	    : (elm->field.cqe_next))
+#define CIRCLEQ_LOOP_PREV(head, elm, field)				\
+	(((elm)->field.cqe_prev == (void *)(head))			\
+	    ? ((head)->cqh_last)					\
+	    : (elm->field.cqe_prev))
+
+#endif	/* sys/queue.h */
diff --git a/srcpkgs/rocm-opencl-runtime/patches/cmake.patch b/srcpkgs/rocm-opencl-runtime/patches/cmake.patch
new file mode 100644
index 00000000000..2b3354f3eeb
--- /dev/null
+++ b/srcpkgs/rocm-opencl-runtime/patches/cmake.patch
@@ -0,0 +1,123 @@
+diff -u -r ../original/OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/CMakeLists.txt ./OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/CMakeLists.txt
+--- OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/CMakeLists.txt	2019-09-10 11:53:28.000000000 -0400
++++ OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/CMakeLists.txt	2020-04-16 20:16:13.481180757 -0400
+@@ -73,11 +73,11 @@
+ 
+ set (OPENCL_ICD_LOADER_HEADERS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/inc CACHE PATH "Path to OpenCL Headers")
+ 
+-add_library (OpenCL ${OPENCL_ICD_LOADER_SOURCES})
+-set_target_properties (OpenCL PROPERTIES VERSION "1.2" SOVERSION "1")
++add_library (OpenCL-ROCm ${OPENCL_ICD_LOADER_SOURCES})
++set_target_properties (OpenCL-ROCm PROPERTIES VERSION "1.2" SOVERSION "1")
+ 
+ if (WIN32)
+-    target_link_libraries (OpenCL cfgmgr32.lib)
++    target_link_libraries (OpenCL-ROCm cfgmgr32.lib)
+ 
+     option (OPENCL_ICD_LOADER_REQUIRE_WDK "Build with D3DKMT support, which requires the Windows WDK." ON)
+     if (OPENCL_ICD_LOADER_REQUIRE_WDK)
+@@ -92,10 +92,10 @@
+             get_filename_component(WDK_DIRECTORY ${LATEST_D3DKMT_HEADER} DIRECTORY)
+             get_filename_component(WDK_DIRECTORY ${WDK_DIRECTORY} DIRECTORY)
+             message(STATUS "Found the Windows WDK in: ${WDK_DIRECTORY}")
+-            target_compile_definitions(OpenCL PRIVATE OPENCL_ICD_LOADER_REQUIRE_WDK)
+-            target_include_directories(OpenCL PRIVATE ${WDK_DIRECTORY}/um)
+-            target_include_directories(OpenCL PRIVATE ${WDK_DIRECTORY}/km)
+-            target_include_directories(OpenCL PRIVATE ${WDK_DIRECTORY}/shared)
++	    target_compile_definitions(OpenCL-ROCm PRIVATE OPENCL_ICD_LOADER_REQUIRE_WDK)
++	    target_include_directories(OpenCL-ROCm PRIVATE ${WDK_DIRECTORY}/um)
++	    target_include_directories(OpenCL-ROCm PRIVATE ${WDK_DIRECTORY}/km)
++	    target_include_directories(OpenCL-ROCm PRIVATE ${WDK_DIRECTORY}/shared)
+         else()
+             message(FATAL_ERROR "The Windows WDK was not found. Consider disabling OPENCL_ICD_LOADER_REQUIRE_WDK. Aborting.")
+         endif()
+@@ -113,25 +113,25 @@
+     endif()
+ else()
+     if (APPLE)
+-        target_link_libraries (OpenCL ${CMAKE_THREAD_LIBS_INIT})
++        target_link_libraries (OpenCL-ROCm ${CMAKE_THREAD_LIBS_INIT})
+     else ()
+-        set_target_properties (OpenCL PROPERTIES LINK_FLAGS "-Wl,--version-script -Wl,${CMAKE_CURRENT_SOURCE_DIR}/loader/linux/icd_exports.map")
+-        target_link_libraries (OpenCL ${CMAKE_THREAD_LIBS_INIT})
++        set_target_properties (OpenCL-ROCm PROPERTIES LINK_FLAGS "-Wl,--version-script -Wl,${CMAKE_CURRENT_SOURCE_DIR}/loader/linux/icd_exports.map")
++	target_link_libraries (OpenCL-ROCm ${CMAKE_THREAD_LIBS_INIT})
+     endif ()
+ endif ()
+ 
+ include_directories (${OPENCL_ICD_LOADER_HEADERS_DIR})
+ add_definitions (-DCL_TARGET_OPENCL_VERSION=220)
+ 
+-target_include_directories (OpenCL PRIVATE ${CMAKE_CURRENT_BINARY_DIR} loader)
+-target_link_libraries (OpenCL ${CMAKE_DL_LIBS})
++target_include_directories (OpenCL-ROCm PRIVATE ${CMAKE_CURRENT_BINARY_DIR} loader)
++target_link_libraries (OpenCL-ROCm ${CMAKE_DL_LIBS})
+ 
+ include (CTest)
+ if (BUILD_TESTING)
+     add_subdirectory (test)
+ endif()
+ 
+-install (TARGETS OpenCL
++install (TARGETS OpenCL-ROCm
+     RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+     ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
+     LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
+diff -u -r ../original/OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/test/loader_test/CMakeLists.txt ./OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/test/loader_test/CMakeLists.txt
+--- OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/test/loader_test/CMakeLists.txt	2019-09-10 11:53:28.000000000 -0400
++++ OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/test/loader_test/CMakeLists.txt	2020-04-16 20:16:56.647026589 -0400
+@@ -12,4 +12,4 @@
+     test_clgl.c
+     test_image_objects.c )
+ 
+-target_link_libraries (icd_loader_test OpenCL IcdLog)
++target_link_libraries (icd_loader_test OpenCL-ROCm IcdLog)
+diff -u -r ../original/ROCm-OpenCL-Runtime-roc-3.3.0/CMakeLists.txt ./ROCm-OpenCL-Runtime-roc-3.3.0/CMakeLists.txt
+--- ROCm-OpenCL-Runtime-roc-3.3.0/CMakeLists.txt	2020-04-18 20:16:13.452670818 -0400
++++ ROCm-OpenCL-Runtime-roc-3.3.0/CMakeLists.txt	2020-04-18 20:20:09.798862321 -0400
+@@ -102,16 +102,16 @@
+ 
+ # MAIN package
+ install(PROGRAMS $<TARGET_FILE:clinfo>
+-        DESTINATION bin/x86_64
++        DESTINATION bin
+         COMPONENT MAIN)
+ install(PROGRAMS $<TARGET_FILE:amdocl64>
+-        DESTINATION lib/x86_64
++        DESTINATION lib
+         COMPONENT MAIN)
+-install(PROGRAMS $<TARGET_FILE:OpenCL>
+-        DESTINATION lib/x86_64
++install(PROGRAMS $<TARGET_FILE:OpenCL-ROCm>
++        DESTINATION lib
+         COMPONENT MAIN)
+-install(PROGRAMS $<TARGET_SONAME_FILE:OpenCL>
+-        DESTINATION lib/x86_64
++install(PROGRAMS $<TARGET_SONAME_FILE:OpenCL-ROCm>
++        DESTINATION lib
+         COMPONENT MAIN)
+ 
+ # DEV package
+@@ -123,8 +123,8 @@
+         PATTERN cl_d3d11.h EXCLUDE
+         PATTERN cl_dx9_media_sharing.h EXCLUDE
+         PATTERN cl_egl.h EXCLUDE)
+-install(PROGRAMS $<TARGET_LINKER_FILE:OpenCL>
+-        DESTINATION lib/x86_64
++install(PROGRAMS $<TARGET_LINKER_FILE:OpenCL-ROCm>
++        DESTINATION lib
+         COMPONENT DEV)
+ 
+ # Generic CPACK variables
+diff -u -r ../original/ROCm-OpenCL-Runtime-roc-3.3.0/tools/clinfo/CMakeLists.txt ./ROCm-OpenCL-Runtime-roc-3.3.0/tools/clinfo/CMakeLists.txt
+--- ROCm-OpenCL-Runtime-roc-3.3.0/tools/clinfo/CMakeLists.txt	2020-04-01 13:05:07.000000000 -0400
++++ ROCm-OpenCL-Runtime-roc-3.3.0/tools/clinfo/CMakeLists.txt	2020-04-16 20:17:33.735894123 -0400
+@@ -8,4 +8,7 @@
+ 
+ add_executable(clinfo clinfo.cpp)
+ 
+-target_link_libraries(clinfo OpenCL)
++target_link_libraries(clinfo OpenCL-ROCm)
++
++# Make sure the clinfo rpath does not point to build directory
++set_target_properties(clinfo PROPERTIES BUILD_WITH_INSTALL_RPATH ON)
diff --git a/srcpkgs/rocm-opencl-runtime/template b/srcpkgs/rocm-opencl-runtime/template
new file mode 100644
index 00000000000..832ec7566ff
--- /dev/null
+++ b/srcpkgs/rocm-opencl-runtime/template
@@ -0,0 +1,78 @@
+# Template file for 'rocm-opencl-runtime'
+pkgname=rocm-opencl-runtime
+version=3.3.0
+revision=1
+_ocl_icd_name="OpenCL-ICD-Loader"
+_ocl_icd_ver="6c03f8b58fafd9dd693eaac826749a5cfad515f8"
+archs="x86_64*"
+create_wrksrc=yes
+build_wrksrc="ROCm-OpenCL-Runtime-roc-${version}"
+build_style=cmake
+configure_args="-DCMAKE_INSTALL_PREFIX:PATH=/opt/rocm
+	-DCMAKE_PREFIX_PATH:PATH=/opt/rocm/lib/cmake
+	-DCMAKE_INSTALL_RPATH:PATH='\$ORIGIN:\$ORIGIN/../lib'
+	-DUSE_COMGR_LIBRARY=yes"
+hostmakedepends="cmake pkg-config"
+makedepends="libglvnd-devel rocm-comgr-devel
+	roct-thunk-interface-devel rocr-runtime-devel"
+depends="rocm-comgr"
+short_desc="Radeon Open Compute OpenCL runtime"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="MIT"
+homepage="https://github.com/RadeonOpenCompute/ROCm-OpenCL-Runtime"
+_rocroot="https://github.com/RadeonOpenCompute"
+distfiles="${_rocroot}/ROCm-OpenCL-Runtime/archive/roc-${version}.tar.gz
+	${_rocroot}/rocm-cmake/archive/rocm-${version}.tar.gz
+	https://github.com/KhronosGroup/${_ocl_icd_name}/archive/${_ocl_icd_ver}.tar.gz"
+checksum="ac6999f1a491ab066286c2bd6adf50f08f831286f56e267879f9f7eced22f98e
+	76ed3ee8e56cf3246011cf7723c2abda539e1136e7e7f6909bfa45d268b8644f
+	c94d5bb6dc980c4d41d73e2b81663a19aabe494e923e2d0eec72a4c95b318438"
+nocross=yes
+
+post_patch() {
+	if [ "$XBPS_LIBC" = "musl" ]; then
+		# Copy sys/queue.h locally for MUSL builds
+		libelf_dir="compiler/lib/loaders/elf/utils/libelf"
+		cp "${FILESDIR}/sys_queue.h" "${libelf_dir}"
+
+		# Remove dependence on glibc
+		patch -Np0 < ${FILESDIR}/libelf-musl.patch
+		patch -Np0 < ${FILESDIR}/runtime-musl.patch
+		vsed -e '/glibc_functions.cpp/d' -i api/opencl/amdocl/CMakeLists.txt
+	fi
+}
+
+pre_configure() {
+	# ROCm requires a very specific Khronos ICD loader version in the tree
+	# Keep the ICD loader config in /opt/rocm to avoid conflicts
+	_ocl_icd_dir="${_ocl_icd_name}-${_ocl_icd_ver}"
+	ln -sf "${wrksrc}/${_ocl_icd_dir}" api/opencl/khronos/icd
+	vsed -i "${wrksrc}/${_ocl_icd_dir}/loader/icd_platform.h" \
+		-e 's@/etc/OpenCL/vendors/@/opt/rocm&@g'
+
+	# CMake modules probably not useful anywhere but for this build
+	ln -sf "${wrksrc}/rocm-cmake-rocm-${version}/share/rocm/cmake"/*.cmake cmake
+
+	# Fix the dlopen macro to point to versioned libamd_comgr shared object
+	vsed -i 'runtime/device/comgrctx.cpp' \
+		-e 's/\blibamd_comgr\(32\)\?.so\b/&.1/g'
+}
+
+post_install() {
+	vlicense License
+
+	# Create descriptor to allow the ICD loader to find the driver
+	_ocl_icd_dir="opt/rocm/etc/OpenCL/vendors"
+	vmkdir "${_ocl_icd_dir}"
+	echo "/opt/rocm/lib/libamdocl64.so" \
+		> "${DESTDIR}/${_ocl_icd_dir}/amdocl64.icd"
+}
+
+rocm-opencl-runtime-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove opt/rocm/include
+		vmove opt/rocm/lib/libOpenCL-ROCm.so
+	}
+}

^ permalink raw reply	[flat|nested] 61+ messages in thread

* Re: [PR PATCH] [Updated] New packages: ROCm core and OpenCL
  2020-04-19 13:34 [PR PATCH] New packages: ROCm core and OpenCL ahesford
                   ` (3 preceding siblings ...)
  2020-04-20  2:02 ` ahesford
@ 2020-04-28 14:00 ` ahesford
  2020-04-28 15:14 ` ahesford
                   ` (54 subsequent siblings)
  59 siblings, 0 replies; 61+ messages in thread
From: ahesford @ 2020-04-28 14:00 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 3893 bytes --]

There is an updated pull request by ahesford against master on the void-packages repository

https://github.com/ahesford/void-packages rocm
https://github.com/void-linux/void-packages/pull/21153

New packages: ROCm core and OpenCL
This PR includes several packages designed to bring the OpenCL portion of the AMD ROCm ecosystem to Void. It addresses Issue #19507. There are many other packages that AMD provides for GPGPU computing, but these can be added piecemeal as users demand.

The packages are currently only for `x86_64*`. While at least some of the packages will compile on other 64-bit architectures, I have no hardware to test. They are certainly not suitable for 32-bit architectures; some internal data structures rely on `uint64_t` values that are cast to pointers. At a
minimum, a thorough audit would be necessary to ensure that these casts are safe (e.g., that the values stored were only ever upcast from 32-bit pointers). More extensive work may be necessary to support 32-bit architectures, probably without significant benefit.

The packages successfully identify a Radeon RX 580 on an `x86_64` installation using both `clinfo` and `rocminfo` as provided. Furthermore, a version of `pyopencl` linked against these ROCm packages successfully runs a simple program that validates arithmetic on GPU-bound arrays.

There are caveats with this set of packages, almost all of which revolve around the incompatibilities between the Void-provided `ocl-icd` and the [Khronos OpenCL ICD loader](https://github.com/KhronosGroup/OpenCL-ID-Loader) required by (and built into) `rocm-opencl-runtime`.
1. All packages install into `/opt/rocm`. This keeps the environment closer to that officially sanctioned by AMD and helps avoid conflicts between other packages and those provided here. (For example, `clinfo` and the ICD loader itself.) Eventually, we may be able to move the files into `/usr`.
2. The Khronos OpenCL ICD loader built into `rocm-opencl-runtime` is an outdated, pre-release commit. If AMD can update its sources to use the release version of that loader (which has a backward-incompatible API change), we may be able to make ROCm compatible with `ocl-icd` or replace `ocl-icd` with the official Khronos loader.
3. In the meantime, to avoid `shlibs` conflicts, the OpenCL ICD loader is installed as `/opt/rocm/lib/libOpenCL-ROCm.so` (and an appropriately versioned shared library), which means that programs wishing to use the ROCm OpenCL must explicitly link against this library instead of the generic `libOpenCL.so`.
4. I do **not** recommend making any Void packages link against this specific library, because it will make those packages ROCm-only. For the time being, ROCm is intended for end-users to specifically link against. Linking Void packages against ROCm would requires the ICD loader used by ROCm be compatible with `ocl-icd`, or `ocl-icd` be replaced by the Khronos loader. However, because the Khronos loader changed its API for the release version, such a change is not yet appropriate.

Hopefully, if AMD updates its dependence on the Khronos ICD loader, we can resolve some of these caveats in the future and make ROCm a more natural Void component. For now, these packages are useful for those who need an AMD OpenCL solution and would rather custom-link software against the AMD ICD loader than hack the `amdgpu-pro` driver into an ICD compatible with `ocl-icd`.

Some patches were made to relocate some files in `/opt/rocm` and make everyting build on x86_64-musl`. Where appropriate, these patches will be pushed upstream to clean up the distribution and packaging.

Update: I pushed some new commits to update license information that triggerd an `xlint` failure. I've also disabled CI builds because they will time out on `rocm-llvm`.

A patch file from https://github.com/void-linux/void-packages/pull/21153.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-rocm-21153.patch --]
[-- Type: text/x-diff, Size: 73767 bytes --]

From 531451c39a0c4bb4b9c8d83297092f42398538fd Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Mon, 13 Apr 2020 13:08:09 -0400
Subject: [PATCH 1/8] New package: roct-thunk-interface-3.3.0

---
 common/shlibs                                 |  1 +
 srcpkgs/roct-thunk-interface-devel            |  1 +
 .../patches/cmake-dev-libdir.patch            | 10 ++++++
 .../roct-thunk-interface/patches/musl.patch   | 29 ++++++++++++++++
 srcpkgs/roct-thunk-interface/template         | 33 +++++++++++++++++++
 5 files changed, 74 insertions(+)
 create mode 120000 srcpkgs/roct-thunk-interface-devel
 create mode 100644 srcpkgs/roct-thunk-interface/patches/cmake-dev-libdir.patch
 create mode 100644 srcpkgs/roct-thunk-interface/patches/musl.patch
 create mode 100644 srcpkgs/roct-thunk-interface/template

diff --git a/common/shlibs b/common/shlibs
index 60ad7fb85d5..e22d4a7a8d1 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3862,3 +3862,4 @@ libtagparser.so.9 tagparser-9.1.2_1
 libqtutilities.so.6 qtutilities-6.0.4_1
 libkdsoap.so.1.9.0 KDSoap-1.9.0_1
 libstoken.so.1 stoken-0.92_1
+libhsakmt.so.1 roct-thunk-interface-3.3.0_1
diff --git a/srcpkgs/roct-thunk-interface-devel b/srcpkgs/roct-thunk-interface-devel
new file mode 120000
index 00000000000..ac3f2cc684c
--- /dev/null
+++ b/srcpkgs/roct-thunk-interface-devel
@@ -0,0 +1 @@
+roct-thunk-interface
\ No newline at end of file
diff --git a/srcpkgs/roct-thunk-interface/patches/cmake-dev-libdir.patch b/srcpkgs/roct-thunk-interface/patches/cmake-dev-libdir.patch
new file mode 100644
index 00000000000..98c7f1e459c
--- /dev/null
+++ b/srcpkgs/roct-thunk-interface/patches/cmake-dev-libdir.patch
@@ -0,0 +1,10 @@
+--- CMakeLists.txt.old	2020-04-18 19:45:17.306081135 -0400
++++ CMakeLists.txt	2020-04-18 19:46:51.300753636 -0400
+@@ -146,6 +146,7 @@
+     COMMAND ${CMAKE_COMMAND}
+         -DSOURCE_DIR="${SOURCE_DIR}"
+         -DCMAKE_INSTALL_PREFIX="${CMAKE_INSTALL_PREFIX}"
++        -DCMAKE_INSTALL_LIBDIR="${CMAKE_INSTALL_LIBDIR}"
+         -DCPACK_RPM_PACKAGE_REQUIRES="hsakmt-roct"
+         -DCPACK_PACKAGING_INSTALL_PREFIX="${CPACK_PACKAGING_INSTALL_PREFIX}"
+         -DVERSION="${BUILD_VERSION_STRING}"
diff --git a/srcpkgs/roct-thunk-interface/patches/musl.patch b/srcpkgs/roct-thunk-interface/patches/musl.patch
new file mode 100644
index 00000000000..aeea9832411
--- /dev/null
+++ b/srcpkgs/roct-thunk-interface/patches/musl.patch
@@ -0,0 +1,29 @@
+diff -r -u old/src/libhsakmt.h new/src/libhsakmt.h
+--- src/libhsakmt.h	2020-03-04 15:00:47.000000000 -0500
++++ src/libhsakmt.h	2020-04-13 12:58:30.444865992 -0400
+@@ -54,6 +54,10 @@
+ #define CHECK_KFD_OPEN() \
+ 	do { if (kfd_open_count == 0 || hsakmt_forked) return HSAKMT_STATUS_KERNEL_IO_CHANNEL_NOT_OPENED; } while (0)
+ 
++/*On some platforms, a PAGE_SIZE macro eclipses the extern variable*/
++#ifdef PAGE_SIZE
++#undef PAGE_SIZE
++#endif
+ extern int PAGE_SIZE;
+ extern int PAGE_SHIFT;
+ 
+diff -r -u old/src/topology.c new/src/topology.c
+--- src/topology.c	2020-03-04 15:00:47.000000000 -0500
++++ src/topology.c	2020-04-13 13:01:31.209870701 -0400
+@@ -38,6 +38,11 @@
+ #include "libhsakmt.h"
+ #include "fmm.h"
+ 
++/*Needed on MUSL*/
++#ifndef MAXNAMLEN
++#define MAXNAMLEN PATH_MAX
++#endif
++
+ /* Number of memory banks added by thunk on top of topology
+  * This only includes static heaps like LDS, scratch and SVM,
+  * not for MMIO_REMAP heap. MMIO_REMAP memory bank is reported
diff --git a/srcpkgs/roct-thunk-interface/template b/srcpkgs/roct-thunk-interface/template
new file mode 100644
index 00000000000..55a1fc6074a
--- /dev/null
+++ b/srcpkgs/roct-thunk-interface/template
@@ -0,0 +1,33 @@
+# Template file for 'roct-thunk-interface'
+pkgname=roct-thunk-interface
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="ROCT-Thunk-Interface-roc-${version}"
+build_style=cmake
+make_build_target="all build-dev"
+make_install_target="install install-dev"
+hostmakedepends="cmake pkg-config"
+makedepends="pciutils-devel libnuma-devel"
+short_desc="Radeon Open Compute Thunk Interface"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="MIT"
+homepage="https://github.com/RadeonOpenCompute/ROCT-Thunk-Interface"
+distfiles="${homepage}/archive/roc-${version}.tar.gz"
+checksum=2cabe9d2cfa72031c05d11290837c476182e72d8dec2049298f691143fdd212b
+nocross=yes
+
+post_install() {
+	vlicense LICENSE.md
+}
+
+roct-thunk-interface-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove "usr/lib/*.so"
+		vmove usr/share/pkgconfig
+		vmove usr/lib/cmake
+	}
+}

From 08cad6f6f48c837a1c67f501abd89425c5a5f61c Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Mon, 13 Apr 2020 15:27:27 -0400
Subject: [PATCH 2/8] New package: rocr-runtime-3.3.0

---
 common/shlibs                            |  1 +
 srcpkgs/rocr-runtime-devel               |  1 +
 srcpkgs/rocr-runtime/patches/cmake.patch | 27 +++++++++++++++++++++
 srcpkgs/rocr-runtime/template            | 30 ++++++++++++++++++++++++
 4 files changed, 59 insertions(+)
 create mode 120000 srcpkgs/rocr-runtime-devel
 create mode 100644 srcpkgs/rocr-runtime/patches/cmake.patch
 create mode 100644 srcpkgs/rocr-runtime/template

diff --git a/common/shlibs b/common/shlibs
index e22d4a7a8d1..68b07cb65bd 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3863,3 +3863,4 @@ libqtutilities.so.6 qtutilities-6.0.4_1
 libkdsoap.so.1.9.0 KDSoap-1.9.0_1
 libstoken.so.1 stoken-0.92_1
 libhsakmt.so.1 roct-thunk-interface-3.3.0_1
+libhsa-runtime64.so.1 rocr-runtime-3.3.0_1
diff --git a/srcpkgs/rocr-runtime-devel b/srcpkgs/rocr-runtime-devel
new file mode 120000
index 00000000000..be838f22d81
--- /dev/null
+++ b/srcpkgs/rocr-runtime-devel
@@ -0,0 +1 @@
+rocr-runtime
\ No newline at end of file
diff --git a/srcpkgs/rocr-runtime/patches/cmake.patch b/srcpkgs/rocr-runtime/patches/cmake.patch
new file mode 100644
index 00000000000..93b74cd2297
--- /dev/null
+++ b/srcpkgs/rocr-runtime/patches/cmake.patch
@@ -0,0 +1,27 @@
+--- src/CMakeLists.txt.old	2020-04-18 20:01:48.549636995 -0400
++++ src/CMakeLists.txt	2020-04-18 20:04:00.177179781 -0400
+@@ -108,8 +108,8 @@
+ ## ROCr build internal versioning
+ add_definitions ( -DROCR_BUILD_ID=${PACKAGE_VERSION_STRING} )
+ 
+-## Set RUNPATH - ../../lib covers use of the legacy symlink in /hsa/lib/
+-set(CMAKE_INSTALL_RPATH "$ORIGIN;$ORIGIN/../../lib;$ORIGIN/../../lib64;$ORIGIN/../lib64")
++## Set RUNPATH
++set(CMAKE_INSTALL_RPATH "$ORIGIN;$ORIGIN/../lib")
+ 
+ ## ------------------------- Linux Compiler and Linker options -------------------------
+ set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -fexceptions -fno-rtti -fvisibility=hidden -Wno-error=sign-compare -Wno-sign-compare -Wno-write-strings -Wno-conversion-null -fno-math-errno -fno-threadsafe-statics -fmerge-all-constants -fms-extensions -Wno-error=comment -Wno-comment -Wno-error=pointer-arith -Wno-pointer-arith -Wno-error=unused-variable -Wno-error=unused-function" )
+@@ -185,11 +185,8 @@
+ add_custom_target ( hsa_lib_link2 ALL WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMAND ${CMAKE_COMMAND} -E create_symlink ../hsa/lib/${CORE_RUNTIME_LIBRARY}.so.${SO_MAJOR} ${CORE_RUNTIME_LIBRARY}-link.so.${SO_MAJOR} )
+ 
+ ## Set install information
+-install ( TARGETS ${CORE_RUNTIME_TARGET} LIBRARY DESTINATION hsa/lib )
+-install ( DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/inc/ DESTINATION hsa/include/hsa )
+-install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/hsa_include_link DESTINATION include PERMISSIONS OWNER_WRITE OWNER_READ RENAME hsa )
+-install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/${CORE_RUNTIME_LIBRARY}-link.so DESTINATION lib PERMISSIONS OWNER_WRITE OWNER_READ RENAME ${CORE_RUNTIME_LIBRARY}.so )
+-install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/${CORE_RUNTIME_LIBRARY}-link.so.${SO_MAJOR} DESTINATION lib PERMISSIONS OWNER_WRITE OWNER_READ RENAME ${CORE_RUNTIME_LIBRARY}.so.${SO_MAJOR} )
++install ( TARGETS ${CORE_RUNTIME_TARGET} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} )
++install ( DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/inc/ DESTINATION include/hsa )
+ 
+ ## Packaging directives
+ set ( CPACK_GENERATOR "DEB;RPM" CACHE STRING "Package types to build")
diff --git a/srcpkgs/rocr-runtime/template b/srcpkgs/rocr-runtime/template
new file mode 100644
index 00000000000..5ee22140f1f
--- /dev/null
+++ b/srcpkgs/rocr-runtime/template
@@ -0,0 +1,30 @@
+# Template file for 'rocr-runtime'
+pkgname=rocr-runtime
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="ROCR-Runtime-rocm-${version}"
+build_wrksrc="src"
+build_style=cmake
+hostmakedepends="cmake pkg-config"
+makedepends="roct-thunk-interface-devel elfutils-devel"
+short_desc="Radeon Open Compute HSA Runtime"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute/ROCR-Runtime"
+distfiles="${homepage}/archive/rocm-${version}.tar.gz"
+checksum=fa2d2d1f8a61d8a6952d377cf288d78c61776c3c2a666f163cafc3aa19ab0b61
+nocross=yes
+
+post_install() {
+	vlicense ../LICENSE.txt
+}
+
+rocr-runtime-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove "usr/lib/*.so"
+	}
+}

From ea7422d5c26bd446f70a52e6e81188b9918b748d Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Mon, 13 Apr 2020 18:07:34 -0400
Subject: [PATCH 3/8] New package: rocm-llvm-3.3.0

---
 srcpkgs/rocm-llvm/template | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)
 create mode 100644 srcpkgs/rocm-llvm/template

diff --git a/srcpkgs/rocm-llvm/template b/srcpkgs/rocm-llvm/template
new file mode 100644
index 00000000000..26942e3ea46
--- /dev/null
+++ b/srcpkgs/rocm-llvm/template
@@ -0,0 +1,25 @@
+# Template file for 'rocm-llvm'
+pkgname=rocm-llvm
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="llvm-project-rocm-ocl-${version}"
+build_wrksrc=llvm
+build_style=cmake
+configure_args="-DCMAKE_INSTALL_PREFIX:PATH=/usr/lib/rocm-llvm
+	-DLLVM_ENABLE_PROJECTS='llvm;clang;lld' -DLLVM_TARGETS_TO_BUILD='AMDGPU'
+	-DLLVM_BUILD_DOCS=NO -DLLVM_ENABLE_OCAMLDOC=OFF
+	-DLLVM_ENABLE_SPHINX=NO -DLLVM_ENABLE_DOXYGEN=OFF
+	-DLLVM_INSTALL_UTILS=ON -DLLVM_VERSION_SUFFIX=roc -DOCAMLFIND=NO"
+hostmakedepends="cmake pkg-config python3"
+short_desc="Radeon Open Compute LLVM toolchain"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="Apache-2.0, NCSA, custom:LLVM-Exceptions"
+homepage="https://github.com/RadeonOpenCompute/llvm-project"
+distfiles="${homepage}/archive/rocm-ocl-${version}.tar.gz"
+checksum=a2bef7042e8e2f2cd8548cb246b88322e1c77188839983dcac8312d56f544dc8
+nocross=yes
+
+post_install() {
+	vlicense LICENSE.TXT
+}

From 0ee2359856f75dacd03c580552e93d58e9a91307 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Tue, 14 Apr 2020 10:25:31 -0400
Subject: [PATCH 4/8] New package: rocm-device-libs-3.3.0

---
 srcpkgs/rocm-device-libs/template | 37 +++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)
 create mode 100644 srcpkgs/rocm-device-libs/template

diff --git a/srcpkgs/rocm-device-libs/template b/srcpkgs/rocm-device-libs/template
new file mode 100644
index 00000000000..fcb4eb0d53e
--- /dev/null
+++ b/srcpkgs/rocm-device-libs/template
@@ -0,0 +1,37 @@
+# Template file for 'rocm-device-libs'
+pkgname=rocm-device-libs
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="ROCm-Device-Libs-rocm-ocl-${version}"
+build_style=cmake
+configure_args="-DLLVM_DIR:PATH=/usr/lib/rocm-llvm
+	-DCMAKE_INSTALL_LIBDIR:PATH=lib/rocm-device-libs"
+hostmakedepends="cmake rocm-llvm"
+short_desc="Radeon Open Compute device libraries"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute/ROCm-Device-Libs"
+distfiles="${homepage}/archive/rocm-ocl-${version}.tar.gz"
+checksum=706b08230790e08ca6a7a2fb7687d6131fd39a562148340e00fa37a6c06769c5
+nocross=yes
+
+pre_configure() {
+	# Put bytecodes in a lib/ subdirectory
+	vsed -i Packages.cmake -e 's@/lib/@/${CMAKE_INSTALL_LIBDIR}/@'
+	vsed -i OCL.cmake -e 's@DESTINATION lib$@DESTINATION ${CMAKE_INSTALL_LIBDIR}@'
+
+	# Build the prepare-builtins executable with native compiler
+	mkdir -p utils/build
+	cd utils/build
+	_prepare_builtins="$PWD/prepare-builtins/prepare-builtins"
+	cmake ${configure_args} ..
+	make ${makejobs}
+
+	# Add path to prepare-builtins for cmake
+	configure_args+=" -DPREPARE_BUILTINS='${_prepare_builtins}'"
+}
+
+post_install() {
+	vlicense LICENSE
+}

From b032bbe813e08f4e6e6a22077c577daab8680876 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Mon, 13 Apr 2020 18:30:00 -0400
Subject: [PATCH 5/8] New package: rocm-comgr-3.3.0

---
 common/shlibs               |  1 +
 srcpkgs/rocm-comgr-devel    |  1 +
 srcpkgs/rocm-comgr/template | 32 ++++++++++++++++++++++++++++++++
 3 files changed, 34 insertions(+)
 create mode 120000 srcpkgs/rocm-comgr-devel
 create mode 100644 srcpkgs/rocm-comgr/template

diff --git a/common/shlibs b/common/shlibs
index 68b07cb65bd..7d69d12b1e6 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3864,3 +3864,4 @@ libkdsoap.so.1.9.0 KDSoap-1.9.0_1
 libstoken.so.1 stoken-0.92_1
 libhsakmt.so.1 roct-thunk-interface-3.3.0_1
 libhsa-runtime64.so.1 rocr-runtime-3.3.0_1
+libamd_comgr.so.1 rocm-comgr-3.3.0_1
diff --git a/srcpkgs/rocm-comgr-devel b/srcpkgs/rocm-comgr-devel
new file mode 120000
index 00000000000..3f5ce255e07
--- /dev/null
+++ b/srcpkgs/rocm-comgr-devel
@@ -0,0 +1 @@
+rocm-comgr
\ No newline at end of file
diff --git a/srcpkgs/rocm-comgr/template b/srcpkgs/rocm-comgr/template
new file mode 100644
index 00000000000..c228bcd4d1f
--- /dev/null
+++ b/srcpkgs/rocm-comgr/template
@@ -0,0 +1,32 @@
+# Template file for 'rocm-comgr'
+pkgname=rocm-comgr
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="ROCm-CompilerSupport-rocm-${version}"
+build_wrksrc="lib/comgr"
+build_style=cmake
+configure_args="-DClang_DIR:PATH=/usr/lib/rocm-llvm/lib/cmake/clang"
+hostmakedepends="cmake pkg-config rocm-llvm"
+makedepends="rocm-device-libs"
+short_desc="Radeon Open Compute Code Object Manager"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="BSD-3-Clause"
+homepage="https://github.com/RadeonOpenCompute/ROCm-CompilerSupport"
+distfiles="${homepage}/archive/rocm-${version}.tar.gz"
+checksum=01e2524e0f28ecd6f46c9720f279207de935d826b0172158792aa3ec86af9ca7
+nocross=yes
+
+post_install() {
+	vlicense LICENSE.txt
+}
+
+rocm-comgr-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove "usr/lib/*.so"
+		vmove usr/lib/cmake
+	}
+}

From 625c567a70470aee7729966ac2533c5bc5cd59ac Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Fri, 17 Apr 2020 12:11:25 -0400
Subject: [PATCH 6/8] New package: rocminfo-3.3.0

---
 srcpkgs/rocminfo/template | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
 create mode 100644 srcpkgs/rocminfo/template

diff --git a/srcpkgs/rocminfo/template b/srcpkgs/rocminfo/template
new file mode 100644
index 00000000000..57d0640dd69
--- /dev/null
+++ b/srcpkgs/rocminfo/template
@@ -0,0 +1,22 @@
+# Template file for 'rocminfo'
+pkgname=rocminfo
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="rocminfo-rocm-${version}"
+build_style=cmake
+configure_args="-DROCM_DIR=/usr"
+hostmakedepends="cmake pkg-config"
+makedepends="rocr-runtime-devel"
+short_desc="Radeon Open Compute system information reporter"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute/rocminfo"
+distfiles="${homepage}/archive/rocm-${version}.tar.gz"
+checksum=e666f662c9e465aaabbbd0b109d87e017243cdf1a0898fabf5a90947bb3dbcd7
+nocross=yes
+python_version=3
+
+post_install() {
+	vlicense License.txt
+}

From f69ae7f2f4159216d382a145b53b0ead7783d5b2 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Sun, 19 Apr 2020 15:01:40 -0400
Subject: [PATCH 7/8] New package: rocm-bandwidth-test-3.3.0

---
 srcpkgs/rocm-bandwidth-test/template | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
 create mode 100644 srcpkgs/rocm-bandwidth-test/template

diff --git a/srcpkgs/rocm-bandwidth-test/template b/srcpkgs/rocm-bandwidth-test/template
new file mode 100644
index 00000000000..5c5058b693d
--- /dev/null
+++ b/srcpkgs/rocm-bandwidth-test/template
@@ -0,0 +1,20 @@
+# Template file for 'rocm-bandwidth-test'
+pkgname=rocm-bandwidth-test
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="rocm_bandwidth_test-rocm-${version}"
+build_style=cmake
+hostmakedepends="cmake"
+makedepends="rocr-runtime-devel roct-thunk-interface-devel"
+short_desc="Radeon Open Compute bandwidth test"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute/rocm_bandwidth_test"
+distfiles="${homepage}/archive/rocm-${version}.tar.gz"
+checksum=f5f914073018619dc91662d5bf630903dfa4db9136d603591917fdfb3c9164ce
+nocross=yes
+
+post_install() {
+	vlicense LICENSE.txt
+}

From 5e82f67d086f9c93673d244f604fc1a3b7a71c63 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Tue, 14 Apr 2020 10:25:54 -0400
Subject: [PATCH 8/8] New package: rocm-opencl-runtime-3.3.0 [ci skip]

---
 common/shlibs                                 |   2 +
 srcpkgs/rocm-opencl-runtime-clinfo            |   1 +
 srcpkgs/rocm-opencl-runtime-devel             |   1 +
 .../files/libelf-musl.patch                   | 688 ++++++++++++++++++
 .../files/runtime-musl.patch                  |  11 +
 srcpkgs/rocm-opencl-runtime/files/sys_queue.h | 574 +++++++++++++++
 .../rocm-opencl-runtime/patches/cmake.patch   | 126 ++++
 srcpkgs/rocm-opencl-runtime/template          |  82 +++
 8 files changed, 1485 insertions(+)
 create mode 120000 srcpkgs/rocm-opencl-runtime-clinfo
 create mode 120000 srcpkgs/rocm-opencl-runtime-devel
 create mode 100644 srcpkgs/rocm-opencl-runtime/files/libelf-musl.patch
 create mode 100644 srcpkgs/rocm-opencl-runtime/files/runtime-musl.patch
 create mode 100644 srcpkgs/rocm-opencl-runtime/files/sys_queue.h
 create mode 100644 srcpkgs/rocm-opencl-runtime/patches/cmake.patch
 create mode 100644 srcpkgs/rocm-opencl-runtime/template

diff --git a/common/shlibs b/common/shlibs
index 7d69d12b1e6..73a205152d0 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3865,3 +3865,5 @@ libstoken.so.1 stoken-0.92_1
 libhsakmt.so.1 roct-thunk-interface-3.3.0_1
 libhsa-runtime64.so.1 rocr-runtime-3.3.0_1
 libamd_comgr.so.1 rocm-comgr-3.3.0_1
+libOpenCL-ROCm.so.1 rocm-opencl-runtime-3.3.0_1
+libamdocl64.so rocm-opencl-runtime-3.3.0_1
diff --git a/srcpkgs/rocm-opencl-runtime-clinfo b/srcpkgs/rocm-opencl-runtime-clinfo
new file mode 120000
index 00000000000..b2cda7e229d
--- /dev/null
+++ b/srcpkgs/rocm-opencl-runtime-clinfo
@@ -0,0 +1 @@
+rocm-opencl-runtime
\ No newline at end of file
diff --git a/srcpkgs/rocm-opencl-runtime-devel b/srcpkgs/rocm-opencl-runtime-devel
new file mode 120000
index 00000000000..b2cda7e229d
--- /dev/null
+++ b/srcpkgs/rocm-opencl-runtime-devel
@@ -0,0 +1 @@
+rocm-opencl-runtime
\ No newline at end of file
diff --git a/srcpkgs/rocm-opencl-runtime/files/libelf-musl.patch b/srcpkgs/rocm-opencl-runtime/files/libelf-musl.patch
new file mode 100644
index 00000000000..a3705c259a9
--- /dev/null
+++ b/srcpkgs/rocm-opencl-runtime/files/libelf-musl.patch
@@ -0,0 +1,688 @@
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/_libelf.h compiler/lib/loaders/elf/utils/libelf/_libelf.h
+--- compiler/lib/loaders/elf/utils/libelf.orig/_libelf.h	2020-04-19 08:59:34.201386585 -0400
++++ compiler/lib/loaders/elf/utils/libelf/_libelf.h	2020-04-19 09:04:12.950433528 -0400
+@@ -30,7 +30,7 @@
+ #define	__LIBELF_H_
+ 
+ #include <limits.h>
+-#include <sys/queue.h>
++#include "sys_queue.h"
+ 
+ #include "_libelf_config.h"
+ 
+@@ -179,7 +179,9 @@
+  * Function Prototypes.
+  */
+ 
+-__BEGIN_DECLS
++#ifdef __cplusplus
++extern "C" {
++#endif
+ Elf_Data *_libelf_allocate_data(Elf_Scn *_s);
+ Elf	*_libelf_allocate_elf(Elf_Mem *mem);
+ Elf_Scn	*_libelf_allocate_scn(Elf *_e, size_t _ndx);
+@@ -213,6 +215,8 @@
+ Elf_Data *_libelf_xlate(Elf_Data *_d, const Elf_Data *_s,
+     unsigned int _encoding, int _elfclass, int _direction);
+ int	_libelf_xlate_shtype(uint32_t _sht);
+-__END_DECLS
++#ifdef __cplusplus
++}
++#endif
+ 
+ #endif	/* __LIBELF_H_ */
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_begin.c compiler/lib/loaders/elf/utils/libelf/elf_begin.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_begin.c	2020-04-19 08:59:34.201386585 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_begin.c	2020-04-19 09:01:04.313212042 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <sys/types.h>
+ #if !defined(WIN32)
+ #include <sys/errno.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_end.c compiler/lib/loaders/elf/utils/libelf/elf_end.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_end.c	2020-04-19 08:59:34.201386585 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_end.c	2020-04-19 09:01:14.895204681 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #if !defined(WIN32)
+ #include <sys/mman.h>
+ #endif
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_errmsg.c compiler/lib/loaders/elf/utils/libelf/elf_errmsg.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_errmsg.c	2020-04-19 08:59:34.201386585 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_errmsg.c	2020-04-19 09:01:16.753207065 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ #include <stdio.h>
+ #include <string.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_errno.c compiler/lib/loaders/elf/utils/libelf/elf_errno.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_errno.c	2020-04-19 08:59:34.201386585 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_errno.c	2020-04-19 09:01:18.669209528 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_fill.c compiler/lib/loaders/elf/utils/libelf/elf_fill.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_fill.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_fill.c	2020-04-19 09:01:21.109212667 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_flag.c compiler/lib/loaders/elf/utils/libelf/elf_flag.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_flag.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_flag.c	2020-04-19 09:01:23.376215579 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_getarhdr.c compiler/lib/loaders/elf/utils/libelf/elf_getarhdr.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_getarhdr.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_getarhdr.c	2020-04-19 09:01:25.414218197 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_getarsym.c compiler/lib/loaders/elf/utils/libelf/elf_getarsym.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_getarsym.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_getarsym.c	2020-04-19 09:01:27.575220978 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_getbase.c compiler/lib/loaders/elf/utils/libelf/elf_getbase.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_getbase.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_getbase.c	2020-04-19 09:01:29.963224043 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_getident.c compiler/lib/loaders/elf/utils/libelf/elf_getident.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_getident.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_getident.c	2020-04-19 09:01:31.912226551 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <ar.h>
+ #include <assert.h>
+ #include <libelf.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_hash.c compiler/lib/loaders/elf/utils/libelf/elf_hash.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_hash.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_hash.c	2020-04-19 09:01:33.877229069 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ #include "_libelf_config.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_kind.c compiler/lib/loaders/elf/utils/libelf/elf_kind.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_kind.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_kind.c	2020-04-19 09:01:35.940231721 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_memory.c compiler/lib/loaders/elf/utils/libelf/elf_memory.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_memory.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_memory.c	2020-04-19 09:01:38.171234596 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <ar.h>
+ #include <libelf.h>
+ #include <string.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_next.c compiler/lib/loaders/elf/utils/libelf/elf_next.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_next.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_next.c	2020-04-19 09:01:40.063237028 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <ar.h>
+ #include <assert.h>
+ #include <libelf.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_phnum.c compiler/lib/loaders/elf/utils/libelf/elf_phnum.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_phnum.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_phnum.c	2020-04-19 09:01:42.480240134 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <ar.h>
+ #include <libelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_rand.c compiler/lib/loaders/elf/utils/libelf/elf_rand.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_rand.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_rand.c	2020-04-19 09:01:45.061243452 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <ar.h>
+ #include <libelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_rawfile.c compiler/lib/loaders/elf/utils/libelf/elf_rawfile.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_rawfile.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_rawfile.c	2020-04-19 09:01:46.988245928 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_scn.c compiler/lib/loaders/elf/utils/libelf/elf_scn.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_scn.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_scn.c	2020-04-19 09:00:19.724298403 -0400
+@@ -24,8 +24,7 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-#include <sys/queue.h>
++#include "sys_queue.h"
+ 
+ #include <assert.h>
+ #include <errno.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_shnum.c compiler/lib/loaders/elf/utils/libelf/elf_shnum.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_shnum.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_shnum.c	2020-04-19 09:01:51.763252060 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <ar.h>
+ #include <libelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_shstrndx.c compiler/lib/loaders/elf/utils/libelf/elf_shstrndx.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_shstrndx.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_shstrndx.c	2020-04-19 09:01:53.532254340 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <ar.h>
+ #include <libelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_version.c compiler/lib/loaders/elf/utils/libelf/elf_version.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_version.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_version.c	2020-04-19 09:02:01.337264370 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf.h compiler/lib/loaders/elf/utils/libelf/gelf.h
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf.h	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf.h	2020-04-19 09:04:29.669455020 -0400
+@@ -29,8 +29,6 @@
+ #ifndef	_GELF_H_
+ #define	_GELF_H_
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ typedef Elf64_Addr	GElf_Addr;	/* Addresses */
+@@ -72,7 +70,9 @@
+ #define	GELF_ST_TYPE			ELF64_ST_TYPE
+ #define	GELF_ST_VISIBILITY		ELF64_ST_VISIBILITY
+ 
+-__BEGIN_DECLS
++#ifdef __cplusplus
++extern "C" {
++#endif
+ long		gelf_checksum(Elf *_elf);
+ size_t		gelf_fsize(Elf *_elf, Elf_Type _type, size_t _count,
+ 			unsigned int _version);
+@@ -109,6 +109,8 @@
+ int		gelf_update_move(Elf_Data *_dst, int _index, GElf_Move *_src);
+ int		gelf_update_syminfo(Elf_Data *_dst, int _index, GElf_Syminfo *_src);
+ #endif
+-__END_DECLS
++#ifdef __cplusplus
++}
++#endif
+ 
+ #endif	/* _GELF_H_ */
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_cap.c compiler/lib/loaders/elf/utils/libelf/gelf_cap.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_cap.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_cap.c	2020-04-19 09:02:05.429269632 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_checksum.c compiler/lib/loaders/elf/utils/libelf/gelf_checksum.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_checksum.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_checksum.c	2020-04-19 09:02:08.192273183 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <gelf.h>
+ #include <libelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_dyn.c compiler/lib/loaders/elf/utils/libelf/gelf_dyn.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_dyn.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_dyn.c	2020-04-19 09:02:10.020275525 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_ehdr.c compiler/lib/loaders/elf/utils/libelf/gelf_ehdr.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_ehdr.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_ehdr.c	2020-04-19 09:02:11.882277926 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ #include <libelf.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_fsize.c compiler/lib/loaders/elf/utils/libelf/gelf_fsize.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_fsize.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_fsize.c	2020-04-19 09:02:14.139280827 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <gelf.h>
+ #include <libelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_getclass.c compiler/lib/loaders/elf/utils/libelf/gelf_getclass.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_getclass.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_getclass.c	2020-04-19 09:02:17.269284848 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <gelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_move.c compiler/lib/loaders/elf/utils/libelf/gelf_move.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_move.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_move.c	2020-04-19 09:02:18.974287034 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_phdr.c compiler/lib/loaders/elf/utils/libelf/gelf_phdr.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_phdr.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_phdr.c	2020-04-19 09:02:20.676289227 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <gelf.h>
+ #include <libelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_rel.c compiler/lib/loaders/elf/utils/libelf/gelf_rel.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_rel.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_rel.c	2020-04-19 09:02:23.177292435 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_rela.c compiler/lib/loaders/elf/utils/libelf/gelf_rela.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_rela.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_rela.c	2020-04-19 09:02:25.246295100 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_shdr.c compiler/lib/loaders/elf/utils/libelf/gelf_shdr.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_shdr.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_shdr.c	2020-04-19 09:02:28.325299060 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ #include <libelf.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_sym.c compiler/lib/loaders/elf/utils/libelf/gelf_sym.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_sym.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_sym.c	2020-04-19 09:02:30.113301356 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_syminfo.c compiler/lib/loaders/elf/utils/libelf/gelf_syminfo.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_syminfo.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_syminfo.c	2020-04-19 09:02:31.906303662 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_symshndx.c compiler/lib/loaders/elf/utils/libelf/gelf_symshndx.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_symshndx.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_symshndx.c	2020-04-19 09:02:33.626305873 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_xlate.c compiler/lib/loaders/elf/utils/libelf/gelf_xlate.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_xlate.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_xlate.c	2020-04-19 09:02:35.921308822 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <gelf.h>
+ #include <libelf.h>
+ #include <string.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf.h compiler/lib/loaders/elf/utils/libelf/libelf.h
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf.h	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf.h	2020-04-19 09:04:38.760466706 -0400
+@@ -30,7 +30,7 @@
+ #define	_LIBELF_H_
+ 
+ #include <sys/types.h>
+-#include <sys/queue.h>
++#include "sys_queue.h"
+ #include <elfdefinitions.h>
+ #ifndef EM_HSAIL
+ #define EM_HSAIL 0xAF5A
+@@ -187,7 +187,9 @@
+ #define	ELF_F_ARCHIVE	   0x100U /* archive creation */
+ #define	ELF_F_ARCHIVE_SYSV 0x200U /* SYSV style archive */
+ 
+-__BEGIN_DECLS
++#ifdef __cplusplus
++extern "C" {
++#endif
+ Elf		*elf_begin(int _fd, Elf_Cmd _cmd, Elf *_elf, Elf_Mem *_mem);
+ int		elf_cntl(Elf *_elf, Elf_Cmd _cmd);
+ int		elf_end(Elf *_elf);
+@@ -257,6 +259,8 @@
+ 			unsigned int _enc);
+ Elf_Data	*elf64_xlatetom(Elf_Data *_dst, const Elf_Data *_src,
+ 			unsigned int _enc);
+-__END_DECLS
++#ifdef __cplusplus
++}
++#endif
+ 
+ #endif	/* _LIBELF_H_ */
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_align.c compiler/lib/loaders/elf/utils/libelf/libelf_align.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_align.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_align.c	2020-04-19 09:02:40.660314911 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <sys/types.h>
+ 
+ #include <libelf.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_allocate.c compiler/lib/loaders/elf/utils/libelf/libelf_allocate.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_allocate.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_allocate.c	2020-04-19 09:02:43.079318019 -0400
+@@ -28,8 +28,6 @@
+  * Internal APIs
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #if !defined(WIN32)
+ #include <sys/errno.h>
+ #endif
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_ar.c compiler/lib/loaders/elf/utils/libelf/libelf_ar.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_ar.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_ar.c	2020-04-19 09:02:44.763320187 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <ctype.h>
+ #include <libelf.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_ar_util.c compiler/lib/loaders/elf/utils/libelf/libelf_ar_util.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_ar_util.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_ar_util.c	2020-04-19 09:02:46.461322369 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <libelf.h>
+ #include <stdlib.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_checksum.c compiler/lib/loaders/elf/utils/libelf/libelf_checksum.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_checksum.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_checksum.c	2020-04-19 09:02:48.645325173 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <gelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_convert.c compiler/lib/loaders/elf/utils/libelf/libelf_convert.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_convert.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_convert.c	2020-04-19 09:02:50.883328053 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <libelf.h>
+ #include <string.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_data.c compiler/lib/loaders/elf/utils/libelf/libelf_data.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_data.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_data.c	2020-04-19 09:02:52.951330708 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_ehdr.c compiler/lib/loaders/elf/utils/libelf/libelf_ehdr.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_ehdr.c	2020-04-19 08:59:34.204386579 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_ehdr.c	2020-04-19 09:02:55.176333563 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ #include <libelf.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_extended.c compiler/lib/loaders/elf/utils/libelf/libelf_extended.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_extended.c	2020-04-19 08:59:34.204386579 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_extended.c	2020-04-19 09:02:57.932337110 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <libelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_msize.c compiler/lib/loaders/elf/utils/libelf/libelf_msize.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_msize.c	2020-04-19 08:59:34.204386579 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_msize.c	2020-04-19 09:03:02.201342598 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <libelf.h>
+ #include <string.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_phdr.c compiler/lib/loaders/elf/utils/libelf/libelf_phdr.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_phdr.c	2020-04-19 08:59:34.204386579 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_phdr.c	2020-04-19 09:03:04.194345160 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ #include <libelf.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_shdr.c compiler/lib/loaders/elf/utils/libelf/libelf_shdr.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_shdr.c	2020-04-19 08:59:34.204386579 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_shdr.c	2020-04-19 09:03:05.795347218 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <gelf.h>
+ #include <libelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_xlate.c compiler/lib/loaders/elf/utils/libelf/libelf_xlate.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_xlate.c	2020-04-19 08:59:34.204386579 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_xlate.c	2020-04-19 09:03:09.472351944 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <libelf.h>
+ 
diff --git a/srcpkgs/rocm-opencl-runtime/files/runtime-musl.patch b/srcpkgs/rocm-opencl-runtime/files/runtime-musl.patch
new file mode 100644
index 00000000000..ea18e90e09c
--- /dev/null
+++ b/srcpkgs/rocm-opencl-runtime/files/runtime-musl.patch
@@ -0,0 +1,11 @@
+--- runtime/os/os_posix.cpp.orig	2020-04-19 09:13:51.701982901 -0400
++++ runtime/os/os_posix.cpp	2020-04-19 09:14:04.156947422 -0400
+@@ -44,6 +44,8 @@
+ #include <algorithm>
+ #include <mutex>
+ 
++#include <libgen.h> // for basename
++
+ 
+ namespace amd {
+ 
diff --git a/srcpkgs/rocm-opencl-runtime/files/sys_queue.h b/srcpkgs/rocm-opencl-runtime/files/sys_queue.h
new file mode 100644
index 00000000000..daf4553d33e
--- /dev/null
+++ b/srcpkgs/rocm-opencl-runtime/files/sys_queue.h
@@ -0,0 +1,574 @@
+/*
+ * Copyright (c) 1991, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *	@(#)queue.h	8.5 (Berkeley) 8/20/94
+ */
+
+#ifndef	_SYS_QUEUE_H_
+#define	_SYS_QUEUE_H_
+
+/*
+ * This file defines five types of data structures: singly-linked lists,
+ * lists, simple queues, tail queues, and circular queues.
+ *
+ * A singly-linked list is headed by a single forward pointer. The
+ * elements are singly linked for minimum space and pointer manipulation
+ * overhead at the expense of O(n) removal for arbitrary elements. New
+ * elements can be added to the list after an existing element or at the
+ * head of the list.  Elements being removed from the head of the list
+ * should use the explicit macro for this purpose for optimum
+ * efficiency. A singly-linked list may only be traversed in the forward
+ * direction.  Singly-linked lists are ideal for applications with large
+ * datasets and few or no removals or for implementing a LIFO queue.
+ *
+ * A list is headed by a single forward pointer (or an array of forward
+ * pointers for a hash table header). The elements are doubly linked
+ * so that an arbitrary element can be removed without a need to
+ * traverse the list. New elements can be added to the list before
+ * or after an existing element or at the head of the list. A list
+ * may only be traversed in the forward direction.
+ *
+ * A simple queue is headed by a pair of pointers, one the head of the
+ * list and the other to the tail of the list. The elements are singly
+ * linked to save space, so elements can only be removed from the
+ * head of the list. New elements can be added to the list after
+ * an existing element, at the head of the list, or at the end of the
+ * list. A simple queue may only be traversed in the forward direction.
+ *
+ * A tail queue is headed by a pair of pointers, one to the head of the
+ * list and the other to the tail of the list. The elements are doubly
+ * linked so that an arbitrary element can be removed without a need to
+ * traverse the list. New elements can be added to the list before or
+ * after an existing element, at the head of the list, or at the end of
+ * the list. A tail queue may be traversed in either direction.
+ *
+ * A circle queue is headed by a pair of pointers, one to the head of the
+ * list and the other to the tail of the list. The elements are doubly
+ * linked so that an arbitrary element can be removed without a need to
+ * traverse the list. New elements can be added to the list before or after
+ * an existing element, at the head of the list, or at the end of the list.
+ * A circle queue may be traversed in either direction, but has a more
+ * complex end of list detection.
+ *
+ * For details on the use of these macros, see the queue(3) manual page.
+ */
+
+/*
+ * List definitions.
+ */
+#define	LIST_HEAD(name, type)						\
+struct name {								\
+	struct type *lh_first;	/* first element */			\
+}
+
+#define	LIST_HEAD_INITIALIZER(head)					\
+	{ NULL }
+
+#define	LIST_ENTRY(type)						\
+struct {								\
+	struct type *le_next;	/* next element */			\
+	struct type **le_prev;	/* address of previous next element */	\
+}
+
+/*
+ * List functions.
+ */
+#define	LIST_INIT(head) do {						\
+	(head)->lh_first = NULL;					\
+} while (/*CONSTCOND*/0)
+
+#define	LIST_INSERT_AFTER(listelm, elm, field) do {			\
+	if (((elm)->field.le_next = (listelm)->field.le_next) != NULL)	\
+		(listelm)->field.le_next->field.le_prev =		\
+		    &(elm)->field.le_next;				\
+	(listelm)->field.le_next = (elm);				\
+	(elm)->field.le_prev = &(listelm)->field.le_next;		\
+} while (/*CONSTCOND*/0)
+
+#define	LIST_INSERT_BEFORE(listelm, elm, field) do {			\
+	(elm)->field.le_prev = (listelm)->field.le_prev;		\
+	(elm)->field.le_next = (listelm);				\
+	*(listelm)->field.le_prev = (elm);				\
+	(listelm)->field.le_prev = &(elm)->field.le_next;		\
+} while (/*CONSTCOND*/0)
+
+#define	LIST_INSERT_HEAD(head, elm, field) do {				\
+	if (((elm)->field.le_next = (head)->lh_first) != NULL)		\
+		(head)->lh_first->field.le_prev = &(elm)->field.le_next;\
+	(head)->lh_first = (elm);					\
+	(elm)->field.le_prev = &(head)->lh_first;			\
+} while (/*CONSTCOND*/0)
+
+#define	LIST_REMOVE(elm, field) do {					\
+	if ((elm)->field.le_next != NULL)				\
+		(elm)->field.le_next->field.le_prev = 			\
+		    (elm)->field.le_prev;				\
+	*(elm)->field.le_prev = (elm)->field.le_next;			\
+} while (/*CONSTCOND*/0)
+
+#define	LIST_FOREACH(var, head, field)					\
+	for ((var) = ((head)->lh_first);				\
+		(var);							\
+		(var) = ((var)->field.le_next))
+
+/*
+ * List access methods.
+ */
+#define	LIST_EMPTY(head)		((head)->lh_first == NULL)
+#define	LIST_FIRST(head)		((head)->lh_first)
+#define	LIST_NEXT(elm, field)		((elm)->field.le_next)
+
+
+/*
+ * Singly-linked List definitions.
+ */
+#define	SLIST_HEAD(name, type)						\
+struct name {								\
+	struct type *slh_first;	/* first element */			\
+}
+
+#define	SLIST_HEAD_INITIALIZER(head)					\
+	{ NULL }
+
+#define	SLIST_ENTRY(type)						\
+struct {								\
+	struct type *sle_next;	/* next element */			\
+}
+
+/*
+ * Singly-linked List functions.
+ */
+#define	SLIST_INIT(head) do {						\
+	(head)->slh_first = NULL;					\
+} while (/*CONSTCOND*/0)
+
+#define	SLIST_INSERT_AFTER(slistelm, elm, field) do {			\
+	(elm)->field.sle_next = (slistelm)->field.sle_next;		\
+	(slistelm)->field.sle_next = (elm);				\
+} while (/*CONSTCOND*/0)
+
+#define	SLIST_INSERT_HEAD(head, elm, field) do {			\
+	(elm)->field.sle_next = (head)->slh_first;			\
+	(head)->slh_first = (elm);					\
+} while (/*CONSTCOND*/0)
+
+#define	SLIST_REMOVE_HEAD(head, field) do {				\
+	(head)->slh_first = (head)->slh_first->field.sle_next;		\
+} while (/*CONSTCOND*/0)
+
+#define	SLIST_REMOVE(head, elm, type, field) do {			\
+	if ((head)->slh_first == (elm)) {				\
+		SLIST_REMOVE_HEAD((head), field);			\
+	}								\
+	else {								\
+		struct type *curelm = (head)->slh_first;		\
+		while(curelm->field.sle_next != (elm))			\
+			curelm = curelm->field.sle_next;		\
+		curelm->field.sle_next =				\
+		    curelm->field.sle_next->field.sle_next;		\
+	}								\
+} while (/*CONSTCOND*/0)
+
+#define	SLIST_FOREACH(var, head, field)					\
+	for((var) = (head)->slh_first; (var); (var) = (var)->field.sle_next)
+
+/*
+ * Singly-linked List access methods.
+ */
+#define	SLIST_EMPTY(head)	((head)->slh_first == NULL)
+#define	SLIST_FIRST(head)	((head)->slh_first)
+#define	SLIST_NEXT(elm, field)	((elm)->field.sle_next)
+
+
+/*
+ * Singly-linked Tail queue declarations.
+ */
+#define	STAILQ_HEAD(name, type)					\
+struct name {								\
+	struct type *stqh_first;	/* first element */			\
+	struct type **stqh_last;	/* addr of last next element */		\
+}
+
+#define	STAILQ_HEAD_INITIALIZER(head)					\
+	{ NULL, &(head).stqh_first }
+
+#define	STAILQ_ENTRY(type)						\
+struct {								\
+	struct type *stqe_next;	/* next element */			\
+}
+
+/*
+ * Singly-linked Tail queue functions.
+ */
+#define	STAILQ_INIT(head) do {						\
+	(head)->stqh_first = NULL;					\
+	(head)->stqh_last = &(head)->stqh_first;				\
+} while (/*CONSTCOND*/0)
+
+#define	STAILQ_INSERT_HEAD(head, elm, field) do {			\
+	if (((elm)->field.stqe_next = (head)->stqh_first) == NULL)	\
+		(head)->stqh_last = &(elm)->field.stqe_next;		\
+	(head)->stqh_first = (elm);					\
+} while (/*CONSTCOND*/0)
+
+#define	STAILQ_INSERT_TAIL(head, elm, field) do {			\
+	(elm)->field.stqe_next = NULL;					\
+	*(head)->stqh_last = (elm);					\
+	(head)->stqh_last = &(elm)->field.stqe_next;			\
+} while (/*CONSTCOND*/0)
+
+#define	STAILQ_INSERT_AFTER(head, listelm, elm, field) do {		\
+	if (((elm)->field.stqe_next = (listelm)->field.stqe_next) == NULL)\
+		(head)->stqh_last = &(elm)->field.stqe_next;		\
+	(listelm)->field.stqe_next = (elm);				\
+} while (/*CONSTCOND*/0)
+
+#define	STAILQ_REMOVE_HEAD(head, field) do {				\
+	if (((head)->stqh_first = (head)->stqh_first->field.stqe_next) == NULL) \
+		(head)->stqh_last = &(head)->stqh_first;			\
+} while (/*CONSTCOND*/0)
+
+#define	STAILQ_REMOVE(head, elm, type, field) do {			\
+	if ((head)->stqh_first == (elm)) {				\
+		STAILQ_REMOVE_HEAD((head), field);			\
+	} else {							\
+		struct type *curelm = (head)->stqh_first;		\
+		while (curelm->field.stqe_next != (elm))			\
+			curelm = curelm->field.stqe_next;		\
+		if ((curelm->field.stqe_next =				\
+			curelm->field.stqe_next->field.stqe_next) == NULL) \
+			    (head)->stqh_last = &(curelm)->field.stqe_next; \
+	}								\
+} while (/*CONSTCOND*/0)
+
+#define	STAILQ_FOREACH(var, head, field)				\
+	for ((var) = ((head)->stqh_first);				\
+		(var);							\
+		(var) = ((var)->field.stqe_next))
+
+#define	STAILQ_CONCAT(head1, head2) do {				\
+	if (!STAILQ_EMPTY((head2))) {					\
+		*(head1)->stqh_last = (head2)->stqh_first;		\
+		(head1)->stqh_last = (head2)->stqh_last;		\
+		STAILQ_INIT((head2));					\
+	}								\
+} while (/*CONSTCOND*/0)
+
+/*
+ * Singly-linked Tail queue access methods.
+ */
+#define	STAILQ_EMPTY(head)	((head)->stqh_first == NULL)
+#define	STAILQ_FIRST(head)	((head)->stqh_first)
+#define	STAILQ_NEXT(elm, field)	((elm)->field.stqe_next)
+
+
+/*
+ * Simple queue definitions.
+ */
+#define	SIMPLEQ_HEAD(name, type)					\
+struct name {								\
+	struct type *sqh_first;	/* first element */			\
+	struct type **sqh_last;	/* addr of last next element */		\
+}
+
+#define	SIMPLEQ_HEAD_INITIALIZER(head)					\
+	{ NULL, &(head).sqh_first }
+
+#define	SIMPLEQ_ENTRY(type)						\
+struct {								\
+	struct type *sqe_next;	/* next element */			\
+}
+
+/*
+ * Simple queue functions.
+ */
+#define	SIMPLEQ_INIT(head) do {						\
+	(head)->sqh_first = NULL;					\
+	(head)->sqh_last = &(head)->sqh_first;				\
+} while (/*CONSTCOND*/0)
+
+#define	SIMPLEQ_INSERT_HEAD(head, elm, field) do {			\
+	if (((elm)->field.sqe_next = (head)->sqh_first) == NULL)	\
+		(head)->sqh_last = &(elm)->field.sqe_next;		\
+	(head)->sqh_first = (elm);					\
+} while (/*CONSTCOND*/0)
+
+#define	SIMPLEQ_INSERT_TAIL(head, elm, field) do {			\
+	(elm)->field.sqe_next = NULL;					\
+	*(head)->sqh_last = (elm);					\
+	(head)->sqh_last = &(elm)->field.sqe_next;			\
+} while (/*CONSTCOND*/0)
+
+#define	SIMPLEQ_INSERT_AFTER(head, listelm, elm, field) do {		\
+	if (((elm)->field.sqe_next = (listelm)->field.sqe_next) == NULL)\
+		(head)->sqh_last = &(elm)->field.sqe_next;		\
+	(listelm)->field.sqe_next = (elm);				\
+} while (/*CONSTCOND*/0)
+
+#define	SIMPLEQ_REMOVE_HEAD(head, field) do {				\
+	if (((head)->sqh_first = (head)->sqh_first->field.sqe_next) == NULL) \
+		(head)->sqh_last = &(head)->sqh_first;			\
+} while (/*CONSTCOND*/0)
+
+#define	SIMPLEQ_REMOVE(head, elm, type, field) do {			\
+	if ((head)->sqh_first == (elm)) {				\
+		SIMPLEQ_REMOVE_HEAD((head), field);			\
+	} else {							\
+		struct type *curelm = (head)->sqh_first;		\
+		while (curelm->field.sqe_next != (elm))			\
+			curelm = curelm->field.sqe_next;		\
+		if ((curelm->field.sqe_next =				\
+			curelm->field.sqe_next->field.sqe_next) == NULL) \
+			    (head)->sqh_last = &(curelm)->field.sqe_next; \
+	}								\
+} while (/*CONSTCOND*/0)
+
+#define	SIMPLEQ_FOREACH(var, head, field)				\
+	for ((var) = ((head)->sqh_first);				\
+		(var);							\
+		(var) = ((var)->field.sqe_next))
+
+/*
+ * Simple queue access methods.
+ */
+#define	SIMPLEQ_EMPTY(head)		((head)->sqh_first == NULL)
+#define	SIMPLEQ_FIRST(head)		((head)->sqh_first)
+#define	SIMPLEQ_NEXT(elm, field)	((elm)->field.sqe_next)
+
+
+/*
+ * Tail queue definitions.
+ */
+#define	_TAILQ_HEAD(name, type, qual)					\
+struct name {								\
+	qual type *tqh_first;		/* first element */		\
+	qual type *qual *tqh_last;	/* addr of last next element */	\
+}
+#define TAILQ_HEAD(name, type)	_TAILQ_HEAD(name, struct type,)
+
+#define	TAILQ_HEAD_INITIALIZER(head)					\
+	{ NULL, &(head).tqh_first }
+
+#define	_TAILQ_ENTRY(type, qual)					\
+struct {								\
+	qual type *tqe_next;		/* next element */		\
+	qual type *qual *tqe_prev;	/* address of previous next element */\
+}
+#define TAILQ_ENTRY(type)	_TAILQ_ENTRY(struct type,)
+
+/*
+ * Tail queue functions.
+ */
+#define	TAILQ_INIT(head) do {						\
+	(head)->tqh_first = NULL;					\
+	(head)->tqh_last = &(head)->tqh_first;				\
+} while (/*CONSTCOND*/0)
+
+#define	TAILQ_INSERT_HEAD(head, elm, field) do {			\
+	if (((elm)->field.tqe_next = (head)->tqh_first) != NULL)	\
+		(head)->tqh_first->field.tqe_prev =			\
+		    &(elm)->field.tqe_next;				\
+	else								\
+		(head)->tqh_last = &(elm)->field.tqe_next;		\
+	(head)->tqh_first = (elm);					\
+	(elm)->field.tqe_prev = &(head)->tqh_first;			\
+} while (/*CONSTCOND*/0)
+
+#define	TAILQ_INSERT_TAIL(head, elm, field) do {			\
+	(elm)->field.tqe_next = NULL;					\
+	(elm)->field.tqe_prev = (head)->tqh_last;			\
+	*(head)->tqh_last = (elm);					\
+	(head)->tqh_last = &(elm)->field.tqe_next;			\
+} while (/*CONSTCOND*/0)
+
+#define	TAILQ_INSERT_AFTER(head, listelm, elm, field) do {		\
+	if (((elm)->field.tqe_next = (listelm)->field.tqe_next) != NULL)\
+		(elm)->field.tqe_next->field.tqe_prev = 		\
+		    &(elm)->field.tqe_next;				\
+	else								\
+		(head)->tqh_last = &(elm)->field.tqe_next;		\
+	(listelm)->field.tqe_next = (elm);				\
+	(elm)->field.tqe_prev = &(listelm)->field.tqe_next;		\
+} while (/*CONSTCOND*/0)
+
+#define	TAILQ_INSERT_BEFORE(listelm, elm, field) do {			\
+	(elm)->field.tqe_prev = (listelm)->field.tqe_prev;		\
+	(elm)->field.tqe_next = (listelm);				\
+	*(listelm)->field.tqe_prev = (elm);				\
+	(listelm)->field.tqe_prev = &(elm)->field.tqe_next;		\
+} while (/*CONSTCOND*/0)
+
+#define	TAILQ_REMOVE(head, elm, field) do {				\
+	if (((elm)->field.tqe_next) != NULL)				\
+		(elm)->field.tqe_next->field.tqe_prev = 		\
+		    (elm)->field.tqe_prev;				\
+	else								\
+		(head)->tqh_last = (elm)->field.tqe_prev;		\
+	*(elm)->field.tqe_prev = (elm)->field.tqe_next;			\
+} while (/*CONSTCOND*/0)
+
+#define	TAILQ_FOREACH(var, head, field)					\
+	for ((var) = ((head)->tqh_first);				\
+		(var);							\
+		(var) = ((var)->field.tqe_next))
+
+#define	TAILQ_FOREACH_REVERSE(var, head, headname, field)		\
+	for ((var) = (*(((struct headname *)((head)->tqh_last))->tqh_last));	\
+		(var);							\
+		(var) = (*(((struct headname *)((var)->field.tqe_prev))->tqh_last)))
+
+#define	TAILQ_CONCAT(head1, head2, field) do {				\
+	if (!TAILQ_EMPTY(head2)) {					\
+		*(head1)->tqh_last = (head2)->tqh_first;		\
+		(head2)->tqh_first->field.tqe_prev = (head1)->tqh_last;	\
+		(head1)->tqh_last = (head2)->tqh_last;			\
+		TAILQ_INIT((head2));					\
+	}								\
+} while (/*CONSTCOND*/0)
+
+/*
+ * Tail queue access methods.
+ */
+#define	TAILQ_EMPTY(head)		((head)->tqh_first == NULL)
+#define	TAILQ_FIRST(head)		((head)->tqh_first)
+#define	TAILQ_NEXT(elm, field)		((elm)->field.tqe_next)
+
+#define	TAILQ_LAST(head, headname) \
+	(*(((struct headname *)((head)->tqh_last))->tqh_last))
+#define	TAILQ_PREV(elm, headname, field) \
+	(*(((struct headname *)((elm)->field.tqe_prev))->tqh_last))
+
+
+/*
+ * Circular queue definitions.
+ */
+#define	CIRCLEQ_HEAD(name, type)					\
+struct name {								\
+	struct type *cqh_first;		/* first element */		\
+	struct type *cqh_last;		/* last element */		\
+}
+
+#define	CIRCLEQ_HEAD_INITIALIZER(head)					\
+	{ (void *)&head, (void *)&head }
+
+#define	CIRCLEQ_ENTRY(type)						\
+struct {								\
+	struct type *cqe_next;		/* next element */		\
+	struct type *cqe_prev;		/* previous element */		\
+}
+
+/*
+ * Circular queue functions.
+ */
+#define	CIRCLEQ_INIT(head) do {						\
+	(head)->cqh_first = (void *)(head);				\
+	(head)->cqh_last = (void *)(head);				\
+} while (/*CONSTCOND*/0)
+
+#define	CIRCLEQ_INSERT_AFTER(head, listelm, elm, field) do {		\
+	(elm)->field.cqe_next = (listelm)->field.cqe_next;		\
+	(elm)->field.cqe_prev = (listelm);				\
+	if ((listelm)->field.cqe_next == (void *)(head))		\
+		(head)->cqh_last = (elm);				\
+	else								\
+		(listelm)->field.cqe_next->field.cqe_prev = (elm);	\
+	(listelm)->field.cqe_next = (elm);				\
+} while (/*CONSTCOND*/0)
+
+#define	CIRCLEQ_INSERT_BEFORE(head, listelm, elm, field) do {		\
+	(elm)->field.cqe_next = (listelm);				\
+	(elm)->field.cqe_prev = (listelm)->field.cqe_prev;		\
+	if ((listelm)->field.cqe_prev == (void *)(head))		\
+		(head)->cqh_first = (elm);				\
+	else								\
+		(listelm)->field.cqe_prev->field.cqe_next = (elm);	\
+	(listelm)->field.cqe_prev = (elm);				\
+} while (/*CONSTCOND*/0)
+
+#define	CIRCLEQ_INSERT_HEAD(head, elm, field) do {			\
+	(elm)->field.cqe_next = (head)->cqh_first;			\
+	(elm)->field.cqe_prev = (void *)(head);				\
+	if ((head)->cqh_last == (void *)(head))				\
+		(head)->cqh_last = (elm);				\
+	else								\
+		(head)->cqh_first->field.cqe_prev = (elm);		\
+	(head)->cqh_first = (elm);					\
+} while (/*CONSTCOND*/0)
+
+#define	CIRCLEQ_INSERT_TAIL(head, elm, field) do {			\
+	(elm)->field.cqe_next = (void *)(head);				\
+	(elm)->field.cqe_prev = (head)->cqh_last;			\
+	if ((head)->cqh_first == (void *)(head))			\
+		(head)->cqh_first = (elm);				\
+	else								\
+		(head)->cqh_last->field.cqe_next = (elm);		\
+	(head)->cqh_last = (elm);					\
+} while (/*CONSTCOND*/0)
+
+#define	CIRCLEQ_REMOVE(head, elm, field) do {				\
+	if ((elm)->field.cqe_next == (void *)(head))			\
+		(head)->cqh_last = (elm)->field.cqe_prev;		\
+	else								\
+		(elm)->field.cqe_next->field.cqe_prev =			\
+		    (elm)->field.cqe_prev;				\
+	if ((elm)->field.cqe_prev == (void *)(head))			\
+		(head)->cqh_first = (elm)->field.cqe_next;		\
+	else								\
+		(elm)->field.cqe_prev->field.cqe_next =			\
+		    (elm)->field.cqe_next;				\
+} while (/*CONSTCOND*/0)
+
+#define	CIRCLEQ_FOREACH(var, head, field)				\
+	for ((var) = ((head)->cqh_first);				\
+		(var) != (const void *)(head);				\
+		(var) = ((var)->field.cqe_next))
+
+#define	CIRCLEQ_FOREACH_REVERSE(var, head, field)			\
+	for ((var) = ((head)->cqh_last);				\
+		(var) != (const void *)(head);				\
+		(var) = ((var)->field.cqe_prev))
+
+/*
+ * Circular queue access methods.
+ */
+#define	CIRCLEQ_EMPTY(head)		((head)->cqh_first == (void *)(head))
+#define	CIRCLEQ_FIRST(head)		((head)->cqh_first)
+#define	CIRCLEQ_LAST(head)		((head)->cqh_last)
+#define	CIRCLEQ_NEXT(elm, field)	((elm)->field.cqe_next)
+#define	CIRCLEQ_PREV(elm, field)	((elm)->field.cqe_prev)
+
+#define CIRCLEQ_LOOP_NEXT(head, elm, field)				\
+	(((elm)->field.cqe_next == (void *)(head))			\
+	    ? ((head)->cqh_first)					\
+	    : (elm->field.cqe_next))
+#define CIRCLEQ_LOOP_PREV(head, elm, field)				\
+	(((elm)->field.cqe_prev == (void *)(head))			\
+	    ? ((head)->cqh_last)					\
+	    : (elm->field.cqe_prev))
+
+#endif	/* sys/queue.h */
diff --git a/srcpkgs/rocm-opencl-runtime/patches/cmake.patch b/srcpkgs/rocm-opencl-runtime/patches/cmake.patch
new file mode 100644
index 00000000000..2c96b99d45a
--- /dev/null
+++ b/srcpkgs/rocm-opencl-runtime/patches/cmake.patch
@@ -0,0 +1,126 @@
+--- OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/CMakeLists.txt	2019-09-10 11:53:28.000000000 -0400
++++ OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/CMakeLists.txt	2020-04-16 20:16:13.481180757 -0400
+@@ -73,11 +73,11 @@
+ 
+ set (OPENCL_ICD_LOADER_HEADERS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/inc CACHE PATH "Path to OpenCL Headers")
+ 
+-add_library (OpenCL ${OPENCL_ICD_LOADER_SOURCES})
+-set_target_properties (OpenCL PROPERTIES VERSION "1.2" SOVERSION "1")
++add_library (OpenCL-ROCm ${OPENCL_ICD_LOADER_SOURCES})
++set_target_properties (OpenCL-ROCm PROPERTIES VERSION "1.2" SOVERSION "1")
+ 
+ if (WIN32)
+-    target_link_libraries (OpenCL cfgmgr32.lib)
++    target_link_libraries (OpenCL-ROCm cfgmgr32.lib)
+ 
+     option (OPENCL_ICD_LOADER_REQUIRE_WDK "Build with D3DKMT support, which requires the Windows WDK." ON)
+     if (OPENCL_ICD_LOADER_REQUIRE_WDK)
+@@ -92,10 +92,10 @@
+             get_filename_component(WDK_DIRECTORY ${LATEST_D3DKMT_HEADER} DIRECTORY)
+             get_filename_component(WDK_DIRECTORY ${WDK_DIRECTORY} DIRECTORY)
+             message(STATUS "Found the Windows WDK in: ${WDK_DIRECTORY}")
+-            target_compile_definitions(OpenCL PRIVATE OPENCL_ICD_LOADER_REQUIRE_WDK)
+-            target_include_directories(OpenCL PRIVATE ${WDK_DIRECTORY}/um)
+-            target_include_directories(OpenCL PRIVATE ${WDK_DIRECTORY}/km)
+-            target_include_directories(OpenCL PRIVATE ${WDK_DIRECTORY}/shared)
++	    target_compile_definitions(OpenCL-ROCm PRIVATE OPENCL_ICD_LOADER_REQUIRE_WDK)
++	    target_include_directories(OpenCL-ROCm PRIVATE ${WDK_DIRECTORY}/um)
++	    target_include_directories(OpenCL-ROCm PRIVATE ${WDK_DIRECTORY}/km)
++	    target_include_directories(OpenCL-ROCm PRIVATE ${WDK_DIRECTORY}/shared)
+         else()
+             message(FATAL_ERROR "The Windows WDK was not found. Consider disabling OPENCL_ICD_LOADER_REQUIRE_WDK. Aborting.")
+         endif()
+@@ -113,25 +113,25 @@
+     endif()
+ else()
+     if (APPLE)
+-        target_link_libraries (OpenCL ${CMAKE_THREAD_LIBS_INIT})
++        target_link_libraries (OpenCL-ROCm ${CMAKE_THREAD_LIBS_INIT})
+     else ()
+-        set_target_properties (OpenCL PROPERTIES LINK_FLAGS "-Wl,--version-script -Wl,${CMAKE_CURRENT_SOURCE_DIR}/loader/linux/icd_exports.map")
+-        target_link_libraries (OpenCL ${CMAKE_THREAD_LIBS_INIT})
++        set_target_properties (OpenCL-ROCm PROPERTIES LINK_FLAGS "-Wl,--version-script -Wl,${CMAKE_CURRENT_SOURCE_DIR}/loader/linux/icd_exports.map")
++	target_link_libraries (OpenCL-ROCm ${CMAKE_THREAD_LIBS_INIT})
+     endif ()
+ endif ()
+ 
+ include_directories (${OPENCL_ICD_LOADER_HEADERS_DIR})
+ add_definitions (-DCL_TARGET_OPENCL_VERSION=220)
+ 
+-target_include_directories (OpenCL PRIVATE ${CMAKE_CURRENT_BINARY_DIR} loader)
+-target_link_libraries (OpenCL ${CMAKE_DL_LIBS})
++target_include_directories (OpenCL-ROCm PRIVATE ${CMAKE_CURRENT_BINARY_DIR} loader)
++target_link_libraries (OpenCL-ROCm ${CMAKE_DL_LIBS})
+ 
+ include (CTest)
+ if (BUILD_TESTING)
+     add_subdirectory (test)
+ endif()
+ 
+-install (TARGETS OpenCL
++install (TARGETS OpenCL-ROCm
+     RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+     ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
+     LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
+--- OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/test/loader_test/CMakeLists.txt	2019-09-10 11:53:28.000000000 -0400
++++ OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/test/loader_test/CMakeLists.txt	2020-04-16 20:16:56.647026589 -0400
+@@ -12,4 +12,4 @@
+     test_clgl.c
+     test_image_objects.c )
+ 
+-target_link_libraries (icd_loader_test OpenCL IcdLog)
++target_link_libraries (icd_loader_test OpenCL-ROCm IcdLog)
+--- ROCm-OpenCL-Runtime-roc-3.3.0/CMakeLists.txt	2020-04-28 07:29:51.864446603 -0400
++++ ROCm-OpenCL-Runtime-roc-3.3.0/CMakeLists.txt	2020-04-28 07:32:45.245793180 -0400
+@@ -101,30 +101,30 @@
+ rocm_setup_version( VERSION "2.0.0" )
+ 
+ # MAIN package
+-install(PROGRAMS $<TARGET_FILE:clinfo>
+-        DESTINATION bin/x86_64
++install(PROGRAMS $<TARGET_FILE:rocm-clinfo>
++        DESTINATION bin
+         COMPONENT MAIN)
+ install(PROGRAMS $<TARGET_FILE:amdocl64>
+-        DESTINATION lib/x86_64
++        DESTINATION lib
+         COMPONENT MAIN)
+-install(PROGRAMS $<TARGET_FILE:OpenCL>
+-        DESTINATION lib/x86_64
++install(PROGRAMS $<TARGET_FILE:OpenCL-ROCm>
++        DESTINATION lib
+         COMPONENT MAIN)
+-install(PROGRAMS $<TARGET_SONAME_FILE:OpenCL>
+-        DESTINATION lib/x86_64
++install(PROGRAMS $<TARGET_SONAME_FILE:OpenCL-ROCm>
++        DESTINATION lib
+         COMPONENT MAIN)
+ 
+ # DEV package
+ install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/api/opencl/khronos/headers/opencl2.2/CL"
+-        DESTINATION include
++	DESTINATION include/rocm
+         COMPONENT DEV
+         USE_SOURCE_PERMISSIONS
+         PATTERN cl_d3d10.h EXCLUDE
+         PATTERN cl_d3d11.h EXCLUDE
+         PATTERN cl_dx9_media_sharing.h EXCLUDE
+         PATTERN cl_egl.h EXCLUDE)
+-install(PROGRAMS $<TARGET_LINKER_FILE:OpenCL>
+-        DESTINATION lib/x86_64
++install(PROGRAMS $<TARGET_LINKER_FILE:OpenCL-ROCm>
++        DESTINATION lib
+         COMPONENT DEV)
+ 
+ # Generic CPACK variables
+--- ROCm-OpenCL-Runtime-roc-3.3.0/tools/clinfo/CMakeLists.txt	2020-04-28 07:29:51.882446535 -0400
++++ ROCm-OpenCL-Runtime-roc-3.3.0/tools/clinfo/CMakeLists.txt	2020-04-28 07:30:05.627394732 -0400
+@@ -6,6 +6,6 @@
+ 
+ add_definitions(-DHAVE_CL2_HPP)
+ 
+-add_executable(clinfo clinfo.cpp)
++add_executable(rocm-clinfo clinfo.cpp)
+ 
+-target_link_libraries(clinfo OpenCL)
++target_link_libraries(rocm-clinfo OpenCL-ROCm)
diff --git a/srcpkgs/rocm-opencl-runtime/template b/srcpkgs/rocm-opencl-runtime/template
new file mode 100644
index 00000000000..f83c6e64149
--- /dev/null
+++ b/srcpkgs/rocm-opencl-runtime/template
@@ -0,0 +1,82 @@
+# Template file for 'rocm-opencl-runtime'
+pkgname=rocm-opencl-runtime
+version=3.3.0
+revision=1
+_ocl_icd_name="OpenCL-ICD-Loader"
+_ocl_icd_ver="6c03f8b58fafd9dd693eaac826749a5cfad515f8"
+archs="x86_64*"
+create_wrksrc=yes
+build_wrksrc="ROCm-OpenCL-Runtime-roc-${version}"
+build_style=cmake
+configure_args="-DUSE_COMGR_LIBRARY=yes"
+hostmakedepends="cmake pkg-config"
+makedepends="libglvnd-devel rocm-comgr-devel
+	roct-thunk-interface-devel rocr-runtime-devel"
+depends="rocm-comgr"
+short_desc="Radeon Open Compute OpenCL runtime"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="MIT"
+homepage="https://github.com/RadeonOpenCompute/ROCm-OpenCL-Runtime"
+_rocroot="https://github.com/RadeonOpenCompute"
+distfiles="${_rocroot}/ROCm-OpenCL-Runtime/archive/roc-${version}.tar.gz
+	${_rocroot}/rocm-cmake/archive/rocm-${version}.tar.gz
+	https://github.com/KhronosGroup/${_ocl_icd_name}/archive/${_ocl_icd_ver}.tar.gz"
+checksum="ac6999f1a491ab066286c2bd6adf50f08f831286f56e267879f9f7eced22f98e
+	76ed3ee8e56cf3246011cf7723c2abda539e1136e7e7f6909bfa45d268b8644f
+	c94d5bb6dc980c4d41d73e2b81663a19aabe494e923e2d0eec72a4c95b318438"
+nocross=yes
+
+post_patch() {
+	if [ "$XBPS_LIBC" = "musl" ]; then
+		# Copy sys/queue.h locally for MUSL builds
+		libelf_dir="compiler/lib/loaders/elf/utils/libelf"
+		cp "${FILESDIR}/sys_queue.h" "${libelf_dir}"
+
+		# Remove dependence on glibc
+		patch -Np0 < ${FILESDIR}/libelf-musl.patch
+		patch -Np0 < ${FILESDIR}/runtime-musl.patch
+		vsed -e '/glibc_functions.cpp/d' -i api/opencl/amdocl/CMakeLists.txt
+	fi
+}
+
+pre_configure() {
+	# ROCm requires a very specific Khronos ICD loader version in the tree
+	# Keep the ICD loader config in /etc/rocm/vendors to avoid conflicts
+	_ocl_icd_dir="${_ocl_icd_name}-${_ocl_icd_ver}"
+	ln -sf "${wrksrc}/${_ocl_icd_dir}" api/opencl/khronos/icd
+	vsed -i "${wrksrc}/${_ocl_icd_dir}/loader/icd_platform.h" \
+		-e 's@/etc/OpenCL/vendors/@/etc/rocm/vendors/@g'
+
+	# CMake modules probably not useful anywhere but for this build
+	ln -sf "${wrksrc}/rocm-cmake-rocm-${version}/share/rocm/cmake"/*.cmake cmake
+
+	# Fix the dlopen macro to point to versioned libamd_comgr shared object
+	vsed -i 'runtime/device/comgrctx.cpp' \
+		-e 's/\blibamd_comgr\(32\)\?.so\b/&.1/g'
+}
+
+post_install() {
+	vlicense License
+
+	# Create descriptor to allow the ICD loader to find the driver
+	_ocl_icd_dir="etc/rocm/vendors"
+	vmkdir "${_ocl_icd_dir}"
+	echo "libamdocl64.so" > "${DESTDIR}/${_ocl_icd_dir}/amdocl64.icd"
+}
+
+rocm-opencl-runtime-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/lib/libOpenCL-ROCm.so
+		vmove usr/include
+	}
+}
+
+rocm-opencl-runtime-clinfo_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - clinfo"
+	pkg_install() {
+		vmove usr/bin/rocm-clinfo
+	}
+}

^ permalink raw reply	[flat|nested] 61+ messages in thread

* Re: [PR PATCH] [Updated] New packages: ROCm core and OpenCL
  2020-04-19 13:34 [PR PATCH] New packages: ROCm core and OpenCL ahesford
                   ` (4 preceding siblings ...)
  2020-04-28 14:00 ` ahesford
@ 2020-04-28 15:14 ` ahesford
  2020-04-28 17:34 ` ahesford
                   ` (53 subsequent siblings)
  59 siblings, 0 replies; 61+ messages in thread
From: ahesford @ 2020-04-28 15:14 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 3893 bytes --]

There is an updated pull request by ahesford against master on the void-packages repository

https://github.com/ahesford/void-packages rocm
https://github.com/void-linux/void-packages/pull/21153

New packages: ROCm core and OpenCL
This PR includes several packages designed to bring the OpenCL portion of the AMD ROCm ecosystem to Void. It addresses Issue #19507. There are many other packages that AMD provides for GPGPU computing, but these can be added piecemeal as users demand.

The packages are currently only for `x86_64*`. While at least some of the packages will compile on other 64-bit architectures, I have no hardware to test. They are certainly not suitable for 32-bit architectures; some internal data structures rely on `uint64_t` values that are cast to pointers. At a
minimum, a thorough audit would be necessary to ensure that these casts are safe (e.g., that the values stored were only ever upcast from 32-bit pointers). More extensive work may be necessary to support 32-bit architectures, probably without significant benefit.

The packages successfully identify a Radeon RX 580 on an `x86_64` installation using both `clinfo` and `rocminfo` as provided. Furthermore, a version of `pyopencl` linked against these ROCm packages successfully runs a simple program that validates arithmetic on GPU-bound arrays.

There are caveats with this set of packages, almost all of which revolve around the incompatibilities between the Void-provided `ocl-icd` and the [Khronos OpenCL ICD loader](https://github.com/KhronosGroup/OpenCL-ID-Loader) required by (and built into) `rocm-opencl-runtime`.
1. All packages install into `/opt/rocm`. This keeps the environment closer to that officially sanctioned by AMD and helps avoid conflicts between other packages and those provided here. (For example, `clinfo` and the ICD loader itself.) Eventually, we may be able to move the files into `/usr`.
2. The Khronos OpenCL ICD loader built into `rocm-opencl-runtime` is an outdated, pre-release commit. If AMD can update its sources to use the release version of that loader (which has a backward-incompatible API change), we may be able to make ROCm compatible with `ocl-icd` or replace `ocl-icd` with the official Khronos loader.
3. In the meantime, to avoid `shlibs` conflicts, the OpenCL ICD loader is installed as `/opt/rocm/lib/libOpenCL-ROCm.so` (and an appropriately versioned shared library), which means that programs wishing to use the ROCm OpenCL must explicitly link against this library instead of the generic `libOpenCL.so`.
4. I do **not** recommend making any Void packages link against this specific library, because it will make those packages ROCm-only. For the time being, ROCm is intended for end-users to specifically link against. Linking Void packages against ROCm would requires the ICD loader used by ROCm be compatible with `ocl-icd`, or `ocl-icd` be replaced by the Khronos loader. However, because the Khronos loader changed its API for the release version, such a change is not yet appropriate.

Hopefully, if AMD updates its dependence on the Khronos ICD loader, we can resolve some of these caveats in the future and make ROCm a more natural Void component. For now, these packages are useful for those who need an AMD OpenCL solution and would rather custom-link software against the AMD ICD loader than hack the `amdgpu-pro` driver into an ICD compatible with `ocl-icd`.

Some patches were made to relocate some files in `/opt/rocm` and make everyting build on x86_64-musl`. Where appropriate, these patches will be pushed upstream to clean up the distribution and packaging.

Update: I pushed some new commits to update license information that triggerd an `xlint` failure. I've also disabled CI builds because they will time out on `rocm-llvm`.

A patch file from https://github.com/void-linux/void-packages/pull/21153.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-rocm-21153.patch --]
[-- Type: text/x-diff, Size: 73767 bytes --]

From 1226ae1e7c5eea64be3859bb36eee4fd8c6cccc6 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Mon, 13 Apr 2020 13:08:09 -0400
Subject: [PATCH 1/8] New package: roct-thunk-interface-3.3.0

---
 common/shlibs                                 |  1 +
 srcpkgs/roct-thunk-interface-devel            |  1 +
 .../patches/cmake-dev-libdir.patch            | 10 ++++++
 .../roct-thunk-interface/patches/musl.patch   | 29 ++++++++++++++++
 srcpkgs/roct-thunk-interface/template         | 33 +++++++++++++++++++
 5 files changed, 74 insertions(+)
 create mode 120000 srcpkgs/roct-thunk-interface-devel
 create mode 100644 srcpkgs/roct-thunk-interface/patches/cmake-dev-libdir.patch
 create mode 100644 srcpkgs/roct-thunk-interface/patches/musl.patch
 create mode 100644 srcpkgs/roct-thunk-interface/template

diff --git a/common/shlibs b/common/shlibs
index 6d39ce34c19..d89ae72ae3e 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3862,3 +3862,4 @@ libtagparser.so.9 tagparser-9.1.2_1
 libqtutilities.so.6 qtutilities-6.0.4_1
 libkdsoap.so.1.9.0 KDSoap-1.9.0_1
 libstoken.so.1 stoken-0.92_1
+libhsakmt.so.1 roct-thunk-interface-3.3.0_1
diff --git a/srcpkgs/roct-thunk-interface-devel b/srcpkgs/roct-thunk-interface-devel
new file mode 120000
index 00000000000..ac3f2cc684c
--- /dev/null
+++ b/srcpkgs/roct-thunk-interface-devel
@@ -0,0 +1 @@
+roct-thunk-interface
\ No newline at end of file
diff --git a/srcpkgs/roct-thunk-interface/patches/cmake-dev-libdir.patch b/srcpkgs/roct-thunk-interface/patches/cmake-dev-libdir.patch
new file mode 100644
index 00000000000..98c7f1e459c
--- /dev/null
+++ b/srcpkgs/roct-thunk-interface/patches/cmake-dev-libdir.patch
@@ -0,0 +1,10 @@
+--- CMakeLists.txt.old	2020-04-18 19:45:17.306081135 -0400
++++ CMakeLists.txt	2020-04-18 19:46:51.300753636 -0400
+@@ -146,6 +146,7 @@
+     COMMAND ${CMAKE_COMMAND}
+         -DSOURCE_DIR="${SOURCE_DIR}"
+         -DCMAKE_INSTALL_PREFIX="${CMAKE_INSTALL_PREFIX}"
++        -DCMAKE_INSTALL_LIBDIR="${CMAKE_INSTALL_LIBDIR}"
+         -DCPACK_RPM_PACKAGE_REQUIRES="hsakmt-roct"
+         -DCPACK_PACKAGING_INSTALL_PREFIX="${CPACK_PACKAGING_INSTALL_PREFIX}"
+         -DVERSION="${BUILD_VERSION_STRING}"
diff --git a/srcpkgs/roct-thunk-interface/patches/musl.patch b/srcpkgs/roct-thunk-interface/patches/musl.patch
new file mode 100644
index 00000000000..aeea9832411
--- /dev/null
+++ b/srcpkgs/roct-thunk-interface/patches/musl.patch
@@ -0,0 +1,29 @@
+diff -r -u old/src/libhsakmt.h new/src/libhsakmt.h
+--- src/libhsakmt.h	2020-03-04 15:00:47.000000000 -0500
++++ src/libhsakmt.h	2020-04-13 12:58:30.444865992 -0400
+@@ -54,6 +54,10 @@
+ #define CHECK_KFD_OPEN() \
+ 	do { if (kfd_open_count == 0 || hsakmt_forked) return HSAKMT_STATUS_KERNEL_IO_CHANNEL_NOT_OPENED; } while (0)
+ 
++/*On some platforms, a PAGE_SIZE macro eclipses the extern variable*/
++#ifdef PAGE_SIZE
++#undef PAGE_SIZE
++#endif
+ extern int PAGE_SIZE;
+ extern int PAGE_SHIFT;
+ 
+diff -r -u old/src/topology.c new/src/topology.c
+--- src/topology.c	2020-03-04 15:00:47.000000000 -0500
++++ src/topology.c	2020-04-13 13:01:31.209870701 -0400
+@@ -38,6 +38,11 @@
+ #include "libhsakmt.h"
+ #include "fmm.h"
+ 
++/*Needed on MUSL*/
++#ifndef MAXNAMLEN
++#define MAXNAMLEN PATH_MAX
++#endif
++
+ /* Number of memory banks added by thunk on top of topology
+  * This only includes static heaps like LDS, scratch and SVM,
+  * not for MMIO_REMAP heap. MMIO_REMAP memory bank is reported
diff --git a/srcpkgs/roct-thunk-interface/template b/srcpkgs/roct-thunk-interface/template
new file mode 100644
index 00000000000..55a1fc6074a
--- /dev/null
+++ b/srcpkgs/roct-thunk-interface/template
@@ -0,0 +1,33 @@
+# Template file for 'roct-thunk-interface'
+pkgname=roct-thunk-interface
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="ROCT-Thunk-Interface-roc-${version}"
+build_style=cmake
+make_build_target="all build-dev"
+make_install_target="install install-dev"
+hostmakedepends="cmake pkg-config"
+makedepends="pciutils-devel libnuma-devel"
+short_desc="Radeon Open Compute Thunk Interface"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="MIT"
+homepage="https://github.com/RadeonOpenCompute/ROCT-Thunk-Interface"
+distfiles="${homepage}/archive/roc-${version}.tar.gz"
+checksum=2cabe9d2cfa72031c05d11290837c476182e72d8dec2049298f691143fdd212b
+nocross=yes
+
+post_install() {
+	vlicense LICENSE.md
+}
+
+roct-thunk-interface-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove "usr/lib/*.so"
+		vmove usr/share/pkgconfig
+		vmove usr/lib/cmake
+	}
+}

From d8bb69aca8ebcd167198d858c11e7b7fa326c389 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Mon, 13 Apr 2020 15:27:27 -0400
Subject: [PATCH 2/8] New package: rocr-runtime-3.3.0

---
 common/shlibs                            |  1 +
 srcpkgs/rocr-runtime-devel               |  1 +
 srcpkgs/rocr-runtime/patches/cmake.patch | 27 +++++++++++++++++++++
 srcpkgs/rocr-runtime/template            | 30 ++++++++++++++++++++++++
 4 files changed, 59 insertions(+)
 create mode 120000 srcpkgs/rocr-runtime-devel
 create mode 100644 srcpkgs/rocr-runtime/patches/cmake.patch
 create mode 100644 srcpkgs/rocr-runtime/template

diff --git a/common/shlibs b/common/shlibs
index d89ae72ae3e..499f35752c2 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3863,3 +3863,4 @@ libqtutilities.so.6 qtutilities-6.0.4_1
 libkdsoap.so.1.9.0 KDSoap-1.9.0_1
 libstoken.so.1 stoken-0.92_1
 libhsakmt.so.1 roct-thunk-interface-3.3.0_1
+libhsa-runtime64.so.1 rocr-runtime-3.3.0_1
diff --git a/srcpkgs/rocr-runtime-devel b/srcpkgs/rocr-runtime-devel
new file mode 120000
index 00000000000..be838f22d81
--- /dev/null
+++ b/srcpkgs/rocr-runtime-devel
@@ -0,0 +1 @@
+rocr-runtime
\ No newline at end of file
diff --git a/srcpkgs/rocr-runtime/patches/cmake.patch b/srcpkgs/rocr-runtime/patches/cmake.patch
new file mode 100644
index 00000000000..93b74cd2297
--- /dev/null
+++ b/srcpkgs/rocr-runtime/patches/cmake.patch
@@ -0,0 +1,27 @@
+--- src/CMakeLists.txt.old	2020-04-18 20:01:48.549636995 -0400
++++ src/CMakeLists.txt	2020-04-18 20:04:00.177179781 -0400
+@@ -108,8 +108,8 @@
+ ## ROCr build internal versioning
+ add_definitions ( -DROCR_BUILD_ID=${PACKAGE_VERSION_STRING} )
+ 
+-## Set RUNPATH - ../../lib covers use of the legacy symlink in /hsa/lib/
+-set(CMAKE_INSTALL_RPATH "$ORIGIN;$ORIGIN/../../lib;$ORIGIN/../../lib64;$ORIGIN/../lib64")
++## Set RUNPATH
++set(CMAKE_INSTALL_RPATH "$ORIGIN;$ORIGIN/../lib")
+ 
+ ## ------------------------- Linux Compiler and Linker options -------------------------
+ set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -fexceptions -fno-rtti -fvisibility=hidden -Wno-error=sign-compare -Wno-sign-compare -Wno-write-strings -Wno-conversion-null -fno-math-errno -fno-threadsafe-statics -fmerge-all-constants -fms-extensions -Wno-error=comment -Wno-comment -Wno-error=pointer-arith -Wno-pointer-arith -Wno-error=unused-variable -Wno-error=unused-function" )
+@@ -185,11 +185,8 @@
+ add_custom_target ( hsa_lib_link2 ALL WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMAND ${CMAKE_COMMAND} -E create_symlink ../hsa/lib/${CORE_RUNTIME_LIBRARY}.so.${SO_MAJOR} ${CORE_RUNTIME_LIBRARY}-link.so.${SO_MAJOR} )
+ 
+ ## Set install information
+-install ( TARGETS ${CORE_RUNTIME_TARGET} LIBRARY DESTINATION hsa/lib )
+-install ( DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/inc/ DESTINATION hsa/include/hsa )
+-install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/hsa_include_link DESTINATION include PERMISSIONS OWNER_WRITE OWNER_READ RENAME hsa )
+-install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/${CORE_RUNTIME_LIBRARY}-link.so DESTINATION lib PERMISSIONS OWNER_WRITE OWNER_READ RENAME ${CORE_RUNTIME_LIBRARY}.so )
+-install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/${CORE_RUNTIME_LIBRARY}-link.so.${SO_MAJOR} DESTINATION lib PERMISSIONS OWNER_WRITE OWNER_READ RENAME ${CORE_RUNTIME_LIBRARY}.so.${SO_MAJOR} )
++install ( TARGETS ${CORE_RUNTIME_TARGET} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} )
++install ( DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/inc/ DESTINATION include/hsa )
+ 
+ ## Packaging directives
+ set ( CPACK_GENERATOR "DEB;RPM" CACHE STRING "Package types to build")
diff --git a/srcpkgs/rocr-runtime/template b/srcpkgs/rocr-runtime/template
new file mode 100644
index 00000000000..5ee22140f1f
--- /dev/null
+++ b/srcpkgs/rocr-runtime/template
@@ -0,0 +1,30 @@
+# Template file for 'rocr-runtime'
+pkgname=rocr-runtime
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="ROCR-Runtime-rocm-${version}"
+build_wrksrc="src"
+build_style=cmake
+hostmakedepends="cmake pkg-config"
+makedepends="roct-thunk-interface-devel elfutils-devel"
+short_desc="Radeon Open Compute HSA Runtime"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute/ROCR-Runtime"
+distfiles="${homepage}/archive/rocm-${version}.tar.gz"
+checksum=fa2d2d1f8a61d8a6952d377cf288d78c61776c3c2a666f163cafc3aa19ab0b61
+nocross=yes
+
+post_install() {
+	vlicense ../LICENSE.txt
+}
+
+rocr-runtime-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove "usr/lib/*.so"
+	}
+}

From 8094f1ed5017c36dc9129b73ed78188378a51284 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Mon, 13 Apr 2020 18:07:34 -0400
Subject: [PATCH 3/8] New package: rocm-llvm-3.3.0

---
 srcpkgs/rocm-llvm/template | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)
 create mode 100644 srcpkgs/rocm-llvm/template

diff --git a/srcpkgs/rocm-llvm/template b/srcpkgs/rocm-llvm/template
new file mode 100644
index 00000000000..26942e3ea46
--- /dev/null
+++ b/srcpkgs/rocm-llvm/template
@@ -0,0 +1,25 @@
+# Template file for 'rocm-llvm'
+pkgname=rocm-llvm
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="llvm-project-rocm-ocl-${version}"
+build_wrksrc=llvm
+build_style=cmake
+configure_args="-DCMAKE_INSTALL_PREFIX:PATH=/usr/lib/rocm-llvm
+	-DLLVM_ENABLE_PROJECTS='llvm;clang;lld' -DLLVM_TARGETS_TO_BUILD='AMDGPU'
+	-DLLVM_BUILD_DOCS=NO -DLLVM_ENABLE_OCAMLDOC=OFF
+	-DLLVM_ENABLE_SPHINX=NO -DLLVM_ENABLE_DOXYGEN=OFF
+	-DLLVM_INSTALL_UTILS=ON -DLLVM_VERSION_SUFFIX=roc -DOCAMLFIND=NO"
+hostmakedepends="cmake pkg-config python3"
+short_desc="Radeon Open Compute LLVM toolchain"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="Apache-2.0, NCSA, custom:LLVM-Exceptions"
+homepage="https://github.com/RadeonOpenCompute/llvm-project"
+distfiles="${homepage}/archive/rocm-ocl-${version}.tar.gz"
+checksum=a2bef7042e8e2f2cd8548cb246b88322e1c77188839983dcac8312d56f544dc8
+nocross=yes
+
+post_install() {
+	vlicense LICENSE.TXT
+}

From 0e7977b668140e095f21839a24923005b3029c81 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Tue, 14 Apr 2020 10:25:31 -0400
Subject: [PATCH 4/8] New package: rocm-device-libs-3.3.0

---
 srcpkgs/rocm-device-libs/template | 37 +++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)
 create mode 100644 srcpkgs/rocm-device-libs/template

diff --git a/srcpkgs/rocm-device-libs/template b/srcpkgs/rocm-device-libs/template
new file mode 100644
index 00000000000..fcb4eb0d53e
--- /dev/null
+++ b/srcpkgs/rocm-device-libs/template
@@ -0,0 +1,37 @@
+# Template file for 'rocm-device-libs'
+pkgname=rocm-device-libs
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="ROCm-Device-Libs-rocm-ocl-${version}"
+build_style=cmake
+configure_args="-DLLVM_DIR:PATH=/usr/lib/rocm-llvm
+	-DCMAKE_INSTALL_LIBDIR:PATH=lib/rocm-device-libs"
+hostmakedepends="cmake rocm-llvm"
+short_desc="Radeon Open Compute device libraries"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute/ROCm-Device-Libs"
+distfiles="${homepage}/archive/rocm-ocl-${version}.tar.gz"
+checksum=706b08230790e08ca6a7a2fb7687d6131fd39a562148340e00fa37a6c06769c5
+nocross=yes
+
+pre_configure() {
+	# Put bytecodes in a lib/ subdirectory
+	vsed -i Packages.cmake -e 's@/lib/@/${CMAKE_INSTALL_LIBDIR}/@'
+	vsed -i OCL.cmake -e 's@DESTINATION lib$@DESTINATION ${CMAKE_INSTALL_LIBDIR}@'
+
+	# Build the prepare-builtins executable with native compiler
+	mkdir -p utils/build
+	cd utils/build
+	_prepare_builtins="$PWD/prepare-builtins/prepare-builtins"
+	cmake ${configure_args} ..
+	make ${makejobs}
+
+	# Add path to prepare-builtins for cmake
+	configure_args+=" -DPREPARE_BUILTINS='${_prepare_builtins}'"
+}
+
+post_install() {
+	vlicense LICENSE
+}

From 81355a023645398d9f99fcd99988a9f61f5f0777 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Mon, 13 Apr 2020 18:30:00 -0400
Subject: [PATCH 5/8] New package: rocm-comgr-3.3.0

---
 common/shlibs               |  1 +
 srcpkgs/rocm-comgr-devel    |  1 +
 srcpkgs/rocm-comgr/template | 32 ++++++++++++++++++++++++++++++++
 3 files changed, 34 insertions(+)
 create mode 120000 srcpkgs/rocm-comgr-devel
 create mode 100644 srcpkgs/rocm-comgr/template

diff --git a/common/shlibs b/common/shlibs
index 499f35752c2..a53de3cf9e0 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3864,3 +3864,4 @@ libkdsoap.so.1.9.0 KDSoap-1.9.0_1
 libstoken.so.1 stoken-0.92_1
 libhsakmt.so.1 roct-thunk-interface-3.3.0_1
 libhsa-runtime64.so.1 rocr-runtime-3.3.0_1
+libamd_comgr.so.1 rocm-comgr-3.3.0_1
diff --git a/srcpkgs/rocm-comgr-devel b/srcpkgs/rocm-comgr-devel
new file mode 120000
index 00000000000..3f5ce255e07
--- /dev/null
+++ b/srcpkgs/rocm-comgr-devel
@@ -0,0 +1 @@
+rocm-comgr
\ No newline at end of file
diff --git a/srcpkgs/rocm-comgr/template b/srcpkgs/rocm-comgr/template
new file mode 100644
index 00000000000..c228bcd4d1f
--- /dev/null
+++ b/srcpkgs/rocm-comgr/template
@@ -0,0 +1,32 @@
+# Template file for 'rocm-comgr'
+pkgname=rocm-comgr
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="ROCm-CompilerSupport-rocm-${version}"
+build_wrksrc="lib/comgr"
+build_style=cmake
+configure_args="-DClang_DIR:PATH=/usr/lib/rocm-llvm/lib/cmake/clang"
+hostmakedepends="cmake pkg-config rocm-llvm"
+makedepends="rocm-device-libs"
+short_desc="Radeon Open Compute Code Object Manager"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="BSD-3-Clause"
+homepage="https://github.com/RadeonOpenCompute/ROCm-CompilerSupport"
+distfiles="${homepage}/archive/rocm-${version}.tar.gz"
+checksum=01e2524e0f28ecd6f46c9720f279207de935d826b0172158792aa3ec86af9ca7
+nocross=yes
+
+post_install() {
+	vlicense LICENSE.txt
+}
+
+rocm-comgr-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove "usr/lib/*.so"
+		vmove usr/lib/cmake
+	}
+}

From 1dda7453d2c6b722fc45c445c49bebd948ea5bda Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Fri, 17 Apr 2020 12:11:25 -0400
Subject: [PATCH 6/8] New package: rocminfo-3.3.0

---
 srcpkgs/rocminfo/template | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
 create mode 100644 srcpkgs/rocminfo/template

diff --git a/srcpkgs/rocminfo/template b/srcpkgs/rocminfo/template
new file mode 100644
index 00000000000..57d0640dd69
--- /dev/null
+++ b/srcpkgs/rocminfo/template
@@ -0,0 +1,22 @@
+# Template file for 'rocminfo'
+pkgname=rocminfo
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="rocminfo-rocm-${version}"
+build_style=cmake
+configure_args="-DROCM_DIR=/usr"
+hostmakedepends="cmake pkg-config"
+makedepends="rocr-runtime-devel"
+short_desc="Radeon Open Compute system information reporter"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute/rocminfo"
+distfiles="${homepage}/archive/rocm-${version}.tar.gz"
+checksum=e666f662c9e465aaabbbd0b109d87e017243cdf1a0898fabf5a90947bb3dbcd7
+nocross=yes
+python_version=3
+
+post_install() {
+	vlicense License.txt
+}

From e84da1d860708fe8c5d8b144500711d167743578 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Sun, 19 Apr 2020 15:01:40 -0400
Subject: [PATCH 7/8] New package: rocm-bandwidth-test-3.3.0

---
 srcpkgs/rocm-bandwidth-test/template | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
 create mode 100644 srcpkgs/rocm-bandwidth-test/template

diff --git a/srcpkgs/rocm-bandwidth-test/template b/srcpkgs/rocm-bandwidth-test/template
new file mode 100644
index 00000000000..5c5058b693d
--- /dev/null
+++ b/srcpkgs/rocm-bandwidth-test/template
@@ -0,0 +1,20 @@
+# Template file for 'rocm-bandwidth-test'
+pkgname=rocm-bandwidth-test
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="rocm_bandwidth_test-rocm-${version}"
+build_style=cmake
+hostmakedepends="cmake"
+makedepends="rocr-runtime-devel roct-thunk-interface-devel"
+short_desc="Radeon Open Compute bandwidth test"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute/rocm_bandwidth_test"
+distfiles="${homepage}/archive/rocm-${version}.tar.gz"
+checksum=f5f914073018619dc91662d5bf630903dfa4db9136d603591917fdfb3c9164ce
+nocross=yes
+
+post_install() {
+	vlicense LICENSE.txt
+}

From da03023ab238ff56bbe9cf41064c04007f11053a Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Tue, 14 Apr 2020 10:25:54 -0400
Subject: [PATCH 8/8] New package: rocm-opencl-runtime-3.3.0 [ci skip]

---
 common/shlibs                                 |   2 +
 srcpkgs/rocm-opencl-runtime-clinfo            |   1 +
 srcpkgs/rocm-opencl-runtime-devel             |   1 +
 .../files/libelf-musl.patch                   | 688 ++++++++++++++++++
 .../files/runtime-musl.patch                  |  11 +
 srcpkgs/rocm-opencl-runtime/files/sys_queue.h | 574 +++++++++++++++
 .../rocm-opencl-runtime/patches/cmake.patch   | 126 ++++
 srcpkgs/rocm-opencl-runtime/template          |  82 +++
 8 files changed, 1485 insertions(+)
 create mode 120000 srcpkgs/rocm-opencl-runtime-clinfo
 create mode 120000 srcpkgs/rocm-opencl-runtime-devel
 create mode 100644 srcpkgs/rocm-opencl-runtime/files/libelf-musl.patch
 create mode 100644 srcpkgs/rocm-opencl-runtime/files/runtime-musl.patch
 create mode 100644 srcpkgs/rocm-opencl-runtime/files/sys_queue.h
 create mode 100644 srcpkgs/rocm-opencl-runtime/patches/cmake.patch
 create mode 100644 srcpkgs/rocm-opencl-runtime/template

diff --git a/common/shlibs b/common/shlibs
index a53de3cf9e0..8cbc885e016 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3865,3 +3865,5 @@ libstoken.so.1 stoken-0.92_1
 libhsakmt.so.1 roct-thunk-interface-3.3.0_1
 libhsa-runtime64.so.1 rocr-runtime-3.3.0_1
 libamd_comgr.so.1 rocm-comgr-3.3.0_1
+libOpenCL-ROCm.so.1 rocm-opencl-runtime-3.3.0_1
+libamdocl64.so rocm-opencl-runtime-3.3.0_1
diff --git a/srcpkgs/rocm-opencl-runtime-clinfo b/srcpkgs/rocm-opencl-runtime-clinfo
new file mode 120000
index 00000000000..b2cda7e229d
--- /dev/null
+++ b/srcpkgs/rocm-opencl-runtime-clinfo
@@ -0,0 +1 @@
+rocm-opencl-runtime
\ No newline at end of file
diff --git a/srcpkgs/rocm-opencl-runtime-devel b/srcpkgs/rocm-opencl-runtime-devel
new file mode 120000
index 00000000000..b2cda7e229d
--- /dev/null
+++ b/srcpkgs/rocm-opencl-runtime-devel
@@ -0,0 +1 @@
+rocm-opencl-runtime
\ No newline at end of file
diff --git a/srcpkgs/rocm-opencl-runtime/files/libelf-musl.patch b/srcpkgs/rocm-opencl-runtime/files/libelf-musl.patch
new file mode 100644
index 00000000000..a3705c259a9
--- /dev/null
+++ b/srcpkgs/rocm-opencl-runtime/files/libelf-musl.patch
@@ -0,0 +1,688 @@
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/_libelf.h compiler/lib/loaders/elf/utils/libelf/_libelf.h
+--- compiler/lib/loaders/elf/utils/libelf.orig/_libelf.h	2020-04-19 08:59:34.201386585 -0400
++++ compiler/lib/loaders/elf/utils/libelf/_libelf.h	2020-04-19 09:04:12.950433528 -0400
+@@ -30,7 +30,7 @@
+ #define	__LIBELF_H_
+ 
+ #include <limits.h>
+-#include <sys/queue.h>
++#include "sys_queue.h"
+ 
+ #include "_libelf_config.h"
+ 
+@@ -179,7 +179,9 @@
+  * Function Prototypes.
+  */
+ 
+-__BEGIN_DECLS
++#ifdef __cplusplus
++extern "C" {
++#endif
+ Elf_Data *_libelf_allocate_data(Elf_Scn *_s);
+ Elf	*_libelf_allocate_elf(Elf_Mem *mem);
+ Elf_Scn	*_libelf_allocate_scn(Elf *_e, size_t _ndx);
+@@ -213,6 +215,8 @@
+ Elf_Data *_libelf_xlate(Elf_Data *_d, const Elf_Data *_s,
+     unsigned int _encoding, int _elfclass, int _direction);
+ int	_libelf_xlate_shtype(uint32_t _sht);
+-__END_DECLS
++#ifdef __cplusplus
++}
++#endif
+ 
+ #endif	/* __LIBELF_H_ */
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_begin.c compiler/lib/loaders/elf/utils/libelf/elf_begin.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_begin.c	2020-04-19 08:59:34.201386585 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_begin.c	2020-04-19 09:01:04.313212042 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <sys/types.h>
+ #if !defined(WIN32)
+ #include <sys/errno.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_end.c compiler/lib/loaders/elf/utils/libelf/elf_end.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_end.c	2020-04-19 08:59:34.201386585 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_end.c	2020-04-19 09:01:14.895204681 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #if !defined(WIN32)
+ #include <sys/mman.h>
+ #endif
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_errmsg.c compiler/lib/loaders/elf/utils/libelf/elf_errmsg.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_errmsg.c	2020-04-19 08:59:34.201386585 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_errmsg.c	2020-04-19 09:01:16.753207065 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ #include <stdio.h>
+ #include <string.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_errno.c compiler/lib/loaders/elf/utils/libelf/elf_errno.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_errno.c	2020-04-19 08:59:34.201386585 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_errno.c	2020-04-19 09:01:18.669209528 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_fill.c compiler/lib/loaders/elf/utils/libelf/elf_fill.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_fill.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_fill.c	2020-04-19 09:01:21.109212667 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_flag.c compiler/lib/loaders/elf/utils/libelf/elf_flag.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_flag.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_flag.c	2020-04-19 09:01:23.376215579 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_getarhdr.c compiler/lib/loaders/elf/utils/libelf/elf_getarhdr.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_getarhdr.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_getarhdr.c	2020-04-19 09:01:25.414218197 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_getarsym.c compiler/lib/loaders/elf/utils/libelf/elf_getarsym.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_getarsym.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_getarsym.c	2020-04-19 09:01:27.575220978 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_getbase.c compiler/lib/loaders/elf/utils/libelf/elf_getbase.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_getbase.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_getbase.c	2020-04-19 09:01:29.963224043 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_getident.c compiler/lib/loaders/elf/utils/libelf/elf_getident.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_getident.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_getident.c	2020-04-19 09:01:31.912226551 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <ar.h>
+ #include <assert.h>
+ #include <libelf.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_hash.c compiler/lib/loaders/elf/utils/libelf/elf_hash.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_hash.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_hash.c	2020-04-19 09:01:33.877229069 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ #include "_libelf_config.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_kind.c compiler/lib/loaders/elf/utils/libelf/elf_kind.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_kind.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_kind.c	2020-04-19 09:01:35.940231721 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_memory.c compiler/lib/loaders/elf/utils/libelf/elf_memory.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_memory.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_memory.c	2020-04-19 09:01:38.171234596 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <ar.h>
+ #include <libelf.h>
+ #include <string.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_next.c compiler/lib/loaders/elf/utils/libelf/elf_next.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_next.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_next.c	2020-04-19 09:01:40.063237028 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <ar.h>
+ #include <assert.h>
+ #include <libelf.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_phnum.c compiler/lib/loaders/elf/utils/libelf/elf_phnum.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_phnum.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_phnum.c	2020-04-19 09:01:42.480240134 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <ar.h>
+ #include <libelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_rand.c compiler/lib/loaders/elf/utils/libelf/elf_rand.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_rand.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_rand.c	2020-04-19 09:01:45.061243452 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <ar.h>
+ #include <libelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_rawfile.c compiler/lib/loaders/elf/utils/libelf/elf_rawfile.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_rawfile.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_rawfile.c	2020-04-19 09:01:46.988245928 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_scn.c compiler/lib/loaders/elf/utils/libelf/elf_scn.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_scn.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_scn.c	2020-04-19 09:00:19.724298403 -0400
+@@ -24,8 +24,7 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-#include <sys/queue.h>
++#include "sys_queue.h"
+ 
+ #include <assert.h>
+ #include <errno.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_shnum.c compiler/lib/loaders/elf/utils/libelf/elf_shnum.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_shnum.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_shnum.c	2020-04-19 09:01:51.763252060 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <ar.h>
+ #include <libelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_shstrndx.c compiler/lib/loaders/elf/utils/libelf/elf_shstrndx.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_shstrndx.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_shstrndx.c	2020-04-19 09:01:53.532254340 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <ar.h>
+ #include <libelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_version.c compiler/lib/loaders/elf/utils/libelf/elf_version.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_version.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_version.c	2020-04-19 09:02:01.337264370 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf.h compiler/lib/loaders/elf/utils/libelf/gelf.h
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf.h	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf.h	2020-04-19 09:04:29.669455020 -0400
+@@ -29,8 +29,6 @@
+ #ifndef	_GELF_H_
+ #define	_GELF_H_
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ typedef Elf64_Addr	GElf_Addr;	/* Addresses */
+@@ -72,7 +70,9 @@
+ #define	GELF_ST_TYPE			ELF64_ST_TYPE
+ #define	GELF_ST_VISIBILITY		ELF64_ST_VISIBILITY
+ 
+-__BEGIN_DECLS
++#ifdef __cplusplus
++extern "C" {
++#endif
+ long		gelf_checksum(Elf *_elf);
+ size_t		gelf_fsize(Elf *_elf, Elf_Type _type, size_t _count,
+ 			unsigned int _version);
+@@ -109,6 +109,8 @@
+ int		gelf_update_move(Elf_Data *_dst, int _index, GElf_Move *_src);
+ int		gelf_update_syminfo(Elf_Data *_dst, int _index, GElf_Syminfo *_src);
+ #endif
+-__END_DECLS
++#ifdef __cplusplus
++}
++#endif
+ 
+ #endif	/* _GELF_H_ */
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_cap.c compiler/lib/loaders/elf/utils/libelf/gelf_cap.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_cap.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_cap.c	2020-04-19 09:02:05.429269632 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_checksum.c compiler/lib/loaders/elf/utils/libelf/gelf_checksum.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_checksum.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_checksum.c	2020-04-19 09:02:08.192273183 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <gelf.h>
+ #include <libelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_dyn.c compiler/lib/loaders/elf/utils/libelf/gelf_dyn.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_dyn.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_dyn.c	2020-04-19 09:02:10.020275525 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_ehdr.c compiler/lib/loaders/elf/utils/libelf/gelf_ehdr.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_ehdr.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_ehdr.c	2020-04-19 09:02:11.882277926 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ #include <libelf.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_fsize.c compiler/lib/loaders/elf/utils/libelf/gelf_fsize.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_fsize.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_fsize.c	2020-04-19 09:02:14.139280827 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <gelf.h>
+ #include <libelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_getclass.c compiler/lib/loaders/elf/utils/libelf/gelf_getclass.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_getclass.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_getclass.c	2020-04-19 09:02:17.269284848 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <gelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_move.c compiler/lib/loaders/elf/utils/libelf/gelf_move.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_move.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_move.c	2020-04-19 09:02:18.974287034 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_phdr.c compiler/lib/loaders/elf/utils/libelf/gelf_phdr.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_phdr.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_phdr.c	2020-04-19 09:02:20.676289227 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <gelf.h>
+ #include <libelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_rel.c compiler/lib/loaders/elf/utils/libelf/gelf_rel.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_rel.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_rel.c	2020-04-19 09:02:23.177292435 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_rela.c compiler/lib/loaders/elf/utils/libelf/gelf_rela.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_rela.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_rela.c	2020-04-19 09:02:25.246295100 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_shdr.c compiler/lib/loaders/elf/utils/libelf/gelf_shdr.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_shdr.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_shdr.c	2020-04-19 09:02:28.325299060 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ #include <libelf.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_sym.c compiler/lib/loaders/elf/utils/libelf/gelf_sym.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_sym.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_sym.c	2020-04-19 09:02:30.113301356 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_syminfo.c compiler/lib/loaders/elf/utils/libelf/gelf_syminfo.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_syminfo.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_syminfo.c	2020-04-19 09:02:31.906303662 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_symshndx.c compiler/lib/loaders/elf/utils/libelf/gelf_symshndx.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_symshndx.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_symshndx.c	2020-04-19 09:02:33.626305873 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_xlate.c compiler/lib/loaders/elf/utils/libelf/gelf_xlate.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_xlate.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_xlate.c	2020-04-19 09:02:35.921308822 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <gelf.h>
+ #include <libelf.h>
+ #include <string.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf.h compiler/lib/loaders/elf/utils/libelf/libelf.h
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf.h	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf.h	2020-04-19 09:04:38.760466706 -0400
+@@ -30,7 +30,7 @@
+ #define	_LIBELF_H_
+ 
+ #include <sys/types.h>
+-#include <sys/queue.h>
++#include "sys_queue.h"
+ #include <elfdefinitions.h>
+ #ifndef EM_HSAIL
+ #define EM_HSAIL 0xAF5A
+@@ -187,7 +187,9 @@
+ #define	ELF_F_ARCHIVE	   0x100U /* archive creation */
+ #define	ELF_F_ARCHIVE_SYSV 0x200U /* SYSV style archive */
+ 
+-__BEGIN_DECLS
++#ifdef __cplusplus
++extern "C" {
++#endif
+ Elf		*elf_begin(int _fd, Elf_Cmd _cmd, Elf *_elf, Elf_Mem *_mem);
+ int		elf_cntl(Elf *_elf, Elf_Cmd _cmd);
+ int		elf_end(Elf *_elf);
+@@ -257,6 +259,8 @@
+ 			unsigned int _enc);
+ Elf_Data	*elf64_xlatetom(Elf_Data *_dst, const Elf_Data *_src,
+ 			unsigned int _enc);
+-__END_DECLS
++#ifdef __cplusplus
++}
++#endif
+ 
+ #endif	/* _LIBELF_H_ */
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_align.c compiler/lib/loaders/elf/utils/libelf/libelf_align.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_align.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_align.c	2020-04-19 09:02:40.660314911 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <sys/types.h>
+ 
+ #include <libelf.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_allocate.c compiler/lib/loaders/elf/utils/libelf/libelf_allocate.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_allocate.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_allocate.c	2020-04-19 09:02:43.079318019 -0400
+@@ -28,8 +28,6 @@
+  * Internal APIs
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #if !defined(WIN32)
+ #include <sys/errno.h>
+ #endif
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_ar.c compiler/lib/loaders/elf/utils/libelf/libelf_ar.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_ar.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_ar.c	2020-04-19 09:02:44.763320187 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <ctype.h>
+ #include <libelf.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_ar_util.c compiler/lib/loaders/elf/utils/libelf/libelf_ar_util.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_ar_util.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_ar_util.c	2020-04-19 09:02:46.461322369 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <libelf.h>
+ #include <stdlib.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_checksum.c compiler/lib/loaders/elf/utils/libelf/libelf_checksum.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_checksum.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_checksum.c	2020-04-19 09:02:48.645325173 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <gelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_convert.c compiler/lib/loaders/elf/utils/libelf/libelf_convert.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_convert.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_convert.c	2020-04-19 09:02:50.883328053 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <libelf.h>
+ #include <string.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_data.c compiler/lib/loaders/elf/utils/libelf/libelf_data.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_data.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_data.c	2020-04-19 09:02:52.951330708 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_ehdr.c compiler/lib/loaders/elf/utils/libelf/libelf_ehdr.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_ehdr.c	2020-04-19 08:59:34.204386579 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_ehdr.c	2020-04-19 09:02:55.176333563 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ #include <libelf.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_extended.c compiler/lib/loaders/elf/utils/libelf/libelf_extended.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_extended.c	2020-04-19 08:59:34.204386579 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_extended.c	2020-04-19 09:02:57.932337110 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <libelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_msize.c compiler/lib/loaders/elf/utils/libelf/libelf_msize.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_msize.c	2020-04-19 08:59:34.204386579 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_msize.c	2020-04-19 09:03:02.201342598 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <libelf.h>
+ #include <string.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_phdr.c compiler/lib/loaders/elf/utils/libelf/libelf_phdr.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_phdr.c	2020-04-19 08:59:34.204386579 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_phdr.c	2020-04-19 09:03:04.194345160 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ #include <libelf.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_shdr.c compiler/lib/loaders/elf/utils/libelf/libelf_shdr.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_shdr.c	2020-04-19 08:59:34.204386579 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_shdr.c	2020-04-19 09:03:05.795347218 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <gelf.h>
+ #include <libelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_xlate.c compiler/lib/loaders/elf/utils/libelf/libelf_xlate.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_xlate.c	2020-04-19 08:59:34.204386579 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_xlate.c	2020-04-19 09:03:09.472351944 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <libelf.h>
+ 
diff --git a/srcpkgs/rocm-opencl-runtime/files/runtime-musl.patch b/srcpkgs/rocm-opencl-runtime/files/runtime-musl.patch
new file mode 100644
index 00000000000..ea18e90e09c
--- /dev/null
+++ b/srcpkgs/rocm-opencl-runtime/files/runtime-musl.patch
@@ -0,0 +1,11 @@
+--- runtime/os/os_posix.cpp.orig	2020-04-19 09:13:51.701982901 -0400
++++ runtime/os/os_posix.cpp	2020-04-19 09:14:04.156947422 -0400
+@@ -44,6 +44,8 @@
+ #include <algorithm>
+ #include <mutex>
+ 
++#include <libgen.h> // for basename
++
+ 
+ namespace amd {
+ 
diff --git a/srcpkgs/rocm-opencl-runtime/files/sys_queue.h b/srcpkgs/rocm-opencl-runtime/files/sys_queue.h
new file mode 100644
index 00000000000..daf4553d33e
--- /dev/null
+++ b/srcpkgs/rocm-opencl-runtime/files/sys_queue.h
@@ -0,0 +1,574 @@
+/*
+ * Copyright (c) 1991, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *	@(#)queue.h	8.5 (Berkeley) 8/20/94
+ */
+
+#ifndef	_SYS_QUEUE_H_
+#define	_SYS_QUEUE_H_
+
+/*
+ * This file defines five types of data structures: singly-linked lists,
+ * lists, simple queues, tail queues, and circular queues.
+ *
+ * A singly-linked list is headed by a single forward pointer. The
+ * elements are singly linked for minimum space and pointer manipulation
+ * overhead at the expense of O(n) removal for arbitrary elements. New
+ * elements can be added to the list after an existing element or at the
+ * head of the list.  Elements being removed from the head of the list
+ * should use the explicit macro for this purpose for optimum
+ * efficiency. A singly-linked list may only be traversed in the forward
+ * direction.  Singly-linked lists are ideal for applications with large
+ * datasets and few or no removals or for implementing a LIFO queue.
+ *
+ * A list is headed by a single forward pointer (or an array of forward
+ * pointers for a hash table header). The elements are doubly linked
+ * so that an arbitrary element can be removed without a need to
+ * traverse the list. New elements can be added to the list before
+ * or after an existing element or at the head of the list. A list
+ * may only be traversed in the forward direction.
+ *
+ * A simple queue is headed by a pair of pointers, one the head of the
+ * list and the other to the tail of the list. The elements are singly
+ * linked to save space, so elements can only be removed from the
+ * head of the list. New elements can be added to the list after
+ * an existing element, at the head of the list, or at the end of the
+ * list. A simple queue may only be traversed in the forward direction.
+ *
+ * A tail queue is headed by a pair of pointers, one to the head of the
+ * list and the other to the tail of the list. The elements are doubly
+ * linked so that an arbitrary element can be removed without a need to
+ * traverse the list. New elements can be added to the list before or
+ * after an existing element, at the head of the list, or at the end of
+ * the list. A tail queue may be traversed in either direction.
+ *
+ * A circle queue is headed by a pair of pointers, one to the head of the
+ * list and the other to the tail of the list. The elements are doubly
+ * linked so that an arbitrary element can be removed without a need to
+ * traverse the list. New elements can be added to the list before or after
+ * an existing element, at the head of the list, or at the end of the list.
+ * A circle queue may be traversed in either direction, but has a more
+ * complex end of list detection.
+ *
+ * For details on the use of these macros, see the queue(3) manual page.
+ */
+
+/*
+ * List definitions.
+ */
+#define	LIST_HEAD(name, type)						\
+struct name {								\
+	struct type *lh_first;	/* first element */			\
+}
+
+#define	LIST_HEAD_INITIALIZER(head)					\
+	{ NULL }
+
+#define	LIST_ENTRY(type)						\
+struct {								\
+	struct type *le_next;	/* next element */			\
+	struct type **le_prev;	/* address of previous next element */	\
+}
+
+/*
+ * List functions.
+ */
+#define	LIST_INIT(head) do {						\
+	(head)->lh_first = NULL;					\
+} while (/*CONSTCOND*/0)
+
+#define	LIST_INSERT_AFTER(listelm, elm, field) do {			\
+	if (((elm)->field.le_next = (listelm)->field.le_next) != NULL)	\
+		(listelm)->field.le_next->field.le_prev =		\
+		    &(elm)->field.le_next;				\
+	(listelm)->field.le_next = (elm);				\
+	(elm)->field.le_prev = &(listelm)->field.le_next;		\
+} while (/*CONSTCOND*/0)
+
+#define	LIST_INSERT_BEFORE(listelm, elm, field) do {			\
+	(elm)->field.le_prev = (listelm)->field.le_prev;		\
+	(elm)->field.le_next = (listelm);				\
+	*(listelm)->field.le_prev = (elm);				\
+	(listelm)->field.le_prev = &(elm)->field.le_next;		\
+} while (/*CONSTCOND*/0)
+
+#define	LIST_INSERT_HEAD(head, elm, field) do {				\
+	if (((elm)->field.le_next = (head)->lh_first) != NULL)		\
+		(head)->lh_first->field.le_prev = &(elm)->field.le_next;\
+	(head)->lh_first = (elm);					\
+	(elm)->field.le_prev = &(head)->lh_first;			\
+} while (/*CONSTCOND*/0)
+
+#define	LIST_REMOVE(elm, field) do {					\
+	if ((elm)->field.le_next != NULL)				\
+		(elm)->field.le_next->field.le_prev = 			\
+		    (elm)->field.le_prev;				\
+	*(elm)->field.le_prev = (elm)->field.le_next;			\
+} while (/*CONSTCOND*/0)
+
+#define	LIST_FOREACH(var, head, field)					\
+	for ((var) = ((head)->lh_first);				\
+		(var);							\
+		(var) = ((var)->field.le_next))
+
+/*
+ * List access methods.
+ */
+#define	LIST_EMPTY(head)		((head)->lh_first == NULL)
+#define	LIST_FIRST(head)		((head)->lh_first)
+#define	LIST_NEXT(elm, field)		((elm)->field.le_next)
+
+
+/*
+ * Singly-linked List definitions.
+ */
+#define	SLIST_HEAD(name, type)						\
+struct name {								\
+	struct type *slh_first;	/* first element */			\
+}
+
+#define	SLIST_HEAD_INITIALIZER(head)					\
+	{ NULL }
+
+#define	SLIST_ENTRY(type)						\
+struct {								\
+	struct type *sle_next;	/* next element */			\
+}
+
+/*
+ * Singly-linked List functions.
+ */
+#define	SLIST_INIT(head) do {						\
+	(head)->slh_first = NULL;					\
+} while (/*CONSTCOND*/0)
+
+#define	SLIST_INSERT_AFTER(slistelm, elm, field) do {			\
+	(elm)->field.sle_next = (slistelm)->field.sle_next;		\
+	(slistelm)->field.sle_next = (elm);				\
+} while (/*CONSTCOND*/0)
+
+#define	SLIST_INSERT_HEAD(head, elm, field) do {			\
+	(elm)->field.sle_next = (head)->slh_first;			\
+	(head)->slh_first = (elm);					\
+} while (/*CONSTCOND*/0)
+
+#define	SLIST_REMOVE_HEAD(head, field) do {				\
+	(head)->slh_first = (head)->slh_first->field.sle_next;		\
+} while (/*CONSTCOND*/0)
+
+#define	SLIST_REMOVE(head, elm, type, field) do {			\
+	if ((head)->slh_first == (elm)) {				\
+		SLIST_REMOVE_HEAD((head), field);			\
+	}								\
+	else {								\
+		struct type *curelm = (head)->slh_first;		\
+		while(curelm->field.sle_next != (elm))			\
+			curelm = curelm->field.sle_next;		\
+		curelm->field.sle_next =				\
+		    curelm->field.sle_next->field.sle_next;		\
+	}								\
+} while (/*CONSTCOND*/0)
+
+#define	SLIST_FOREACH(var, head, field)					\
+	for((var) = (head)->slh_first; (var); (var) = (var)->field.sle_next)
+
+/*
+ * Singly-linked List access methods.
+ */
+#define	SLIST_EMPTY(head)	((head)->slh_first == NULL)
+#define	SLIST_FIRST(head)	((head)->slh_first)
+#define	SLIST_NEXT(elm, field)	((elm)->field.sle_next)
+
+
+/*
+ * Singly-linked Tail queue declarations.
+ */
+#define	STAILQ_HEAD(name, type)					\
+struct name {								\
+	struct type *stqh_first;	/* first element */			\
+	struct type **stqh_last;	/* addr of last next element */		\
+}
+
+#define	STAILQ_HEAD_INITIALIZER(head)					\
+	{ NULL, &(head).stqh_first }
+
+#define	STAILQ_ENTRY(type)						\
+struct {								\
+	struct type *stqe_next;	/* next element */			\
+}
+
+/*
+ * Singly-linked Tail queue functions.
+ */
+#define	STAILQ_INIT(head) do {						\
+	(head)->stqh_first = NULL;					\
+	(head)->stqh_last = &(head)->stqh_first;				\
+} while (/*CONSTCOND*/0)
+
+#define	STAILQ_INSERT_HEAD(head, elm, field) do {			\
+	if (((elm)->field.stqe_next = (head)->stqh_first) == NULL)	\
+		(head)->stqh_last = &(elm)->field.stqe_next;		\
+	(head)->stqh_first = (elm);					\
+} while (/*CONSTCOND*/0)
+
+#define	STAILQ_INSERT_TAIL(head, elm, field) do {			\
+	(elm)->field.stqe_next = NULL;					\
+	*(head)->stqh_last = (elm);					\
+	(head)->stqh_last = &(elm)->field.stqe_next;			\
+} while (/*CONSTCOND*/0)
+
+#define	STAILQ_INSERT_AFTER(head, listelm, elm, field) do {		\
+	if (((elm)->field.stqe_next = (listelm)->field.stqe_next) == NULL)\
+		(head)->stqh_last = &(elm)->field.stqe_next;		\
+	(listelm)->field.stqe_next = (elm);				\
+} while (/*CONSTCOND*/0)
+
+#define	STAILQ_REMOVE_HEAD(head, field) do {				\
+	if (((head)->stqh_first = (head)->stqh_first->field.stqe_next) == NULL) \
+		(head)->stqh_last = &(head)->stqh_first;			\
+} while (/*CONSTCOND*/0)
+
+#define	STAILQ_REMOVE(head, elm, type, field) do {			\
+	if ((head)->stqh_first == (elm)) {				\
+		STAILQ_REMOVE_HEAD((head), field);			\
+	} else {							\
+		struct type *curelm = (head)->stqh_first;		\
+		while (curelm->field.stqe_next != (elm))			\
+			curelm = curelm->field.stqe_next;		\
+		if ((curelm->field.stqe_next =				\
+			curelm->field.stqe_next->field.stqe_next) == NULL) \
+			    (head)->stqh_last = &(curelm)->field.stqe_next; \
+	}								\
+} while (/*CONSTCOND*/0)
+
+#define	STAILQ_FOREACH(var, head, field)				\
+	for ((var) = ((head)->stqh_first);				\
+		(var);							\
+		(var) = ((var)->field.stqe_next))
+
+#define	STAILQ_CONCAT(head1, head2) do {				\
+	if (!STAILQ_EMPTY((head2))) {					\
+		*(head1)->stqh_last = (head2)->stqh_first;		\
+		(head1)->stqh_last = (head2)->stqh_last;		\
+		STAILQ_INIT((head2));					\
+	}								\
+} while (/*CONSTCOND*/0)
+
+/*
+ * Singly-linked Tail queue access methods.
+ */
+#define	STAILQ_EMPTY(head)	((head)->stqh_first == NULL)
+#define	STAILQ_FIRST(head)	((head)->stqh_first)
+#define	STAILQ_NEXT(elm, field)	((elm)->field.stqe_next)
+
+
+/*
+ * Simple queue definitions.
+ */
+#define	SIMPLEQ_HEAD(name, type)					\
+struct name {								\
+	struct type *sqh_first;	/* first element */			\
+	struct type **sqh_last;	/* addr of last next element */		\
+}
+
+#define	SIMPLEQ_HEAD_INITIALIZER(head)					\
+	{ NULL, &(head).sqh_first }
+
+#define	SIMPLEQ_ENTRY(type)						\
+struct {								\
+	struct type *sqe_next;	/* next element */			\
+}
+
+/*
+ * Simple queue functions.
+ */
+#define	SIMPLEQ_INIT(head) do {						\
+	(head)->sqh_first = NULL;					\
+	(head)->sqh_last = &(head)->sqh_first;				\
+} while (/*CONSTCOND*/0)
+
+#define	SIMPLEQ_INSERT_HEAD(head, elm, field) do {			\
+	if (((elm)->field.sqe_next = (head)->sqh_first) == NULL)	\
+		(head)->sqh_last = &(elm)->field.sqe_next;		\
+	(head)->sqh_first = (elm);					\
+} while (/*CONSTCOND*/0)
+
+#define	SIMPLEQ_INSERT_TAIL(head, elm, field) do {			\
+	(elm)->field.sqe_next = NULL;					\
+	*(head)->sqh_last = (elm);					\
+	(head)->sqh_last = &(elm)->field.sqe_next;			\
+} while (/*CONSTCOND*/0)
+
+#define	SIMPLEQ_INSERT_AFTER(head, listelm, elm, field) do {		\
+	if (((elm)->field.sqe_next = (listelm)->field.sqe_next) == NULL)\
+		(head)->sqh_last = &(elm)->field.sqe_next;		\
+	(listelm)->field.sqe_next = (elm);				\
+} while (/*CONSTCOND*/0)
+
+#define	SIMPLEQ_REMOVE_HEAD(head, field) do {				\
+	if (((head)->sqh_first = (head)->sqh_first->field.sqe_next) == NULL) \
+		(head)->sqh_last = &(head)->sqh_first;			\
+} while (/*CONSTCOND*/0)
+
+#define	SIMPLEQ_REMOVE(head, elm, type, field) do {			\
+	if ((head)->sqh_first == (elm)) {				\
+		SIMPLEQ_REMOVE_HEAD((head), field);			\
+	} else {							\
+		struct type *curelm = (head)->sqh_first;		\
+		while (curelm->field.sqe_next != (elm))			\
+			curelm = curelm->field.sqe_next;		\
+		if ((curelm->field.sqe_next =				\
+			curelm->field.sqe_next->field.sqe_next) == NULL) \
+			    (head)->sqh_last = &(curelm)->field.sqe_next; \
+	}								\
+} while (/*CONSTCOND*/0)
+
+#define	SIMPLEQ_FOREACH(var, head, field)				\
+	for ((var) = ((head)->sqh_first);				\
+		(var);							\
+		(var) = ((var)->field.sqe_next))
+
+/*
+ * Simple queue access methods.
+ */
+#define	SIMPLEQ_EMPTY(head)		((head)->sqh_first == NULL)
+#define	SIMPLEQ_FIRST(head)		((head)->sqh_first)
+#define	SIMPLEQ_NEXT(elm, field)	((elm)->field.sqe_next)
+
+
+/*
+ * Tail queue definitions.
+ */
+#define	_TAILQ_HEAD(name, type, qual)					\
+struct name {								\
+	qual type *tqh_first;		/* first element */		\
+	qual type *qual *tqh_last;	/* addr of last next element */	\
+}
+#define TAILQ_HEAD(name, type)	_TAILQ_HEAD(name, struct type,)
+
+#define	TAILQ_HEAD_INITIALIZER(head)					\
+	{ NULL, &(head).tqh_first }
+
+#define	_TAILQ_ENTRY(type, qual)					\
+struct {								\
+	qual type *tqe_next;		/* next element */		\
+	qual type *qual *tqe_prev;	/* address of previous next element */\
+}
+#define TAILQ_ENTRY(type)	_TAILQ_ENTRY(struct type,)
+
+/*
+ * Tail queue functions.
+ */
+#define	TAILQ_INIT(head) do {						\
+	(head)->tqh_first = NULL;					\
+	(head)->tqh_last = &(head)->tqh_first;				\
+} while (/*CONSTCOND*/0)
+
+#define	TAILQ_INSERT_HEAD(head, elm, field) do {			\
+	if (((elm)->field.tqe_next = (head)->tqh_first) != NULL)	\
+		(head)->tqh_first->field.tqe_prev =			\
+		    &(elm)->field.tqe_next;				\
+	else								\
+		(head)->tqh_last = &(elm)->field.tqe_next;		\
+	(head)->tqh_first = (elm);					\
+	(elm)->field.tqe_prev = &(head)->tqh_first;			\
+} while (/*CONSTCOND*/0)
+
+#define	TAILQ_INSERT_TAIL(head, elm, field) do {			\
+	(elm)->field.tqe_next = NULL;					\
+	(elm)->field.tqe_prev = (head)->tqh_last;			\
+	*(head)->tqh_last = (elm);					\
+	(head)->tqh_last = &(elm)->field.tqe_next;			\
+} while (/*CONSTCOND*/0)
+
+#define	TAILQ_INSERT_AFTER(head, listelm, elm, field) do {		\
+	if (((elm)->field.tqe_next = (listelm)->field.tqe_next) != NULL)\
+		(elm)->field.tqe_next->field.tqe_prev = 		\
+		    &(elm)->field.tqe_next;				\
+	else								\
+		(head)->tqh_last = &(elm)->field.tqe_next;		\
+	(listelm)->field.tqe_next = (elm);				\
+	(elm)->field.tqe_prev = &(listelm)->field.tqe_next;		\
+} while (/*CONSTCOND*/0)
+
+#define	TAILQ_INSERT_BEFORE(listelm, elm, field) do {			\
+	(elm)->field.tqe_prev = (listelm)->field.tqe_prev;		\
+	(elm)->field.tqe_next = (listelm);				\
+	*(listelm)->field.tqe_prev = (elm);				\
+	(listelm)->field.tqe_prev = &(elm)->field.tqe_next;		\
+} while (/*CONSTCOND*/0)
+
+#define	TAILQ_REMOVE(head, elm, field) do {				\
+	if (((elm)->field.tqe_next) != NULL)				\
+		(elm)->field.tqe_next->field.tqe_prev = 		\
+		    (elm)->field.tqe_prev;				\
+	else								\
+		(head)->tqh_last = (elm)->field.tqe_prev;		\
+	*(elm)->field.tqe_prev = (elm)->field.tqe_next;			\
+} while (/*CONSTCOND*/0)
+
+#define	TAILQ_FOREACH(var, head, field)					\
+	for ((var) = ((head)->tqh_first);				\
+		(var);							\
+		(var) = ((var)->field.tqe_next))
+
+#define	TAILQ_FOREACH_REVERSE(var, head, headname, field)		\
+	for ((var) = (*(((struct headname *)((head)->tqh_last))->tqh_last));	\
+		(var);							\
+		(var) = (*(((struct headname *)((var)->field.tqe_prev))->tqh_last)))
+
+#define	TAILQ_CONCAT(head1, head2, field) do {				\
+	if (!TAILQ_EMPTY(head2)) {					\
+		*(head1)->tqh_last = (head2)->tqh_first;		\
+		(head2)->tqh_first->field.tqe_prev = (head1)->tqh_last;	\
+		(head1)->tqh_last = (head2)->tqh_last;			\
+		TAILQ_INIT((head2));					\
+	}								\
+} while (/*CONSTCOND*/0)
+
+/*
+ * Tail queue access methods.
+ */
+#define	TAILQ_EMPTY(head)		((head)->tqh_first == NULL)
+#define	TAILQ_FIRST(head)		((head)->tqh_first)
+#define	TAILQ_NEXT(elm, field)		((elm)->field.tqe_next)
+
+#define	TAILQ_LAST(head, headname) \
+	(*(((struct headname *)((head)->tqh_last))->tqh_last))
+#define	TAILQ_PREV(elm, headname, field) \
+	(*(((struct headname *)((elm)->field.tqe_prev))->tqh_last))
+
+
+/*
+ * Circular queue definitions.
+ */
+#define	CIRCLEQ_HEAD(name, type)					\
+struct name {								\
+	struct type *cqh_first;		/* first element */		\
+	struct type *cqh_last;		/* last element */		\
+}
+
+#define	CIRCLEQ_HEAD_INITIALIZER(head)					\
+	{ (void *)&head, (void *)&head }
+
+#define	CIRCLEQ_ENTRY(type)						\
+struct {								\
+	struct type *cqe_next;		/* next element */		\
+	struct type *cqe_prev;		/* previous element */		\
+}
+
+/*
+ * Circular queue functions.
+ */
+#define	CIRCLEQ_INIT(head) do {						\
+	(head)->cqh_first = (void *)(head);				\
+	(head)->cqh_last = (void *)(head);				\
+} while (/*CONSTCOND*/0)
+
+#define	CIRCLEQ_INSERT_AFTER(head, listelm, elm, field) do {		\
+	(elm)->field.cqe_next = (listelm)->field.cqe_next;		\
+	(elm)->field.cqe_prev = (listelm);				\
+	if ((listelm)->field.cqe_next == (void *)(head))		\
+		(head)->cqh_last = (elm);				\
+	else								\
+		(listelm)->field.cqe_next->field.cqe_prev = (elm);	\
+	(listelm)->field.cqe_next = (elm);				\
+} while (/*CONSTCOND*/0)
+
+#define	CIRCLEQ_INSERT_BEFORE(head, listelm, elm, field) do {		\
+	(elm)->field.cqe_next = (listelm);				\
+	(elm)->field.cqe_prev = (listelm)->field.cqe_prev;		\
+	if ((listelm)->field.cqe_prev == (void *)(head))		\
+		(head)->cqh_first = (elm);				\
+	else								\
+		(listelm)->field.cqe_prev->field.cqe_next = (elm);	\
+	(listelm)->field.cqe_prev = (elm);				\
+} while (/*CONSTCOND*/0)
+
+#define	CIRCLEQ_INSERT_HEAD(head, elm, field) do {			\
+	(elm)->field.cqe_next = (head)->cqh_first;			\
+	(elm)->field.cqe_prev = (void *)(head);				\
+	if ((head)->cqh_last == (void *)(head))				\
+		(head)->cqh_last = (elm);				\
+	else								\
+		(head)->cqh_first->field.cqe_prev = (elm);		\
+	(head)->cqh_first = (elm);					\
+} while (/*CONSTCOND*/0)
+
+#define	CIRCLEQ_INSERT_TAIL(head, elm, field) do {			\
+	(elm)->field.cqe_next = (void *)(head);				\
+	(elm)->field.cqe_prev = (head)->cqh_last;			\
+	if ((head)->cqh_first == (void *)(head))			\
+		(head)->cqh_first = (elm);				\
+	else								\
+		(head)->cqh_last->field.cqe_next = (elm);		\
+	(head)->cqh_last = (elm);					\
+} while (/*CONSTCOND*/0)
+
+#define	CIRCLEQ_REMOVE(head, elm, field) do {				\
+	if ((elm)->field.cqe_next == (void *)(head))			\
+		(head)->cqh_last = (elm)->field.cqe_prev;		\
+	else								\
+		(elm)->field.cqe_next->field.cqe_prev =			\
+		    (elm)->field.cqe_prev;				\
+	if ((elm)->field.cqe_prev == (void *)(head))			\
+		(head)->cqh_first = (elm)->field.cqe_next;		\
+	else								\
+		(elm)->field.cqe_prev->field.cqe_next =			\
+		    (elm)->field.cqe_next;				\
+} while (/*CONSTCOND*/0)
+
+#define	CIRCLEQ_FOREACH(var, head, field)				\
+	for ((var) = ((head)->cqh_first);				\
+		(var) != (const void *)(head);				\
+		(var) = ((var)->field.cqe_next))
+
+#define	CIRCLEQ_FOREACH_REVERSE(var, head, field)			\
+	for ((var) = ((head)->cqh_last);				\
+		(var) != (const void *)(head);				\
+		(var) = ((var)->field.cqe_prev))
+
+/*
+ * Circular queue access methods.
+ */
+#define	CIRCLEQ_EMPTY(head)		((head)->cqh_first == (void *)(head))
+#define	CIRCLEQ_FIRST(head)		((head)->cqh_first)
+#define	CIRCLEQ_LAST(head)		((head)->cqh_last)
+#define	CIRCLEQ_NEXT(elm, field)	((elm)->field.cqe_next)
+#define	CIRCLEQ_PREV(elm, field)	((elm)->field.cqe_prev)
+
+#define CIRCLEQ_LOOP_NEXT(head, elm, field)				\
+	(((elm)->field.cqe_next == (void *)(head))			\
+	    ? ((head)->cqh_first)					\
+	    : (elm->field.cqe_next))
+#define CIRCLEQ_LOOP_PREV(head, elm, field)				\
+	(((elm)->field.cqe_prev == (void *)(head))			\
+	    ? ((head)->cqh_last)					\
+	    : (elm->field.cqe_prev))
+
+#endif	/* sys/queue.h */
diff --git a/srcpkgs/rocm-opencl-runtime/patches/cmake.patch b/srcpkgs/rocm-opencl-runtime/patches/cmake.patch
new file mode 100644
index 00000000000..2c96b99d45a
--- /dev/null
+++ b/srcpkgs/rocm-opencl-runtime/patches/cmake.patch
@@ -0,0 +1,126 @@
+--- OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/CMakeLists.txt	2019-09-10 11:53:28.000000000 -0400
++++ OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/CMakeLists.txt	2020-04-16 20:16:13.481180757 -0400
+@@ -73,11 +73,11 @@
+ 
+ set (OPENCL_ICD_LOADER_HEADERS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/inc CACHE PATH "Path to OpenCL Headers")
+ 
+-add_library (OpenCL ${OPENCL_ICD_LOADER_SOURCES})
+-set_target_properties (OpenCL PROPERTIES VERSION "1.2" SOVERSION "1")
++add_library (OpenCL-ROCm ${OPENCL_ICD_LOADER_SOURCES})
++set_target_properties (OpenCL-ROCm PROPERTIES VERSION "1.2" SOVERSION "1")
+ 
+ if (WIN32)
+-    target_link_libraries (OpenCL cfgmgr32.lib)
++    target_link_libraries (OpenCL-ROCm cfgmgr32.lib)
+ 
+     option (OPENCL_ICD_LOADER_REQUIRE_WDK "Build with D3DKMT support, which requires the Windows WDK." ON)
+     if (OPENCL_ICD_LOADER_REQUIRE_WDK)
+@@ -92,10 +92,10 @@
+             get_filename_component(WDK_DIRECTORY ${LATEST_D3DKMT_HEADER} DIRECTORY)
+             get_filename_component(WDK_DIRECTORY ${WDK_DIRECTORY} DIRECTORY)
+             message(STATUS "Found the Windows WDK in: ${WDK_DIRECTORY}")
+-            target_compile_definitions(OpenCL PRIVATE OPENCL_ICD_LOADER_REQUIRE_WDK)
+-            target_include_directories(OpenCL PRIVATE ${WDK_DIRECTORY}/um)
+-            target_include_directories(OpenCL PRIVATE ${WDK_DIRECTORY}/km)
+-            target_include_directories(OpenCL PRIVATE ${WDK_DIRECTORY}/shared)
++	    target_compile_definitions(OpenCL-ROCm PRIVATE OPENCL_ICD_LOADER_REQUIRE_WDK)
++	    target_include_directories(OpenCL-ROCm PRIVATE ${WDK_DIRECTORY}/um)
++	    target_include_directories(OpenCL-ROCm PRIVATE ${WDK_DIRECTORY}/km)
++	    target_include_directories(OpenCL-ROCm PRIVATE ${WDK_DIRECTORY}/shared)
+         else()
+             message(FATAL_ERROR "The Windows WDK was not found. Consider disabling OPENCL_ICD_LOADER_REQUIRE_WDK. Aborting.")
+         endif()
+@@ -113,25 +113,25 @@
+     endif()
+ else()
+     if (APPLE)
+-        target_link_libraries (OpenCL ${CMAKE_THREAD_LIBS_INIT})
++        target_link_libraries (OpenCL-ROCm ${CMAKE_THREAD_LIBS_INIT})
+     else ()
+-        set_target_properties (OpenCL PROPERTIES LINK_FLAGS "-Wl,--version-script -Wl,${CMAKE_CURRENT_SOURCE_DIR}/loader/linux/icd_exports.map")
+-        target_link_libraries (OpenCL ${CMAKE_THREAD_LIBS_INIT})
++        set_target_properties (OpenCL-ROCm PROPERTIES LINK_FLAGS "-Wl,--version-script -Wl,${CMAKE_CURRENT_SOURCE_DIR}/loader/linux/icd_exports.map")
++	target_link_libraries (OpenCL-ROCm ${CMAKE_THREAD_LIBS_INIT})
+     endif ()
+ endif ()
+ 
+ include_directories (${OPENCL_ICD_LOADER_HEADERS_DIR})
+ add_definitions (-DCL_TARGET_OPENCL_VERSION=220)
+ 
+-target_include_directories (OpenCL PRIVATE ${CMAKE_CURRENT_BINARY_DIR} loader)
+-target_link_libraries (OpenCL ${CMAKE_DL_LIBS})
++target_include_directories (OpenCL-ROCm PRIVATE ${CMAKE_CURRENT_BINARY_DIR} loader)
++target_link_libraries (OpenCL-ROCm ${CMAKE_DL_LIBS})
+ 
+ include (CTest)
+ if (BUILD_TESTING)
+     add_subdirectory (test)
+ endif()
+ 
+-install (TARGETS OpenCL
++install (TARGETS OpenCL-ROCm
+     RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+     ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
+     LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
+--- OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/test/loader_test/CMakeLists.txt	2019-09-10 11:53:28.000000000 -0400
++++ OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/test/loader_test/CMakeLists.txt	2020-04-16 20:16:56.647026589 -0400
+@@ -12,4 +12,4 @@
+     test_clgl.c
+     test_image_objects.c )
+ 
+-target_link_libraries (icd_loader_test OpenCL IcdLog)
++target_link_libraries (icd_loader_test OpenCL-ROCm IcdLog)
+--- ROCm-OpenCL-Runtime-roc-3.3.0/CMakeLists.txt	2020-04-28 07:29:51.864446603 -0400
++++ ROCm-OpenCL-Runtime-roc-3.3.0/CMakeLists.txt	2020-04-28 07:32:45.245793180 -0400
+@@ -101,30 +101,30 @@
+ rocm_setup_version( VERSION "2.0.0" )
+ 
+ # MAIN package
+-install(PROGRAMS $<TARGET_FILE:clinfo>
+-        DESTINATION bin/x86_64
++install(PROGRAMS $<TARGET_FILE:rocm-clinfo>
++        DESTINATION bin
+         COMPONENT MAIN)
+ install(PROGRAMS $<TARGET_FILE:amdocl64>
+-        DESTINATION lib/x86_64
++        DESTINATION lib
+         COMPONENT MAIN)
+-install(PROGRAMS $<TARGET_FILE:OpenCL>
+-        DESTINATION lib/x86_64
++install(PROGRAMS $<TARGET_FILE:OpenCL-ROCm>
++        DESTINATION lib
+         COMPONENT MAIN)
+-install(PROGRAMS $<TARGET_SONAME_FILE:OpenCL>
+-        DESTINATION lib/x86_64
++install(PROGRAMS $<TARGET_SONAME_FILE:OpenCL-ROCm>
++        DESTINATION lib
+         COMPONENT MAIN)
+ 
+ # DEV package
+ install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/api/opencl/khronos/headers/opencl2.2/CL"
+-        DESTINATION include
++	DESTINATION include/rocm
+         COMPONENT DEV
+         USE_SOURCE_PERMISSIONS
+         PATTERN cl_d3d10.h EXCLUDE
+         PATTERN cl_d3d11.h EXCLUDE
+         PATTERN cl_dx9_media_sharing.h EXCLUDE
+         PATTERN cl_egl.h EXCLUDE)
+-install(PROGRAMS $<TARGET_LINKER_FILE:OpenCL>
+-        DESTINATION lib/x86_64
++install(PROGRAMS $<TARGET_LINKER_FILE:OpenCL-ROCm>
++        DESTINATION lib
+         COMPONENT DEV)
+ 
+ # Generic CPACK variables
+--- ROCm-OpenCL-Runtime-roc-3.3.0/tools/clinfo/CMakeLists.txt	2020-04-28 07:29:51.882446535 -0400
++++ ROCm-OpenCL-Runtime-roc-3.3.0/tools/clinfo/CMakeLists.txt	2020-04-28 07:30:05.627394732 -0400
+@@ -6,6 +6,6 @@
+ 
+ add_definitions(-DHAVE_CL2_HPP)
+ 
+-add_executable(clinfo clinfo.cpp)
++add_executable(rocm-clinfo clinfo.cpp)
+ 
+-target_link_libraries(clinfo OpenCL)
++target_link_libraries(rocm-clinfo OpenCL-ROCm)
diff --git a/srcpkgs/rocm-opencl-runtime/template b/srcpkgs/rocm-opencl-runtime/template
new file mode 100644
index 00000000000..f83c6e64149
--- /dev/null
+++ b/srcpkgs/rocm-opencl-runtime/template
@@ -0,0 +1,82 @@
+# Template file for 'rocm-opencl-runtime'
+pkgname=rocm-opencl-runtime
+version=3.3.0
+revision=1
+_ocl_icd_name="OpenCL-ICD-Loader"
+_ocl_icd_ver="6c03f8b58fafd9dd693eaac826749a5cfad515f8"
+archs="x86_64*"
+create_wrksrc=yes
+build_wrksrc="ROCm-OpenCL-Runtime-roc-${version}"
+build_style=cmake
+configure_args="-DUSE_COMGR_LIBRARY=yes"
+hostmakedepends="cmake pkg-config"
+makedepends="libglvnd-devel rocm-comgr-devel
+	roct-thunk-interface-devel rocr-runtime-devel"
+depends="rocm-comgr"
+short_desc="Radeon Open Compute OpenCL runtime"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="MIT"
+homepage="https://github.com/RadeonOpenCompute/ROCm-OpenCL-Runtime"
+_rocroot="https://github.com/RadeonOpenCompute"
+distfiles="${_rocroot}/ROCm-OpenCL-Runtime/archive/roc-${version}.tar.gz
+	${_rocroot}/rocm-cmake/archive/rocm-${version}.tar.gz
+	https://github.com/KhronosGroup/${_ocl_icd_name}/archive/${_ocl_icd_ver}.tar.gz"
+checksum="ac6999f1a491ab066286c2bd6adf50f08f831286f56e267879f9f7eced22f98e
+	76ed3ee8e56cf3246011cf7723c2abda539e1136e7e7f6909bfa45d268b8644f
+	c94d5bb6dc980c4d41d73e2b81663a19aabe494e923e2d0eec72a4c95b318438"
+nocross=yes
+
+post_patch() {
+	if [ "$XBPS_LIBC" = "musl" ]; then
+		# Copy sys/queue.h locally for MUSL builds
+		libelf_dir="compiler/lib/loaders/elf/utils/libelf"
+		cp "${FILESDIR}/sys_queue.h" "${libelf_dir}"
+
+		# Remove dependence on glibc
+		patch -Np0 < ${FILESDIR}/libelf-musl.patch
+		patch -Np0 < ${FILESDIR}/runtime-musl.patch
+		vsed -e '/glibc_functions.cpp/d' -i api/opencl/amdocl/CMakeLists.txt
+	fi
+}
+
+pre_configure() {
+	# ROCm requires a very specific Khronos ICD loader version in the tree
+	# Keep the ICD loader config in /etc/rocm/vendors to avoid conflicts
+	_ocl_icd_dir="${_ocl_icd_name}-${_ocl_icd_ver}"
+	ln -sf "${wrksrc}/${_ocl_icd_dir}" api/opencl/khronos/icd
+	vsed -i "${wrksrc}/${_ocl_icd_dir}/loader/icd_platform.h" \
+		-e 's@/etc/OpenCL/vendors/@/etc/rocm/vendors/@g'
+
+	# CMake modules probably not useful anywhere but for this build
+	ln -sf "${wrksrc}/rocm-cmake-rocm-${version}/share/rocm/cmake"/*.cmake cmake
+
+	# Fix the dlopen macro to point to versioned libamd_comgr shared object
+	vsed -i 'runtime/device/comgrctx.cpp' \
+		-e 's/\blibamd_comgr\(32\)\?.so\b/&.1/g'
+}
+
+post_install() {
+	vlicense License
+
+	# Create descriptor to allow the ICD loader to find the driver
+	_ocl_icd_dir="etc/rocm/vendors"
+	vmkdir "${_ocl_icd_dir}"
+	echo "libamdocl64.so" > "${DESTDIR}/${_ocl_icd_dir}/amdocl64.icd"
+}
+
+rocm-opencl-runtime-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/lib/libOpenCL-ROCm.so
+		vmove usr/include
+	}
+}
+
+rocm-opencl-runtime-clinfo_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - clinfo"
+	pkg_install() {
+		vmove usr/bin/rocm-clinfo
+	}
+}

^ permalink raw reply	[flat|nested] 61+ messages in thread

* Re: [PR PATCH] [Updated] New packages: ROCm core and OpenCL
  2020-04-19 13:34 [PR PATCH] New packages: ROCm core and OpenCL ahesford
                   ` (5 preceding siblings ...)
  2020-04-28 15:14 ` ahesford
@ 2020-04-28 17:34 ` ahesford
  2020-04-28 17:34 ` ahesford
                   ` (52 subsequent siblings)
  59 siblings, 0 replies; 61+ messages in thread
From: ahesford @ 2020-04-28 17:34 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 3893 bytes --]

There is an updated pull request by ahesford against master on the void-packages repository

https://github.com/ahesford/void-packages rocm
https://github.com/void-linux/void-packages/pull/21153

New packages: ROCm core and OpenCL
This PR includes several packages designed to bring the OpenCL portion of the AMD ROCm ecosystem to Void. It addresses Issue #19507. There are many other packages that AMD provides for GPGPU computing, but these can be added piecemeal as users demand.

The packages are currently only for `x86_64*`. While at least some of the packages will compile on other 64-bit architectures, I have no hardware to test. They are certainly not suitable for 32-bit architectures; some internal data structures rely on `uint64_t` values that are cast to pointers. At a
minimum, a thorough audit would be necessary to ensure that these casts are safe (e.g., that the values stored were only ever upcast from 32-bit pointers). More extensive work may be necessary to support 32-bit architectures, probably without significant benefit.

The packages successfully identify a Radeon RX 580 on an `x86_64` installation using both `clinfo` and `rocminfo` as provided. Furthermore, a version of `pyopencl` linked against these ROCm packages successfully runs a simple program that validates arithmetic on GPU-bound arrays.

There are caveats with this set of packages, almost all of which revolve around the incompatibilities between the Void-provided `ocl-icd` and the [Khronos OpenCL ICD loader](https://github.com/KhronosGroup/OpenCL-ID-Loader) required by (and built into) `rocm-opencl-runtime`.
1. All packages install into `/opt/rocm`. This keeps the environment closer to that officially sanctioned by AMD and helps avoid conflicts between other packages and those provided here. (For example, `clinfo` and the ICD loader itself.) Eventually, we may be able to move the files into `/usr`.
2. The Khronos OpenCL ICD loader built into `rocm-opencl-runtime` is an outdated, pre-release commit. If AMD can update its sources to use the release version of that loader (which has a backward-incompatible API change), we may be able to make ROCm compatible with `ocl-icd` or replace `ocl-icd` with the official Khronos loader.
3. In the meantime, to avoid `shlibs` conflicts, the OpenCL ICD loader is installed as `/opt/rocm/lib/libOpenCL-ROCm.so` (and an appropriately versioned shared library), which means that programs wishing to use the ROCm OpenCL must explicitly link against this library instead of the generic `libOpenCL.so`.
4. I do **not** recommend making any Void packages link against this specific library, because it will make those packages ROCm-only. For the time being, ROCm is intended for end-users to specifically link against. Linking Void packages against ROCm would requires the ICD loader used by ROCm be compatible with `ocl-icd`, or `ocl-icd` be replaced by the Khronos loader. However, because the Khronos loader changed its API for the release version, such a change is not yet appropriate.

Hopefully, if AMD updates its dependence on the Khronos ICD loader, we can resolve some of these caveats in the future and make ROCm a more natural Void component. For now, these packages are useful for those who need an AMD OpenCL solution and would rather custom-link software against the AMD ICD loader than hack the `amdgpu-pro` driver into an ICD compatible with `ocl-icd`.

Some patches were made to relocate some files in `/opt/rocm` and make everyting build on x86_64-musl`. Where appropriate, these patches will be pushed upstream to clean up the distribution and packaging.

Update: I pushed some new commits to update license information that triggerd an `xlint` failure. I've also disabled CI builds because they will time out on `rocm-llvm`.

A patch file from https://github.com/void-linux/void-packages/pull/21153.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-rocm-21153.patch --]
[-- Type: text/x-diff, Size: 76982 bytes --]

From 1226ae1e7c5eea64be3859bb36eee4fd8c6cccc6 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Mon, 13 Apr 2020 13:08:09 -0400
Subject: [PATCH 1/9] New package: roct-thunk-interface-3.3.0

---
 common/shlibs                                 |  1 +
 srcpkgs/roct-thunk-interface-devel            |  1 +
 .../patches/cmake-dev-libdir.patch            | 10 ++++++
 .../roct-thunk-interface/patches/musl.patch   | 29 ++++++++++++++++
 srcpkgs/roct-thunk-interface/template         | 33 +++++++++++++++++++
 5 files changed, 74 insertions(+)
 create mode 120000 srcpkgs/roct-thunk-interface-devel
 create mode 100644 srcpkgs/roct-thunk-interface/patches/cmake-dev-libdir.patch
 create mode 100644 srcpkgs/roct-thunk-interface/patches/musl.patch
 create mode 100644 srcpkgs/roct-thunk-interface/template

diff --git a/common/shlibs b/common/shlibs
index 6d39ce34c19..d89ae72ae3e 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3862,3 +3862,4 @@ libtagparser.so.9 tagparser-9.1.2_1
 libqtutilities.so.6 qtutilities-6.0.4_1
 libkdsoap.so.1.9.0 KDSoap-1.9.0_1
 libstoken.so.1 stoken-0.92_1
+libhsakmt.so.1 roct-thunk-interface-3.3.0_1
diff --git a/srcpkgs/roct-thunk-interface-devel b/srcpkgs/roct-thunk-interface-devel
new file mode 120000
index 00000000000..ac3f2cc684c
--- /dev/null
+++ b/srcpkgs/roct-thunk-interface-devel
@@ -0,0 +1 @@
+roct-thunk-interface
\ No newline at end of file
diff --git a/srcpkgs/roct-thunk-interface/patches/cmake-dev-libdir.patch b/srcpkgs/roct-thunk-interface/patches/cmake-dev-libdir.patch
new file mode 100644
index 00000000000..98c7f1e459c
--- /dev/null
+++ b/srcpkgs/roct-thunk-interface/patches/cmake-dev-libdir.patch
@@ -0,0 +1,10 @@
+--- CMakeLists.txt.old	2020-04-18 19:45:17.306081135 -0400
++++ CMakeLists.txt	2020-04-18 19:46:51.300753636 -0400
+@@ -146,6 +146,7 @@
+     COMMAND ${CMAKE_COMMAND}
+         -DSOURCE_DIR="${SOURCE_DIR}"
+         -DCMAKE_INSTALL_PREFIX="${CMAKE_INSTALL_PREFIX}"
++        -DCMAKE_INSTALL_LIBDIR="${CMAKE_INSTALL_LIBDIR}"
+         -DCPACK_RPM_PACKAGE_REQUIRES="hsakmt-roct"
+         -DCPACK_PACKAGING_INSTALL_PREFIX="${CPACK_PACKAGING_INSTALL_PREFIX}"
+         -DVERSION="${BUILD_VERSION_STRING}"
diff --git a/srcpkgs/roct-thunk-interface/patches/musl.patch b/srcpkgs/roct-thunk-interface/patches/musl.patch
new file mode 100644
index 00000000000..aeea9832411
--- /dev/null
+++ b/srcpkgs/roct-thunk-interface/patches/musl.patch
@@ -0,0 +1,29 @@
+diff -r -u old/src/libhsakmt.h new/src/libhsakmt.h
+--- src/libhsakmt.h	2020-03-04 15:00:47.000000000 -0500
++++ src/libhsakmt.h	2020-04-13 12:58:30.444865992 -0400
+@@ -54,6 +54,10 @@
+ #define CHECK_KFD_OPEN() \
+ 	do { if (kfd_open_count == 0 || hsakmt_forked) return HSAKMT_STATUS_KERNEL_IO_CHANNEL_NOT_OPENED; } while (0)
+ 
++/*On some platforms, a PAGE_SIZE macro eclipses the extern variable*/
++#ifdef PAGE_SIZE
++#undef PAGE_SIZE
++#endif
+ extern int PAGE_SIZE;
+ extern int PAGE_SHIFT;
+ 
+diff -r -u old/src/topology.c new/src/topology.c
+--- src/topology.c	2020-03-04 15:00:47.000000000 -0500
++++ src/topology.c	2020-04-13 13:01:31.209870701 -0400
+@@ -38,6 +38,11 @@
+ #include "libhsakmt.h"
+ #include "fmm.h"
+ 
++/*Needed on MUSL*/
++#ifndef MAXNAMLEN
++#define MAXNAMLEN PATH_MAX
++#endif
++
+ /* Number of memory banks added by thunk on top of topology
+  * This only includes static heaps like LDS, scratch and SVM,
+  * not for MMIO_REMAP heap. MMIO_REMAP memory bank is reported
diff --git a/srcpkgs/roct-thunk-interface/template b/srcpkgs/roct-thunk-interface/template
new file mode 100644
index 00000000000..55a1fc6074a
--- /dev/null
+++ b/srcpkgs/roct-thunk-interface/template
@@ -0,0 +1,33 @@
+# Template file for 'roct-thunk-interface'
+pkgname=roct-thunk-interface
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="ROCT-Thunk-Interface-roc-${version}"
+build_style=cmake
+make_build_target="all build-dev"
+make_install_target="install install-dev"
+hostmakedepends="cmake pkg-config"
+makedepends="pciutils-devel libnuma-devel"
+short_desc="Radeon Open Compute Thunk Interface"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="MIT"
+homepage="https://github.com/RadeonOpenCompute/ROCT-Thunk-Interface"
+distfiles="${homepage}/archive/roc-${version}.tar.gz"
+checksum=2cabe9d2cfa72031c05d11290837c476182e72d8dec2049298f691143fdd212b
+nocross=yes
+
+post_install() {
+	vlicense LICENSE.md
+}
+
+roct-thunk-interface-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove "usr/lib/*.so"
+		vmove usr/share/pkgconfig
+		vmove usr/lib/cmake
+	}
+}

From d8bb69aca8ebcd167198d858c11e7b7fa326c389 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Mon, 13 Apr 2020 15:27:27 -0400
Subject: [PATCH 2/9] New package: rocr-runtime-3.3.0

---
 common/shlibs                            |  1 +
 srcpkgs/rocr-runtime-devel               |  1 +
 srcpkgs/rocr-runtime/patches/cmake.patch | 27 +++++++++++++++++++++
 srcpkgs/rocr-runtime/template            | 30 ++++++++++++++++++++++++
 4 files changed, 59 insertions(+)
 create mode 120000 srcpkgs/rocr-runtime-devel
 create mode 100644 srcpkgs/rocr-runtime/patches/cmake.patch
 create mode 100644 srcpkgs/rocr-runtime/template

diff --git a/common/shlibs b/common/shlibs
index d89ae72ae3e..499f35752c2 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3863,3 +3863,4 @@ libqtutilities.so.6 qtutilities-6.0.4_1
 libkdsoap.so.1.9.0 KDSoap-1.9.0_1
 libstoken.so.1 stoken-0.92_1
 libhsakmt.so.1 roct-thunk-interface-3.3.0_1
+libhsa-runtime64.so.1 rocr-runtime-3.3.0_1
diff --git a/srcpkgs/rocr-runtime-devel b/srcpkgs/rocr-runtime-devel
new file mode 120000
index 00000000000..be838f22d81
--- /dev/null
+++ b/srcpkgs/rocr-runtime-devel
@@ -0,0 +1 @@
+rocr-runtime
\ No newline at end of file
diff --git a/srcpkgs/rocr-runtime/patches/cmake.patch b/srcpkgs/rocr-runtime/patches/cmake.patch
new file mode 100644
index 00000000000..93b74cd2297
--- /dev/null
+++ b/srcpkgs/rocr-runtime/patches/cmake.patch
@@ -0,0 +1,27 @@
+--- src/CMakeLists.txt.old	2020-04-18 20:01:48.549636995 -0400
++++ src/CMakeLists.txt	2020-04-18 20:04:00.177179781 -0400
+@@ -108,8 +108,8 @@
+ ## ROCr build internal versioning
+ add_definitions ( -DROCR_BUILD_ID=${PACKAGE_VERSION_STRING} )
+ 
+-## Set RUNPATH - ../../lib covers use of the legacy symlink in /hsa/lib/
+-set(CMAKE_INSTALL_RPATH "$ORIGIN;$ORIGIN/../../lib;$ORIGIN/../../lib64;$ORIGIN/../lib64")
++## Set RUNPATH
++set(CMAKE_INSTALL_RPATH "$ORIGIN;$ORIGIN/../lib")
+ 
+ ## ------------------------- Linux Compiler and Linker options -------------------------
+ set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -fexceptions -fno-rtti -fvisibility=hidden -Wno-error=sign-compare -Wno-sign-compare -Wno-write-strings -Wno-conversion-null -fno-math-errno -fno-threadsafe-statics -fmerge-all-constants -fms-extensions -Wno-error=comment -Wno-comment -Wno-error=pointer-arith -Wno-pointer-arith -Wno-error=unused-variable -Wno-error=unused-function" )
+@@ -185,11 +185,8 @@
+ add_custom_target ( hsa_lib_link2 ALL WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMAND ${CMAKE_COMMAND} -E create_symlink ../hsa/lib/${CORE_RUNTIME_LIBRARY}.so.${SO_MAJOR} ${CORE_RUNTIME_LIBRARY}-link.so.${SO_MAJOR} )
+ 
+ ## Set install information
+-install ( TARGETS ${CORE_RUNTIME_TARGET} LIBRARY DESTINATION hsa/lib )
+-install ( DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/inc/ DESTINATION hsa/include/hsa )
+-install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/hsa_include_link DESTINATION include PERMISSIONS OWNER_WRITE OWNER_READ RENAME hsa )
+-install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/${CORE_RUNTIME_LIBRARY}-link.so DESTINATION lib PERMISSIONS OWNER_WRITE OWNER_READ RENAME ${CORE_RUNTIME_LIBRARY}.so )
+-install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/${CORE_RUNTIME_LIBRARY}-link.so.${SO_MAJOR} DESTINATION lib PERMISSIONS OWNER_WRITE OWNER_READ RENAME ${CORE_RUNTIME_LIBRARY}.so.${SO_MAJOR} )
++install ( TARGETS ${CORE_RUNTIME_TARGET} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} )
++install ( DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/inc/ DESTINATION include/hsa )
+ 
+ ## Packaging directives
+ set ( CPACK_GENERATOR "DEB;RPM" CACHE STRING "Package types to build")
diff --git a/srcpkgs/rocr-runtime/template b/srcpkgs/rocr-runtime/template
new file mode 100644
index 00000000000..5ee22140f1f
--- /dev/null
+++ b/srcpkgs/rocr-runtime/template
@@ -0,0 +1,30 @@
+# Template file for 'rocr-runtime'
+pkgname=rocr-runtime
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="ROCR-Runtime-rocm-${version}"
+build_wrksrc="src"
+build_style=cmake
+hostmakedepends="cmake pkg-config"
+makedepends="roct-thunk-interface-devel elfutils-devel"
+short_desc="Radeon Open Compute HSA Runtime"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute/ROCR-Runtime"
+distfiles="${homepage}/archive/rocm-${version}.tar.gz"
+checksum=fa2d2d1f8a61d8a6952d377cf288d78c61776c3c2a666f163cafc3aa19ab0b61
+nocross=yes
+
+post_install() {
+	vlicense ../LICENSE.txt
+}
+
+rocr-runtime-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove "usr/lib/*.so"
+	}
+}

From 8094f1ed5017c36dc9129b73ed78188378a51284 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Mon, 13 Apr 2020 18:07:34 -0400
Subject: [PATCH 3/9] New package: rocm-llvm-3.3.0

---
 srcpkgs/rocm-llvm/template | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)
 create mode 100644 srcpkgs/rocm-llvm/template

diff --git a/srcpkgs/rocm-llvm/template b/srcpkgs/rocm-llvm/template
new file mode 100644
index 00000000000..26942e3ea46
--- /dev/null
+++ b/srcpkgs/rocm-llvm/template
@@ -0,0 +1,25 @@
+# Template file for 'rocm-llvm'
+pkgname=rocm-llvm
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="llvm-project-rocm-ocl-${version}"
+build_wrksrc=llvm
+build_style=cmake
+configure_args="-DCMAKE_INSTALL_PREFIX:PATH=/usr/lib/rocm-llvm
+	-DLLVM_ENABLE_PROJECTS='llvm;clang;lld' -DLLVM_TARGETS_TO_BUILD='AMDGPU'
+	-DLLVM_BUILD_DOCS=NO -DLLVM_ENABLE_OCAMLDOC=OFF
+	-DLLVM_ENABLE_SPHINX=NO -DLLVM_ENABLE_DOXYGEN=OFF
+	-DLLVM_INSTALL_UTILS=ON -DLLVM_VERSION_SUFFIX=roc -DOCAMLFIND=NO"
+hostmakedepends="cmake pkg-config python3"
+short_desc="Radeon Open Compute LLVM toolchain"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="Apache-2.0, NCSA, custom:LLVM-Exceptions"
+homepage="https://github.com/RadeonOpenCompute/llvm-project"
+distfiles="${homepage}/archive/rocm-ocl-${version}.tar.gz"
+checksum=a2bef7042e8e2f2cd8548cb246b88322e1c77188839983dcac8312d56f544dc8
+nocross=yes
+
+post_install() {
+	vlicense LICENSE.TXT
+}

From 0e7977b668140e095f21839a24923005b3029c81 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Tue, 14 Apr 2020 10:25:31 -0400
Subject: [PATCH 4/9] New package: rocm-device-libs-3.3.0

---
 srcpkgs/rocm-device-libs/template | 37 +++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)
 create mode 100644 srcpkgs/rocm-device-libs/template

diff --git a/srcpkgs/rocm-device-libs/template b/srcpkgs/rocm-device-libs/template
new file mode 100644
index 00000000000..fcb4eb0d53e
--- /dev/null
+++ b/srcpkgs/rocm-device-libs/template
@@ -0,0 +1,37 @@
+# Template file for 'rocm-device-libs'
+pkgname=rocm-device-libs
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="ROCm-Device-Libs-rocm-ocl-${version}"
+build_style=cmake
+configure_args="-DLLVM_DIR:PATH=/usr/lib/rocm-llvm
+	-DCMAKE_INSTALL_LIBDIR:PATH=lib/rocm-device-libs"
+hostmakedepends="cmake rocm-llvm"
+short_desc="Radeon Open Compute device libraries"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute/ROCm-Device-Libs"
+distfiles="${homepage}/archive/rocm-ocl-${version}.tar.gz"
+checksum=706b08230790e08ca6a7a2fb7687d6131fd39a562148340e00fa37a6c06769c5
+nocross=yes
+
+pre_configure() {
+	# Put bytecodes in a lib/ subdirectory
+	vsed -i Packages.cmake -e 's@/lib/@/${CMAKE_INSTALL_LIBDIR}/@'
+	vsed -i OCL.cmake -e 's@DESTINATION lib$@DESTINATION ${CMAKE_INSTALL_LIBDIR}@'
+
+	# Build the prepare-builtins executable with native compiler
+	mkdir -p utils/build
+	cd utils/build
+	_prepare_builtins="$PWD/prepare-builtins/prepare-builtins"
+	cmake ${configure_args} ..
+	make ${makejobs}
+
+	# Add path to prepare-builtins for cmake
+	configure_args+=" -DPREPARE_BUILTINS='${_prepare_builtins}'"
+}
+
+post_install() {
+	vlicense LICENSE
+}

From 81355a023645398d9f99fcd99988a9f61f5f0777 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Mon, 13 Apr 2020 18:30:00 -0400
Subject: [PATCH 5/9] New package: rocm-comgr-3.3.0

---
 common/shlibs               |  1 +
 srcpkgs/rocm-comgr-devel    |  1 +
 srcpkgs/rocm-comgr/template | 32 ++++++++++++++++++++++++++++++++
 3 files changed, 34 insertions(+)
 create mode 120000 srcpkgs/rocm-comgr-devel
 create mode 100644 srcpkgs/rocm-comgr/template

diff --git a/common/shlibs b/common/shlibs
index 499f35752c2..a53de3cf9e0 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3864,3 +3864,4 @@ libkdsoap.so.1.9.0 KDSoap-1.9.0_1
 libstoken.so.1 stoken-0.92_1
 libhsakmt.so.1 roct-thunk-interface-3.3.0_1
 libhsa-runtime64.so.1 rocr-runtime-3.3.0_1
+libamd_comgr.so.1 rocm-comgr-3.3.0_1
diff --git a/srcpkgs/rocm-comgr-devel b/srcpkgs/rocm-comgr-devel
new file mode 120000
index 00000000000..3f5ce255e07
--- /dev/null
+++ b/srcpkgs/rocm-comgr-devel
@@ -0,0 +1 @@
+rocm-comgr
\ No newline at end of file
diff --git a/srcpkgs/rocm-comgr/template b/srcpkgs/rocm-comgr/template
new file mode 100644
index 00000000000..c228bcd4d1f
--- /dev/null
+++ b/srcpkgs/rocm-comgr/template
@@ -0,0 +1,32 @@
+# Template file for 'rocm-comgr'
+pkgname=rocm-comgr
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="ROCm-CompilerSupport-rocm-${version}"
+build_wrksrc="lib/comgr"
+build_style=cmake
+configure_args="-DClang_DIR:PATH=/usr/lib/rocm-llvm/lib/cmake/clang"
+hostmakedepends="cmake pkg-config rocm-llvm"
+makedepends="rocm-device-libs"
+short_desc="Radeon Open Compute Code Object Manager"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="BSD-3-Clause"
+homepage="https://github.com/RadeonOpenCompute/ROCm-CompilerSupport"
+distfiles="${homepage}/archive/rocm-${version}.tar.gz"
+checksum=01e2524e0f28ecd6f46c9720f279207de935d826b0172158792aa3ec86af9ca7
+nocross=yes
+
+post_install() {
+	vlicense LICENSE.txt
+}
+
+rocm-comgr-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove "usr/lib/*.so"
+		vmove usr/lib/cmake
+	}
+}

From 1dda7453d2c6b722fc45c445c49bebd948ea5bda Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Fri, 17 Apr 2020 12:11:25 -0400
Subject: [PATCH 6/9] New package: rocminfo-3.3.0

---
 srcpkgs/rocminfo/template | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
 create mode 100644 srcpkgs/rocminfo/template

diff --git a/srcpkgs/rocminfo/template b/srcpkgs/rocminfo/template
new file mode 100644
index 00000000000..57d0640dd69
--- /dev/null
+++ b/srcpkgs/rocminfo/template
@@ -0,0 +1,22 @@
+# Template file for 'rocminfo'
+pkgname=rocminfo
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="rocminfo-rocm-${version}"
+build_style=cmake
+configure_args="-DROCM_DIR=/usr"
+hostmakedepends="cmake pkg-config"
+makedepends="rocr-runtime-devel"
+short_desc="Radeon Open Compute system information reporter"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute/rocminfo"
+distfiles="${homepage}/archive/rocm-${version}.tar.gz"
+checksum=e666f662c9e465aaabbbd0b109d87e017243cdf1a0898fabf5a90947bb3dbcd7
+nocross=yes
+python_version=3
+
+post_install() {
+	vlicense License.txt
+}

From e84da1d860708fe8c5d8b144500711d167743578 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Sun, 19 Apr 2020 15:01:40 -0400
Subject: [PATCH 7/9] New package: rocm-bandwidth-test-3.3.0

---
 srcpkgs/rocm-bandwidth-test/template | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
 create mode 100644 srcpkgs/rocm-bandwidth-test/template

diff --git a/srcpkgs/rocm-bandwidth-test/template b/srcpkgs/rocm-bandwidth-test/template
new file mode 100644
index 00000000000..5c5058b693d
--- /dev/null
+++ b/srcpkgs/rocm-bandwidth-test/template
@@ -0,0 +1,20 @@
+# Template file for 'rocm-bandwidth-test'
+pkgname=rocm-bandwidth-test
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="rocm_bandwidth_test-rocm-${version}"
+build_style=cmake
+hostmakedepends="cmake"
+makedepends="rocr-runtime-devel roct-thunk-interface-devel"
+short_desc="Radeon Open Compute bandwidth test"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute/rocm_bandwidth_test"
+distfiles="${homepage}/archive/rocm-${version}.tar.gz"
+checksum=f5f914073018619dc91662d5bf630903dfa4db9136d603591917fdfb3c9164ce
+nocross=yes
+
+post_install() {
+	vlicense LICENSE.txt
+}

From da03023ab238ff56bbe9cf41064c04007f11053a Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Tue, 14 Apr 2020 10:25:54 -0400
Subject: [PATCH 8/9] New package: rocm-opencl-runtime-3.3.0 [ci skip]

---
 common/shlibs                                 |   2 +
 srcpkgs/rocm-opencl-runtime-clinfo            |   1 +
 srcpkgs/rocm-opencl-runtime-devel             |   1 +
 .../files/libelf-musl.patch                   | 688 ++++++++++++++++++
 .../files/runtime-musl.patch                  |  11 +
 srcpkgs/rocm-opencl-runtime/files/sys_queue.h | 574 +++++++++++++++
 .../rocm-opencl-runtime/patches/cmake.patch   | 126 ++++
 srcpkgs/rocm-opencl-runtime/template          |  82 +++
 8 files changed, 1485 insertions(+)
 create mode 120000 srcpkgs/rocm-opencl-runtime-clinfo
 create mode 120000 srcpkgs/rocm-opencl-runtime-devel
 create mode 100644 srcpkgs/rocm-opencl-runtime/files/libelf-musl.patch
 create mode 100644 srcpkgs/rocm-opencl-runtime/files/runtime-musl.patch
 create mode 100644 srcpkgs/rocm-opencl-runtime/files/sys_queue.h
 create mode 100644 srcpkgs/rocm-opencl-runtime/patches/cmake.patch
 create mode 100644 srcpkgs/rocm-opencl-runtime/template

diff --git a/common/shlibs b/common/shlibs
index a53de3cf9e0..8cbc885e016 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3865,3 +3865,5 @@ libstoken.so.1 stoken-0.92_1
 libhsakmt.so.1 roct-thunk-interface-3.3.0_1
 libhsa-runtime64.so.1 rocr-runtime-3.3.0_1
 libamd_comgr.so.1 rocm-comgr-3.3.0_1
+libOpenCL-ROCm.so.1 rocm-opencl-runtime-3.3.0_1
+libamdocl64.so rocm-opencl-runtime-3.3.0_1
diff --git a/srcpkgs/rocm-opencl-runtime-clinfo b/srcpkgs/rocm-opencl-runtime-clinfo
new file mode 120000
index 00000000000..b2cda7e229d
--- /dev/null
+++ b/srcpkgs/rocm-opencl-runtime-clinfo
@@ -0,0 +1 @@
+rocm-opencl-runtime
\ No newline at end of file
diff --git a/srcpkgs/rocm-opencl-runtime-devel b/srcpkgs/rocm-opencl-runtime-devel
new file mode 120000
index 00000000000..b2cda7e229d
--- /dev/null
+++ b/srcpkgs/rocm-opencl-runtime-devel
@@ -0,0 +1 @@
+rocm-opencl-runtime
\ No newline at end of file
diff --git a/srcpkgs/rocm-opencl-runtime/files/libelf-musl.patch b/srcpkgs/rocm-opencl-runtime/files/libelf-musl.patch
new file mode 100644
index 00000000000..a3705c259a9
--- /dev/null
+++ b/srcpkgs/rocm-opencl-runtime/files/libelf-musl.patch
@@ -0,0 +1,688 @@
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/_libelf.h compiler/lib/loaders/elf/utils/libelf/_libelf.h
+--- compiler/lib/loaders/elf/utils/libelf.orig/_libelf.h	2020-04-19 08:59:34.201386585 -0400
++++ compiler/lib/loaders/elf/utils/libelf/_libelf.h	2020-04-19 09:04:12.950433528 -0400
+@@ -30,7 +30,7 @@
+ #define	__LIBELF_H_
+ 
+ #include <limits.h>
+-#include <sys/queue.h>
++#include "sys_queue.h"
+ 
+ #include "_libelf_config.h"
+ 
+@@ -179,7 +179,9 @@
+  * Function Prototypes.
+  */
+ 
+-__BEGIN_DECLS
++#ifdef __cplusplus
++extern "C" {
++#endif
+ Elf_Data *_libelf_allocate_data(Elf_Scn *_s);
+ Elf	*_libelf_allocate_elf(Elf_Mem *mem);
+ Elf_Scn	*_libelf_allocate_scn(Elf *_e, size_t _ndx);
+@@ -213,6 +215,8 @@
+ Elf_Data *_libelf_xlate(Elf_Data *_d, const Elf_Data *_s,
+     unsigned int _encoding, int _elfclass, int _direction);
+ int	_libelf_xlate_shtype(uint32_t _sht);
+-__END_DECLS
++#ifdef __cplusplus
++}
++#endif
+ 
+ #endif	/* __LIBELF_H_ */
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_begin.c compiler/lib/loaders/elf/utils/libelf/elf_begin.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_begin.c	2020-04-19 08:59:34.201386585 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_begin.c	2020-04-19 09:01:04.313212042 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <sys/types.h>
+ #if !defined(WIN32)
+ #include <sys/errno.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_end.c compiler/lib/loaders/elf/utils/libelf/elf_end.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_end.c	2020-04-19 08:59:34.201386585 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_end.c	2020-04-19 09:01:14.895204681 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #if !defined(WIN32)
+ #include <sys/mman.h>
+ #endif
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_errmsg.c compiler/lib/loaders/elf/utils/libelf/elf_errmsg.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_errmsg.c	2020-04-19 08:59:34.201386585 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_errmsg.c	2020-04-19 09:01:16.753207065 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ #include <stdio.h>
+ #include <string.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_errno.c compiler/lib/loaders/elf/utils/libelf/elf_errno.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_errno.c	2020-04-19 08:59:34.201386585 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_errno.c	2020-04-19 09:01:18.669209528 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_fill.c compiler/lib/loaders/elf/utils/libelf/elf_fill.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_fill.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_fill.c	2020-04-19 09:01:21.109212667 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_flag.c compiler/lib/loaders/elf/utils/libelf/elf_flag.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_flag.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_flag.c	2020-04-19 09:01:23.376215579 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_getarhdr.c compiler/lib/loaders/elf/utils/libelf/elf_getarhdr.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_getarhdr.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_getarhdr.c	2020-04-19 09:01:25.414218197 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_getarsym.c compiler/lib/loaders/elf/utils/libelf/elf_getarsym.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_getarsym.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_getarsym.c	2020-04-19 09:01:27.575220978 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_getbase.c compiler/lib/loaders/elf/utils/libelf/elf_getbase.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_getbase.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_getbase.c	2020-04-19 09:01:29.963224043 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_getident.c compiler/lib/loaders/elf/utils/libelf/elf_getident.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_getident.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_getident.c	2020-04-19 09:01:31.912226551 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <ar.h>
+ #include <assert.h>
+ #include <libelf.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_hash.c compiler/lib/loaders/elf/utils/libelf/elf_hash.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_hash.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_hash.c	2020-04-19 09:01:33.877229069 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ #include "_libelf_config.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_kind.c compiler/lib/loaders/elf/utils/libelf/elf_kind.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_kind.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_kind.c	2020-04-19 09:01:35.940231721 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_memory.c compiler/lib/loaders/elf/utils/libelf/elf_memory.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_memory.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_memory.c	2020-04-19 09:01:38.171234596 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <ar.h>
+ #include <libelf.h>
+ #include <string.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_next.c compiler/lib/loaders/elf/utils/libelf/elf_next.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_next.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_next.c	2020-04-19 09:01:40.063237028 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <ar.h>
+ #include <assert.h>
+ #include <libelf.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_phnum.c compiler/lib/loaders/elf/utils/libelf/elf_phnum.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_phnum.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_phnum.c	2020-04-19 09:01:42.480240134 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <ar.h>
+ #include <libelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_rand.c compiler/lib/loaders/elf/utils/libelf/elf_rand.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_rand.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_rand.c	2020-04-19 09:01:45.061243452 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <ar.h>
+ #include <libelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_rawfile.c compiler/lib/loaders/elf/utils/libelf/elf_rawfile.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_rawfile.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_rawfile.c	2020-04-19 09:01:46.988245928 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_scn.c compiler/lib/loaders/elf/utils/libelf/elf_scn.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_scn.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_scn.c	2020-04-19 09:00:19.724298403 -0400
+@@ -24,8 +24,7 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-#include <sys/queue.h>
++#include "sys_queue.h"
+ 
+ #include <assert.h>
+ #include <errno.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_shnum.c compiler/lib/loaders/elf/utils/libelf/elf_shnum.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_shnum.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_shnum.c	2020-04-19 09:01:51.763252060 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <ar.h>
+ #include <libelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_shstrndx.c compiler/lib/loaders/elf/utils/libelf/elf_shstrndx.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_shstrndx.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_shstrndx.c	2020-04-19 09:01:53.532254340 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <ar.h>
+ #include <libelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_version.c compiler/lib/loaders/elf/utils/libelf/elf_version.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_version.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_version.c	2020-04-19 09:02:01.337264370 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf.h compiler/lib/loaders/elf/utils/libelf/gelf.h
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf.h	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf.h	2020-04-19 09:04:29.669455020 -0400
+@@ -29,8 +29,6 @@
+ #ifndef	_GELF_H_
+ #define	_GELF_H_
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ typedef Elf64_Addr	GElf_Addr;	/* Addresses */
+@@ -72,7 +70,9 @@
+ #define	GELF_ST_TYPE			ELF64_ST_TYPE
+ #define	GELF_ST_VISIBILITY		ELF64_ST_VISIBILITY
+ 
+-__BEGIN_DECLS
++#ifdef __cplusplus
++extern "C" {
++#endif
+ long		gelf_checksum(Elf *_elf);
+ size_t		gelf_fsize(Elf *_elf, Elf_Type _type, size_t _count,
+ 			unsigned int _version);
+@@ -109,6 +109,8 @@
+ int		gelf_update_move(Elf_Data *_dst, int _index, GElf_Move *_src);
+ int		gelf_update_syminfo(Elf_Data *_dst, int _index, GElf_Syminfo *_src);
+ #endif
+-__END_DECLS
++#ifdef __cplusplus
++}
++#endif
+ 
+ #endif	/* _GELF_H_ */
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_cap.c compiler/lib/loaders/elf/utils/libelf/gelf_cap.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_cap.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_cap.c	2020-04-19 09:02:05.429269632 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_checksum.c compiler/lib/loaders/elf/utils/libelf/gelf_checksum.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_checksum.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_checksum.c	2020-04-19 09:02:08.192273183 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <gelf.h>
+ #include <libelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_dyn.c compiler/lib/loaders/elf/utils/libelf/gelf_dyn.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_dyn.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_dyn.c	2020-04-19 09:02:10.020275525 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_ehdr.c compiler/lib/loaders/elf/utils/libelf/gelf_ehdr.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_ehdr.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_ehdr.c	2020-04-19 09:02:11.882277926 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ #include <libelf.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_fsize.c compiler/lib/loaders/elf/utils/libelf/gelf_fsize.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_fsize.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_fsize.c	2020-04-19 09:02:14.139280827 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <gelf.h>
+ #include <libelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_getclass.c compiler/lib/loaders/elf/utils/libelf/gelf_getclass.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_getclass.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_getclass.c	2020-04-19 09:02:17.269284848 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <gelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_move.c compiler/lib/loaders/elf/utils/libelf/gelf_move.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_move.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_move.c	2020-04-19 09:02:18.974287034 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_phdr.c compiler/lib/loaders/elf/utils/libelf/gelf_phdr.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_phdr.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_phdr.c	2020-04-19 09:02:20.676289227 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <gelf.h>
+ #include <libelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_rel.c compiler/lib/loaders/elf/utils/libelf/gelf_rel.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_rel.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_rel.c	2020-04-19 09:02:23.177292435 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_rela.c compiler/lib/loaders/elf/utils/libelf/gelf_rela.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_rela.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_rela.c	2020-04-19 09:02:25.246295100 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_shdr.c compiler/lib/loaders/elf/utils/libelf/gelf_shdr.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_shdr.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_shdr.c	2020-04-19 09:02:28.325299060 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ #include <libelf.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_sym.c compiler/lib/loaders/elf/utils/libelf/gelf_sym.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_sym.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_sym.c	2020-04-19 09:02:30.113301356 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_syminfo.c compiler/lib/loaders/elf/utils/libelf/gelf_syminfo.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_syminfo.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_syminfo.c	2020-04-19 09:02:31.906303662 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_symshndx.c compiler/lib/loaders/elf/utils/libelf/gelf_symshndx.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_symshndx.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_symshndx.c	2020-04-19 09:02:33.626305873 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_xlate.c compiler/lib/loaders/elf/utils/libelf/gelf_xlate.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_xlate.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_xlate.c	2020-04-19 09:02:35.921308822 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <gelf.h>
+ #include <libelf.h>
+ #include <string.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf.h compiler/lib/loaders/elf/utils/libelf/libelf.h
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf.h	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf.h	2020-04-19 09:04:38.760466706 -0400
+@@ -30,7 +30,7 @@
+ #define	_LIBELF_H_
+ 
+ #include <sys/types.h>
+-#include <sys/queue.h>
++#include "sys_queue.h"
+ #include <elfdefinitions.h>
+ #ifndef EM_HSAIL
+ #define EM_HSAIL 0xAF5A
+@@ -187,7 +187,9 @@
+ #define	ELF_F_ARCHIVE	   0x100U /* archive creation */
+ #define	ELF_F_ARCHIVE_SYSV 0x200U /* SYSV style archive */
+ 
+-__BEGIN_DECLS
++#ifdef __cplusplus
++extern "C" {
++#endif
+ Elf		*elf_begin(int _fd, Elf_Cmd _cmd, Elf *_elf, Elf_Mem *_mem);
+ int		elf_cntl(Elf *_elf, Elf_Cmd _cmd);
+ int		elf_end(Elf *_elf);
+@@ -257,6 +259,8 @@
+ 			unsigned int _enc);
+ Elf_Data	*elf64_xlatetom(Elf_Data *_dst, const Elf_Data *_src,
+ 			unsigned int _enc);
+-__END_DECLS
++#ifdef __cplusplus
++}
++#endif
+ 
+ #endif	/* _LIBELF_H_ */
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_align.c compiler/lib/loaders/elf/utils/libelf/libelf_align.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_align.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_align.c	2020-04-19 09:02:40.660314911 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <sys/types.h>
+ 
+ #include <libelf.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_allocate.c compiler/lib/loaders/elf/utils/libelf/libelf_allocate.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_allocate.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_allocate.c	2020-04-19 09:02:43.079318019 -0400
+@@ -28,8 +28,6 @@
+  * Internal APIs
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #if !defined(WIN32)
+ #include <sys/errno.h>
+ #endif
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_ar.c compiler/lib/loaders/elf/utils/libelf/libelf_ar.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_ar.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_ar.c	2020-04-19 09:02:44.763320187 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <ctype.h>
+ #include <libelf.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_ar_util.c compiler/lib/loaders/elf/utils/libelf/libelf_ar_util.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_ar_util.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_ar_util.c	2020-04-19 09:02:46.461322369 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <libelf.h>
+ #include <stdlib.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_checksum.c compiler/lib/loaders/elf/utils/libelf/libelf_checksum.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_checksum.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_checksum.c	2020-04-19 09:02:48.645325173 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <gelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_convert.c compiler/lib/loaders/elf/utils/libelf/libelf_convert.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_convert.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_convert.c	2020-04-19 09:02:50.883328053 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <libelf.h>
+ #include <string.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_data.c compiler/lib/loaders/elf/utils/libelf/libelf_data.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_data.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_data.c	2020-04-19 09:02:52.951330708 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_ehdr.c compiler/lib/loaders/elf/utils/libelf/libelf_ehdr.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_ehdr.c	2020-04-19 08:59:34.204386579 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_ehdr.c	2020-04-19 09:02:55.176333563 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ #include <libelf.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_extended.c compiler/lib/loaders/elf/utils/libelf/libelf_extended.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_extended.c	2020-04-19 08:59:34.204386579 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_extended.c	2020-04-19 09:02:57.932337110 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <libelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_msize.c compiler/lib/loaders/elf/utils/libelf/libelf_msize.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_msize.c	2020-04-19 08:59:34.204386579 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_msize.c	2020-04-19 09:03:02.201342598 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <libelf.h>
+ #include <string.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_phdr.c compiler/lib/loaders/elf/utils/libelf/libelf_phdr.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_phdr.c	2020-04-19 08:59:34.204386579 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_phdr.c	2020-04-19 09:03:04.194345160 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ #include <libelf.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_shdr.c compiler/lib/loaders/elf/utils/libelf/libelf_shdr.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_shdr.c	2020-04-19 08:59:34.204386579 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_shdr.c	2020-04-19 09:03:05.795347218 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <gelf.h>
+ #include <libelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_xlate.c compiler/lib/loaders/elf/utils/libelf/libelf_xlate.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_xlate.c	2020-04-19 08:59:34.204386579 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_xlate.c	2020-04-19 09:03:09.472351944 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <libelf.h>
+ 
diff --git a/srcpkgs/rocm-opencl-runtime/files/runtime-musl.patch b/srcpkgs/rocm-opencl-runtime/files/runtime-musl.patch
new file mode 100644
index 00000000000..ea18e90e09c
--- /dev/null
+++ b/srcpkgs/rocm-opencl-runtime/files/runtime-musl.patch
@@ -0,0 +1,11 @@
+--- runtime/os/os_posix.cpp.orig	2020-04-19 09:13:51.701982901 -0400
++++ runtime/os/os_posix.cpp	2020-04-19 09:14:04.156947422 -0400
+@@ -44,6 +44,8 @@
+ #include <algorithm>
+ #include <mutex>
+ 
++#include <libgen.h> // for basename
++
+ 
+ namespace amd {
+ 
diff --git a/srcpkgs/rocm-opencl-runtime/files/sys_queue.h b/srcpkgs/rocm-opencl-runtime/files/sys_queue.h
new file mode 100644
index 00000000000..daf4553d33e
--- /dev/null
+++ b/srcpkgs/rocm-opencl-runtime/files/sys_queue.h
@@ -0,0 +1,574 @@
+/*
+ * Copyright (c) 1991, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *	@(#)queue.h	8.5 (Berkeley) 8/20/94
+ */
+
+#ifndef	_SYS_QUEUE_H_
+#define	_SYS_QUEUE_H_
+
+/*
+ * This file defines five types of data structures: singly-linked lists,
+ * lists, simple queues, tail queues, and circular queues.
+ *
+ * A singly-linked list is headed by a single forward pointer. The
+ * elements are singly linked for minimum space and pointer manipulation
+ * overhead at the expense of O(n) removal for arbitrary elements. New
+ * elements can be added to the list after an existing element or at the
+ * head of the list.  Elements being removed from the head of the list
+ * should use the explicit macro for this purpose for optimum
+ * efficiency. A singly-linked list may only be traversed in the forward
+ * direction.  Singly-linked lists are ideal for applications with large
+ * datasets and few or no removals or for implementing a LIFO queue.
+ *
+ * A list is headed by a single forward pointer (or an array of forward
+ * pointers for a hash table header). The elements are doubly linked
+ * so that an arbitrary element can be removed without a need to
+ * traverse the list. New elements can be added to the list before
+ * or after an existing element or at the head of the list. A list
+ * may only be traversed in the forward direction.
+ *
+ * A simple queue is headed by a pair of pointers, one the head of the
+ * list and the other to the tail of the list. The elements are singly
+ * linked to save space, so elements can only be removed from the
+ * head of the list. New elements can be added to the list after
+ * an existing element, at the head of the list, or at the end of the
+ * list. A simple queue may only be traversed in the forward direction.
+ *
+ * A tail queue is headed by a pair of pointers, one to the head of the
+ * list and the other to the tail of the list. The elements are doubly
+ * linked so that an arbitrary element can be removed without a need to
+ * traverse the list. New elements can be added to the list before or
+ * after an existing element, at the head of the list, or at the end of
+ * the list. A tail queue may be traversed in either direction.
+ *
+ * A circle queue is headed by a pair of pointers, one to the head of the
+ * list and the other to the tail of the list. The elements are doubly
+ * linked so that an arbitrary element can be removed without a need to
+ * traverse the list. New elements can be added to the list before or after
+ * an existing element, at the head of the list, or at the end of the list.
+ * A circle queue may be traversed in either direction, but has a more
+ * complex end of list detection.
+ *
+ * For details on the use of these macros, see the queue(3) manual page.
+ */
+
+/*
+ * List definitions.
+ */
+#define	LIST_HEAD(name, type)						\
+struct name {								\
+	struct type *lh_first;	/* first element */			\
+}
+
+#define	LIST_HEAD_INITIALIZER(head)					\
+	{ NULL }
+
+#define	LIST_ENTRY(type)						\
+struct {								\
+	struct type *le_next;	/* next element */			\
+	struct type **le_prev;	/* address of previous next element */	\
+}
+
+/*
+ * List functions.
+ */
+#define	LIST_INIT(head) do {						\
+	(head)->lh_first = NULL;					\
+} while (/*CONSTCOND*/0)
+
+#define	LIST_INSERT_AFTER(listelm, elm, field) do {			\
+	if (((elm)->field.le_next = (listelm)->field.le_next) != NULL)	\
+		(listelm)->field.le_next->field.le_prev =		\
+		    &(elm)->field.le_next;				\
+	(listelm)->field.le_next = (elm);				\
+	(elm)->field.le_prev = &(listelm)->field.le_next;		\
+} while (/*CONSTCOND*/0)
+
+#define	LIST_INSERT_BEFORE(listelm, elm, field) do {			\
+	(elm)->field.le_prev = (listelm)->field.le_prev;		\
+	(elm)->field.le_next = (listelm);				\
+	*(listelm)->field.le_prev = (elm);				\
+	(listelm)->field.le_prev = &(elm)->field.le_next;		\
+} while (/*CONSTCOND*/0)
+
+#define	LIST_INSERT_HEAD(head, elm, field) do {				\
+	if (((elm)->field.le_next = (head)->lh_first) != NULL)		\
+		(head)->lh_first->field.le_prev = &(elm)->field.le_next;\
+	(head)->lh_first = (elm);					\
+	(elm)->field.le_prev = &(head)->lh_first;			\
+} while (/*CONSTCOND*/0)
+
+#define	LIST_REMOVE(elm, field) do {					\
+	if ((elm)->field.le_next != NULL)				\
+		(elm)->field.le_next->field.le_prev = 			\
+		    (elm)->field.le_prev;				\
+	*(elm)->field.le_prev = (elm)->field.le_next;			\
+} while (/*CONSTCOND*/0)
+
+#define	LIST_FOREACH(var, head, field)					\
+	for ((var) = ((head)->lh_first);				\
+		(var);							\
+		(var) = ((var)->field.le_next))
+
+/*
+ * List access methods.
+ */
+#define	LIST_EMPTY(head)		((head)->lh_first == NULL)
+#define	LIST_FIRST(head)		((head)->lh_first)
+#define	LIST_NEXT(elm, field)		((elm)->field.le_next)
+
+
+/*
+ * Singly-linked List definitions.
+ */
+#define	SLIST_HEAD(name, type)						\
+struct name {								\
+	struct type *slh_first;	/* first element */			\
+}
+
+#define	SLIST_HEAD_INITIALIZER(head)					\
+	{ NULL }
+
+#define	SLIST_ENTRY(type)						\
+struct {								\
+	struct type *sle_next;	/* next element */			\
+}
+
+/*
+ * Singly-linked List functions.
+ */
+#define	SLIST_INIT(head) do {						\
+	(head)->slh_first = NULL;					\
+} while (/*CONSTCOND*/0)
+
+#define	SLIST_INSERT_AFTER(slistelm, elm, field) do {			\
+	(elm)->field.sle_next = (slistelm)->field.sle_next;		\
+	(slistelm)->field.sle_next = (elm);				\
+} while (/*CONSTCOND*/0)
+
+#define	SLIST_INSERT_HEAD(head, elm, field) do {			\
+	(elm)->field.sle_next = (head)->slh_first;			\
+	(head)->slh_first = (elm);					\
+} while (/*CONSTCOND*/0)
+
+#define	SLIST_REMOVE_HEAD(head, field) do {				\
+	(head)->slh_first = (head)->slh_first->field.sle_next;		\
+} while (/*CONSTCOND*/0)
+
+#define	SLIST_REMOVE(head, elm, type, field) do {			\
+	if ((head)->slh_first == (elm)) {				\
+		SLIST_REMOVE_HEAD((head), field);			\
+	}								\
+	else {								\
+		struct type *curelm = (head)->slh_first;		\
+		while(curelm->field.sle_next != (elm))			\
+			curelm = curelm->field.sle_next;		\
+		curelm->field.sle_next =				\
+		    curelm->field.sle_next->field.sle_next;		\
+	}								\
+} while (/*CONSTCOND*/0)
+
+#define	SLIST_FOREACH(var, head, field)					\
+	for((var) = (head)->slh_first; (var); (var) = (var)->field.sle_next)
+
+/*
+ * Singly-linked List access methods.
+ */
+#define	SLIST_EMPTY(head)	((head)->slh_first == NULL)
+#define	SLIST_FIRST(head)	((head)->slh_first)
+#define	SLIST_NEXT(elm, field)	((elm)->field.sle_next)
+
+
+/*
+ * Singly-linked Tail queue declarations.
+ */
+#define	STAILQ_HEAD(name, type)					\
+struct name {								\
+	struct type *stqh_first;	/* first element */			\
+	struct type **stqh_last;	/* addr of last next element */		\
+}
+
+#define	STAILQ_HEAD_INITIALIZER(head)					\
+	{ NULL, &(head).stqh_first }
+
+#define	STAILQ_ENTRY(type)						\
+struct {								\
+	struct type *stqe_next;	/* next element */			\
+}
+
+/*
+ * Singly-linked Tail queue functions.
+ */
+#define	STAILQ_INIT(head) do {						\
+	(head)->stqh_first = NULL;					\
+	(head)->stqh_last = &(head)->stqh_first;				\
+} while (/*CONSTCOND*/0)
+
+#define	STAILQ_INSERT_HEAD(head, elm, field) do {			\
+	if (((elm)->field.stqe_next = (head)->stqh_first) == NULL)	\
+		(head)->stqh_last = &(elm)->field.stqe_next;		\
+	(head)->stqh_first = (elm);					\
+} while (/*CONSTCOND*/0)
+
+#define	STAILQ_INSERT_TAIL(head, elm, field) do {			\
+	(elm)->field.stqe_next = NULL;					\
+	*(head)->stqh_last = (elm);					\
+	(head)->stqh_last = &(elm)->field.stqe_next;			\
+} while (/*CONSTCOND*/0)
+
+#define	STAILQ_INSERT_AFTER(head, listelm, elm, field) do {		\
+	if (((elm)->field.stqe_next = (listelm)->field.stqe_next) == NULL)\
+		(head)->stqh_last = &(elm)->field.stqe_next;		\
+	(listelm)->field.stqe_next = (elm);				\
+} while (/*CONSTCOND*/0)
+
+#define	STAILQ_REMOVE_HEAD(head, field) do {				\
+	if (((head)->stqh_first = (head)->stqh_first->field.stqe_next) == NULL) \
+		(head)->stqh_last = &(head)->stqh_first;			\
+} while (/*CONSTCOND*/0)
+
+#define	STAILQ_REMOVE(head, elm, type, field) do {			\
+	if ((head)->stqh_first == (elm)) {				\
+		STAILQ_REMOVE_HEAD((head), field);			\
+	} else {							\
+		struct type *curelm = (head)->stqh_first;		\
+		while (curelm->field.stqe_next != (elm))			\
+			curelm = curelm->field.stqe_next;		\
+		if ((curelm->field.stqe_next =				\
+			curelm->field.stqe_next->field.stqe_next) == NULL) \
+			    (head)->stqh_last = &(curelm)->field.stqe_next; \
+	}								\
+} while (/*CONSTCOND*/0)
+
+#define	STAILQ_FOREACH(var, head, field)				\
+	for ((var) = ((head)->stqh_first);				\
+		(var);							\
+		(var) = ((var)->field.stqe_next))
+
+#define	STAILQ_CONCAT(head1, head2) do {				\
+	if (!STAILQ_EMPTY((head2))) {					\
+		*(head1)->stqh_last = (head2)->stqh_first;		\
+		(head1)->stqh_last = (head2)->stqh_last;		\
+		STAILQ_INIT((head2));					\
+	}								\
+} while (/*CONSTCOND*/0)
+
+/*
+ * Singly-linked Tail queue access methods.
+ */
+#define	STAILQ_EMPTY(head)	((head)->stqh_first == NULL)
+#define	STAILQ_FIRST(head)	((head)->stqh_first)
+#define	STAILQ_NEXT(elm, field)	((elm)->field.stqe_next)
+
+
+/*
+ * Simple queue definitions.
+ */
+#define	SIMPLEQ_HEAD(name, type)					\
+struct name {								\
+	struct type *sqh_first;	/* first element */			\
+	struct type **sqh_last;	/* addr of last next element */		\
+}
+
+#define	SIMPLEQ_HEAD_INITIALIZER(head)					\
+	{ NULL, &(head).sqh_first }
+
+#define	SIMPLEQ_ENTRY(type)						\
+struct {								\
+	struct type *sqe_next;	/* next element */			\
+}
+
+/*
+ * Simple queue functions.
+ */
+#define	SIMPLEQ_INIT(head) do {						\
+	(head)->sqh_first = NULL;					\
+	(head)->sqh_last = &(head)->sqh_first;				\
+} while (/*CONSTCOND*/0)
+
+#define	SIMPLEQ_INSERT_HEAD(head, elm, field) do {			\
+	if (((elm)->field.sqe_next = (head)->sqh_first) == NULL)	\
+		(head)->sqh_last = &(elm)->field.sqe_next;		\
+	(head)->sqh_first = (elm);					\
+} while (/*CONSTCOND*/0)
+
+#define	SIMPLEQ_INSERT_TAIL(head, elm, field) do {			\
+	(elm)->field.sqe_next = NULL;					\
+	*(head)->sqh_last = (elm);					\
+	(head)->sqh_last = &(elm)->field.sqe_next;			\
+} while (/*CONSTCOND*/0)
+
+#define	SIMPLEQ_INSERT_AFTER(head, listelm, elm, field) do {		\
+	if (((elm)->field.sqe_next = (listelm)->field.sqe_next) == NULL)\
+		(head)->sqh_last = &(elm)->field.sqe_next;		\
+	(listelm)->field.sqe_next = (elm);				\
+} while (/*CONSTCOND*/0)
+
+#define	SIMPLEQ_REMOVE_HEAD(head, field) do {				\
+	if (((head)->sqh_first = (head)->sqh_first->field.sqe_next) == NULL) \
+		(head)->sqh_last = &(head)->sqh_first;			\
+} while (/*CONSTCOND*/0)
+
+#define	SIMPLEQ_REMOVE(head, elm, type, field) do {			\
+	if ((head)->sqh_first == (elm)) {				\
+		SIMPLEQ_REMOVE_HEAD((head), field);			\
+	} else {							\
+		struct type *curelm = (head)->sqh_first;		\
+		while (curelm->field.sqe_next != (elm))			\
+			curelm = curelm->field.sqe_next;		\
+		if ((curelm->field.sqe_next =				\
+			curelm->field.sqe_next->field.sqe_next) == NULL) \
+			    (head)->sqh_last = &(curelm)->field.sqe_next; \
+	}								\
+} while (/*CONSTCOND*/0)
+
+#define	SIMPLEQ_FOREACH(var, head, field)				\
+	for ((var) = ((head)->sqh_first);				\
+		(var);							\
+		(var) = ((var)->field.sqe_next))
+
+/*
+ * Simple queue access methods.
+ */
+#define	SIMPLEQ_EMPTY(head)		((head)->sqh_first == NULL)
+#define	SIMPLEQ_FIRST(head)		((head)->sqh_first)
+#define	SIMPLEQ_NEXT(elm, field)	((elm)->field.sqe_next)
+
+
+/*
+ * Tail queue definitions.
+ */
+#define	_TAILQ_HEAD(name, type, qual)					\
+struct name {								\
+	qual type *tqh_first;		/* first element */		\
+	qual type *qual *tqh_last;	/* addr of last next element */	\
+}
+#define TAILQ_HEAD(name, type)	_TAILQ_HEAD(name, struct type,)
+
+#define	TAILQ_HEAD_INITIALIZER(head)					\
+	{ NULL, &(head).tqh_first }
+
+#define	_TAILQ_ENTRY(type, qual)					\
+struct {								\
+	qual type *tqe_next;		/* next element */		\
+	qual type *qual *tqe_prev;	/* address of previous next element */\
+}
+#define TAILQ_ENTRY(type)	_TAILQ_ENTRY(struct type,)
+
+/*
+ * Tail queue functions.
+ */
+#define	TAILQ_INIT(head) do {						\
+	(head)->tqh_first = NULL;					\
+	(head)->tqh_last = &(head)->tqh_first;				\
+} while (/*CONSTCOND*/0)
+
+#define	TAILQ_INSERT_HEAD(head, elm, field) do {			\
+	if (((elm)->field.tqe_next = (head)->tqh_first) != NULL)	\
+		(head)->tqh_first->field.tqe_prev =			\
+		    &(elm)->field.tqe_next;				\
+	else								\
+		(head)->tqh_last = &(elm)->field.tqe_next;		\
+	(head)->tqh_first = (elm);					\
+	(elm)->field.tqe_prev = &(head)->tqh_first;			\
+} while (/*CONSTCOND*/0)
+
+#define	TAILQ_INSERT_TAIL(head, elm, field) do {			\
+	(elm)->field.tqe_next = NULL;					\
+	(elm)->field.tqe_prev = (head)->tqh_last;			\
+	*(head)->tqh_last = (elm);					\
+	(head)->tqh_last = &(elm)->field.tqe_next;			\
+} while (/*CONSTCOND*/0)
+
+#define	TAILQ_INSERT_AFTER(head, listelm, elm, field) do {		\
+	if (((elm)->field.tqe_next = (listelm)->field.tqe_next) != NULL)\
+		(elm)->field.tqe_next->field.tqe_prev = 		\
+		    &(elm)->field.tqe_next;				\
+	else								\
+		(head)->tqh_last = &(elm)->field.tqe_next;		\
+	(listelm)->field.tqe_next = (elm);				\
+	(elm)->field.tqe_prev = &(listelm)->field.tqe_next;		\
+} while (/*CONSTCOND*/0)
+
+#define	TAILQ_INSERT_BEFORE(listelm, elm, field) do {			\
+	(elm)->field.tqe_prev = (listelm)->field.tqe_prev;		\
+	(elm)->field.tqe_next = (listelm);				\
+	*(listelm)->field.tqe_prev = (elm);				\
+	(listelm)->field.tqe_prev = &(elm)->field.tqe_next;		\
+} while (/*CONSTCOND*/0)
+
+#define	TAILQ_REMOVE(head, elm, field) do {				\
+	if (((elm)->field.tqe_next) != NULL)				\
+		(elm)->field.tqe_next->field.tqe_prev = 		\
+		    (elm)->field.tqe_prev;				\
+	else								\
+		(head)->tqh_last = (elm)->field.tqe_prev;		\
+	*(elm)->field.tqe_prev = (elm)->field.tqe_next;			\
+} while (/*CONSTCOND*/0)
+
+#define	TAILQ_FOREACH(var, head, field)					\
+	for ((var) = ((head)->tqh_first);				\
+		(var);							\
+		(var) = ((var)->field.tqe_next))
+
+#define	TAILQ_FOREACH_REVERSE(var, head, headname, field)		\
+	for ((var) = (*(((struct headname *)((head)->tqh_last))->tqh_last));	\
+		(var);							\
+		(var) = (*(((struct headname *)((var)->field.tqe_prev))->tqh_last)))
+
+#define	TAILQ_CONCAT(head1, head2, field) do {				\
+	if (!TAILQ_EMPTY(head2)) {					\
+		*(head1)->tqh_last = (head2)->tqh_first;		\
+		(head2)->tqh_first->field.tqe_prev = (head1)->tqh_last;	\
+		(head1)->tqh_last = (head2)->tqh_last;			\
+		TAILQ_INIT((head2));					\
+	}								\
+} while (/*CONSTCOND*/0)
+
+/*
+ * Tail queue access methods.
+ */
+#define	TAILQ_EMPTY(head)		((head)->tqh_first == NULL)
+#define	TAILQ_FIRST(head)		((head)->tqh_first)
+#define	TAILQ_NEXT(elm, field)		((elm)->field.tqe_next)
+
+#define	TAILQ_LAST(head, headname) \
+	(*(((struct headname *)((head)->tqh_last))->tqh_last))
+#define	TAILQ_PREV(elm, headname, field) \
+	(*(((struct headname *)((elm)->field.tqe_prev))->tqh_last))
+
+
+/*
+ * Circular queue definitions.
+ */
+#define	CIRCLEQ_HEAD(name, type)					\
+struct name {								\
+	struct type *cqh_first;		/* first element */		\
+	struct type *cqh_last;		/* last element */		\
+}
+
+#define	CIRCLEQ_HEAD_INITIALIZER(head)					\
+	{ (void *)&head, (void *)&head }
+
+#define	CIRCLEQ_ENTRY(type)						\
+struct {								\
+	struct type *cqe_next;		/* next element */		\
+	struct type *cqe_prev;		/* previous element */		\
+}
+
+/*
+ * Circular queue functions.
+ */
+#define	CIRCLEQ_INIT(head) do {						\
+	(head)->cqh_first = (void *)(head);				\
+	(head)->cqh_last = (void *)(head);				\
+} while (/*CONSTCOND*/0)
+
+#define	CIRCLEQ_INSERT_AFTER(head, listelm, elm, field) do {		\
+	(elm)->field.cqe_next = (listelm)->field.cqe_next;		\
+	(elm)->field.cqe_prev = (listelm);				\
+	if ((listelm)->field.cqe_next == (void *)(head))		\
+		(head)->cqh_last = (elm);				\
+	else								\
+		(listelm)->field.cqe_next->field.cqe_prev = (elm);	\
+	(listelm)->field.cqe_next = (elm);				\
+} while (/*CONSTCOND*/0)
+
+#define	CIRCLEQ_INSERT_BEFORE(head, listelm, elm, field) do {		\
+	(elm)->field.cqe_next = (listelm);				\
+	(elm)->field.cqe_prev = (listelm)->field.cqe_prev;		\
+	if ((listelm)->field.cqe_prev == (void *)(head))		\
+		(head)->cqh_first = (elm);				\
+	else								\
+		(listelm)->field.cqe_prev->field.cqe_next = (elm);	\
+	(listelm)->field.cqe_prev = (elm);				\
+} while (/*CONSTCOND*/0)
+
+#define	CIRCLEQ_INSERT_HEAD(head, elm, field) do {			\
+	(elm)->field.cqe_next = (head)->cqh_first;			\
+	(elm)->field.cqe_prev = (void *)(head);				\
+	if ((head)->cqh_last == (void *)(head))				\
+		(head)->cqh_last = (elm);				\
+	else								\
+		(head)->cqh_first->field.cqe_prev = (elm);		\
+	(head)->cqh_first = (elm);					\
+} while (/*CONSTCOND*/0)
+
+#define	CIRCLEQ_INSERT_TAIL(head, elm, field) do {			\
+	(elm)->field.cqe_next = (void *)(head);				\
+	(elm)->field.cqe_prev = (head)->cqh_last;			\
+	if ((head)->cqh_first == (void *)(head))			\
+		(head)->cqh_first = (elm);				\
+	else								\
+		(head)->cqh_last->field.cqe_next = (elm);		\
+	(head)->cqh_last = (elm);					\
+} while (/*CONSTCOND*/0)
+
+#define	CIRCLEQ_REMOVE(head, elm, field) do {				\
+	if ((elm)->field.cqe_next == (void *)(head))			\
+		(head)->cqh_last = (elm)->field.cqe_prev;		\
+	else								\
+		(elm)->field.cqe_next->field.cqe_prev =			\
+		    (elm)->field.cqe_prev;				\
+	if ((elm)->field.cqe_prev == (void *)(head))			\
+		(head)->cqh_first = (elm)->field.cqe_next;		\
+	else								\
+		(elm)->field.cqe_prev->field.cqe_next =			\
+		    (elm)->field.cqe_next;				\
+} while (/*CONSTCOND*/0)
+
+#define	CIRCLEQ_FOREACH(var, head, field)				\
+	for ((var) = ((head)->cqh_first);				\
+		(var) != (const void *)(head);				\
+		(var) = ((var)->field.cqe_next))
+
+#define	CIRCLEQ_FOREACH_REVERSE(var, head, field)			\
+	for ((var) = ((head)->cqh_last);				\
+		(var) != (const void *)(head);				\
+		(var) = ((var)->field.cqe_prev))
+
+/*
+ * Circular queue access methods.
+ */
+#define	CIRCLEQ_EMPTY(head)		((head)->cqh_first == (void *)(head))
+#define	CIRCLEQ_FIRST(head)		((head)->cqh_first)
+#define	CIRCLEQ_LAST(head)		((head)->cqh_last)
+#define	CIRCLEQ_NEXT(elm, field)	((elm)->field.cqe_next)
+#define	CIRCLEQ_PREV(elm, field)	((elm)->field.cqe_prev)
+
+#define CIRCLEQ_LOOP_NEXT(head, elm, field)				\
+	(((elm)->field.cqe_next == (void *)(head))			\
+	    ? ((head)->cqh_first)					\
+	    : (elm->field.cqe_next))
+#define CIRCLEQ_LOOP_PREV(head, elm, field)				\
+	(((elm)->field.cqe_prev == (void *)(head))			\
+	    ? ((head)->cqh_last)					\
+	    : (elm->field.cqe_prev))
+
+#endif	/* sys/queue.h */
diff --git a/srcpkgs/rocm-opencl-runtime/patches/cmake.patch b/srcpkgs/rocm-opencl-runtime/patches/cmake.patch
new file mode 100644
index 00000000000..2c96b99d45a
--- /dev/null
+++ b/srcpkgs/rocm-opencl-runtime/patches/cmake.patch
@@ -0,0 +1,126 @@
+--- OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/CMakeLists.txt	2019-09-10 11:53:28.000000000 -0400
++++ OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/CMakeLists.txt	2020-04-16 20:16:13.481180757 -0400
+@@ -73,11 +73,11 @@
+ 
+ set (OPENCL_ICD_LOADER_HEADERS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/inc CACHE PATH "Path to OpenCL Headers")
+ 
+-add_library (OpenCL ${OPENCL_ICD_LOADER_SOURCES})
+-set_target_properties (OpenCL PROPERTIES VERSION "1.2" SOVERSION "1")
++add_library (OpenCL-ROCm ${OPENCL_ICD_LOADER_SOURCES})
++set_target_properties (OpenCL-ROCm PROPERTIES VERSION "1.2" SOVERSION "1")
+ 
+ if (WIN32)
+-    target_link_libraries (OpenCL cfgmgr32.lib)
++    target_link_libraries (OpenCL-ROCm cfgmgr32.lib)
+ 
+     option (OPENCL_ICD_LOADER_REQUIRE_WDK "Build with D3DKMT support, which requires the Windows WDK." ON)
+     if (OPENCL_ICD_LOADER_REQUIRE_WDK)
+@@ -92,10 +92,10 @@
+             get_filename_component(WDK_DIRECTORY ${LATEST_D3DKMT_HEADER} DIRECTORY)
+             get_filename_component(WDK_DIRECTORY ${WDK_DIRECTORY} DIRECTORY)
+             message(STATUS "Found the Windows WDK in: ${WDK_DIRECTORY}")
+-            target_compile_definitions(OpenCL PRIVATE OPENCL_ICD_LOADER_REQUIRE_WDK)
+-            target_include_directories(OpenCL PRIVATE ${WDK_DIRECTORY}/um)
+-            target_include_directories(OpenCL PRIVATE ${WDK_DIRECTORY}/km)
+-            target_include_directories(OpenCL PRIVATE ${WDK_DIRECTORY}/shared)
++	    target_compile_definitions(OpenCL-ROCm PRIVATE OPENCL_ICD_LOADER_REQUIRE_WDK)
++	    target_include_directories(OpenCL-ROCm PRIVATE ${WDK_DIRECTORY}/um)
++	    target_include_directories(OpenCL-ROCm PRIVATE ${WDK_DIRECTORY}/km)
++	    target_include_directories(OpenCL-ROCm PRIVATE ${WDK_DIRECTORY}/shared)
+         else()
+             message(FATAL_ERROR "The Windows WDK was not found. Consider disabling OPENCL_ICD_LOADER_REQUIRE_WDK. Aborting.")
+         endif()
+@@ -113,25 +113,25 @@
+     endif()
+ else()
+     if (APPLE)
+-        target_link_libraries (OpenCL ${CMAKE_THREAD_LIBS_INIT})
++        target_link_libraries (OpenCL-ROCm ${CMAKE_THREAD_LIBS_INIT})
+     else ()
+-        set_target_properties (OpenCL PROPERTIES LINK_FLAGS "-Wl,--version-script -Wl,${CMAKE_CURRENT_SOURCE_DIR}/loader/linux/icd_exports.map")
+-        target_link_libraries (OpenCL ${CMAKE_THREAD_LIBS_INIT})
++        set_target_properties (OpenCL-ROCm PROPERTIES LINK_FLAGS "-Wl,--version-script -Wl,${CMAKE_CURRENT_SOURCE_DIR}/loader/linux/icd_exports.map")
++	target_link_libraries (OpenCL-ROCm ${CMAKE_THREAD_LIBS_INIT})
+     endif ()
+ endif ()
+ 
+ include_directories (${OPENCL_ICD_LOADER_HEADERS_DIR})
+ add_definitions (-DCL_TARGET_OPENCL_VERSION=220)
+ 
+-target_include_directories (OpenCL PRIVATE ${CMAKE_CURRENT_BINARY_DIR} loader)
+-target_link_libraries (OpenCL ${CMAKE_DL_LIBS})
++target_include_directories (OpenCL-ROCm PRIVATE ${CMAKE_CURRENT_BINARY_DIR} loader)
++target_link_libraries (OpenCL-ROCm ${CMAKE_DL_LIBS})
+ 
+ include (CTest)
+ if (BUILD_TESTING)
+     add_subdirectory (test)
+ endif()
+ 
+-install (TARGETS OpenCL
++install (TARGETS OpenCL-ROCm
+     RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+     ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
+     LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
+--- OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/test/loader_test/CMakeLists.txt	2019-09-10 11:53:28.000000000 -0400
++++ OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/test/loader_test/CMakeLists.txt	2020-04-16 20:16:56.647026589 -0400
+@@ -12,4 +12,4 @@
+     test_clgl.c
+     test_image_objects.c )
+ 
+-target_link_libraries (icd_loader_test OpenCL IcdLog)
++target_link_libraries (icd_loader_test OpenCL-ROCm IcdLog)
+--- ROCm-OpenCL-Runtime-roc-3.3.0/CMakeLists.txt	2020-04-28 07:29:51.864446603 -0400
++++ ROCm-OpenCL-Runtime-roc-3.3.0/CMakeLists.txt	2020-04-28 07:32:45.245793180 -0400
+@@ -101,30 +101,30 @@
+ rocm_setup_version( VERSION "2.0.0" )
+ 
+ # MAIN package
+-install(PROGRAMS $<TARGET_FILE:clinfo>
+-        DESTINATION bin/x86_64
++install(PROGRAMS $<TARGET_FILE:rocm-clinfo>
++        DESTINATION bin
+         COMPONENT MAIN)
+ install(PROGRAMS $<TARGET_FILE:amdocl64>
+-        DESTINATION lib/x86_64
++        DESTINATION lib
+         COMPONENT MAIN)
+-install(PROGRAMS $<TARGET_FILE:OpenCL>
+-        DESTINATION lib/x86_64
++install(PROGRAMS $<TARGET_FILE:OpenCL-ROCm>
++        DESTINATION lib
+         COMPONENT MAIN)
+-install(PROGRAMS $<TARGET_SONAME_FILE:OpenCL>
+-        DESTINATION lib/x86_64
++install(PROGRAMS $<TARGET_SONAME_FILE:OpenCL-ROCm>
++        DESTINATION lib
+         COMPONENT MAIN)
+ 
+ # DEV package
+ install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/api/opencl/khronos/headers/opencl2.2/CL"
+-        DESTINATION include
++	DESTINATION include/rocm
+         COMPONENT DEV
+         USE_SOURCE_PERMISSIONS
+         PATTERN cl_d3d10.h EXCLUDE
+         PATTERN cl_d3d11.h EXCLUDE
+         PATTERN cl_dx9_media_sharing.h EXCLUDE
+         PATTERN cl_egl.h EXCLUDE)
+-install(PROGRAMS $<TARGET_LINKER_FILE:OpenCL>
+-        DESTINATION lib/x86_64
++install(PROGRAMS $<TARGET_LINKER_FILE:OpenCL-ROCm>
++        DESTINATION lib
+         COMPONENT DEV)
+ 
+ # Generic CPACK variables
+--- ROCm-OpenCL-Runtime-roc-3.3.0/tools/clinfo/CMakeLists.txt	2020-04-28 07:29:51.882446535 -0400
++++ ROCm-OpenCL-Runtime-roc-3.3.0/tools/clinfo/CMakeLists.txt	2020-04-28 07:30:05.627394732 -0400
+@@ -6,6 +6,6 @@
+ 
+ add_definitions(-DHAVE_CL2_HPP)
+ 
+-add_executable(clinfo clinfo.cpp)
++add_executable(rocm-clinfo clinfo.cpp)
+ 
+-target_link_libraries(clinfo OpenCL)
++target_link_libraries(rocm-clinfo OpenCL-ROCm)
diff --git a/srcpkgs/rocm-opencl-runtime/template b/srcpkgs/rocm-opencl-runtime/template
new file mode 100644
index 00000000000..f83c6e64149
--- /dev/null
+++ b/srcpkgs/rocm-opencl-runtime/template
@@ -0,0 +1,82 @@
+# Template file for 'rocm-opencl-runtime'
+pkgname=rocm-opencl-runtime
+version=3.3.0
+revision=1
+_ocl_icd_name="OpenCL-ICD-Loader"
+_ocl_icd_ver="6c03f8b58fafd9dd693eaac826749a5cfad515f8"
+archs="x86_64*"
+create_wrksrc=yes
+build_wrksrc="ROCm-OpenCL-Runtime-roc-${version}"
+build_style=cmake
+configure_args="-DUSE_COMGR_LIBRARY=yes"
+hostmakedepends="cmake pkg-config"
+makedepends="libglvnd-devel rocm-comgr-devel
+	roct-thunk-interface-devel rocr-runtime-devel"
+depends="rocm-comgr"
+short_desc="Radeon Open Compute OpenCL runtime"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="MIT"
+homepage="https://github.com/RadeonOpenCompute/ROCm-OpenCL-Runtime"
+_rocroot="https://github.com/RadeonOpenCompute"
+distfiles="${_rocroot}/ROCm-OpenCL-Runtime/archive/roc-${version}.tar.gz
+	${_rocroot}/rocm-cmake/archive/rocm-${version}.tar.gz
+	https://github.com/KhronosGroup/${_ocl_icd_name}/archive/${_ocl_icd_ver}.tar.gz"
+checksum="ac6999f1a491ab066286c2bd6adf50f08f831286f56e267879f9f7eced22f98e
+	76ed3ee8e56cf3246011cf7723c2abda539e1136e7e7f6909bfa45d268b8644f
+	c94d5bb6dc980c4d41d73e2b81663a19aabe494e923e2d0eec72a4c95b318438"
+nocross=yes
+
+post_patch() {
+	if [ "$XBPS_LIBC" = "musl" ]; then
+		# Copy sys/queue.h locally for MUSL builds
+		libelf_dir="compiler/lib/loaders/elf/utils/libelf"
+		cp "${FILESDIR}/sys_queue.h" "${libelf_dir}"
+
+		# Remove dependence on glibc
+		patch -Np0 < ${FILESDIR}/libelf-musl.patch
+		patch -Np0 < ${FILESDIR}/runtime-musl.patch
+		vsed -e '/glibc_functions.cpp/d' -i api/opencl/amdocl/CMakeLists.txt
+	fi
+}
+
+pre_configure() {
+	# ROCm requires a very specific Khronos ICD loader version in the tree
+	# Keep the ICD loader config in /etc/rocm/vendors to avoid conflicts
+	_ocl_icd_dir="${_ocl_icd_name}-${_ocl_icd_ver}"
+	ln -sf "${wrksrc}/${_ocl_icd_dir}" api/opencl/khronos/icd
+	vsed -i "${wrksrc}/${_ocl_icd_dir}/loader/icd_platform.h" \
+		-e 's@/etc/OpenCL/vendors/@/etc/rocm/vendors/@g'
+
+	# CMake modules probably not useful anywhere but for this build
+	ln -sf "${wrksrc}/rocm-cmake-rocm-${version}/share/rocm/cmake"/*.cmake cmake
+
+	# Fix the dlopen macro to point to versioned libamd_comgr shared object
+	vsed -i 'runtime/device/comgrctx.cpp' \
+		-e 's/\blibamd_comgr\(32\)\?.so\b/&.1/g'
+}
+
+post_install() {
+	vlicense License
+
+	# Create descriptor to allow the ICD loader to find the driver
+	_ocl_icd_dir="etc/rocm/vendors"
+	vmkdir "${_ocl_icd_dir}"
+	echo "libamdocl64.so" > "${DESTDIR}/${_ocl_icd_dir}/amdocl64.icd"
+}
+
+rocm-opencl-runtime-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/lib/libOpenCL-ROCm.so
+		vmove usr/include
+	}
+}
+
+rocm-opencl-runtime-clinfo_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - clinfo"
+	pkg_install() {
+		vmove usr/bin/rocm-clinfo
+	}
+}

From c39eeded06b5d0cfedd7059f59a2d9ab337c44bb Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Tue, 28 Apr 2020 13:33:46 -0400
Subject: [PATCH 9/9] hashcat: add build option to support new rocm packages

---
 srcpkgs/hashcat/files/rocm.patch | 35 ++++++++++++++++++++++++++++++++
 srcpkgs/hashcat/template         | 17 +++++++++++++---
 2 files changed, 49 insertions(+), 3 deletions(-)
 create mode 100644 srcpkgs/hashcat/files/rocm.patch

diff --git a/srcpkgs/hashcat/files/rocm.patch b/srcpkgs/hashcat/files/rocm.patch
new file mode 100644
index 00000000000..5f7e4e69197
--- /dev/null
+++ b/srcpkgs/hashcat/files/rocm.patch
@@ -0,0 +1,35 @@
+diff -ur a/src/folder.c b/src/folder.c
+--- a/src/folder.c	2018-12-02 05:58:48.000000000 -0500
++++ b/src/folder.c	2020-04-28 13:22:27.340522751 -0400
+@@ -457,16 +457,6 @@
+ 
+   hcfree (cpath);
+ 
+-  //if (getenv ("TMP") == NULL)
+-  if (1)
+-  {
+-    char *tmp;
+-
+-    hc_asprintf (&tmp, "TMP=%s", cpath_real);
+-
+-    putenv (tmp);
+-  }
+-
+   #if defined (_WIN)
+ 
+   naive_replace (cpath_real, '\\', '/');
+diff -ur a/src/opencl.c b/src/opencl.c
+--- a/src/opencl.c	2018-12-02 05:58:48.000000000 -0500
++++ b/src/opencl.c	2020-04-28 13:24:12.602415333 -0400
+@@ -492,9 +492,9 @@
+ 
+   if (ocl->lib == NULL) ocl->lib = hc_dlopen ("cygOpenCL-1.dll", RTLD_NOW);
+   #else
+-  ocl->lib = hc_dlopen ("libOpenCL.so", RTLD_NOW);
++  ocl->lib = hc_dlopen ("libOpenCL-ROCm.so.1", RTLD_NOW);
+ 
+-  if (ocl->lib == NULL) ocl->lib = hc_dlopen ("libOpenCL.so.1", RTLD_NOW);
++  if (ocl->lib == NULL) ocl->lib = hc_dlopen ("libOpenCL-ROCm.so", RTLD_NOW);
+   #endif
+ 
+   if (ocl->lib == NULL)
diff --git a/srcpkgs/hashcat/template b/srcpkgs/hashcat/template
index e982f99cebf..7d3a8cb5a6b 100644
--- a/srcpkgs/hashcat/template
+++ b/srcpkgs/hashcat/template
@@ -1,15 +1,16 @@
 # Template file for 'hashcat'
 pkgname=hashcat
 version=5.1.0
-revision=2
+revision=3
 build_style=gnu-makefile
 make_build_args="PREFIX=/usr
  USE_SYSTEM_OPENCL=1 USE_SYSTEM_XXHASH=1
- DEPS_OPENCL_PATH=${XBPS_CROSS_BASE}/usr/include
+ DEPS_OPENCL_PATH=${XBPS_CROSS_BASE}/usr/include$(vopt_if rocm /rocm)
  DEPS_XXHASH_PATH=${XBPS_CROSS_BASE}/usr/include"
 make_use_env=yes
 make_install_args="$make_build_args"
-makedepends="gmp-devel opencl2-headers xxHash-devel"
+makedepends="gmp-devel xxHash-devel
+ $(vopt_if rocm rocm-opencl-runtime-devel opencl2-headers)"
 checkdepends="perl"
 short_desc="Advanced CPU-based password recovery utility"
 maintainer="Duncaen <duncaen@voidlinux.org>"
@@ -19,6 +20,9 @@ changelog="https://raw.githubusercontent.com/hashcat/hashcat/master/docs/changes
 distfiles="https://hashcat.net/files/hashcat-${version}.tar.gz"
 checksum=283beaa68e1eab41de080a58bb92349c8e47a2bb1b93d10f36ea30f418f1e338
 
+build_options="rocm"
+desc_option_rocm="Use ROCm OpenCL runtime"
+
 if [ "$XBPS_TARGET_ENDIAN" = "be" ]; then
 	broken="Not supported on big endian"
 fi
@@ -26,6 +30,13 @@ fi
 post_extract() {
 	sed '/^CC/d' -i src/Makefile
 }
+
+post_patch() {
+	if [ "$build_option_rocm" ]; then
+		patch -Np1 < ${FILESDIR}/rocm.patch
+	fi
+}
+
 post_install() {
 	rm -f ${DESTDIR}/usr/share/docs/hashcat/license.txt
 	vlicense docs/license.txt

^ permalink raw reply	[flat|nested] 61+ messages in thread

* Re: [PR PATCH] [Updated] New packages: ROCm core and OpenCL
  2020-04-19 13:34 [PR PATCH] New packages: ROCm core and OpenCL ahesford
                   ` (6 preceding siblings ...)
  2020-04-28 17:34 ` ahesford
@ 2020-04-28 17:34 ` ahesford
  2020-04-28 17:38 ` ahesford
                   ` (51 subsequent siblings)
  59 siblings, 0 replies; 61+ messages in thread
From: ahesford @ 2020-04-28 17:34 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 3893 bytes --]

There is an updated pull request by ahesford against master on the void-packages repository

https://github.com/ahesford/void-packages rocm
https://github.com/void-linux/void-packages/pull/21153

New packages: ROCm core and OpenCL
This PR includes several packages designed to bring the OpenCL portion of the AMD ROCm ecosystem to Void. It addresses Issue #19507. There are many other packages that AMD provides for GPGPU computing, but these can be added piecemeal as users demand.

The packages are currently only for `x86_64*`. While at least some of the packages will compile on other 64-bit architectures, I have no hardware to test. They are certainly not suitable for 32-bit architectures; some internal data structures rely on `uint64_t` values that are cast to pointers. At a
minimum, a thorough audit would be necessary to ensure that these casts are safe (e.g., that the values stored were only ever upcast from 32-bit pointers). More extensive work may be necessary to support 32-bit architectures, probably without significant benefit.

The packages successfully identify a Radeon RX 580 on an `x86_64` installation using both `clinfo` and `rocminfo` as provided. Furthermore, a version of `pyopencl` linked against these ROCm packages successfully runs a simple program that validates arithmetic on GPU-bound arrays.

There are caveats with this set of packages, almost all of which revolve around the incompatibilities between the Void-provided `ocl-icd` and the [Khronos OpenCL ICD loader](https://github.com/KhronosGroup/OpenCL-ID-Loader) required by (and built into) `rocm-opencl-runtime`.
1. All packages install into `/opt/rocm`. This keeps the environment closer to that officially sanctioned by AMD and helps avoid conflicts between other packages and those provided here. (For example, `clinfo` and the ICD loader itself.) Eventually, we may be able to move the files into `/usr`.
2. The Khronos OpenCL ICD loader built into `rocm-opencl-runtime` is an outdated, pre-release commit. If AMD can update its sources to use the release version of that loader (which has a backward-incompatible API change), we may be able to make ROCm compatible with `ocl-icd` or replace `ocl-icd` with the official Khronos loader.
3. In the meantime, to avoid `shlibs` conflicts, the OpenCL ICD loader is installed as `/opt/rocm/lib/libOpenCL-ROCm.so` (and an appropriately versioned shared library), which means that programs wishing to use the ROCm OpenCL must explicitly link against this library instead of the generic `libOpenCL.so`.
4. I do **not** recommend making any Void packages link against this specific library, because it will make those packages ROCm-only. For the time being, ROCm is intended for end-users to specifically link against. Linking Void packages against ROCm would requires the ICD loader used by ROCm be compatible with `ocl-icd`, or `ocl-icd` be replaced by the Khronos loader. However, because the Khronos loader changed its API for the release version, such a change is not yet appropriate.

Hopefully, if AMD updates its dependence on the Khronos ICD loader, we can resolve some of these caveats in the future and make ROCm a more natural Void component. For now, these packages are useful for those who need an AMD OpenCL solution and would rather custom-link software against the AMD ICD loader than hack the `amdgpu-pro` driver into an ICD compatible with `ocl-icd`.

Some patches were made to relocate some files in `/opt/rocm` and make everyting build on x86_64-musl`. Where appropriate, these patches will be pushed upstream to clean up the distribution and packaging.

Update: I pushed some new commits to update license information that triggerd an `xlint` failure. I've also disabled CI builds because they will time out on `rocm-llvm`.

A patch file from https://github.com/void-linux/void-packages/pull/21153.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-rocm-21153.patch --]
[-- Type: text/x-diff, Size: 76993 bytes --]

From 1226ae1e7c5eea64be3859bb36eee4fd8c6cccc6 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Mon, 13 Apr 2020 13:08:09 -0400
Subject: [PATCH 1/9] New package: roct-thunk-interface-3.3.0

---
 common/shlibs                                 |  1 +
 srcpkgs/roct-thunk-interface-devel            |  1 +
 .../patches/cmake-dev-libdir.patch            | 10 ++++++
 .../roct-thunk-interface/patches/musl.patch   | 29 ++++++++++++++++
 srcpkgs/roct-thunk-interface/template         | 33 +++++++++++++++++++
 5 files changed, 74 insertions(+)
 create mode 120000 srcpkgs/roct-thunk-interface-devel
 create mode 100644 srcpkgs/roct-thunk-interface/patches/cmake-dev-libdir.patch
 create mode 100644 srcpkgs/roct-thunk-interface/patches/musl.patch
 create mode 100644 srcpkgs/roct-thunk-interface/template

diff --git a/common/shlibs b/common/shlibs
index 6d39ce34c19..d89ae72ae3e 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3862,3 +3862,4 @@ libtagparser.so.9 tagparser-9.1.2_1
 libqtutilities.so.6 qtutilities-6.0.4_1
 libkdsoap.so.1.9.0 KDSoap-1.9.0_1
 libstoken.so.1 stoken-0.92_1
+libhsakmt.so.1 roct-thunk-interface-3.3.0_1
diff --git a/srcpkgs/roct-thunk-interface-devel b/srcpkgs/roct-thunk-interface-devel
new file mode 120000
index 00000000000..ac3f2cc684c
--- /dev/null
+++ b/srcpkgs/roct-thunk-interface-devel
@@ -0,0 +1 @@
+roct-thunk-interface
\ No newline at end of file
diff --git a/srcpkgs/roct-thunk-interface/patches/cmake-dev-libdir.patch b/srcpkgs/roct-thunk-interface/patches/cmake-dev-libdir.patch
new file mode 100644
index 00000000000..98c7f1e459c
--- /dev/null
+++ b/srcpkgs/roct-thunk-interface/patches/cmake-dev-libdir.patch
@@ -0,0 +1,10 @@
+--- CMakeLists.txt.old	2020-04-18 19:45:17.306081135 -0400
++++ CMakeLists.txt	2020-04-18 19:46:51.300753636 -0400
+@@ -146,6 +146,7 @@
+     COMMAND ${CMAKE_COMMAND}
+         -DSOURCE_DIR="${SOURCE_DIR}"
+         -DCMAKE_INSTALL_PREFIX="${CMAKE_INSTALL_PREFIX}"
++        -DCMAKE_INSTALL_LIBDIR="${CMAKE_INSTALL_LIBDIR}"
+         -DCPACK_RPM_PACKAGE_REQUIRES="hsakmt-roct"
+         -DCPACK_PACKAGING_INSTALL_PREFIX="${CPACK_PACKAGING_INSTALL_PREFIX}"
+         -DVERSION="${BUILD_VERSION_STRING}"
diff --git a/srcpkgs/roct-thunk-interface/patches/musl.patch b/srcpkgs/roct-thunk-interface/patches/musl.patch
new file mode 100644
index 00000000000..aeea9832411
--- /dev/null
+++ b/srcpkgs/roct-thunk-interface/patches/musl.patch
@@ -0,0 +1,29 @@
+diff -r -u old/src/libhsakmt.h new/src/libhsakmt.h
+--- src/libhsakmt.h	2020-03-04 15:00:47.000000000 -0500
++++ src/libhsakmt.h	2020-04-13 12:58:30.444865992 -0400
+@@ -54,6 +54,10 @@
+ #define CHECK_KFD_OPEN() \
+ 	do { if (kfd_open_count == 0 || hsakmt_forked) return HSAKMT_STATUS_KERNEL_IO_CHANNEL_NOT_OPENED; } while (0)
+ 
++/*On some platforms, a PAGE_SIZE macro eclipses the extern variable*/
++#ifdef PAGE_SIZE
++#undef PAGE_SIZE
++#endif
+ extern int PAGE_SIZE;
+ extern int PAGE_SHIFT;
+ 
+diff -r -u old/src/topology.c new/src/topology.c
+--- src/topology.c	2020-03-04 15:00:47.000000000 -0500
++++ src/topology.c	2020-04-13 13:01:31.209870701 -0400
+@@ -38,6 +38,11 @@
+ #include "libhsakmt.h"
+ #include "fmm.h"
+ 
++/*Needed on MUSL*/
++#ifndef MAXNAMLEN
++#define MAXNAMLEN PATH_MAX
++#endif
++
+ /* Number of memory banks added by thunk on top of topology
+  * This only includes static heaps like LDS, scratch and SVM,
+  * not for MMIO_REMAP heap. MMIO_REMAP memory bank is reported
diff --git a/srcpkgs/roct-thunk-interface/template b/srcpkgs/roct-thunk-interface/template
new file mode 100644
index 00000000000..55a1fc6074a
--- /dev/null
+++ b/srcpkgs/roct-thunk-interface/template
@@ -0,0 +1,33 @@
+# Template file for 'roct-thunk-interface'
+pkgname=roct-thunk-interface
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="ROCT-Thunk-Interface-roc-${version}"
+build_style=cmake
+make_build_target="all build-dev"
+make_install_target="install install-dev"
+hostmakedepends="cmake pkg-config"
+makedepends="pciutils-devel libnuma-devel"
+short_desc="Radeon Open Compute Thunk Interface"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="MIT"
+homepage="https://github.com/RadeonOpenCompute/ROCT-Thunk-Interface"
+distfiles="${homepage}/archive/roc-${version}.tar.gz"
+checksum=2cabe9d2cfa72031c05d11290837c476182e72d8dec2049298f691143fdd212b
+nocross=yes
+
+post_install() {
+	vlicense LICENSE.md
+}
+
+roct-thunk-interface-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove "usr/lib/*.so"
+		vmove usr/share/pkgconfig
+		vmove usr/lib/cmake
+	}
+}

From d8bb69aca8ebcd167198d858c11e7b7fa326c389 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Mon, 13 Apr 2020 15:27:27 -0400
Subject: [PATCH 2/9] New package: rocr-runtime-3.3.0

---
 common/shlibs                            |  1 +
 srcpkgs/rocr-runtime-devel               |  1 +
 srcpkgs/rocr-runtime/patches/cmake.patch | 27 +++++++++++++++++++++
 srcpkgs/rocr-runtime/template            | 30 ++++++++++++++++++++++++
 4 files changed, 59 insertions(+)
 create mode 120000 srcpkgs/rocr-runtime-devel
 create mode 100644 srcpkgs/rocr-runtime/patches/cmake.patch
 create mode 100644 srcpkgs/rocr-runtime/template

diff --git a/common/shlibs b/common/shlibs
index d89ae72ae3e..499f35752c2 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3863,3 +3863,4 @@ libqtutilities.so.6 qtutilities-6.0.4_1
 libkdsoap.so.1.9.0 KDSoap-1.9.0_1
 libstoken.so.1 stoken-0.92_1
 libhsakmt.so.1 roct-thunk-interface-3.3.0_1
+libhsa-runtime64.so.1 rocr-runtime-3.3.0_1
diff --git a/srcpkgs/rocr-runtime-devel b/srcpkgs/rocr-runtime-devel
new file mode 120000
index 00000000000..be838f22d81
--- /dev/null
+++ b/srcpkgs/rocr-runtime-devel
@@ -0,0 +1 @@
+rocr-runtime
\ No newline at end of file
diff --git a/srcpkgs/rocr-runtime/patches/cmake.patch b/srcpkgs/rocr-runtime/patches/cmake.patch
new file mode 100644
index 00000000000..93b74cd2297
--- /dev/null
+++ b/srcpkgs/rocr-runtime/patches/cmake.patch
@@ -0,0 +1,27 @@
+--- src/CMakeLists.txt.old	2020-04-18 20:01:48.549636995 -0400
++++ src/CMakeLists.txt	2020-04-18 20:04:00.177179781 -0400
+@@ -108,8 +108,8 @@
+ ## ROCr build internal versioning
+ add_definitions ( -DROCR_BUILD_ID=${PACKAGE_VERSION_STRING} )
+ 
+-## Set RUNPATH - ../../lib covers use of the legacy symlink in /hsa/lib/
+-set(CMAKE_INSTALL_RPATH "$ORIGIN;$ORIGIN/../../lib;$ORIGIN/../../lib64;$ORIGIN/../lib64")
++## Set RUNPATH
++set(CMAKE_INSTALL_RPATH "$ORIGIN;$ORIGIN/../lib")
+ 
+ ## ------------------------- Linux Compiler and Linker options -------------------------
+ set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -fexceptions -fno-rtti -fvisibility=hidden -Wno-error=sign-compare -Wno-sign-compare -Wno-write-strings -Wno-conversion-null -fno-math-errno -fno-threadsafe-statics -fmerge-all-constants -fms-extensions -Wno-error=comment -Wno-comment -Wno-error=pointer-arith -Wno-pointer-arith -Wno-error=unused-variable -Wno-error=unused-function" )
+@@ -185,11 +185,8 @@
+ add_custom_target ( hsa_lib_link2 ALL WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMAND ${CMAKE_COMMAND} -E create_symlink ../hsa/lib/${CORE_RUNTIME_LIBRARY}.so.${SO_MAJOR} ${CORE_RUNTIME_LIBRARY}-link.so.${SO_MAJOR} )
+ 
+ ## Set install information
+-install ( TARGETS ${CORE_RUNTIME_TARGET} LIBRARY DESTINATION hsa/lib )
+-install ( DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/inc/ DESTINATION hsa/include/hsa )
+-install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/hsa_include_link DESTINATION include PERMISSIONS OWNER_WRITE OWNER_READ RENAME hsa )
+-install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/${CORE_RUNTIME_LIBRARY}-link.so DESTINATION lib PERMISSIONS OWNER_WRITE OWNER_READ RENAME ${CORE_RUNTIME_LIBRARY}.so )
+-install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/${CORE_RUNTIME_LIBRARY}-link.so.${SO_MAJOR} DESTINATION lib PERMISSIONS OWNER_WRITE OWNER_READ RENAME ${CORE_RUNTIME_LIBRARY}.so.${SO_MAJOR} )
++install ( TARGETS ${CORE_RUNTIME_TARGET} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} )
++install ( DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/inc/ DESTINATION include/hsa )
+ 
+ ## Packaging directives
+ set ( CPACK_GENERATOR "DEB;RPM" CACHE STRING "Package types to build")
diff --git a/srcpkgs/rocr-runtime/template b/srcpkgs/rocr-runtime/template
new file mode 100644
index 00000000000..5ee22140f1f
--- /dev/null
+++ b/srcpkgs/rocr-runtime/template
@@ -0,0 +1,30 @@
+# Template file for 'rocr-runtime'
+pkgname=rocr-runtime
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="ROCR-Runtime-rocm-${version}"
+build_wrksrc="src"
+build_style=cmake
+hostmakedepends="cmake pkg-config"
+makedepends="roct-thunk-interface-devel elfutils-devel"
+short_desc="Radeon Open Compute HSA Runtime"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute/ROCR-Runtime"
+distfiles="${homepage}/archive/rocm-${version}.tar.gz"
+checksum=fa2d2d1f8a61d8a6952d377cf288d78c61776c3c2a666f163cafc3aa19ab0b61
+nocross=yes
+
+post_install() {
+	vlicense ../LICENSE.txt
+}
+
+rocr-runtime-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove "usr/lib/*.so"
+	}
+}

From 8094f1ed5017c36dc9129b73ed78188378a51284 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Mon, 13 Apr 2020 18:07:34 -0400
Subject: [PATCH 3/9] New package: rocm-llvm-3.3.0

---
 srcpkgs/rocm-llvm/template | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)
 create mode 100644 srcpkgs/rocm-llvm/template

diff --git a/srcpkgs/rocm-llvm/template b/srcpkgs/rocm-llvm/template
new file mode 100644
index 00000000000..26942e3ea46
--- /dev/null
+++ b/srcpkgs/rocm-llvm/template
@@ -0,0 +1,25 @@
+# Template file for 'rocm-llvm'
+pkgname=rocm-llvm
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="llvm-project-rocm-ocl-${version}"
+build_wrksrc=llvm
+build_style=cmake
+configure_args="-DCMAKE_INSTALL_PREFIX:PATH=/usr/lib/rocm-llvm
+	-DLLVM_ENABLE_PROJECTS='llvm;clang;lld' -DLLVM_TARGETS_TO_BUILD='AMDGPU'
+	-DLLVM_BUILD_DOCS=NO -DLLVM_ENABLE_OCAMLDOC=OFF
+	-DLLVM_ENABLE_SPHINX=NO -DLLVM_ENABLE_DOXYGEN=OFF
+	-DLLVM_INSTALL_UTILS=ON -DLLVM_VERSION_SUFFIX=roc -DOCAMLFIND=NO"
+hostmakedepends="cmake pkg-config python3"
+short_desc="Radeon Open Compute LLVM toolchain"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="Apache-2.0, NCSA, custom:LLVM-Exceptions"
+homepage="https://github.com/RadeonOpenCompute/llvm-project"
+distfiles="${homepage}/archive/rocm-ocl-${version}.tar.gz"
+checksum=a2bef7042e8e2f2cd8548cb246b88322e1c77188839983dcac8312d56f544dc8
+nocross=yes
+
+post_install() {
+	vlicense LICENSE.TXT
+}

From 0e7977b668140e095f21839a24923005b3029c81 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Tue, 14 Apr 2020 10:25:31 -0400
Subject: [PATCH 4/9] New package: rocm-device-libs-3.3.0

---
 srcpkgs/rocm-device-libs/template | 37 +++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)
 create mode 100644 srcpkgs/rocm-device-libs/template

diff --git a/srcpkgs/rocm-device-libs/template b/srcpkgs/rocm-device-libs/template
new file mode 100644
index 00000000000..fcb4eb0d53e
--- /dev/null
+++ b/srcpkgs/rocm-device-libs/template
@@ -0,0 +1,37 @@
+# Template file for 'rocm-device-libs'
+pkgname=rocm-device-libs
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="ROCm-Device-Libs-rocm-ocl-${version}"
+build_style=cmake
+configure_args="-DLLVM_DIR:PATH=/usr/lib/rocm-llvm
+	-DCMAKE_INSTALL_LIBDIR:PATH=lib/rocm-device-libs"
+hostmakedepends="cmake rocm-llvm"
+short_desc="Radeon Open Compute device libraries"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute/ROCm-Device-Libs"
+distfiles="${homepage}/archive/rocm-ocl-${version}.tar.gz"
+checksum=706b08230790e08ca6a7a2fb7687d6131fd39a562148340e00fa37a6c06769c5
+nocross=yes
+
+pre_configure() {
+	# Put bytecodes in a lib/ subdirectory
+	vsed -i Packages.cmake -e 's@/lib/@/${CMAKE_INSTALL_LIBDIR}/@'
+	vsed -i OCL.cmake -e 's@DESTINATION lib$@DESTINATION ${CMAKE_INSTALL_LIBDIR}@'
+
+	# Build the prepare-builtins executable with native compiler
+	mkdir -p utils/build
+	cd utils/build
+	_prepare_builtins="$PWD/prepare-builtins/prepare-builtins"
+	cmake ${configure_args} ..
+	make ${makejobs}
+
+	# Add path to prepare-builtins for cmake
+	configure_args+=" -DPREPARE_BUILTINS='${_prepare_builtins}'"
+}
+
+post_install() {
+	vlicense LICENSE
+}

From 81355a023645398d9f99fcd99988a9f61f5f0777 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Mon, 13 Apr 2020 18:30:00 -0400
Subject: [PATCH 5/9] New package: rocm-comgr-3.3.0

---
 common/shlibs               |  1 +
 srcpkgs/rocm-comgr-devel    |  1 +
 srcpkgs/rocm-comgr/template | 32 ++++++++++++++++++++++++++++++++
 3 files changed, 34 insertions(+)
 create mode 120000 srcpkgs/rocm-comgr-devel
 create mode 100644 srcpkgs/rocm-comgr/template

diff --git a/common/shlibs b/common/shlibs
index 499f35752c2..a53de3cf9e0 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3864,3 +3864,4 @@ libkdsoap.so.1.9.0 KDSoap-1.9.0_1
 libstoken.so.1 stoken-0.92_1
 libhsakmt.so.1 roct-thunk-interface-3.3.0_1
 libhsa-runtime64.so.1 rocr-runtime-3.3.0_1
+libamd_comgr.so.1 rocm-comgr-3.3.0_1
diff --git a/srcpkgs/rocm-comgr-devel b/srcpkgs/rocm-comgr-devel
new file mode 120000
index 00000000000..3f5ce255e07
--- /dev/null
+++ b/srcpkgs/rocm-comgr-devel
@@ -0,0 +1 @@
+rocm-comgr
\ No newline at end of file
diff --git a/srcpkgs/rocm-comgr/template b/srcpkgs/rocm-comgr/template
new file mode 100644
index 00000000000..c228bcd4d1f
--- /dev/null
+++ b/srcpkgs/rocm-comgr/template
@@ -0,0 +1,32 @@
+# Template file for 'rocm-comgr'
+pkgname=rocm-comgr
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="ROCm-CompilerSupport-rocm-${version}"
+build_wrksrc="lib/comgr"
+build_style=cmake
+configure_args="-DClang_DIR:PATH=/usr/lib/rocm-llvm/lib/cmake/clang"
+hostmakedepends="cmake pkg-config rocm-llvm"
+makedepends="rocm-device-libs"
+short_desc="Radeon Open Compute Code Object Manager"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="BSD-3-Clause"
+homepage="https://github.com/RadeonOpenCompute/ROCm-CompilerSupport"
+distfiles="${homepage}/archive/rocm-${version}.tar.gz"
+checksum=01e2524e0f28ecd6f46c9720f279207de935d826b0172158792aa3ec86af9ca7
+nocross=yes
+
+post_install() {
+	vlicense LICENSE.txt
+}
+
+rocm-comgr-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove "usr/lib/*.so"
+		vmove usr/lib/cmake
+	}
+}

From 1dda7453d2c6b722fc45c445c49bebd948ea5bda Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Fri, 17 Apr 2020 12:11:25 -0400
Subject: [PATCH 6/9] New package: rocminfo-3.3.0

---
 srcpkgs/rocminfo/template | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
 create mode 100644 srcpkgs/rocminfo/template

diff --git a/srcpkgs/rocminfo/template b/srcpkgs/rocminfo/template
new file mode 100644
index 00000000000..57d0640dd69
--- /dev/null
+++ b/srcpkgs/rocminfo/template
@@ -0,0 +1,22 @@
+# Template file for 'rocminfo'
+pkgname=rocminfo
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="rocminfo-rocm-${version}"
+build_style=cmake
+configure_args="-DROCM_DIR=/usr"
+hostmakedepends="cmake pkg-config"
+makedepends="rocr-runtime-devel"
+short_desc="Radeon Open Compute system information reporter"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute/rocminfo"
+distfiles="${homepage}/archive/rocm-${version}.tar.gz"
+checksum=e666f662c9e465aaabbbd0b109d87e017243cdf1a0898fabf5a90947bb3dbcd7
+nocross=yes
+python_version=3
+
+post_install() {
+	vlicense License.txt
+}

From e84da1d860708fe8c5d8b144500711d167743578 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Sun, 19 Apr 2020 15:01:40 -0400
Subject: [PATCH 7/9] New package: rocm-bandwidth-test-3.3.0

---
 srcpkgs/rocm-bandwidth-test/template | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
 create mode 100644 srcpkgs/rocm-bandwidth-test/template

diff --git a/srcpkgs/rocm-bandwidth-test/template b/srcpkgs/rocm-bandwidth-test/template
new file mode 100644
index 00000000000..5c5058b693d
--- /dev/null
+++ b/srcpkgs/rocm-bandwidth-test/template
@@ -0,0 +1,20 @@
+# Template file for 'rocm-bandwidth-test'
+pkgname=rocm-bandwidth-test
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="rocm_bandwidth_test-rocm-${version}"
+build_style=cmake
+hostmakedepends="cmake"
+makedepends="rocr-runtime-devel roct-thunk-interface-devel"
+short_desc="Radeon Open Compute bandwidth test"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute/rocm_bandwidth_test"
+distfiles="${homepage}/archive/rocm-${version}.tar.gz"
+checksum=f5f914073018619dc91662d5bf630903dfa4db9136d603591917fdfb3c9164ce
+nocross=yes
+
+post_install() {
+	vlicense LICENSE.txt
+}

From da03023ab238ff56bbe9cf41064c04007f11053a Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Tue, 14 Apr 2020 10:25:54 -0400
Subject: [PATCH 8/9] New package: rocm-opencl-runtime-3.3.0 [ci skip]

---
 common/shlibs                                 |   2 +
 srcpkgs/rocm-opencl-runtime-clinfo            |   1 +
 srcpkgs/rocm-opencl-runtime-devel             |   1 +
 .../files/libelf-musl.patch                   | 688 ++++++++++++++++++
 .../files/runtime-musl.patch                  |  11 +
 srcpkgs/rocm-opencl-runtime/files/sys_queue.h | 574 +++++++++++++++
 .../rocm-opencl-runtime/patches/cmake.patch   | 126 ++++
 srcpkgs/rocm-opencl-runtime/template          |  82 +++
 8 files changed, 1485 insertions(+)
 create mode 120000 srcpkgs/rocm-opencl-runtime-clinfo
 create mode 120000 srcpkgs/rocm-opencl-runtime-devel
 create mode 100644 srcpkgs/rocm-opencl-runtime/files/libelf-musl.patch
 create mode 100644 srcpkgs/rocm-opencl-runtime/files/runtime-musl.patch
 create mode 100644 srcpkgs/rocm-opencl-runtime/files/sys_queue.h
 create mode 100644 srcpkgs/rocm-opencl-runtime/patches/cmake.patch
 create mode 100644 srcpkgs/rocm-opencl-runtime/template

diff --git a/common/shlibs b/common/shlibs
index a53de3cf9e0..8cbc885e016 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3865,3 +3865,5 @@ libstoken.so.1 stoken-0.92_1
 libhsakmt.so.1 roct-thunk-interface-3.3.0_1
 libhsa-runtime64.so.1 rocr-runtime-3.3.0_1
 libamd_comgr.so.1 rocm-comgr-3.3.0_1
+libOpenCL-ROCm.so.1 rocm-opencl-runtime-3.3.0_1
+libamdocl64.so rocm-opencl-runtime-3.3.0_1
diff --git a/srcpkgs/rocm-opencl-runtime-clinfo b/srcpkgs/rocm-opencl-runtime-clinfo
new file mode 120000
index 00000000000..b2cda7e229d
--- /dev/null
+++ b/srcpkgs/rocm-opencl-runtime-clinfo
@@ -0,0 +1 @@
+rocm-opencl-runtime
\ No newline at end of file
diff --git a/srcpkgs/rocm-opencl-runtime-devel b/srcpkgs/rocm-opencl-runtime-devel
new file mode 120000
index 00000000000..b2cda7e229d
--- /dev/null
+++ b/srcpkgs/rocm-opencl-runtime-devel
@@ -0,0 +1 @@
+rocm-opencl-runtime
\ No newline at end of file
diff --git a/srcpkgs/rocm-opencl-runtime/files/libelf-musl.patch b/srcpkgs/rocm-opencl-runtime/files/libelf-musl.patch
new file mode 100644
index 00000000000..a3705c259a9
--- /dev/null
+++ b/srcpkgs/rocm-opencl-runtime/files/libelf-musl.patch
@@ -0,0 +1,688 @@
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/_libelf.h compiler/lib/loaders/elf/utils/libelf/_libelf.h
+--- compiler/lib/loaders/elf/utils/libelf.orig/_libelf.h	2020-04-19 08:59:34.201386585 -0400
++++ compiler/lib/loaders/elf/utils/libelf/_libelf.h	2020-04-19 09:04:12.950433528 -0400
+@@ -30,7 +30,7 @@
+ #define	__LIBELF_H_
+ 
+ #include <limits.h>
+-#include <sys/queue.h>
++#include "sys_queue.h"
+ 
+ #include "_libelf_config.h"
+ 
+@@ -179,7 +179,9 @@
+  * Function Prototypes.
+  */
+ 
+-__BEGIN_DECLS
++#ifdef __cplusplus
++extern "C" {
++#endif
+ Elf_Data *_libelf_allocate_data(Elf_Scn *_s);
+ Elf	*_libelf_allocate_elf(Elf_Mem *mem);
+ Elf_Scn	*_libelf_allocate_scn(Elf *_e, size_t _ndx);
+@@ -213,6 +215,8 @@
+ Elf_Data *_libelf_xlate(Elf_Data *_d, const Elf_Data *_s,
+     unsigned int _encoding, int _elfclass, int _direction);
+ int	_libelf_xlate_shtype(uint32_t _sht);
+-__END_DECLS
++#ifdef __cplusplus
++}
++#endif
+ 
+ #endif	/* __LIBELF_H_ */
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_begin.c compiler/lib/loaders/elf/utils/libelf/elf_begin.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_begin.c	2020-04-19 08:59:34.201386585 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_begin.c	2020-04-19 09:01:04.313212042 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <sys/types.h>
+ #if !defined(WIN32)
+ #include <sys/errno.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_end.c compiler/lib/loaders/elf/utils/libelf/elf_end.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_end.c	2020-04-19 08:59:34.201386585 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_end.c	2020-04-19 09:01:14.895204681 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #if !defined(WIN32)
+ #include <sys/mman.h>
+ #endif
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_errmsg.c compiler/lib/loaders/elf/utils/libelf/elf_errmsg.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_errmsg.c	2020-04-19 08:59:34.201386585 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_errmsg.c	2020-04-19 09:01:16.753207065 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ #include <stdio.h>
+ #include <string.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_errno.c compiler/lib/loaders/elf/utils/libelf/elf_errno.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_errno.c	2020-04-19 08:59:34.201386585 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_errno.c	2020-04-19 09:01:18.669209528 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_fill.c compiler/lib/loaders/elf/utils/libelf/elf_fill.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_fill.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_fill.c	2020-04-19 09:01:21.109212667 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_flag.c compiler/lib/loaders/elf/utils/libelf/elf_flag.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_flag.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_flag.c	2020-04-19 09:01:23.376215579 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_getarhdr.c compiler/lib/loaders/elf/utils/libelf/elf_getarhdr.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_getarhdr.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_getarhdr.c	2020-04-19 09:01:25.414218197 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_getarsym.c compiler/lib/loaders/elf/utils/libelf/elf_getarsym.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_getarsym.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_getarsym.c	2020-04-19 09:01:27.575220978 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_getbase.c compiler/lib/loaders/elf/utils/libelf/elf_getbase.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_getbase.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_getbase.c	2020-04-19 09:01:29.963224043 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_getident.c compiler/lib/loaders/elf/utils/libelf/elf_getident.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_getident.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_getident.c	2020-04-19 09:01:31.912226551 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <ar.h>
+ #include <assert.h>
+ #include <libelf.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_hash.c compiler/lib/loaders/elf/utils/libelf/elf_hash.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_hash.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_hash.c	2020-04-19 09:01:33.877229069 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ #include "_libelf_config.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_kind.c compiler/lib/loaders/elf/utils/libelf/elf_kind.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_kind.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_kind.c	2020-04-19 09:01:35.940231721 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_memory.c compiler/lib/loaders/elf/utils/libelf/elf_memory.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_memory.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_memory.c	2020-04-19 09:01:38.171234596 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <ar.h>
+ #include <libelf.h>
+ #include <string.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_next.c compiler/lib/loaders/elf/utils/libelf/elf_next.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_next.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_next.c	2020-04-19 09:01:40.063237028 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <ar.h>
+ #include <assert.h>
+ #include <libelf.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_phnum.c compiler/lib/loaders/elf/utils/libelf/elf_phnum.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_phnum.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_phnum.c	2020-04-19 09:01:42.480240134 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <ar.h>
+ #include <libelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_rand.c compiler/lib/loaders/elf/utils/libelf/elf_rand.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_rand.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_rand.c	2020-04-19 09:01:45.061243452 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <ar.h>
+ #include <libelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_rawfile.c compiler/lib/loaders/elf/utils/libelf/elf_rawfile.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_rawfile.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_rawfile.c	2020-04-19 09:01:46.988245928 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_scn.c compiler/lib/loaders/elf/utils/libelf/elf_scn.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_scn.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_scn.c	2020-04-19 09:00:19.724298403 -0400
+@@ -24,8 +24,7 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-#include <sys/queue.h>
++#include "sys_queue.h"
+ 
+ #include <assert.h>
+ #include <errno.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_shnum.c compiler/lib/loaders/elf/utils/libelf/elf_shnum.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_shnum.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_shnum.c	2020-04-19 09:01:51.763252060 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <ar.h>
+ #include <libelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_shstrndx.c compiler/lib/loaders/elf/utils/libelf/elf_shstrndx.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_shstrndx.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_shstrndx.c	2020-04-19 09:01:53.532254340 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <ar.h>
+ #include <libelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_version.c compiler/lib/loaders/elf/utils/libelf/elf_version.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_version.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_version.c	2020-04-19 09:02:01.337264370 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf.h compiler/lib/loaders/elf/utils/libelf/gelf.h
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf.h	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf.h	2020-04-19 09:04:29.669455020 -0400
+@@ -29,8 +29,6 @@
+ #ifndef	_GELF_H_
+ #define	_GELF_H_
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ typedef Elf64_Addr	GElf_Addr;	/* Addresses */
+@@ -72,7 +70,9 @@
+ #define	GELF_ST_TYPE			ELF64_ST_TYPE
+ #define	GELF_ST_VISIBILITY		ELF64_ST_VISIBILITY
+ 
+-__BEGIN_DECLS
++#ifdef __cplusplus
++extern "C" {
++#endif
+ long		gelf_checksum(Elf *_elf);
+ size_t		gelf_fsize(Elf *_elf, Elf_Type _type, size_t _count,
+ 			unsigned int _version);
+@@ -109,6 +109,8 @@
+ int		gelf_update_move(Elf_Data *_dst, int _index, GElf_Move *_src);
+ int		gelf_update_syminfo(Elf_Data *_dst, int _index, GElf_Syminfo *_src);
+ #endif
+-__END_DECLS
++#ifdef __cplusplus
++}
++#endif
+ 
+ #endif	/* _GELF_H_ */
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_cap.c compiler/lib/loaders/elf/utils/libelf/gelf_cap.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_cap.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_cap.c	2020-04-19 09:02:05.429269632 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_checksum.c compiler/lib/loaders/elf/utils/libelf/gelf_checksum.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_checksum.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_checksum.c	2020-04-19 09:02:08.192273183 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <gelf.h>
+ #include <libelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_dyn.c compiler/lib/loaders/elf/utils/libelf/gelf_dyn.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_dyn.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_dyn.c	2020-04-19 09:02:10.020275525 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_ehdr.c compiler/lib/loaders/elf/utils/libelf/gelf_ehdr.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_ehdr.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_ehdr.c	2020-04-19 09:02:11.882277926 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ #include <libelf.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_fsize.c compiler/lib/loaders/elf/utils/libelf/gelf_fsize.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_fsize.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_fsize.c	2020-04-19 09:02:14.139280827 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <gelf.h>
+ #include <libelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_getclass.c compiler/lib/loaders/elf/utils/libelf/gelf_getclass.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_getclass.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_getclass.c	2020-04-19 09:02:17.269284848 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <gelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_move.c compiler/lib/loaders/elf/utils/libelf/gelf_move.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_move.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_move.c	2020-04-19 09:02:18.974287034 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_phdr.c compiler/lib/loaders/elf/utils/libelf/gelf_phdr.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_phdr.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_phdr.c	2020-04-19 09:02:20.676289227 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <gelf.h>
+ #include <libelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_rel.c compiler/lib/loaders/elf/utils/libelf/gelf_rel.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_rel.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_rel.c	2020-04-19 09:02:23.177292435 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_rela.c compiler/lib/loaders/elf/utils/libelf/gelf_rela.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_rela.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_rela.c	2020-04-19 09:02:25.246295100 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_shdr.c compiler/lib/loaders/elf/utils/libelf/gelf_shdr.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_shdr.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_shdr.c	2020-04-19 09:02:28.325299060 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ #include <libelf.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_sym.c compiler/lib/loaders/elf/utils/libelf/gelf_sym.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_sym.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_sym.c	2020-04-19 09:02:30.113301356 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_syminfo.c compiler/lib/loaders/elf/utils/libelf/gelf_syminfo.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_syminfo.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_syminfo.c	2020-04-19 09:02:31.906303662 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_symshndx.c compiler/lib/loaders/elf/utils/libelf/gelf_symshndx.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_symshndx.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_symshndx.c	2020-04-19 09:02:33.626305873 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_xlate.c compiler/lib/loaders/elf/utils/libelf/gelf_xlate.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_xlate.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_xlate.c	2020-04-19 09:02:35.921308822 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <gelf.h>
+ #include <libelf.h>
+ #include <string.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf.h compiler/lib/loaders/elf/utils/libelf/libelf.h
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf.h	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf.h	2020-04-19 09:04:38.760466706 -0400
+@@ -30,7 +30,7 @@
+ #define	_LIBELF_H_
+ 
+ #include <sys/types.h>
+-#include <sys/queue.h>
++#include "sys_queue.h"
+ #include <elfdefinitions.h>
+ #ifndef EM_HSAIL
+ #define EM_HSAIL 0xAF5A
+@@ -187,7 +187,9 @@
+ #define	ELF_F_ARCHIVE	   0x100U /* archive creation */
+ #define	ELF_F_ARCHIVE_SYSV 0x200U /* SYSV style archive */
+ 
+-__BEGIN_DECLS
++#ifdef __cplusplus
++extern "C" {
++#endif
+ Elf		*elf_begin(int _fd, Elf_Cmd _cmd, Elf *_elf, Elf_Mem *_mem);
+ int		elf_cntl(Elf *_elf, Elf_Cmd _cmd);
+ int		elf_end(Elf *_elf);
+@@ -257,6 +259,8 @@
+ 			unsigned int _enc);
+ Elf_Data	*elf64_xlatetom(Elf_Data *_dst, const Elf_Data *_src,
+ 			unsigned int _enc);
+-__END_DECLS
++#ifdef __cplusplus
++}
++#endif
+ 
+ #endif	/* _LIBELF_H_ */
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_align.c compiler/lib/loaders/elf/utils/libelf/libelf_align.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_align.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_align.c	2020-04-19 09:02:40.660314911 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <sys/types.h>
+ 
+ #include <libelf.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_allocate.c compiler/lib/loaders/elf/utils/libelf/libelf_allocate.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_allocate.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_allocate.c	2020-04-19 09:02:43.079318019 -0400
+@@ -28,8 +28,6 @@
+  * Internal APIs
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #if !defined(WIN32)
+ #include <sys/errno.h>
+ #endif
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_ar.c compiler/lib/loaders/elf/utils/libelf/libelf_ar.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_ar.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_ar.c	2020-04-19 09:02:44.763320187 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <ctype.h>
+ #include <libelf.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_ar_util.c compiler/lib/loaders/elf/utils/libelf/libelf_ar_util.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_ar_util.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_ar_util.c	2020-04-19 09:02:46.461322369 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <libelf.h>
+ #include <stdlib.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_checksum.c compiler/lib/loaders/elf/utils/libelf/libelf_checksum.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_checksum.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_checksum.c	2020-04-19 09:02:48.645325173 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <gelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_convert.c compiler/lib/loaders/elf/utils/libelf/libelf_convert.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_convert.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_convert.c	2020-04-19 09:02:50.883328053 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <libelf.h>
+ #include <string.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_data.c compiler/lib/loaders/elf/utils/libelf/libelf_data.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_data.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_data.c	2020-04-19 09:02:52.951330708 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_ehdr.c compiler/lib/loaders/elf/utils/libelf/libelf_ehdr.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_ehdr.c	2020-04-19 08:59:34.204386579 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_ehdr.c	2020-04-19 09:02:55.176333563 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ #include <libelf.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_extended.c compiler/lib/loaders/elf/utils/libelf/libelf_extended.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_extended.c	2020-04-19 08:59:34.204386579 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_extended.c	2020-04-19 09:02:57.932337110 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <libelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_msize.c compiler/lib/loaders/elf/utils/libelf/libelf_msize.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_msize.c	2020-04-19 08:59:34.204386579 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_msize.c	2020-04-19 09:03:02.201342598 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <libelf.h>
+ #include <string.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_phdr.c compiler/lib/loaders/elf/utils/libelf/libelf_phdr.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_phdr.c	2020-04-19 08:59:34.204386579 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_phdr.c	2020-04-19 09:03:04.194345160 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ #include <libelf.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_shdr.c compiler/lib/loaders/elf/utils/libelf/libelf_shdr.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_shdr.c	2020-04-19 08:59:34.204386579 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_shdr.c	2020-04-19 09:03:05.795347218 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <gelf.h>
+ #include <libelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_xlate.c compiler/lib/loaders/elf/utils/libelf/libelf_xlate.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_xlate.c	2020-04-19 08:59:34.204386579 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_xlate.c	2020-04-19 09:03:09.472351944 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <libelf.h>
+ 
diff --git a/srcpkgs/rocm-opencl-runtime/files/runtime-musl.patch b/srcpkgs/rocm-opencl-runtime/files/runtime-musl.patch
new file mode 100644
index 00000000000..ea18e90e09c
--- /dev/null
+++ b/srcpkgs/rocm-opencl-runtime/files/runtime-musl.patch
@@ -0,0 +1,11 @@
+--- runtime/os/os_posix.cpp.orig	2020-04-19 09:13:51.701982901 -0400
++++ runtime/os/os_posix.cpp	2020-04-19 09:14:04.156947422 -0400
+@@ -44,6 +44,8 @@
+ #include <algorithm>
+ #include <mutex>
+ 
++#include <libgen.h> // for basename
++
+ 
+ namespace amd {
+ 
diff --git a/srcpkgs/rocm-opencl-runtime/files/sys_queue.h b/srcpkgs/rocm-opencl-runtime/files/sys_queue.h
new file mode 100644
index 00000000000..daf4553d33e
--- /dev/null
+++ b/srcpkgs/rocm-opencl-runtime/files/sys_queue.h
@@ -0,0 +1,574 @@
+/*
+ * Copyright (c) 1991, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *	@(#)queue.h	8.5 (Berkeley) 8/20/94
+ */
+
+#ifndef	_SYS_QUEUE_H_
+#define	_SYS_QUEUE_H_
+
+/*
+ * This file defines five types of data structures: singly-linked lists,
+ * lists, simple queues, tail queues, and circular queues.
+ *
+ * A singly-linked list is headed by a single forward pointer. The
+ * elements are singly linked for minimum space and pointer manipulation
+ * overhead at the expense of O(n) removal for arbitrary elements. New
+ * elements can be added to the list after an existing element or at the
+ * head of the list.  Elements being removed from the head of the list
+ * should use the explicit macro for this purpose for optimum
+ * efficiency. A singly-linked list may only be traversed in the forward
+ * direction.  Singly-linked lists are ideal for applications with large
+ * datasets and few or no removals or for implementing a LIFO queue.
+ *
+ * A list is headed by a single forward pointer (or an array of forward
+ * pointers for a hash table header). The elements are doubly linked
+ * so that an arbitrary element can be removed without a need to
+ * traverse the list. New elements can be added to the list before
+ * or after an existing element or at the head of the list. A list
+ * may only be traversed in the forward direction.
+ *
+ * A simple queue is headed by a pair of pointers, one the head of the
+ * list and the other to the tail of the list. The elements are singly
+ * linked to save space, so elements can only be removed from the
+ * head of the list. New elements can be added to the list after
+ * an existing element, at the head of the list, or at the end of the
+ * list. A simple queue may only be traversed in the forward direction.
+ *
+ * A tail queue is headed by a pair of pointers, one to the head of the
+ * list and the other to the tail of the list. The elements are doubly
+ * linked so that an arbitrary element can be removed without a need to
+ * traverse the list. New elements can be added to the list before or
+ * after an existing element, at the head of the list, or at the end of
+ * the list. A tail queue may be traversed in either direction.
+ *
+ * A circle queue is headed by a pair of pointers, one to the head of the
+ * list and the other to the tail of the list. The elements are doubly
+ * linked so that an arbitrary element can be removed without a need to
+ * traverse the list. New elements can be added to the list before or after
+ * an existing element, at the head of the list, or at the end of the list.
+ * A circle queue may be traversed in either direction, but has a more
+ * complex end of list detection.
+ *
+ * For details on the use of these macros, see the queue(3) manual page.
+ */
+
+/*
+ * List definitions.
+ */
+#define	LIST_HEAD(name, type)						\
+struct name {								\
+	struct type *lh_first;	/* first element */			\
+}
+
+#define	LIST_HEAD_INITIALIZER(head)					\
+	{ NULL }
+
+#define	LIST_ENTRY(type)						\
+struct {								\
+	struct type *le_next;	/* next element */			\
+	struct type **le_prev;	/* address of previous next element */	\
+}
+
+/*
+ * List functions.
+ */
+#define	LIST_INIT(head) do {						\
+	(head)->lh_first = NULL;					\
+} while (/*CONSTCOND*/0)
+
+#define	LIST_INSERT_AFTER(listelm, elm, field) do {			\
+	if (((elm)->field.le_next = (listelm)->field.le_next) != NULL)	\
+		(listelm)->field.le_next->field.le_prev =		\
+		    &(elm)->field.le_next;				\
+	(listelm)->field.le_next = (elm);				\
+	(elm)->field.le_prev = &(listelm)->field.le_next;		\
+} while (/*CONSTCOND*/0)
+
+#define	LIST_INSERT_BEFORE(listelm, elm, field) do {			\
+	(elm)->field.le_prev = (listelm)->field.le_prev;		\
+	(elm)->field.le_next = (listelm);				\
+	*(listelm)->field.le_prev = (elm);				\
+	(listelm)->field.le_prev = &(elm)->field.le_next;		\
+} while (/*CONSTCOND*/0)
+
+#define	LIST_INSERT_HEAD(head, elm, field) do {				\
+	if (((elm)->field.le_next = (head)->lh_first) != NULL)		\
+		(head)->lh_first->field.le_prev = &(elm)->field.le_next;\
+	(head)->lh_first = (elm);					\
+	(elm)->field.le_prev = &(head)->lh_first;			\
+} while (/*CONSTCOND*/0)
+
+#define	LIST_REMOVE(elm, field) do {					\
+	if ((elm)->field.le_next != NULL)				\
+		(elm)->field.le_next->field.le_prev = 			\
+		    (elm)->field.le_prev;				\
+	*(elm)->field.le_prev = (elm)->field.le_next;			\
+} while (/*CONSTCOND*/0)
+
+#define	LIST_FOREACH(var, head, field)					\
+	for ((var) = ((head)->lh_first);				\
+		(var);							\
+		(var) = ((var)->field.le_next))
+
+/*
+ * List access methods.
+ */
+#define	LIST_EMPTY(head)		((head)->lh_first == NULL)
+#define	LIST_FIRST(head)		((head)->lh_first)
+#define	LIST_NEXT(elm, field)		((elm)->field.le_next)
+
+
+/*
+ * Singly-linked List definitions.
+ */
+#define	SLIST_HEAD(name, type)						\
+struct name {								\
+	struct type *slh_first;	/* first element */			\
+}
+
+#define	SLIST_HEAD_INITIALIZER(head)					\
+	{ NULL }
+
+#define	SLIST_ENTRY(type)						\
+struct {								\
+	struct type *sle_next;	/* next element */			\
+}
+
+/*
+ * Singly-linked List functions.
+ */
+#define	SLIST_INIT(head) do {						\
+	(head)->slh_first = NULL;					\
+} while (/*CONSTCOND*/0)
+
+#define	SLIST_INSERT_AFTER(slistelm, elm, field) do {			\
+	(elm)->field.sle_next = (slistelm)->field.sle_next;		\
+	(slistelm)->field.sle_next = (elm);				\
+} while (/*CONSTCOND*/0)
+
+#define	SLIST_INSERT_HEAD(head, elm, field) do {			\
+	(elm)->field.sle_next = (head)->slh_first;			\
+	(head)->slh_first = (elm);					\
+} while (/*CONSTCOND*/0)
+
+#define	SLIST_REMOVE_HEAD(head, field) do {				\
+	(head)->slh_first = (head)->slh_first->field.sle_next;		\
+} while (/*CONSTCOND*/0)
+
+#define	SLIST_REMOVE(head, elm, type, field) do {			\
+	if ((head)->slh_first == (elm)) {				\
+		SLIST_REMOVE_HEAD((head), field);			\
+	}								\
+	else {								\
+		struct type *curelm = (head)->slh_first;		\
+		while(curelm->field.sle_next != (elm))			\
+			curelm = curelm->field.sle_next;		\
+		curelm->field.sle_next =				\
+		    curelm->field.sle_next->field.sle_next;		\
+	}								\
+} while (/*CONSTCOND*/0)
+
+#define	SLIST_FOREACH(var, head, field)					\
+	for((var) = (head)->slh_first; (var); (var) = (var)->field.sle_next)
+
+/*
+ * Singly-linked List access methods.
+ */
+#define	SLIST_EMPTY(head)	((head)->slh_first == NULL)
+#define	SLIST_FIRST(head)	((head)->slh_first)
+#define	SLIST_NEXT(elm, field)	((elm)->field.sle_next)
+
+
+/*
+ * Singly-linked Tail queue declarations.
+ */
+#define	STAILQ_HEAD(name, type)					\
+struct name {								\
+	struct type *stqh_first;	/* first element */			\
+	struct type **stqh_last;	/* addr of last next element */		\
+}
+
+#define	STAILQ_HEAD_INITIALIZER(head)					\
+	{ NULL, &(head).stqh_first }
+
+#define	STAILQ_ENTRY(type)						\
+struct {								\
+	struct type *stqe_next;	/* next element */			\
+}
+
+/*
+ * Singly-linked Tail queue functions.
+ */
+#define	STAILQ_INIT(head) do {						\
+	(head)->stqh_first = NULL;					\
+	(head)->stqh_last = &(head)->stqh_first;				\
+} while (/*CONSTCOND*/0)
+
+#define	STAILQ_INSERT_HEAD(head, elm, field) do {			\
+	if (((elm)->field.stqe_next = (head)->stqh_first) == NULL)	\
+		(head)->stqh_last = &(elm)->field.stqe_next;		\
+	(head)->stqh_first = (elm);					\
+} while (/*CONSTCOND*/0)
+
+#define	STAILQ_INSERT_TAIL(head, elm, field) do {			\
+	(elm)->field.stqe_next = NULL;					\
+	*(head)->stqh_last = (elm);					\
+	(head)->stqh_last = &(elm)->field.stqe_next;			\
+} while (/*CONSTCOND*/0)
+
+#define	STAILQ_INSERT_AFTER(head, listelm, elm, field) do {		\
+	if (((elm)->field.stqe_next = (listelm)->field.stqe_next) == NULL)\
+		(head)->stqh_last = &(elm)->field.stqe_next;		\
+	(listelm)->field.stqe_next = (elm);				\
+} while (/*CONSTCOND*/0)
+
+#define	STAILQ_REMOVE_HEAD(head, field) do {				\
+	if (((head)->stqh_first = (head)->stqh_first->field.stqe_next) == NULL) \
+		(head)->stqh_last = &(head)->stqh_first;			\
+} while (/*CONSTCOND*/0)
+
+#define	STAILQ_REMOVE(head, elm, type, field) do {			\
+	if ((head)->stqh_first == (elm)) {				\
+		STAILQ_REMOVE_HEAD((head), field);			\
+	} else {							\
+		struct type *curelm = (head)->stqh_first;		\
+		while (curelm->field.stqe_next != (elm))			\
+			curelm = curelm->field.stqe_next;		\
+		if ((curelm->field.stqe_next =				\
+			curelm->field.stqe_next->field.stqe_next) == NULL) \
+			    (head)->stqh_last = &(curelm)->field.stqe_next; \
+	}								\
+} while (/*CONSTCOND*/0)
+
+#define	STAILQ_FOREACH(var, head, field)				\
+	for ((var) = ((head)->stqh_first);				\
+		(var);							\
+		(var) = ((var)->field.stqe_next))
+
+#define	STAILQ_CONCAT(head1, head2) do {				\
+	if (!STAILQ_EMPTY((head2))) {					\
+		*(head1)->stqh_last = (head2)->stqh_first;		\
+		(head1)->stqh_last = (head2)->stqh_last;		\
+		STAILQ_INIT((head2));					\
+	}								\
+} while (/*CONSTCOND*/0)
+
+/*
+ * Singly-linked Tail queue access methods.
+ */
+#define	STAILQ_EMPTY(head)	((head)->stqh_first == NULL)
+#define	STAILQ_FIRST(head)	((head)->stqh_first)
+#define	STAILQ_NEXT(elm, field)	((elm)->field.stqe_next)
+
+
+/*
+ * Simple queue definitions.
+ */
+#define	SIMPLEQ_HEAD(name, type)					\
+struct name {								\
+	struct type *sqh_first;	/* first element */			\
+	struct type **sqh_last;	/* addr of last next element */		\
+}
+
+#define	SIMPLEQ_HEAD_INITIALIZER(head)					\
+	{ NULL, &(head).sqh_first }
+
+#define	SIMPLEQ_ENTRY(type)						\
+struct {								\
+	struct type *sqe_next;	/* next element */			\
+}
+
+/*
+ * Simple queue functions.
+ */
+#define	SIMPLEQ_INIT(head) do {						\
+	(head)->sqh_first = NULL;					\
+	(head)->sqh_last = &(head)->sqh_first;				\
+} while (/*CONSTCOND*/0)
+
+#define	SIMPLEQ_INSERT_HEAD(head, elm, field) do {			\
+	if (((elm)->field.sqe_next = (head)->sqh_first) == NULL)	\
+		(head)->sqh_last = &(elm)->field.sqe_next;		\
+	(head)->sqh_first = (elm);					\
+} while (/*CONSTCOND*/0)
+
+#define	SIMPLEQ_INSERT_TAIL(head, elm, field) do {			\
+	(elm)->field.sqe_next = NULL;					\
+	*(head)->sqh_last = (elm);					\
+	(head)->sqh_last = &(elm)->field.sqe_next;			\
+} while (/*CONSTCOND*/0)
+
+#define	SIMPLEQ_INSERT_AFTER(head, listelm, elm, field) do {		\
+	if (((elm)->field.sqe_next = (listelm)->field.sqe_next) == NULL)\
+		(head)->sqh_last = &(elm)->field.sqe_next;		\
+	(listelm)->field.sqe_next = (elm);				\
+} while (/*CONSTCOND*/0)
+
+#define	SIMPLEQ_REMOVE_HEAD(head, field) do {				\
+	if (((head)->sqh_first = (head)->sqh_first->field.sqe_next) == NULL) \
+		(head)->sqh_last = &(head)->sqh_first;			\
+} while (/*CONSTCOND*/0)
+
+#define	SIMPLEQ_REMOVE(head, elm, type, field) do {			\
+	if ((head)->sqh_first == (elm)) {				\
+		SIMPLEQ_REMOVE_HEAD((head), field);			\
+	} else {							\
+		struct type *curelm = (head)->sqh_first;		\
+		while (curelm->field.sqe_next != (elm))			\
+			curelm = curelm->field.sqe_next;		\
+		if ((curelm->field.sqe_next =				\
+			curelm->field.sqe_next->field.sqe_next) == NULL) \
+			    (head)->sqh_last = &(curelm)->field.sqe_next; \
+	}								\
+} while (/*CONSTCOND*/0)
+
+#define	SIMPLEQ_FOREACH(var, head, field)				\
+	for ((var) = ((head)->sqh_first);				\
+		(var);							\
+		(var) = ((var)->field.sqe_next))
+
+/*
+ * Simple queue access methods.
+ */
+#define	SIMPLEQ_EMPTY(head)		((head)->sqh_first == NULL)
+#define	SIMPLEQ_FIRST(head)		((head)->sqh_first)
+#define	SIMPLEQ_NEXT(elm, field)	((elm)->field.sqe_next)
+
+
+/*
+ * Tail queue definitions.
+ */
+#define	_TAILQ_HEAD(name, type, qual)					\
+struct name {								\
+	qual type *tqh_first;		/* first element */		\
+	qual type *qual *tqh_last;	/* addr of last next element */	\
+}
+#define TAILQ_HEAD(name, type)	_TAILQ_HEAD(name, struct type,)
+
+#define	TAILQ_HEAD_INITIALIZER(head)					\
+	{ NULL, &(head).tqh_first }
+
+#define	_TAILQ_ENTRY(type, qual)					\
+struct {								\
+	qual type *tqe_next;		/* next element */		\
+	qual type *qual *tqe_prev;	/* address of previous next element */\
+}
+#define TAILQ_ENTRY(type)	_TAILQ_ENTRY(struct type,)
+
+/*
+ * Tail queue functions.
+ */
+#define	TAILQ_INIT(head) do {						\
+	(head)->tqh_first = NULL;					\
+	(head)->tqh_last = &(head)->tqh_first;				\
+} while (/*CONSTCOND*/0)
+
+#define	TAILQ_INSERT_HEAD(head, elm, field) do {			\
+	if (((elm)->field.tqe_next = (head)->tqh_first) != NULL)	\
+		(head)->tqh_first->field.tqe_prev =			\
+		    &(elm)->field.tqe_next;				\
+	else								\
+		(head)->tqh_last = &(elm)->field.tqe_next;		\
+	(head)->tqh_first = (elm);					\
+	(elm)->field.tqe_prev = &(head)->tqh_first;			\
+} while (/*CONSTCOND*/0)
+
+#define	TAILQ_INSERT_TAIL(head, elm, field) do {			\
+	(elm)->field.tqe_next = NULL;					\
+	(elm)->field.tqe_prev = (head)->tqh_last;			\
+	*(head)->tqh_last = (elm);					\
+	(head)->tqh_last = &(elm)->field.tqe_next;			\
+} while (/*CONSTCOND*/0)
+
+#define	TAILQ_INSERT_AFTER(head, listelm, elm, field) do {		\
+	if (((elm)->field.tqe_next = (listelm)->field.tqe_next) != NULL)\
+		(elm)->field.tqe_next->field.tqe_prev = 		\
+		    &(elm)->field.tqe_next;				\
+	else								\
+		(head)->tqh_last = &(elm)->field.tqe_next;		\
+	(listelm)->field.tqe_next = (elm);				\
+	(elm)->field.tqe_prev = &(listelm)->field.tqe_next;		\
+} while (/*CONSTCOND*/0)
+
+#define	TAILQ_INSERT_BEFORE(listelm, elm, field) do {			\
+	(elm)->field.tqe_prev = (listelm)->field.tqe_prev;		\
+	(elm)->field.tqe_next = (listelm);				\
+	*(listelm)->field.tqe_prev = (elm);				\
+	(listelm)->field.tqe_prev = &(elm)->field.tqe_next;		\
+} while (/*CONSTCOND*/0)
+
+#define	TAILQ_REMOVE(head, elm, field) do {				\
+	if (((elm)->field.tqe_next) != NULL)				\
+		(elm)->field.tqe_next->field.tqe_prev = 		\
+		    (elm)->field.tqe_prev;				\
+	else								\
+		(head)->tqh_last = (elm)->field.tqe_prev;		\
+	*(elm)->field.tqe_prev = (elm)->field.tqe_next;			\
+} while (/*CONSTCOND*/0)
+
+#define	TAILQ_FOREACH(var, head, field)					\
+	for ((var) = ((head)->tqh_first);				\
+		(var);							\
+		(var) = ((var)->field.tqe_next))
+
+#define	TAILQ_FOREACH_REVERSE(var, head, headname, field)		\
+	for ((var) = (*(((struct headname *)((head)->tqh_last))->tqh_last));	\
+		(var);							\
+		(var) = (*(((struct headname *)((var)->field.tqe_prev))->tqh_last)))
+
+#define	TAILQ_CONCAT(head1, head2, field) do {				\
+	if (!TAILQ_EMPTY(head2)) {					\
+		*(head1)->tqh_last = (head2)->tqh_first;		\
+		(head2)->tqh_first->field.tqe_prev = (head1)->tqh_last;	\
+		(head1)->tqh_last = (head2)->tqh_last;			\
+		TAILQ_INIT((head2));					\
+	}								\
+} while (/*CONSTCOND*/0)
+
+/*
+ * Tail queue access methods.
+ */
+#define	TAILQ_EMPTY(head)		((head)->tqh_first == NULL)
+#define	TAILQ_FIRST(head)		((head)->tqh_first)
+#define	TAILQ_NEXT(elm, field)		((elm)->field.tqe_next)
+
+#define	TAILQ_LAST(head, headname) \
+	(*(((struct headname *)((head)->tqh_last))->tqh_last))
+#define	TAILQ_PREV(elm, headname, field) \
+	(*(((struct headname *)((elm)->field.tqe_prev))->tqh_last))
+
+
+/*
+ * Circular queue definitions.
+ */
+#define	CIRCLEQ_HEAD(name, type)					\
+struct name {								\
+	struct type *cqh_first;		/* first element */		\
+	struct type *cqh_last;		/* last element */		\
+}
+
+#define	CIRCLEQ_HEAD_INITIALIZER(head)					\
+	{ (void *)&head, (void *)&head }
+
+#define	CIRCLEQ_ENTRY(type)						\
+struct {								\
+	struct type *cqe_next;		/* next element */		\
+	struct type *cqe_prev;		/* previous element */		\
+}
+
+/*
+ * Circular queue functions.
+ */
+#define	CIRCLEQ_INIT(head) do {						\
+	(head)->cqh_first = (void *)(head);				\
+	(head)->cqh_last = (void *)(head);				\
+} while (/*CONSTCOND*/0)
+
+#define	CIRCLEQ_INSERT_AFTER(head, listelm, elm, field) do {		\
+	(elm)->field.cqe_next = (listelm)->field.cqe_next;		\
+	(elm)->field.cqe_prev = (listelm);				\
+	if ((listelm)->field.cqe_next == (void *)(head))		\
+		(head)->cqh_last = (elm);				\
+	else								\
+		(listelm)->field.cqe_next->field.cqe_prev = (elm);	\
+	(listelm)->field.cqe_next = (elm);				\
+} while (/*CONSTCOND*/0)
+
+#define	CIRCLEQ_INSERT_BEFORE(head, listelm, elm, field) do {		\
+	(elm)->field.cqe_next = (listelm);				\
+	(elm)->field.cqe_prev = (listelm)->field.cqe_prev;		\
+	if ((listelm)->field.cqe_prev == (void *)(head))		\
+		(head)->cqh_first = (elm);				\
+	else								\
+		(listelm)->field.cqe_prev->field.cqe_next = (elm);	\
+	(listelm)->field.cqe_prev = (elm);				\
+} while (/*CONSTCOND*/0)
+
+#define	CIRCLEQ_INSERT_HEAD(head, elm, field) do {			\
+	(elm)->field.cqe_next = (head)->cqh_first;			\
+	(elm)->field.cqe_prev = (void *)(head);				\
+	if ((head)->cqh_last == (void *)(head))				\
+		(head)->cqh_last = (elm);				\
+	else								\
+		(head)->cqh_first->field.cqe_prev = (elm);		\
+	(head)->cqh_first = (elm);					\
+} while (/*CONSTCOND*/0)
+
+#define	CIRCLEQ_INSERT_TAIL(head, elm, field) do {			\
+	(elm)->field.cqe_next = (void *)(head);				\
+	(elm)->field.cqe_prev = (head)->cqh_last;			\
+	if ((head)->cqh_first == (void *)(head))			\
+		(head)->cqh_first = (elm);				\
+	else								\
+		(head)->cqh_last->field.cqe_next = (elm);		\
+	(head)->cqh_last = (elm);					\
+} while (/*CONSTCOND*/0)
+
+#define	CIRCLEQ_REMOVE(head, elm, field) do {				\
+	if ((elm)->field.cqe_next == (void *)(head))			\
+		(head)->cqh_last = (elm)->field.cqe_prev;		\
+	else								\
+		(elm)->field.cqe_next->field.cqe_prev =			\
+		    (elm)->field.cqe_prev;				\
+	if ((elm)->field.cqe_prev == (void *)(head))			\
+		(head)->cqh_first = (elm)->field.cqe_next;		\
+	else								\
+		(elm)->field.cqe_prev->field.cqe_next =			\
+		    (elm)->field.cqe_next;				\
+} while (/*CONSTCOND*/0)
+
+#define	CIRCLEQ_FOREACH(var, head, field)				\
+	for ((var) = ((head)->cqh_first);				\
+		(var) != (const void *)(head);				\
+		(var) = ((var)->field.cqe_next))
+
+#define	CIRCLEQ_FOREACH_REVERSE(var, head, field)			\
+	for ((var) = ((head)->cqh_last);				\
+		(var) != (const void *)(head);				\
+		(var) = ((var)->field.cqe_prev))
+
+/*
+ * Circular queue access methods.
+ */
+#define	CIRCLEQ_EMPTY(head)		((head)->cqh_first == (void *)(head))
+#define	CIRCLEQ_FIRST(head)		((head)->cqh_first)
+#define	CIRCLEQ_LAST(head)		((head)->cqh_last)
+#define	CIRCLEQ_NEXT(elm, field)	((elm)->field.cqe_next)
+#define	CIRCLEQ_PREV(elm, field)	((elm)->field.cqe_prev)
+
+#define CIRCLEQ_LOOP_NEXT(head, elm, field)				\
+	(((elm)->field.cqe_next == (void *)(head))			\
+	    ? ((head)->cqh_first)					\
+	    : (elm->field.cqe_next))
+#define CIRCLEQ_LOOP_PREV(head, elm, field)				\
+	(((elm)->field.cqe_prev == (void *)(head))			\
+	    ? ((head)->cqh_last)					\
+	    : (elm->field.cqe_prev))
+
+#endif	/* sys/queue.h */
diff --git a/srcpkgs/rocm-opencl-runtime/patches/cmake.patch b/srcpkgs/rocm-opencl-runtime/patches/cmake.patch
new file mode 100644
index 00000000000..2c96b99d45a
--- /dev/null
+++ b/srcpkgs/rocm-opencl-runtime/patches/cmake.patch
@@ -0,0 +1,126 @@
+--- OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/CMakeLists.txt	2019-09-10 11:53:28.000000000 -0400
++++ OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/CMakeLists.txt	2020-04-16 20:16:13.481180757 -0400
+@@ -73,11 +73,11 @@
+ 
+ set (OPENCL_ICD_LOADER_HEADERS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/inc CACHE PATH "Path to OpenCL Headers")
+ 
+-add_library (OpenCL ${OPENCL_ICD_LOADER_SOURCES})
+-set_target_properties (OpenCL PROPERTIES VERSION "1.2" SOVERSION "1")
++add_library (OpenCL-ROCm ${OPENCL_ICD_LOADER_SOURCES})
++set_target_properties (OpenCL-ROCm PROPERTIES VERSION "1.2" SOVERSION "1")
+ 
+ if (WIN32)
+-    target_link_libraries (OpenCL cfgmgr32.lib)
++    target_link_libraries (OpenCL-ROCm cfgmgr32.lib)
+ 
+     option (OPENCL_ICD_LOADER_REQUIRE_WDK "Build with D3DKMT support, which requires the Windows WDK." ON)
+     if (OPENCL_ICD_LOADER_REQUIRE_WDK)
+@@ -92,10 +92,10 @@
+             get_filename_component(WDK_DIRECTORY ${LATEST_D3DKMT_HEADER} DIRECTORY)
+             get_filename_component(WDK_DIRECTORY ${WDK_DIRECTORY} DIRECTORY)
+             message(STATUS "Found the Windows WDK in: ${WDK_DIRECTORY}")
+-            target_compile_definitions(OpenCL PRIVATE OPENCL_ICD_LOADER_REQUIRE_WDK)
+-            target_include_directories(OpenCL PRIVATE ${WDK_DIRECTORY}/um)
+-            target_include_directories(OpenCL PRIVATE ${WDK_DIRECTORY}/km)
+-            target_include_directories(OpenCL PRIVATE ${WDK_DIRECTORY}/shared)
++	    target_compile_definitions(OpenCL-ROCm PRIVATE OPENCL_ICD_LOADER_REQUIRE_WDK)
++	    target_include_directories(OpenCL-ROCm PRIVATE ${WDK_DIRECTORY}/um)
++	    target_include_directories(OpenCL-ROCm PRIVATE ${WDK_DIRECTORY}/km)
++	    target_include_directories(OpenCL-ROCm PRIVATE ${WDK_DIRECTORY}/shared)
+         else()
+             message(FATAL_ERROR "The Windows WDK was not found. Consider disabling OPENCL_ICD_LOADER_REQUIRE_WDK. Aborting.")
+         endif()
+@@ -113,25 +113,25 @@
+     endif()
+ else()
+     if (APPLE)
+-        target_link_libraries (OpenCL ${CMAKE_THREAD_LIBS_INIT})
++        target_link_libraries (OpenCL-ROCm ${CMAKE_THREAD_LIBS_INIT})
+     else ()
+-        set_target_properties (OpenCL PROPERTIES LINK_FLAGS "-Wl,--version-script -Wl,${CMAKE_CURRENT_SOURCE_DIR}/loader/linux/icd_exports.map")
+-        target_link_libraries (OpenCL ${CMAKE_THREAD_LIBS_INIT})
++        set_target_properties (OpenCL-ROCm PROPERTIES LINK_FLAGS "-Wl,--version-script -Wl,${CMAKE_CURRENT_SOURCE_DIR}/loader/linux/icd_exports.map")
++	target_link_libraries (OpenCL-ROCm ${CMAKE_THREAD_LIBS_INIT})
+     endif ()
+ endif ()
+ 
+ include_directories (${OPENCL_ICD_LOADER_HEADERS_DIR})
+ add_definitions (-DCL_TARGET_OPENCL_VERSION=220)
+ 
+-target_include_directories (OpenCL PRIVATE ${CMAKE_CURRENT_BINARY_DIR} loader)
+-target_link_libraries (OpenCL ${CMAKE_DL_LIBS})
++target_include_directories (OpenCL-ROCm PRIVATE ${CMAKE_CURRENT_BINARY_DIR} loader)
++target_link_libraries (OpenCL-ROCm ${CMAKE_DL_LIBS})
+ 
+ include (CTest)
+ if (BUILD_TESTING)
+     add_subdirectory (test)
+ endif()
+ 
+-install (TARGETS OpenCL
++install (TARGETS OpenCL-ROCm
+     RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+     ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
+     LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
+--- OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/test/loader_test/CMakeLists.txt	2019-09-10 11:53:28.000000000 -0400
++++ OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/test/loader_test/CMakeLists.txt	2020-04-16 20:16:56.647026589 -0400
+@@ -12,4 +12,4 @@
+     test_clgl.c
+     test_image_objects.c )
+ 
+-target_link_libraries (icd_loader_test OpenCL IcdLog)
++target_link_libraries (icd_loader_test OpenCL-ROCm IcdLog)
+--- ROCm-OpenCL-Runtime-roc-3.3.0/CMakeLists.txt	2020-04-28 07:29:51.864446603 -0400
++++ ROCm-OpenCL-Runtime-roc-3.3.0/CMakeLists.txt	2020-04-28 07:32:45.245793180 -0400
+@@ -101,30 +101,30 @@
+ rocm_setup_version( VERSION "2.0.0" )
+ 
+ # MAIN package
+-install(PROGRAMS $<TARGET_FILE:clinfo>
+-        DESTINATION bin/x86_64
++install(PROGRAMS $<TARGET_FILE:rocm-clinfo>
++        DESTINATION bin
+         COMPONENT MAIN)
+ install(PROGRAMS $<TARGET_FILE:amdocl64>
+-        DESTINATION lib/x86_64
++        DESTINATION lib
+         COMPONENT MAIN)
+-install(PROGRAMS $<TARGET_FILE:OpenCL>
+-        DESTINATION lib/x86_64
++install(PROGRAMS $<TARGET_FILE:OpenCL-ROCm>
++        DESTINATION lib
+         COMPONENT MAIN)
+-install(PROGRAMS $<TARGET_SONAME_FILE:OpenCL>
+-        DESTINATION lib/x86_64
++install(PROGRAMS $<TARGET_SONAME_FILE:OpenCL-ROCm>
++        DESTINATION lib
+         COMPONENT MAIN)
+ 
+ # DEV package
+ install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/api/opencl/khronos/headers/opencl2.2/CL"
+-        DESTINATION include
++	DESTINATION include/rocm
+         COMPONENT DEV
+         USE_SOURCE_PERMISSIONS
+         PATTERN cl_d3d10.h EXCLUDE
+         PATTERN cl_d3d11.h EXCLUDE
+         PATTERN cl_dx9_media_sharing.h EXCLUDE
+         PATTERN cl_egl.h EXCLUDE)
+-install(PROGRAMS $<TARGET_LINKER_FILE:OpenCL>
+-        DESTINATION lib/x86_64
++install(PROGRAMS $<TARGET_LINKER_FILE:OpenCL-ROCm>
++        DESTINATION lib
+         COMPONENT DEV)
+ 
+ # Generic CPACK variables
+--- ROCm-OpenCL-Runtime-roc-3.3.0/tools/clinfo/CMakeLists.txt	2020-04-28 07:29:51.882446535 -0400
++++ ROCm-OpenCL-Runtime-roc-3.3.0/tools/clinfo/CMakeLists.txt	2020-04-28 07:30:05.627394732 -0400
+@@ -6,6 +6,6 @@
+ 
+ add_definitions(-DHAVE_CL2_HPP)
+ 
+-add_executable(clinfo clinfo.cpp)
++add_executable(rocm-clinfo clinfo.cpp)
+ 
+-target_link_libraries(clinfo OpenCL)
++target_link_libraries(rocm-clinfo OpenCL-ROCm)
diff --git a/srcpkgs/rocm-opencl-runtime/template b/srcpkgs/rocm-opencl-runtime/template
new file mode 100644
index 00000000000..f83c6e64149
--- /dev/null
+++ b/srcpkgs/rocm-opencl-runtime/template
@@ -0,0 +1,82 @@
+# Template file for 'rocm-opencl-runtime'
+pkgname=rocm-opencl-runtime
+version=3.3.0
+revision=1
+_ocl_icd_name="OpenCL-ICD-Loader"
+_ocl_icd_ver="6c03f8b58fafd9dd693eaac826749a5cfad515f8"
+archs="x86_64*"
+create_wrksrc=yes
+build_wrksrc="ROCm-OpenCL-Runtime-roc-${version}"
+build_style=cmake
+configure_args="-DUSE_COMGR_LIBRARY=yes"
+hostmakedepends="cmake pkg-config"
+makedepends="libglvnd-devel rocm-comgr-devel
+	roct-thunk-interface-devel rocr-runtime-devel"
+depends="rocm-comgr"
+short_desc="Radeon Open Compute OpenCL runtime"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="MIT"
+homepage="https://github.com/RadeonOpenCompute/ROCm-OpenCL-Runtime"
+_rocroot="https://github.com/RadeonOpenCompute"
+distfiles="${_rocroot}/ROCm-OpenCL-Runtime/archive/roc-${version}.tar.gz
+	${_rocroot}/rocm-cmake/archive/rocm-${version}.tar.gz
+	https://github.com/KhronosGroup/${_ocl_icd_name}/archive/${_ocl_icd_ver}.tar.gz"
+checksum="ac6999f1a491ab066286c2bd6adf50f08f831286f56e267879f9f7eced22f98e
+	76ed3ee8e56cf3246011cf7723c2abda539e1136e7e7f6909bfa45d268b8644f
+	c94d5bb6dc980c4d41d73e2b81663a19aabe494e923e2d0eec72a4c95b318438"
+nocross=yes
+
+post_patch() {
+	if [ "$XBPS_LIBC" = "musl" ]; then
+		# Copy sys/queue.h locally for MUSL builds
+		libelf_dir="compiler/lib/loaders/elf/utils/libelf"
+		cp "${FILESDIR}/sys_queue.h" "${libelf_dir}"
+
+		# Remove dependence on glibc
+		patch -Np0 < ${FILESDIR}/libelf-musl.patch
+		patch -Np0 < ${FILESDIR}/runtime-musl.patch
+		vsed -e '/glibc_functions.cpp/d' -i api/opencl/amdocl/CMakeLists.txt
+	fi
+}
+
+pre_configure() {
+	# ROCm requires a very specific Khronos ICD loader version in the tree
+	# Keep the ICD loader config in /etc/rocm/vendors to avoid conflicts
+	_ocl_icd_dir="${_ocl_icd_name}-${_ocl_icd_ver}"
+	ln -sf "${wrksrc}/${_ocl_icd_dir}" api/opencl/khronos/icd
+	vsed -i "${wrksrc}/${_ocl_icd_dir}/loader/icd_platform.h" \
+		-e 's@/etc/OpenCL/vendors/@/etc/rocm/vendors/@g'
+
+	# CMake modules probably not useful anywhere but for this build
+	ln -sf "${wrksrc}/rocm-cmake-rocm-${version}/share/rocm/cmake"/*.cmake cmake
+
+	# Fix the dlopen macro to point to versioned libamd_comgr shared object
+	vsed -i 'runtime/device/comgrctx.cpp' \
+		-e 's/\blibamd_comgr\(32\)\?.so\b/&.1/g'
+}
+
+post_install() {
+	vlicense License
+
+	# Create descriptor to allow the ICD loader to find the driver
+	_ocl_icd_dir="etc/rocm/vendors"
+	vmkdir "${_ocl_icd_dir}"
+	echo "libamdocl64.so" > "${DESTDIR}/${_ocl_icd_dir}/amdocl64.icd"
+}
+
+rocm-opencl-runtime-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/lib/libOpenCL-ROCm.so
+		vmove usr/include
+	}
+}
+
+rocm-opencl-runtime-clinfo_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - clinfo"
+	pkg_install() {
+		vmove usr/bin/rocm-clinfo
+	}
+}

From d0c9cf7ce58ca3fe008cf3f256d7251ce41c35a8 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Tue, 28 Apr 2020 13:33:46 -0400
Subject: [PATCH 9/9] hashcat: add build option to support new rocm packages
 [ci skip]

---
 srcpkgs/hashcat/files/rocm.patch | 35 ++++++++++++++++++++++++++++++++
 srcpkgs/hashcat/template         | 17 +++++++++++++---
 2 files changed, 49 insertions(+), 3 deletions(-)
 create mode 100644 srcpkgs/hashcat/files/rocm.patch

diff --git a/srcpkgs/hashcat/files/rocm.patch b/srcpkgs/hashcat/files/rocm.patch
new file mode 100644
index 00000000000..5f7e4e69197
--- /dev/null
+++ b/srcpkgs/hashcat/files/rocm.patch
@@ -0,0 +1,35 @@
+diff -ur a/src/folder.c b/src/folder.c
+--- a/src/folder.c	2018-12-02 05:58:48.000000000 -0500
++++ b/src/folder.c	2020-04-28 13:22:27.340522751 -0400
+@@ -457,16 +457,6 @@
+ 
+   hcfree (cpath);
+ 
+-  //if (getenv ("TMP") == NULL)
+-  if (1)
+-  {
+-    char *tmp;
+-
+-    hc_asprintf (&tmp, "TMP=%s", cpath_real);
+-
+-    putenv (tmp);
+-  }
+-
+   #if defined (_WIN)
+ 
+   naive_replace (cpath_real, '\\', '/');
+diff -ur a/src/opencl.c b/src/opencl.c
+--- a/src/opencl.c	2018-12-02 05:58:48.000000000 -0500
++++ b/src/opencl.c	2020-04-28 13:24:12.602415333 -0400
+@@ -492,9 +492,9 @@
+ 
+   if (ocl->lib == NULL) ocl->lib = hc_dlopen ("cygOpenCL-1.dll", RTLD_NOW);
+   #else
+-  ocl->lib = hc_dlopen ("libOpenCL.so", RTLD_NOW);
++  ocl->lib = hc_dlopen ("libOpenCL-ROCm.so.1", RTLD_NOW);
+ 
+-  if (ocl->lib == NULL) ocl->lib = hc_dlopen ("libOpenCL.so.1", RTLD_NOW);
++  if (ocl->lib == NULL) ocl->lib = hc_dlopen ("libOpenCL-ROCm.so", RTLD_NOW);
+   #endif
+ 
+   if (ocl->lib == NULL)
diff --git a/srcpkgs/hashcat/template b/srcpkgs/hashcat/template
index e982f99cebf..7d3a8cb5a6b 100644
--- a/srcpkgs/hashcat/template
+++ b/srcpkgs/hashcat/template
@@ -1,15 +1,16 @@
 # Template file for 'hashcat'
 pkgname=hashcat
 version=5.1.0
-revision=2
+revision=3
 build_style=gnu-makefile
 make_build_args="PREFIX=/usr
  USE_SYSTEM_OPENCL=1 USE_SYSTEM_XXHASH=1
- DEPS_OPENCL_PATH=${XBPS_CROSS_BASE}/usr/include
+ DEPS_OPENCL_PATH=${XBPS_CROSS_BASE}/usr/include$(vopt_if rocm /rocm)
  DEPS_XXHASH_PATH=${XBPS_CROSS_BASE}/usr/include"
 make_use_env=yes
 make_install_args="$make_build_args"
-makedepends="gmp-devel opencl2-headers xxHash-devel"
+makedepends="gmp-devel xxHash-devel
+ $(vopt_if rocm rocm-opencl-runtime-devel opencl2-headers)"
 checkdepends="perl"
 short_desc="Advanced CPU-based password recovery utility"
 maintainer="Duncaen <duncaen@voidlinux.org>"
@@ -19,6 +20,9 @@ changelog="https://raw.githubusercontent.com/hashcat/hashcat/master/docs/changes
 distfiles="https://hashcat.net/files/hashcat-${version}.tar.gz"
 checksum=283beaa68e1eab41de080a58bb92349c8e47a2bb1b93d10f36ea30f418f1e338
 
+build_options="rocm"
+desc_option_rocm="Use ROCm OpenCL runtime"
+
 if [ "$XBPS_TARGET_ENDIAN" = "be" ]; then
 	broken="Not supported on big endian"
 fi
@@ -26,6 +30,13 @@ fi
 post_extract() {
 	sed '/^CC/d' -i src/Makefile
 }
+
+post_patch() {
+	if [ "$build_option_rocm" ]; then
+		patch -Np1 < ${FILESDIR}/rocm.patch
+	fi
+}
+
 post_install() {
 	rm -f ${DESTDIR}/usr/share/docs/hashcat/license.txt
 	vlicense docs/license.txt

^ permalink raw reply	[flat|nested] 61+ messages in thread

* Re: [PR PATCH] [Updated] New packages: ROCm core and OpenCL
  2020-04-19 13:34 [PR PATCH] New packages: ROCm core and OpenCL ahesford
                   ` (7 preceding siblings ...)
  2020-04-28 17:34 ` ahesford
@ 2020-04-28 17:38 ` ahesford
  2020-04-28 18:09 ` ahesford
                   ` (50 subsequent siblings)
  59 siblings, 0 replies; 61+ messages in thread
From: ahesford @ 2020-04-28 17:38 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 3893 bytes --]

There is an updated pull request by ahesford against master on the void-packages repository

https://github.com/ahesford/void-packages rocm
https://github.com/void-linux/void-packages/pull/21153

New packages: ROCm core and OpenCL
This PR includes several packages designed to bring the OpenCL portion of the AMD ROCm ecosystem to Void. It addresses Issue #19507. There are many other packages that AMD provides for GPGPU computing, but these can be added piecemeal as users demand.

The packages are currently only for `x86_64*`. While at least some of the packages will compile on other 64-bit architectures, I have no hardware to test. They are certainly not suitable for 32-bit architectures; some internal data structures rely on `uint64_t` values that are cast to pointers. At a
minimum, a thorough audit would be necessary to ensure that these casts are safe (e.g., that the values stored were only ever upcast from 32-bit pointers). More extensive work may be necessary to support 32-bit architectures, probably without significant benefit.

The packages successfully identify a Radeon RX 580 on an `x86_64` installation using both `clinfo` and `rocminfo` as provided. Furthermore, a version of `pyopencl` linked against these ROCm packages successfully runs a simple program that validates arithmetic on GPU-bound arrays.

There are caveats with this set of packages, almost all of which revolve around the incompatibilities between the Void-provided `ocl-icd` and the [Khronos OpenCL ICD loader](https://github.com/KhronosGroup/OpenCL-ID-Loader) required by (and built into) `rocm-opencl-runtime`.
1. All packages install into `/opt/rocm`. This keeps the environment closer to that officially sanctioned by AMD and helps avoid conflicts between other packages and those provided here. (For example, `clinfo` and the ICD loader itself.) Eventually, we may be able to move the files into `/usr`.
2. The Khronos OpenCL ICD loader built into `rocm-opencl-runtime` is an outdated, pre-release commit. If AMD can update its sources to use the release version of that loader (which has a backward-incompatible API change), we may be able to make ROCm compatible with `ocl-icd` or replace `ocl-icd` with the official Khronos loader.
3. In the meantime, to avoid `shlibs` conflicts, the OpenCL ICD loader is installed as `/opt/rocm/lib/libOpenCL-ROCm.so` (and an appropriately versioned shared library), which means that programs wishing to use the ROCm OpenCL must explicitly link against this library instead of the generic `libOpenCL.so`.
4. I do **not** recommend making any Void packages link against this specific library, because it will make those packages ROCm-only. For the time being, ROCm is intended for end-users to specifically link against. Linking Void packages against ROCm would requires the ICD loader used by ROCm be compatible with `ocl-icd`, or `ocl-icd` be replaced by the Khronos loader. However, because the Khronos loader changed its API for the release version, such a change is not yet appropriate.

Hopefully, if AMD updates its dependence on the Khronos ICD loader, we can resolve some of these caveats in the future and make ROCm a more natural Void component. For now, these packages are useful for those who need an AMD OpenCL solution and would rather custom-link software against the AMD ICD loader than hack the `amdgpu-pro` driver into an ICD compatible with `ocl-icd`.

Some patches were made to relocate some files in `/opt/rocm` and make everyting build on x86_64-musl`. Where appropriate, these patches will be pushed upstream to clean up the distribution and packaging.

Update: I pushed some new commits to update license information that triggerd an `xlint` failure. I've also disabled CI builds because they will time out on `rocm-llvm`.

A patch file from https://github.com/void-linux/void-packages/pull/21153.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-rocm-21153.patch --]
[-- Type: text/x-diff, Size: 76983 bytes --]

From 1226ae1e7c5eea64be3859bb36eee4fd8c6cccc6 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Mon, 13 Apr 2020 13:08:09 -0400
Subject: [PATCH 1/9] New package: roct-thunk-interface-3.3.0

---
 common/shlibs                                 |  1 +
 srcpkgs/roct-thunk-interface-devel            |  1 +
 .../patches/cmake-dev-libdir.patch            | 10 ++++++
 .../roct-thunk-interface/patches/musl.patch   | 29 ++++++++++++++++
 srcpkgs/roct-thunk-interface/template         | 33 +++++++++++++++++++
 5 files changed, 74 insertions(+)
 create mode 120000 srcpkgs/roct-thunk-interface-devel
 create mode 100644 srcpkgs/roct-thunk-interface/patches/cmake-dev-libdir.patch
 create mode 100644 srcpkgs/roct-thunk-interface/patches/musl.patch
 create mode 100644 srcpkgs/roct-thunk-interface/template

diff --git a/common/shlibs b/common/shlibs
index 6d39ce34c19..d89ae72ae3e 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3862,3 +3862,4 @@ libtagparser.so.9 tagparser-9.1.2_1
 libqtutilities.so.6 qtutilities-6.0.4_1
 libkdsoap.so.1.9.0 KDSoap-1.9.0_1
 libstoken.so.1 stoken-0.92_1
+libhsakmt.so.1 roct-thunk-interface-3.3.0_1
diff --git a/srcpkgs/roct-thunk-interface-devel b/srcpkgs/roct-thunk-interface-devel
new file mode 120000
index 00000000000..ac3f2cc684c
--- /dev/null
+++ b/srcpkgs/roct-thunk-interface-devel
@@ -0,0 +1 @@
+roct-thunk-interface
\ No newline at end of file
diff --git a/srcpkgs/roct-thunk-interface/patches/cmake-dev-libdir.patch b/srcpkgs/roct-thunk-interface/patches/cmake-dev-libdir.patch
new file mode 100644
index 00000000000..98c7f1e459c
--- /dev/null
+++ b/srcpkgs/roct-thunk-interface/patches/cmake-dev-libdir.patch
@@ -0,0 +1,10 @@
+--- CMakeLists.txt.old	2020-04-18 19:45:17.306081135 -0400
++++ CMakeLists.txt	2020-04-18 19:46:51.300753636 -0400
+@@ -146,6 +146,7 @@
+     COMMAND ${CMAKE_COMMAND}
+         -DSOURCE_DIR="${SOURCE_DIR}"
+         -DCMAKE_INSTALL_PREFIX="${CMAKE_INSTALL_PREFIX}"
++        -DCMAKE_INSTALL_LIBDIR="${CMAKE_INSTALL_LIBDIR}"
+         -DCPACK_RPM_PACKAGE_REQUIRES="hsakmt-roct"
+         -DCPACK_PACKAGING_INSTALL_PREFIX="${CPACK_PACKAGING_INSTALL_PREFIX}"
+         -DVERSION="${BUILD_VERSION_STRING}"
diff --git a/srcpkgs/roct-thunk-interface/patches/musl.patch b/srcpkgs/roct-thunk-interface/patches/musl.patch
new file mode 100644
index 00000000000..aeea9832411
--- /dev/null
+++ b/srcpkgs/roct-thunk-interface/patches/musl.patch
@@ -0,0 +1,29 @@
+diff -r -u old/src/libhsakmt.h new/src/libhsakmt.h
+--- src/libhsakmt.h	2020-03-04 15:00:47.000000000 -0500
++++ src/libhsakmt.h	2020-04-13 12:58:30.444865992 -0400
+@@ -54,6 +54,10 @@
+ #define CHECK_KFD_OPEN() \
+ 	do { if (kfd_open_count == 0 || hsakmt_forked) return HSAKMT_STATUS_KERNEL_IO_CHANNEL_NOT_OPENED; } while (0)
+ 
++/*On some platforms, a PAGE_SIZE macro eclipses the extern variable*/
++#ifdef PAGE_SIZE
++#undef PAGE_SIZE
++#endif
+ extern int PAGE_SIZE;
+ extern int PAGE_SHIFT;
+ 
+diff -r -u old/src/topology.c new/src/topology.c
+--- src/topology.c	2020-03-04 15:00:47.000000000 -0500
++++ src/topology.c	2020-04-13 13:01:31.209870701 -0400
+@@ -38,6 +38,11 @@
+ #include "libhsakmt.h"
+ #include "fmm.h"
+ 
++/*Needed on MUSL*/
++#ifndef MAXNAMLEN
++#define MAXNAMLEN PATH_MAX
++#endif
++
+ /* Number of memory banks added by thunk on top of topology
+  * This only includes static heaps like LDS, scratch and SVM,
+  * not for MMIO_REMAP heap. MMIO_REMAP memory bank is reported
diff --git a/srcpkgs/roct-thunk-interface/template b/srcpkgs/roct-thunk-interface/template
new file mode 100644
index 00000000000..55a1fc6074a
--- /dev/null
+++ b/srcpkgs/roct-thunk-interface/template
@@ -0,0 +1,33 @@
+# Template file for 'roct-thunk-interface'
+pkgname=roct-thunk-interface
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="ROCT-Thunk-Interface-roc-${version}"
+build_style=cmake
+make_build_target="all build-dev"
+make_install_target="install install-dev"
+hostmakedepends="cmake pkg-config"
+makedepends="pciutils-devel libnuma-devel"
+short_desc="Radeon Open Compute Thunk Interface"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="MIT"
+homepage="https://github.com/RadeonOpenCompute/ROCT-Thunk-Interface"
+distfiles="${homepage}/archive/roc-${version}.tar.gz"
+checksum=2cabe9d2cfa72031c05d11290837c476182e72d8dec2049298f691143fdd212b
+nocross=yes
+
+post_install() {
+	vlicense LICENSE.md
+}
+
+roct-thunk-interface-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove "usr/lib/*.so"
+		vmove usr/share/pkgconfig
+		vmove usr/lib/cmake
+	}
+}

From d8bb69aca8ebcd167198d858c11e7b7fa326c389 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Mon, 13 Apr 2020 15:27:27 -0400
Subject: [PATCH 2/9] New package: rocr-runtime-3.3.0

---
 common/shlibs                            |  1 +
 srcpkgs/rocr-runtime-devel               |  1 +
 srcpkgs/rocr-runtime/patches/cmake.patch | 27 +++++++++++++++++++++
 srcpkgs/rocr-runtime/template            | 30 ++++++++++++++++++++++++
 4 files changed, 59 insertions(+)
 create mode 120000 srcpkgs/rocr-runtime-devel
 create mode 100644 srcpkgs/rocr-runtime/patches/cmake.patch
 create mode 100644 srcpkgs/rocr-runtime/template

diff --git a/common/shlibs b/common/shlibs
index d89ae72ae3e..499f35752c2 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3863,3 +3863,4 @@ libqtutilities.so.6 qtutilities-6.0.4_1
 libkdsoap.so.1.9.0 KDSoap-1.9.0_1
 libstoken.so.1 stoken-0.92_1
 libhsakmt.so.1 roct-thunk-interface-3.3.0_1
+libhsa-runtime64.so.1 rocr-runtime-3.3.0_1
diff --git a/srcpkgs/rocr-runtime-devel b/srcpkgs/rocr-runtime-devel
new file mode 120000
index 00000000000..be838f22d81
--- /dev/null
+++ b/srcpkgs/rocr-runtime-devel
@@ -0,0 +1 @@
+rocr-runtime
\ No newline at end of file
diff --git a/srcpkgs/rocr-runtime/patches/cmake.patch b/srcpkgs/rocr-runtime/patches/cmake.patch
new file mode 100644
index 00000000000..93b74cd2297
--- /dev/null
+++ b/srcpkgs/rocr-runtime/patches/cmake.patch
@@ -0,0 +1,27 @@
+--- src/CMakeLists.txt.old	2020-04-18 20:01:48.549636995 -0400
++++ src/CMakeLists.txt	2020-04-18 20:04:00.177179781 -0400
+@@ -108,8 +108,8 @@
+ ## ROCr build internal versioning
+ add_definitions ( -DROCR_BUILD_ID=${PACKAGE_VERSION_STRING} )
+ 
+-## Set RUNPATH - ../../lib covers use of the legacy symlink in /hsa/lib/
+-set(CMAKE_INSTALL_RPATH "$ORIGIN;$ORIGIN/../../lib;$ORIGIN/../../lib64;$ORIGIN/../lib64")
++## Set RUNPATH
++set(CMAKE_INSTALL_RPATH "$ORIGIN;$ORIGIN/../lib")
+ 
+ ## ------------------------- Linux Compiler and Linker options -------------------------
+ set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -fexceptions -fno-rtti -fvisibility=hidden -Wno-error=sign-compare -Wno-sign-compare -Wno-write-strings -Wno-conversion-null -fno-math-errno -fno-threadsafe-statics -fmerge-all-constants -fms-extensions -Wno-error=comment -Wno-comment -Wno-error=pointer-arith -Wno-pointer-arith -Wno-error=unused-variable -Wno-error=unused-function" )
+@@ -185,11 +185,8 @@
+ add_custom_target ( hsa_lib_link2 ALL WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMAND ${CMAKE_COMMAND} -E create_symlink ../hsa/lib/${CORE_RUNTIME_LIBRARY}.so.${SO_MAJOR} ${CORE_RUNTIME_LIBRARY}-link.so.${SO_MAJOR} )
+ 
+ ## Set install information
+-install ( TARGETS ${CORE_RUNTIME_TARGET} LIBRARY DESTINATION hsa/lib )
+-install ( DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/inc/ DESTINATION hsa/include/hsa )
+-install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/hsa_include_link DESTINATION include PERMISSIONS OWNER_WRITE OWNER_READ RENAME hsa )
+-install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/${CORE_RUNTIME_LIBRARY}-link.so DESTINATION lib PERMISSIONS OWNER_WRITE OWNER_READ RENAME ${CORE_RUNTIME_LIBRARY}.so )
+-install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/${CORE_RUNTIME_LIBRARY}-link.so.${SO_MAJOR} DESTINATION lib PERMISSIONS OWNER_WRITE OWNER_READ RENAME ${CORE_RUNTIME_LIBRARY}.so.${SO_MAJOR} )
++install ( TARGETS ${CORE_RUNTIME_TARGET} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} )
++install ( DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/inc/ DESTINATION include/hsa )
+ 
+ ## Packaging directives
+ set ( CPACK_GENERATOR "DEB;RPM" CACHE STRING "Package types to build")
diff --git a/srcpkgs/rocr-runtime/template b/srcpkgs/rocr-runtime/template
new file mode 100644
index 00000000000..5ee22140f1f
--- /dev/null
+++ b/srcpkgs/rocr-runtime/template
@@ -0,0 +1,30 @@
+# Template file for 'rocr-runtime'
+pkgname=rocr-runtime
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="ROCR-Runtime-rocm-${version}"
+build_wrksrc="src"
+build_style=cmake
+hostmakedepends="cmake pkg-config"
+makedepends="roct-thunk-interface-devel elfutils-devel"
+short_desc="Radeon Open Compute HSA Runtime"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute/ROCR-Runtime"
+distfiles="${homepage}/archive/rocm-${version}.tar.gz"
+checksum=fa2d2d1f8a61d8a6952d377cf288d78c61776c3c2a666f163cafc3aa19ab0b61
+nocross=yes
+
+post_install() {
+	vlicense ../LICENSE.txt
+}
+
+rocr-runtime-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove "usr/lib/*.so"
+	}
+}

From 8094f1ed5017c36dc9129b73ed78188378a51284 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Mon, 13 Apr 2020 18:07:34 -0400
Subject: [PATCH 3/9] New package: rocm-llvm-3.3.0

---
 srcpkgs/rocm-llvm/template | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)
 create mode 100644 srcpkgs/rocm-llvm/template

diff --git a/srcpkgs/rocm-llvm/template b/srcpkgs/rocm-llvm/template
new file mode 100644
index 00000000000..26942e3ea46
--- /dev/null
+++ b/srcpkgs/rocm-llvm/template
@@ -0,0 +1,25 @@
+# Template file for 'rocm-llvm'
+pkgname=rocm-llvm
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="llvm-project-rocm-ocl-${version}"
+build_wrksrc=llvm
+build_style=cmake
+configure_args="-DCMAKE_INSTALL_PREFIX:PATH=/usr/lib/rocm-llvm
+	-DLLVM_ENABLE_PROJECTS='llvm;clang;lld' -DLLVM_TARGETS_TO_BUILD='AMDGPU'
+	-DLLVM_BUILD_DOCS=NO -DLLVM_ENABLE_OCAMLDOC=OFF
+	-DLLVM_ENABLE_SPHINX=NO -DLLVM_ENABLE_DOXYGEN=OFF
+	-DLLVM_INSTALL_UTILS=ON -DLLVM_VERSION_SUFFIX=roc -DOCAMLFIND=NO"
+hostmakedepends="cmake pkg-config python3"
+short_desc="Radeon Open Compute LLVM toolchain"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="Apache-2.0, NCSA, custom:LLVM-Exceptions"
+homepage="https://github.com/RadeonOpenCompute/llvm-project"
+distfiles="${homepage}/archive/rocm-ocl-${version}.tar.gz"
+checksum=a2bef7042e8e2f2cd8548cb246b88322e1c77188839983dcac8312d56f544dc8
+nocross=yes
+
+post_install() {
+	vlicense LICENSE.TXT
+}

From 0e7977b668140e095f21839a24923005b3029c81 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Tue, 14 Apr 2020 10:25:31 -0400
Subject: [PATCH 4/9] New package: rocm-device-libs-3.3.0

---
 srcpkgs/rocm-device-libs/template | 37 +++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)
 create mode 100644 srcpkgs/rocm-device-libs/template

diff --git a/srcpkgs/rocm-device-libs/template b/srcpkgs/rocm-device-libs/template
new file mode 100644
index 00000000000..fcb4eb0d53e
--- /dev/null
+++ b/srcpkgs/rocm-device-libs/template
@@ -0,0 +1,37 @@
+# Template file for 'rocm-device-libs'
+pkgname=rocm-device-libs
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="ROCm-Device-Libs-rocm-ocl-${version}"
+build_style=cmake
+configure_args="-DLLVM_DIR:PATH=/usr/lib/rocm-llvm
+	-DCMAKE_INSTALL_LIBDIR:PATH=lib/rocm-device-libs"
+hostmakedepends="cmake rocm-llvm"
+short_desc="Radeon Open Compute device libraries"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute/ROCm-Device-Libs"
+distfiles="${homepage}/archive/rocm-ocl-${version}.tar.gz"
+checksum=706b08230790e08ca6a7a2fb7687d6131fd39a562148340e00fa37a6c06769c5
+nocross=yes
+
+pre_configure() {
+	# Put bytecodes in a lib/ subdirectory
+	vsed -i Packages.cmake -e 's@/lib/@/${CMAKE_INSTALL_LIBDIR}/@'
+	vsed -i OCL.cmake -e 's@DESTINATION lib$@DESTINATION ${CMAKE_INSTALL_LIBDIR}@'
+
+	# Build the prepare-builtins executable with native compiler
+	mkdir -p utils/build
+	cd utils/build
+	_prepare_builtins="$PWD/prepare-builtins/prepare-builtins"
+	cmake ${configure_args} ..
+	make ${makejobs}
+
+	# Add path to prepare-builtins for cmake
+	configure_args+=" -DPREPARE_BUILTINS='${_prepare_builtins}'"
+}
+
+post_install() {
+	vlicense LICENSE
+}

From 81355a023645398d9f99fcd99988a9f61f5f0777 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Mon, 13 Apr 2020 18:30:00 -0400
Subject: [PATCH 5/9] New package: rocm-comgr-3.3.0

---
 common/shlibs               |  1 +
 srcpkgs/rocm-comgr-devel    |  1 +
 srcpkgs/rocm-comgr/template | 32 ++++++++++++++++++++++++++++++++
 3 files changed, 34 insertions(+)
 create mode 120000 srcpkgs/rocm-comgr-devel
 create mode 100644 srcpkgs/rocm-comgr/template

diff --git a/common/shlibs b/common/shlibs
index 499f35752c2..a53de3cf9e0 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3864,3 +3864,4 @@ libkdsoap.so.1.9.0 KDSoap-1.9.0_1
 libstoken.so.1 stoken-0.92_1
 libhsakmt.so.1 roct-thunk-interface-3.3.0_1
 libhsa-runtime64.so.1 rocr-runtime-3.3.0_1
+libamd_comgr.so.1 rocm-comgr-3.3.0_1
diff --git a/srcpkgs/rocm-comgr-devel b/srcpkgs/rocm-comgr-devel
new file mode 120000
index 00000000000..3f5ce255e07
--- /dev/null
+++ b/srcpkgs/rocm-comgr-devel
@@ -0,0 +1 @@
+rocm-comgr
\ No newline at end of file
diff --git a/srcpkgs/rocm-comgr/template b/srcpkgs/rocm-comgr/template
new file mode 100644
index 00000000000..c228bcd4d1f
--- /dev/null
+++ b/srcpkgs/rocm-comgr/template
@@ -0,0 +1,32 @@
+# Template file for 'rocm-comgr'
+pkgname=rocm-comgr
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="ROCm-CompilerSupport-rocm-${version}"
+build_wrksrc="lib/comgr"
+build_style=cmake
+configure_args="-DClang_DIR:PATH=/usr/lib/rocm-llvm/lib/cmake/clang"
+hostmakedepends="cmake pkg-config rocm-llvm"
+makedepends="rocm-device-libs"
+short_desc="Radeon Open Compute Code Object Manager"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="BSD-3-Clause"
+homepage="https://github.com/RadeonOpenCompute/ROCm-CompilerSupport"
+distfiles="${homepage}/archive/rocm-${version}.tar.gz"
+checksum=01e2524e0f28ecd6f46c9720f279207de935d826b0172158792aa3ec86af9ca7
+nocross=yes
+
+post_install() {
+	vlicense LICENSE.txt
+}
+
+rocm-comgr-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove "usr/lib/*.so"
+		vmove usr/lib/cmake
+	}
+}

From 1dda7453d2c6b722fc45c445c49bebd948ea5bda Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Fri, 17 Apr 2020 12:11:25 -0400
Subject: [PATCH 6/9] New package: rocminfo-3.3.0

---
 srcpkgs/rocminfo/template | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
 create mode 100644 srcpkgs/rocminfo/template

diff --git a/srcpkgs/rocminfo/template b/srcpkgs/rocminfo/template
new file mode 100644
index 00000000000..57d0640dd69
--- /dev/null
+++ b/srcpkgs/rocminfo/template
@@ -0,0 +1,22 @@
+# Template file for 'rocminfo'
+pkgname=rocminfo
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="rocminfo-rocm-${version}"
+build_style=cmake
+configure_args="-DROCM_DIR=/usr"
+hostmakedepends="cmake pkg-config"
+makedepends="rocr-runtime-devel"
+short_desc="Radeon Open Compute system information reporter"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute/rocminfo"
+distfiles="${homepage}/archive/rocm-${version}.tar.gz"
+checksum=e666f662c9e465aaabbbd0b109d87e017243cdf1a0898fabf5a90947bb3dbcd7
+nocross=yes
+python_version=3
+
+post_install() {
+	vlicense License.txt
+}

From e84da1d860708fe8c5d8b144500711d167743578 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Sun, 19 Apr 2020 15:01:40 -0400
Subject: [PATCH 7/9] New package: rocm-bandwidth-test-3.3.0

---
 srcpkgs/rocm-bandwidth-test/template | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
 create mode 100644 srcpkgs/rocm-bandwidth-test/template

diff --git a/srcpkgs/rocm-bandwidth-test/template b/srcpkgs/rocm-bandwidth-test/template
new file mode 100644
index 00000000000..5c5058b693d
--- /dev/null
+++ b/srcpkgs/rocm-bandwidth-test/template
@@ -0,0 +1,20 @@
+# Template file for 'rocm-bandwidth-test'
+pkgname=rocm-bandwidth-test
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="rocm_bandwidth_test-rocm-${version}"
+build_style=cmake
+hostmakedepends="cmake"
+makedepends="rocr-runtime-devel roct-thunk-interface-devel"
+short_desc="Radeon Open Compute bandwidth test"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute/rocm_bandwidth_test"
+distfiles="${homepage}/archive/rocm-${version}.tar.gz"
+checksum=f5f914073018619dc91662d5bf630903dfa4db9136d603591917fdfb3c9164ce
+nocross=yes
+
+post_install() {
+	vlicense LICENSE.txt
+}

From 5da68ef267144953447d7bdabcf7818e9c167180 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Tue, 14 Apr 2020 10:25:54 -0400
Subject: [PATCH 8/9] New package: rocm-opencl-runtime-3.3.0

---
 common/shlibs                                 |   2 +
 srcpkgs/rocm-opencl-runtime-clinfo            |   1 +
 srcpkgs/rocm-opencl-runtime-devel             |   1 +
 .../files/libelf-musl.patch                   | 688 ++++++++++++++++++
 .../files/runtime-musl.patch                  |  11 +
 srcpkgs/rocm-opencl-runtime/files/sys_queue.h | 574 +++++++++++++++
 .../rocm-opencl-runtime/patches/cmake.patch   | 126 ++++
 srcpkgs/rocm-opencl-runtime/template          |  82 +++
 8 files changed, 1485 insertions(+)
 create mode 120000 srcpkgs/rocm-opencl-runtime-clinfo
 create mode 120000 srcpkgs/rocm-opencl-runtime-devel
 create mode 100644 srcpkgs/rocm-opencl-runtime/files/libelf-musl.patch
 create mode 100644 srcpkgs/rocm-opencl-runtime/files/runtime-musl.patch
 create mode 100644 srcpkgs/rocm-opencl-runtime/files/sys_queue.h
 create mode 100644 srcpkgs/rocm-opencl-runtime/patches/cmake.patch
 create mode 100644 srcpkgs/rocm-opencl-runtime/template

diff --git a/common/shlibs b/common/shlibs
index a53de3cf9e0..8cbc885e016 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3865,3 +3865,5 @@ libstoken.so.1 stoken-0.92_1
 libhsakmt.so.1 roct-thunk-interface-3.3.0_1
 libhsa-runtime64.so.1 rocr-runtime-3.3.0_1
 libamd_comgr.so.1 rocm-comgr-3.3.0_1
+libOpenCL-ROCm.so.1 rocm-opencl-runtime-3.3.0_1
+libamdocl64.so rocm-opencl-runtime-3.3.0_1
diff --git a/srcpkgs/rocm-opencl-runtime-clinfo b/srcpkgs/rocm-opencl-runtime-clinfo
new file mode 120000
index 00000000000..b2cda7e229d
--- /dev/null
+++ b/srcpkgs/rocm-opencl-runtime-clinfo
@@ -0,0 +1 @@
+rocm-opencl-runtime
\ No newline at end of file
diff --git a/srcpkgs/rocm-opencl-runtime-devel b/srcpkgs/rocm-opencl-runtime-devel
new file mode 120000
index 00000000000..b2cda7e229d
--- /dev/null
+++ b/srcpkgs/rocm-opencl-runtime-devel
@@ -0,0 +1 @@
+rocm-opencl-runtime
\ No newline at end of file
diff --git a/srcpkgs/rocm-opencl-runtime/files/libelf-musl.patch b/srcpkgs/rocm-opencl-runtime/files/libelf-musl.patch
new file mode 100644
index 00000000000..a3705c259a9
--- /dev/null
+++ b/srcpkgs/rocm-opencl-runtime/files/libelf-musl.patch
@@ -0,0 +1,688 @@
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/_libelf.h compiler/lib/loaders/elf/utils/libelf/_libelf.h
+--- compiler/lib/loaders/elf/utils/libelf.orig/_libelf.h	2020-04-19 08:59:34.201386585 -0400
++++ compiler/lib/loaders/elf/utils/libelf/_libelf.h	2020-04-19 09:04:12.950433528 -0400
+@@ -30,7 +30,7 @@
+ #define	__LIBELF_H_
+ 
+ #include <limits.h>
+-#include <sys/queue.h>
++#include "sys_queue.h"
+ 
+ #include "_libelf_config.h"
+ 
+@@ -179,7 +179,9 @@
+  * Function Prototypes.
+  */
+ 
+-__BEGIN_DECLS
++#ifdef __cplusplus
++extern "C" {
++#endif
+ Elf_Data *_libelf_allocate_data(Elf_Scn *_s);
+ Elf	*_libelf_allocate_elf(Elf_Mem *mem);
+ Elf_Scn	*_libelf_allocate_scn(Elf *_e, size_t _ndx);
+@@ -213,6 +215,8 @@
+ Elf_Data *_libelf_xlate(Elf_Data *_d, const Elf_Data *_s,
+     unsigned int _encoding, int _elfclass, int _direction);
+ int	_libelf_xlate_shtype(uint32_t _sht);
+-__END_DECLS
++#ifdef __cplusplus
++}
++#endif
+ 
+ #endif	/* __LIBELF_H_ */
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_begin.c compiler/lib/loaders/elf/utils/libelf/elf_begin.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_begin.c	2020-04-19 08:59:34.201386585 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_begin.c	2020-04-19 09:01:04.313212042 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <sys/types.h>
+ #if !defined(WIN32)
+ #include <sys/errno.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_end.c compiler/lib/loaders/elf/utils/libelf/elf_end.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_end.c	2020-04-19 08:59:34.201386585 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_end.c	2020-04-19 09:01:14.895204681 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #if !defined(WIN32)
+ #include <sys/mman.h>
+ #endif
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_errmsg.c compiler/lib/loaders/elf/utils/libelf/elf_errmsg.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_errmsg.c	2020-04-19 08:59:34.201386585 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_errmsg.c	2020-04-19 09:01:16.753207065 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ #include <stdio.h>
+ #include <string.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_errno.c compiler/lib/loaders/elf/utils/libelf/elf_errno.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_errno.c	2020-04-19 08:59:34.201386585 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_errno.c	2020-04-19 09:01:18.669209528 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_fill.c compiler/lib/loaders/elf/utils/libelf/elf_fill.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_fill.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_fill.c	2020-04-19 09:01:21.109212667 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_flag.c compiler/lib/loaders/elf/utils/libelf/elf_flag.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_flag.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_flag.c	2020-04-19 09:01:23.376215579 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_getarhdr.c compiler/lib/loaders/elf/utils/libelf/elf_getarhdr.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_getarhdr.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_getarhdr.c	2020-04-19 09:01:25.414218197 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_getarsym.c compiler/lib/loaders/elf/utils/libelf/elf_getarsym.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_getarsym.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_getarsym.c	2020-04-19 09:01:27.575220978 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_getbase.c compiler/lib/loaders/elf/utils/libelf/elf_getbase.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_getbase.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_getbase.c	2020-04-19 09:01:29.963224043 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_getident.c compiler/lib/loaders/elf/utils/libelf/elf_getident.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_getident.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_getident.c	2020-04-19 09:01:31.912226551 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <ar.h>
+ #include <assert.h>
+ #include <libelf.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_hash.c compiler/lib/loaders/elf/utils/libelf/elf_hash.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_hash.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_hash.c	2020-04-19 09:01:33.877229069 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ #include "_libelf_config.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_kind.c compiler/lib/loaders/elf/utils/libelf/elf_kind.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_kind.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_kind.c	2020-04-19 09:01:35.940231721 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_memory.c compiler/lib/loaders/elf/utils/libelf/elf_memory.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_memory.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_memory.c	2020-04-19 09:01:38.171234596 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <ar.h>
+ #include <libelf.h>
+ #include <string.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_next.c compiler/lib/loaders/elf/utils/libelf/elf_next.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_next.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_next.c	2020-04-19 09:01:40.063237028 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <ar.h>
+ #include <assert.h>
+ #include <libelf.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_phnum.c compiler/lib/loaders/elf/utils/libelf/elf_phnum.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_phnum.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_phnum.c	2020-04-19 09:01:42.480240134 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <ar.h>
+ #include <libelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_rand.c compiler/lib/loaders/elf/utils/libelf/elf_rand.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_rand.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_rand.c	2020-04-19 09:01:45.061243452 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <ar.h>
+ #include <libelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_rawfile.c compiler/lib/loaders/elf/utils/libelf/elf_rawfile.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_rawfile.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_rawfile.c	2020-04-19 09:01:46.988245928 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_scn.c compiler/lib/loaders/elf/utils/libelf/elf_scn.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_scn.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_scn.c	2020-04-19 09:00:19.724298403 -0400
+@@ -24,8 +24,7 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-#include <sys/queue.h>
++#include "sys_queue.h"
+ 
+ #include <assert.h>
+ #include <errno.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_shnum.c compiler/lib/loaders/elf/utils/libelf/elf_shnum.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_shnum.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_shnum.c	2020-04-19 09:01:51.763252060 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <ar.h>
+ #include <libelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_shstrndx.c compiler/lib/loaders/elf/utils/libelf/elf_shstrndx.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_shstrndx.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_shstrndx.c	2020-04-19 09:01:53.532254340 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <ar.h>
+ #include <libelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_version.c compiler/lib/loaders/elf/utils/libelf/elf_version.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_version.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_version.c	2020-04-19 09:02:01.337264370 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf.h compiler/lib/loaders/elf/utils/libelf/gelf.h
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf.h	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf.h	2020-04-19 09:04:29.669455020 -0400
+@@ -29,8 +29,6 @@
+ #ifndef	_GELF_H_
+ #define	_GELF_H_
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ typedef Elf64_Addr	GElf_Addr;	/* Addresses */
+@@ -72,7 +70,9 @@
+ #define	GELF_ST_TYPE			ELF64_ST_TYPE
+ #define	GELF_ST_VISIBILITY		ELF64_ST_VISIBILITY
+ 
+-__BEGIN_DECLS
++#ifdef __cplusplus
++extern "C" {
++#endif
+ long		gelf_checksum(Elf *_elf);
+ size_t		gelf_fsize(Elf *_elf, Elf_Type _type, size_t _count,
+ 			unsigned int _version);
+@@ -109,6 +109,8 @@
+ int		gelf_update_move(Elf_Data *_dst, int _index, GElf_Move *_src);
+ int		gelf_update_syminfo(Elf_Data *_dst, int _index, GElf_Syminfo *_src);
+ #endif
+-__END_DECLS
++#ifdef __cplusplus
++}
++#endif
+ 
+ #endif	/* _GELF_H_ */
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_cap.c compiler/lib/loaders/elf/utils/libelf/gelf_cap.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_cap.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_cap.c	2020-04-19 09:02:05.429269632 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_checksum.c compiler/lib/loaders/elf/utils/libelf/gelf_checksum.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_checksum.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_checksum.c	2020-04-19 09:02:08.192273183 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <gelf.h>
+ #include <libelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_dyn.c compiler/lib/loaders/elf/utils/libelf/gelf_dyn.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_dyn.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_dyn.c	2020-04-19 09:02:10.020275525 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_ehdr.c compiler/lib/loaders/elf/utils/libelf/gelf_ehdr.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_ehdr.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_ehdr.c	2020-04-19 09:02:11.882277926 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ #include <libelf.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_fsize.c compiler/lib/loaders/elf/utils/libelf/gelf_fsize.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_fsize.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_fsize.c	2020-04-19 09:02:14.139280827 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <gelf.h>
+ #include <libelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_getclass.c compiler/lib/loaders/elf/utils/libelf/gelf_getclass.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_getclass.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_getclass.c	2020-04-19 09:02:17.269284848 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <gelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_move.c compiler/lib/loaders/elf/utils/libelf/gelf_move.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_move.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_move.c	2020-04-19 09:02:18.974287034 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_phdr.c compiler/lib/loaders/elf/utils/libelf/gelf_phdr.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_phdr.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_phdr.c	2020-04-19 09:02:20.676289227 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <gelf.h>
+ #include <libelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_rel.c compiler/lib/loaders/elf/utils/libelf/gelf_rel.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_rel.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_rel.c	2020-04-19 09:02:23.177292435 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_rela.c compiler/lib/loaders/elf/utils/libelf/gelf_rela.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_rela.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_rela.c	2020-04-19 09:02:25.246295100 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_shdr.c compiler/lib/loaders/elf/utils/libelf/gelf_shdr.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_shdr.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_shdr.c	2020-04-19 09:02:28.325299060 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ #include <libelf.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_sym.c compiler/lib/loaders/elf/utils/libelf/gelf_sym.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_sym.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_sym.c	2020-04-19 09:02:30.113301356 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_syminfo.c compiler/lib/loaders/elf/utils/libelf/gelf_syminfo.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_syminfo.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_syminfo.c	2020-04-19 09:02:31.906303662 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_symshndx.c compiler/lib/loaders/elf/utils/libelf/gelf_symshndx.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_symshndx.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_symshndx.c	2020-04-19 09:02:33.626305873 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_xlate.c compiler/lib/loaders/elf/utils/libelf/gelf_xlate.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_xlate.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_xlate.c	2020-04-19 09:02:35.921308822 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <gelf.h>
+ #include <libelf.h>
+ #include <string.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf.h compiler/lib/loaders/elf/utils/libelf/libelf.h
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf.h	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf.h	2020-04-19 09:04:38.760466706 -0400
+@@ -30,7 +30,7 @@
+ #define	_LIBELF_H_
+ 
+ #include <sys/types.h>
+-#include <sys/queue.h>
++#include "sys_queue.h"
+ #include <elfdefinitions.h>
+ #ifndef EM_HSAIL
+ #define EM_HSAIL 0xAF5A
+@@ -187,7 +187,9 @@
+ #define	ELF_F_ARCHIVE	   0x100U /* archive creation */
+ #define	ELF_F_ARCHIVE_SYSV 0x200U /* SYSV style archive */
+ 
+-__BEGIN_DECLS
++#ifdef __cplusplus
++extern "C" {
++#endif
+ Elf		*elf_begin(int _fd, Elf_Cmd _cmd, Elf *_elf, Elf_Mem *_mem);
+ int		elf_cntl(Elf *_elf, Elf_Cmd _cmd);
+ int		elf_end(Elf *_elf);
+@@ -257,6 +259,8 @@
+ 			unsigned int _enc);
+ Elf_Data	*elf64_xlatetom(Elf_Data *_dst, const Elf_Data *_src,
+ 			unsigned int _enc);
+-__END_DECLS
++#ifdef __cplusplus
++}
++#endif
+ 
+ #endif	/* _LIBELF_H_ */
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_align.c compiler/lib/loaders/elf/utils/libelf/libelf_align.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_align.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_align.c	2020-04-19 09:02:40.660314911 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <sys/types.h>
+ 
+ #include <libelf.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_allocate.c compiler/lib/loaders/elf/utils/libelf/libelf_allocate.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_allocate.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_allocate.c	2020-04-19 09:02:43.079318019 -0400
+@@ -28,8 +28,6 @@
+  * Internal APIs
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #if !defined(WIN32)
+ #include <sys/errno.h>
+ #endif
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_ar.c compiler/lib/loaders/elf/utils/libelf/libelf_ar.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_ar.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_ar.c	2020-04-19 09:02:44.763320187 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <ctype.h>
+ #include <libelf.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_ar_util.c compiler/lib/loaders/elf/utils/libelf/libelf_ar_util.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_ar_util.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_ar_util.c	2020-04-19 09:02:46.461322369 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <libelf.h>
+ #include <stdlib.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_checksum.c compiler/lib/loaders/elf/utils/libelf/libelf_checksum.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_checksum.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_checksum.c	2020-04-19 09:02:48.645325173 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <gelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_convert.c compiler/lib/loaders/elf/utils/libelf/libelf_convert.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_convert.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_convert.c	2020-04-19 09:02:50.883328053 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <libelf.h>
+ #include <string.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_data.c compiler/lib/loaders/elf/utils/libelf/libelf_data.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_data.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_data.c	2020-04-19 09:02:52.951330708 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_ehdr.c compiler/lib/loaders/elf/utils/libelf/libelf_ehdr.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_ehdr.c	2020-04-19 08:59:34.204386579 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_ehdr.c	2020-04-19 09:02:55.176333563 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ #include <libelf.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_extended.c compiler/lib/loaders/elf/utils/libelf/libelf_extended.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_extended.c	2020-04-19 08:59:34.204386579 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_extended.c	2020-04-19 09:02:57.932337110 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <libelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_msize.c compiler/lib/loaders/elf/utils/libelf/libelf_msize.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_msize.c	2020-04-19 08:59:34.204386579 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_msize.c	2020-04-19 09:03:02.201342598 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <libelf.h>
+ #include <string.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_phdr.c compiler/lib/loaders/elf/utils/libelf/libelf_phdr.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_phdr.c	2020-04-19 08:59:34.204386579 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_phdr.c	2020-04-19 09:03:04.194345160 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ #include <libelf.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_shdr.c compiler/lib/loaders/elf/utils/libelf/libelf_shdr.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_shdr.c	2020-04-19 08:59:34.204386579 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_shdr.c	2020-04-19 09:03:05.795347218 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <gelf.h>
+ #include <libelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_xlate.c compiler/lib/loaders/elf/utils/libelf/libelf_xlate.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_xlate.c	2020-04-19 08:59:34.204386579 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_xlate.c	2020-04-19 09:03:09.472351944 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <libelf.h>
+ 
diff --git a/srcpkgs/rocm-opencl-runtime/files/runtime-musl.patch b/srcpkgs/rocm-opencl-runtime/files/runtime-musl.patch
new file mode 100644
index 00000000000..ea18e90e09c
--- /dev/null
+++ b/srcpkgs/rocm-opencl-runtime/files/runtime-musl.patch
@@ -0,0 +1,11 @@
+--- runtime/os/os_posix.cpp.orig	2020-04-19 09:13:51.701982901 -0400
++++ runtime/os/os_posix.cpp	2020-04-19 09:14:04.156947422 -0400
+@@ -44,6 +44,8 @@
+ #include <algorithm>
+ #include <mutex>
+ 
++#include <libgen.h> // for basename
++
+ 
+ namespace amd {
+ 
diff --git a/srcpkgs/rocm-opencl-runtime/files/sys_queue.h b/srcpkgs/rocm-opencl-runtime/files/sys_queue.h
new file mode 100644
index 00000000000..daf4553d33e
--- /dev/null
+++ b/srcpkgs/rocm-opencl-runtime/files/sys_queue.h
@@ -0,0 +1,574 @@
+/*
+ * Copyright (c) 1991, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *	@(#)queue.h	8.5 (Berkeley) 8/20/94
+ */
+
+#ifndef	_SYS_QUEUE_H_
+#define	_SYS_QUEUE_H_
+
+/*
+ * This file defines five types of data structures: singly-linked lists,
+ * lists, simple queues, tail queues, and circular queues.
+ *
+ * A singly-linked list is headed by a single forward pointer. The
+ * elements are singly linked for minimum space and pointer manipulation
+ * overhead at the expense of O(n) removal for arbitrary elements. New
+ * elements can be added to the list after an existing element or at the
+ * head of the list.  Elements being removed from the head of the list
+ * should use the explicit macro for this purpose for optimum
+ * efficiency. A singly-linked list may only be traversed in the forward
+ * direction.  Singly-linked lists are ideal for applications with large
+ * datasets and few or no removals or for implementing a LIFO queue.
+ *
+ * A list is headed by a single forward pointer (or an array of forward
+ * pointers for a hash table header). The elements are doubly linked
+ * so that an arbitrary element can be removed without a need to
+ * traverse the list. New elements can be added to the list before
+ * or after an existing element or at the head of the list. A list
+ * may only be traversed in the forward direction.
+ *
+ * A simple queue is headed by a pair of pointers, one the head of the
+ * list and the other to the tail of the list. The elements are singly
+ * linked to save space, so elements can only be removed from the
+ * head of the list. New elements can be added to the list after
+ * an existing element, at the head of the list, or at the end of the
+ * list. A simple queue may only be traversed in the forward direction.
+ *
+ * A tail queue is headed by a pair of pointers, one to the head of the
+ * list and the other to the tail of the list. The elements are doubly
+ * linked so that an arbitrary element can be removed without a need to
+ * traverse the list. New elements can be added to the list before or
+ * after an existing element, at the head of the list, or at the end of
+ * the list. A tail queue may be traversed in either direction.
+ *
+ * A circle queue is headed by a pair of pointers, one to the head of the
+ * list and the other to the tail of the list. The elements are doubly
+ * linked so that an arbitrary element can be removed without a need to
+ * traverse the list. New elements can be added to the list before or after
+ * an existing element, at the head of the list, or at the end of the list.
+ * A circle queue may be traversed in either direction, but has a more
+ * complex end of list detection.
+ *
+ * For details on the use of these macros, see the queue(3) manual page.
+ */
+
+/*
+ * List definitions.
+ */
+#define	LIST_HEAD(name, type)						\
+struct name {								\
+	struct type *lh_first;	/* first element */			\
+}
+
+#define	LIST_HEAD_INITIALIZER(head)					\
+	{ NULL }
+
+#define	LIST_ENTRY(type)						\
+struct {								\
+	struct type *le_next;	/* next element */			\
+	struct type **le_prev;	/* address of previous next element */	\
+}
+
+/*
+ * List functions.
+ */
+#define	LIST_INIT(head) do {						\
+	(head)->lh_first = NULL;					\
+} while (/*CONSTCOND*/0)
+
+#define	LIST_INSERT_AFTER(listelm, elm, field) do {			\
+	if (((elm)->field.le_next = (listelm)->field.le_next) != NULL)	\
+		(listelm)->field.le_next->field.le_prev =		\
+		    &(elm)->field.le_next;				\
+	(listelm)->field.le_next = (elm);				\
+	(elm)->field.le_prev = &(listelm)->field.le_next;		\
+} while (/*CONSTCOND*/0)
+
+#define	LIST_INSERT_BEFORE(listelm, elm, field) do {			\
+	(elm)->field.le_prev = (listelm)->field.le_prev;		\
+	(elm)->field.le_next = (listelm);				\
+	*(listelm)->field.le_prev = (elm);				\
+	(listelm)->field.le_prev = &(elm)->field.le_next;		\
+} while (/*CONSTCOND*/0)
+
+#define	LIST_INSERT_HEAD(head, elm, field) do {				\
+	if (((elm)->field.le_next = (head)->lh_first) != NULL)		\
+		(head)->lh_first->field.le_prev = &(elm)->field.le_next;\
+	(head)->lh_first = (elm);					\
+	(elm)->field.le_prev = &(head)->lh_first;			\
+} while (/*CONSTCOND*/0)
+
+#define	LIST_REMOVE(elm, field) do {					\
+	if ((elm)->field.le_next != NULL)				\
+		(elm)->field.le_next->field.le_prev = 			\
+		    (elm)->field.le_prev;				\
+	*(elm)->field.le_prev = (elm)->field.le_next;			\
+} while (/*CONSTCOND*/0)
+
+#define	LIST_FOREACH(var, head, field)					\
+	for ((var) = ((head)->lh_first);				\
+		(var);							\
+		(var) = ((var)->field.le_next))
+
+/*
+ * List access methods.
+ */
+#define	LIST_EMPTY(head)		((head)->lh_first == NULL)
+#define	LIST_FIRST(head)		((head)->lh_first)
+#define	LIST_NEXT(elm, field)		((elm)->field.le_next)
+
+
+/*
+ * Singly-linked List definitions.
+ */
+#define	SLIST_HEAD(name, type)						\
+struct name {								\
+	struct type *slh_first;	/* first element */			\
+}
+
+#define	SLIST_HEAD_INITIALIZER(head)					\
+	{ NULL }
+
+#define	SLIST_ENTRY(type)						\
+struct {								\
+	struct type *sle_next;	/* next element */			\
+}
+
+/*
+ * Singly-linked List functions.
+ */
+#define	SLIST_INIT(head) do {						\
+	(head)->slh_first = NULL;					\
+} while (/*CONSTCOND*/0)
+
+#define	SLIST_INSERT_AFTER(slistelm, elm, field) do {			\
+	(elm)->field.sle_next = (slistelm)->field.sle_next;		\
+	(slistelm)->field.sle_next = (elm);				\
+} while (/*CONSTCOND*/0)
+
+#define	SLIST_INSERT_HEAD(head, elm, field) do {			\
+	(elm)->field.sle_next = (head)->slh_first;			\
+	(head)->slh_first = (elm);					\
+} while (/*CONSTCOND*/0)
+
+#define	SLIST_REMOVE_HEAD(head, field) do {				\
+	(head)->slh_first = (head)->slh_first->field.sle_next;		\
+} while (/*CONSTCOND*/0)
+
+#define	SLIST_REMOVE(head, elm, type, field) do {			\
+	if ((head)->slh_first == (elm)) {				\
+		SLIST_REMOVE_HEAD((head), field);			\
+	}								\
+	else {								\
+		struct type *curelm = (head)->slh_first;		\
+		while(curelm->field.sle_next != (elm))			\
+			curelm = curelm->field.sle_next;		\
+		curelm->field.sle_next =				\
+		    curelm->field.sle_next->field.sle_next;		\
+	}								\
+} while (/*CONSTCOND*/0)
+
+#define	SLIST_FOREACH(var, head, field)					\
+	for((var) = (head)->slh_first; (var); (var) = (var)->field.sle_next)
+
+/*
+ * Singly-linked List access methods.
+ */
+#define	SLIST_EMPTY(head)	((head)->slh_first == NULL)
+#define	SLIST_FIRST(head)	((head)->slh_first)
+#define	SLIST_NEXT(elm, field)	((elm)->field.sle_next)
+
+
+/*
+ * Singly-linked Tail queue declarations.
+ */
+#define	STAILQ_HEAD(name, type)					\
+struct name {								\
+	struct type *stqh_first;	/* first element */			\
+	struct type **stqh_last;	/* addr of last next element */		\
+}
+
+#define	STAILQ_HEAD_INITIALIZER(head)					\
+	{ NULL, &(head).stqh_first }
+
+#define	STAILQ_ENTRY(type)						\
+struct {								\
+	struct type *stqe_next;	/* next element */			\
+}
+
+/*
+ * Singly-linked Tail queue functions.
+ */
+#define	STAILQ_INIT(head) do {						\
+	(head)->stqh_first = NULL;					\
+	(head)->stqh_last = &(head)->stqh_first;				\
+} while (/*CONSTCOND*/0)
+
+#define	STAILQ_INSERT_HEAD(head, elm, field) do {			\
+	if (((elm)->field.stqe_next = (head)->stqh_first) == NULL)	\
+		(head)->stqh_last = &(elm)->field.stqe_next;		\
+	(head)->stqh_first = (elm);					\
+} while (/*CONSTCOND*/0)
+
+#define	STAILQ_INSERT_TAIL(head, elm, field) do {			\
+	(elm)->field.stqe_next = NULL;					\
+	*(head)->stqh_last = (elm);					\
+	(head)->stqh_last = &(elm)->field.stqe_next;			\
+} while (/*CONSTCOND*/0)
+
+#define	STAILQ_INSERT_AFTER(head, listelm, elm, field) do {		\
+	if (((elm)->field.stqe_next = (listelm)->field.stqe_next) == NULL)\
+		(head)->stqh_last = &(elm)->field.stqe_next;		\
+	(listelm)->field.stqe_next = (elm);				\
+} while (/*CONSTCOND*/0)
+
+#define	STAILQ_REMOVE_HEAD(head, field) do {				\
+	if (((head)->stqh_first = (head)->stqh_first->field.stqe_next) == NULL) \
+		(head)->stqh_last = &(head)->stqh_first;			\
+} while (/*CONSTCOND*/0)
+
+#define	STAILQ_REMOVE(head, elm, type, field) do {			\
+	if ((head)->stqh_first == (elm)) {				\
+		STAILQ_REMOVE_HEAD((head), field);			\
+	} else {							\
+		struct type *curelm = (head)->stqh_first;		\
+		while (curelm->field.stqe_next != (elm))			\
+			curelm = curelm->field.stqe_next;		\
+		if ((curelm->field.stqe_next =				\
+			curelm->field.stqe_next->field.stqe_next) == NULL) \
+			    (head)->stqh_last = &(curelm)->field.stqe_next; \
+	}								\
+} while (/*CONSTCOND*/0)
+
+#define	STAILQ_FOREACH(var, head, field)				\
+	for ((var) = ((head)->stqh_first);				\
+		(var);							\
+		(var) = ((var)->field.stqe_next))
+
+#define	STAILQ_CONCAT(head1, head2) do {				\
+	if (!STAILQ_EMPTY((head2))) {					\
+		*(head1)->stqh_last = (head2)->stqh_first;		\
+		(head1)->stqh_last = (head2)->stqh_last;		\
+		STAILQ_INIT((head2));					\
+	}								\
+} while (/*CONSTCOND*/0)
+
+/*
+ * Singly-linked Tail queue access methods.
+ */
+#define	STAILQ_EMPTY(head)	((head)->stqh_first == NULL)
+#define	STAILQ_FIRST(head)	((head)->stqh_first)
+#define	STAILQ_NEXT(elm, field)	((elm)->field.stqe_next)
+
+
+/*
+ * Simple queue definitions.
+ */
+#define	SIMPLEQ_HEAD(name, type)					\
+struct name {								\
+	struct type *sqh_first;	/* first element */			\
+	struct type **sqh_last;	/* addr of last next element */		\
+}
+
+#define	SIMPLEQ_HEAD_INITIALIZER(head)					\
+	{ NULL, &(head).sqh_first }
+
+#define	SIMPLEQ_ENTRY(type)						\
+struct {								\
+	struct type *sqe_next;	/* next element */			\
+}
+
+/*
+ * Simple queue functions.
+ */
+#define	SIMPLEQ_INIT(head) do {						\
+	(head)->sqh_first = NULL;					\
+	(head)->sqh_last = &(head)->sqh_first;				\
+} while (/*CONSTCOND*/0)
+
+#define	SIMPLEQ_INSERT_HEAD(head, elm, field) do {			\
+	if (((elm)->field.sqe_next = (head)->sqh_first) == NULL)	\
+		(head)->sqh_last = &(elm)->field.sqe_next;		\
+	(head)->sqh_first = (elm);					\
+} while (/*CONSTCOND*/0)
+
+#define	SIMPLEQ_INSERT_TAIL(head, elm, field) do {			\
+	(elm)->field.sqe_next = NULL;					\
+	*(head)->sqh_last = (elm);					\
+	(head)->sqh_last = &(elm)->field.sqe_next;			\
+} while (/*CONSTCOND*/0)
+
+#define	SIMPLEQ_INSERT_AFTER(head, listelm, elm, field) do {		\
+	if (((elm)->field.sqe_next = (listelm)->field.sqe_next) == NULL)\
+		(head)->sqh_last = &(elm)->field.sqe_next;		\
+	(listelm)->field.sqe_next = (elm);				\
+} while (/*CONSTCOND*/0)
+
+#define	SIMPLEQ_REMOVE_HEAD(head, field) do {				\
+	if (((head)->sqh_first = (head)->sqh_first->field.sqe_next) == NULL) \
+		(head)->sqh_last = &(head)->sqh_first;			\
+} while (/*CONSTCOND*/0)
+
+#define	SIMPLEQ_REMOVE(head, elm, type, field) do {			\
+	if ((head)->sqh_first == (elm)) {				\
+		SIMPLEQ_REMOVE_HEAD((head), field);			\
+	} else {							\
+		struct type *curelm = (head)->sqh_first;		\
+		while (curelm->field.sqe_next != (elm))			\
+			curelm = curelm->field.sqe_next;		\
+		if ((curelm->field.sqe_next =				\
+			curelm->field.sqe_next->field.sqe_next) == NULL) \
+			    (head)->sqh_last = &(curelm)->field.sqe_next; \
+	}								\
+} while (/*CONSTCOND*/0)
+
+#define	SIMPLEQ_FOREACH(var, head, field)				\
+	for ((var) = ((head)->sqh_first);				\
+		(var);							\
+		(var) = ((var)->field.sqe_next))
+
+/*
+ * Simple queue access methods.
+ */
+#define	SIMPLEQ_EMPTY(head)		((head)->sqh_first == NULL)
+#define	SIMPLEQ_FIRST(head)		((head)->sqh_first)
+#define	SIMPLEQ_NEXT(elm, field)	((elm)->field.sqe_next)
+
+
+/*
+ * Tail queue definitions.
+ */
+#define	_TAILQ_HEAD(name, type, qual)					\
+struct name {								\
+	qual type *tqh_first;		/* first element */		\
+	qual type *qual *tqh_last;	/* addr of last next element */	\
+}
+#define TAILQ_HEAD(name, type)	_TAILQ_HEAD(name, struct type,)
+
+#define	TAILQ_HEAD_INITIALIZER(head)					\
+	{ NULL, &(head).tqh_first }
+
+#define	_TAILQ_ENTRY(type, qual)					\
+struct {								\
+	qual type *tqe_next;		/* next element */		\
+	qual type *qual *tqe_prev;	/* address of previous next element */\
+}
+#define TAILQ_ENTRY(type)	_TAILQ_ENTRY(struct type,)
+
+/*
+ * Tail queue functions.
+ */
+#define	TAILQ_INIT(head) do {						\
+	(head)->tqh_first = NULL;					\
+	(head)->tqh_last = &(head)->tqh_first;				\
+} while (/*CONSTCOND*/0)
+
+#define	TAILQ_INSERT_HEAD(head, elm, field) do {			\
+	if (((elm)->field.tqe_next = (head)->tqh_first) != NULL)	\
+		(head)->tqh_first->field.tqe_prev =			\
+		    &(elm)->field.tqe_next;				\
+	else								\
+		(head)->tqh_last = &(elm)->field.tqe_next;		\
+	(head)->tqh_first = (elm);					\
+	(elm)->field.tqe_prev = &(head)->tqh_first;			\
+} while (/*CONSTCOND*/0)
+
+#define	TAILQ_INSERT_TAIL(head, elm, field) do {			\
+	(elm)->field.tqe_next = NULL;					\
+	(elm)->field.tqe_prev = (head)->tqh_last;			\
+	*(head)->tqh_last = (elm);					\
+	(head)->tqh_last = &(elm)->field.tqe_next;			\
+} while (/*CONSTCOND*/0)
+
+#define	TAILQ_INSERT_AFTER(head, listelm, elm, field) do {		\
+	if (((elm)->field.tqe_next = (listelm)->field.tqe_next) != NULL)\
+		(elm)->field.tqe_next->field.tqe_prev = 		\
+		    &(elm)->field.tqe_next;				\
+	else								\
+		(head)->tqh_last = &(elm)->field.tqe_next;		\
+	(listelm)->field.tqe_next = (elm);				\
+	(elm)->field.tqe_prev = &(listelm)->field.tqe_next;		\
+} while (/*CONSTCOND*/0)
+
+#define	TAILQ_INSERT_BEFORE(listelm, elm, field) do {			\
+	(elm)->field.tqe_prev = (listelm)->field.tqe_prev;		\
+	(elm)->field.tqe_next = (listelm);				\
+	*(listelm)->field.tqe_prev = (elm);				\
+	(listelm)->field.tqe_prev = &(elm)->field.tqe_next;		\
+} while (/*CONSTCOND*/0)
+
+#define	TAILQ_REMOVE(head, elm, field) do {				\
+	if (((elm)->field.tqe_next) != NULL)				\
+		(elm)->field.tqe_next->field.tqe_prev = 		\
+		    (elm)->field.tqe_prev;				\
+	else								\
+		(head)->tqh_last = (elm)->field.tqe_prev;		\
+	*(elm)->field.tqe_prev = (elm)->field.tqe_next;			\
+} while (/*CONSTCOND*/0)
+
+#define	TAILQ_FOREACH(var, head, field)					\
+	for ((var) = ((head)->tqh_first);				\
+		(var);							\
+		(var) = ((var)->field.tqe_next))
+
+#define	TAILQ_FOREACH_REVERSE(var, head, headname, field)		\
+	for ((var) = (*(((struct headname *)((head)->tqh_last))->tqh_last));	\
+		(var);							\
+		(var) = (*(((struct headname *)((var)->field.tqe_prev))->tqh_last)))
+
+#define	TAILQ_CONCAT(head1, head2, field) do {				\
+	if (!TAILQ_EMPTY(head2)) {					\
+		*(head1)->tqh_last = (head2)->tqh_first;		\
+		(head2)->tqh_first->field.tqe_prev = (head1)->tqh_last;	\
+		(head1)->tqh_last = (head2)->tqh_last;			\
+		TAILQ_INIT((head2));					\
+	}								\
+} while (/*CONSTCOND*/0)
+
+/*
+ * Tail queue access methods.
+ */
+#define	TAILQ_EMPTY(head)		((head)->tqh_first == NULL)
+#define	TAILQ_FIRST(head)		((head)->tqh_first)
+#define	TAILQ_NEXT(elm, field)		((elm)->field.tqe_next)
+
+#define	TAILQ_LAST(head, headname) \
+	(*(((struct headname *)((head)->tqh_last))->tqh_last))
+#define	TAILQ_PREV(elm, headname, field) \
+	(*(((struct headname *)((elm)->field.tqe_prev))->tqh_last))
+
+
+/*
+ * Circular queue definitions.
+ */
+#define	CIRCLEQ_HEAD(name, type)					\
+struct name {								\
+	struct type *cqh_first;		/* first element */		\
+	struct type *cqh_last;		/* last element */		\
+}
+
+#define	CIRCLEQ_HEAD_INITIALIZER(head)					\
+	{ (void *)&head, (void *)&head }
+
+#define	CIRCLEQ_ENTRY(type)						\
+struct {								\
+	struct type *cqe_next;		/* next element */		\
+	struct type *cqe_prev;		/* previous element */		\
+}
+
+/*
+ * Circular queue functions.
+ */
+#define	CIRCLEQ_INIT(head) do {						\
+	(head)->cqh_first = (void *)(head);				\
+	(head)->cqh_last = (void *)(head);				\
+} while (/*CONSTCOND*/0)
+
+#define	CIRCLEQ_INSERT_AFTER(head, listelm, elm, field) do {		\
+	(elm)->field.cqe_next = (listelm)->field.cqe_next;		\
+	(elm)->field.cqe_prev = (listelm);				\
+	if ((listelm)->field.cqe_next == (void *)(head))		\
+		(head)->cqh_last = (elm);				\
+	else								\
+		(listelm)->field.cqe_next->field.cqe_prev = (elm);	\
+	(listelm)->field.cqe_next = (elm);				\
+} while (/*CONSTCOND*/0)
+
+#define	CIRCLEQ_INSERT_BEFORE(head, listelm, elm, field) do {		\
+	(elm)->field.cqe_next = (listelm);				\
+	(elm)->field.cqe_prev = (listelm)->field.cqe_prev;		\
+	if ((listelm)->field.cqe_prev == (void *)(head))		\
+		(head)->cqh_first = (elm);				\
+	else								\
+		(listelm)->field.cqe_prev->field.cqe_next = (elm);	\
+	(listelm)->field.cqe_prev = (elm);				\
+} while (/*CONSTCOND*/0)
+
+#define	CIRCLEQ_INSERT_HEAD(head, elm, field) do {			\
+	(elm)->field.cqe_next = (head)->cqh_first;			\
+	(elm)->field.cqe_prev = (void *)(head);				\
+	if ((head)->cqh_last == (void *)(head))				\
+		(head)->cqh_last = (elm);				\
+	else								\
+		(head)->cqh_first->field.cqe_prev = (elm);		\
+	(head)->cqh_first = (elm);					\
+} while (/*CONSTCOND*/0)
+
+#define	CIRCLEQ_INSERT_TAIL(head, elm, field) do {			\
+	(elm)->field.cqe_next = (void *)(head);				\
+	(elm)->field.cqe_prev = (head)->cqh_last;			\
+	if ((head)->cqh_first == (void *)(head))			\
+		(head)->cqh_first = (elm);				\
+	else								\
+		(head)->cqh_last->field.cqe_next = (elm);		\
+	(head)->cqh_last = (elm);					\
+} while (/*CONSTCOND*/0)
+
+#define	CIRCLEQ_REMOVE(head, elm, field) do {				\
+	if ((elm)->field.cqe_next == (void *)(head))			\
+		(head)->cqh_last = (elm)->field.cqe_prev;		\
+	else								\
+		(elm)->field.cqe_next->field.cqe_prev =			\
+		    (elm)->field.cqe_prev;				\
+	if ((elm)->field.cqe_prev == (void *)(head))			\
+		(head)->cqh_first = (elm)->field.cqe_next;		\
+	else								\
+		(elm)->field.cqe_prev->field.cqe_next =			\
+		    (elm)->field.cqe_next;				\
+} while (/*CONSTCOND*/0)
+
+#define	CIRCLEQ_FOREACH(var, head, field)				\
+	for ((var) = ((head)->cqh_first);				\
+		(var) != (const void *)(head);				\
+		(var) = ((var)->field.cqe_next))
+
+#define	CIRCLEQ_FOREACH_REVERSE(var, head, field)			\
+	for ((var) = ((head)->cqh_last);				\
+		(var) != (const void *)(head);				\
+		(var) = ((var)->field.cqe_prev))
+
+/*
+ * Circular queue access methods.
+ */
+#define	CIRCLEQ_EMPTY(head)		((head)->cqh_first == (void *)(head))
+#define	CIRCLEQ_FIRST(head)		((head)->cqh_first)
+#define	CIRCLEQ_LAST(head)		((head)->cqh_last)
+#define	CIRCLEQ_NEXT(elm, field)	((elm)->field.cqe_next)
+#define	CIRCLEQ_PREV(elm, field)	((elm)->field.cqe_prev)
+
+#define CIRCLEQ_LOOP_NEXT(head, elm, field)				\
+	(((elm)->field.cqe_next == (void *)(head))			\
+	    ? ((head)->cqh_first)					\
+	    : (elm->field.cqe_next))
+#define CIRCLEQ_LOOP_PREV(head, elm, field)				\
+	(((elm)->field.cqe_prev == (void *)(head))			\
+	    ? ((head)->cqh_last)					\
+	    : (elm->field.cqe_prev))
+
+#endif	/* sys/queue.h */
diff --git a/srcpkgs/rocm-opencl-runtime/patches/cmake.patch b/srcpkgs/rocm-opencl-runtime/patches/cmake.patch
new file mode 100644
index 00000000000..2c96b99d45a
--- /dev/null
+++ b/srcpkgs/rocm-opencl-runtime/patches/cmake.patch
@@ -0,0 +1,126 @@
+--- OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/CMakeLists.txt	2019-09-10 11:53:28.000000000 -0400
++++ OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/CMakeLists.txt	2020-04-16 20:16:13.481180757 -0400
+@@ -73,11 +73,11 @@
+ 
+ set (OPENCL_ICD_LOADER_HEADERS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/inc CACHE PATH "Path to OpenCL Headers")
+ 
+-add_library (OpenCL ${OPENCL_ICD_LOADER_SOURCES})
+-set_target_properties (OpenCL PROPERTIES VERSION "1.2" SOVERSION "1")
++add_library (OpenCL-ROCm ${OPENCL_ICD_LOADER_SOURCES})
++set_target_properties (OpenCL-ROCm PROPERTIES VERSION "1.2" SOVERSION "1")
+ 
+ if (WIN32)
+-    target_link_libraries (OpenCL cfgmgr32.lib)
++    target_link_libraries (OpenCL-ROCm cfgmgr32.lib)
+ 
+     option (OPENCL_ICD_LOADER_REQUIRE_WDK "Build with D3DKMT support, which requires the Windows WDK." ON)
+     if (OPENCL_ICD_LOADER_REQUIRE_WDK)
+@@ -92,10 +92,10 @@
+             get_filename_component(WDK_DIRECTORY ${LATEST_D3DKMT_HEADER} DIRECTORY)
+             get_filename_component(WDK_DIRECTORY ${WDK_DIRECTORY} DIRECTORY)
+             message(STATUS "Found the Windows WDK in: ${WDK_DIRECTORY}")
+-            target_compile_definitions(OpenCL PRIVATE OPENCL_ICD_LOADER_REQUIRE_WDK)
+-            target_include_directories(OpenCL PRIVATE ${WDK_DIRECTORY}/um)
+-            target_include_directories(OpenCL PRIVATE ${WDK_DIRECTORY}/km)
+-            target_include_directories(OpenCL PRIVATE ${WDK_DIRECTORY}/shared)
++	    target_compile_definitions(OpenCL-ROCm PRIVATE OPENCL_ICD_LOADER_REQUIRE_WDK)
++	    target_include_directories(OpenCL-ROCm PRIVATE ${WDK_DIRECTORY}/um)
++	    target_include_directories(OpenCL-ROCm PRIVATE ${WDK_DIRECTORY}/km)
++	    target_include_directories(OpenCL-ROCm PRIVATE ${WDK_DIRECTORY}/shared)
+         else()
+             message(FATAL_ERROR "The Windows WDK was not found. Consider disabling OPENCL_ICD_LOADER_REQUIRE_WDK. Aborting.")
+         endif()
+@@ -113,25 +113,25 @@
+     endif()
+ else()
+     if (APPLE)
+-        target_link_libraries (OpenCL ${CMAKE_THREAD_LIBS_INIT})
++        target_link_libraries (OpenCL-ROCm ${CMAKE_THREAD_LIBS_INIT})
+     else ()
+-        set_target_properties (OpenCL PROPERTIES LINK_FLAGS "-Wl,--version-script -Wl,${CMAKE_CURRENT_SOURCE_DIR}/loader/linux/icd_exports.map")
+-        target_link_libraries (OpenCL ${CMAKE_THREAD_LIBS_INIT})
++        set_target_properties (OpenCL-ROCm PROPERTIES LINK_FLAGS "-Wl,--version-script -Wl,${CMAKE_CURRENT_SOURCE_DIR}/loader/linux/icd_exports.map")
++	target_link_libraries (OpenCL-ROCm ${CMAKE_THREAD_LIBS_INIT})
+     endif ()
+ endif ()
+ 
+ include_directories (${OPENCL_ICD_LOADER_HEADERS_DIR})
+ add_definitions (-DCL_TARGET_OPENCL_VERSION=220)
+ 
+-target_include_directories (OpenCL PRIVATE ${CMAKE_CURRENT_BINARY_DIR} loader)
+-target_link_libraries (OpenCL ${CMAKE_DL_LIBS})
++target_include_directories (OpenCL-ROCm PRIVATE ${CMAKE_CURRENT_BINARY_DIR} loader)
++target_link_libraries (OpenCL-ROCm ${CMAKE_DL_LIBS})
+ 
+ include (CTest)
+ if (BUILD_TESTING)
+     add_subdirectory (test)
+ endif()
+ 
+-install (TARGETS OpenCL
++install (TARGETS OpenCL-ROCm
+     RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+     ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
+     LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
+--- OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/test/loader_test/CMakeLists.txt	2019-09-10 11:53:28.000000000 -0400
++++ OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/test/loader_test/CMakeLists.txt	2020-04-16 20:16:56.647026589 -0400
+@@ -12,4 +12,4 @@
+     test_clgl.c
+     test_image_objects.c )
+ 
+-target_link_libraries (icd_loader_test OpenCL IcdLog)
++target_link_libraries (icd_loader_test OpenCL-ROCm IcdLog)
+--- ROCm-OpenCL-Runtime-roc-3.3.0/CMakeLists.txt	2020-04-28 07:29:51.864446603 -0400
++++ ROCm-OpenCL-Runtime-roc-3.3.0/CMakeLists.txt	2020-04-28 07:32:45.245793180 -0400
+@@ -101,30 +101,30 @@
+ rocm_setup_version( VERSION "2.0.0" )
+ 
+ # MAIN package
+-install(PROGRAMS $<TARGET_FILE:clinfo>
+-        DESTINATION bin/x86_64
++install(PROGRAMS $<TARGET_FILE:rocm-clinfo>
++        DESTINATION bin
+         COMPONENT MAIN)
+ install(PROGRAMS $<TARGET_FILE:amdocl64>
+-        DESTINATION lib/x86_64
++        DESTINATION lib
+         COMPONENT MAIN)
+-install(PROGRAMS $<TARGET_FILE:OpenCL>
+-        DESTINATION lib/x86_64
++install(PROGRAMS $<TARGET_FILE:OpenCL-ROCm>
++        DESTINATION lib
+         COMPONENT MAIN)
+-install(PROGRAMS $<TARGET_SONAME_FILE:OpenCL>
+-        DESTINATION lib/x86_64
++install(PROGRAMS $<TARGET_SONAME_FILE:OpenCL-ROCm>
++        DESTINATION lib
+         COMPONENT MAIN)
+ 
+ # DEV package
+ install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/api/opencl/khronos/headers/opencl2.2/CL"
+-        DESTINATION include
++	DESTINATION include/rocm
+         COMPONENT DEV
+         USE_SOURCE_PERMISSIONS
+         PATTERN cl_d3d10.h EXCLUDE
+         PATTERN cl_d3d11.h EXCLUDE
+         PATTERN cl_dx9_media_sharing.h EXCLUDE
+         PATTERN cl_egl.h EXCLUDE)
+-install(PROGRAMS $<TARGET_LINKER_FILE:OpenCL>
+-        DESTINATION lib/x86_64
++install(PROGRAMS $<TARGET_LINKER_FILE:OpenCL-ROCm>
++        DESTINATION lib
+         COMPONENT DEV)
+ 
+ # Generic CPACK variables
+--- ROCm-OpenCL-Runtime-roc-3.3.0/tools/clinfo/CMakeLists.txt	2020-04-28 07:29:51.882446535 -0400
++++ ROCm-OpenCL-Runtime-roc-3.3.0/tools/clinfo/CMakeLists.txt	2020-04-28 07:30:05.627394732 -0400
+@@ -6,6 +6,6 @@
+ 
+ add_definitions(-DHAVE_CL2_HPP)
+ 
+-add_executable(clinfo clinfo.cpp)
++add_executable(rocm-clinfo clinfo.cpp)
+ 
+-target_link_libraries(clinfo OpenCL)
++target_link_libraries(rocm-clinfo OpenCL-ROCm)
diff --git a/srcpkgs/rocm-opencl-runtime/template b/srcpkgs/rocm-opencl-runtime/template
new file mode 100644
index 00000000000..f83c6e64149
--- /dev/null
+++ b/srcpkgs/rocm-opencl-runtime/template
@@ -0,0 +1,82 @@
+# Template file for 'rocm-opencl-runtime'
+pkgname=rocm-opencl-runtime
+version=3.3.0
+revision=1
+_ocl_icd_name="OpenCL-ICD-Loader"
+_ocl_icd_ver="6c03f8b58fafd9dd693eaac826749a5cfad515f8"
+archs="x86_64*"
+create_wrksrc=yes
+build_wrksrc="ROCm-OpenCL-Runtime-roc-${version}"
+build_style=cmake
+configure_args="-DUSE_COMGR_LIBRARY=yes"
+hostmakedepends="cmake pkg-config"
+makedepends="libglvnd-devel rocm-comgr-devel
+	roct-thunk-interface-devel rocr-runtime-devel"
+depends="rocm-comgr"
+short_desc="Radeon Open Compute OpenCL runtime"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="MIT"
+homepage="https://github.com/RadeonOpenCompute/ROCm-OpenCL-Runtime"
+_rocroot="https://github.com/RadeonOpenCompute"
+distfiles="${_rocroot}/ROCm-OpenCL-Runtime/archive/roc-${version}.tar.gz
+	${_rocroot}/rocm-cmake/archive/rocm-${version}.tar.gz
+	https://github.com/KhronosGroup/${_ocl_icd_name}/archive/${_ocl_icd_ver}.tar.gz"
+checksum="ac6999f1a491ab066286c2bd6adf50f08f831286f56e267879f9f7eced22f98e
+	76ed3ee8e56cf3246011cf7723c2abda539e1136e7e7f6909bfa45d268b8644f
+	c94d5bb6dc980c4d41d73e2b81663a19aabe494e923e2d0eec72a4c95b318438"
+nocross=yes
+
+post_patch() {
+	if [ "$XBPS_LIBC" = "musl" ]; then
+		# Copy sys/queue.h locally for MUSL builds
+		libelf_dir="compiler/lib/loaders/elf/utils/libelf"
+		cp "${FILESDIR}/sys_queue.h" "${libelf_dir}"
+
+		# Remove dependence on glibc
+		patch -Np0 < ${FILESDIR}/libelf-musl.patch
+		patch -Np0 < ${FILESDIR}/runtime-musl.patch
+		vsed -e '/glibc_functions.cpp/d' -i api/opencl/amdocl/CMakeLists.txt
+	fi
+}
+
+pre_configure() {
+	# ROCm requires a very specific Khronos ICD loader version in the tree
+	# Keep the ICD loader config in /etc/rocm/vendors to avoid conflicts
+	_ocl_icd_dir="${_ocl_icd_name}-${_ocl_icd_ver}"
+	ln -sf "${wrksrc}/${_ocl_icd_dir}" api/opencl/khronos/icd
+	vsed -i "${wrksrc}/${_ocl_icd_dir}/loader/icd_platform.h" \
+		-e 's@/etc/OpenCL/vendors/@/etc/rocm/vendors/@g'
+
+	# CMake modules probably not useful anywhere but for this build
+	ln -sf "${wrksrc}/rocm-cmake-rocm-${version}/share/rocm/cmake"/*.cmake cmake
+
+	# Fix the dlopen macro to point to versioned libamd_comgr shared object
+	vsed -i 'runtime/device/comgrctx.cpp' \
+		-e 's/\blibamd_comgr\(32\)\?.so\b/&.1/g'
+}
+
+post_install() {
+	vlicense License
+
+	# Create descriptor to allow the ICD loader to find the driver
+	_ocl_icd_dir="etc/rocm/vendors"
+	vmkdir "${_ocl_icd_dir}"
+	echo "libamdocl64.so" > "${DESTDIR}/${_ocl_icd_dir}/amdocl64.icd"
+}
+
+rocm-opencl-runtime-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/lib/libOpenCL-ROCm.so
+		vmove usr/include
+	}
+}
+
+rocm-opencl-runtime-clinfo_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - clinfo"
+	pkg_install() {
+		vmove usr/bin/rocm-clinfo
+	}
+}

From 5983d9cbd8e21f34c03769213a66dddad309e936 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Tue, 28 Apr 2020 13:33:46 -0400
Subject: [PATCH 9/9] hashcat: add build option to support new rocm packages
 [ci skip]

---
 srcpkgs/hashcat/files/rocm.patch | 35 ++++++++++++++++++++++++++++++++
 srcpkgs/hashcat/template         | 17 +++++++++++++---
 2 files changed, 49 insertions(+), 3 deletions(-)
 create mode 100644 srcpkgs/hashcat/files/rocm.patch

diff --git a/srcpkgs/hashcat/files/rocm.patch b/srcpkgs/hashcat/files/rocm.patch
new file mode 100644
index 00000000000..5f7e4e69197
--- /dev/null
+++ b/srcpkgs/hashcat/files/rocm.patch
@@ -0,0 +1,35 @@
+diff -ur a/src/folder.c b/src/folder.c
+--- a/src/folder.c	2018-12-02 05:58:48.000000000 -0500
++++ b/src/folder.c	2020-04-28 13:22:27.340522751 -0400
+@@ -457,16 +457,6 @@
+ 
+   hcfree (cpath);
+ 
+-  //if (getenv ("TMP") == NULL)
+-  if (1)
+-  {
+-    char *tmp;
+-
+-    hc_asprintf (&tmp, "TMP=%s", cpath_real);
+-
+-    putenv (tmp);
+-  }
+-
+   #if defined (_WIN)
+ 
+   naive_replace (cpath_real, '\\', '/');
+diff -ur a/src/opencl.c b/src/opencl.c
+--- a/src/opencl.c	2018-12-02 05:58:48.000000000 -0500
++++ b/src/opencl.c	2020-04-28 13:24:12.602415333 -0400
+@@ -492,9 +492,9 @@
+ 
+   if (ocl->lib == NULL) ocl->lib = hc_dlopen ("cygOpenCL-1.dll", RTLD_NOW);
+   #else
+-  ocl->lib = hc_dlopen ("libOpenCL.so", RTLD_NOW);
++  ocl->lib = hc_dlopen ("libOpenCL-ROCm.so.1", RTLD_NOW);
+ 
+-  if (ocl->lib == NULL) ocl->lib = hc_dlopen ("libOpenCL.so.1", RTLD_NOW);
++  if (ocl->lib == NULL) ocl->lib = hc_dlopen ("libOpenCL-ROCm.so", RTLD_NOW);
+   #endif
+ 
+   if (ocl->lib == NULL)
diff --git a/srcpkgs/hashcat/template b/srcpkgs/hashcat/template
index e982f99cebf..7d3a8cb5a6b 100644
--- a/srcpkgs/hashcat/template
+++ b/srcpkgs/hashcat/template
@@ -1,15 +1,16 @@
 # Template file for 'hashcat'
 pkgname=hashcat
 version=5.1.0
-revision=2
+revision=3
 build_style=gnu-makefile
 make_build_args="PREFIX=/usr
  USE_SYSTEM_OPENCL=1 USE_SYSTEM_XXHASH=1
- DEPS_OPENCL_PATH=${XBPS_CROSS_BASE}/usr/include
+ DEPS_OPENCL_PATH=${XBPS_CROSS_BASE}/usr/include$(vopt_if rocm /rocm)
  DEPS_XXHASH_PATH=${XBPS_CROSS_BASE}/usr/include"
 make_use_env=yes
 make_install_args="$make_build_args"
-makedepends="gmp-devel opencl2-headers xxHash-devel"
+makedepends="gmp-devel xxHash-devel
+ $(vopt_if rocm rocm-opencl-runtime-devel opencl2-headers)"
 checkdepends="perl"
 short_desc="Advanced CPU-based password recovery utility"
 maintainer="Duncaen <duncaen@voidlinux.org>"
@@ -19,6 +20,9 @@ changelog="https://raw.githubusercontent.com/hashcat/hashcat/master/docs/changes
 distfiles="https://hashcat.net/files/hashcat-${version}.tar.gz"
 checksum=283beaa68e1eab41de080a58bb92349c8e47a2bb1b93d10f36ea30f418f1e338
 
+build_options="rocm"
+desc_option_rocm="Use ROCm OpenCL runtime"
+
 if [ "$XBPS_TARGET_ENDIAN" = "be" ]; then
 	broken="Not supported on big endian"
 fi
@@ -26,6 +30,13 @@ fi
 post_extract() {
 	sed '/^CC/d' -i src/Makefile
 }
+
+post_patch() {
+	if [ "$build_option_rocm" ]; then
+		patch -Np1 < ${FILESDIR}/rocm.patch
+	fi
+}
+
 post_install() {
 	rm -f ${DESTDIR}/usr/share/docs/hashcat/license.txt
 	vlicense docs/license.txt

^ permalink raw reply	[flat|nested] 61+ messages in thread

* Re: New packages: ROCm core and OpenCL
  2020-04-19 13:34 [PR PATCH] New packages: ROCm core and OpenCL ahesford
                   ` (8 preceding siblings ...)
  2020-04-28 17:38 ` ahesford
@ 2020-04-28 18:09 ` ahesford
  2020-04-28 18:44 ` [PR PATCH] [Updated] " ahesford
                   ` (49 subsequent siblings)
  59 siblings, 0 replies; 61+ messages in thread
From: ahesford @ 2020-04-28 18:09 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1778 bytes --]

New comment by ahesford on void-packages repository

https://github.com/void-linux/void-packages/pull/21153#issuecomment-620769230

Comment:
Some updates:
* All packages install into the normal `/usr` hierarchy now.
* The `rocm-llvm` package (which is really only used to build `rocm-comgr` and isn't intended for end-users) only targets `AMDGPU` and installs under `/usr/lib/rocm-llvm`.
* All files which might conflict with other packages (`usr/bin/clinfo`, `usr/lib/libOpenCL.so*` and `usr/include/CL/*`) have custom names: `clinfo` is `rocm-clinfo`, `libOpenCL.so*` is `libOpenCL-ROCm.so*` and `usr/include/CL` becomes `usr/include/rocm/CL`.

I believe this is ready for roll-out, although individual OpenCL-aware programs will need special handling to support ROCm. The incompatibilities between `libOpenCL` in `ocl-icd` and `libOpenCL` in `rocm-opencl-runtime` make this unavoidable.

The library rename in `rocm-opencl-runtime` is more than just a linking issue. While some programs explicitly link against `libOpenCL` and could be altered to link against `libOpenCL-ROCm`, many OpenCL programs load the OpenCL ICD with `dlopen`. Those packages will need source patches to move `libOpenCL.so*` references in the code to `libOpenCL-ROCm.so*`. Packages will also need to use the header files in `usr/include/rocm/CL`, which is probably as simple as not depending on `opencl2-headers` and adding `usr/include/rocm` to the compiler include paths.

In most cases, I think OpenCL-aware packages can be custom-built to support ROCm with a build option that toggles a few simple things. This PR includes a modified `hashcat` template to do just that. Of course, because ROCm will not be universally useful to Void, the `rocm` build option should be disabled by default.

^ permalink raw reply	[flat|nested] 61+ messages in thread

* Re: [PR PATCH] [Updated] New packages: ROCm core and OpenCL
  2020-04-19 13:34 [PR PATCH] New packages: ROCm core and OpenCL ahesford
                   ` (9 preceding siblings ...)
  2020-04-28 18:09 ` ahesford
@ 2020-04-28 18:44 ` ahesford
  2020-04-28 19:59 ` ahesford
                   ` (48 subsequent siblings)
  59 siblings, 0 replies; 61+ messages in thread
From: ahesford @ 2020-04-28 18:44 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 3893 bytes --]

There is an updated pull request by ahesford against master on the void-packages repository

https://github.com/ahesford/void-packages rocm
https://github.com/void-linux/void-packages/pull/21153

New packages: ROCm core and OpenCL
This PR includes several packages designed to bring the OpenCL portion of the AMD ROCm ecosystem to Void. It addresses Issue #19507. There are many other packages that AMD provides for GPGPU computing, but these can be added piecemeal as users demand.

The packages are currently only for `x86_64*`. While at least some of the packages will compile on other 64-bit architectures, I have no hardware to test. They are certainly not suitable for 32-bit architectures; some internal data structures rely on `uint64_t` values that are cast to pointers. At a
minimum, a thorough audit would be necessary to ensure that these casts are safe (e.g., that the values stored were only ever upcast from 32-bit pointers). More extensive work may be necessary to support 32-bit architectures, probably without significant benefit.

The packages successfully identify a Radeon RX 580 on an `x86_64` installation using both `clinfo` and `rocminfo` as provided. Furthermore, a version of `pyopencl` linked against these ROCm packages successfully runs a simple program that validates arithmetic on GPU-bound arrays.

There are caveats with this set of packages, almost all of which revolve around the incompatibilities between the Void-provided `ocl-icd` and the [Khronos OpenCL ICD loader](https://github.com/KhronosGroup/OpenCL-ID-Loader) required by (and built into) `rocm-opencl-runtime`.
1. All packages install into `/opt/rocm`. This keeps the environment closer to that officially sanctioned by AMD and helps avoid conflicts between other packages and those provided here. (For example, `clinfo` and the ICD loader itself.) Eventually, we may be able to move the files into `/usr`.
2. The Khronos OpenCL ICD loader built into `rocm-opencl-runtime` is an outdated, pre-release commit. If AMD can update its sources to use the release version of that loader (which has a backward-incompatible API change), we may be able to make ROCm compatible with `ocl-icd` or replace `ocl-icd` with the official Khronos loader.
3. In the meantime, to avoid `shlibs` conflicts, the OpenCL ICD loader is installed as `/opt/rocm/lib/libOpenCL-ROCm.so` (and an appropriately versioned shared library), which means that programs wishing to use the ROCm OpenCL must explicitly link against this library instead of the generic `libOpenCL.so`.
4. I do **not** recommend making any Void packages link against this specific library, because it will make those packages ROCm-only. For the time being, ROCm is intended for end-users to specifically link against. Linking Void packages against ROCm would requires the ICD loader used by ROCm be compatible with `ocl-icd`, or `ocl-icd` be replaced by the Khronos loader. However, because the Khronos loader changed its API for the release version, such a change is not yet appropriate.

Hopefully, if AMD updates its dependence on the Khronos ICD loader, we can resolve some of these caveats in the future and make ROCm a more natural Void component. For now, these packages are useful for those who need an AMD OpenCL solution and would rather custom-link software against the AMD ICD loader than hack the `amdgpu-pro` driver into an ICD compatible with `ocl-icd`.

Some patches were made to relocate some files in `/opt/rocm` and make everyting build on x86_64-musl`. Where appropriate, these patches will be pushed upstream to clean up the distribution and packaging.

Update: I pushed some new commits to update license information that triggerd an `xlint` failure. I've also disabled CI builds because they will time out on `rocm-llvm`.

A patch file from https://github.com/void-linux/void-packages/pull/21153.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-rocm-21153.patch --]
[-- Type: text/x-diff, Size: 77002 bytes --]

From 1226ae1e7c5eea64be3859bb36eee4fd8c6cccc6 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Mon, 13 Apr 2020 13:08:09 -0400
Subject: [PATCH 1/9] New package: roct-thunk-interface-3.3.0

---
 common/shlibs                                 |  1 +
 srcpkgs/roct-thunk-interface-devel            |  1 +
 .../patches/cmake-dev-libdir.patch            | 10 ++++++
 .../roct-thunk-interface/patches/musl.patch   | 29 ++++++++++++++++
 srcpkgs/roct-thunk-interface/template         | 33 +++++++++++++++++++
 5 files changed, 74 insertions(+)
 create mode 120000 srcpkgs/roct-thunk-interface-devel
 create mode 100644 srcpkgs/roct-thunk-interface/patches/cmake-dev-libdir.patch
 create mode 100644 srcpkgs/roct-thunk-interface/patches/musl.patch
 create mode 100644 srcpkgs/roct-thunk-interface/template

diff --git a/common/shlibs b/common/shlibs
index 6d39ce34c19..d89ae72ae3e 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3862,3 +3862,4 @@ libtagparser.so.9 tagparser-9.1.2_1
 libqtutilities.so.6 qtutilities-6.0.4_1
 libkdsoap.so.1.9.0 KDSoap-1.9.0_1
 libstoken.so.1 stoken-0.92_1
+libhsakmt.so.1 roct-thunk-interface-3.3.0_1
diff --git a/srcpkgs/roct-thunk-interface-devel b/srcpkgs/roct-thunk-interface-devel
new file mode 120000
index 00000000000..ac3f2cc684c
--- /dev/null
+++ b/srcpkgs/roct-thunk-interface-devel
@@ -0,0 +1 @@
+roct-thunk-interface
\ No newline at end of file
diff --git a/srcpkgs/roct-thunk-interface/patches/cmake-dev-libdir.patch b/srcpkgs/roct-thunk-interface/patches/cmake-dev-libdir.patch
new file mode 100644
index 00000000000..98c7f1e459c
--- /dev/null
+++ b/srcpkgs/roct-thunk-interface/patches/cmake-dev-libdir.patch
@@ -0,0 +1,10 @@
+--- CMakeLists.txt.old	2020-04-18 19:45:17.306081135 -0400
++++ CMakeLists.txt	2020-04-18 19:46:51.300753636 -0400
+@@ -146,6 +146,7 @@
+     COMMAND ${CMAKE_COMMAND}
+         -DSOURCE_DIR="${SOURCE_DIR}"
+         -DCMAKE_INSTALL_PREFIX="${CMAKE_INSTALL_PREFIX}"
++        -DCMAKE_INSTALL_LIBDIR="${CMAKE_INSTALL_LIBDIR}"
+         -DCPACK_RPM_PACKAGE_REQUIRES="hsakmt-roct"
+         -DCPACK_PACKAGING_INSTALL_PREFIX="${CPACK_PACKAGING_INSTALL_PREFIX}"
+         -DVERSION="${BUILD_VERSION_STRING}"
diff --git a/srcpkgs/roct-thunk-interface/patches/musl.patch b/srcpkgs/roct-thunk-interface/patches/musl.patch
new file mode 100644
index 00000000000..aeea9832411
--- /dev/null
+++ b/srcpkgs/roct-thunk-interface/patches/musl.patch
@@ -0,0 +1,29 @@
+diff -r -u old/src/libhsakmt.h new/src/libhsakmt.h
+--- src/libhsakmt.h	2020-03-04 15:00:47.000000000 -0500
++++ src/libhsakmt.h	2020-04-13 12:58:30.444865992 -0400
+@@ -54,6 +54,10 @@
+ #define CHECK_KFD_OPEN() \
+ 	do { if (kfd_open_count == 0 || hsakmt_forked) return HSAKMT_STATUS_KERNEL_IO_CHANNEL_NOT_OPENED; } while (0)
+ 
++/*On some platforms, a PAGE_SIZE macro eclipses the extern variable*/
++#ifdef PAGE_SIZE
++#undef PAGE_SIZE
++#endif
+ extern int PAGE_SIZE;
+ extern int PAGE_SHIFT;
+ 
+diff -r -u old/src/topology.c new/src/topology.c
+--- src/topology.c	2020-03-04 15:00:47.000000000 -0500
++++ src/topology.c	2020-04-13 13:01:31.209870701 -0400
+@@ -38,6 +38,11 @@
+ #include "libhsakmt.h"
+ #include "fmm.h"
+ 
++/*Needed on MUSL*/
++#ifndef MAXNAMLEN
++#define MAXNAMLEN PATH_MAX
++#endif
++
+ /* Number of memory banks added by thunk on top of topology
+  * This only includes static heaps like LDS, scratch and SVM,
+  * not for MMIO_REMAP heap. MMIO_REMAP memory bank is reported
diff --git a/srcpkgs/roct-thunk-interface/template b/srcpkgs/roct-thunk-interface/template
new file mode 100644
index 00000000000..55a1fc6074a
--- /dev/null
+++ b/srcpkgs/roct-thunk-interface/template
@@ -0,0 +1,33 @@
+# Template file for 'roct-thunk-interface'
+pkgname=roct-thunk-interface
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="ROCT-Thunk-Interface-roc-${version}"
+build_style=cmake
+make_build_target="all build-dev"
+make_install_target="install install-dev"
+hostmakedepends="cmake pkg-config"
+makedepends="pciutils-devel libnuma-devel"
+short_desc="Radeon Open Compute Thunk Interface"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="MIT"
+homepage="https://github.com/RadeonOpenCompute/ROCT-Thunk-Interface"
+distfiles="${homepage}/archive/roc-${version}.tar.gz"
+checksum=2cabe9d2cfa72031c05d11290837c476182e72d8dec2049298f691143fdd212b
+nocross=yes
+
+post_install() {
+	vlicense LICENSE.md
+}
+
+roct-thunk-interface-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove "usr/lib/*.so"
+		vmove usr/share/pkgconfig
+		vmove usr/lib/cmake
+	}
+}

From d8bb69aca8ebcd167198d858c11e7b7fa326c389 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Mon, 13 Apr 2020 15:27:27 -0400
Subject: [PATCH 2/9] New package: rocr-runtime-3.3.0

---
 common/shlibs                            |  1 +
 srcpkgs/rocr-runtime-devel               |  1 +
 srcpkgs/rocr-runtime/patches/cmake.patch | 27 +++++++++++++++++++++
 srcpkgs/rocr-runtime/template            | 30 ++++++++++++++++++++++++
 4 files changed, 59 insertions(+)
 create mode 120000 srcpkgs/rocr-runtime-devel
 create mode 100644 srcpkgs/rocr-runtime/patches/cmake.patch
 create mode 100644 srcpkgs/rocr-runtime/template

diff --git a/common/shlibs b/common/shlibs
index d89ae72ae3e..499f35752c2 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3863,3 +3863,4 @@ libqtutilities.so.6 qtutilities-6.0.4_1
 libkdsoap.so.1.9.0 KDSoap-1.9.0_1
 libstoken.so.1 stoken-0.92_1
 libhsakmt.so.1 roct-thunk-interface-3.3.0_1
+libhsa-runtime64.so.1 rocr-runtime-3.3.0_1
diff --git a/srcpkgs/rocr-runtime-devel b/srcpkgs/rocr-runtime-devel
new file mode 120000
index 00000000000..be838f22d81
--- /dev/null
+++ b/srcpkgs/rocr-runtime-devel
@@ -0,0 +1 @@
+rocr-runtime
\ No newline at end of file
diff --git a/srcpkgs/rocr-runtime/patches/cmake.patch b/srcpkgs/rocr-runtime/patches/cmake.patch
new file mode 100644
index 00000000000..93b74cd2297
--- /dev/null
+++ b/srcpkgs/rocr-runtime/patches/cmake.patch
@@ -0,0 +1,27 @@
+--- src/CMakeLists.txt.old	2020-04-18 20:01:48.549636995 -0400
++++ src/CMakeLists.txt	2020-04-18 20:04:00.177179781 -0400
+@@ -108,8 +108,8 @@
+ ## ROCr build internal versioning
+ add_definitions ( -DROCR_BUILD_ID=${PACKAGE_VERSION_STRING} )
+ 
+-## Set RUNPATH - ../../lib covers use of the legacy symlink in /hsa/lib/
+-set(CMAKE_INSTALL_RPATH "$ORIGIN;$ORIGIN/../../lib;$ORIGIN/../../lib64;$ORIGIN/../lib64")
++## Set RUNPATH
++set(CMAKE_INSTALL_RPATH "$ORIGIN;$ORIGIN/../lib")
+ 
+ ## ------------------------- Linux Compiler and Linker options -------------------------
+ set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -fexceptions -fno-rtti -fvisibility=hidden -Wno-error=sign-compare -Wno-sign-compare -Wno-write-strings -Wno-conversion-null -fno-math-errno -fno-threadsafe-statics -fmerge-all-constants -fms-extensions -Wno-error=comment -Wno-comment -Wno-error=pointer-arith -Wno-pointer-arith -Wno-error=unused-variable -Wno-error=unused-function" )
+@@ -185,11 +185,8 @@
+ add_custom_target ( hsa_lib_link2 ALL WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMAND ${CMAKE_COMMAND} -E create_symlink ../hsa/lib/${CORE_RUNTIME_LIBRARY}.so.${SO_MAJOR} ${CORE_RUNTIME_LIBRARY}-link.so.${SO_MAJOR} )
+ 
+ ## Set install information
+-install ( TARGETS ${CORE_RUNTIME_TARGET} LIBRARY DESTINATION hsa/lib )
+-install ( DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/inc/ DESTINATION hsa/include/hsa )
+-install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/hsa_include_link DESTINATION include PERMISSIONS OWNER_WRITE OWNER_READ RENAME hsa )
+-install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/${CORE_RUNTIME_LIBRARY}-link.so DESTINATION lib PERMISSIONS OWNER_WRITE OWNER_READ RENAME ${CORE_RUNTIME_LIBRARY}.so )
+-install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/${CORE_RUNTIME_LIBRARY}-link.so.${SO_MAJOR} DESTINATION lib PERMISSIONS OWNER_WRITE OWNER_READ RENAME ${CORE_RUNTIME_LIBRARY}.so.${SO_MAJOR} )
++install ( TARGETS ${CORE_RUNTIME_TARGET} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} )
++install ( DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/inc/ DESTINATION include/hsa )
+ 
+ ## Packaging directives
+ set ( CPACK_GENERATOR "DEB;RPM" CACHE STRING "Package types to build")
diff --git a/srcpkgs/rocr-runtime/template b/srcpkgs/rocr-runtime/template
new file mode 100644
index 00000000000..5ee22140f1f
--- /dev/null
+++ b/srcpkgs/rocr-runtime/template
@@ -0,0 +1,30 @@
+# Template file for 'rocr-runtime'
+pkgname=rocr-runtime
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="ROCR-Runtime-rocm-${version}"
+build_wrksrc="src"
+build_style=cmake
+hostmakedepends="cmake pkg-config"
+makedepends="roct-thunk-interface-devel elfutils-devel"
+short_desc="Radeon Open Compute HSA Runtime"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute/ROCR-Runtime"
+distfiles="${homepage}/archive/rocm-${version}.tar.gz"
+checksum=fa2d2d1f8a61d8a6952d377cf288d78c61776c3c2a666f163cafc3aa19ab0b61
+nocross=yes
+
+post_install() {
+	vlicense ../LICENSE.txt
+}
+
+rocr-runtime-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove "usr/lib/*.so"
+	}
+}

From 5991aaa587df9bdce5c93daf534974432a336acf Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Mon, 13 Apr 2020 18:07:34 -0400
Subject: [PATCH 3/9] New package: rocm-llvm-3.3.0

---
 srcpkgs/rocm-llvm/template | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)
 create mode 100644 srcpkgs/rocm-llvm/template

diff --git a/srcpkgs/rocm-llvm/template b/srcpkgs/rocm-llvm/template
new file mode 100644
index 00000000000..d6e75cd050c
--- /dev/null
+++ b/srcpkgs/rocm-llvm/template
@@ -0,0 +1,26 @@
+# Template file for 'rocm-llvm'
+pkgname=rocm-llvm
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="llvm-project-rocm-ocl-${version}"
+build_wrksrc=llvm
+build_style=cmake
+configure_args="-DCMAKE_INSTALL_PREFIX:PATH=/usr/lib/rocm-llvm
+	-DLLVM_ENABLE_PROJECTS='llvm;clang;lld' -DLLVM_TARGETS_TO_BUILD='AMDGPU'
+	-DLLVM_BUILD_DOCS=NO -DLLVM_ENABLE_OCAMLDOC=OFF
+	-DLLVM_ENABLE_SPHINX=NO -DLLVM_ENABLE_DOXYGEN=OFF
+	-DLLVM_INSTALL_UTILS=ON -DLLVM_VERSION_SUFFIX=roc -DOCAMLFIND=NO"
+hostmakedepends="cmake pkg-config python3"
+short_desc="Radeon Open Compute LLVM toolchain"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="Apache-2.0, NCSA, custom:LLVM-Exceptions"
+homepage="https://github.com/RadeonOpenCompute/llvm-project"
+distfiles="${homepage}/archive/rocm-ocl-${version}.tar.gz"
+checksum=a2bef7042e8e2f2cd8548cb246b88322e1c77188839983dcac8312d56f544dc8
+python_version=3
+nocross=yes
+
+post_install() {
+	vlicense LICENSE.TXT
+}

From 19c7a333ec5877c0e1e57ab9d1438bc0b31520a3 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Tue, 14 Apr 2020 10:25:31 -0400
Subject: [PATCH 4/9] New package: rocm-device-libs-3.3.0

---
 srcpkgs/rocm-device-libs/template | 37 +++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)
 create mode 100644 srcpkgs/rocm-device-libs/template

diff --git a/srcpkgs/rocm-device-libs/template b/srcpkgs/rocm-device-libs/template
new file mode 100644
index 00000000000..fcb4eb0d53e
--- /dev/null
+++ b/srcpkgs/rocm-device-libs/template
@@ -0,0 +1,37 @@
+# Template file for 'rocm-device-libs'
+pkgname=rocm-device-libs
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="ROCm-Device-Libs-rocm-ocl-${version}"
+build_style=cmake
+configure_args="-DLLVM_DIR:PATH=/usr/lib/rocm-llvm
+	-DCMAKE_INSTALL_LIBDIR:PATH=lib/rocm-device-libs"
+hostmakedepends="cmake rocm-llvm"
+short_desc="Radeon Open Compute device libraries"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute/ROCm-Device-Libs"
+distfiles="${homepage}/archive/rocm-ocl-${version}.tar.gz"
+checksum=706b08230790e08ca6a7a2fb7687d6131fd39a562148340e00fa37a6c06769c5
+nocross=yes
+
+pre_configure() {
+	# Put bytecodes in a lib/ subdirectory
+	vsed -i Packages.cmake -e 's@/lib/@/${CMAKE_INSTALL_LIBDIR}/@'
+	vsed -i OCL.cmake -e 's@DESTINATION lib$@DESTINATION ${CMAKE_INSTALL_LIBDIR}@'
+
+	# Build the prepare-builtins executable with native compiler
+	mkdir -p utils/build
+	cd utils/build
+	_prepare_builtins="$PWD/prepare-builtins/prepare-builtins"
+	cmake ${configure_args} ..
+	make ${makejobs}
+
+	# Add path to prepare-builtins for cmake
+	configure_args+=" -DPREPARE_BUILTINS='${_prepare_builtins}'"
+}
+
+post_install() {
+	vlicense LICENSE
+}

From 691d78f81e8346791c5556569cfa00b5b5d133ac Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Mon, 13 Apr 2020 18:30:00 -0400
Subject: [PATCH 5/9] New package: rocm-comgr-3.3.0

---
 common/shlibs               |  1 +
 srcpkgs/rocm-comgr-devel    |  1 +
 srcpkgs/rocm-comgr/template | 32 ++++++++++++++++++++++++++++++++
 3 files changed, 34 insertions(+)
 create mode 120000 srcpkgs/rocm-comgr-devel
 create mode 100644 srcpkgs/rocm-comgr/template

diff --git a/common/shlibs b/common/shlibs
index 499f35752c2..a53de3cf9e0 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3864,3 +3864,4 @@ libkdsoap.so.1.9.0 KDSoap-1.9.0_1
 libstoken.so.1 stoken-0.92_1
 libhsakmt.so.1 roct-thunk-interface-3.3.0_1
 libhsa-runtime64.so.1 rocr-runtime-3.3.0_1
+libamd_comgr.so.1 rocm-comgr-3.3.0_1
diff --git a/srcpkgs/rocm-comgr-devel b/srcpkgs/rocm-comgr-devel
new file mode 120000
index 00000000000..3f5ce255e07
--- /dev/null
+++ b/srcpkgs/rocm-comgr-devel
@@ -0,0 +1 @@
+rocm-comgr
\ No newline at end of file
diff --git a/srcpkgs/rocm-comgr/template b/srcpkgs/rocm-comgr/template
new file mode 100644
index 00000000000..c228bcd4d1f
--- /dev/null
+++ b/srcpkgs/rocm-comgr/template
@@ -0,0 +1,32 @@
+# Template file for 'rocm-comgr'
+pkgname=rocm-comgr
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="ROCm-CompilerSupport-rocm-${version}"
+build_wrksrc="lib/comgr"
+build_style=cmake
+configure_args="-DClang_DIR:PATH=/usr/lib/rocm-llvm/lib/cmake/clang"
+hostmakedepends="cmake pkg-config rocm-llvm"
+makedepends="rocm-device-libs"
+short_desc="Radeon Open Compute Code Object Manager"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="BSD-3-Clause"
+homepage="https://github.com/RadeonOpenCompute/ROCm-CompilerSupport"
+distfiles="${homepage}/archive/rocm-${version}.tar.gz"
+checksum=01e2524e0f28ecd6f46c9720f279207de935d826b0172158792aa3ec86af9ca7
+nocross=yes
+
+post_install() {
+	vlicense LICENSE.txt
+}
+
+rocm-comgr-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove "usr/lib/*.so"
+		vmove usr/lib/cmake
+	}
+}

From 34506fec471194f2746c0fca2b1a8f8de3c02f1c Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Fri, 17 Apr 2020 12:11:25 -0400
Subject: [PATCH 6/9] New package: rocminfo-3.3.0

---
 srcpkgs/rocminfo/template | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
 create mode 100644 srcpkgs/rocminfo/template

diff --git a/srcpkgs/rocminfo/template b/srcpkgs/rocminfo/template
new file mode 100644
index 00000000000..57d0640dd69
--- /dev/null
+++ b/srcpkgs/rocminfo/template
@@ -0,0 +1,22 @@
+# Template file for 'rocminfo'
+pkgname=rocminfo
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="rocminfo-rocm-${version}"
+build_style=cmake
+configure_args="-DROCM_DIR=/usr"
+hostmakedepends="cmake pkg-config"
+makedepends="rocr-runtime-devel"
+short_desc="Radeon Open Compute system information reporter"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute/rocminfo"
+distfiles="${homepage}/archive/rocm-${version}.tar.gz"
+checksum=e666f662c9e465aaabbbd0b109d87e017243cdf1a0898fabf5a90947bb3dbcd7
+nocross=yes
+python_version=3
+
+post_install() {
+	vlicense License.txt
+}

From 673ee21a6905ad3ca6877af58e936900c8d13bf1 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Sun, 19 Apr 2020 15:01:40 -0400
Subject: [PATCH 7/9] New package: rocm-bandwidth-test-3.3.0

---
 srcpkgs/rocm-bandwidth-test/template | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
 create mode 100644 srcpkgs/rocm-bandwidth-test/template

diff --git a/srcpkgs/rocm-bandwidth-test/template b/srcpkgs/rocm-bandwidth-test/template
new file mode 100644
index 00000000000..5c5058b693d
--- /dev/null
+++ b/srcpkgs/rocm-bandwidth-test/template
@@ -0,0 +1,20 @@
+# Template file for 'rocm-bandwidth-test'
+pkgname=rocm-bandwidth-test
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="rocm_bandwidth_test-rocm-${version}"
+build_style=cmake
+hostmakedepends="cmake"
+makedepends="rocr-runtime-devel roct-thunk-interface-devel"
+short_desc="Radeon Open Compute bandwidth test"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute/rocm_bandwidth_test"
+distfiles="${homepage}/archive/rocm-${version}.tar.gz"
+checksum=f5f914073018619dc91662d5bf630903dfa4db9136d603591917fdfb3c9164ce
+nocross=yes
+
+post_install() {
+	vlicense LICENSE.txt
+}

From ec070a854c6fa87db12a50b96bafa8b660569bc5 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Tue, 14 Apr 2020 10:25:54 -0400
Subject: [PATCH 8/9] New package: rocm-opencl-runtime-3.3.0

---
 common/shlibs                                 |   2 +
 srcpkgs/rocm-opencl-runtime-clinfo            |   1 +
 srcpkgs/rocm-opencl-runtime-devel             |   1 +
 .../files/libelf-musl.patch                   | 688 ++++++++++++++++++
 .../files/runtime-musl.patch                  |  11 +
 srcpkgs/rocm-opencl-runtime/files/sys_queue.h | 574 +++++++++++++++
 .../rocm-opencl-runtime/patches/cmake.patch   | 126 ++++
 srcpkgs/rocm-opencl-runtime/template          |  82 +++
 8 files changed, 1485 insertions(+)
 create mode 120000 srcpkgs/rocm-opencl-runtime-clinfo
 create mode 120000 srcpkgs/rocm-opencl-runtime-devel
 create mode 100644 srcpkgs/rocm-opencl-runtime/files/libelf-musl.patch
 create mode 100644 srcpkgs/rocm-opencl-runtime/files/runtime-musl.patch
 create mode 100644 srcpkgs/rocm-opencl-runtime/files/sys_queue.h
 create mode 100644 srcpkgs/rocm-opencl-runtime/patches/cmake.patch
 create mode 100644 srcpkgs/rocm-opencl-runtime/template

diff --git a/common/shlibs b/common/shlibs
index a53de3cf9e0..8cbc885e016 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3865,3 +3865,5 @@ libstoken.so.1 stoken-0.92_1
 libhsakmt.so.1 roct-thunk-interface-3.3.0_1
 libhsa-runtime64.so.1 rocr-runtime-3.3.0_1
 libamd_comgr.so.1 rocm-comgr-3.3.0_1
+libOpenCL-ROCm.so.1 rocm-opencl-runtime-3.3.0_1
+libamdocl64.so rocm-opencl-runtime-3.3.0_1
diff --git a/srcpkgs/rocm-opencl-runtime-clinfo b/srcpkgs/rocm-opencl-runtime-clinfo
new file mode 120000
index 00000000000..b2cda7e229d
--- /dev/null
+++ b/srcpkgs/rocm-opencl-runtime-clinfo
@@ -0,0 +1 @@
+rocm-opencl-runtime
\ No newline at end of file
diff --git a/srcpkgs/rocm-opencl-runtime-devel b/srcpkgs/rocm-opencl-runtime-devel
new file mode 120000
index 00000000000..b2cda7e229d
--- /dev/null
+++ b/srcpkgs/rocm-opencl-runtime-devel
@@ -0,0 +1 @@
+rocm-opencl-runtime
\ No newline at end of file
diff --git a/srcpkgs/rocm-opencl-runtime/files/libelf-musl.patch b/srcpkgs/rocm-opencl-runtime/files/libelf-musl.patch
new file mode 100644
index 00000000000..a3705c259a9
--- /dev/null
+++ b/srcpkgs/rocm-opencl-runtime/files/libelf-musl.patch
@@ -0,0 +1,688 @@
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/_libelf.h compiler/lib/loaders/elf/utils/libelf/_libelf.h
+--- compiler/lib/loaders/elf/utils/libelf.orig/_libelf.h	2020-04-19 08:59:34.201386585 -0400
++++ compiler/lib/loaders/elf/utils/libelf/_libelf.h	2020-04-19 09:04:12.950433528 -0400
+@@ -30,7 +30,7 @@
+ #define	__LIBELF_H_
+ 
+ #include <limits.h>
+-#include <sys/queue.h>
++#include "sys_queue.h"
+ 
+ #include "_libelf_config.h"
+ 
+@@ -179,7 +179,9 @@
+  * Function Prototypes.
+  */
+ 
+-__BEGIN_DECLS
++#ifdef __cplusplus
++extern "C" {
++#endif
+ Elf_Data *_libelf_allocate_data(Elf_Scn *_s);
+ Elf	*_libelf_allocate_elf(Elf_Mem *mem);
+ Elf_Scn	*_libelf_allocate_scn(Elf *_e, size_t _ndx);
+@@ -213,6 +215,8 @@
+ Elf_Data *_libelf_xlate(Elf_Data *_d, const Elf_Data *_s,
+     unsigned int _encoding, int _elfclass, int _direction);
+ int	_libelf_xlate_shtype(uint32_t _sht);
+-__END_DECLS
++#ifdef __cplusplus
++}
++#endif
+ 
+ #endif	/* __LIBELF_H_ */
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_begin.c compiler/lib/loaders/elf/utils/libelf/elf_begin.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_begin.c	2020-04-19 08:59:34.201386585 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_begin.c	2020-04-19 09:01:04.313212042 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <sys/types.h>
+ #if !defined(WIN32)
+ #include <sys/errno.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_end.c compiler/lib/loaders/elf/utils/libelf/elf_end.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_end.c	2020-04-19 08:59:34.201386585 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_end.c	2020-04-19 09:01:14.895204681 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #if !defined(WIN32)
+ #include <sys/mman.h>
+ #endif
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_errmsg.c compiler/lib/loaders/elf/utils/libelf/elf_errmsg.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_errmsg.c	2020-04-19 08:59:34.201386585 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_errmsg.c	2020-04-19 09:01:16.753207065 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ #include <stdio.h>
+ #include <string.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_errno.c compiler/lib/loaders/elf/utils/libelf/elf_errno.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_errno.c	2020-04-19 08:59:34.201386585 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_errno.c	2020-04-19 09:01:18.669209528 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_fill.c compiler/lib/loaders/elf/utils/libelf/elf_fill.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_fill.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_fill.c	2020-04-19 09:01:21.109212667 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_flag.c compiler/lib/loaders/elf/utils/libelf/elf_flag.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_flag.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_flag.c	2020-04-19 09:01:23.376215579 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_getarhdr.c compiler/lib/loaders/elf/utils/libelf/elf_getarhdr.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_getarhdr.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_getarhdr.c	2020-04-19 09:01:25.414218197 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_getarsym.c compiler/lib/loaders/elf/utils/libelf/elf_getarsym.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_getarsym.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_getarsym.c	2020-04-19 09:01:27.575220978 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_getbase.c compiler/lib/loaders/elf/utils/libelf/elf_getbase.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_getbase.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_getbase.c	2020-04-19 09:01:29.963224043 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_getident.c compiler/lib/loaders/elf/utils/libelf/elf_getident.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_getident.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_getident.c	2020-04-19 09:01:31.912226551 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <ar.h>
+ #include <assert.h>
+ #include <libelf.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_hash.c compiler/lib/loaders/elf/utils/libelf/elf_hash.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_hash.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_hash.c	2020-04-19 09:01:33.877229069 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ #include "_libelf_config.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_kind.c compiler/lib/loaders/elf/utils/libelf/elf_kind.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_kind.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_kind.c	2020-04-19 09:01:35.940231721 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_memory.c compiler/lib/loaders/elf/utils/libelf/elf_memory.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_memory.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_memory.c	2020-04-19 09:01:38.171234596 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <ar.h>
+ #include <libelf.h>
+ #include <string.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_next.c compiler/lib/loaders/elf/utils/libelf/elf_next.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_next.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_next.c	2020-04-19 09:01:40.063237028 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <ar.h>
+ #include <assert.h>
+ #include <libelf.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_phnum.c compiler/lib/loaders/elf/utils/libelf/elf_phnum.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_phnum.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_phnum.c	2020-04-19 09:01:42.480240134 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <ar.h>
+ #include <libelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_rand.c compiler/lib/loaders/elf/utils/libelf/elf_rand.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_rand.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_rand.c	2020-04-19 09:01:45.061243452 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <ar.h>
+ #include <libelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_rawfile.c compiler/lib/loaders/elf/utils/libelf/elf_rawfile.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_rawfile.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_rawfile.c	2020-04-19 09:01:46.988245928 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_scn.c compiler/lib/loaders/elf/utils/libelf/elf_scn.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_scn.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_scn.c	2020-04-19 09:00:19.724298403 -0400
+@@ -24,8 +24,7 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-#include <sys/queue.h>
++#include "sys_queue.h"
+ 
+ #include <assert.h>
+ #include <errno.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_shnum.c compiler/lib/loaders/elf/utils/libelf/elf_shnum.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_shnum.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_shnum.c	2020-04-19 09:01:51.763252060 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <ar.h>
+ #include <libelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_shstrndx.c compiler/lib/loaders/elf/utils/libelf/elf_shstrndx.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_shstrndx.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_shstrndx.c	2020-04-19 09:01:53.532254340 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <ar.h>
+ #include <libelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_version.c compiler/lib/loaders/elf/utils/libelf/elf_version.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_version.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_version.c	2020-04-19 09:02:01.337264370 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf.h compiler/lib/loaders/elf/utils/libelf/gelf.h
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf.h	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf.h	2020-04-19 09:04:29.669455020 -0400
+@@ -29,8 +29,6 @@
+ #ifndef	_GELF_H_
+ #define	_GELF_H_
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ typedef Elf64_Addr	GElf_Addr;	/* Addresses */
+@@ -72,7 +70,9 @@
+ #define	GELF_ST_TYPE			ELF64_ST_TYPE
+ #define	GELF_ST_VISIBILITY		ELF64_ST_VISIBILITY
+ 
+-__BEGIN_DECLS
++#ifdef __cplusplus
++extern "C" {
++#endif
+ long		gelf_checksum(Elf *_elf);
+ size_t		gelf_fsize(Elf *_elf, Elf_Type _type, size_t _count,
+ 			unsigned int _version);
+@@ -109,6 +109,8 @@
+ int		gelf_update_move(Elf_Data *_dst, int _index, GElf_Move *_src);
+ int		gelf_update_syminfo(Elf_Data *_dst, int _index, GElf_Syminfo *_src);
+ #endif
+-__END_DECLS
++#ifdef __cplusplus
++}
++#endif
+ 
+ #endif	/* _GELF_H_ */
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_cap.c compiler/lib/loaders/elf/utils/libelf/gelf_cap.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_cap.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_cap.c	2020-04-19 09:02:05.429269632 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_checksum.c compiler/lib/loaders/elf/utils/libelf/gelf_checksum.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_checksum.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_checksum.c	2020-04-19 09:02:08.192273183 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <gelf.h>
+ #include <libelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_dyn.c compiler/lib/loaders/elf/utils/libelf/gelf_dyn.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_dyn.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_dyn.c	2020-04-19 09:02:10.020275525 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_ehdr.c compiler/lib/loaders/elf/utils/libelf/gelf_ehdr.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_ehdr.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_ehdr.c	2020-04-19 09:02:11.882277926 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ #include <libelf.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_fsize.c compiler/lib/loaders/elf/utils/libelf/gelf_fsize.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_fsize.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_fsize.c	2020-04-19 09:02:14.139280827 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <gelf.h>
+ #include <libelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_getclass.c compiler/lib/loaders/elf/utils/libelf/gelf_getclass.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_getclass.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_getclass.c	2020-04-19 09:02:17.269284848 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <gelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_move.c compiler/lib/loaders/elf/utils/libelf/gelf_move.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_move.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_move.c	2020-04-19 09:02:18.974287034 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_phdr.c compiler/lib/loaders/elf/utils/libelf/gelf_phdr.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_phdr.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_phdr.c	2020-04-19 09:02:20.676289227 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <gelf.h>
+ #include <libelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_rel.c compiler/lib/loaders/elf/utils/libelf/gelf_rel.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_rel.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_rel.c	2020-04-19 09:02:23.177292435 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_rela.c compiler/lib/loaders/elf/utils/libelf/gelf_rela.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_rela.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_rela.c	2020-04-19 09:02:25.246295100 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_shdr.c compiler/lib/loaders/elf/utils/libelf/gelf_shdr.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_shdr.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_shdr.c	2020-04-19 09:02:28.325299060 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ #include <libelf.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_sym.c compiler/lib/loaders/elf/utils/libelf/gelf_sym.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_sym.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_sym.c	2020-04-19 09:02:30.113301356 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_syminfo.c compiler/lib/loaders/elf/utils/libelf/gelf_syminfo.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_syminfo.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_syminfo.c	2020-04-19 09:02:31.906303662 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_symshndx.c compiler/lib/loaders/elf/utils/libelf/gelf_symshndx.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_symshndx.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_symshndx.c	2020-04-19 09:02:33.626305873 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_xlate.c compiler/lib/loaders/elf/utils/libelf/gelf_xlate.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_xlate.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_xlate.c	2020-04-19 09:02:35.921308822 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <gelf.h>
+ #include <libelf.h>
+ #include <string.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf.h compiler/lib/loaders/elf/utils/libelf/libelf.h
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf.h	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf.h	2020-04-19 09:04:38.760466706 -0400
+@@ -30,7 +30,7 @@
+ #define	_LIBELF_H_
+ 
+ #include <sys/types.h>
+-#include <sys/queue.h>
++#include "sys_queue.h"
+ #include <elfdefinitions.h>
+ #ifndef EM_HSAIL
+ #define EM_HSAIL 0xAF5A
+@@ -187,7 +187,9 @@
+ #define	ELF_F_ARCHIVE	   0x100U /* archive creation */
+ #define	ELF_F_ARCHIVE_SYSV 0x200U /* SYSV style archive */
+ 
+-__BEGIN_DECLS
++#ifdef __cplusplus
++extern "C" {
++#endif
+ Elf		*elf_begin(int _fd, Elf_Cmd _cmd, Elf *_elf, Elf_Mem *_mem);
+ int		elf_cntl(Elf *_elf, Elf_Cmd _cmd);
+ int		elf_end(Elf *_elf);
+@@ -257,6 +259,8 @@
+ 			unsigned int _enc);
+ Elf_Data	*elf64_xlatetom(Elf_Data *_dst, const Elf_Data *_src,
+ 			unsigned int _enc);
+-__END_DECLS
++#ifdef __cplusplus
++}
++#endif
+ 
+ #endif	/* _LIBELF_H_ */
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_align.c compiler/lib/loaders/elf/utils/libelf/libelf_align.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_align.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_align.c	2020-04-19 09:02:40.660314911 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <sys/types.h>
+ 
+ #include <libelf.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_allocate.c compiler/lib/loaders/elf/utils/libelf/libelf_allocate.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_allocate.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_allocate.c	2020-04-19 09:02:43.079318019 -0400
+@@ -28,8 +28,6 @@
+  * Internal APIs
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #if !defined(WIN32)
+ #include <sys/errno.h>
+ #endif
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_ar.c compiler/lib/loaders/elf/utils/libelf/libelf_ar.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_ar.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_ar.c	2020-04-19 09:02:44.763320187 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <ctype.h>
+ #include <libelf.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_ar_util.c compiler/lib/loaders/elf/utils/libelf/libelf_ar_util.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_ar_util.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_ar_util.c	2020-04-19 09:02:46.461322369 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <libelf.h>
+ #include <stdlib.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_checksum.c compiler/lib/loaders/elf/utils/libelf/libelf_checksum.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_checksum.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_checksum.c	2020-04-19 09:02:48.645325173 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <gelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_convert.c compiler/lib/loaders/elf/utils/libelf/libelf_convert.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_convert.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_convert.c	2020-04-19 09:02:50.883328053 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <libelf.h>
+ #include <string.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_data.c compiler/lib/loaders/elf/utils/libelf/libelf_data.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_data.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_data.c	2020-04-19 09:02:52.951330708 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_ehdr.c compiler/lib/loaders/elf/utils/libelf/libelf_ehdr.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_ehdr.c	2020-04-19 08:59:34.204386579 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_ehdr.c	2020-04-19 09:02:55.176333563 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ #include <libelf.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_extended.c compiler/lib/loaders/elf/utils/libelf/libelf_extended.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_extended.c	2020-04-19 08:59:34.204386579 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_extended.c	2020-04-19 09:02:57.932337110 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <libelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_msize.c compiler/lib/loaders/elf/utils/libelf/libelf_msize.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_msize.c	2020-04-19 08:59:34.204386579 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_msize.c	2020-04-19 09:03:02.201342598 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <libelf.h>
+ #include <string.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_phdr.c compiler/lib/loaders/elf/utils/libelf/libelf_phdr.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_phdr.c	2020-04-19 08:59:34.204386579 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_phdr.c	2020-04-19 09:03:04.194345160 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ #include <libelf.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_shdr.c compiler/lib/loaders/elf/utils/libelf/libelf_shdr.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_shdr.c	2020-04-19 08:59:34.204386579 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_shdr.c	2020-04-19 09:03:05.795347218 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <gelf.h>
+ #include <libelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_xlate.c compiler/lib/loaders/elf/utils/libelf/libelf_xlate.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_xlate.c	2020-04-19 08:59:34.204386579 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_xlate.c	2020-04-19 09:03:09.472351944 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <libelf.h>
+ 
diff --git a/srcpkgs/rocm-opencl-runtime/files/runtime-musl.patch b/srcpkgs/rocm-opencl-runtime/files/runtime-musl.patch
new file mode 100644
index 00000000000..ea18e90e09c
--- /dev/null
+++ b/srcpkgs/rocm-opencl-runtime/files/runtime-musl.patch
@@ -0,0 +1,11 @@
+--- runtime/os/os_posix.cpp.orig	2020-04-19 09:13:51.701982901 -0400
++++ runtime/os/os_posix.cpp	2020-04-19 09:14:04.156947422 -0400
+@@ -44,6 +44,8 @@
+ #include <algorithm>
+ #include <mutex>
+ 
++#include <libgen.h> // for basename
++
+ 
+ namespace amd {
+ 
diff --git a/srcpkgs/rocm-opencl-runtime/files/sys_queue.h b/srcpkgs/rocm-opencl-runtime/files/sys_queue.h
new file mode 100644
index 00000000000..daf4553d33e
--- /dev/null
+++ b/srcpkgs/rocm-opencl-runtime/files/sys_queue.h
@@ -0,0 +1,574 @@
+/*
+ * Copyright (c) 1991, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *	@(#)queue.h	8.5 (Berkeley) 8/20/94
+ */
+
+#ifndef	_SYS_QUEUE_H_
+#define	_SYS_QUEUE_H_
+
+/*
+ * This file defines five types of data structures: singly-linked lists,
+ * lists, simple queues, tail queues, and circular queues.
+ *
+ * A singly-linked list is headed by a single forward pointer. The
+ * elements are singly linked for minimum space and pointer manipulation
+ * overhead at the expense of O(n) removal for arbitrary elements. New
+ * elements can be added to the list after an existing element or at the
+ * head of the list.  Elements being removed from the head of the list
+ * should use the explicit macro for this purpose for optimum
+ * efficiency. A singly-linked list may only be traversed in the forward
+ * direction.  Singly-linked lists are ideal for applications with large
+ * datasets and few or no removals or for implementing a LIFO queue.
+ *
+ * A list is headed by a single forward pointer (or an array of forward
+ * pointers for a hash table header). The elements are doubly linked
+ * so that an arbitrary element can be removed without a need to
+ * traverse the list. New elements can be added to the list before
+ * or after an existing element or at the head of the list. A list
+ * may only be traversed in the forward direction.
+ *
+ * A simple queue is headed by a pair of pointers, one the head of the
+ * list and the other to the tail of the list. The elements are singly
+ * linked to save space, so elements can only be removed from the
+ * head of the list. New elements can be added to the list after
+ * an existing element, at the head of the list, or at the end of the
+ * list. A simple queue may only be traversed in the forward direction.
+ *
+ * A tail queue is headed by a pair of pointers, one to the head of the
+ * list and the other to the tail of the list. The elements are doubly
+ * linked so that an arbitrary element can be removed without a need to
+ * traverse the list. New elements can be added to the list before or
+ * after an existing element, at the head of the list, or at the end of
+ * the list. A tail queue may be traversed in either direction.
+ *
+ * A circle queue is headed by a pair of pointers, one to the head of the
+ * list and the other to the tail of the list. The elements are doubly
+ * linked so that an arbitrary element can be removed without a need to
+ * traverse the list. New elements can be added to the list before or after
+ * an existing element, at the head of the list, or at the end of the list.
+ * A circle queue may be traversed in either direction, but has a more
+ * complex end of list detection.
+ *
+ * For details on the use of these macros, see the queue(3) manual page.
+ */
+
+/*
+ * List definitions.
+ */
+#define	LIST_HEAD(name, type)						\
+struct name {								\
+	struct type *lh_first;	/* first element */			\
+}
+
+#define	LIST_HEAD_INITIALIZER(head)					\
+	{ NULL }
+
+#define	LIST_ENTRY(type)						\
+struct {								\
+	struct type *le_next;	/* next element */			\
+	struct type **le_prev;	/* address of previous next element */	\
+}
+
+/*
+ * List functions.
+ */
+#define	LIST_INIT(head) do {						\
+	(head)->lh_first = NULL;					\
+} while (/*CONSTCOND*/0)
+
+#define	LIST_INSERT_AFTER(listelm, elm, field) do {			\
+	if (((elm)->field.le_next = (listelm)->field.le_next) != NULL)	\
+		(listelm)->field.le_next->field.le_prev =		\
+		    &(elm)->field.le_next;				\
+	(listelm)->field.le_next = (elm);				\
+	(elm)->field.le_prev = &(listelm)->field.le_next;		\
+} while (/*CONSTCOND*/0)
+
+#define	LIST_INSERT_BEFORE(listelm, elm, field) do {			\
+	(elm)->field.le_prev = (listelm)->field.le_prev;		\
+	(elm)->field.le_next = (listelm);				\
+	*(listelm)->field.le_prev = (elm);				\
+	(listelm)->field.le_prev = &(elm)->field.le_next;		\
+} while (/*CONSTCOND*/0)
+
+#define	LIST_INSERT_HEAD(head, elm, field) do {				\
+	if (((elm)->field.le_next = (head)->lh_first) != NULL)		\
+		(head)->lh_first->field.le_prev = &(elm)->field.le_next;\
+	(head)->lh_first = (elm);					\
+	(elm)->field.le_prev = &(head)->lh_first;			\
+} while (/*CONSTCOND*/0)
+
+#define	LIST_REMOVE(elm, field) do {					\
+	if ((elm)->field.le_next != NULL)				\
+		(elm)->field.le_next->field.le_prev = 			\
+		    (elm)->field.le_prev;				\
+	*(elm)->field.le_prev = (elm)->field.le_next;			\
+} while (/*CONSTCOND*/0)
+
+#define	LIST_FOREACH(var, head, field)					\
+	for ((var) = ((head)->lh_first);				\
+		(var);							\
+		(var) = ((var)->field.le_next))
+
+/*
+ * List access methods.
+ */
+#define	LIST_EMPTY(head)		((head)->lh_first == NULL)
+#define	LIST_FIRST(head)		((head)->lh_first)
+#define	LIST_NEXT(elm, field)		((elm)->field.le_next)
+
+
+/*
+ * Singly-linked List definitions.
+ */
+#define	SLIST_HEAD(name, type)						\
+struct name {								\
+	struct type *slh_first;	/* first element */			\
+}
+
+#define	SLIST_HEAD_INITIALIZER(head)					\
+	{ NULL }
+
+#define	SLIST_ENTRY(type)						\
+struct {								\
+	struct type *sle_next;	/* next element */			\
+}
+
+/*
+ * Singly-linked List functions.
+ */
+#define	SLIST_INIT(head) do {						\
+	(head)->slh_first = NULL;					\
+} while (/*CONSTCOND*/0)
+
+#define	SLIST_INSERT_AFTER(slistelm, elm, field) do {			\
+	(elm)->field.sle_next = (slistelm)->field.sle_next;		\
+	(slistelm)->field.sle_next = (elm);				\
+} while (/*CONSTCOND*/0)
+
+#define	SLIST_INSERT_HEAD(head, elm, field) do {			\
+	(elm)->field.sle_next = (head)->slh_first;			\
+	(head)->slh_first = (elm);					\
+} while (/*CONSTCOND*/0)
+
+#define	SLIST_REMOVE_HEAD(head, field) do {				\
+	(head)->slh_first = (head)->slh_first->field.sle_next;		\
+} while (/*CONSTCOND*/0)
+
+#define	SLIST_REMOVE(head, elm, type, field) do {			\
+	if ((head)->slh_first == (elm)) {				\
+		SLIST_REMOVE_HEAD((head), field);			\
+	}								\
+	else {								\
+		struct type *curelm = (head)->slh_first;		\
+		while(curelm->field.sle_next != (elm))			\
+			curelm = curelm->field.sle_next;		\
+		curelm->field.sle_next =				\
+		    curelm->field.sle_next->field.sle_next;		\
+	}								\
+} while (/*CONSTCOND*/0)
+
+#define	SLIST_FOREACH(var, head, field)					\
+	for((var) = (head)->slh_first; (var); (var) = (var)->field.sle_next)
+
+/*
+ * Singly-linked List access methods.
+ */
+#define	SLIST_EMPTY(head)	((head)->slh_first == NULL)
+#define	SLIST_FIRST(head)	((head)->slh_first)
+#define	SLIST_NEXT(elm, field)	((elm)->field.sle_next)
+
+
+/*
+ * Singly-linked Tail queue declarations.
+ */
+#define	STAILQ_HEAD(name, type)					\
+struct name {								\
+	struct type *stqh_first;	/* first element */			\
+	struct type **stqh_last;	/* addr of last next element */		\
+}
+
+#define	STAILQ_HEAD_INITIALIZER(head)					\
+	{ NULL, &(head).stqh_first }
+
+#define	STAILQ_ENTRY(type)						\
+struct {								\
+	struct type *stqe_next;	/* next element */			\
+}
+
+/*
+ * Singly-linked Tail queue functions.
+ */
+#define	STAILQ_INIT(head) do {						\
+	(head)->stqh_first = NULL;					\
+	(head)->stqh_last = &(head)->stqh_first;				\
+} while (/*CONSTCOND*/0)
+
+#define	STAILQ_INSERT_HEAD(head, elm, field) do {			\
+	if (((elm)->field.stqe_next = (head)->stqh_first) == NULL)	\
+		(head)->stqh_last = &(elm)->field.stqe_next;		\
+	(head)->stqh_first = (elm);					\
+} while (/*CONSTCOND*/0)
+
+#define	STAILQ_INSERT_TAIL(head, elm, field) do {			\
+	(elm)->field.stqe_next = NULL;					\
+	*(head)->stqh_last = (elm);					\
+	(head)->stqh_last = &(elm)->field.stqe_next;			\
+} while (/*CONSTCOND*/0)
+
+#define	STAILQ_INSERT_AFTER(head, listelm, elm, field) do {		\
+	if (((elm)->field.stqe_next = (listelm)->field.stqe_next) == NULL)\
+		(head)->stqh_last = &(elm)->field.stqe_next;		\
+	(listelm)->field.stqe_next = (elm);				\
+} while (/*CONSTCOND*/0)
+
+#define	STAILQ_REMOVE_HEAD(head, field) do {				\
+	if (((head)->stqh_first = (head)->stqh_first->field.stqe_next) == NULL) \
+		(head)->stqh_last = &(head)->stqh_first;			\
+} while (/*CONSTCOND*/0)
+
+#define	STAILQ_REMOVE(head, elm, type, field) do {			\
+	if ((head)->stqh_first == (elm)) {				\
+		STAILQ_REMOVE_HEAD((head), field);			\
+	} else {							\
+		struct type *curelm = (head)->stqh_first;		\
+		while (curelm->field.stqe_next != (elm))			\
+			curelm = curelm->field.stqe_next;		\
+		if ((curelm->field.stqe_next =				\
+			curelm->field.stqe_next->field.stqe_next) == NULL) \
+			    (head)->stqh_last = &(curelm)->field.stqe_next; \
+	}								\
+} while (/*CONSTCOND*/0)
+
+#define	STAILQ_FOREACH(var, head, field)				\
+	for ((var) = ((head)->stqh_first);				\
+		(var);							\
+		(var) = ((var)->field.stqe_next))
+
+#define	STAILQ_CONCAT(head1, head2) do {				\
+	if (!STAILQ_EMPTY((head2))) {					\
+		*(head1)->stqh_last = (head2)->stqh_first;		\
+		(head1)->stqh_last = (head2)->stqh_last;		\
+		STAILQ_INIT((head2));					\
+	}								\
+} while (/*CONSTCOND*/0)
+
+/*
+ * Singly-linked Tail queue access methods.
+ */
+#define	STAILQ_EMPTY(head)	((head)->stqh_first == NULL)
+#define	STAILQ_FIRST(head)	((head)->stqh_first)
+#define	STAILQ_NEXT(elm, field)	((elm)->field.stqe_next)
+
+
+/*
+ * Simple queue definitions.
+ */
+#define	SIMPLEQ_HEAD(name, type)					\
+struct name {								\
+	struct type *sqh_first;	/* first element */			\
+	struct type **sqh_last;	/* addr of last next element */		\
+}
+
+#define	SIMPLEQ_HEAD_INITIALIZER(head)					\
+	{ NULL, &(head).sqh_first }
+
+#define	SIMPLEQ_ENTRY(type)						\
+struct {								\
+	struct type *sqe_next;	/* next element */			\
+}
+
+/*
+ * Simple queue functions.
+ */
+#define	SIMPLEQ_INIT(head) do {						\
+	(head)->sqh_first = NULL;					\
+	(head)->sqh_last = &(head)->sqh_first;				\
+} while (/*CONSTCOND*/0)
+
+#define	SIMPLEQ_INSERT_HEAD(head, elm, field) do {			\
+	if (((elm)->field.sqe_next = (head)->sqh_first) == NULL)	\
+		(head)->sqh_last = &(elm)->field.sqe_next;		\
+	(head)->sqh_first = (elm);					\
+} while (/*CONSTCOND*/0)
+
+#define	SIMPLEQ_INSERT_TAIL(head, elm, field) do {			\
+	(elm)->field.sqe_next = NULL;					\
+	*(head)->sqh_last = (elm);					\
+	(head)->sqh_last = &(elm)->field.sqe_next;			\
+} while (/*CONSTCOND*/0)
+
+#define	SIMPLEQ_INSERT_AFTER(head, listelm, elm, field) do {		\
+	if (((elm)->field.sqe_next = (listelm)->field.sqe_next) == NULL)\
+		(head)->sqh_last = &(elm)->field.sqe_next;		\
+	(listelm)->field.sqe_next = (elm);				\
+} while (/*CONSTCOND*/0)
+
+#define	SIMPLEQ_REMOVE_HEAD(head, field) do {				\
+	if (((head)->sqh_first = (head)->sqh_first->field.sqe_next) == NULL) \
+		(head)->sqh_last = &(head)->sqh_first;			\
+} while (/*CONSTCOND*/0)
+
+#define	SIMPLEQ_REMOVE(head, elm, type, field) do {			\
+	if ((head)->sqh_first == (elm)) {				\
+		SIMPLEQ_REMOVE_HEAD((head), field);			\
+	} else {							\
+		struct type *curelm = (head)->sqh_first;		\
+		while (curelm->field.sqe_next != (elm))			\
+			curelm = curelm->field.sqe_next;		\
+		if ((curelm->field.sqe_next =				\
+			curelm->field.sqe_next->field.sqe_next) == NULL) \
+			    (head)->sqh_last = &(curelm)->field.sqe_next; \
+	}								\
+} while (/*CONSTCOND*/0)
+
+#define	SIMPLEQ_FOREACH(var, head, field)				\
+	for ((var) = ((head)->sqh_first);				\
+		(var);							\
+		(var) = ((var)->field.sqe_next))
+
+/*
+ * Simple queue access methods.
+ */
+#define	SIMPLEQ_EMPTY(head)		((head)->sqh_first == NULL)
+#define	SIMPLEQ_FIRST(head)		((head)->sqh_first)
+#define	SIMPLEQ_NEXT(elm, field)	((elm)->field.sqe_next)
+
+
+/*
+ * Tail queue definitions.
+ */
+#define	_TAILQ_HEAD(name, type, qual)					\
+struct name {								\
+	qual type *tqh_first;		/* first element */		\
+	qual type *qual *tqh_last;	/* addr of last next element */	\
+}
+#define TAILQ_HEAD(name, type)	_TAILQ_HEAD(name, struct type,)
+
+#define	TAILQ_HEAD_INITIALIZER(head)					\
+	{ NULL, &(head).tqh_first }
+
+#define	_TAILQ_ENTRY(type, qual)					\
+struct {								\
+	qual type *tqe_next;		/* next element */		\
+	qual type *qual *tqe_prev;	/* address of previous next element */\
+}
+#define TAILQ_ENTRY(type)	_TAILQ_ENTRY(struct type,)
+
+/*
+ * Tail queue functions.
+ */
+#define	TAILQ_INIT(head) do {						\
+	(head)->tqh_first = NULL;					\
+	(head)->tqh_last = &(head)->tqh_first;				\
+} while (/*CONSTCOND*/0)
+
+#define	TAILQ_INSERT_HEAD(head, elm, field) do {			\
+	if (((elm)->field.tqe_next = (head)->tqh_first) != NULL)	\
+		(head)->tqh_first->field.tqe_prev =			\
+		    &(elm)->field.tqe_next;				\
+	else								\
+		(head)->tqh_last = &(elm)->field.tqe_next;		\
+	(head)->tqh_first = (elm);					\
+	(elm)->field.tqe_prev = &(head)->tqh_first;			\
+} while (/*CONSTCOND*/0)
+
+#define	TAILQ_INSERT_TAIL(head, elm, field) do {			\
+	(elm)->field.tqe_next = NULL;					\
+	(elm)->field.tqe_prev = (head)->tqh_last;			\
+	*(head)->tqh_last = (elm);					\
+	(head)->tqh_last = &(elm)->field.tqe_next;			\
+} while (/*CONSTCOND*/0)
+
+#define	TAILQ_INSERT_AFTER(head, listelm, elm, field) do {		\
+	if (((elm)->field.tqe_next = (listelm)->field.tqe_next) != NULL)\
+		(elm)->field.tqe_next->field.tqe_prev = 		\
+		    &(elm)->field.tqe_next;				\
+	else								\
+		(head)->tqh_last = &(elm)->field.tqe_next;		\
+	(listelm)->field.tqe_next = (elm);				\
+	(elm)->field.tqe_prev = &(listelm)->field.tqe_next;		\
+} while (/*CONSTCOND*/0)
+
+#define	TAILQ_INSERT_BEFORE(listelm, elm, field) do {			\
+	(elm)->field.tqe_prev = (listelm)->field.tqe_prev;		\
+	(elm)->field.tqe_next = (listelm);				\
+	*(listelm)->field.tqe_prev = (elm);				\
+	(listelm)->field.tqe_prev = &(elm)->field.tqe_next;		\
+} while (/*CONSTCOND*/0)
+
+#define	TAILQ_REMOVE(head, elm, field) do {				\
+	if (((elm)->field.tqe_next) != NULL)				\
+		(elm)->field.tqe_next->field.tqe_prev = 		\
+		    (elm)->field.tqe_prev;				\
+	else								\
+		(head)->tqh_last = (elm)->field.tqe_prev;		\
+	*(elm)->field.tqe_prev = (elm)->field.tqe_next;			\
+} while (/*CONSTCOND*/0)
+
+#define	TAILQ_FOREACH(var, head, field)					\
+	for ((var) = ((head)->tqh_first);				\
+		(var);							\
+		(var) = ((var)->field.tqe_next))
+
+#define	TAILQ_FOREACH_REVERSE(var, head, headname, field)		\
+	for ((var) = (*(((struct headname *)((head)->tqh_last))->tqh_last));	\
+		(var);							\
+		(var) = (*(((struct headname *)((var)->field.tqe_prev))->tqh_last)))
+
+#define	TAILQ_CONCAT(head1, head2, field) do {				\
+	if (!TAILQ_EMPTY(head2)) {					\
+		*(head1)->tqh_last = (head2)->tqh_first;		\
+		(head2)->tqh_first->field.tqe_prev = (head1)->tqh_last;	\
+		(head1)->tqh_last = (head2)->tqh_last;			\
+		TAILQ_INIT((head2));					\
+	}								\
+} while (/*CONSTCOND*/0)
+
+/*
+ * Tail queue access methods.
+ */
+#define	TAILQ_EMPTY(head)		((head)->tqh_first == NULL)
+#define	TAILQ_FIRST(head)		((head)->tqh_first)
+#define	TAILQ_NEXT(elm, field)		((elm)->field.tqe_next)
+
+#define	TAILQ_LAST(head, headname) \
+	(*(((struct headname *)((head)->tqh_last))->tqh_last))
+#define	TAILQ_PREV(elm, headname, field) \
+	(*(((struct headname *)((elm)->field.tqe_prev))->tqh_last))
+
+
+/*
+ * Circular queue definitions.
+ */
+#define	CIRCLEQ_HEAD(name, type)					\
+struct name {								\
+	struct type *cqh_first;		/* first element */		\
+	struct type *cqh_last;		/* last element */		\
+}
+
+#define	CIRCLEQ_HEAD_INITIALIZER(head)					\
+	{ (void *)&head, (void *)&head }
+
+#define	CIRCLEQ_ENTRY(type)						\
+struct {								\
+	struct type *cqe_next;		/* next element */		\
+	struct type *cqe_prev;		/* previous element */		\
+}
+
+/*
+ * Circular queue functions.
+ */
+#define	CIRCLEQ_INIT(head) do {						\
+	(head)->cqh_first = (void *)(head);				\
+	(head)->cqh_last = (void *)(head);				\
+} while (/*CONSTCOND*/0)
+
+#define	CIRCLEQ_INSERT_AFTER(head, listelm, elm, field) do {		\
+	(elm)->field.cqe_next = (listelm)->field.cqe_next;		\
+	(elm)->field.cqe_prev = (listelm);				\
+	if ((listelm)->field.cqe_next == (void *)(head))		\
+		(head)->cqh_last = (elm);				\
+	else								\
+		(listelm)->field.cqe_next->field.cqe_prev = (elm);	\
+	(listelm)->field.cqe_next = (elm);				\
+} while (/*CONSTCOND*/0)
+
+#define	CIRCLEQ_INSERT_BEFORE(head, listelm, elm, field) do {		\
+	(elm)->field.cqe_next = (listelm);				\
+	(elm)->field.cqe_prev = (listelm)->field.cqe_prev;		\
+	if ((listelm)->field.cqe_prev == (void *)(head))		\
+		(head)->cqh_first = (elm);				\
+	else								\
+		(listelm)->field.cqe_prev->field.cqe_next = (elm);	\
+	(listelm)->field.cqe_prev = (elm);				\
+} while (/*CONSTCOND*/0)
+
+#define	CIRCLEQ_INSERT_HEAD(head, elm, field) do {			\
+	(elm)->field.cqe_next = (head)->cqh_first;			\
+	(elm)->field.cqe_prev = (void *)(head);				\
+	if ((head)->cqh_last == (void *)(head))				\
+		(head)->cqh_last = (elm);				\
+	else								\
+		(head)->cqh_first->field.cqe_prev = (elm);		\
+	(head)->cqh_first = (elm);					\
+} while (/*CONSTCOND*/0)
+
+#define	CIRCLEQ_INSERT_TAIL(head, elm, field) do {			\
+	(elm)->field.cqe_next = (void *)(head);				\
+	(elm)->field.cqe_prev = (head)->cqh_last;			\
+	if ((head)->cqh_first == (void *)(head))			\
+		(head)->cqh_first = (elm);				\
+	else								\
+		(head)->cqh_last->field.cqe_next = (elm);		\
+	(head)->cqh_last = (elm);					\
+} while (/*CONSTCOND*/0)
+
+#define	CIRCLEQ_REMOVE(head, elm, field) do {				\
+	if ((elm)->field.cqe_next == (void *)(head))			\
+		(head)->cqh_last = (elm)->field.cqe_prev;		\
+	else								\
+		(elm)->field.cqe_next->field.cqe_prev =			\
+		    (elm)->field.cqe_prev;				\
+	if ((elm)->field.cqe_prev == (void *)(head))			\
+		(head)->cqh_first = (elm)->field.cqe_next;		\
+	else								\
+		(elm)->field.cqe_prev->field.cqe_next =			\
+		    (elm)->field.cqe_next;				\
+} while (/*CONSTCOND*/0)
+
+#define	CIRCLEQ_FOREACH(var, head, field)				\
+	for ((var) = ((head)->cqh_first);				\
+		(var) != (const void *)(head);				\
+		(var) = ((var)->field.cqe_next))
+
+#define	CIRCLEQ_FOREACH_REVERSE(var, head, field)			\
+	for ((var) = ((head)->cqh_last);				\
+		(var) != (const void *)(head);				\
+		(var) = ((var)->field.cqe_prev))
+
+/*
+ * Circular queue access methods.
+ */
+#define	CIRCLEQ_EMPTY(head)		((head)->cqh_first == (void *)(head))
+#define	CIRCLEQ_FIRST(head)		((head)->cqh_first)
+#define	CIRCLEQ_LAST(head)		((head)->cqh_last)
+#define	CIRCLEQ_NEXT(elm, field)	((elm)->field.cqe_next)
+#define	CIRCLEQ_PREV(elm, field)	((elm)->field.cqe_prev)
+
+#define CIRCLEQ_LOOP_NEXT(head, elm, field)				\
+	(((elm)->field.cqe_next == (void *)(head))			\
+	    ? ((head)->cqh_first)					\
+	    : (elm->field.cqe_next))
+#define CIRCLEQ_LOOP_PREV(head, elm, field)				\
+	(((elm)->field.cqe_prev == (void *)(head))			\
+	    ? ((head)->cqh_last)					\
+	    : (elm->field.cqe_prev))
+
+#endif	/* sys/queue.h */
diff --git a/srcpkgs/rocm-opencl-runtime/patches/cmake.patch b/srcpkgs/rocm-opencl-runtime/patches/cmake.patch
new file mode 100644
index 00000000000..2c96b99d45a
--- /dev/null
+++ b/srcpkgs/rocm-opencl-runtime/patches/cmake.patch
@@ -0,0 +1,126 @@
+--- OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/CMakeLists.txt	2019-09-10 11:53:28.000000000 -0400
++++ OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/CMakeLists.txt	2020-04-16 20:16:13.481180757 -0400
+@@ -73,11 +73,11 @@
+ 
+ set (OPENCL_ICD_LOADER_HEADERS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/inc CACHE PATH "Path to OpenCL Headers")
+ 
+-add_library (OpenCL ${OPENCL_ICD_LOADER_SOURCES})
+-set_target_properties (OpenCL PROPERTIES VERSION "1.2" SOVERSION "1")
++add_library (OpenCL-ROCm ${OPENCL_ICD_LOADER_SOURCES})
++set_target_properties (OpenCL-ROCm PROPERTIES VERSION "1.2" SOVERSION "1")
+ 
+ if (WIN32)
+-    target_link_libraries (OpenCL cfgmgr32.lib)
++    target_link_libraries (OpenCL-ROCm cfgmgr32.lib)
+ 
+     option (OPENCL_ICD_LOADER_REQUIRE_WDK "Build with D3DKMT support, which requires the Windows WDK." ON)
+     if (OPENCL_ICD_LOADER_REQUIRE_WDK)
+@@ -92,10 +92,10 @@
+             get_filename_component(WDK_DIRECTORY ${LATEST_D3DKMT_HEADER} DIRECTORY)
+             get_filename_component(WDK_DIRECTORY ${WDK_DIRECTORY} DIRECTORY)
+             message(STATUS "Found the Windows WDK in: ${WDK_DIRECTORY}")
+-            target_compile_definitions(OpenCL PRIVATE OPENCL_ICD_LOADER_REQUIRE_WDK)
+-            target_include_directories(OpenCL PRIVATE ${WDK_DIRECTORY}/um)
+-            target_include_directories(OpenCL PRIVATE ${WDK_DIRECTORY}/km)
+-            target_include_directories(OpenCL PRIVATE ${WDK_DIRECTORY}/shared)
++	    target_compile_definitions(OpenCL-ROCm PRIVATE OPENCL_ICD_LOADER_REQUIRE_WDK)
++	    target_include_directories(OpenCL-ROCm PRIVATE ${WDK_DIRECTORY}/um)
++	    target_include_directories(OpenCL-ROCm PRIVATE ${WDK_DIRECTORY}/km)
++	    target_include_directories(OpenCL-ROCm PRIVATE ${WDK_DIRECTORY}/shared)
+         else()
+             message(FATAL_ERROR "The Windows WDK was not found. Consider disabling OPENCL_ICD_LOADER_REQUIRE_WDK. Aborting.")
+         endif()
+@@ -113,25 +113,25 @@
+     endif()
+ else()
+     if (APPLE)
+-        target_link_libraries (OpenCL ${CMAKE_THREAD_LIBS_INIT})
++        target_link_libraries (OpenCL-ROCm ${CMAKE_THREAD_LIBS_INIT})
+     else ()
+-        set_target_properties (OpenCL PROPERTIES LINK_FLAGS "-Wl,--version-script -Wl,${CMAKE_CURRENT_SOURCE_DIR}/loader/linux/icd_exports.map")
+-        target_link_libraries (OpenCL ${CMAKE_THREAD_LIBS_INIT})
++        set_target_properties (OpenCL-ROCm PROPERTIES LINK_FLAGS "-Wl,--version-script -Wl,${CMAKE_CURRENT_SOURCE_DIR}/loader/linux/icd_exports.map")
++	target_link_libraries (OpenCL-ROCm ${CMAKE_THREAD_LIBS_INIT})
+     endif ()
+ endif ()
+ 
+ include_directories (${OPENCL_ICD_LOADER_HEADERS_DIR})
+ add_definitions (-DCL_TARGET_OPENCL_VERSION=220)
+ 
+-target_include_directories (OpenCL PRIVATE ${CMAKE_CURRENT_BINARY_DIR} loader)
+-target_link_libraries (OpenCL ${CMAKE_DL_LIBS})
++target_include_directories (OpenCL-ROCm PRIVATE ${CMAKE_CURRENT_BINARY_DIR} loader)
++target_link_libraries (OpenCL-ROCm ${CMAKE_DL_LIBS})
+ 
+ include (CTest)
+ if (BUILD_TESTING)
+     add_subdirectory (test)
+ endif()
+ 
+-install (TARGETS OpenCL
++install (TARGETS OpenCL-ROCm
+     RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+     ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
+     LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
+--- OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/test/loader_test/CMakeLists.txt	2019-09-10 11:53:28.000000000 -0400
++++ OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/test/loader_test/CMakeLists.txt	2020-04-16 20:16:56.647026589 -0400
+@@ -12,4 +12,4 @@
+     test_clgl.c
+     test_image_objects.c )
+ 
+-target_link_libraries (icd_loader_test OpenCL IcdLog)
++target_link_libraries (icd_loader_test OpenCL-ROCm IcdLog)
+--- ROCm-OpenCL-Runtime-roc-3.3.0/CMakeLists.txt	2020-04-28 07:29:51.864446603 -0400
++++ ROCm-OpenCL-Runtime-roc-3.3.0/CMakeLists.txt	2020-04-28 07:32:45.245793180 -0400
+@@ -101,30 +101,30 @@
+ rocm_setup_version( VERSION "2.0.0" )
+ 
+ # MAIN package
+-install(PROGRAMS $<TARGET_FILE:clinfo>
+-        DESTINATION bin/x86_64
++install(PROGRAMS $<TARGET_FILE:rocm-clinfo>
++        DESTINATION bin
+         COMPONENT MAIN)
+ install(PROGRAMS $<TARGET_FILE:amdocl64>
+-        DESTINATION lib/x86_64
++        DESTINATION lib
+         COMPONENT MAIN)
+-install(PROGRAMS $<TARGET_FILE:OpenCL>
+-        DESTINATION lib/x86_64
++install(PROGRAMS $<TARGET_FILE:OpenCL-ROCm>
++        DESTINATION lib
+         COMPONENT MAIN)
+-install(PROGRAMS $<TARGET_SONAME_FILE:OpenCL>
+-        DESTINATION lib/x86_64
++install(PROGRAMS $<TARGET_SONAME_FILE:OpenCL-ROCm>
++        DESTINATION lib
+         COMPONENT MAIN)
+ 
+ # DEV package
+ install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/api/opencl/khronos/headers/opencl2.2/CL"
+-        DESTINATION include
++	DESTINATION include/rocm
+         COMPONENT DEV
+         USE_SOURCE_PERMISSIONS
+         PATTERN cl_d3d10.h EXCLUDE
+         PATTERN cl_d3d11.h EXCLUDE
+         PATTERN cl_dx9_media_sharing.h EXCLUDE
+         PATTERN cl_egl.h EXCLUDE)
+-install(PROGRAMS $<TARGET_LINKER_FILE:OpenCL>
+-        DESTINATION lib/x86_64
++install(PROGRAMS $<TARGET_LINKER_FILE:OpenCL-ROCm>
++        DESTINATION lib
+         COMPONENT DEV)
+ 
+ # Generic CPACK variables
+--- ROCm-OpenCL-Runtime-roc-3.3.0/tools/clinfo/CMakeLists.txt	2020-04-28 07:29:51.882446535 -0400
++++ ROCm-OpenCL-Runtime-roc-3.3.0/tools/clinfo/CMakeLists.txt	2020-04-28 07:30:05.627394732 -0400
+@@ -6,6 +6,6 @@
+ 
+ add_definitions(-DHAVE_CL2_HPP)
+ 
+-add_executable(clinfo clinfo.cpp)
++add_executable(rocm-clinfo clinfo.cpp)
+ 
+-target_link_libraries(clinfo OpenCL)
++target_link_libraries(rocm-clinfo OpenCL-ROCm)
diff --git a/srcpkgs/rocm-opencl-runtime/template b/srcpkgs/rocm-opencl-runtime/template
new file mode 100644
index 00000000000..f83c6e64149
--- /dev/null
+++ b/srcpkgs/rocm-opencl-runtime/template
@@ -0,0 +1,82 @@
+# Template file for 'rocm-opencl-runtime'
+pkgname=rocm-opencl-runtime
+version=3.3.0
+revision=1
+_ocl_icd_name="OpenCL-ICD-Loader"
+_ocl_icd_ver="6c03f8b58fafd9dd693eaac826749a5cfad515f8"
+archs="x86_64*"
+create_wrksrc=yes
+build_wrksrc="ROCm-OpenCL-Runtime-roc-${version}"
+build_style=cmake
+configure_args="-DUSE_COMGR_LIBRARY=yes"
+hostmakedepends="cmake pkg-config"
+makedepends="libglvnd-devel rocm-comgr-devel
+	roct-thunk-interface-devel rocr-runtime-devel"
+depends="rocm-comgr"
+short_desc="Radeon Open Compute OpenCL runtime"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="MIT"
+homepage="https://github.com/RadeonOpenCompute/ROCm-OpenCL-Runtime"
+_rocroot="https://github.com/RadeonOpenCompute"
+distfiles="${_rocroot}/ROCm-OpenCL-Runtime/archive/roc-${version}.tar.gz
+	${_rocroot}/rocm-cmake/archive/rocm-${version}.tar.gz
+	https://github.com/KhronosGroup/${_ocl_icd_name}/archive/${_ocl_icd_ver}.tar.gz"
+checksum="ac6999f1a491ab066286c2bd6adf50f08f831286f56e267879f9f7eced22f98e
+	76ed3ee8e56cf3246011cf7723c2abda539e1136e7e7f6909bfa45d268b8644f
+	c94d5bb6dc980c4d41d73e2b81663a19aabe494e923e2d0eec72a4c95b318438"
+nocross=yes
+
+post_patch() {
+	if [ "$XBPS_LIBC" = "musl" ]; then
+		# Copy sys/queue.h locally for MUSL builds
+		libelf_dir="compiler/lib/loaders/elf/utils/libelf"
+		cp "${FILESDIR}/sys_queue.h" "${libelf_dir}"
+
+		# Remove dependence on glibc
+		patch -Np0 < ${FILESDIR}/libelf-musl.patch
+		patch -Np0 < ${FILESDIR}/runtime-musl.patch
+		vsed -e '/glibc_functions.cpp/d' -i api/opencl/amdocl/CMakeLists.txt
+	fi
+}
+
+pre_configure() {
+	# ROCm requires a very specific Khronos ICD loader version in the tree
+	# Keep the ICD loader config in /etc/rocm/vendors to avoid conflicts
+	_ocl_icd_dir="${_ocl_icd_name}-${_ocl_icd_ver}"
+	ln -sf "${wrksrc}/${_ocl_icd_dir}" api/opencl/khronos/icd
+	vsed -i "${wrksrc}/${_ocl_icd_dir}/loader/icd_platform.h" \
+		-e 's@/etc/OpenCL/vendors/@/etc/rocm/vendors/@g'
+
+	# CMake modules probably not useful anywhere but for this build
+	ln -sf "${wrksrc}/rocm-cmake-rocm-${version}/share/rocm/cmake"/*.cmake cmake
+
+	# Fix the dlopen macro to point to versioned libamd_comgr shared object
+	vsed -i 'runtime/device/comgrctx.cpp' \
+		-e 's/\blibamd_comgr\(32\)\?.so\b/&.1/g'
+}
+
+post_install() {
+	vlicense License
+
+	# Create descriptor to allow the ICD loader to find the driver
+	_ocl_icd_dir="etc/rocm/vendors"
+	vmkdir "${_ocl_icd_dir}"
+	echo "libamdocl64.so" > "${DESTDIR}/${_ocl_icd_dir}/amdocl64.icd"
+}
+
+rocm-opencl-runtime-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/lib/libOpenCL-ROCm.so
+		vmove usr/include
+	}
+}
+
+rocm-opencl-runtime-clinfo_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - clinfo"
+	pkg_install() {
+		vmove usr/bin/rocm-clinfo
+	}
+}

From fe628d6265729a5b74a5ddc35208657101d48b14 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Tue, 28 Apr 2020 13:33:46 -0400
Subject: [PATCH 9/9] hashcat: add build option to support new rocm packages
 [ci skip]

---
 srcpkgs/hashcat/files/rocm.patch | 35 ++++++++++++++++++++++++++++++++
 srcpkgs/hashcat/template         | 17 +++++++++++++---
 2 files changed, 49 insertions(+), 3 deletions(-)
 create mode 100644 srcpkgs/hashcat/files/rocm.patch

diff --git a/srcpkgs/hashcat/files/rocm.patch b/srcpkgs/hashcat/files/rocm.patch
new file mode 100644
index 00000000000..5f7e4e69197
--- /dev/null
+++ b/srcpkgs/hashcat/files/rocm.patch
@@ -0,0 +1,35 @@
+diff -ur a/src/folder.c b/src/folder.c
+--- a/src/folder.c	2018-12-02 05:58:48.000000000 -0500
++++ b/src/folder.c	2020-04-28 13:22:27.340522751 -0400
+@@ -457,16 +457,6 @@
+ 
+   hcfree (cpath);
+ 
+-  //if (getenv ("TMP") == NULL)
+-  if (1)
+-  {
+-    char *tmp;
+-
+-    hc_asprintf (&tmp, "TMP=%s", cpath_real);
+-
+-    putenv (tmp);
+-  }
+-
+   #if defined (_WIN)
+ 
+   naive_replace (cpath_real, '\\', '/');
+diff -ur a/src/opencl.c b/src/opencl.c
+--- a/src/opencl.c	2018-12-02 05:58:48.000000000 -0500
++++ b/src/opencl.c	2020-04-28 13:24:12.602415333 -0400
+@@ -492,9 +492,9 @@
+ 
+   if (ocl->lib == NULL) ocl->lib = hc_dlopen ("cygOpenCL-1.dll", RTLD_NOW);
+   #else
+-  ocl->lib = hc_dlopen ("libOpenCL.so", RTLD_NOW);
++  ocl->lib = hc_dlopen ("libOpenCL-ROCm.so.1", RTLD_NOW);
+ 
+-  if (ocl->lib == NULL) ocl->lib = hc_dlopen ("libOpenCL.so.1", RTLD_NOW);
++  if (ocl->lib == NULL) ocl->lib = hc_dlopen ("libOpenCL-ROCm.so", RTLD_NOW);
+   #endif
+ 
+   if (ocl->lib == NULL)
diff --git a/srcpkgs/hashcat/template b/srcpkgs/hashcat/template
index e982f99cebf..7d3a8cb5a6b 100644
--- a/srcpkgs/hashcat/template
+++ b/srcpkgs/hashcat/template
@@ -1,15 +1,16 @@
 # Template file for 'hashcat'
 pkgname=hashcat
 version=5.1.0
-revision=2
+revision=3
 build_style=gnu-makefile
 make_build_args="PREFIX=/usr
  USE_SYSTEM_OPENCL=1 USE_SYSTEM_XXHASH=1
- DEPS_OPENCL_PATH=${XBPS_CROSS_BASE}/usr/include
+ DEPS_OPENCL_PATH=${XBPS_CROSS_BASE}/usr/include$(vopt_if rocm /rocm)
  DEPS_XXHASH_PATH=${XBPS_CROSS_BASE}/usr/include"
 make_use_env=yes
 make_install_args="$make_build_args"
-makedepends="gmp-devel opencl2-headers xxHash-devel"
+makedepends="gmp-devel xxHash-devel
+ $(vopt_if rocm rocm-opencl-runtime-devel opencl2-headers)"
 checkdepends="perl"
 short_desc="Advanced CPU-based password recovery utility"
 maintainer="Duncaen <duncaen@voidlinux.org>"
@@ -19,6 +20,9 @@ changelog="https://raw.githubusercontent.com/hashcat/hashcat/master/docs/changes
 distfiles="https://hashcat.net/files/hashcat-${version}.tar.gz"
 checksum=283beaa68e1eab41de080a58bb92349c8e47a2bb1b93d10f36ea30f418f1e338
 
+build_options="rocm"
+desc_option_rocm="Use ROCm OpenCL runtime"
+
 if [ "$XBPS_TARGET_ENDIAN" = "be" ]; then
 	broken="Not supported on big endian"
 fi
@@ -26,6 +30,13 @@ fi
 post_extract() {
 	sed '/^CC/d' -i src/Makefile
 }
+
+post_patch() {
+	if [ "$build_option_rocm" ]; then
+		patch -Np1 < ${FILESDIR}/rocm.patch
+	fi
+}
+
 post_install() {
 	rm -f ${DESTDIR}/usr/share/docs/hashcat/license.txt
 	vlicense docs/license.txt

^ permalink raw reply	[flat|nested] 61+ messages in thread

* Re: [PR PATCH] [Updated] New packages: ROCm core and OpenCL
  2020-04-19 13:34 [PR PATCH] New packages: ROCm core and OpenCL ahesford
                   ` (10 preceding siblings ...)
  2020-04-28 18:44 ` [PR PATCH] [Updated] " ahesford
@ 2020-04-28 19:59 ` ahesford
  2020-04-30 19:05 ` ahesford
                   ` (47 subsequent siblings)
  59 siblings, 0 replies; 61+ messages in thread
From: ahesford @ 2020-04-28 19:59 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 3893 bytes --]

There is an updated pull request by ahesford against master on the void-packages repository

https://github.com/ahesford/void-packages rocm
https://github.com/void-linux/void-packages/pull/21153

New packages: ROCm core and OpenCL
This PR includes several packages designed to bring the OpenCL portion of the AMD ROCm ecosystem to Void. It addresses Issue #19507. There are many other packages that AMD provides for GPGPU computing, but these can be added piecemeal as users demand.

The packages are currently only for `x86_64*`. While at least some of the packages will compile on other 64-bit architectures, I have no hardware to test. They are certainly not suitable for 32-bit architectures; some internal data structures rely on `uint64_t` values that are cast to pointers. At a
minimum, a thorough audit would be necessary to ensure that these casts are safe (e.g., that the values stored were only ever upcast from 32-bit pointers). More extensive work may be necessary to support 32-bit architectures, probably without significant benefit.

The packages successfully identify a Radeon RX 580 on an `x86_64` installation using both `clinfo` and `rocminfo` as provided. Furthermore, a version of `pyopencl` linked against these ROCm packages successfully runs a simple program that validates arithmetic on GPU-bound arrays.

There are caveats with this set of packages, almost all of which revolve around the incompatibilities between the Void-provided `ocl-icd` and the [Khronos OpenCL ICD loader](https://github.com/KhronosGroup/OpenCL-ID-Loader) required by (and built into) `rocm-opencl-runtime`.
1. All packages install into `/opt/rocm`. This keeps the environment closer to that officially sanctioned by AMD and helps avoid conflicts between other packages and those provided here. (For example, `clinfo` and the ICD loader itself.) Eventually, we may be able to move the files into `/usr`.
2. The Khronos OpenCL ICD loader built into `rocm-opencl-runtime` is an outdated, pre-release commit. If AMD can update its sources to use the release version of that loader (which has a backward-incompatible API change), we may be able to make ROCm compatible with `ocl-icd` or replace `ocl-icd` with the official Khronos loader.
3. In the meantime, to avoid `shlibs` conflicts, the OpenCL ICD loader is installed as `/opt/rocm/lib/libOpenCL-ROCm.so` (and an appropriately versioned shared library), which means that programs wishing to use the ROCm OpenCL must explicitly link against this library instead of the generic `libOpenCL.so`.
4. I do **not** recommend making any Void packages link against this specific library, because it will make those packages ROCm-only. For the time being, ROCm is intended for end-users to specifically link against. Linking Void packages against ROCm would requires the ICD loader used by ROCm be compatible with `ocl-icd`, or `ocl-icd` be replaced by the Khronos loader. However, because the Khronos loader changed its API for the release version, such a change is not yet appropriate.

Hopefully, if AMD updates its dependence on the Khronos ICD loader, we can resolve some of these caveats in the future and make ROCm a more natural Void component. For now, these packages are useful for those who need an AMD OpenCL solution and would rather custom-link software against the AMD ICD loader than hack the `amdgpu-pro` driver into an ICD compatible with `ocl-icd`.

Some patches were made to relocate some files in `/opt/rocm` and make everyting build on x86_64-musl`. Where appropriate, these patches will be pushed upstream to clean up the distribution and packaging.

Update: I pushed some new commits to update license information that triggerd an `xlint` failure. I've also disabled CI builds because they will time out on `rocm-llvm`.

A patch file from https://github.com/void-linux/void-packages/pull/21153.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-rocm-21153.patch --]
[-- Type: text/x-diff, Size: 77002 bytes --]

From 1226ae1e7c5eea64be3859bb36eee4fd8c6cccc6 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Mon, 13 Apr 2020 13:08:09 -0400
Subject: [PATCH 1/9] New package: roct-thunk-interface-3.3.0

---
 common/shlibs                                 |  1 +
 srcpkgs/roct-thunk-interface-devel            |  1 +
 .../patches/cmake-dev-libdir.patch            | 10 ++++++
 .../roct-thunk-interface/patches/musl.patch   | 29 ++++++++++++++++
 srcpkgs/roct-thunk-interface/template         | 33 +++++++++++++++++++
 5 files changed, 74 insertions(+)
 create mode 120000 srcpkgs/roct-thunk-interface-devel
 create mode 100644 srcpkgs/roct-thunk-interface/patches/cmake-dev-libdir.patch
 create mode 100644 srcpkgs/roct-thunk-interface/patches/musl.patch
 create mode 100644 srcpkgs/roct-thunk-interface/template

diff --git a/common/shlibs b/common/shlibs
index 6d39ce34c19..d89ae72ae3e 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3862,3 +3862,4 @@ libtagparser.so.9 tagparser-9.1.2_1
 libqtutilities.so.6 qtutilities-6.0.4_1
 libkdsoap.so.1.9.0 KDSoap-1.9.0_1
 libstoken.so.1 stoken-0.92_1
+libhsakmt.so.1 roct-thunk-interface-3.3.0_1
diff --git a/srcpkgs/roct-thunk-interface-devel b/srcpkgs/roct-thunk-interface-devel
new file mode 120000
index 00000000000..ac3f2cc684c
--- /dev/null
+++ b/srcpkgs/roct-thunk-interface-devel
@@ -0,0 +1 @@
+roct-thunk-interface
\ No newline at end of file
diff --git a/srcpkgs/roct-thunk-interface/patches/cmake-dev-libdir.patch b/srcpkgs/roct-thunk-interface/patches/cmake-dev-libdir.patch
new file mode 100644
index 00000000000..98c7f1e459c
--- /dev/null
+++ b/srcpkgs/roct-thunk-interface/patches/cmake-dev-libdir.patch
@@ -0,0 +1,10 @@
+--- CMakeLists.txt.old	2020-04-18 19:45:17.306081135 -0400
++++ CMakeLists.txt	2020-04-18 19:46:51.300753636 -0400
+@@ -146,6 +146,7 @@
+     COMMAND ${CMAKE_COMMAND}
+         -DSOURCE_DIR="${SOURCE_DIR}"
+         -DCMAKE_INSTALL_PREFIX="${CMAKE_INSTALL_PREFIX}"
++        -DCMAKE_INSTALL_LIBDIR="${CMAKE_INSTALL_LIBDIR}"
+         -DCPACK_RPM_PACKAGE_REQUIRES="hsakmt-roct"
+         -DCPACK_PACKAGING_INSTALL_PREFIX="${CPACK_PACKAGING_INSTALL_PREFIX}"
+         -DVERSION="${BUILD_VERSION_STRING}"
diff --git a/srcpkgs/roct-thunk-interface/patches/musl.patch b/srcpkgs/roct-thunk-interface/patches/musl.patch
new file mode 100644
index 00000000000..aeea9832411
--- /dev/null
+++ b/srcpkgs/roct-thunk-interface/patches/musl.patch
@@ -0,0 +1,29 @@
+diff -r -u old/src/libhsakmt.h new/src/libhsakmt.h
+--- src/libhsakmt.h	2020-03-04 15:00:47.000000000 -0500
++++ src/libhsakmt.h	2020-04-13 12:58:30.444865992 -0400
+@@ -54,6 +54,10 @@
+ #define CHECK_KFD_OPEN() \
+ 	do { if (kfd_open_count == 0 || hsakmt_forked) return HSAKMT_STATUS_KERNEL_IO_CHANNEL_NOT_OPENED; } while (0)
+ 
++/*On some platforms, a PAGE_SIZE macro eclipses the extern variable*/
++#ifdef PAGE_SIZE
++#undef PAGE_SIZE
++#endif
+ extern int PAGE_SIZE;
+ extern int PAGE_SHIFT;
+ 
+diff -r -u old/src/topology.c new/src/topology.c
+--- src/topology.c	2020-03-04 15:00:47.000000000 -0500
++++ src/topology.c	2020-04-13 13:01:31.209870701 -0400
+@@ -38,6 +38,11 @@
+ #include "libhsakmt.h"
+ #include "fmm.h"
+ 
++/*Needed on MUSL*/
++#ifndef MAXNAMLEN
++#define MAXNAMLEN PATH_MAX
++#endif
++
+ /* Number of memory banks added by thunk on top of topology
+  * This only includes static heaps like LDS, scratch and SVM,
+  * not for MMIO_REMAP heap. MMIO_REMAP memory bank is reported
diff --git a/srcpkgs/roct-thunk-interface/template b/srcpkgs/roct-thunk-interface/template
new file mode 100644
index 00000000000..55a1fc6074a
--- /dev/null
+++ b/srcpkgs/roct-thunk-interface/template
@@ -0,0 +1,33 @@
+# Template file for 'roct-thunk-interface'
+pkgname=roct-thunk-interface
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="ROCT-Thunk-Interface-roc-${version}"
+build_style=cmake
+make_build_target="all build-dev"
+make_install_target="install install-dev"
+hostmakedepends="cmake pkg-config"
+makedepends="pciutils-devel libnuma-devel"
+short_desc="Radeon Open Compute Thunk Interface"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="MIT"
+homepage="https://github.com/RadeonOpenCompute/ROCT-Thunk-Interface"
+distfiles="${homepage}/archive/roc-${version}.tar.gz"
+checksum=2cabe9d2cfa72031c05d11290837c476182e72d8dec2049298f691143fdd212b
+nocross=yes
+
+post_install() {
+	vlicense LICENSE.md
+}
+
+roct-thunk-interface-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove "usr/lib/*.so"
+		vmove usr/share/pkgconfig
+		vmove usr/lib/cmake
+	}
+}

From d8bb69aca8ebcd167198d858c11e7b7fa326c389 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Mon, 13 Apr 2020 15:27:27 -0400
Subject: [PATCH 2/9] New package: rocr-runtime-3.3.0

---
 common/shlibs                            |  1 +
 srcpkgs/rocr-runtime-devel               |  1 +
 srcpkgs/rocr-runtime/patches/cmake.patch | 27 +++++++++++++++++++++
 srcpkgs/rocr-runtime/template            | 30 ++++++++++++++++++++++++
 4 files changed, 59 insertions(+)
 create mode 120000 srcpkgs/rocr-runtime-devel
 create mode 100644 srcpkgs/rocr-runtime/patches/cmake.patch
 create mode 100644 srcpkgs/rocr-runtime/template

diff --git a/common/shlibs b/common/shlibs
index d89ae72ae3e..499f35752c2 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3863,3 +3863,4 @@ libqtutilities.so.6 qtutilities-6.0.4_1
 libkdsoap.so.1.9.0 KDSoap-1.9.0_1
 libstoken.so.1 stoken-0.92_1
 libhsakmt.so.1 roct-thunk-interface-3.3.0_1
+libhsa-runtime64.so.1 rocr-runtime-3.3.0_1
diff --git a/srcpkgs/rocr-runtime-devel b/srcpkgs/rocr-runtime-devel
new file mode 120000
index 00000000000..be838f22d81
--- /dev/null
+++ b/srcpkgs/rocr-runtime-devel
@@ -0,0 +1 @@
+rocr-runtime
\ No newline at end of file
diff --git a/srcpkgs/rocr-runtime/patches/cmake.patch b/srcpkgs/rocr-runtime/patches/cmake.patch
new file mode 100644
index 00000000000..93b74cd2297
--- /dev/null
+++ b/srcpkgs/rocr-runtime/patches/cmake.patch
@@ -0,0 +1,27 @@
+--- src/CMakeLists.txt.old	2020-04-18 20:01:48.549636995 -0400
++++ src/CMakeLists.txt	2020-04-18 20:04:00.177179781 -0400
+@@ -108,8 +108,8 @@
+ ## ROCr build internal versioning
+ add_definitions ( -DROCR_BUILD_ID=${PACKAGE_VERSION_STRING} )
+ 
+-## Set RUNPATH - ../../lib covers use of the legacy symlink in /hsa/lib/
+-set(CMAKE_INSTALL_RPATH "$ORIGIN;$ORIGIN/../../lib;$ORIGIN/../../lib64;$ORIGIN/../lib64")
++## Set RUNPATH
++set(CMAKE_INSTALL_RPATH "$ORIGIN;$ORIGIN/../lib")
+ 
+ ## ------------------------- Linux Compiler and Linker options -------------------------
+ set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -fexceptions -fno-rtti -fvisibility=hidden -Wno-error=sign-compare -Wno-sign-compare -Wno-write-strings -Wno-conversion-null -fno-math-errno -fno-threadsafe-statics -fmerge-all-constants -fms-extensions -Wno-error=comment -Wno-comment -Wno-error=pointer-arith -Wno-pointer-arith -Wno-error=unused-variable -Wno-error=unused-function" )
+@@ -185,11 +185,8 @@
+ add_custom_target ( hsa_lib_link2 ALL WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMAND ${CMAKE_COMMAND} -E create_symlink ../hsa/lib/${CORE_RUNTIME_LIBRARY}.so.${SO_MAJOR} ${CORE_RUNTIME_LIBRARY}-link.so.${SO_MAJOR} )
+ 
+ ## Set install information
+-install ( TARGETS ${CORE_RUNTIME_TARGET} LIBRARY DESTINATION hsa/lib )
+-install ( DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/inc/ DESTINATION hsa/include/hsa )
+-install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/hsa_include_link DESTINATION include PERMISSIONS OWNER_WRITE OWNER_READ RENAME hsa )
+-install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/${CORE_RUNTIME_LIBRARY}-link.so DESTINATION lib PERMISSIONS OWNER_WRITE OWNER_READ RENAME ${CORE_RUNTIME_LIBRARY}.so )
+-install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/${CORE_RUNTIME_LIBRARY}-link.so.${SO_MAJOR} DESTINATION lib PERMISSIONS OWNER_WRITE OWNER_READ RENAME ${CORE_RUNTIME_LIBRARY}.so.${SO_MAJOR} )
++install ( TARGETS ${CORE_RUNTIME_TARGET} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} )
++install ( DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/inc/ DESTINATION include/hsa )
+ 
+ ## Packaging directives
+ set ( CPACK_GENERATOR "DEB;RPM" CACHE STRING "Package types to build")
diff --git a/srcpkgs/rocr-runtime/template b/srcpkgs/rocr-runtime/template
new file mode 100644
index 00000000000..5ee22140f1f
--- /dev/null
+++ b/srcpkgs/rocr-runtime/template
@@ -0,0 +1,30 @@
+# Template file for 'rocr-runtime'
+pkgname=rocr-runtime
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="ROCR-Runtime-rocm-${version}"
+build_wrksrc="src"
+build_style=cmake
+hostmakedepends="cmake pkg-config"
+makedepends="roct-thunk-interface-devel elfutils-devel"
+short_desc="Radeon Open Compute HSA Runtime"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute/ROCR-Runtime"
+distfiles="${homepage}/archive/rocm-${version}.tar.gz"
+checksum=fa2d2d1f8a61d8a6952d377cf288d78c61776c3c2a666f163cafc3aa19ab0b61
+nocross=yes
+
+post_install() {
+	vlicense ../LICENSE.txt
+}
+
+rocr-runtime-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove "usr/lib/*.so"
+	}
+}

From 5991aaa587df9bdce5c93daf534974432a336acf Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Mon, 13 Apr 2020 18:07:34 -0400
Subject: [PATCH 3/9] New package: rocm-llvm-3.3.0

---
 srcpkgs/rocm-llvm/template | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)
 create mode 100644 srcpkgs/rocm-llvm/template

diff --git a/srcpkgs/rocm-llvm/template b/srcpkgs/rocm-llvm/template
new file mode 100644
index 00000000000..d6e75cd050c
--- /dev/null
+++ b/srcpkgs/rocm-llvm/template
@@ -0,0 +1,26 @@
+# Template file for 'rocm-llvm'
+pkgname=rocm-llvm
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="llvm-project-rocm-ocl-${version}"
+build_wrksrc=llvm
+build_style=cmake
+configure_args="-DCMAKE_INSTALL_PREFIX:PATH=/usr/lib/rocm-llvm
+	-DLLVM_ENABLE_PROJECTS='llvm;clang;lld' -DLLVM_TARGETS_TO_BUILD='AMDGPU'
+	-DLLVM_BUILD_DOCS=NO -DLLVM_ENABLE_OCAMLDOC=OFF
+	-DLLVM_ENABLE_SPHINX=NO -DLLVM_ENABLE_DOXYGEN=OFF
+	-DLLVM_INSTALL_UTILS=ON -DLLVM_VERSION_SUFFIX=roc -DOCAMLFIND=NO"
+hostmakedepends="cmake pkg-config python3"
+short_desc="Radeon Open Compute LLVM toolchain"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="Apache-2.0, NCSA, custom:LLVM-Exceptions"
+homepage="https://github.com/RadeonOpenCompute/llvm-project"
+distfiles="${homepage}/archive/rocm-ocl-${version}.tar.gz"
+checksum=a2bef7042e8e2f2cd8548cb246b88322e1c77188839983dcac8312d56f544dc8
+python_version=3
+nocross=yes
+
+post_install() {
+	vlicense LICENSE.TXT
+}

From 19c7a333ec5877c0e1e57ab9d1438bc0b31520a3 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Tue, 14 Apr 2020 10:25:31 -0400
Subject: [PATCH 4/9] New package: rocm-device-libs-3.3.0

---
 srcpkgs/rocm-device-libs/template | 37 +++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)
 create mode 100644 srcpkgs/rocm-device-libs/template

diff --git a/srcpkgs/rocm-device-libs/template b/srcpkgs/rocm-device-libs/template
new file mode 100644
index 00000000000..fcb4eb0d53e
--- /dev/null
+++ b/srcpkgs/rocm-device-libs/template
@@ -0,0 +1,37 @@
+# Template file for 'rocm-device-libs'
+pkgname=rocm-device-libs
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="ROCm-Device-Libs-rocm-ocl-${version}"
+build_style=cmake
+configure_args="-DLLVM_DIR:PATH=/usr/lib/rocm-llvm
+	-DCMAKE_INSTALL_LIBDIR:PATH=lib/rocm-device-libs"
+hostmakedepends="cmake rocm-llvm"
+short_desc="Radeon Open Compute device libraries"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute/ROCm-Device-Libs"
+distfiles="${homepage}/archive/rocm-ocl-${version}.tar.gz"
+checksum=706b08230790e08ca6a7a2fb7687d6131fd39a562148340e00fa37a6c06769c5
+nocross=yes
+
+pre_configure() {
+	# Put bytecodes in a lib/ subdirectory
+	vsed -i Packages.cmake -e 's@/lib/@/${CMAKE_INSTALL_LIBDIR}/@'
+	vsed -i OCL.cmake -e 's@DESTINATION lib$@DESTINATION ${CMAKE_INSTALL_LIBDIR}@'
+
+	# Build the prepare-builtins executable with native compiler
+	mkdir -p utils/build
+	cd utils/build
+	_prepare_builtins="$PWD/prepare-builtins/prepare-builtins"
+	cmake ${configure_args} ..
+	make ${makejobs}
+
+	# Add path to prepare-builtins for cmake
+	configure_args+=" -DPREPARE_BUILTINS='${_prepare_builtins}'"
+}
+
+post_install() {
+	vlicense LICENSE
+}

From 691d78f81e8346791c5556569cfa00b5b5d133ac Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Mon, 13 Apr 2020 18:30:00 -0400
Subject: [PATCH 5/9] New package: rocm-comgr-3.3.0

---
 common/shlibs               |  1 +
 srcpkgs/rocm-comgr-devel    |  1 +
 srcpkgs/rocm-comgr/template | 32 ++++++++++++++++++++++++++++++++
 3 files changed, 34 insertions(+)
 create mode 120000 srcpkgs/rocm-comgr-devel
 create mode 100644 srcpkgs/rocm-comgr/template

diff --git a/common/shlibs b/common/shlibs
index 499f35752c2..a53de3cf9e0 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3864,3 +3864,4 @@ libkdsoap.so.1.9.0 KDSoap-1.9.0_1
 libstoken.so.1 stoken-0.92_1
 libhsakmt.so.1 roct-thunk-interface-3.3.0_1
 libhsa-runtime64.so.1 rocr-runtime-3.3.0_1
+libamd_comgr.so.1 rocm-comgr-3.3.0_1
diff --git a/srcpkgs/rocm-comgr-devel b/srcpkgs/rocm-comgr-devel
new file mode 120000
index 00000000000..3f5ce255e07
--- /dev/null
+++ b/srcpkgs/rocm-comgr-devel
@@ -0,0 +1 @@
+rocm-comgr
\ No newline at end of file
diff --git a/srcpkgs/rocm-comgr/template b/srcpkgs/rocm-comgr/template
new file mode 100644
index 00000000000..c228bcd4d1f
--- /dev/null
+++ b/srcpkgs/rocm-comgr/template
@@ -0,0 +1,32 @@
+# Template file for 'rocm-comgr'
+pkgname=rocm-comgr
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="ROCm-CompilerSupport-rocm-${version}"
+build_wrksrc="lib/comgr"
+build_style=cmake
+configure_args="-DClang_DIR:PATH=/usr/lib/rocm-llvm/lib/cmake/clang"
+hostmakedepends="cmake pkg-config rocm-llvm"
+makedepends="rocm-device-libs"
+short_desc="Radeon Open Compute Code Object Manager"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="BSD-3-Clause"
+homepage="https://github.com/RadeonOpenCompute/ROCm-CompilerSupport"
+distfiles="${homepage}/archive/rocm-${version}.tar.gz"
+checksum=01e2524e0f28ecd6f46c9720f279207de935d826b0172158792aa3ec86af9ca7
+nocross=yes
+
+post_install() {
+	vlicense LICENSE.txt
+}
+
+rocm-comgr-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove "usr/lib/*.so"
+		vmove usr/lib/cmake
+	}
+}

From 34506fec471194f2746c0fca2b1a8f8de3c02f1c Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Fri, 17 Apr 2020 12:11:25 -0400
Subject: [PATCH 6/9] New package: rocminfo-3.3.0

---
 srcpkgs/rocminfo/template | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
 create mode 100644 srcpkgs/rocminfo/template

diff --git a/srcpkgs/rocminfo/template b/srcpkgs/rocminfo/template
new file mode 100644
index 00000000000..57d0640dd69
--- /dev/null
+++ b/srcpkgs/rocminfo/template
@@ -0,0 +1,22 @@
+# Template file for 'rocminfo'
+pkgname=rocminfo
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="rocminfo-rocm-${version}"
+build_style=cmake
+configure_args="-DROCM_DIR=/usr"
+hostmakedepends="cmake pkg-config"
+makedepends="rocr-runtime-devel"
+short_desc="Radeon Open Compute system information reporter"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute/rocminfo"
+distfiles="${homepage}/archive/rocm-${version}.tar.gz"
+checksum=e666f662c9e465aaabbbd0b109d87e017243cdf1a0898fabf5a90947bb3dbcd7
+nocross=yes
+python_version=3
+
+post_install() {
+	vlicense License.txt
+}

From 673ee21a6905ad3ca6877af58e936900c8d13bf1 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Sun, 19 Apr 2020 15:01:40 -0400
Subject: [PATCH 7/9] New package: rocm-bandwidth-test-3.3.0

---
 srcpkgs/rocm-bandwidth-test/template | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
 create mode 100644 srcpkgs/rocm-bandwidth-test/template

diff --git a/srcpkgs/rocm-bandwidth-test/template b/srcpkgs/rocm-bandwidth-test/template
new file mode 100644
index 00000000000..5c5058b693d
--- /dev/null
+++ b/srcpkgs/rocm-bandwidth-test/template
@@ -0,0 +1,20 @@
+# Template file for 'rocm-bandwidth-test'
+pkgname=rocm-bandwidth-test
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="rocm_bandwidth_test-rocm-${version}"
+build_style=cmake
+hostmakedepends="cmake"
+makedepends="rocr-runtime-devel roct-thunk-interface-devel"
+short_desc="Radeon Open Compute bandwidth test"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute/rocm_bandwidth_test"
+distfiles="${homepage}/archive/rocm-${version}.tar.gz"
+checksum=f5f914073018619dc91662d5bf630903dfa4db9136d603591917fdfb3c9164ce
+nocross=yes
+
+post_install() {
+	vlicense LICENSE.txt
+}

From ec070a854c6fa87db12a50b96bafa8b660569bc5 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Tue, 14 Apr 2020 10:25:54 -0400
Subject: [PATCH 8/9] New package: rocm-opencl-runtime-3.3.0

---
 common/shlibs                                 |   2 +
 srcpkgs/rocm-opencl-runtime-clinfo            |   1 +
 srcpkgs/rocm-opencl-runtime-devel             |   1 +
 .../files/libelf-musl.patch                   | 688 ++++++++++++++++++
 .../files/runtime-musl.patch                  |  11 +
 srcpkgs/rocm-opencl-runtime/files/sys_queue.h | 574 +++++++++++++++
 .../rocm-opencl-runtime/patches/cmake.patch   | 126 ++++
 srcpkgs/rocm-opencl-runtime/template          |  82 +++
 8 files changed, 1485 insertions(+)
 create mode 120000 srcpkgs/rocm-opencl-runtime-clinfo
 create mode 120000 srcpkgs/rocm-opencl-runtime-devel
 create mode 100644 srcpkgs/rocm-opencl-runtime/files/libelf-musl.patch
 create mode 100644 srcpkgs/rocm-opencl-runtime/files/runtime-musl.patch
 create mode 100644 srcpkgs/rocm-opencl-runtime/files/sys_queue.h
 create mode 100644 srcpkgs/rocm-opencl-runtime/patches/cmake.patch
 create mode 100644 srcpkgs/rocm-opencl-runtime/template

diff --git a/common/shlibs b/common/shlibs
index a53de3cf9e0..8cbc885e016 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3865,3 +3865,5 @@ libstoken.so.1 stoken-0.92_1
 libhsakmt.so.1 roct-thunk-interface-3.3.0_1
 libhsa-runtime64.so.1 rocr-runtime-3.3.0_1
 libamd_comgr.so.1 rocm-comgr-3.3.0_1
+libOpenCL-ROCm.so.1 rocm-opencl-runtime-3.3.0_1
+libamdocl64.so rocm-opencl-runtime-3.3.0_1
diff --git a/srcpkgs/rocm-opencl-runtime-clinfo b/srcpkgs/rocm-opencl-runtime-clinfo
new file mode 120000
index 00000000000..b2cda7e229d
--- /dev/null
+++ b/srcpkgs/rocm-opencl-runtime-clinfo
@@ -0,0 +1 @@
+rocm-opencl-runtime
\ No newline at end of file
diff --git a/srcpkgs/rocm-opencl-runtime-devel b/srcpkgs/rocm-opencl-runtime-devel
new file mode 120000
index 00000000000..b2cda7e229d
--- /dev/null
+++ b/srcpkgs/rocm-opencl-runtime-devel
@@ -0,0 +1 @@
+rocm-opencl-runtime
\ No newline at end of file
diff --git a/srcpkgs/rocm-opencl-runtime/files/libelf-musl.patch b/srcpkgs/rocm-opencl-runtime/files/libelf-musl.patch
new file mode 100644
index 00000000000..a3705c259a9
--- /dev/null
+++ b/srcpkgs/rocm-opencl-runtime/files/libelf-musl.patch
@@ -0,0 +1,688 @@
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/_libelf.h compiler/lib/loaders/elf/utils/libelf/_libelf.h
+--- compiler/lib/loaders/elf/utils/libelf.orig/_libelf.h	2020-04-19 08:59:34.201386585 -0400
++++ compiler/lib/loaders/elf/utils/libelf/_libelf.h	2020-04-19 09:04:12.950433528 -0400
+@@ -30,7 +30,7 @@
+ #define	__LIBELF_H_
+ 
+ #include <limits.h>
+-#include <sys/queue.h>
++#include "sys_queue.h"
+ 
+ #include "_libelf_config.h"
+ 
+@@ -179,7 +179,9 @@
+  * Function Prototypes.
+  */
+ 
+-__BEGIN_DECLS
++#ifdef __cplusplus
++extern "C" {
++#endif
+ Elf_Data *_libelf_allocate_data(Elf_Scn *_s);
+ Elf	*_libelf_allocate_elf(Elf_Mem *mem);
+ Elf_Scn	*_libelf_allocate_scn(Elf *_e, size_t _ndx);
+@@ -213,6 +215,8 @@
+ Elf_Data *_libelf_xlate(Elf_Data *_d, const Elf_Data *_s,
+     unsigned int _encoding, int _elfclass, int _direction);
+ int	_libelf_xlate_shtype(uint32_t _sht);
+-__END_DECLS
++#ifdef __cplusplus
++}
++#endif
+ 
+ #endif	/* __LIBELF_H_ */
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_begin.c compiler/lib/loaders/elf/utils/libelf/elf_begin.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_begin.c	2020-04-19 08:59:34.201386585 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_begin.c	2020-04-19 09:01:04.313212042 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <sys/types.h>
+ #if !defined(WIN32)
+ #include <sys/errno.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_end.c compiler/lib/loaders/elf/utils/libelf/elf_end.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_end.c	2020-04-19 08:59:34.201386585 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_end.c	2020-04-19 09:01:14.895204681 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #if !defined(WIN32)
+ #include <sys/mman.h>
+ #endif
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_errmsg.c compiler/lib/loaders/elf/utils/libelf/elf_errmsg.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_errmsg.c	2020-04-19 08:59:34.201386585 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_errmsg.c	2020-04-19 09:01:16.753207065 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ #include <stdio.h>
+ #include <string.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_errno.c compiler/lib/loaders/elf/utils/libelf/elf_errno.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_errno.c	2020-04-19 08:59:34.201386585 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_errno.c	2020-04-19 09:01:18.669209528 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_fill.c compiler/lib/loaders/elf/utils/libelf/elf_fill.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_fill.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_fill.c	2020-04-19 09:01:21.109212667 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_flag.c compiler/lib/loaders/elf/utils/libelf/elf_flag.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_flag.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_flag.c	2020-04-19 09:01:23.376215579 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_getarhdr.c compiler/lib/loaders/elf/utils/libelf/elf_getarhdr.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_getarhdr.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_getarhdr.c	2020-04-19 09:01:25.414218197 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_getarsym.c compiler/lib/loaders/elf/utils/libelf/elf_getarsym.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_getarsym.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_getarsym.c	2020-04-19 09:01:27.575220978 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_getbase.c compiler/lib/loaders/elf/utils/libelf/elf_getbase.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_getbase.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_getbase.c	2020-04-19 09:01:29.963224043 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_getident.c compiler/lib/loaders/elf/utils/libelf/elf_getident.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_getident.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_getident.c	2020-04-19 09:01:31.912226551 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <ar.h>
+ #include <assert.h>
+ #include <libelf.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_hash.c compiler/lib/loaders/elf/utils/libelf/elf_hash.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_hash.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_hash.c	2020-04-19 09:01:33.877229069 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ #include "_libelf_config.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_kind.c compiler/lib/loaders/elf/utils/libelf/elf_kind.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_kind.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_kind.c	2020-04-19 09:01:35.940231721 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_memory.c compiler/lib/loaders/elf/utils/libelf/elf_memory.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_memory.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_memory.c	2020-04-19 09:01:38.171234596 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <ar.h>
+ #include <libelf.h>
+ #include <string.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_next.c compiler/lib/loaders/elf/utils/libelf/elf_next.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_next.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_next.c	2020-04-19 09:01:40.063237028 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <ar.h>
+ #include <assert.h>
+ #include <libelf.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_phnum.c compiler/lib/loaders/elf/utils/libelf/elf_phnum.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_phnum.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_phnum.c	2020-04-19 09:01:42.480240134 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <ar.h>
+ #include <libelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_rand.c compiler/lib/loaders/elf/utils/libelf/elf_rand.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_rand.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_rand.c	2020-04-19 09:01:45.061243452 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <ar.h>
+ #include <libelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_rawfile.c compiler/lib/loaders/elf/utils/libelf/elf_rawfile.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_rawfile.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_rawfile.c	2020-04-19 09:01:46.988245928 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_scn.c compiler/lib/loaders/elf/utils/libelf/elf_scn.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_scn.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_scn.c	2020-04-19 09:00:19.724298403 -0400
+@@ -24,8 +24,7 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-#include <sys/queue.h>
++#include "sys_queue.h"
+ 
+ #include <assert.h>
+ #include <errno.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_shnum.c compiler/lib/loaders/elf/utils/libelf/elf_shnum.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_shnum.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_shnum.c	2020-04-19 09:01:51.763252060 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <ar.h>
+ #include <libelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_shstrndx.c compiler/lib/loaders/elf/utils/libelf/elf_shstrndx.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_shstrndx.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_shstrndx.c	2020-04-19 09:01:53.532254340 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <ar.h>
+ #include <libelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/elf_version.c compiler/lib/loaders/elf/utils/libelf/elf_version.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/elf_version.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/elf_version.c	2020-04-19 09:02:01.337264370 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf.h compiler/lib/loaders/elf/utils/libelf/gelf.h
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf.h	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf.h	2020-04-19 09:04:29.669455020 -0400
+@@ -29,8 +29,6 @@
+ #ifndef	_GELF_H_
+ #define	_GELF_H_
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ typedef Elf64_Addr	GElf_Addr;	/* Addresses */
+@@ -72,7 +70,9 @@
+ #define	GELF_ST_TYPE			ELF64_ST_TYPE
+ #define	GELF_ST_VISIBILITY		ELF64_ST_VISIBILITY
+ 
+-__BEGIN_DECLS
++#ifdef __cplusplus
++extern "C" {
++#endif
+ long		gelf_checksum(Elf *_elf);
+ size_t		gelf_fsize(Elf *_elf, Elf_Type _type, size_t _count,
+ 			unsigned int _version);
+@@ -109,6 +109,8 @@
+ int		gelf_update_move(Elf_Data *_dst, int _index, GElf_Move *_src);
+ int		gelf_update_syminfo(Elf_Data *_dst, int _index, GElf_Syminfo *_src);
+ #endif
+-__END_DECLS
++#ifdef __cplusplus
++}
++#endif
+ 
+ #endif	/* _GELF_H_ */
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_cap.c compiler/lib/loaders/elf/utils/libelf/gelf_cap.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_cap.c	2020-04-19 08:59:34.202386583 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_cap.c	2020-04-19 09:02:05.429269632 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_checksum.c compiler/lib/loaders/elf/utils/libelf/gelf_checksum.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_checksum.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_checksum.c	2020-04-19 09:02:08.192273183 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <gelf.h>
+ #include <libelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_dyn.c compiler/lib/loaders/elf/utils/libelf/gelf_dyn.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_dyn.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_dyn.c	2020-04-19 09:02:10.020275525 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_ehdr.c compiler/lib/loaders/elf/utils/libelf/gelf_ehdr.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_ehdr.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_ehdr.c	2020-04-19 09:02:11.882277926 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ #include <libelf.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_fsize.c compiler/lib/loaders/elf/utils/libelf/gelf_fsize.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_fsize.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_fsize.c	2020-04-19 09:02:14.139280827 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <gelf.h>
+ #include <libelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_getclass.c compiler/lib/loaders/elf/utils/libelf/gelf_getclass.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_getclass.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_getclass.c	2020-04-19 09:02:17.269284848 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <gelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_move.c compiler/lib/loaders/elf/utils/libelf/gelf_move.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_move.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_move.c	2020-04-19 09:02:18.974287034 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_phdr.c compiler/lib/loaders/elf/utils/libelf/gelf_phdr.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_phdr.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_phdr.c	2020-04-19 09:02:20.676289227 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <gelf.h>
+ #include <libelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_rel.c compiler/lib/loaders/elf/utils/libelf/gelf_rel.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_rel.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_rel.c	2020-04-19 09:02:23.177292435 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_rela.c compiler/lib/loaders/elf/utils/libelf/gelf_rela.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_rela.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_rela.c	2020-04-19 09:02:25.246295100 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_shdr.c compiler/lib/loaders/elf/utils/libelf/gelf_shdr.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_shdr.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_shdr.c	2020-04-19 09:02:28.325299060 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ #include <libelf.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_sym.c compiler/lib/loaders/elf/utils/libelf/gelf_sym.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_sym.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_sym.c	2020-04-19 09:02:30.113301356 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_syminfo.c compiler/lib/loaders/elf/utils/libelf/gelf_syminfo.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_syminfo.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_syminfo.c	2020-04-19 09:02:31.906303662 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_symshndx.c compiler/lib/loaders/elf/utils/libelf/gelf_symshndx.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_symshndx.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_symshndx.c	2020-04-19 09:02:33.626305873 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/gelf_xlate.c compiler/lib/loaders/elf/utils/libelf/gelf_xlate.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/gelf_xlate.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/gelf_xlate.c	2020-04-19 09:02:35.921308822 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <gelf.h>
+ #include <libelf.h>
+ #include <string.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf.h compiler/lib/loaders/elf/utils/libelf/libelf.h
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf.h	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf.h	2020-04-19 09:04:38.760466706 -0400
+@@ -30,7 +30,7 @@
+ #define	_LIBELF_H_
+ 
+ #include <sys/types.h>
+-#include <sys/queue.h>
++#include "sys_queue.h"
+ #include <elfdefinitions.h>
+ #ifndef EM_HSAIL
+ #define EM_HSAIL 0xAF5A
+@@ -187,7 +187,9 @@
+ #define	ELF_F_ARCHIVE	   0x100U /* archive creation */
+ #define	ELF_F_ARCHIVE_SYSV 0x200U /* SYSV style archive */
+ 
+-__BEGIN_DECLS
++#ifdef __cplusplus
++extern "C" {
++#endif
+ Elf		*elf_begin(int _fd, Elf_Cmd _cmd, Elf *_elf, Elf_Mem *_mem);
+ int		elf_cntl(Elf *_elf, Elf_Cmd _cmd);
+ int		elf_end(Elf *_elf);
+@@ -257,6 +259,8 @@
+ 			unsigned int _enc);
+ Elf_Data	*elf64_xlatetom(Elf_Data *_dst, const Elf_Data *_src,
+ 			unsigned int _enc);
+-__END_DECLS
++#ifdef __cplusplus
++}
++#endif
+ 
+ #endif	/* _LIBELF_H_ */
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_align.c compiler/lib/loaders/elf/utils/libelf/libelf_align.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_align.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_align.c	2020-04-19 09:02:40.660314911 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <sys/types.h>
+ 
+ #include <libelf.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_allocate.c compiler/lib/loaders/elf/utils/libelf/libelf_allocate.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_allocate.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_allocate.c	2020-04-19 09:02:43.079318019 -0400
+@@ -28,8 +28,6 @@
+  * Internal APIs
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #if !defined(WIN32)
+ #include <sys/errno.h>
+ #endif
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_ar.c compiler/lib/loaders/elf/utils/libelf/libelf_ar.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_ar.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_ar.c	2020-04-19 09:02:44.763320187 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <ctype.h>
+ #include <libelf.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_ar_util.c compiler/lib/loaders/elf/utils/libelf/libelf_ar_util.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_ar_util.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_ar_util.c	2020-04-19 09:02:46.461322369 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <libelf.h>
+ #include <stdlib.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_checksum.c compiler/lib/loaders/elf/utils/libelf/libelf_checksum.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_checksum.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_checksum.c	2020-04-19 09:02:48.645325173 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <gelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_convert.c compiler/lib/loaders/elf/utils/libelf/libelf_convert.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_convert.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_convert.c	2020-04-19 09:02:50.883328053 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <libelf.h>
+ #include <string.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_data.c compiler/lib/loaders/elf/utils/libelf/libelf_data.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_data.c	2020-04-19 08:59:34.203386581 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_data.c	2020-04-19 09:02:52.951330708 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <libelf.h>
+ 
+ #include "_libelf.h"
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_ehdr.c compiler/lib/loaders/elf/utils/libelf/libelf_ehdr.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_ehdr.c	2020-04-19 08:59:34.204386579 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_ehdr.c	2020-04-19 09:02:55.176333563 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ #include <libelf.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_extended.c compiler/lib/loaders/elf/utils/libelf/libelf_extended.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_extended.c	2020-04-19 08:59:34.204386579 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_extended.c	2020-04-19 09:02:57.932337110 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <libelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_msize.c compiler/lib/loaders/elf/utils/libelf/libelf_msize.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_msize.c	2020-04-19 08:59:34.204386579 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_msize.c	2020-04-19 09:03:02.201342598 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <libelf.h>
+ #include <string.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_phdr.c compiler/lib/loaders/elf/utils/libelf/libelf_phdr.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_phdr.c	2020-04-19 08:59:34.204386579 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_phdr.c	2020-04-19 09:03:04.194345160 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <gelf.h>
+ #include <libelf.h>
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_shdr.c compiler/lib/loaders/elf/utils/libelf/libelf_shdr.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_shdr.c	2020-04-19 08:59:34.204386579 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_shdr.c	2020-04-19 09:03:05.795347218 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <gelf.h>
+ #include <libelf.h>
+ 
+diff -u -r compiler/lib/loaders/elf/utils/libelf.orig/libelf_xlate.c compiler/lib/loaders/elf/utils/libelf/libelf_xlate.c
+--- compiler/lib/loaders/elf/utils/libelf.orig/libelf_xlate.c	2020-04-19 08:59:34.204386579 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf_xlate.c	2020-04-19 09:03:09.472351944 -0400
+@@ -24,8 +24,6 @@
+  * SUCH DAMAGE.
+  */
+ 
+-#include <sys/cdefs.h>
+-
+ #include <assert.h>
+ #include <libelf.h>
+ 
diff --git a/srcpkgs/rocm-opencl-runtime/files/runtime-musl.patch b/srcpkgs/rocm-opencl-runtime/files/runtime-musl.patch
new file mode 100644
index 00000000000..ea18e90e09c
--- /dev/null
+++ b/srcpkgs/rocm-opencl-runtime/files/runtime-musl.patch
@@ -0,0 +1,11 @@
+--- runtime/os/os_posix.cpp.orig	2020-04-19 09:13:51.701982901 -0400
++++ runtime/os/os_posix.cpp	2020-04-19 09:14:04.156947422 -0400
+@@ -44,6 +44,8 @@
+ #include <algorithm>
+ #include <mutex>
+ 
++#include <libgen.h> // for basename
++
+ 
+ namespace amd {
+ 
diff --git a/srcpkgs/rocm-opencl-runtime/files/sys_queue.h b/srcpkgs/rocm-opencl-runtime/files/sys_queue.h
new file mode 100644
index 00000000000..daf4553d33e
--- /dev/null
+++ b/srcpkgs/rocm-opencl-runtime/files/sys_queue.h
@@ -0,0 +1,574 @@
+/*
+ * Copyright (c) 1991, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *	@(#)queue.h	8.5 (Berkeley) 8/20/94
+ */
+
+#ifndef	_SYS_QUEUE_H_
+#define	_SYS_QUEUE_H_
+
+/*
+ * This file defines five types of data structures: singly-linked lists,
+ * lists, simple queues, tail queues, and circular queues.
+ *
+ * A singly-linked list is headed by a single forward pointer. The
+ * elements are singly linked for minimum space and pointer manipulation
+ * overhead at the expense of O(n) removal for arbitrary elements. New
+ * elements can be added to the list after an existing element or at the
+ * head of the list.  Elements being removed from the head of the list
+ * should use the explicit macro for this purpose for optimum
+ * efficiency. A singly-linked list may only be traversed in the forward
+ * direction.  Singly-linked lists are ideal for applications with large
+ * datasets and few or no removals or for implementing a LIFO queue.
+ *
+ * A list is headed by a single forward pointer (or an array of forward
+ * pointers for a hash table header). The elements are doubly linked
+ * so that an arbitrary element can be removed without a need to
+ * traverse the list. New elements can be added to the list before
+ * or after an existing element or at the head of the list. A list
+ * may only be traversed in the forward direction.
+ *
+ * A simple queue is headed by a pair of pointers, one the head of the
+ * list and the other to the tail of the list. The elements are singly
+ * linked to save space, so elements can only be removed from the
+ * head of the list. New elements can be added to the list after
+ * an existing element, at the head of the list, or at the end of the
+ * list. A simple queue may only be traversed in the forward direction.
+ *
+ * A tail queue is headed by a pair of pointers, one to the head of the
+ * list and the other to the tail of the list. The elements are doubly
+ * linked so that an arbitrary element can be removed without a need to
+ * traverse the list. New elements can be added to the list before or
+ * after an existing element, at the head of the list, or at the end of
+ * the list. A tail queue may be traversed in either direction.
+ *
+ * A circle queue is headed by a pair of pointers, one to the head of the
+ * list and the other to the tail of the list. The elements are doubly
+ * linked so that an arbitrary element can be removed without a need to
+ * traverse the list. New elements can be added to the list before or after
+ * an existing element, at the head of the list, or at the end of the list.
+ * A circle queue may be traversed in either direction, but has a more
+ * complex end of list detection.
+ *
+ * For details on the use of these macros, see the queue(3) manual page.
+ */
+
+/*
+ * List definitions.
+ */
+#define	LIST_HEAD(name, type)						\
+struct name {								\
+	struct type *lh_first;	/* first element */			\
+}
+
+#define	LIST_HEAD_INITIALIZER(head)					\
+	{ NULL }
+
+#define	LIST_ENTRY(type)						\
+struct {								\
+	struct type *le_next;	/* next element */			\
+	struct type **le_prev;	/* address of previous next element */	\
+}
+
+/*
+ * List functions.
+ */
+#define	LIST_INIT(head) do {						\
+	(head)->lh_first = NULL;					\
+} while (/*CONSTCOND*/0)
+
+#define	LIST_INSERT_AFTER(listelm, elm, field) do {			\
+	if (((elm)->field.le_next = (listelm)->field.le_next) != NULL)	\
+		(listelm)->field.le_next->field.le_prev =		\
+		    &(elm)->field.le_next;				\
+	(listelm)->field.le_next = (elm);				\
+	(elm)->field.le_prev = &(listelm)->field.le_next;		\
+} while (/*CONSTCOND*/0)
+
+#define	LIST_INSERT_BEFORE(listelm, elm, field) do {			\
+	(elm)->field.le_prev = (listelm)->field.le_prev;		\
+	(elm)->field.le_next = (listelm);				\
+	*(listelm)->field.le_prev = (elm);				\
+	(listelm)->field.le_prev = &(elm)->field.le_next;		\
+} while (/*CONSTCOND*/0)
+
+#define	LIST_INSERT_HEAD(head, elm, field) do {				\
+	if (((elm)->field.le_next = (head)->lh_first) != NULL)		\
+		(head)->lh_first->field.le_prev = &(elm)->field.le_next;\
+	(head)->lh_first = (elm);					\
+	(elm)->field.le_prev = &(head)->lh_first;			\
+} while (/*CONSTCOND*/0)
+
+#define	LIST_REMOVE(elm, field) do {					\
+	if ((elm)->field.le_next != NULL)				\
+		(elm)->field.le_next->field.le_prev = 			\
+		    (elm)->field.le_prev;				\
+	*(elm)->field.le_prev = (elm)->field.le_next;			\
+} while (/*CONSTCOND*/0)
+
+#define	LIST_FOREACH(var, head, field)					\
+	for ((var) = ((head)->lh_first);				\
+		(var);							\
+		(var) = ((var)->field.le_next))
+
+/*
+ * List access methods.
+ */
+#define	LIST_EMPTY(head)		((head)->lh_first == NULL)
+#define	LIST_FIRST(head)		((head)->lh_first)
+#define	LIST_NEXT(elm, field)		((elm)->field.le_next)
+
+
+/*
+ * Singly-linked List definitions.
+ */
+#define	SLIST_HEAD(name, type)						\
+struct name {								\
+	struct type *slh_first;	/* first element */			\
+}
+
+#define	SLIST_HEAD_INITIALIZER(head)					\
+	{ NULL }
+
+#define	SLIST_ENTRY(type)						\
+struct {								\
+	struct type *sle_next;	/* next element */			\
+}
+
+/*
+ * Singly-linked List functions.
+ */
+#define	SLIST_INIT(head) do {						\
+	(head)->slh_first = NULL;					\
+} while (/*CONSTCOND*/0)
+
+#define	SLIST_INSERT_AFTER(slistelm, elm, field) do {			\
+	(elm)->field.sle_next = (slistelm)->field.sle_next;		\
+	(slistelm)->field.sle_next = (elm);				\
+} while (/*CONSTCOND*/0)
+
+#define	SLIST_INSERT_HEAD(head, elm, field) do {			\
+	(elm)->field.sle_next = (head)->slh_first;			\
+	(head)->slh_first = (elm);					\
+} while (/*CONSTCOND*/0)
+
+#define	SLIST_REMOVE_HEAD(head, field) do {				\
+	(head)->slh_first = (head)->slh_first->field.sle_next;		\
+} while (/*CONSTCOND*/0)
+
+#define	SLIST_REMOVE(head, elm, type, field) do {			\
+	if ((head)->slh_first == (elm)) {				\
+		SLIST_REMOVE_HEAD((head), field);			\
+	}								\
+	else {								\
+		struct type *curelm = (head)->slh_first;		\
+		while(curelm->field.sle_next != (elm))			\
+			curelm = curelm->field.sle_next;		\
+		curelm->field.sle_next =				\
+		    curelm->field.sle_next->field.sle_next;		\
+	}								\
+} while (/*CONSTCOND*/0)
+
+#define	SLIST_FOREACH(var, head, field)					\
+	for((var) = (head)->slh_first; (var); (var) = (var)->field.sle_next)
+
+/*
+ * Singly-linked List access methods.
+ */
+#define	SLIST_EMPTY(head)	((head)->slh_first == NULL)
+#define	SLIST_FIRST(head)	((head)->slh_first)
+#define	SLIST_NEXT(elm, field)	((elm)->field.sle_next)
+
+
+/*
+ * Singly-linked Tail queue declarations.
+ */
+#define	STAILQ_HEAD(name, type)					\
+struct name {								\
+	struct type *stqh_first;	/* first element */			\
+	struct type **stqh_last;	/* addr of last next element */		\
+}
+
+#define	STAILQ_HEAD_INITIALIZER(head)					\
+	{ NULL, &(head).stqh_first }
+
+#define	STAILQ_ENTRY(type)						\
+struct {								\
+	struct type *stqe_next;	/* next element */			\
+}
+
+/*
+ * Singly-linked Tail queue functions.
+ */
+#define	STAILQ_INIT(head) do {						\
+	(head)->stqh_first = NULL;					\
+	(head)->stqh_last = &(head)->stqh_first;				\
+} while (/*CONSTCOND*/0)
+
+#define	STAILQ_INSERT_HEAD(head, elm, field) do {			\
+	if (((elm)->field.stqe_next = (head)->stqh_first) == NULL)	\
+		(head)->stqh_last = &(elm)->field.stqe_next;		\
+	(head)->stqh_first = (elm);					\
+} while (/*CONSTCOND*/0)
+
+#define	STAILQ_INSERT_TAIL(head, elm, field) do {			\
+	(elm)->field.stqe_next = NULL;					\
+	*(head)->stqh_last = (elm);					\
+	(head)->stqh_last = &(elm)->field.stqe_next;			\
+} while (/*CONSTCOND*/0)
+
+#define	STAILQ_INSERT_AFTER(head, listelm, elm, field) do {		\
+	if (((elm)->field.stqe_next = (listelm)->field.stqe_next) == NULL)\
+		(head)->stqh_last = &(elm)->field.stqe_next;		\
+	(listelm)->field.stqe_next = (elm);				\
+} while (/*CONSTCOND*/0)
+
+#define	STAILQ_REMOVE_HEAD(head, field) do {				\
+	if (((head)->stqh_first = (head)->stqh_first->field.stqe_next) == NULL) \
+		(head)->stqh_last = &(head)->stqh_first;			\
+} while (/*CONSTCOND*/0)
+
+#define	STAILQ_REMOVE(head, elm, type, field) do {			\
+	if ((head)->stqh_first == (elm)) {				\
+		STAILQ_REMOVE_HEAD((head), field);			\
+	} else {							\
+		struct type *curelm = (head)->stqh_first;		\
+		while (curelm->field.stqe_next != (elm))			\
+			curelm = curelm->field.stqe_next;		\
+		if ((curelm->field.stqe_next =				\
+			curelm->field.stqe_next->field.stqe_next) == NULL) \
+			    (head)->stqh_last = &(curelm)->field.stqe_next; \
+	}								\
+} while (/*CONSTCOND*/0)
+
+#define	STAILQ_FOREACH(var, head, field)				\
+	for ((var) = ((head)->stqh_first);				\
+		(var);							\
+		(var) = ((var)->field.stqe_next))
+
+#define	STAILQ_CONCAT(head1, head2) do {				\
+	if (!STAILQ_EMPTY((head2))) {					\
+		*(head1)->stqh_last = (head2)->stqh_first;		\
+		(head1)->stqh_last = (head2)->stqh_last;		\
+		STAILQ_INIT((head2));					\
+	}								\
+} while (/*CONSTCOND*/0)
+
+/*
+ * Singly-linked Tail queue access methods.
+ */
+#define	STAILQ_EMPTY(head)	((head)->stqh_first == NULL)
+#define	STAILQ_FIRST(head)	((head)->stqh_first)
+#define	STAILQ_NEXT(elm, field)	((elm)->field.stqe_next)
+
+
+/*
+ * Simple queue definitions.
+ */
+#define	SIMPLEQ_HEAD(name, type)					\
+struct name {								\
+	struct type *sqh_first;	/* first element */			\
+	struct type **sqh_last;	/* addr of last next element */		\
+}
+
+#define	SIMPLEQ_HEAD_INITIALIZER(head)					\
+	{ NULL, &(head).sqh_first }
+
+#define	SIMPLEQ_ENTRY(type)						\
+struct {								\
+	struct type *sqe_next;	/* next element */			\
+}
+
+/*
+ * Simple queue functions.
+ */
+#define	SIMPLEQ_INIT(head) do {						\
+	(head)->sqh_first = NULL;					\
+	(head)->sqh_last = &(head)->sqh_first;				\
+} while (/*CONSTCOND*/0)
+
+#define	SIMPLEQ_INSERT_HEAD(head, elm, field) do {			\
+	if (((elm)->field.sqe_next = (head)->sqh_first) == NULL)	\
+		(head)->sqh_last = &(elm)->field.sqe_next;		\
+	(head)->sqh_first = (elm);					\
+} while (/*CONSTCOND*/0)
+
+#define	SIMPLEQ_INSERT_TAIL(head, elm, field) do {			\
+	(elm)->field.sqe_next = NULL;					\
+	*(head)->sqh_last = (elm);					\
+	(head)->sqh_last = &(elm)->field.sqe_next;			\
+} while (/*CONSTCOND*/0)
+
+#define	SIMPLEQ_INSERT_AFTER(head, listelm, elm, field) do {		\
+	if (((elm)->field.sqe_next = (listelm)->field.sqe_next) == NULL)\
+		(head)->sqh_last = &(elm)->field.sqe_next;		\
+	(listelm)->field.sqe_next = (elm);				\
+} while (/*CONSTCOND*/0)
+
+#define	SIMPLEQ_REMOVE_HEAD(head, field) do {				\
+	if (((head)->sqh_first = (head)->sqh_first->field.sqe_next) == NULL) \
+		(head)->sqh_last = &(head)->sqh_first;			\
+} while (/*CONSTCOND*/0)
+
+#define	SIMPLEQ_REMOVE(head, elm, type, field) do {			\
+	if ((head)->sqh_first == (elm)) {				\
+		SIMPLEQ_REMOVE_HEAD((head), field);			\
+	} else {							\
+		struct type *curelm = (head)->sqh_first;		\
+		while (curelm->field.sqe_next != (elm))			\
+			curelm = curelm->field.sqe_next;		\
+		if ((curelm->field.sqe_next =				\
+			curelm->field.sqe_next->field.sqe_next) == NULL) \
+			    (head)->sqh_last = &(curelm)->field.sqe_next; \
+	}								\
+} while (/*CONSTCOND*/0)
+
+#define	SIMPLEQ_FOREACH(var, head, field)				\
+	for ((var) = ((head)->sqh_first);				\
+		(var);							\
+		(var) = ((var)->field.sqe_next))
+
+/*
+ * Simple queue access methods.
+ */
+#define	SIMPLEQ_EMPTY(head)		((head)->sqh_first == NULL)
+#define	SIMPLEQ_FIRST(head)		((head)->sqh_first)
+#define	SIMPLEQ_NEXT(elm, field)	((elm)->field.sqe_next)
+
+
+/*
+ * Tail queue definitions.
+ */
+#define	_TAILQ_HEAD(name, type, qual)					\
+struct name {								\
+	qual type *tqh_first;		/* first element */		\
+	qual type *qual *tqh_last;	/* addr of last next element */	\
+}
+#define TAILQ_HEAD(name, type)	_TAILQ_HEAD(name, struct type,)
+
+#define	TAILQ_HEAD_INITIALIZER(head)					\
+	{ NULL, &(head).tqh_first }
+
+#define	_TAILQ_ENTRY(type, qual)					\
+struct {								\
+	qual type *tqe_next;		/* next element */		\
+	qual type *qual *tqe_prev;	/* address of previous next element */\
+}
+#define TAILQ_ENTRY(type)	_TAILQ_ENTRY(struct type,)
+
+/*
+ * Tail queue functions.
+ */
+#define	TAILQ_INIT(head) do {						\
+	(head)->tqh_first = NULL;					\
+	(head)->tqh_last = &(head)->tqh_first;				\
+} while (/*CONSTCOND*/0)
+
+#define	TAILQ_INSERT_HEAD(head, elm, field) do {			\
+	if (((elm)->field.tqe_next = (head)->tqh_first) != NULL)	\
+		(head)->tqh_first->field.tqe_prev =			\
+		    &(elm)->field.tqe_next;				\
+	else								\
+		(head)->tqh_last = &(elm)->field.tqe_next;		\
+	(head)->tqh_first = (elm);					\
+	(elm)->field.tqe_prev = &(head)->tqh_first;			\
+} while (/*CONSTCOND*/0)
+
+#define	TAILQ_INSERT_TAIL(head, elm, field) do {			\
+	(elm)->field.tqe_next = NULL;					\
+	(elm)->field.tqe_prev = (head)->tqh_last;			\
+	*(head)->tqh_last = (elm);					\
+	(head)->tqh_last = &(elm)->field.tqe_next;			\
+} while (/*CONSTCOND*/0)
+
+#define	TAILQ_INSERT_AFTER(head, listelm, elm, field) do {		\
+	if (((elm)->field.tqe_next = (listelm)->field.tqe_next) != NULL)\
+		(elm)->field.tqe_next->field.tqe_prev = 		\
+		    &(elm)->field.tqe_next;				\
+	else								\
+		(head)->tqh_last = &(elm)->field.tqe_next;		\
+	(listelm)->field.tqe_next = (elm);				\
+	(elm)->field.tqe_prev = &(listelm)->field.tqe_next;		\
+} while (/*CONSTCOND*/0)
+
+#define	TAILQ_INSERT_BEFORE(listelm, elm, field) do {			\
+	(elm)->field.tqe_prev = (listelm)->field.tqe_prev;		\
+	(elm)->field.tqe_next = (listelm);				\
+	*(listelm)->field.tqe_prev = (elm);				\
+	(listelm)->field.tqe_prev = &(elm)->field.tqe_next;		\
+} while (/*CONSTCOND*/0)
+
+#define	TAILQ_REMOVE(head, elm, field) do {				\
+	if (((elm)->field.tqe_next) != NULL)				\
+		(elm)->field.tqe_next->field.tqe_prev = 		\
+		    (elm)->field.tqe_prev;				\
+	else								\
+		(head)->tqh_last = (elm)->field.tqe_prev;		\
+	*(elm)->field.tqe_prev = (elm)->field.tqe_next;			\
+} while (/*CONSTCOND*/0)
+
+#define	TAILQ_FOREACH(var, head, field)					\
+	for ((var) = ((head)->tqh_first);				\
+		(var);							\
+		(var) = ((var)->field.tqe_next))
+
+#define	TAILQ_FOREACH_REVERSE(var, head, headname, field)		\
+	for ((var) = (*(((struct headname *)((head)->tqh_last))->tqh_last));	\
+		(var);							\
+		(var) = (*(((struct headname *)((var)->field.tqe_prev))->tqh_last)))
+
+#define	TAILQ_CONCAT(head1, head2, field) do {				\
+	if (!TAILQ_EMPTY(head2)) {					\
+		*(head1)->tqh_last = (head2)->tqh_first;		\
+		(head2)->tqh_first->field.tqe_prev = (head1)->tqh_last;	\
+		(head1)->tqh_last = (head2)->tqh_last;			\
+		TAILQ_INIT((head2));					\
+	}								\
+} while (/*CONSTCOND*/0)
+
+/*
+ * Tail queue access methods.
+ */
+#define	TAILQ_EMPTY(head)		((head)->tqh_first == NULL)
+#define	TAILQ_FIRST(head)		((head)->tqh_first)
+#define	TAILQ_NEXT(elm, field)		((elm)->field.tqe_next)
+
+#define	TAILQ_LAST(head, headname) \
+	(*(((struct headname *)((head)->tqh_last))->tqh_last))
+#define	TAILQ_PREV(elm, headname, field) \
+	(*(((struct headname *)((elm)->field.tqe_prev))->tqh_last))
+
+
+/*
+ * Circular queue definitions.
+ */
+#define	CIRCLEQ_HEAD(name, type)					\
+struct name {								\
+	struct type *cqh_first;		/* first element */		\
+	struct type *cqh_last;		/* last element */		\
+}
+
+#define	CIRCLEQ_HEAD_INITIALIZER(head)					\
+	{ (void *)&head, (void *)&head }
+
+#define	CIRCLEQ_ENTRY(type)						\
+struct {								\
+	struct type *cqe_next;		/* next element */		\
+	struct type *cqe_prev;		/* previous element */		\
+}
+
+/*
+ * Circular queue functions.
+ */
+#define	CIRCLEQ_INIT(head) do {						\
+	(head)->cqh_first = (void *)(head);				\
+	(head)->cqh_last = (void *)(head);				\
+} while (/*CONSTCOND*/0)
+
+#define	CIRCLEQ_INSERT_AFTER(head, listelm, elm, field) do {		\
+	(elm)->field.cqe_next = (listelm)->field.cqe_next;		\
+	(elm)->field.cqe_prev = (listelm);				\
+	if ((listelm)->field.cqe_next == (void *)(head))		\
+		(head)->cqh_last = (elm);				\
+	else								\
+		(listelm)->field.cqe_next->field.cqe_prev = (elm);	\
+	(listelm)->field.cqe_next = (elm);				\
+} while (/*CONSTCOND*/0)
+
+#define	CIRCLEQ_INSERT_BEFORE(head, listelm, elm, field) do {		\
+	(elm)->field.cqe_next = (listelm);				\
+	(elm)->field.cqe_prev = (listelm)->field.cqe_prev;		\
+	if ((listelm)->field.cqe_prev == (void *)(head))		\
+		(head)->cqh_first = (elm);				\
+	else								\
+		(listelm)->field.cqe_prev->field.cqe_next = (elm);	\
+	(listelm)->field.cqe_prev = (elm);				\
+} while (/*CONSTCOND*/0)
+
+#define	CIRCLEQ_INSERT_HEAD(head, elm, field) do {			\
+	(elm)->field.cqe_next = (head)->cqh_first;			\
+	(elm)->field.cqe_prev = (void *)(head);				\
+	if ((head)->cqh_last == (void *)(head))				\
+		(head)->cqh_last = (elm);				\
+	else								\
+		(head)->cqh_first->field.cqe_prev = (elm);		\
+	(head)->cqh_first = (elm);					\
+} while (/*CONSTCOND*/0)
+
+#define	CIRCLEQ_INSERT_TAIL(head, elm, field) do {			\
+	(elm)->field.cqe_next = (void *)(head);				\
+	(elm)->field.cqe_prev = (head)->cqh_last;			\
+	if ((head)->cqh_first == (void *)(head))			\
+		(head)->cqh_first = (elm);				\
+	else								\
+		(head)->cqh_last->field.cqe_next = (elm);		\
+	(head)->cqh_last = (elm);					\
+} while (/*CONSTCOND*/0)
+
+#define	CIRCLEQ_REMOVE(head, elm, field) do {				\
+	if ((elm)->field.cqe_next == (void *)(head))			\
+		(head)->cqh_last = (elm)->field.cqe_prev;		\
+	else								\
+		(elm)->field.cqe_next->field.cqe_prev =			\
+		    (elm)->field.cqe_prev;				\
+	if ((elm)->field.cqe_prev == (void *)(head))			\
+		(head)->cqh_first = (elm)->field.cqe_next;		\
+	else								\
+		(elm)->field.cqe_prev->field.cqe_next =			\
+		    (elm)->field.cqe_next;				\
+} while (/*CONSTCOND*/0)
+
+#define	CIRCLEQ_FOREACH(var, head, field)				\
+	for ((var) = ((head)->cqh_first);				\
+		(var) != (const void *)(head);				\
+		(var) = ((var)->field.cqe_next))
+
+#define	CIRCLEQ_FOREACH_REVERSE(var, head, field)			\
+	for ((var) = ((head)->cqh_last);				\
+		(var) != (const void *)(head);				\
+		(var) = ((var)->field.cqe_prev))
+
+/*
+ * Circular queue access methods.
+ */
+#define	CIRCLEQ_EMPTY(head)		((head)->cqh_first == (void *)(head))
+#define	CIRCLEQ_FIRST(head)		((head)->cqh_first)
+#define	CIRCLEQ_LAST(head)		((head)->cqh_last)
+#define	CIRCLEQ_NEXT(elm, field)	((elm)->field.cqe_next)
+#define	CIRCLEQ_PREV(elm, field)	((elm)->field.cqe_prev)
+
+#define CIRCLEQ_LOOP_NEXT(head, elm, field)				\
+	(((elm)->field.cqe_next == (void *)(head))			\
+	    ? ((head)->cqh_first)					\
+	    : (elm->field.cqe_next))
+#define CIRCLEQ_LOOP_PREV(head, elm, field)				\
+	(((elm)->field.cqe_prev == (void *)(head))			\
+	    ? ((head)->cqh_last)					\
+	    : (elm->field.cqe_prev))
+
+#endif	/* sys/queue.h */
diff --git a/srcpkgs/rocm-opencl-runtime/patches/cmake.patch b/srcpkgs/rocm-opencl-runtime/patches/cmake.patch
new file mode 100644
index 00000000000..2c96b99d45a
--- /dev/null
+++ b/srcpkgs/rocm-opencl-runtime/patches/cmake.patch
@@ -0,0 +1,126 @@
+--- OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/CMakeLists.txt	2019-09-10 11:53:28.000000000 -0400
++++ OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/CMakeLists.txt	2020-04-16 20:16:13.481180757 -0400
+@@ -73,11 +73,11 @@
+ 
+ set (OPENCL_ICD_LOADER_HEADERS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/inc CACHE PATH "Path to OpenCL Headers")
+ 
+-add_library (OpenCL ${OPENCL_ICD_LOADER_SOURCES})
+-set_target_properties (OpenCL PROPERTIES VERSION "1.2" SOVERSION "1")
++add_library (OpenCL-ROCm ${OPENCL_ICD_LOADER_SOURCES})
++set_target_properties (OpenCL-ROCm PROPERTIES VERSION "1.2" SOVERSION "1")
+ 
+ if (WIN32)
+-    target_link_libraries (OpenCL cfgmgr32.lib)
++    target_link_libraries (OpenCL-ROCm cfgmgr32.lib)
+ 
+     option (OPENCL_ICD_LOADER_REQUIRE_WDK "Build with D3DKMT support, which requires the Windows WDK." ON)
+     if (OPENCL_ICD_LOADER_REQUIRE_WDK)
+@@ -92,10 +92,10 @@
+             get_filename_component(WDK_DIRECTORY ${LATEST_D3DKMT_HEADER} DIRECTORY)
+             get_filename_component(WDK_DIRECTORY ${WDK_DIRECTORY} DIRECTORY)
+             message(STATUS "Found the Windows WDK in: ${WDK_DIRECTORY}")
+-            target_compile_definitions(OpenCL PRIVATE OPENCL_ICD_LOADER_REQUIRE_WDK)
+-            target_include_directories(OpenCL PRIVATE ${WDK_DIRECTORY}/um)
+-            target_include_directories(OpenCL PRIVATE ${WDK_DIRECTORY}/km)
+-            target_include_directories(OpenCL PRIVATE ${WDK_DIRECTORY}/shared)
++	    target_compile_definitions(OpenCL-ROCm PRIVATE OPENCL_ICD_LOADER_REQUIRE_WDK)
++	    target_include_directories(OpenCL-ROCm PRIVATE ${WDK_DIRECTORY}/um)
++	    target_include_directories(OpenCL-ROCm PRIVATE ${WDK_DIRECTORY}/km)
++	    target_include_directories(OpenCL-ROCm PRIVATE ${WDK_DIRECTORY}/shared)
+         else()
+             message(FATAL_ERROR "The Windows WDK was not found. Consider disabling OPENCL_ICD_LOADER_REQUIRE_WDK. Aborting.")
+         endif()
+@@ -113,25 +113,25 @@
+     endif()
+ else()
+     if (APPLE)
+-        target_link_libraries (OpenCL ${CMAKE_THREAD_LIBS_INIT})
++        target_link_libraries (OpenCL-ROCm ${CMAKE_THREAD_LIBS_INIT})
+     else ()
+-        set_target_properties (OpenCL PROPERTIES LINK_FLAGS "-Wl,--version-script -Wl,${CMAKE_CURRENT_SOURCE_DIR}/loader/linux/icd_exports.map")
+-        target_link_libraries (OpenCL ${CMAKE_THREAD_LIBS_INIT})
++        set_target_properties (OpenCL-ROCm PROPERTIES LINK_FLAGS "-Wl,--version-script -Wl,${CMAKE_CURRENT_SOURCE_DIR}/loader/linux/icd_exports.map")
++	target_link_libraries (OpenCL-ROCm ${CMAKE_THREAD_LIBS_INIT})
+     endif ()
+ endif ()
+ 
+ include_directories (${OPENCL_ICD_LOADER_HEADERS_DIR})
+ add_definitions (-DCL_TARGET_OPENCL_VERSION=220)
+ 
+-target_include_directories (OpenCL PRIVATE ${CMAKE_CURRENT_BINARY_DIR} loader)
+-target_link_libraries (OpenCL ${CMAKE_DL_LIBS})
++target_include_directories (OpenCL-ROCm PRIVATE ${CMAKE_CURRENT_BINARY_DIR} loader)
++target_link_libraries (OpenCL-ROCm ${CMAKE_DL_LIBS})
+ 
+ include (CTest)
+ if (BUILD_TESTING)
+     add_subdirectory (test)
+ endif()
+ 
+-install (TARGETS OpenCL
++install (TARGETS OpenCL-ROCm
+     RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+     ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
+     LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
+--- OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/test/loader_test/CMakeLists.txt	2019-09-10 11:53:28.000000000 -0400
++++ OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/test/loader_test/CMakeLists.txt	2020-04-16 20:16:56.647026589 -0400
+@@ -12,4 +12,4 @@
+     test_clgl.c
+     test_image_objects.c )
+ 
+-target_link_libraries (icd_loader_test OpenCL IcdLog)
++target_link_libraries (icd_loader_test OpenCL-ROCm IcdLog)
+--- ROCm-OpenCL-Runtime-roc-3.3.0/CMakeLists.txt	2020-04-28 07:29:51.864446603 -0400
++++ ROCm-OpenCL-Runtime-roc-3.3.0/CMakeLists.txt	2020-04-28 07:32:45.245793180 -0400
+@@ -101,30 +101,30 @@
+ rocm_setup_version( VERSION "2.0.0" )
+ 
+ # MAIN package
+-install(PROGRAMS $<TARGET_FILE:clinfo>
+-        DESTINATION bin/x86_64
++install(PROGRAMS $<TARGET_FILE:rocm-clinfo>
++        DESTINATION bin
+         COMPONENT MAIN)
+ install(PROGRAMS $<TARGET_FILE:amdocl64>
+-        DESTINATION lib/x86_64
++        DESTINATION lib
+         COMPONENT MAIN)
+-install(PROGRAMS $<TARGET_FILE:OpenCL>
+-        DESTINATION lib/x86_64
++install(PROGRAMS $<TARGET_FILE:OpenCL-ROCm>
++        DESTINATION lib
+         COMPONENT MAIN)
+-install(PROGRAMS $<TARGET_SONAME_FILE:OpenCL>
+-        DESTINATION lib/x86_64
++install(PROGRAMS $<TARGET_SONAME_FILE:OpenCL-ROCm>
++        DESTINATION lib
+         COMPONENT MAIN)
+ 
+ # DEV package
+ install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/api/opencl/khronos/headers/opencl2.2/CL"
+-        DESTINATION include
++	DESTINATION include/rocm
+         COMPONENT DEV
+         USE_SOURCE_PERMISSIONS
+         PATTERN cl_d3d10.h EXCLUDE
+         PATTERN cl_d3d11.h EXCLUDE
+         PATTERN cl_dx9_media_sharing.h EXCLUDE
+         PATTERN cl_egl.h EXCLUDE)
+-install(PROGRAMS $<TARGET_LINKER_FILE:OpenCL>
+-        DESTINATION lib/x86_64
++install(PROGRAMS $<TARGET_LINKER_FILE:OpenCL-ROCm>
++        DESTINATION lib
+         COMPONENT DEV)
+ 
+ # Generic CPACK variables
+--- ROCm-OpenCL-Runtime-roc-3.3.0/tools/clinfo/CMakeLists.txt	2020-04-28 07:29:51.882446535 -0400
++++ ROCm-OpenCL-Runtime-roc-3.3.0/tools/clinfo/CMakeLists.txt	2020-04-28 07:30:05.627394732 -0400
+@@ -6,6 +6,6 @@
+ 
+ add_definitions(-DHAVE_CL2_HPP)
+ 
+-add_executable(clinfo clinfo.cpp)
++add_executable(rocm-clinfo clinfo.cpp)
+ 
+-target_link_libraries(clinfo OpenCL)
++target_link_libraries(rocm-clinfo OpenCL-ROCm)
diff --git a/srcpkgs/rocm-opencl-runtime/template b/srcpkgs/rocm-opencl-runtime/template
new file mode 100644
index 00000000000..f83c6e64149
--- /dev/null
+++ b/srcpkgs/rocm-opencl-runtime/template
@@ -0,0 +1,82 @@
+# Template file for 'rocm-opencl-runtime'
+pkgname=rocm-opencl-runtime
+version=3.3.0
+revision=1
+_ocl_icd_name="OpenCL-ICD-Loader"
+_ocl_icd_ver="6c03f8b58fafd9dd693eaac826749a5cfad515f8"
+archs="x86_64*"
+create_wrksrc=yes
+build_wrksrc="ROCm-OpenCL-Runtime-roc-${version}"
+build_style=cmake
+configure_args="-DUSE_COMGR_LIBRARY=yes"
+hostmakedepends="cmake pkg-config"
+makedepends="libglvnd-devel rocm-comgr-devel
+	roct-thunk-interface-devel rocr-runtime-devel"
+depends="rocm-comgr"
+short_desc="Radeon Open Compute OpenCL runtime"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="MIT"
+homepage="https://github.com/RadeonOpenCompute/ROCm-OpenCL-Runtime"
+_rocroot="https://github.com/RadeonOpenCompute"
+distfiles="${_rocroot}/ROCm-OpenCL-Runtime/archive/roc-${version}.tar.gz
+	${_rocroot}/rocm-cmake/archive/rocm-${version}.tar.gz
+	https://github.com/KhronosGroup/${_ocl_icd_name}/archive/${_ocl_icd_ver}.tar.gz"
+checksum="ac6999f1a491ab066286c2bd6adf50f08f831286f56e267879f9f7eced22f98e
+	76ed3ee8e56cf3246011cf7723c2abda539e1136e7e7f6909bfa45d268b8644f
+	c94d5bb6dc980c4d41d73e2b81663a19aabe494e923e2d0eec72a4c95b318438"
+nocross=yes
+
+post_patch() {
+	if [ "$XBPS_LIBC" = "musl" ]; then
+		# Copy sys/queue.h locally for MUSL builds
+		libelf_dir="compiler/lib/loaders/elf/utils/libelf"
+		cp "${FILESDIR}/sys_queue.h" "${libelf_dir}"
+
+		# Remove dependence on glibc
+		patch -Np0 < ${FILESDIR}/libelf-musl.patch
+		patch -Np0 < ${FILESDIR}/runtime-musl.patch
+		vsed -e '/glibc_functions.cpp/d' -i api/opencl/amdocl/CMakeLists.txt
+	fi
+}
+
+pre_configure() {
+	# ROCm requires a very specific Khronos ICD loader version in the tree
+	# Keep the ICD loader config in /etc/rocm/vendors to avoid conflicts
+	_ocl_icd_dir="${_ocl_icd_name}-${_ocl_icd_ver}"
+	ln -sf "${wrksrc}/${_ocl_icd_dir}" api/opencl/khronos/icd
+	vsed -i "${wrksrc}/${_ocl_icd_dir}/loader/icd_platform.h" \
+		-e 's@/etc/OpenCL/vendors/@/etc/rocm/vendors/@g'
+
+	# CMake modules probably not useful anywhere but for this build
+	ln -sf "${wrksrc}/rocm-cmake-rocm-${version}/share/rocm/cmake"/*.cmake cmake
+
+	# Fix the dlopen macro to point to versioned libamd_comgr shared object
+	vsed -i 'runtime/device/comgrctx.cpp' \
+		-e 's/\blibamd_comgr\(32\)\?.so\b/&.1/g'
+}
+
+post_install() {
+	vlicense License
+
+	# Create descriptor to allow the ICD loader to find the driver
+	_ocl_icd_dir="etc/rocm/vendors"
+	vmkdir "${_ocl_icd_dir}"
+	echo "libamdocl64.so" > "${DESTDIR}/${_ocl_icd_dir}/amdocl64.icd"
+}
+
+rocm-opencl-runtime-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/lib/libOpenCL-ROCm.so
+		vmove usr/include
+	}
+}
+
+rocm-opencl-runtime-clinfo_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - clinfo"
+	pkg_install() {
+		vmove usr/bin/rocm-clinfo
+	}
+}

From fe628d6265729a5b74a5ddc35208657101d48b14 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Tue, 28 Apr 2020 13:33:46 -0400
Subject: [PATCH 9/9] hashcat: add build option to support new rocm packages
 [ci skip]

---
 srcpkgs/hashcat/files/rocm.patch | 35 ++++++++++++++++++++++++++++++++
 srcpkgs/hashcat/template         | 17 +++++++++++++---
 2 files changed, 49 insertions(+), 3 deletions(-)
 create mode 100644 srcpkgs/hashcat/files/rocm.patch

diff --git a/srcpkgs/hashcat/files/rocm.patch b/srcpkgs/hashcat/files/rocm.patch
new file mode 100644
index 00000000000..5f7e4e69197
--- /dev/null
+++ b/srcpkgs/hashcat/files/rocm.patch
@@ -0,0 +1,35 @@
+diff -ur a/src/folder.c b/src/folder.c
+--- a/src/folder.c	2018-12-02 05:58:48.000000000 -0500
++++ b/src/folder.c	2020-04-28 13:22:27.340522751 -0400
+@@ -457,16 +457,6 @@
+ 
+   hcfree (cpath);
+ 
+-  //if (getenv ("TMP") == NULL)
+-  if (1)
+-  {
+-    char *tmp;
+-
+-    hc_asprintf (&tmp, "TMP=%s", cpath_real);
+-
+-    putenv (tmp);
+-  }
+-
+   #if defined (_WIN)
+ 
+   naive_replace (cpath_real, '\\', '/');
+diff -ur a/src/opencl.c b/src/opencl.c
+--- a/src/opencl.c	2018-12-02 05:58:48.000000000 -0500
++++ b/src/opencl.c	2020-04-28 13:24:12.602415333 -0400
+@@ -492,9 +492,9 @@
+ 
+   if (ocl->lib == NULL) ocl->lib = hc_dlopen ("cygOpenCL-1.dll", RTLD_NOW);
+   #else
+-  ocl->lib = hc_dlopen ("libOpenCL.so", RTLD_NOW);
++  ocl->lib = hc_dlopen ("libOpenCL-ROCm.so.1", RTLD_NOW);
+ 
+-  if (ocl->lib == NULL) ocl->lib = hc_dlopen ("libOpenCL.so.1", RTLD_NOW);
++  if (ocl->lib == NULL) ocl->lib = hc_dlopen ("libOpenCL-ROCm.so", RTLD_NOW);
+   #endif
+ 
+   if (ocl->lib == NULL)
diff --git a/srcpkgs/hashcat/template b/srcpkgs/hashcat/template
index e982f99cebf..7d3a8cb5a6b 100644
--- a/srcpkgs/hashcat/template
+++ b/srcpkgs/hashcat/template
@@ -1,15 +1,16 @@
 # Template file for 'hashcat'
 pkgname=hashcat
 version=5.1.0
-revision=2
+revision=3
 build_style=gnu-makefile
 make_build_args="PREFIX=/usr
  USE_SYSTEM_OPENCL=1 USE_SYSTEM_XXHASH=1
- DEPS_OPENCL_PATH=${XBPS_CROSS_BASE}/usr/include
+ DEPS_OPENCL_PATH=${XBPS_CROSS_BASE}/usr/include$(vopt_if rocm /rocm)
  DEPS_XXHASH_PATH=${XBPS_CROSS_BASE}/usr/include"
 make_use_env=yes
 make_install_args="$make_build_args"
-makedepends="gmp-devel opencl2-headers xxHash-devel"
+makedepends="gmp-devel xxHash-devel
+ $(vopt_if rocm rocm-opencl-runtime-devel opencl2-headers)"
 checkdepends="perl"
 short_desc="Advanced CPU-based password recovery utility"
 maintainer="Duncaen <duncaen@voidlinux.org>"
@@ -19,6 +20,9 @@ changelog="https://raw.githubusercontent.com/hashcat/hashcat/master/docs/changes
 distfiles="https://hashcat.net/files/hashcat-${version}.tar.gz"
 checksum=283beaa68e1eab41de080a58bb92349c8e47a2bb1b93d10f36ea30f418f1e338
 
+build_options="rocm"
+desc_option_rocm="Use ROCm OpenCL runtime"
+
 if [ "$XBPS_TARGET_ENDIAN" = "be" ]; then
 	broken="Not supported on big endian"
 fi
@@ -26,6 +30,13 @@ fi
 post_extract() {
 	sed '/^CC/d' -i src/Makefile
 }
+
+post_patch() {
+	if [ "$build_option_rocm" ]; then
+		patch -Np1 < ${FILESDIR}/rocm.patch
+	fi
+}
+
 post_install() {
 	rm -f ${DESTDIR}/usr/share/docs/hashcat/license.txt
 	vlicense docs/license.txt

^ permalink raw reply	[flat|nested] 61+ messages in thread

* Re: [PR PATCH] [Updated] New packages: ROCm core and OpenCL
  2020-04-19 13:34 [PR PATCH] New packages: ROCm core and OpenCL ahesford
                   ` (11 preceding siblings ...)
  2020-04-28 19:59 ` ahesford
@ 2020-04-30 19:05 ` ahesford
  2020-04-30 19:12 ` ahesford
                   ` (46 subsequent siblings)
  59 siblings, 0 replies; 61+ messages in thread
From: ahesford @ 2020-04-30 19:05 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 3893 bytes --]

There is an updated pull request by ahesford against master on the void-packages repository

https://github.com/ahesford/void-packages rocm
https://github.com/void-linux/void-packages/pull/21153

New packages: ROCm core and OpenCL
This PR includes several packages designed to bring the OpenCL portion of the AMD ROCm ecosystem to Void. It addresses Issue #19507. There are many other packages that AMD provides for GPGPU computing, but these can be added piecemeal as users demand.

The packages are currently only for `x86_64*`. While at least some of the packages will compile on other 64-bit architectures, I have no hardware to test. They are certainly not suitable for 32-bit architectures; some internal data structures rely on `uint64_t` values that are cast to pointers. At a
minimum, a thorough audit would be necessary to ensure that these casts are safe (e.g., that the values stored were only ever upcast from 32-bit pointers). More extensive work may be necessary to support 32-bit architectures, probably without significant benefit.

The packages successfully identify a Radeon RX 580 on an `x86_64` installation using both `clinfo` and `rocminfo` as provided. Furthermore, a version of `pyopencl` linked against these ROCm packages successfully runs a simple program that validates arithmetic on GPU-bound arrays.

There are caveats with this set of packages, almost all of which revolve around the incompatibilities between the Void-provided `ocl-icd` and the [Khronos OpenCL ICD loader](https://github.com/KhronosGroup/OpenCL-ID-Loader) required by (and built into) `rocm-opencl-runtime`.
1. All packages install into `/opt/rocm`. This keeps the environment closer to that officially sanctioned by AMD and helps avoid conflicts between other packages and those provided here. (For example, `clinfo` and the ICD loader itself.) Eventually, we may be able to move the files into `/usr`.
2. The Khronos OpenCL ICD loader built into `rocm-opencl-runtime` is an outdated, pre-release commit. If AMD can update its sources to use the release version of that loader (which has a backward-incompatible API change), we may be able to make ROCm compatible with `ocl-icd` or replace `ocl-icd` with the official Khronos loader.
3. In the meantime, to avoid `shlibs` conflicts, the OpenCL ICD loader is installed as `/opt/rocm/lib/libOpenCL-ROCm.so` (and an appropriately versioned shared library), which means that programs wishing to use the ROCm OpenCL must explicitly link against this library instead of the generic `libOpenCL.so`.
4. I do **not** recommend making any Void packages link against this specific library, because it will make those packages ROCm-only. For the time being, ROCm is intended for end-users to specifically link against. Linking Void packages against ROCm would requires the ICD loader used by ROCm be compatible with `ocl-icd`, or `ocl-icd` be replaced by the Khronos loader. However, because the Khronos loader changed its API for the release version, such a change is not yet appropriate.

Hopefully, if AMD updates its dependence on the Khronos ICD loader, we can resolve some of these caveats in the future and make ROCm a more natural Void component. For now, these packages are useful for those who need an AMD OpenCL solution and would rather custom-link software against the AMD ICD loader than hack the `amdgpu-pro` driver into an ICD compatible with `ocl-icd`.

Some patches were made to relocate some files in `/opt/rocm` and make everyting build on x86_64-musl`. Where appropriate, these patches will be pushed upstream to clean up the distribution and packaging.

Update: I pushed some new commits to update license information that triggerd an `xlint` failure. I've also disabled CI builds because they will time out on `rocm-llvm`.

A patch file from https://github.com/void-linux/void-packages/pull/21153.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-rocm-21153.patch --]
[-- Type: text/x-diff, Size: 35783 bytes --]

From 1226ae1e7c5eea64be3859bb36eee4fd8c6cccc6 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Mon, 13 Apr 2020 13:08:09 -0400
Subject: [PATCH 01/10] New package: roct-thunk-interface-3.3.0

---
 common/shlibs                                 |  1 +
 srcpkgs/roct-thunk-interface-devel            |  1 +
 .../patches/cmake-dev-libdir.patch            | 10 ++++++
 .../roct-thunk-interface/patches/musl.patch   | 29 ++++++++++++++++
 srcpkgs/roct-thunk-interface/template         | 33 +++++++++++++++++++
 5 files changed, 74 insertions(+)
 create mode 120000 srcpkgs/roct-thunk-interface-devel
 create mode 100644 srcpkgs/roct-thunk-interface/patches/cmake-dev-libdir.patch
 create mode 100644 srcpkgs/roct-thunk-interface/patches/musl.patch
 create mode 100644 srcpkgs/roct-thunk-interface/template

diff --git a/common/shlibs b/common/shlibs
index 6d39ce34c19..d89ae72ae3e 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3862,3 +3862,4 @@ libtagparser.so.9 tagparser-9.1.2_1
 libqtutilities.so.6 qtutilities-6.0.4_1
 libkdsoap.so.1.9.0 KDSoap-1.9.0_1
 libstoken.so.1 stoken-0.92_1
+libhsakmt.so.1 roct-thunk-interface-3.3.0_1
diff --git a/srcpkgs/roct-thunk-interface-devel b/srcpkgs/roct-thunk-interface-devel
new file mode 120000
index 00000000000..ac3f2cc684c
--- /dev/null
+++ b/srcpkgs/roct-thunk-interface-devel
@@ -0,0 +1 @@
+roct-thunk-interface
\ No newline at end of file
diff --git a/srcpkgs/roct-thunk-interface/patches/cmake-dev-libdir.patch b/srcpkgs/roct-thunk-interface/patches/cmake-dev-libdir.patch
new file mode 100644
index 00000000000..98c7f1e459c
--- /dev/null
+++ b/srcpkgs/roct-thunk-interface/patches/cmake-dev-libdir.patch
@@ -0,0 +1,10 @@
+--- CMakeLists.txt.old	2020-04-18 19:45:17.306081135 -0400
++++ CMakeLists.txt	2020-04-18 19:46:51.300753636 -0400
+@@ -146,6 +146,7 @@
+     COMMAND ${CMAKE_COMMAND}
+         -DSOURCE_DIR="${SOURCE_DIR}"
+         -DCMAKE_INSTALL_PREFIX="${CMAKE_INSTALL_PREFIX}"
++        -DCMAKE_INSTALL_LIBDIR="${CMAKE_INSTALL_LIBDIR}"
+         -DCPACK_RPM_PACKAGE_REQUIRES="hsakmt-roct"
+         -DCPACK_PACKAGING_INSTALL_PREFIX="${CPACK_PACKAGING_INSTALL_PREFIX}"
+         -DVERSION="${BUILD_VERSION_STRING}"
diff --git a/srcpkgs/roct-thunk-interface/patches/musl.patch b/srcpkgs/roct-thunk-interface/patches/musl.patch
new file mode 100644
index 00000000000..aeea9832411
--- /dev/null
+++ b/srcpkgs/roct-thunk-interface/patches/musl.patch
@@ -0,0 +1,29 @@
+diff -r -u old/src/libhsakmt.h new/src/libhsakmt.h
+--- src/libhsakmt.h	2020-03-04 15:00:47.000000000 -0500
++++ src/libhsakmt.h	2020-04-13 12:58:30.444865992 -0400
+@@ -54,6 +54,10 @@
+ #define CHECK_KFD_OPEN() \
+ 	do { if (kfd_open_count == 0 || hsakmt_forked) return HSAKMT_STATUS_KERNEL_IO_CHANNEL_NOT_OPENED; } while (0)
+ 
++/*On some platforms, a PAGE_SIZE macro eclipses the extern variable*/
++#ifdef PAGE_SIZE
++#undef PAGE_SIZE
++#endif
+ extern int PAGE_SIZE;
+ extern int PAGE_SHIFT;
+ 
+diff -r -u old/src/topology.c new/src/topology.c
+--- src/topology.c	2020-03-04 15:00:47.000000000 -0500
++++ src/topology.c	2020-04-13 13:01:31.209870701 -0400
+@@ -38,6 +38,11 @@
+ #include "libhsakmt.h"
+ #include "fmm.h"
+ 
++/*Needed on MUSL*/
++#ifndef MAXNAMLEN
++#define MAXNAMLEN PATH_MAX
++#endif
++
+ /* Number of memory banks added by thunk on top of topology
+  * This only includes static heaps like LDS, scratch and SVM,
+  * not for MMIO_REMAP heap. MMIO_REMAP memory bank is reported
diff --git a/srcpkgs/roct-thunk-interface/template b/srcpkgs/roct-thunk-interface/template
new file mode 100644
index 00000000000..55a1fc6074a
--- /dev/null
+++ b/srcpkgs/roct-thunk-interface/template
@@ -0,0 +1,33 @@
+# Template file for 'roct-thunk-interface'
+pkgname=roct-thunk-interface
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="ROCT-Thunk-Interface-roc-${version}"
+build_style=cmake
+make_build_target="all build-dev"
+make_install_target="install install-dev"
+hostmakedepends="cmake pkg-config"
+makedepends="pciutils-devel libnuma-devel"
+short_desc="Radeon Open Compute Thunk Interface"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="MIT"
+homepage="https://github.com/RadeonOpenCompute/ROCT-Thunk-Interface"
+distfiles="${homepage}/archive/roc-${version}.tar.gz"
+checksum=2cabe9d2cfa72031c05d11290837c476182e72d8dec2049298f691143fdd212b
+nocross=yes
+
+post_install() {
+	vlicense LICENSE.md
+}
+
+roct-thunk-interface-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove "usr/lib/*.so"
+		vmove usr/share/pkgconfig
+		vmove usr/lib/cmake
+	}
+}

From d8bb69aca8ebcd167198d858c11e7b7fa326c389 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Mon, 13 Apr 2020 15:27:27 -0400
Subject: [PATCH 02/10] New package: rocr-runtime-3.3.0

---
 common/shlibs                            |  1 +
 srcpkgs/rocr-runtime-devel               |  1 +
 srcpkgs/rocr-runtime/patches/cmake.patch | 27 +++++++++++++++++++++
 srcpkgs/rocr-runtime/template            | 30 ++++++++++++++++++++++++
 4 files changed, 59 insertions(+)
 create mode 120000 srcpkgs/rocr-runtime-devel
 create mode 100644 srcpkgs/rocr-runtime/patches/cmake.patch
 create mode 100644 srcpkgs/rocr-runtime/template

diff --git a/common/shlibs b/common/shlibs
index d89ae72ae3e..499f35752c2 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3863,3 +3863,4 @@ libqtutilities.so.6 qtutilities-6.0.4_1
 libkdsoap.so.1.9.0 KDSoap-1.9.0_1
 libstoken.so.1 stoken-0.92_1
 libhsakmt.so.1 roct-thunk-interface-3.3.0_1
+libhsa-runtime64.so.1 rocr-runtime-3.3.0_1
diff --git a/srcpkgs/rocr-runtime-devel b/srcpkgs/rocr-runtime-devel
new file mode 120000
index 00000000000..be838f22d81
--- /dev/null
+++ b/srcpkgs/rocr-runtime-devel
@@ -0,0 +1 @@
+rocr-runtime
\ No newline at end of file
diff --git a/srcpkgs/rocr-runtime/patches/cmake.patch b/srcpkgs/rocr-runtime/patches/cmake.patch
new file mode 100644
index 00000000000..93b74cd2297
--- /dev/null
+++ b/srcpkgs/rocr-runtime/patches/cmake.patch
@@ -0,0 +1,27 @@
+--- src/CMakeLists.txt.old	2020-04-18 20:01:48.549636995 -0400
++++ src/CMakeLists.txt	2020-04-18 20:04:00.177179781 -0400
+@@ -108,8 +108,8 @@
+ ## ROCr build internal versioning
+ add_definitions ( -DROCR_BUILD_ID=${PACKAGE_VERSION_STRING} )
+ 
+-## Set RUNPATH - ../../lib covers use of the legacy symlink in /hsa/lib/
+-set(CMAKE_INSTALL_RPATH "$ORIGIN;$ORIGIN/../../lib;$ORIGIN/../../lib64;$ORIGIN/../lib64")
++## Set RUNPATH
++set(CMAKE_INSTALL_RPATH "$ORIGIN;$ORIGIN/../lib")
+ 
+ ## ------------------------- Linux Compiler and Linker options -------------------------
+ set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -fexceptions -fno-rtti -fvisibility=hidden -Wno-error=sign-compare -Wno-sign-compare -Wno-write-strings -Wno-conversion-null -fno-math-errno -fno-threadsafe-statics -fmerge-all-constants -fms-extensions -Wno-error=comment -Wno-comment -Wno-error=pointer-arith -Wno-pointer-arith -Wno-error=unused-variable -Wno-error=unused-function" )
+@@ -185,11 +185,8 @@
+ add_custom_target ( hsa_lib_link2 ALL WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMAND ${CMAKE_COMMAND} -E create_symlink ../hsa/lib/${CORE_RUNTIME_LIBRARY}.so.${SO_MAJOR} ${CORE_RUNTIME_LIBRARY}-link.so.${SO_MAJOR} )
+ 
+ ## Set install information
+-install ( TARGETS ${CORE_RUNTIME_TARGET} LIBRARY DESTINATION hsa/lib )
+-install ( DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/inc/ DESTINATION hsa/include/hsa )
+-install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/hsa_include_link DESTINATION include PERMISSIONS OWNER_WRITE OWNER_READ RENAME hsa )
+-install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/${CORE_RUNTIME_LIBRARY}-link.so DESTINATION lib PERMISSIONS OWNER_WRITE OWNER_READ RENAME ${CORE_RUNTIME_LIBRARY}.so )
+-install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/${CORE_RUNTIME_LIBRARY}-link.so.${SO_MAJOR} DESTINATION lib PERMISSIONS OWNER_WRITE OWNER_READ RENAME ${CORE_RUNTIME_LIBRARY}.so.${SO_MAJOR} )
++install ( TARGETS ${CORE_RUNTIME_TARGET} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} )
++install ( DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/inc/ DESTINATION include/hsa )
+ 
+ ## Packaging directives
+ set ( CPACK_GENERATOR "DEB;RPM" CACHE STRING "Package types to build")
diff --git a/srcpkgs/rocr-runtime/template b/srcpkgs/rocr-runtime/template
new file mode 100644
index 00000000000..5ee22140f1f
--- /dev/null
+++ b/srcpkgs/rocr-runtime/template
@@ -0,0 +1,30 @@
+# Template file for 'rocr-runtime'
+pkgname=rocr-runtime
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="ROCR-Runtime-rocm-${version}"
+build_wrksrc="src"
+build_style=cmake
+hostmakedepends="cmake pkg-config"
+makedepends="roct-thunk-interface-devel elfutils-devel"
+short_desc="Radeon Open Compute HSA Runtime"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute/ROCR-Runtime"
+distfiles="${homepage}/archive/rocm-${version}.tar.gz"
+checksum=fa2d2d1f8a61d8a6952d377cf288d78c61776c3c2a666f163cafc3aa19ab0b61
+nocross=yes
+
+post_install() {
+	vlicense ../LICENSE.txt
+}
+
+rocr-runtime-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove "usr/lib/*.so"
+	}
+}

From 5991aaa587df9bdce5c93daf534974432a336acf Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Mon, 13 Apr 2020 18:07:34 -0400
Subject: [PATCH 03/10] New package: rocm-llvm-3.3.0

---
 srcpkgs/rocm-llvm/template | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)
 create mode 100644 srcpkgs/rocm-llvm/template

diff --git a/srcpkgs/rocm-llvm/template b/srcpkgs/rocm-llvm/template
new file mode 100644
index 00000000000..d6e75cd050c
--- /dev/null
+++ b/srcpkgs/rocm-llvm/template
@@ -0,0 +1,26 @@
+# Template file for 'rocm-llvm'
+pkgname=rocm-llvm
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="llvm-project-rocm-ocl-${version}"
+build_wrksrc=llvm
+build_style=cmake
+configure_args="-DCMAKE_INSTALL_PREFIX:PATH=/usr/lib/rocm-llvm
+	-DLLVM_ENABLE_PROJECTS='llvm;clang;lld' -DLLVM_TARGETS_TO_BUILD='AMDGPU'
+	-DLLVM_BUILD_DOCS=NO -DLLVM_ENABLE_OCAMLDOC=OFF
+	-DLLVM_ENABLE_SPHINX=NO -DLLVM_ENABLE_DOXYGEN=OFF
+	-DLLVM_INSTALL_UTILS=ON -DLLVM_VERSION_SUFFIX=roc -DOCAMLFIND=NO"
+hostmakedepends="cmake pkg-config python3"
+short_desc="Radeon Open Compute LLVM toolchain"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="Apache-2.0, NCSA, custom:LLVM-Exceptions"
+homepage="https://github.com/RadeonOpenCompute/llvm-project"
+distfiles="${homepage}/archive/rocm-ocl-${version}.tar.gz"
+checksum=a2bef7042e8e2f2cd8548cb246b88322e1c77188839983dcac8312d56f544dc8
+python_version=3
+nocross=yes
+
+post_install() {
+	vlicense LICENSE.TXT
+}

From 19c7a333ec5877c0e1e57ab9d1438bc0b31520a3 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Tue, 14 Apr 2020 10:25:31 -0400
Subject: [PATCH 04/10] New package: rocm-device-libs-3.3.0

---
 srcpkgs/rocm-device-libs/template | 37 +++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)
 create mode 100644 srcpkgs/rocm-device-libs/template

diff --git a/srcpkgs/rocm-device-libs/template b/srcpkgs/rocm-device-libs/template
new file mode 100644
index 00000000000..fcb4eb0d53e
--- /dev/null
+++ b/srcpkgs/rocm-device-libs/template
@@ -0,0 +1,37 @@
+# Template file for 'rocm-device-libs'
+pkgname=rocm-device-libs
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="ROCm-Device-Libs-rocm-ocl-${version}"
+build_style=cmake
+configure_args="-DLLVM_DIR:PATH=/usr/lib/rocm-llvm
+	-DCMAKE_INSTALL_LIBDIR:PATH=lib/rocm-device-libs"
+hostmakedepends="cmake rocm-llvm"
+short_desc="Radeon Open Compute device libraries"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute/ROCm-Device-Libs"
+distfiles="${homepage}/archive/rocm-ocl-${version}.tar.gz"
+checksum=706b08230790e08ca6a7a2fb7687d6131fd39a562148340e00fa37a6c06769c5
+nocross=yes
+
+pre_configure() {
+	# Put bytecodes in a lib/ subdirectory
+	vsed -i Packages.cmake -e 's@/lib/@/${CMAKE_INSTALL_LIBDIR}/@'
+	vsed -i OCL.cmake -e 's@DESTINATION lib$@DESTINATION ${CMAKE_INSTALL_LIBDIR}@'
+
+	# Build the prepare-builtins executable with native compiler
+	mkdir -p utils/build
+	cd utils/build
+	_prepare_builtins="$PWD/prepare-builtins/prepare-builtins"
+	cmake ${configure_args} ..
+	make ${makejobs}
+
+	# Add path to prepare-builtins for cmake
+	configure_args+=" -DPREPARE_BUILTINS='${_prepare_builtins}'"
+}
+
+post_install() {
+	vlicense LICENSE
+}

From 691d78f81e8346791c5556569cfa00b5b5d133ac Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Mon, 13 Apr 2020 18:30:00 -0400
Subject: [PATCH 05/10] New package: rocm-comgr-3.3.0

---
 common/shlibs               |  1 +
 srcpkgs/rocm-comgr-devel    |  1 +
 srcpkgs/rocm-comgr/template | 32 ++++++++++++++++++++++++++++++++
 3 files changed, 34 insertions(+)
 create mode 120000 srcpkgs/rocm-comgr-devel
 create mode 100644 srcpkgs/rocm-comgr/template

diff --git a/common/shlibs b/common/shlibs
index 499f35752c2..a53de3cf9e0 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3864,3 +3864,4 @@ libkdsoap.so.1.9.0 KDSoap-1.9.0_1
 libstoken.so.1 stoken-0.92_1
 libhsakmt.so.1 roct-thunk-interface-3.3.0_1
 libhsa-runtime64.so.1 rocr-runtime-3.3.0_1
+libamd_comgr.so.1 rocm-comgr-3.3.0_1
diff --git a/srcpkgs/rocm-comgr-devel b/srcpkgs/rocm-comgr-devel
new file mode 120000
index 00000000000..3f5ce255e07
--- /dev/null
+++ b/srcpkgs/rocm-comgr-devel
@@ -0,0 +1 @@
+rocm-comgr
\ No newline at end of file
diff --git a/srcpkgs/rocm-comgr/template b/srcpkgs/rocm-comgr/template
new file mode 100644
index 00000000000..c228bcd4d1f
--- /dev/null
+++ b/srcpkgs/rocm-comgr/template
@@ -0,0 +1,32 @@
+# Template file for 'rocm-comgr'
+pkgname=rocm-comgr
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="ROCm-CompilerSupport-rocm-${version}"
+build_wrksrc="lib/comgr"
+build_style=cmake
+configure_args="-DClang_DIR:PATH=/usr/lib/rocm-llvm/lib/cmake/clang"
+hostmakedepends="cmake pkg-config rocm-llvm"
+makedepends="rocm-device-libs"
+short_desc="Radeon Open Compute Code Object Manager"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="BSD-3-Clause"
+homepage="https://github.com/RadeonOpenCompute/ROCm-CompilerSupport"
+distfiles="${homepage}/archive/rocm-${version}.tar.gz"
+checksum=01e2524e0f28ecd6f46c9720f279207de935d826b0172158792aa3ec86af9ca7
+nocross=yes
+
+post_install() {
+	vlicense LICENSE.txt
+}
+
+rocm-comgr-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove "usr/lib/*.so"
+		vmove usr/lib/cmake
+	}
+}

From 34506fec471194f2746c0fca2b1a8f8de3c02f1c Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Fri, 17 Apr 2020 12:11:25 -0400
Subject: [PATCH 06/10] New package: rocminfo-3.3.0

---
 srcpkgs/rocminfo/template | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
 create mode 100644 srcpkgs/rocminfo/template

diff --git a/srcpkgs/rocminfo/template b/srcpkgs/rocminfo/template
new file mode 100644
index 00000000000..57d0640dd69
--- /dev/null
+++ b/srcpkgs/rocminfo/template
@@ -0,0 +1,22 @@
+# Template file for 'rocminfo'
+pkgname=rocminfo
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="rocminfo-rocm-${version}"
+build_style=cmake
+configure_args="-DROCM_DIR=/usr"
+hostmakedepends="cmake pkg-config"
+makedepends="rocr-runtime-devel"
+short_desc="Radeon Open Compute system information reporter"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute/rocminfo"
+distfiles="${homepage}/archive/rocm-${version}.tar.gz"
+checksum=e666f662c9e465aaabbbd0b109d87e017243cdf1a0898fabf5a90947bb3dbcd7
+nocross=yes
+python_version=3
+
+post_install() {
+	vlicense License.txt
+}

From 673ee21a6905ad3ca6877af58e936900c8d13bf1 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Sun, 19 Apr 2020 15:01:40 -0400
Subject: [PATCH 07/10] New package: rocm-bandwidth-test-3.3.0

---
 srcpkgs/rocm-bandwidth-test/template | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
 create mode 100644 srcpkgs/rocm-bandwidth-test/template

diff --git a/srcpkgs/rocm-bandwidth-test/template b/srcpkgs/rocm-bandwidth-test/template
new file mode 100644
index 00000000000..5c5058b693d
--- /dev/null
+++ b/srcpkgs/rocm-bandwidth-test/template
@@ -0,0 +1,20 @@
+# Template file for 'rocm-bandwidth-test'
+pkgname=rocm-bandwidth-test
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="rocm_bandwidth_test-rocm-${version}"
+build_style=cmake
+hostmakedepends="cmake"
+makedepends="rocr-runtime-devel roct-thunk-interface-devel"
+short_desc="Radeon Open Compute bandwidth test"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute/rocm_bandwidth_test"
+distfiles="${homepage}/archive/rocm-${version}.tar.gz"
+checksum=f5f914073018619dc91662d5bf630903dfa4db9136d603591917fdfb3c9164ce
+nocross=yes
+
+post_install() {
+	vlicense LICENSE.txt
+}

From 8880063d1e46a22e487bc193b63a08a7e7fc3d6d Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Tue, 14 Apr 2020 10:25:54 -0400
Subject: [PATCH 08/10] New package: rocm-opencl-runtime-3.3.0

---
 common/shlibs                                 |   2 +
 srcpkgs/rocm-opencl-runtime-clinfo            |   1 +
 srcpkgs/rocm-opencl-runtime-devel             |   1 +
 .../files/libelf-musl.patch                   |  21 +++
 .../files/runtime-musl.patch                  |  11 ++
 .../rocm-opencl-runtime/patches/cmake.patch   | 126 ++++++++++++++++++
 srcpkgs/rocm-opencl-runtime/template          |  83 ++++++++++++
 7 files changed, 245 insertions(+)
 create mode 120000 srcpkgs/rocm-opencl-runtime-clinfo
 create mode 120000 srcpkgs/rocm-opencl-runtime-devel
 create mode 100644 srcpkgs/rocm-opencl-runtime/files/libelf-musl.patch
 create mode 100644 srcpkgs/rocm-opencl-runtime/files/runtime-musl.patch
 create mode 100644 srcpkgs/rocm-opencl-runtime/patches/cmake.patch
 create mode 100644 srcpkgs/rocm-opencl-runtime/template

diff --git a/common/shlibs b/common/shlibs
index a53de3cf9e0..8cbc885e016 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3865,3 +3865,5 @@ libstoken.so.1 stoken-0.92_1
 libhsakmt.so.1 roct-thunk-interface-3.3.0_1
 libhsa-runtime64.so.1 rocr-runtime-3.3.0_1
 libamd_comgr.so.1 rocm-comgr-3.3.0_1
+libOpenCL-ROCm.so.1 rocm-opencl-runtime-3.3.0_1
+libamdocl64.so rocm-opencl-runtime-3.3.0_1
diff --git a/srcpkgs/rocm-opencl-runtime-clinfo b/srcpkgs/rocm-opencl-runtime-clinfo
new file mode 120000
index 00000000000..b2cda7e229d
--- /dev/null
+++ b/srcpkgs/rocm-opencl-runtime-clinfo
@@ -0,0 +1 @@
+rocm-opencl-runtime
\ No newline at end of file
diff --git a/srcpkgs/rocm-opencl-runtime-devel b/srcpkgs/rocm-opencl-runtime-devel
new file mode 120000
index 00000000000..b2cda7e229d
--- /dev/null
+++ b/srcpkgs/rocm-opencl-runtime-devel
@@ -0,0 +1 @@
+rocm-opencl-runtime
\ No newline at end of file
diff --git a/srcpkgs/rocm-opencl-runtime/files/libelf-musl.patch b/srcpkgs/rocm-opencl-runtime/files/libelf-musl.patch
new file mode 100644
index 00000000000..29469a9a351
--- /dev/null
+++ b/srcpkgs/rocm-opencl-runtime/files/libelf-musl.patch
@@ -0,0 +1,21 @@
+--- compiler/lib/loaders/elf/utils/libelf/_libelf.h	2020-04-28 15:50:53.243438174 -0400
++++ compiler/lib/loaders/elf/utils/libelf/_libelf.h	2020-04-28 15:51:54.293435415 -0400
+@@ -35,6 +35,7 @@
+ #include "_libelf_config.h"
+ 
+ #include "_elftc.h"
++#include <sys/cdefs.h>
+ 
+ /*
+  * Library-private data structures.
+--- compiler/lib/loaders/elf/utils/libelf/libelf.h	2020-04-28 15:50:53.244438174 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf.h	2020-04-28 15:52:12.375434593 -0400
+@@ -36,6 +36,8 @@
+ #define EM_HSAIL 0xAF5A
+ #endif
+ 
++#include <sys/cdefs.h>
++
+ /* Library private data structures */
+ typedef struct _Elf Elf;
+ typedef struct _Elf_Scn Elf_Scn;
diff --git a/srcpkgs/rocm-opencl-runtime/files/runtime-musl.patch b/srcpkgs/rocm-opencl-runtime/files/runtime-musl.patch
new file mode 100644
index 00000000000..ea18e90e09c
--- /dev/null
+++ b/srcpkgs/rocm-opencl-runtime/files/runtime-musl.patch
@@ -0,0 +1,11 @@
+--- runtime/os/os_posix.cpp.orig	2020-04-19 09:13:51.701982901 -0400
++++ runtime/os/os_posix.cpp	2020-04-19 09:14:04.156947422 -0400
+@@ -44,6 +44,8 @@
+ #include <algorithm>
+ #include <mutex>
+ 
++#include <libgen.h> // for basename
++
+ 
+ namespace amd {
+ 
diff --git a/srcpkgs/rocm-opencl-runtime/patches/cmake.patch b/srcpkgs/rocm-opencl-runtime/patches/cmake.patch
new file mode 100644
index 00000000000..2c96b99d45a
--- /dev/null
+++ b/srcpkgs/rocm-opencl-runtime/patches/cmake.patch
@@ -0,0 +1,126 @@
+--- OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/CMakeLists.txt	2019-09-10 11:53:28.000000000 -0400
++++ OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/CMakeLists.txt	2020-04-16 20:16:13.481180757 -0400
+@@ -73,11 +73,11 @@
+ 
+ set (OPENCL_ICD_LOADER_HEADERS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/inc CACHE PATH "Path to OpenCL Headers")
+ 
+-add_library (OpenCL ${OPENCL_ICD_LOADER_SOURCES})
+-set_target_properties (OpenCL PROPERTIES VERSION "1.2" SOVERSION "1")
++add_library (OpenCL-ROCm ${OPENCL_ICD_LOADER_SOURCES})
++set_target_properties (OpenCL-ROCm PROPERTIES VERSION "1.2" SOVERSION "1")
+ 
+ if (WIN32)
+-    target_link_libraries (OpenCL cfgmgr32.lib)
++    target_link_libraries (OpenCL-ROCm cfgmgr32.lib)
+ 
+     option (OPENCL_ICD_LOADER_REQUIRE_WDK "Build with D3DKMT support, which requires the Windows WDK." ON)
+     if (OPENCL_ICD_LOADER_REQUIRE_WDK)
+@@ -92,10 +92,10 @@
+             get_filename_component(WDK_DIRECTORY ${LATEST_D3DKMT_HEADER} DIRECTORY)
+             get_filename_component(WDK_DIRECTORY ${WDK_DIRECTORY} DIRECTORY)
+             message(STATUS "Found the Windows WDK in: ${WDK_DIRECTORY}")
+-            target_compile_definitions(OpenCL PRIVATE OPENCL_ICD_LOADER_REQUIRE_WDK)
+-            target_include_directories(OpenCL PRIVATE ${WDK_DIRECTORY}/um)
+-            target_include_directories(OpenCL PRIVATE ${WDK_DIRECTORY}/km)
+-            target_include_directories(OpenCL PRIVATE ${WDK_DIRECTORY}/shared)
++	    target_compile_definitions(OpenCL-ROCm PRIVATE OPENCL_ICD_LOADER_REQUIRE_WDK)
++	    target_include_directories(OpenCL-ROCm PRIVATE ${WDK_DIRECTORY}/um)
++	    target_include_directories(OpenCL-ROCm PRIVATE ${WDK_DIRECTORY}/km)
++	    target_include_directories(OpenCL-ROCm PRIVATE ${WDK_DIRECTORY}/shared)
+         else()
+             message(FATAL_ERROR "The Windows WDK was not found. Consider disabling OPENCL_ICD_LOADER_REQUIRE_WDK. Aborting.")
+         endif()
+@@ -113,25 +113,25 @@
+     endif()
+ else()
+     if (APPLE)
+-        target_link_libraries (OpenCL ${CMAKE_THREAD_LIBS_INIT})
++        target_link_libraries (OpenCL-ROCm ${CMAKE_THREAD_LIBS_INIT})
+     else ()
+-        set_target_properties (OpenCL PROPERTIES LINK_FLAGS "-Wl,--version-script -Wl,${CMAKE_CURRENT_SOURCE_DIR}/loader/linux/icd_exports.map")
+-        target_link_libraries (OpenCL ${CMAKE_THREAD_LIBS_INIT})
++        set_target_properties (OpenCL-ROCm PROPERTIES LINK_FLAGS "-Wl,--version-script -Wl,${CMAKE_CURRENT_SOURCE_DIR}/loader/linux/icd_exports.map")
++	target_link_libraries (OpenCL-ROCm ${CMAKE_THREAD_LIBS_INIT})
+     endif ()
+ endif ()
+ 
+ include_directories (${OPENCL_ICD_LOADER_HEADERS_DIR})
+ add_definitions (-DCL_TARGET_OPENCL_VERSION=220)
+ 
+-target_include_directories (OpenCL PRIVATE ${CMAKE_CURRENT_BINARY_DIR} loader)
+-target_link_libraries (OpenCL ${CMAKE_DL_LIBS})
++target_include_directories (OpenCL-ROCm PRIVATE ${CMAKE_CURRENT_BINARY_DIR} loader)
++target_link_libraries (OpenCL-ROCm ${CMAKE_DL_LIBS})
+ 
+ include (CTest)
+ if (BUILD_TESTING)
+     add_subdirectory (test)
+ endif()
+ 
+-install (TARGETS OpenCL
++install (TARGETS OpenCL-ROCm
+     RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+     ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
+     LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
+--- OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/test/loader_test/CMakeLists.txt	2019-09-10 11:53:28.000000000 -0400
++++ OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/test/loader_test/CMakeLists.txt	2020-04-16 20:16:56.647026589 -0400
+@@ -12,4 +12,4 @@
+     test_clgl.c
+     test_image_objects.c )
+ 
+-target_link_libraries (icd_loader_test OpenCL IcdLog)
++target_link_libraries (icd_loader_test OpenCL-ROCm IcdLog)
+--- ROCm-OpenCL-Runtime-roc-3.3.0/CMakeLists.txt	2020-04-28 07:29:51.864446603 -0400
++++ ROCm-OpenCL-Runtime-roc-3.3.0/CMakeLists.txt	2020-04-28 07:32:45.245793180 -0400
+@@ -101,30 +101,30 @@
+ rocm_setup_version( VERSION "2.0.0" )
+ 
+ # MAIN package
+-install(PROGRAMS $<TARGET_FILE:clinfo>
+-        DESTINATION bin/x86_64
++install(PROGRAMS $<TARGET_FILE:rocm-clinfo>
++        DESTINATION bin
+         COMPONENT MAIN)
+ install(PROGRAMS $<TARGET_FILE:amdocl64>
+-        DESTINATION lib/x86_64
++        DESTINATION lib
+         COMPONENT MAIN)
+-install(PROGRAMS $<TARGET_FILE:OpenCL>
+-        DESTINATION lib/x86_64
++install(PROGRAMS $<TARGET_FILE:OpenCL-ROCm>
++        DESTINATION lib
+         COMPONENT MAIN)
+-install(PROGRAMS $<TARGET_SONAME_FILE:OpenCL>
+-        DESTINATION lib/x86_64
++install(PROGRAMS $<TARGET_SONAME_FILE:OpenCL-ROCm>
++        DESTINATION lib
+         COMPONENT MAIN)
+ 
+ # DEV package
+ install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/api/opencl/khronos/headers/opencl2.2/CL"
+-        DESTINATION include
++	DESTINATION include/rocm
+         COMPONENT DEV
+         USE_SOURCE_PERMISSIONS
+         PATTERN cl_d3d10.h EXCLUDE
+         PATTERN cl_d3d11.h EXCLUDE
+         PATTERN cl_dx9_media_sharing.h EXCLUDE
+         PATTERN cl_egl.h EXCLUDE)
+-install(PROGRAMS $<TARGET_LINKER_FILE:OpenCL>
+-        DESTINATION lib/x86_64
++install(PROGRAMS $<TARGET_LINKER_FILE:OpenCL-ROCm>
++        DESTINATION lib
+         COMPONENT DEV)
+ 
+ # Generic CPACK variables
+--- ROCm-OpenCL-Runtime-roc-3.3.0/tools/clinfo/CMakeLists.txt	2020-04-28 07:29:51.882446535 -0400
++++ ROCm-OpenCL-Runtime-roc-3.3.0/tools/clinfo/CMakeLists.txt	2020-04-28 07:30:05.627394732 -0400
+@@ -6,6 +6,6 @@
+ 
+ add_definitions(-DHAVE_CL2_HPP)
+ 
+-add_executable(clinfo clinfo.cpp)
++add_executable(rocm-clinfo clinfo.cpp)
+ 
+-target_link_libraries(clinfo OpenCL)
++target_link_libraries(rocm-clinfo OpenCL-ROCm)
diff --git a/srcpkgs/rocm-opencl-runtime/template b/srcpkgs/rocm-opencl-runtime/template
new file mode 100644
index 00000000000..dcad3951717
--- /dev/null
+++ b/srcpkgs/rocm-opencl-runtime/template
@@ -0,0 +1,83 @@
+# Template file for 'rocm-opencl-runtime'
+pkgname=rocm-opencl-runtime
+version=3.3.0
+revision=1
+_ocl_icd_name="OpenCL-ICD-Loader"
+_ocl_icd_ver="6c03f8b58fafd9dd693eaac826749a5cfad515f8"
+archs="x86_64*"
+create_wrksrc=yes
+build_wrksrc="ROCm-OpenCL-Runtime-roc-${version}"
+build_style=cmake
+configure_args="-DUSE_COMGR_LIBRARY=yes"
+hostmakedepends="cmake pkg-config"
+makedepends="libglvnd-devel rocm-comgr-devel
+	roct-thunk-interface-devel rocr-runtime-devel"
+depends="rocm-comgr"
+short_desc="Radeon Open Compute OpenCL runtime"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="MIT"
+homepage="https://github.com/RadeonOpenCompute/ROCm-OpenCL-Runtime"
+_rocroot="https://github.com/RadeonOpenCompute"
+distfiles="${_rocroot}/ROCm-OpenCL-Runtime/archive/roc-${version}.tar.gz
+	${_rocroot}/rocm-cmake/archive/rocm-${version}.tar.gz
+	https://github.com/KhronosGroup/${_ocl_icd_name}/archive/${_ocl_icd_ver}.tar.gz"
+checksum="ac6999f1a491ab066286c2bd6adf50f08f831286f56e267879f9f7eced22f98e
+	76ed3ee8e56cf3246011cf7723c2abda539e1136e7e7f6909bfa45d268b8644f
+	c94d5bb6dc980c4d41d73e2b81663a19aabe494e923e2d0eec72a4c95b318438"
+nocross=yes
+
+if [ "$XBPS_LIBC" = "musl" ]; then
+	makedepends+=" musl-legacy-compat"
+fi
+
+post_patch() {
+	if [ "$XBPS_LIBC" = "musl" ]; then
+		# Remove dependence on glibc
+		patch -Np0 < ${FILESDIR}/libelf-musl.patch
+		patch -Np0 < ${FILESDIR}/runtime-musl.patch
+		vsed -e '/glibc_functions.cpp/d' -i api/opencl/amdocl/CMakeLists.txt
+	fi
+}
+
+pre_configure() {
+	# ROCm requires a very specific Khronos ICD loader version in the tree
+	# Keep the ICD loader config in /etc/rocm/vendors to avoid conflicts
+	_ocl_icd_dir="${_ocl_icd_name}-${_ocl_icd_ver}"
+	ln -sf "${wrksrc}/${_ocl_icd_dir}" api/opencl/khronos/icd
+	vsed -i "${wrksrc}/${_ocl_icd_dir}/loader/icd_platform.h" \
+		-e 's@/etc/OpenCL/vendors/@/etc/rocm/vendors/@g'
+
+	# CMake modules probably not useful anywhere but for this build
+	ln -sf "${wrksrc}/rocm-cmake-rocm-${version}/share/rocm/cmake"/*.cmake cmake
+
+	# Fix the dlopen macro to point to versioned libamd_comgr shared object
+	vsed -i 'runtime/device/comgrctx.cpp' \
+		-e 's/\blibamd_comgr\(32\)\?.so\b/&.1/g'
+}
+
+post_install() {
+	vlicense License
+
+	# Create descriptor to allow the ICD loader to find the driver
+	vmkdir etc/rocm/vendors
+	echo "libamdocl64.so" > "${DESTDIR}/etc/rocm/vendors/rocm-amdocl64.icd"
+	vmkdir etc/OpenCL/vendors
+	ln -s ../../rocm/vendors/rocm-amdocl64.icd ${DESTDIR}/etc/OpenCL/vendors
+}
+
+rocm-opencl-runtime-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/lib/libOpenCL-ROCm.so
+		vmove usr/include
+	}
+}
+
+rocm-opencl-runtime-clinfo_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - clinfo"
+	pkg_install() {
+		vmove usr/bin/rocm-clinfo
+	}
+}

From 3ffbdebb02cd53feebe3c33f73c01c093fbe93cf Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Thu, 30 Apr 2020 13:11:12 -0400
Subject: [PATCH 09/10] New package: rocm-hsa-extensions-3.3.0

---
 common/shlibs                 |  2 ++
 srcpkgs/rocm-hsa-ext-devel    |  1 +
 srcpkgs/rocm-hsa-ext/template | 41 +++++++++++++++++++++++++++++++++++
 3 files changed, 44 insertions(+)
 create mode 120000 srcpkgs/rocm-hsa-ext-devel
 create mode 100644 srcpkgs/rocm-hsa-ext/template

diff --git a/common/shlibs b/common/shlibs
index 8cbc885e016..730e6d0d394 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3867,3 +3867,5 @@ libhsa-runtime64.so.1 rocr-runtime-3.3.0_1
 libamd_comgr.so.1 rocm-comgr-3.3.0_1
 libOpenCL-ROCm.so.1 rocm-opencl-runtime-3.3.0_1
 libamdocl64.so rocm-opencl-runtime-3.3.0_1
+libhsa-ext-image64.so.1 rocm-hsa-ext-3.3.0_1
+libhsa-runtime-tools64.so.1 rocm-hsa-ext-3.3.0_1
diff --git a/srcpkgs/rocm-hsa-ext-devel b/srcpkgs/rocm-hsa-ext-devel
new file mode 120000
index 00000000000..d201e9f2fae
--- /dev/null
+++ b/srcpkgs/rocm-hsa-ext-devel
@@ -0,0 +1 @@
+rocm-hsa-ext
\ No newline at end of file
diff --git a/srcpkgs/rocm-hsa-ext/template b/srcpkgs/rocm-hsa-ext/template
new file mode 100644
index 00000000000..a8ca5220cab
--- /dev/null
+++ b/srcpkgs/rocm-hsa-ext/template
@@ -0,0 +1,41 @@
+# Template file for 'rocm-hsa-ext'
+pkgname=rocm-hsa-ext
+version=3.3.0
+revision=1
+archs="x86_64"
+hostmakedepends="tar"
+short_desc="Radeon Open Compute HSA runtime extensions"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute"
+_hsa_deb="hsa-ext-rocr-dev_1.1.30300.0-rocm-rel-3.3-19-23fc088b_amd64.deb"
+distfiles="https://repo.radeon.com/rocm/apt/debian/pool/main/h/hsa-ext-rocr-dev/$_hsa_deb"
+checksum=6b44e286b395d946b865ec1f3cc546356396785ac1fde591d07af02d0aa7c25d
+
+do_extract() {
+	ar x "${XBPS_SRCDISTDIR}/${pkgname}-${version}/${_hsa_deb}"
+	tar xvf data.tar.gz
+}
+
+do_install() {
+	_rocm_includes="opt/rocm-${version}/hsa/include"
+	
+	vmkdir usr
+	vcopy opt/rocm-${version}/hsa/lib usr
+	vcopy "$_rocm_includes" usr
+
+	# Extract license from one of the header files
+	awk 'BEGIN{HEADER=0} /\/\//{HEADER=1; print $0;} /^[^/]/{if(HEADER==1) exit;}' \
+		< "${_rocm_includes}/hsa/amd_hsa_tools_interfaces.h" \
+		| sed 's@^///*\( \|$\)@@' > LICENSE
+	vlicense LICENSE
+}
+
+rocm-hsa-ext-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove "usr/lib/*.so"
+	}
+}

From 555c9bcc213737c1e31dea9911e34811afd2a535 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Tue, 28 Apr 2020 13:33:46 -0400
Subject: [PATCH 10/10] hashcat: add build option to link against ROCm [ci
 skip]

---
 srcpkgs/hashcat/files/rocm.patch     | 15 +++++++++++++++
 srcpkgs/hashcat/patches/tmpdir.patch | 21 +++++++++++++++++++++
 srcpkgs/hashcat/template             | 17 ++++++++++++++---
 3 files changed, 50 insertions(+), 3 deletions(-)
 create mode 100644 srcpkgs/hashcat/files/rocm.patch
 create mode 100644 srcpkgs/hashcat/patches/tmpdir.patch

diff --git a/srcpkgs/hashcat/files/rocm.patch b/srcpkgs/hashcat/files/rocm.patch
new file mode 100644
index 00000000000..f1e899d30ee
--- /dev/null
+++ b/srcpkgs/hashcat/files/rocm.patch
@@ -0,0 +1,15 @@
+diff -ur a/src/opencl.c b/src/opencl.c
+--- a/src/opencl.c	2018-12-02 05:58:48.000000000 -0500
++++ b/src/opencl.c	2020-04-28 13:24:12.602415333 -0400
+@@ -492,9 +492,9 @@
+ 
+   if (ocl->lib == NULL) ocl->lib = hc_dlopen ("cygOpenCL-1.dll", RTLD_NOW);
+   #else
+-  ocl->lib = hc_dlopen ("libOpenCL.so", RTLD_NOW);
++  ocl->lib = hc_dlopen ("libOpenCL-ROCm.so.1", RTLD_NOW);
+ 
+-  if (ocl->lib == NULL) ocl->lib = hc_dlopen ("libOpenCL.so.1", RTLD_NOW);
++  if (ocl->lib == NULL) ocl->lib = hc_dlopen ("libOpenCL-ROCm.so", RTLD_NOW);
+   #endif
+ 
+   if (ocl->lib == NULL)
diff --git a/srcpkgs/hashcat/patches/tmpdir.patch b/srcpkgs/hashcat/patches/tmpdir.patch
new file mode 100644
index 00000000000..0558a001c9c
--- /dev/null
+++ b/srcpkgs/hashcat/patches/tmpdir.patch
@@ -0,0 +1,21 @@
+Addresses https://github.com/hashcat/hashcat/issues/2379
+diff -ur a/src/folder.c b/src/folder.c
+--- src/folder.c	2018-12-02 05:58:48.000000000 -0500
++++ src/folder.c	2020-04-28 13:22:27.340522751 -0400
+@@ -457,16 +457,6 @@
+ 
+   hcfree (cpath);
+ 
+-  //if (getenv ("TMP") == NULL)
+-  if (1)
+-  {
+-    char *tmp;
+-
+-    hc_asprintf (&tmp, "TMP=%s", cpath_real);
+-
+-    putenv (tmp);
+-  }
+-
+   #if defined (_WIN)
+ 
+   naive_replace (cpath_real, '\\', '/');
diff --git a/srcpkgs/hashcat/template b/srcpkgs/hashcat/template
index e982f99cebf..7d3a8cb5a6b 100644
--- a/srcpkgs/hashcat/template
+++ b/srcpkgs/hashcat/template
@@ -1,15 +1,16 @@
 # Template file for 'hashcat'
 pkgname=hashcat
 version=5.1.0
-revision=2
+revision=3
 build_style=gnu-makefile
 make_build_args="PREFIX=/usr
  USE_SYSTEM_OPENCL=1 USE_SYSTEM_XXHASH=1
- DEPS_OPENCL_PATH=${XBPS_CROSS_BASE}/usr/include
+ DEPS_OPENCL_PATH=${XBPS_CROSS_BASE}/usr/include$(vopt_if rocm /rocm)
  DEPS_XXHASH_PATH=${XBPS_CROSS_BASE}/usr/include"
 make_use_env=yes
 make_install_args="$make_build_args"
-makedepends="gmp-devel opencl2-headers xxHash-devel"
+makedepends="gmp-devel xxHash-devel
+ $(vopt_if rocm rocm-opencl-runtime-devel opencl2-headers)"
 checkdepends="perl"
 short_desc="Advanced CPU-based password recovery utility"
 maintainer="Duncaen <duncaen@voidlinux.org>"
@@ -19,6 +20,9 @@ changelog="https://raw.githubusercontent.com/hashcat/hashcat/master/docs/changes
 distfiles="https://hashcat.net/files/hashcat-${version}.tar.gz"
 checksum=283beaa68e1eab41de080a58bb92349c8e47a2bb1b93d10f36ea30f418f1e338
 
+build_options="rocm"
+desc_option_rocm="Use ROCm OpenCL runtime"
+
 if [ "$XBPS_TARGET_ENDIAN" = "be" ]; then
 	broken="Not supported on big endian"
 fi
@@ -26,6 +30,13 @@ fi
 post_extract() {
 	sed '/^CC/d' -i src/Makefile
 }
+
+post_patch() {
+	if [ "$build_option_rocm" ]; then
+		patch -Np1 < ${FILESDIR}/rocm.patch
+	fi
+}
+
 post_install() {
 	rm -f ${DESTDIR}/usr/share/docs/hashcat/license.txt
 	vlicense docs/license.txt

^ permalink raw reply	[flat|nested] 61+ messages in thread

* Re: [PR PATCH] [Updated] New packages: ROCm core and OpenCL
  2020-04-19 13:34 [PR PATCH] New packages: ROCm core and OpenCL ahesford
                   ` (12 preceding siblings ...)
  2020-04-30 19:05 ` ahesford
@ 2020-04-30 19:12 ` ahesford
  2020-04-30 19:22 ` ahesford
                   ` (45 subsequent siblings)
  59 siblings, 0 replies; 61+ messages in thread
From: ahesford @ 2020-04-30 19:12 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 3893 bytes --]

There is an updated pull request by ahesford against master on the void-packages repository

https://github.com/ahesford/void-packages rocm
https://github.com/void-linux/void-packages/pull/21153

New packages: ROCm core and OpenCL
This PR includes several packages designed to bring the OpenCL portion of the AMD ROCm ecosystem to Void. It addresses Issue #19507. There are many other packages that AMD provides for GPGPU computing, but these can be added piecemeal as users demand.

The packages are currently only for `x86_64*`. While at least some of the packages will compile on other 64-bit architectures, I have no hardware to test. They are certainly not suitable for 32-bit architectures; some internal data structures rely on `uint64_t` values that are cast to pointers. At a
minimum, a thorough audit would be necessary to ensure that these casts are safe (e.g., that the values stored were only ever upcast from 32-bit pointers). More extensive work may be necessary to support 32-bit architectures, probably without significant benefit.

The packages successfully identify a Radeon RX 580 on an `x86_64` installation using both `clinfo` and `rocminfo` as provided. Furthermore, a version of `pyopencl` linked against these ROCm packages successfully runs a simple program that validates arithmetic on GPU-bound arrays.

There are caveats with this set of packages, almost all of which revolve around the incompatibilities between the Void-provided `ocl-icd` and the [Khronos OpenCL ICD loader](https://github.com/KhronosGroup/OpenCL-ID-Loader) required by (and built into) `rocm-opencl-runtime`.
1. All packages install into `/opt/rocm`. This keeps the environment closer to that officially sanctioned by AMD and helps avoid conflicts between other packages and those provided here. (For example, `clinfo` and the ICD loader itself.) Eventually, we may be able to move the files into `/usr`.
2. The Khronos OpenCL ICD loader built into `rocm-opencl-runtime` is an outdated, pre-release commit. If AMD can update its sources to use the release version of that loader (which has a backward-incompatible API change), we may be able to make ROCm compatible with `ocl-icd` or replace `ocl-icd` with the official Khronos loader.
3. In the meantime, to avoid `shlibs` conflicts, the OpenCL ICD loader is installed as `/opt/rocm/lib/libOpenCL-ROCm.so` (and an appropriately versioned shared library), which means that programs wishing to use the ROCm OpenCL must explicitly link against this library instead of the generic `libOpenCL.so`.
4. I do **not** recommend making any Void packages link against this specific library, because it will make those packages ROCm-only. For the time being, ROCm is intended for end-users to specifically link against. Linking Void packages against ROCm would requires the ICD loader used by ROCm be compatible with `ocl-icd`, or `ocl-icd` be replaced by the Khronos loader. However, because the Khronos loader changed its API for the release version, such a change is not yet appropriate.

Hopefully, if AMD updates its dependence on the Khronos ICD loader, we can resolve some of these caveats in the future and make ROCm a more natural Void component. For now, these packages are useful for those who need an AMD OpenCL solution and would rather custom-link software against the AMD ICD loader than hack the `amdgpu-pro` driver into an ICD compatible with `ocl-icd`.

Some patches were made to relocate some files in `/opt/rocm` and make everyting build on x86_64-musl`. Where appropriate, these patches will be pushed upstream to clean up the distribution and packaging.

Update: I pushed some new commits to update license information that triggerd an `xlint` failure. I've also disabled CI builds because they will time out on `rocm-llvm`.

A patch file from https://github.com/void-linux/void-packages/pull/21153.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-rocm-21153.patch --]
[-- Type: text/x-diff, Size: 35776 bytes --]

From 1226ae1e7c5eea64be3859bb36eee4fd8c6cccc6 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Mon, 13 Apr 2020 13:08:09 -0400
Subject: [PATCH 01/10] New package: roct-thunk-interface-3.3.0

---
 common/shlibs                                 |  1 +
 srcpkgs/roct-thunk-interface-devel            |  1 +
 .../patches/cmake-dev-libdir.patch            | 10 ++++++
 .../roct-thunk-interface/patches/musl.patch   | 29 ++++++++++++++++
 srcpkgs/roct-thunk-interface/template         | 33 +++++++++++++++++++
 5 files changed, 74 insertions(+)
 create mode 120000 srcpkgs/roct-thunk-interface-devel
 create mode 100644 srcpkgs/roct-thunk-interface/patches/cmake-dev-libdir.patch
 create mode 100644 srcpkgs/roct-thunk-interface/patches/musl.patch
 create mode 100644 srcpkgs/roct-thunk-interface/template

diff --git a/common/shlibs b/common/shlibs
index 6d39ce34c19..d89ae72ae3e 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3862,3 +3862,4 @@ libtagparser.so.9 tagparser-9.1.2_1
 libqtutilities.so.6 qtutilities-6.0.4_1
 libkdsoap.so.1.9.0 KDSoap-1.9.0_1
 libstoken.so.1 stoken-0.92_1
+libhsakmt.so.1 roct-thunk-interface-3.3.0_1
diff --git a/srcpkgs/roct-thunk-interface-devel b/srcpkgs/roct-thunk-interface-devel
new file mode 120000
index 00000000000..ac3f2cc684c
--- /dev/null
+++ b/srcpkgs/roct-thunk-interface-devel
@@ -0,0 +1 @@
+roct-thunk-interface
\ No newline at end of file
diff --git a/srcpkgs/roct-thunk-interface/patches/cmake-dev-libdir.patch b/srcpkgs/roct-thunk-interface/patches/cmake-dev-libdir.patch
new file mode 100644
index 00000000000..98c7f1e459c
--- /dev/null
+++ b/srcpkgs/roct-thunk-interface/patches/cmake-dev-libdir.patch
@@ -0,0 +1,10 @@
+--- CMakeLists.txt.old	2020-04-18 19:45:17.306081135 -0400
++++ CMakeLists.txt	2020-04-18 19:46:51.300753636 -0400
+@@ -146,6 +146,7 @@
+     COMMAND ${CMAKE_COMMAND}
+         -DSOURCE_DIR="${SOURCE_DIR}"
+         -DCMAKE_INSTALL_PREFIX="${CMAKE_INSTALL_PREFIX}"
++        -DCMAKE_INSTALL_LIBDIR="${CMAKE_INSTALL_LIBDIR}"
+         -DCPACK_RPM_PACKAGE_REQUIRES="hsakmt-roct"
+         -DCPACK_PACKAGING_INSTALL_PREFIX="${CPACK_PACKAGING_INSTALL_PREFIX}"
+         -DVERSION="${BUILD_VERSION_STRING}"
diff --git a/srcpkgs/roct-thunk-interface/patches/musl.patch b/srcpkgs/roct-thunk-interface/patches/musl.patch
new file mode 100644
index 00000000000..aeea9832411
--- /dev/null
+++ b/srcpkgs/roct-thunk-interface/patches/musl.patch
@@ -0,0 +1,29 @@
+diff -r -u old/src/libhsakmt.h new/src/libhsakmt.h
+--- src/libhsakmt.h	2020-03-04 15:00:47.000000000 -0500
++++ src/libhsakmt.h	2020-04-13 12:58:30.444865992 -0400
+@@ -54,6 +54,10 @@
+ #define CHECK_KFD_OPEN() \
+ 	do { if (kfd_open_count == 0 || hsakmt_forked) return HSAKMT_STATUS_KERNEL_IO_CHANNEL_NOT_OPENED; } while (0)
+ 
++/*On some platforms, a PAGE_SIZE macro eclipses the extern variable*/
++#ifdef PAGE_SIZE
++#undef PAGE_SIZE
++#endif
+ extern int PAGE_SIZE;
+ extern int PAGE_SHIFT;
+ 
+diff -r -u old/src/topology.c new/src/topology.c
+--- src/topology.c	2020-03-04 15:00:47.000000000 -0500
++++ src/topology.c	2020-04-13 13:01:31.209870701 -0400
+@@ -38,6 +38,11 @@
+ #include "libhsakmt.h"
+ #include "fmm.h"
+ 
++/*Needed on MUSL*/
++#ifndef MAXNAMLEN
++#define MAXNAMLEN PATH_MAX
++#endif
++
+ /* Number of memory banks added by thunk on top of topology
+  * This only includes static heaps like LDS, scratch and SVM,
+  * not for MMIO_REMAP heap. MMIO_REMAP memory bank is reported
diff --git a/srcpkgs/roct-thunk-interface/template b/srcpkgs/roct-thunk-interface/template
new file mode 100644
index 00000000000..55a1fc6074a
--- /dev/null
+++ b/srcpkgs/roct-thunk-interface/template
@@ -0,0 +1,33 @@
+# Template file for 'roct-thunk-interface'
+pkgname=roct-thunk-interface
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="ROCT-Thunk-Interface-roc-${version}"
+build_style=cmake
+make_build_target="all build-dev"
+make_install_target="install install-dev"
+hostmakedepends="cmake pkg-config"
+makedepends="pciutils-devel libnuma-devel"
+short_desc="Radeon Open Compute Thunk Interface"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="MIT"
+homepage="https://github.com/RadeonOpenCompute/ROCT-Thunk-Interface"
+distfiles="${homepage}/archive/roc-${version}.tar.gz"
+checksum=2cabe9d2cfa72031c05d11290837c476182e72d8dec2049298f691143fdd212b
+nocross=yes
+
+post_install() {
+	vlicense LICENSE.md
+}
+
+roct-thunk-interface-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove "usr/lib/*.so"
+		vmove usr/share/pkgconfig
+		vmove usr/lib/cmake
+	}
+}

From d8bb69aca8ebcd167198d858c11e7b7fa326c389 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Mon, 13 Apr 2020 15:27:27 -0400
Subject: [PATCH 02/10] New package: rocr-runtime-3.3.0

---
 common/shlibs                            |  1 +
 srcpkgs/rocr-runtime-devel               |  1 +
 srcpkgs/rocr-runtime/patches/cmake.patch | 27 +++++++++++++++++++++
 srcpkgs/rocr-runtime/template            | 30 ++++++++++++++++++++++++
 4 files changed, 59 insertions(+)
 create mode 120000 srcpkgs/rocr-runtime-devel
 create mode 100644 srcpkgs/rocr-runtime/patches/cmake.patch
 create mode 100644 srcpkgs/rocr-runtime/template

diff --git a/common/shlibs b/common/shlibs
index d89ae72ae3e..499f35752c2 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3863,3 +3863,4 @@ libqtutilities.so.6 qtutilities-6.0.4_1
 libkdsoap.so.1.9.0 KDSoap-1.9.0_1
 libstoken.so.1 stoken-0.92_1
 libhsakmt.so.1 roct-thunk-interface-3.3.0_1
+libhsa-runtime64.so.1 rocr-runtime-3.3.0_1
diff --git a/srcpkgs/rocr-runtime-devel b/srcpkgs/rocr-runtime-devel
new file mode 120000
index 00000000000..be838f22d81
--- /dev/null
+++ b/srcpkgs/rocr-runtime-devel
@@ -0,0 +1 @@
+rocr-runtime
\ No newline at end of file
diff --git a/srcpkgs/rocr-runtime/patches/cmake.patch b/srcpkgs/rocr-runtime/patches/cmake.patch
new file mode 100644
index 00000000000..93b74cd2297
--- /dev/null
+++ b/srcpkgs/rocr-runtime/patches/cmake.patch
@@ -0,0 +1,27 @@
+--- src/CMakeLists.txt.old	2020-04-18 20:01:48.549636995 -0400
++++ src/CMakeLists.txt	2020-04-18 20:04:00.177179781 -0400
+@@ -108,8 +108,8 @@
+ ## ROCr build internal versioning
+ add_definitions ( -DROCR_BUILD_ID=${PACKAGE_VERSION_STRING} )
+ 
+-## Set RUNPATH - ../../lib covers use of the legacy symlink in /hsa/lib/
+-set(CMAKE_INSTALL_RPATH "$ORIGIN;$ORIGIN/../../lib;$ORIGIN/../../lib64;$ORIGIN/../lib64")
++## Set RUNPATH
++set(CMAKE_INSTALL_RPATH "$ORIGIN;$ORIGIN/../lib")
+ 
+ ## ------------------------- Linux Compiler and Linker options -------------------------
+ set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -fexceptions -fno-rtti -fvisibility=hidden -Wno-error=sign-compare -Wno-sign-compare -Wno-write-strings -Wno-conversion-null -fno-math-errno -fno-threadsafe-statics -fmerge-all-constants -fms-extensions -Wno-error=comment -Wno-comment -Wno-error=pointer-arith -Wno-pointer-arith -Wno-error=unused-variable -Wno-error=unused-function" )
+@@ -185,11 +185,8 @@
+ add_custom_target ( hsa_lib_link2 ALL WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMAND ${CMAKE_COMMAND} -E create_symlink ../hsa/lib/${CORE_RUNTIME_LIBRARY}.so.${SO_MAJOR} ${CORE_RUNTIME_LIBRARY}-link.so.${SO_MAJOR} )
+ 
+ ## Set install information
+-install ( TARGETS ${CORE_RUNTIME_TARGET} LIBRARY DESTINATION hsa/lib )
+-install ( DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/inc/ DESTINATION hsa/include/hsa )
+-install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/hsa_include_link DESTINATION include PERMISSIONS OWNER_WRITE OWNER_READ RENAME hsa )
+-install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/${CORE_RUNTIME_LIBRARY}-link.so DESTINATION lib PERMISSIONS OWNER_WRITE OWNER_READ RENAME ${CORE_RUNTIME_LIBRARY}.so )
+-install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/${CORE_RUNTIME_LIBRARY}-link.so.${SO_MAJOR} DESTINATION lib PERMISSIONS OWNER_WRITE OWNER_READ RENAME ${CORE_RUNTIME_LIBRARY}.so.${SO_MAJOR} )
++install ( TARGETS ${CORE_RUNTIME_TARGET} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} )
++install ( DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/inc/ DESTINATION include/hsa )
+ 
+ ## Packaging directives
+ set ( CPACK_GENERATOR "DEB;RPM" CACHE STRING "Package types to build")
diff --git a/srcpkgs/rocr-runtime/template b/srcpkgs/rocr-runtime/template
new file mode 100644
index 00000000000..5ee22140f1f
--- /dev/null
+++ b/srcpkgs/rocr-runtime/template
@@ -0,0 +1,30 @@
+# Template file for 'rocr-runtime'
+pkgname=rocr-runtime
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="ROCR-Runtime-rocm-${version}"
+build_wrksrc="src"
+build_style=cmake
+hostmakedepends="cmake pkg-config"
+makedepends="roct-thunk-interface-devel elfutils-devel"
+short_desc="Radeon Open Compute HSA Runtime"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute/ROCR-Runtime"
+distfiles="${homepage}/archive/rocm-${version}.tar.gz"
+checksum=fa2d2d1f8a61d8a6952d377cf288d78c61776c3c2a666f163cafc3aa19ab0b61
+nocross=yes
+
+post_install() {
+	vlicense ../LICENSE.txt
+}
+
+rocr-runtime-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove "usr/lib/*.so"
+	}
+}

From 5991aaa587df9bdce5c93daf534974432a336acf Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Mon, 13 Apr 2020 18:07:34 -0400
Subject: [PATCH 03/10] New package: rocm-llvm-3.3.0

---
 srcpkgs/rocm-llvm/template | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)
 create mode 100644 srcpkgs/rocm-llvm/template

diff --git a/srcpkgs/rocm-llvm/template b/srcpkgs/rocm-llvm/template
new file mode 100644
index 00000000000..d6e75cd050c
--- /dev/null
+++ b/srcpkgs/rocm-llvm/template
@@ -0,0 +1,26 @@
+# Template file for 'rocm-llvm'
+pkgname=rocm-llvm
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="llvm-project-rocm-ocl-${version}"
+build_wrksrc=llvm
+build_style=cmake
+configure_args="-DCMAKE_INSTALL_PREFIX:PATH=/usr/lib/rocm-llvm
+	-DLLVM_ENABLE_PROJECTS='llvm;clang;lld' -DLLVM_TARGETS_TO_BUILD='AMDGPU'
+	-DLLVM_BUILD_DOCS=NO -DLLVM_ENABLE_OCAMLDOC=OFF
+	-DLLVM_ENABLE_SPHINX=NO -DLLVM_ENABLE_DOXYGEN=OFF
+	-DLLVM_INSTALL_UTILS=ON -DLLVM_VERSION_SUFFIX=roc -DOCAMLFIND=NO"
+hostmakedepends="cmake pkg-config python3"
+short_desc="Radeon Open Compute LLVM toolchain"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="Apache-2.0, NCSA, custom:LLVM-Exceptions"
+homepage="https://github.com/RadeonOpenCompute/llvm-project"
+distfiles="${homepage}/archive/rocm-ocl-${version}.tar.gz"
+checksum=a2bef7042e8e2f2cd8548cb246b88322e1c77188839983dcac8312d56f544dc8
+python_version=3
+nocross=yes
+
+post_install() {
+	vlicense LICENSE.TXT
+}

From 19c7a333ec5877c0e1e57ab9d1438bc0b31520a3 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Tue, 14 Apr 2020 10:25:31 -0400
Subject: [PATCH 04/10] New package: rocm-device-libs-3.3.0

---
 srcpkgs/rocm-device-libs/template | 37 +++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)
 create mode 100644 srcpkgs/rocm-device-libs/template

diff --git a/srcpkgs/rocm-device-libs/template b/srcpkgs/rocm-device-libs/template
new file mode 100644
index 00000000000..fcb4eb0d53e
--- /dev/null
+++ b/srcpkgs/rocm-device-libs/template
@@ -0,0 +1,37 @@
+# Template file for 'rocm-device-libs'
+pkgname=rocm-device-libs
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="ROCm-Device-Libs-rocm-ocl-${version}"
+build_style=cmake
+configure_args="-DLLVM_DIR:PATH=/usr/lib/rocm-llvm
+	-DCMAKE_INSTALL_LIBDIR:PATH=lib/rocm-device-libs"
+hostmakedepends="cmake rocm-llvm"
+short_desc="Radeon Open Compute device libraries"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute/ROCm-Device-Libs"
+distfiles="${homepage}/archive/rocm-ocl-${version}.tar.gz"
+checksum=706b08230790e08ca6a7a2fb7687d6131fd39a562148340e00fa37a6c06769c5
+nocross=yes
+
+pre_configure() {
+	# Put bytecodes in a lib/ subdirectory
+	vsed -i Packages.cmake -e 's@/lib/@/${CMAKE_INSTALL_LIBDIR}/@'
+	vsed -i OCL.cmake -e 's@DESTINATION lib$@DESTINATION ${CMAKE_INSTALL_LIBDIR}@'
+
+	# Build the prepare-builtins executable with native compiler
+	mkdir -p utils/build
+	cd utils/build
+	_prepare_builtins="$PWD/prepare-builtins/prepare-builtins"
+	cmake ${configure_args} ..
+	make ${makejobs}
+
+	# Add path to prepare-builtins for cmake
+	configure_args+=" -DPREPARE_BUILTINS='${_prepare_builtins}'"
+}
+
+post_install() {
+	vlicense LICENSE
+}

From 691d78f81e8346791c5556569cfa00b5b5d133ac Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Mon, 13 Apr 2020 18:30:00 -0400
Subject: [PATCH 05/10] New package: rocm-comgr-3.3.0

---
 common/shlibs               |  1 +
 srcpkgs/rocm-comgr-devel    |  1 +
 srcpkgs/rocm-comgr/template | 32 ++++++++++++++++++++++++++++++++
 3 files changed, 34 insertions(+)
 create mode 120000 srcpkgs/rocm-comgr-devel
 create mode 100644 srcpkgs/rocm-comgr/template

diff --git a/common/shlibs b/common/shlibs
index 499f35752c2..a53de3cf9e0 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3864,3 +3864,4 @@ libkdsoap.so.1.9.0 KDSoap-1.9.0_1
 libstoken.so.1 stoken-0.92_1
 libhsakmt.so.1 roct-thunk-interface-3.3.0_1
 libhsa-runtime64.so.1 rocr-runtime-3.3.0_1
+libamd_comgr.so.1 rocm-comgr-3.3.0_1
diff --git a/srcpkgs/rocm-comgr-devel b/srcpkgs/rocm-comgr-devel
new file mode 120000
index 00000000000..3f5ce255e07
--- /dev/null
+++ b/srcpkgs/rocm-comgr-devel
@@ -0,0 +1 @@
+rocm-comgr
\ No newline at end of file
diff --git a/srcpkgs/rocm-comgr/template b/srcpkgs/rocm-comgr/template
new file mode 100644
index 00000000000..c228bcd4d1f
--- /dev/null
+++ b/srcpkgs/rocm-comgr/template
@@ -0,0 +1,32 @@
+# Template file for 'rocm-comgr'
+pkgname=rocm-comgr
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="ROCm-CompilerSupport-rocm-${version}"
+build_wrksrc="lib/comgr"
+build_style=cmake
+configure_args="-DClang_DIR:PATH=/usr/lib/rocm-llvm/lib/cmake/clang"
+hostmakedepends="cmake pkg-config rocm-llvm"
+makedepends="rocm-device-libs"
+short_desc="Radeon Open Compute Code Object Manager"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="BSD-3-Clause"
+homepage="https://github.com/RadeonOpenCompute/ROCm-CompilerSupport"
+distfiles="${homepage}/archive/rocm-${version}.tar.gz"
+checksum=01e2524e0f28ecd6f46c9720f279207de935d826b0172158792aa3ec86af9ca7
+nocross=yes
+
+post_install() {
+	vlicense LICENSE.txt
+}
+
+rocm-comgr-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove "usr/lib/*.so"
+		vmove usr/lib/cmake
+	}
+}

From 34506fec471194f2746c0fca2b1a8f8de3c02f1c Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Fri, 17 Apr 2020 12:11:25 -0400
Subject: [PATCH 06/10] New package: rocminfo-3.3.0

---
 srcpkgs/rocminfo/template | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
 create mode 100644 srcpkgs/rocminfo/template

diff --git a/srcpkgs/rocminfo/template b/srcpkgs/rocminfo/template
new file mode 100644
index 00000000000..57d0640dd69
--- /dev/null
+++ b/srcpkgs/rocminfo/template
@@ -0,0 +1,22 @@
+# Template file for 'rocminfo'
+pkgname=rocminfo
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="rocminfo-rocm-${version}"
+build_style=cmake
+configure_args="-DROCM_DIR=/usr"
+hostmakedepends="cmake pkg-config"
+makedepends="rocr-runtime-devel"
+short_desc="Radeon Open Compute system information reporter"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute/rocminfo"
+distfiles="${homepage}/archive/rocm-${version}.tar.gz"
+checksum=e666f662c9e465aaabbbd0b109d87e017243cdf1a0898fabf5a90947bb3dbcd7
+nocross=yes
+python_version=3
+
+post_install() {
+	vlicense License.txt
+}

From 673ee21a6905ad3ca6877af58e936900c8d13bf1 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Sun, 19 Apr 2020 15:01:40 -0400
Subject: [PATCH 07/10] New package: rocm-bandwidth-test-3.3.0

---
 srcpkgs/rocm-bandwidth-test/template | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
 create mode 100644 srcpkgs/rocm-bandwidth-test/template

diff --git a/srcpkgs/rocm-bandwidth-test/template b/srcpkgs/rocm-bandwidth-test/template
new file mode 100644
index 00000000000..5c5058b693d
--- /dev/null
+++ b/srcpkgs/rocm-bandwidth-test/template
@@ -0,0 +1,20 @@
+# Template file for 'rocm-bandwidth-test'
+pkgname=rocm-bandwidth-test
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="rocm_bandwidth_test-rocm-${version}"
+build_style=cmake
+hostmakedepends="cmake"
+makedepends="rocr-runtime-devel roct-thunk-interface-devel"
+short_desc="Radeon Open Compute bandwidth test"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute/rocm_bandwidth_test"
+distfiles="${homepage}/archive/rocm-${version}.tar.gz"
+checksum=f5f914073018619dc91662d5bf630903dfa4db9136d603591917fdfb3c9164ce
+nocross=yes
+
+post_install() {
+	vlicense LICENSE.txt
+}

From 8880063d1e46a22e487bc193b63a08a7e7fc3d6d Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Tue, 14 Apr 2020 10:25:54 -0400
Subject: [PATCH 08/10] New package: rocm-opencl-runtime-3.3.0

---
 common/shlibs                                 |   2 +
 srcpkgs/rocm-opencl-runtime-clinfo            |   1 +
 srcpkgs/rocm-opencl-runtime-devel             |   1 +
 .../files/libelf-musl.patch                   |  21 +++
 .../files/runtime-musl.patch                  |  11 ++
 .../rocm-opencl-runtime/patches/cmake.patch   | 126 ++++++++++++++++++
 srcpkgs/rocm-opencl-runtime/template          |  83 ++++++++++++
 7 files changed, 245 insertions(+)
 create mode 120000 srcpkgs/rocm-opencl-runtime-clinfo
 create mode 120000 srcpkgs/rocm-opencl-runtime-devel
 create mode 100644 srcpkgs/rocm-opencl-runtime/files/libelf-musl.patch
 create mode 100644 srcpkgs/rocm-opencl-runtime/files/runtime-musl.patch
 create mode 100644 srcpkgs/rocm-opencl-runtime/patches/cmake.patch
 create mode 100644 srcpkgs/rocm-opencl-runtime/template

diff --git a/common/shlibs b/common/shlibs
index a53de3cf9e0..8cbc885e016 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3865,3 +3865,5 @@ libstoken.so.1 stoken-0.92_1
 libhsakmt.so.1 roct-thunk-interface-3.3.0_1
 libhsa-runtime64.so.1 rocr-runtime-3.3.0_1
 libamd_comgr.so.1 rocm-comgr-3.3.0_1
+libOpenCL-ROCm.so.1 rocm-opencl-runtime-3.3.0_1
+libamdocl64.so rocm-opencl-runtime-3.3.0_1
diff --git a/srcpkgs/rocm-opencl-runtime-clinfo b/srcpkgs/rocm-opencl-runtime-clinfo
new file mode 120000
index 00000000000..b2cda7e229d
--- /dev/null
+++ b/srcpkgs/rocm-opencl-runtime-clinfo
@@ -0,0 +1 @@
+rocm-opencl-runtime
\ No newline at end of file
diff --git a/srcpkgs/rocm-opencl-runtime-devel b/srcpkgs/rocm-opencl-runtime-devel
new file mode 120000
index 00000000000..b2cda7e229d
--- /dev/null
+++ b/srcpkgs/rocm-opencl-runtime-devel
@@ -0,0 +1 @@
+rocm-opencl-runtime
\ No newline at end of file
diff --git a/srcpkgs/rocm-opencl-runtime/files/libelf-musl.patch b/srcpkgs/rocm-opencl-runtime/files/libelf-musl.patch
new file mode 100644
index 00000000000..29469a9a351
--- /dev/null
+++ b/srcpkgs/rocm-opencl-runtime/files/libelf-musl.patch
@@ -0,0 +1,21 @@
+--- compiler/lib/loaders/elf/utils/libelf/_libelf.h	2020-04-28 15:50:53.243438174 -0400
++++ compiler/lib/loaders/elf/utils/libelf/_libelf.h	2020-04-28 15:51:54.293435415 -0400
+@@ -35,6 +35,7 @@
+ #include "_libelf_config.h"
+ 
+ #include "_elftc.h"
++#include <sys/cdefs.h>
+ 
+ /*
+  * Library-private data structures.
+--- compiler/lib/loaders/elf/utils/libelf/libelf.h	2020-04-28 15:50:53.244438174 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf.h	2020-04-28 15:52:12.375434593 -0400
+@@ -36,6 +36,8 @@
+ #define EM_HSAIL 0xAF5A
+ #endif
+ 
++#include <sys/cdefs.h>
++
+ /* Library private data structures */
+ typedef struct _Elf Elf;
+ typedef struct _Elf_Scn Elf_Scn;
diff --git a/srcpkgs/rocm-opencl-runtime/files/runtime-musl.patch b/srcpkgs/rocm-opencl-runtime/files/runtime-musl.patch
new file mode 100644
index 00000000000..ea18e90e09c
--- /dev/null
+++ b/srcpkgs/rocm-opencl-runtime/files/runtime-musl.patch
@@ -0,0 +1,11 @@
+--- runtime/os/os_posix.cpp.orig	2020-04-19 09:13:51.701982901 -0400
++++ runtime/os/os_posix.cpp	2020-04-19 09:14:04.156947422 -0400
+@@ -44,6 +44,8 @@
+ #include <algorithm>
+ #include <mutex>
+ 
++#include <libgen.h> // for basename
++
+ 
+ namespace amd {
+ 
diff --git a/srcpkgs/rocm-opencl-runtime/patches/cmake.patch b/srcpkgs/rocm-opencl-runtime/patches/cmake.patch
new file mode 100644
index 00000000000..2c96b99d45a
--- /dev/null
+++ b/srcpkgs/rocm-opencl-runtime/patches/cmake.patch
@@ -0,0 +1,126 @@
+--- OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/CMakeLists.txt	2019-09-10 11:53:28.000000000 -0400
++++ OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/CMakeLists.txt	2020-04-16 20:16:13.481180757 -0400
+@@ -73,11 +73,11 @@
+ 
+ set (OPENCL_ICD_LOADER_HEADERS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/inc CACHE PATH "Path to OpenCL Headers")
+ 
+-add_library (OpenCL ${OPENCL_ICD_LOADER_SOURCES})
+-set_target_properties (OpenCL PROPERTIES VERSION "1.2" SOVERSION "1")
++add_library (OpenCL-ROCm ${OPENCL_ICD_LOADER_SOURCES})
++set_target_properties (OpenCL-ROCm PROPERTIES VERSION "1.2" SOVERSION "1")
+ 
+ if (WIN32)
+-    target_link_libraries (OpenCL cfgmgr32.lib)
++    target_link_libraries (OpenCL-ROCm cfgmgr32.lib)
+ 
+     option (OPENCL_ICD_LOADER_REQUIRE_WDK "Build with D3DKMT support, which requires the Windows WDK." ON)
+     if (OPENCL_ICD_LOADER_REQUIRE_WDK)
+@@ -92,10 +92,10 @@
+             get_filename_component(WDK_DIRECTORY ${LATEST_D3DKMT_HEADER} DIRECTORY)
+             get_filename_component(WDK_DIRECTORY ${WDK_DIRECTORY} DIRECTORY)
+             message(STATUS "Found the Windows WDK in: ${WDK_DIRECTORY}")
+-            target_compile_definitions(OpenCL PRIVATE OPENCL_ICD_LOADER_REQUIRE_WDK)
+-            target_include_directories(OpenCL PRIVATE ${WDK_DIRECTORY}/um)
+-            target_include_directories(OpenCL PRIVATE ${WDK_DIRECTORY}/km)
+-            target_include_directories(OpenCL PRIVATE ${WDK_DIRECTORY}/shared)
++	    target_compile_definitions(OpenCL-ROCm PRIVATE OPENCL_ICD_LOADER_REQUIRE_WDK)
++	    target_include_directories(OpenCL-ROCm PRIVATE ${WDK_DIRECTORY}/um)
++	    target_include_directories(OpenCL-ROCm PRIVATE ${WDK_DIRECTORY}/km)
++	    target_include_directories(OpenCL-ROCm PRIVATE ${WDK_DIRECTORY}/shared)
+         else()
+             message(FATAL_ERROR "The Windows WDK was not found. Consider disabling OPENCL_ICD_LOADER_REQUIRE_WDK. Aborting.")
+         endif()
+@@ -113,25 +113,25 @@
+     endif()
+ else()
+     if (APPLE)
+-        target_link_libraries (OpenCL ${CMAKE_THREAD_LIBS_INIT})
++        target_link_libraries (OpenCL-ROCm ${CMAKE_THREAD_LIBS_INIT})
+     else ()
+-        set_target_properties (OpenCL PROPERTIES LINK_FLAGS "-Wl,--version-script -Wl,${CMAKE_CURRENT_SOURCE_DIR}/loader/linux/icd_exports.map")
+-        target_link_libraries (OpenCL ${CMAKE_THREAD_LIBS_INIT})
++        set_target_properties (OpenCL-ROCm PROPERTIES LINK_FLAGS "-Wl,--version-script -Wl,${CMAKE_CURRENT_SOURCE_DIR}/loader/linux/icd_exports.map")
++	target_link_libraries (OpenCL-ROCm ${CMAKE_THREAD_LIBS_INIT})
+     endif ()
+ endif ()
+ 
+ include_directories (${OPENCL_ICD_LOADER_HEADERS_DIR})
+ add_definitions (-DCL_TARGET_OPENCL_VERSION=220)
+ 
+-target_include_directories (OpenCL PRIVATE ${CMAKE_CURRENT_BINARY_DIR} loader)
+-target_link_libraries (OpenCL ${CMAKE_DL_LIBS})
++target_include_directories (OpenCL-ROCm PRIVATE ${CMAKE_CURRENT_BINARY_DIR} loader)
++target_link_libraries (OpenCL-ROCm ${CMAKE_DL_LIBS})
+ 
+ include (CTest)
+ if (BUILD_TESTING)
+     add_subdirectory (test)
+ endif()
+ 
+-install (TARGETS OpenCL
++install (TARGETS OpenCL-ROCm
+     RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+     ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
+     LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
+--- OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/test/loader_test/CMakeLists.txt	2019-09-10 11:53:28.000000000 -0400
++++ OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/test/loader_test/CMakeLists.txt	2020-04-16 20:16:56.647026589 -0400
+@@ -12,4 +12,4 @@
+     test_clgl.c
+     test_image_objects.c )
+ 
+-target_link_libraries (icd_loader_test OpenCL IcdLog)
++target_link_libraries (icd_loader_test OpenCL-ROCm IcdLog)
+--- ROCm-OpenCL-Runtime-roc-3.3.0/CMakeLists.txt	2020-04-28 07:29:51.864446603 -0400
++++ ROCm-OpenCL-Runtime-roc-3.3.0/CMakeLists.txt	2020-04-28 07:32:45.245793180 -0400
+@@ -101,30 +101,30 @@
+ rocm_setup_version( VERSION "2.0.0" )
+ 
+ # MAIN package
+-install(PROGRAMS $<TARGET_FILE:clinfo>
+-        DESTINATION bin/x86_64
++install(PROGRAMS $<TARGET_FILE:rocm-clinfo>
++        DESTINATION bin
+         COMPONENT MAIN)
+ install(PROGRAMS $<TARGET_FILE:amdocl64>
+-        DESTINATION lib/x86_64
++        DESTINATION lib
+         COMPONENT MAIN)
+-install(PROGRAMS $<TARGET_FILE:OpenCL>
+-        DESTINATION lib/x86_64
++install(PROGRAMS $<TARGET_FILE:OpenCL-ROCm>
++        DESTINATION lib
+         COMPONENT MAIN)
+-install(PROGRAMS $<TARGET_SONAME_FILE:OpenCL>
+-        DESTINATION lib/x86_64
++install(PROGRAMS $<TARGET_SONAME_FILE:OpenCL-ROCm>
++        DESTINATION lib
+         COMPONENT MAIN)
+ 
+ # DEV package
+ install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/api/opencl/khronos/headers/opencl2.2/CL"
+-        DESTINATION include
++	DESTINATION include/rocm
+         COMPONENT DEV
+         USE_SOURCE_PERMISSIONS
+         PATTERN cl_d3d10.h EXCLUDE
+         PATTERN cl_d3d11.h EXCLUDE
+         PATTERN cl_dx9_media_sharing.h EXCLUDE
+         PATTERN cl_egl.h EXCLUDE)
+-install(PROGRAMS $<TARGET_LINKER_FILE:OpenCL>
+-        DESTINATION lib/x86_64
++install(PROGRAMS $<TARGET_LINKER_FILE:OpenCL-ROCm>
++        DESTINATION lib
+         COMPONENT DEV)
+ 
+ # Generic CPACK variables
+--- ROCm-OpenCL-Runtime-roc-3.3.0/tools/clinfo/CMakeLists.txt	2020-04-28 07:29:51.882446535 -0400
++++ ROCm-OpenCL-Runtime-roc-3.3.0/tools/clinfo/CMakeLists.txt	2020-04-28 07:30:05.627394732 -0400
+@@ -6,6 +6,6 @@
+ 
+ add_definitions(-DHAVE_CL2_HPP)
+ 
+-add_executable(clinfo clinfo.cpp)
++add_executable(rocm-clinfo clinfo.cpp)
+ 
+-target_link_libraries(clinfo OpenCL)
++target_link_libraries(rocm-clinfo OpenCL-ROCm)
diff --git a/srcpkgs/rocm-opencl-runtime/template b/srcpkgs/rocm-opencl-runtime/template
new file mode 100644
index 00000000000..dcad3951717
--- /dev/null
+++ b/srcpkgs/rocm-opencl-runtime/template
@@ -0,0 +1,83 @@
+# Template file for 'rocm-opencl-runtime'
+pkgname=rocm-opencl-runtime
+version=3.3.0
+revision=1
+_ocl_icd_name="OpenCL-ICD-Loader"
+_ocl_icd_ver="6c03f8b58fafd9dd693eaac826749a5cfad515f8"
+archs="x86_64*"
+create_wrksrc=yes
+build_wrksrc="ROCm-OpenCL-Runtime-roc-${version}"
+build_style=cmake
+configure_args="-DUSE_COMGR_LIBRARY=yes"
+hostmakedepends="cmake pkg-config"
+makedepends="libglvnd-devel rocm-comgr-devel
+	roct-thunk-interface-devel rocr-runtime-devel"
+depends="rocm-comgr"
+short_desc="Radeon Open Compute OpenCL runtime"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="MIT"
+homepage="https://github.com/RadeonOpenCompute/ROCm-OpenCL-Runtime"
+_rocroot="https://github.com/RadeonOpenCompute"
+distfiles="${_rocroot}/ROCm-OpenCL-Runtime/archive/roc-${version}.tar.gz
+	${_rocroot}/rocm-cmake/archive/rocm-${version}.tar.gz
+	https://github.com/KhronosGroup/${_ocl_icd_name}/archive/${_ocl_icd_ver}.tar.gz"
+checksum="ac6999f1a491ab066286c2bd6adf50f08f831286f56e267879f9f7eced22f98e
+	76ed3ee8e56cf3246011cf7723c2abda539e1136e7e7f6909bfa45d268b8644f
+	c94d5bb6dc980c4d41d73e2b81663a19aabe494e923e2d0eec72a4c95b318438"
+nocross=yes
+
+if [ "$XBPS_LIBC" = "musl" ]; then
+	makedepends+=" musl-legacy-compat"
+fi
+
+post_patch() {
+	if [ "$XBPS_LIBC" = "musl" ]; then
+		# Remove dependence on glibc
+		patch -Np0 < ${FILESDIR}/libelf-musl.patch
+		patch -Np0 < ${FILESDIR}/runtime-musl.patch
+		vsed -e '/glibc_functions.cpp/d' -i api/opencl/amdocl/CMakeLists.txt
+	fi
+}
+
+pre_configure() {
+	# ROCm requires a very specific Khronos ICD loader version in the tree
+	# Keep the ICD loader config in /etc/rocm/vendors to avoid conflicts
+	_ocl_icd_dir="${_ocl_icd_name}-${_ocl_icd_ver}"
+	ln -sf "${wrksrc}/${_ocl_icd_dir}" api/opencl/khronos/icd
+	vsed -i "${wrksrc}/${_ocl_icd_dir}/loader/icd_platform.h" \
+		-e 's@/etc/OpenCL/vendors/@/etc/rocm/vendors/@g'
+
+	# CMake modules probably not useful anywhere but for this build
+	ln -sf "${wrksrc}/rocm-cmake-rocm-${version}/share/rocm/cmake"/*.cmake cmake
+
+	# Fix the dlopen macro to point to versioned libamd_comgr shared object
+	vsed -i 'runtime/device/comgrctx.cpp' \
+		-e 's/\blibamd_comgr\(32\)\?.so\b/&.1/g'
+}
+
+post_install() {
+	vlicense License
+
+	# Create descriptor to allow the ICD loader to find the driver
+	vmkdir etc/rocm/vendors
+	echo "libamdocl64.so" > "${DESTDIR}/etc/rocm/vendors/rocm-amdocl64.icd"
+	vmkdir etc/OpenCL/vendors
+	ln -s ../../rocm/vendors/rocm-amdocl64.icd ${DESTDIR}/etc/OpenCL/vendors
+}
+
+rocm-opencl-runtime-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/lib/libOpenCL-ROCm.so
+		vmove usr/include
+	}
+}
+
+rocm-opencl-runtime-clinfo_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - clinfo"
+	pkg_install() {
+		vmove usr/bin/rocm-clinfo
+	}
+}

From ec828063ede3a3c5403a04a60a0c9797c7153865 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Thu, 30 Apr 2020 13:11:12 -0400
Subject: [PATCH 09/10] New package: rocm-hsa-ext-3.3.0

---
 common/shlibs                 |  2 ++
 srcpkgs/rocm-hsa-ext-devel    |  1 +
 srcpkgs/rocm-hsa-ext/template | 41 +++++++++++++++++++++++++++++++++++
 3 files changed, 44 insertions(+)
 create mode 120000 srcpkgs/rocm-hsa-ext-devel
 create mode 100644 srcpkgs/rocm-hsa-ext/template

diff --git a/common/shlibs b/common/shlibs
index 8cbc885e016..730e6d0d394 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3867,3 +3867,5 @@ libhsa-runtime64.so.1 rocr-runtime-3.3.0_1
 libamd_comgr.so.1 rocm-comgr-3.3.0_1
 libOpenCL-ROCm.so.1 rocm-opencl-runtime-3.3.0_1
 libamdocl64.so rocm-opencl-runtime-3.3.0_1
+libhsa-ext-image64.so.1 rocm-hsa-ext-3.3.0_1
+libhsa-runtime-tools64.so.1 rocm-hsa-ext-3.3.0_1
diff --git a/srcpkgs/rocm-hsa-ext-devel b/srcpkgs/rocm-hsa-ext-devel
new file mode 120000
index 00000000000..d201e9f2fae
--- /dev/null
+++ b/srcpkgs/rocm-hsa-ext-devel
@@ -0,0 +1 @@
+rocm-hsa-ext
\ No newline at end of file
diff --git a/srcpkgs/rocm-hsa-ext/template b/srcpkgs/rocm-hsa-ext/template
new file mode 100644
index 00000000000..a8ca5220cab
--- /dev/null
+++ b/srcpkgs/rocm-hsa-ext/template
@@ -0,0 +1,41 @@
+# Template file for 'rocm-hsa-ext'
+pkgname=rocm-hsa-ext
+version=3.3.0
+revision=1
+archs="x86_64"
+hostmakedepends="tar"
+short_desc="Radeon Open Compute HSA runtime extensions"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute"
+_hsa_deb="hsa-ext-rocr-dev_1.1.30300.0-rocm-rel-3.3-19-23fc088b_amd64.deb"
+distfiles="https://repo.radeon.com/rocm/apt/debian/pool/main/h/hsa-ext-rocr-dev/$_hsa_deb"
+checksum=6b44e286b395d946b865ec1f3cc546356396785ac1fde591d07af02d0aa7c25d
+
+do_extract() {
+	ar x "${XBPS_SRCDISTDIR}/${pkgname}-${version}/${_hsa_deb}"
+	tar xvf data.tar.gz
+}
+
+do_install() {
+	_rocm_includes="opt/rocm-${version}/hsa/include"
+	
+	vmkdir usr
+	vcopy opt/rocm-${version}/hsa/lib usr
+	vcopy "$_rocm_includes" usr
+
+	# Extract license from one of the header files
+	awk 'BEGIN{HEADER=0} /\/\//{HEADER=1; print $0;} /^[^/]/{if(HEADER==1) exit;}' \
+		< "${_rocm_includes}/hsa/amd_hsa_tools_interfaces.h" \
+		| sed 's@^///*\( \|$\)@@' > LICENSE
+	vlicense LICENSE
+}
+
+rocm-hsa-ext-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove "usr/lib/*.so"
+	}
+}

From e1190061e1d8e68b47bc29fc379af57c9bf38b8f Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Tue, 28 Apr 2020 13:33:46 -0400
Subject: [PATCH 10/10] hashcat: add build option to link against ROCm [ci
 skip]

---
 srcpkgs/hashcat/files/rocm.patch     | 15 +++++++++++++++
 srcpkgs/hashcat/patches/tmpdir.patch | 21 +++++++++++++++++++++
 srcpkgs/hashcat/template             | 17 ++++++++++++++---
 3 files changed, 50 insertions(+), 3 deletions(-)
 create mode 100644 srcpkgs/hashcat/files/rocm.patch
 create mode 100644 srcpkgs/hashcat/patches/tmpdir.patch

diff --git a/srcpkgs/hashcat/files/rocm.patch b/srcpkgs/hashcat/files/rocm.patch
new file mode 100644
index 00000000000..f1e899d30ee
--- /dev/null
+++ b/srcpkgs/hashcat/files/rocm.patch
@@ -0,0 +1,15 @@
+diff -ur a/src/opencl.c b/src/opencl.c
+--- a/src/opencl.c	2018-12-02 05:58:48.000000000 -0500
++++ b/src/opencl.c	2020-04-28 13:24:12.602415333 -0400
+@@ -492,9 +492,9 @@
+ 
+   if (ocl->lib == NULL) ocl->lib = hc_dlopen ("cygOpenCL-1.dll", RTLD_NOW);
+   #else
+-  ocl->lib = hc_dlopen ("libOpenCL.so", RTLD_NOW);
++  ocl->lib = hc_dlopen ("libOpenCL-ROCm.so.1", RTLD_NOW);
+ 
+-  if (ocl->lib == NULL) ocl->lib = hc_dlopen ("libOpenCL.so.1", RTLD_NOW);
++  if (ocl->lib == NULL) ocl->lib = hc_dlopen ("libOpenCL-ROCm.so", RTLD_NOW);
+   #endif
+ 
+   if (ocl->lib == NULL)
diff --git a/srcpkgs/hashcat/patches/tmpdir.patch b/srcpkgs/hashcat/patches/tmpdir.patch
new file mode 100644
index 00000000000..0558a001c9c
--- /dev/null
+++ b/srcpkgs/hashcat/patches/tmpdir.patch
@@ -0,0 +1,21 @@
+Addresses https://github.com/hashcat/hashcat/issues/2379
+diff -ur a/src/folder.c b/src/folder.c
+--- src/folder.c	2018-12-02 05:58:48.000000000 -0500
++++ src/folder.c	2020-04-28 13:22:27.340522751 -0400
+@@ -457,16 +457,6 @@
+ 
+   hcfree (cpath);
+ 
+-  //if (getenv ("TMP") == NULL)
+-  if (1)
+-  {
+-    char *tmp;
+-
+-    hc_asprintf (&tmp, "TMP=%s", cpath_real);
+-
+-    putenv (tmp);
+-  }
+-
+   #if defined (_WIN)
+ 
+   naive_replace (cpath_real, '\\', '/');
diff --git a/srcpkgs/hashcat/template b/srcpkgs/hashcat/template
index e982f99cebf..7d3a8cb5a6b 100644
--- a/srcpkgs/hashcat/template
+++ b/srcpkgs/hashcat/template
@@ -1,15 +1,16 @@
 # Template file for 'hashcat'
 pkgname=hashcat
 version=5.1.0
-revision=2
+revision=3
 build_style=gnu-makefile
 make_build_args="PREFIX=/usr
  USE_SYSTEM_OPENCL=1 USE_SYSTEM_XXHASH=1
- DEPS_OPENCL_PATH=${XBPS_CROSS_BASE}/usr/include
+ DEPS_OPENCL_PATH=${XBPS_CROSS_BASE}/usr/include$(vopt_if rocm /rocm)
  DEPS_XXHASH_PATH=${XBPS_CROSS_BASE}/usr/include"
 make_use_env=yes
 make_install_args="$make_build_args"
-makedepends="gmp-devel opencl2-headers xxHash-devel"
+makedepends="gmp-devel xxHash-devel
+ $(vopt_if rocm rocm-opencl-runtime-devel opencl2-headers)"
 checkdepends="perl"
 short_desc="Advanced CPU-based password recovery utility"
 maintainer="Duncaen <duncaen@voidlinux.org>"
@@ -19,6 +20,9 @@ changelog="https://raw.githubusercontent.com/hashcat/hashcat/master/docs/changes
 distfiles="https://hashcat.net/files/hashcat-${version}.tar.gz"
 checksum=283beaa68e1eab41de080a58bb92349c8e47a2bb1b93d10f36ea30f418f1e338
 
+build_options="rocm"
+desc_option_rocm="Use ROCm OpenCL runtime"
+
 if [ "$XBPS_TARGET_ENDIAN" = "be" ]; then
 	broken="Not supported on big endian"
 fi
@@ -26,6 +30,13 @@ fi
 post_extract() {
 	sed '/^CC/d' -i src/Makefile
 }
+
+post_patch() {
+	if [ "$build_option_rocm" ]; then
+		patch -Np1 < ${FILESDIR}/rocm.patch
+	fi
+}
+
 post_install() {
 	rm -f ${DESTDIR}/usr/share/docs/hashcat/license.txt
 	vlicense docs/license.txt

^ permalink raw reply	[flat|nested] 61+ messages in thread

* Re: [PR PATCH] [Updated] New packages: ROCm core and OpenCL
  2020-04-19 13:34 [PR PATCH] New packages: ROCm core and OpenCL ahesford
                   ` (13 preceding siblings ...)
  2020-04-30 19:12 ` ahesford
@ 2020-04-30 19:22 ` ahesford
  2020-04-30 19:32 ` ahesford
                   ` (44 subsequent siblings)
  59 siblings, 0 replies; 61+ messages in thread
From: ahesford @ 2020-04-30 19:22 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 3893 bytes --]

There is an updated pull request by ahesford against master on the void-packages repository

https://github.com/ahesford/void-packages rocm
https://github.com/void-linux/void-packages/pull/21153

New packages: ROCm core and OpenCL
This PR includes several packages designed to bring the OpenCL portion of the AMD ROCm ecosystem to Void. It addresses Issue #19507. There are many other packages that AMD provides for GPGPU computing, but these can be added piecemeal as users demand.

The packages are currently only for `x86_64*`. While at least some of the packages will compile on other 64-bit architectures, I have no hardware to test. They are certainly not suitable for 32-bit architectures; some internal data structures rely on `uint64_t` values that are cast to pointers. At a
minimum, a thorough audit would be necessary to ensure that these casts are safe (e.g., that the values stored were only ever upcast from 32-bit pointers). More extensive work may be necessary to support 32-bit architectures, probably without significant benefit.

The packages successfully identify a Radeon RX 580 on an `x86_64` installation using both `clinfo` and `rocminfo` as provided. Furthermore, a version of `pyopencl` linked against these ROCm packages successfully runs a simple program that validates arithmetic on GPU-bound arrays.

There are caveats with this set of packages, almost all of which revolve around the incompatibilities between the Void-provided `ocl-icd` and the [Khronos OpenCL ICD loader](https://github.com/KhronosGroup/OpenCL-ID-Loader) required by (and built into) `rocm-opencl-runtime`.
1. All packages install into `/opt/rocm`. This keeps the environment closer to that officially sanctioned by AMD and helps avoid conflicts between other packages and those provided here. (For example, `clinfo` and the ICD loader itself.) Eventually, we may be able to move the files into `/usr`.
2. The Khronos OpenCL ICD loader built into `rocm-opencl-runtime` is an outdated, pre-release commit. If AMD can update its sources to use the release version of that loader (which has a backward-incompatible API change), we may be able to make ROCm compatible with `ocl-icd` or replace `ocl-icd` with the official Khronos loader.
3. In the meantime, to avoid `shlibs` conflicts, the OpenCL ICD loader is installed as `/opt/rocm/lib/libOpenCL-ROCm.so` (and an appropriately versioned shared library), which means that programs wishing to use the ROCm OpenCL must explicitly link against this library instead of the generic `libOpenCL.so`.
4. I do **not** recommend making any Void packages link against this specific library, because it will make those packages ROCm-only. For the time being, ROCm is intended for end-users to specifically link against. Linking Void packages against ROCm would requires the ICD loader used by ROCm be compatible with `ocl-icd`, or `ocl-icd` be replaced by the Khronos loader. However, because the Khronos loader changed its API for the release version, such a change is not yet appropriate.

Hopefully, if AMD updates its dependence on the Khronos ICD loader, we can resolve some of these caveats in the future and make ROCm a more natural Void component. For now, these packages are useful for those who need an AMD OpenCL solution and would rather custom-link software against the AMD ICD loader than hack the `amdgpu-pro` driver into an ICD compatible with `ocl-icd`.

Some patches were made to relocate some files in `/opt/rocm` and make everyting build on x86_64-musl`. Where appropriate, these patches will be pushed upstream to clean up the distribution and packaging.

Update: I pushed some new commits to update license information that triggerd an `xlint` failure. I've also disabled CI builds because they will time out on `rocm-llvm`.

A patch file from https://github.com/void-linux/void-packages/pull/21153.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-rocm-21153.patch --]
[-- Type: text/x-diff, Size: 35824 bytes --]

From 1226ae1e7c5eea64be3859bb36eee4fd8c6cccc6 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Mon, 13 Apr 2020 13:08:09 -0400
Subject: [PATCH 01/10] New package: roct-thunk-interface-3.3.0

---
 common/shlibs                                 |  1 +
 srcpkgs/roct-thunk-interface-devel            |  1 +
 .../patches/cmake-dev-libdir.patch            | 10 ++++++
 .../roct-thunk-interface/patches/musl.patch   | 29 ++++++++++++++++
 srcpkgs/roct-thunk-interface/template         | 33 +++++++++++++++++++
 5 files changed, 74 insertions(+)
 create mode 120000 srcpkgs/roct-thunk-interface-devel
 create mode 100644 srcpkgs/roct-thunk-interface/patches/cmake-dev-libdir.patch
 create mode 100644 srcpkgs/roct-thunk-interface/patches/musl.patch
 create mode 100644 srcpkgs/roct-thunk-interface/template

diff --git a/common/shlibs b/common/shlibs
index 6d39ce34c19..d89ae72ae3e 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3862,3 +3862,4 @@ libtagparser.so.9 tagparser-9.1.2_1
 libqtutilities.so.6 qtutilities-6.0.4_1
 libkdsoap.so.1.9.0 KDSoap-1.9.0_1
 libstoken.so.1 stoken-0.92_1
+libhsakmt.so.1 roct-thunk-interface-3.3.0_1
diff --git a/srcpkgs/roct-thunk-interface-devel b/srcpkgs/roct-thunk-interface-devel
new file mode 120000
index 00000000000..ac3f2cc684c
--- /dev/null
+++ b/srcpkgs/roct-thunk-interface-devel
@@ -0,0 +1 @@
+roct-thunk-interface
\ No newline at end of file
diff --git a/srcpkgs/roct-thunk-interface/patches/cmake-dev-libdir.patch b/srcpkgs/roct-thunk-interface/patches/cmake-dev-libdir.patch
new file mode 100644
index 00000000000..98c7f1e459c
--- /dev/null
+++ b/srcpkgs/roct-thunk-interface/patches/cmake-dev-libdir.patch
@@ -0,0 +1,10 @@
+--- CMakeLists.txt.old	2020-04-18 19:45:17.306081135 -0400
++++ CMakeLists.txt	2020-04-18 19:46:51.300753636 -0400
+@@ -146,6 +146,7 @@
+     COMMAND ${CMAKE_COMMAND}
+         -DSOURCE_DIR="${SOURCE_DIR}"
+         -DCMAKE_INSTALL_PREFIX="${CMAKE_INSTALL_PREFIX}"
++        -DCMAKE_INSTALL_LIBDIR="${CMAKE_INSTALL_LIBDIR}"
+         -DCPACK_RPM_PACKAGE_REQUIRES="hsakmt-roct"
+         -DCPACK_PACKAGING_INSTALL_PREFIX="${CPACK_PACKAGING_INSTALL_PREFIX}"
+         -DVERSION="${BUILD_VERSION_STRING}"
diff --git a/srcpkgs/roct-thunk-interface/patches/musl.patch b/srcpkgs/roct-thunk-interface/patches/musl.patch
new file mode 100644
index 00000000000..aeea9832411
--- /dev/null
+++ b/srcpkgs/roct-thunk-interface/patches/musl.patch
@@ -0,0 +1,29 @@
+diff -r -u old/src/libhsakmt.h new/src/libhsakmt.h
+--- src/libhsakmt.h	2020-03-04 15:00:47.000000000 -0500
++++ src/libhsakmt.h	2020-04-13 12:58:30.444865992 -0400
+@@ -54,6 +54,10 @@
+ #define CHECK_KFD_OPEN() \
+ 	do { if (kfd_open_count == 0 || hsakmt_forked) return HSAKMT_STATUS_KERNEL_IO_CHANNEL_NOT_OPENED; } while (0)
+ 
++/*On some platforms, a PAGE_SIZE macro eclipses the extern variable*/
++#ifdef PAGE_SIZE
++#undef PAGE_SIZE
++#endif
+ extern int PAGE_SIZE;
+ extern int PAGE_SHIFT;
+ 
+diff -r -u old/src/topology.c new/src/topology.c
+--- src/topology.c	2020-03-04 15:00:47.000000000 -0500
++++ src/topology.c	2020-04-13 13:01:31.209870701 -0400
+@@ -38,6 +38,11 @@
+ #include "libhsakmt.h"
+ #include "fmm.h"
+ 
++/*Needed on MUSL*/
++#ifndef MAXNAMLEN
++#define MAXNAMLEN PATH_MAX
++#endif
++
+ /* Number of memory banks added by thunk on top of topology
+  * This only includes static heaps like LDS, scratch and SVM,
+  * not for MMIO_REMAP heap. MMIO_REMAP memory bank is reported
diff --git a/srcpkgs/roct-thunk-interface/template b/srcpkgs/roct-thunk-interface/template
new file mode 100644
index 00000000000..55a1fc6074a
--- /dev/null
+++ b/srcpkgs/roct-thunk-interface/template
@@ -0,0 +1,33 @@
+# Template file for 'roct-thunk-interface'
+pkgname=roct-thunk-interface
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="ROCT-Thunk-Interface-roc-${version}"
+build_style=cmake
+make_build_target="all build-dev"
+make_install_target="install install-dev"
+hostmakedepends="cmake pkg-config"
+makedepends="pciutils-devel libnuma-devel"
+short_desc="Radeon Open Compute Thunk Interface"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="MIT"
+homepage="https://github.com/RadeonOpenCompute/ROCT-Thunk-Interface"
+distfiles="${homepage}/archive/roc-${version}.tar.gz"
+checksum=2cabe9d2cfa72031c05d11290837c476182e72d8dec2049298f691143fdd212b
+nocross=yes
+
+post_install() {
+	vlicense LICENSE.md
+}
+
+roct-thunk-interface-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove "usr/lib/*.so"
+		vmove usr/share/pkgconfig
+		vmove usr/lib/cmake
+	}
+}

From d8bb69aca8ebcd167198d858c11e7b7fa326c389 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Mon, 13 Apr 2020 15:27:27 -0400
Subject: [PATCH 02/10] New package: rocr-runtime-3.3.0

---
 common/shlibs                            |  1 +
 srcpkgs/rocr-runtime-devel               |  1 +
 srcpkgs/rocr-runtime/patches/cmake.patch | 27 +++++++++++++++++++++
 srcpkgs/rocr-runtime/template            | 30 ++++++++++++++++++++++++
 4 files changed, 59 insertions(+)
 create mode 120000 srcpkgs/rocr-runtime-devel
 create mode 100644 srcpkgs/rocr-runtime/patches/cmake.patch
 create mode 100644 srcpkgs/rocr-runtime/template

diff --git a/common/shlibs b/common/shlibs
index d89ae72ae3e..499f35752c2 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3863,3 +3863,4 @@ libqtutilities.so.6 qtutilities-6.0.4_1
 libkdsoap.so.1.9.0 KDSoap-1.9.0_1
 libstoken.so.1 stoken-0.92_1
 libhsakmt.so.1 roct-thunk-interface-3.3.0_1
+libhsa-runtime64.so.1 rocr-runtime-3.3.0_1
diff --git a/srcpkgs/rocr-runtime-devel b/srcpkgs/rocr-runtime-devel
new file mode 120000
index 00000000000..be838f22d81
--- /dev/null
+++ b/srcpkgs/rocr-runtime-devel
@@ -0,0 +1 @@
+rocr-runtime
\ No newline at end of file
diff --git a/srcpkgs/rocr-runtime/patches/cmake.patch b/srcpkgs/rocr-runtime/patches/cmake.patch
new file mode 100644
index 00000000000..93b74cd2297
--- /dev/null
+++ b/srcpkgs/rocr-runtime/patches/cmake.patch
@@ -0,0 +1,27 @@
+--- src/CMakeLists.txt.old	2020-04-18 20:01:48.549636995 -0400
++++ src/CMakeLists.txt	2020-04-18 20:04:00.177179781 -0400
+@@ -108,8 +108,8 @@
+ ## ROCr build internal versioning
+ add_definitions ( -DROCR_BUILD_ID=${PACKAGE_VERSION_STRING} )
+ 
+-## Set RUNPATH - ../../lib covers use of the legacy symlink in /hsa/lib/
+-set(CMAKE_INSTALL_RPATH "$ORIGIN;$ORIGIN/../../lib;$ORIGIN/../../lib64;$ORIGIN/../lib64")
++## Set RUNPATH
++set(CMAKE_INSTALL_RPATH "$ORIGIN;$ORIGIN/../lib")
+ 
+ ## ------------------------- Linux Compiler and Linker options -------------------------
+ set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -fexceptions -fno-rtti -fvisibility=hidden -Wno-error=sign-compare -Wno-sign-compare -Wno-write-strings -Wno-conversion-null -fno-math-errno -fno-threadsafe-statics -fmerge-all-constants -fms-extensions -Wno-error=comment -Wno-comment -Wno-error=pointer-arith -Wno-pointer-arith -Wno-error=unused-variable -Wno-error=unused-function" )
+@@ -185,11 +185,8 @@
+ add_custom_target ( hsa_lib_link2 ALL WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMAND ${CMAKE_COMMAND} -E create_symlink ../hsa/lib/${CORE_RUNTIME_LIBRARY}.so.${SO_MAJOR} ${CORE_RUNTIME_LIBRARY}-link.so.${SO_MAJOR} )
+ 
+ ## Set install information
+-install ( TARGETS ${CORE_RUNTIME_TARGET} LIBRARY DESTINATION hsa/lib )
+-install ( DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/inc/ DESTINATION hsa/include/hsa )
+-install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/hsa_include_link DESTINATION include PERMISSIONS OWNER_WRITE OWNER_READ RENAME hsa )
+-install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/${CORE_RUNTIME_LIBRARY}-link.so DESTINATION lib PERMISSIONS OWNER_WRITE OWNER_READ RENAME ${CORE_RUNTIME_LIBRARY}.so )
+-install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/${CORE_RUNTIME_LIBRARY}-link.so.${SO_MAJOR} DESTINATION lib PERMISSIONS OWNER_WRITE OWNER_READ RENAME ${CORE_RUNTIME_LIBRARY}.so.${SO_MAJOR} )
++install ( TARGETS ${CORE_RUNTIME_TARGET} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} )
++install ( DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/inc/ DESTINATION include/hsa )
+ 
+ ## Packaging directives
+ set ( CPACK_GENERATOR "DEB;RPM" CACHE STRING "Package types to build")
diff --git a/srcpkgs/rocr-runtime/template b/srcpkgs/rocr-runtime/template
new file mode 100644
index 00000000000..5ee22140f1f
--- /dev/null
+++ b/srcpkgs/rocr-runtime/template
@@ -0,0 +1,30 @@
+# Template file for 'rocr-runtime'
+pkgname=rocr-runtime
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="ROCR-Runtime-rocm-${version}"
+build_wrksrc="src"
+build_style=cmake
+hostmakedepends="cmake pkg-config"
+makedepends="roct-thunk-interface-devel elfutils-devel"
+short_desc="Radeon Open Compute HSA Runtime"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute/ROCR-Runtime"
+distfiles="${homepage}/archive/rocm-${version}.tar.gz"
+checksum=fa2d2d1f8a61d8a6952d377cf288d78c61776c3c2a666f163cafc3aa19ab0b61
+nocross=yes
+
+post_install() {
+	vlicense ../LICENSE.txt
+}
+
+rocr-runtime-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove "usr/lib/*.so"
+	}
+}

From 5991aaa587df9bdce5c93daf534974432a336acf Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Mon, 13 Apr 2020 18:07:34 -0400
Subject: [PATCH 03/10] New package: rocm-llvm-3.3.0

---
 srcpkgs/rocm-llvm/template | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)
 create mode 100644 srcpkgs/rocm-llvm/template

diff --git a/srcpkgs/rocm-llvm/template b/srcpkgs/rocm-llvm/template
new file mode 100644
index 00000000000..d6e75cd050c
--- /dev/null
+++ b/srcpkgs/rocm-llvm/template
@@ -0,0 +1,26 @@
+# Template file for 'rocm-llvm'
+pkgname=rocm-llvm
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="llvm-project-rocm-ocl-${version}"
+build_wrksrc=llvm
+build_style=cmake
+configure_args="-DCMAKE_INSTALL_PREFIX:PATH=/usr/lib/rocm-llvm
+	-DLLVM_ENABLE_PROJECTS='llvm;clang;lld' -DLLVM_TARGETS_TO_BUILD='AMDGPU'
+	-DLLVM_BUILD_DOCS=NO -DLLVM_ENABLE_OCAMLDOC=OFF
+	-DLLVM_ENABLE_SPHINX=NO -DLLVM_ENABLE_DOXYGEN=OFF
+	-DLLVM_INSTALL_UTILS=ON -DLLVM_VERSION_SUFFIX=roc -DOCAMLFIND=NO"
+hostmakedepends="cmake pkg-config python3"
+short_desc="Radeon Open Compute LLVM toolchain"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="Apache-2.0, NCSA, custom:LLVM-Exceptions"
+homepage="https://github.com/RadeonOpenCompute/llvm-project"
+distfiles="${homepage}/archive/rocm-ocl-${version}.tar.gz"
+checksum=a2bef7042e8e2f2cd8548cb246b88322e1c77188839983dcac8312d56f544dc8
+python_version=3
+nocross=yes
+
+post_install() {
+	vlicense LICENSE.TXT
+}

From 19c7a333ec5877c0e1e57ab9d1438bc0b31520a3 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Tue, 14 Apr 2020 10:25:31 -0400
Subject: [PATCH 04/10] New package: rocm-device-libs-3.3.0

---
 srcpkgs/rocm-device-libs/template | 37 +++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)
 create mode 100644 srcpkgs/rocm-device-libs/template

diff --git a/srcpkgs/rocm-device-libs/template b/srcpkgs/rocm-device-libs/template
new file mode 100644
index 00000000000..fcb4eb0d53e
--- /dev/null
+++ b/srcpkgs/rocm-device-libs/template
@@ -0,0 +1,37 @@
+# Template file for 'rocm-device-libs'
+pkgname=rocm-device-libs
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="ROCm-Device-Libs-rocm-ocl-${version}"
+build_style=cmake
+configure_args="-DLLVM_DIR:PATH=/usr/lib/rocm-llvm
+	-DCMAKE_INSTALL_LIBDIR:PATH=lib/rocm-device-libs"
+hostmakedepends="cmake rocm-llvm"
+short_desc="Radeon Open Compute device libraries"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute/ROCm-Device-Libs"
+distfiles="${homepage}/archive/rocm-ocl-${version}.tar.gz"
+checksum=706b08230790e08ca6a7a2fb7687d6131fd39a562148340e00fa37a6c06769c5
+nocross=yes
+
+pre_configure() {
+	# Put bytecodes in a lib/ subdirectory
+	vsed -i Packages.cmake -e 's@/lib/@/${CMAKE_INSTALL_LIBDIR}/@'
+	vsed -i OCL.cmake -e 's@DESTINATION lib$@DESTINATION ${CMAKE_INSTALL_LIBDIR}@'
+
+	# Build the prepare-builtins executable with native compiler
+	mkdir -p utils/build
+	cd utils/build
+	_prepare_builtins="$PWD/prepare-builtins/prepare-builtins"
+	cmake ${configure_args} ..
+	make ${makejobs}
+
+	# Add path to prepare-builtins for cmake
+	configure_args+=" -DPREPARE_BUILTINS='${_prepare_builtins}'"
+}
+
+post_install() {
+	vlicense LICENSE
+}

From 691d78f81e8346791c5556569cfa00b5b5d133ac Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Mon, 13 Apr 2020 18:30:00 -0400
Subject: [PATCH 05/10] New package: rocm-comgr-3.3.0

---
 common/shlibs               |  1 +
 srcpkgs/rocm-comgr-devel    |  1 +
 srcpkgs/rocm-comgr/template | 32 ++++++++++++++++++++++++++++++++
 3 files changed, 34 insertions(+)
 create mode 120000 srcpkgs/rocm-comgr-devel
 create mode 100644 srcpkgs/rocm-comgr/template

diff --git a/common/shlibs b/common/shlibs
index 499f35752c2..a53de3cf9e0 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3864,3 +3864,4 @@ libkdsoap.so.1.9.0 KDSoap-1.9.0_1
 libstoken.so.1 stoken-0.92_1
 libhsakmt.so.1 roct-thunk-interface-3.3.0_1
 libhsa-runtime64.so.1 rocr-runtime-3.3.0_1
+libamd_comgr.so.1 rocm-comgr-3.3.0_1
diff --git a/srcpkgs/rocm-comgr-devel b/srcpkgs/rocm-comgr-devel
new file mode 120000
index 00000000000..3f5ce255e07
--- /dev/null
+++ b/srcpkgs/rocm-comgr-devel
@@ -0,0 +1 @@
+rocm-comgr
\ No newline at end of file
diff --git a/srcpkgs/rocm-comgr/template b/srcpkgs/rocm-comgr/template
new file mode 100644
index 00000000000..c228bcd4d1f
--- /dev/null
+++ b/srcpkgs/rocm-comgr/template
@@ -0,0 +1,32 @@
+# Template file for 'rocm-comgr'
+pkgname=rocm-comgr
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="ROCm-CompilerSupport-rocm-${version}"
+build_wrksrc="lib/comgr"
+build_style=cmake
+configure_args="-DClang_DIR:PATH=/usr/lib/rocm-llvm/lib/cmake/clang"
+hostmakedepends="cmake pkg-config rocm-llvm"
+makedepends="rocm-device-libs"
+short_desc="Radeon Open Compute Code Object Manager"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="BSD-3-Clause"
+homepage="https://github.com/RadeonOpenCompute/ROCm-CompilerSupport"
+distfiles="${homepage}/archive/rocm-${version}.tar.gz"
+checksum=01e2524e0f28ecd6f46c9720f279207de935d826b0172158792aa3ec86af9ca7
+nocross=yes
+
+post_install() {
+	vlicense LICENSE.txt
+}
+
+rocm-comgr-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove "usr/lib/*.so"
+		vmove usr/lib/cmake
+	}
+}

From 34506fec471194f2746c0fca2b1a8f8de3c02f1c Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Fri, 17 Apr 2020 12:11:25 -0400
Subject: [PATCH 06/10] New package: rocminfo-3.3.0

---
 srcpkgs/rocminfo/template | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
 create mode 100644 srcpkgs/rocminfo/template

diff --git a/srcpkgs/rocminfo/template b/srcpkgs/rocminfo/template
new file mode 100644
index 00000000000..57d0640dd69
--- /dev/null
+++ b/srcpkgs/rocminfo/template
@@ -0,0 +1,22 @@
+# Template file for 'rocminfo'
+pkgname=rocminfo
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="rocminfo-rocm-${version}"
+build_style=cmake
+configure_args="-DROCM_DIR=/usr"
+hostmakedepends="cmake pkg-config"
+makedepends="rocr-runtime-devel"
+short_desc="Radeon Open Compute system information reporter"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute/rocminfo"
+distfiles="${homepage}/archive/rocm-${version}.tar.gz"
+checksum=e666f662c9e465aaabbbd0b109d87e017243cdf1a0898fabf5a90947bb3dbcd7
+nocross=yes
+python_version=3
+
+post_install() {
+	vlicense License.txt
+}

From 673ee21a6905ad3ca6877af58e936900c8d13bf1 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Sun, 19 Apr 2020 15:01:40 -0400
Subject: [PATCH 07/10] New package: rocm-bandwidth-test-3.3.0

---
 srcpkgs/rocm-bandwidth-test/template | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
 create mode 100644 srcpkgs/rocm-bandwidth-test/template

diff --git a/srcpkgs/rocm-bandwidth-test/template b/srcpkgs/rocm-bandwidth-test/template
new file mode 100644
index 00000000000..5c5058b693d
--- /dev/null
+++ b/srcpkgs/rocm-bandwidth-test/template
@@ -0,0 +1,20 @@
+# Template file for 'rocm-bandwidth-test'
+pkgname=rocm-bandwidth-test
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="rocm_bandwidth_test-rocm-${version}"
+build_style=cmake
+hostmakedepends="cmake"
+makedepends="rocr-runtime-devel roct-thunk-interface-devel"
+short_desc="Radeon Open Compute bandwidth test"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute/rocm_bandwidth_test"
+distfiles="${homepage}/archive/rocm-${version}.tar.gz"
+checksum=f5f914073018619dc91662d5bf630903dfa4db9136d603591917fdfb3c9164ce
+nocross=yes
+
+post_install() {
+	vlicense LICENSE.txt
+}

From f04a079a8f29a4171912c5d20135811d7b710ba3 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Tue, 14 Apr 2020 10:25:54 -0400
Subject: [PATCH 08/10] New package: rocm-opencl-runtime-3.3.0

---
 common/shlibs                                 |   2 +
 srcpkgs/rocm-opencl-runtime-clinfo            |   1 +
 srcpkgs/rocm-opencl-runtime-devel             |   1 +
 .../files/libelf-musl.patch                   |  21 +++
 .../files/runtime-musl.patch                  |  11 ++
 .../rocm-opencl-runtime/patches/cmake.patch   | 126 ++++++++++++++++++
 srcpkgs/rocm-opencl-runtime/template          |  84 ++++++++++++
 7 files changed, 246 insertions(+)
 create mode 120000 srcpkgs/rocm-opencl-runtime-clinfo
 create mode 120000 srcpkgs/rocm-opencl-runtime-devel
 create mode 100644 srcpkgs/rocm-opencl-runtime/files/libelf-musl.patch
 create mode 100644 srcpkgs/rocm-opencl-runtime/files/runtime-musl.patch
 create mode 100644 srcpkgs/rocm-opencl-runtime/patches/cmake.patch
 create mode 100644 srcpkgs/rocm-opencl-runtime/template

diff --git a/common/shlibs b/common/shlibs
index a53de3cf9e0..8cbc885e016 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3865,3 +3865,5 @@ libstoken.so.1 stoken-0.92_1
 libhsakmt.so.1 roct-thunk-interface-3.3.0_1
 libhsa-runtime64.so.1 rocr-runtime-3.3.0_1
 libamd_comgr.so.1 rocm-comgr-3.3.0_1
+libOpenCL-ROCm.so.1 rocm-opencl-runtime-3.3.0_1
+libamdocl64.so rocm-opencl-runtime-3.3.0_1
diff --git a/srcpkgs/rocm-opencl-runtime-clinfo b/srcpkgs/rocm-opencl-runtime-clinfo
new file mode 120000
index 00000000000..b2cda7e229d
--- /dev/null
+++ b/srcpkgs/rocm-opencl-runtime-clinfo
@@ -0,0 +1 @@
+rocm-opencl-runtime
\ No newline at end of file
diff --git a/srcpkgs/rocm-opencl-runtime-devel b/srcpkgs/rocm-opencl-runtime-devel
new file mode 120000
index 00000000000..b2cda7e229d
--- /dev/null
+++ b/srcpkgs/rocm-opencl-runtime-devel
@@ -0,0 +1 @@
+rocm-opencl-runtime
\ No newline at end of file
diff --git a/srcpkgs/rocm-opencl-runtime/files/libelf-musl.patch b/srcpkgs/rocm-opencl-runtime/files/libelf-musl.patch
new file mode 100644
index 00000000000..29469a9a351
--- /dev/null
+++ b/srcpkgs/rocm-opencl-runtime/files/libelf-musl.patch
@@ -0,0 +1,21 @@
+--- compiler/lib/loaders/elf/utils/libelf/_libelf.h	2020-04-28 15:50:53.243438174 -0400
++++ compiler/lib/loaders/elf/utils/libelf/_libelf.h	2020-04-28 15:51:54.293435415 -0400
+@@ -35,6 +35,7 @@
+ #include "_libelf_config.h"
+ 
+ #include "_elftc.h"
++#include <sys/cdefs.h>
+ 
+ /*
+  * Library-private data structures.
+--- compiler/lib/loaders/elf/utils/libelf/libelf.h	2020-04-28 15:50:53.244438174 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf.h	2020-04-28 15:52:12.375434593 -0400
+@@ -36,6 +36,8 @@
+ #define EM_HSAIL 0xAF5A
+ #endif
+ 
++#include <sys/cdefs.h>
++
+ /* Library private data structures */
+ typedef struct _Elf Elf;
+ typedef struct _Elf_Scn Elf_Scn;
diff --git a/srcpkgs/rocm-opencl-runtime/files/runtime-musl.patch b/srcpkgs/rocm-opencl-runtime/files/runtime-musl.patch
new file mode 100644
index 00000000000..ea18e90e09c
--- /dev/null
+++ b/srcpkgs/rocm-opencl-runtime/files/runtime-musl.patch
@@ -0,0 +1,11 @@
+--- runtime/os/os_posix.cpp.orig	2020-04-19 09:13:51.701982901 -0400
++++ runtime/os/os_posix.cpp	2020-04-19 09:14:04.156947422 -0400
+@@ -44,6 +44,8 @@
+ #include <algorithm>
+ #include <mutex>
+ 
++#include <libgen.h> // for basename
++
+ 
+ namespace amd {
+ 
diff --git a/srcpkgs/rocm-opencl-runtime/patches/cmake.patch b/srcpkgs/rocm-opencl-runtime/patches/cmake.patch
new file mode 100644
index 00000000000..2c96b99d45a
--- /dev/null
+++ b/srcpkgs/rocm-opencl-runtime/patches/cmake.patch
@@ -0,0 +1,126 @@
+--- OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/CMakeLists.txt	2019-09-10 11:53:28.000000000 -0400
++++ OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/CMakeLists.txt	2020-04-16 20:16:13.481180757 -0400
+@@ -73,11 +73,11 @@
+ 
+ set (OPENCL_ICD_LOADER_HEADERS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/inc CACHE PATH "Path to OpenCL Headers")
+ 
+-add_library (OpenCL ${OPENCL_ICD_LOADER_SOURCES})
+-set_target_properties (OpenCL PROPERTIES VERSION "1.2" SOVERSION "1")
++add_library (OpenCL-ROCm ${OPENCL_ICD_LOADER_SOURCES})
++set_target_properties (OpenCL-ROCm PROPERTIES VERSION "1.2" SOVERSION "1")
+ 
+ if (WIN32)
+-    target_link_libraries (OpenCL cfgmgr32.lib)
++    target_link_libraries (OpenCL-ROCm cfgmgr32.lib)
+ 
+     option (OPENCL_ICD_LOADER_REQUIRE_WDK "Build with D3DKMT support, which requires the Windows WDK." ON)
+     if (OPENCL_ICD_LOADER_REQUIRE_WDK)
+@@ -92,10 +92,10 @@
+             get_filename_component(WDK_DIRECTORY ${LATEST_D3DKMT_HEADER} DIRECTORY)
+             get_filename_component(WDK_DIRECTORY ${WDK_DIRECTORY} DIRECTORY)
+             message(STATUS "Found the Windows WDK in: ${WDK_DIRECTORY}")
+-            target_compile_definitions(OpenCL PRIVATE OPENCL_ICD_LOADER_REQUIRE_WDK)
+-            target_include_directories(OpenCL PRIVATE ${WDK_DIRECTORY}/um)
+-            target_include_directories(OpenCL PRIVATE ${WDK_DIRECTORY}/km)
+-            target_include_directories(OpenCL PRIVATE ${WDK_DIRECTORY}/shared)
++	    target_compile_definitions(OpenCL-ROCm PRIVATE OPENCL_ICD_LOADER_REQUIRE_WDK)
++	    target_include_directories(OpenCL-ROCm PRIVATE ${WDK_DIRECTORY}/um)
++	    target_include_directories(OpenCL-ROCm PRIVATE ${WDK_DIRECTORY}/km)
++	    target_include_directories(OpenCL-ROCm PRIVATE ${WDK_DIRECTORY}/shared)
+         else()
+             message(FATAL_ERROR "The Windows WDK was not found. Consider disabling OPENCL_ICD_LOADER_REQUIRE_WDK. Aborting.")
+         endif()
+@@ -113,25 +113,25 @@
+     endif()
+ else()
+     if (APPLE)
+-        target_link_libraries (OpenCL ${CMAKE_THREAD_LIBS_INIT})
++        target_link_libraries (OpenCL-ROCm ${CMAKE_THREAD_LIBS_INIT})
+     else ()
+-        set_target_properties (OpenCL PROPERTIES LINK_FLAGS "-Wl,--version-script -Wl,${CMAKE_CURRENT_SOURCE_DIR}/loader/linux/icd_exports.map")
+-        target_link_libraries (OpenCL ${CMAKE_THREAD_LIBS_INIT})
++        set_target_properties (OpenCL-ROCm PROPERTIES LINK_FLAGS "-Wl,--version-script -Wl,${CMAKE_CURRENT_SOURCE_DIR}/loader/linux/icd_exports.map")
++	target_link_libraries (OpenCL-ROCm ${CMAKE_THREAD_LIBS_INIT})
+     endif ()
+ endif ()
+ 
+ include_directories (${OPENCL_ICD_LOADER_HEADERS_DIR})
+ add_definitions (-DCL_TARGET_OPENCL_VERSION=220)
+ 
+-target_include_directories (OpenCL PRIVATE ${CMAKE_CURRENT_BINARY_DIR} loader)
+-target_link_libraries (OpenCL ${CMAKE_DL_LIBS})
++target_include_directories (OpenCL-ROCm PRIVATE ${CMAKE_CURRENT_BINARY_DIR} loader)
++target_link_libraries (OpenCL-ROCm ${CMAKE_DL_LIBS})
+ 
+ include (CTest)
+ if (BUILD_TESTING)
+     add_subdirectory (test)
+ endif()
+ 
+-install (TARGETS OpenCL
++install (TARGETS OpenCL-ROCm
+     RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+     ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
+     LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
+--- OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/test/loader_test/CMakeLists.txt	2019-09-10 11:53:28.000000000 -0400
++++ OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/test/loader_test/CMakeLists.txt	2020-04-16 20:16:56.647026589 -0400
+@@ -12,4 +12,4 @@
+     test_clgl.c
+     test_image_objects.c )
+ 
+-target_link_libraries (icd_loader_test OpenCL IcdLog)
++target_link_libraries (icd_loader_test OpenCL-ROCm IcdLog)
+--- ROCm-OpenCL-Runtime-roc-3.3.0/CMakeLists.txt	2020-04-28 07:29:51.864446603 -0400
++++ ROCm-OpenCL-Runtime-roc-3.3.0/CMakeLists.txt	2020-04-28 07:32:45.245793180 -0400
+@@ -101,30 +101,30 @@
+ rocm_setup_version( VERSION "2.0.0" )
+ 
+ # MAIN package
+-install(PROGRAMS $<TARGET_FILE:clinfo>
+-        DESTINATION bin/x86_64
++install(PROGRAMS $<TARGET_FILE:rocm-clinfo>
++        DESTINATION bin
+         COMPONENT MAIN)
+ install(PROGRAMS $<TARGET_FILE:amdocl64>
+-        DESTINATION lib/x86_64
++        DESTINATION lib
+         COMPONENT MAIN)
+-install(PROGRAMS $<TARGET_FILE:OpenCL>
+-        DESTINATION lib/x86_64
++install(PROGRAMS $<TARGET_FILE:OpenCL-ROCm>
++        DESTINATION lib
+         COMPONENT MAIN)
+-install(PROGRAMS $<TARGET_SONAME_FILE:OpenCL>
+-        DESTINATION lib/x86_64
++install(PROGRAMS $<TARGET_SONAME_FILE:OpenCL-ROCm>
++        DESTINATION lib
+         COMPONENT MAIN)
+ 
+ # DEV package
+ install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/api/opencl/khronos/headers/opencl2.2/CL"
+-        DESTINATION include
++	DESTINATION include/rocm
+         COMPONENT DEV
+         USE_SOURCE_PERMISSIONS
+         PATTERN cl_d3d10.h EXCLUDE
+         PATTERN cl_d3d11.h EXCLUDE
+         PATTERN cl_dx9_media_sharing.h EXCLUDE
+         PATTERN cl_egl.h EXCLUDE)
+-install(PROGRAMS $<TARGET_LINKER_FILE:OpenCL>
+-        DESTINATION lib/x86_64
++install(PROGRAMS $<TARGET_LINKER_FILE:OpenCL-ROCm>
++        DESTINATION lib
+         COMPONENT DEV)
+ 
+ # Generic CPACK variables
+--- ROCm-OpenCL-Runtime-roc-3.3.0/tools/clinfo/CMakeLists.txt	2020-04-28 07:29:51.882446535 -0400
++++ ROCm-OpenCL-Runtime-roc-3.3.0/tools/clinfo/CMakeLists.txt	2020-04-28 07:30:05.627394732 -0400
+@@ -6,6 +6,6 @@
+ 
+ add_definitions(-DHAVE_CL2_HPP)
+ 
+-add_executable(clinfo clinfo.cpp)
++add_executable(rocm-clinfo clinfo.cpp)
+ 
+-target_link_libraries(clinfo OpenCL)
++target_link_libraries(rocm-clinfo OpenCL-ROCm)
diff --git a/srcpkgs/rocm-opencl-runtime/template b/srcpkgs/rocm-opencl-runtime/template
new file mode 100644
index 00000000000..02aebb91bd8
--- /dev/null
+++ b/srcpkgs/rocm-opencl-runtime/template
@@ -0,0 +1,84 @@
+# Template file for 'rocm-opencl-runtime'
+pkgname=rocm-opencl-runtime
+version=3.3.0
+revision=1
+_ocl_icd_name="OpenCL-ICD-Loader"
+_ocl_icd_ver="6c03f8b58fafd9dd693eaac826749a5cfad515f8"
+archs="x86_64*"
+create_wrksrc=yes
+build_wrksrc="ROCm-OpenCL-Runtime-roc-${version}"
+build_style=cmake
+configure_args="-DUSE_COMGR_LIBRARY=yes"
+hostmakedepends="cmake pkg-config"
+makedepends="libglvnd-devel rocm-comgr-devel
+	roct-thunk-interface-devel rocr-runtime-devel"
+depends="rocm-comgr"
+short_desc="Radeon Open Compute OpenCL runtime"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="MIT"
+homepage="https://github.com/RadeonOpenCompute/ROCm-OpenCL-Runtime"
+_rocroot="https://github.com/RadeonOpenCompute"
+distfiles="${_rocroot}/ROCm-OpenCL-Runtime/archive/roc-${version}.tar.gz
+	${_rocroot}/rocm-cmake/archive/rocm-${version}.tar.gz
+	https://github.com/KhronosGroup/${_ocl_icd_name}/archive/${_ocl_icd_ver}.tar.gz"
+checksum="ac6999f1a491ab066286c2bd6adf50f08f831286f56e267879f9f7eced22f98e
+	76ed3ee8e56cf3246011cf7723c2abda539e1136e7e7f6909bfa45d268b8644f
+	c94d5bb6dc980c4d41d73e2b81663a19aabe494e923e2d0eec72a4c95b318438"
+nocross=yes
+
+if [ "$XBPS_LIBC" = "musl" ]; then
+	makedepends+=" musl-legacy-compat"
+fi
+
+post_patch() {
+	if [ "$XBPS_LIBC" = "musl" ]; then
+		# Remove dependence on glibc
+		patch -Np0 < ${FILESDIR}/libelf-musl.patch
+		patch -Np0 < ${FILESDIR}/runtime-musl.patch
+		vsed -e '/glibc_functions.cpp/d' -i api/opencl/amdocl/CMakeLists.txt
+	fi
+}
+
+pre_configure() {
+	# ROCm requires a very specific Khronos ICD loader version in the tree
+	# Keep the ICD loader config in /etc/OpenCL/rocm-vendors to avoid conflicts
+	_ocl_icd_dir="${_ocl_icd_name}-${_ocl_icd_ver}"
+	ln -sf "${wrksrc}/${_ocl_icd_dir}" api/opencl/khronos/icd
+	vsed -i "${wrksrc}/${_ocl_icd_dir}/loader/icd_platform.h" \
+		-e 's@/etc/OpenCL/vendors/@/etc/OpenCL/rocm-vendors/@g'
+
+	# CMake modules probably not useful anywhere but for this build
+	ln -sf "${wrksrc}/rocm-cmake-rocm-${version}/share/rocm/cmake"/*.cmake cmake
+
+	# Fix the dlopen macro to point to versioned libamd_comgr shared object
+	vsed -i 'runtime/device/comgrctx.cpp' \
+		-e 's/\blibamd_comgr\(32\)\?.so\b/&.1/g'
+}
+
+post_install() {
+	vlicense License
+
+	# Create descriptor to allow the ICD loader to find the driver
+	vmkdir etc/OpenCL/rocm-vendors
+	echo "libamdocl64.so" > "${DESTDIR}/etc/OpenCL/rocm-vendors/amdocl64.icd"
+	vmkdir etc/OpenCL/vendors
+	ln -s ../../OpenCL/rocm-vendors/amdocl64.icd \
+		${DESTDIR}/etc/OpenCL/vendors/rocm-amdocl64.icd
+}
+
+rocm-opencl-runtime-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/lib/libOpenCL-ROCm.so
+		vmove usr/include
+	}
+}
+
+rocm-opencl-runtime-clinfo_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - clinfo"
+	pkg_install() {
+		vmove usr/bin/rocm-clinfo
+	}
+}

From 569181bd267f4dbc71640eeac4737b8390597a01 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Thu, 30 Apr 2020 13:11:12 -0400
Subject: [PATCH 09/10] New package: rocm-hsa-ext-3.3.0

---
 common/shlibs                 |  2 ++
 srcpkgs/rocm-hsa-ext-devel    |  1 +
 srcpkgs/rocm-hsa-ext/template | 41 +++++++++++++++++++++++++++++++++++
 3 files changed, 44 insertions(+)
 create mode 120000 srcpkgs/rocm-hsa-ext-devel
 create mode 100644 srcpkgs/rocm-hsa-ext/template

diff --git a/common/shlibs b/common/shlibs
index 8cbc885e016..730e6d0d394 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3867,3 +3867,5 @@ libhsa-runtime64.so.1 rocr-runtime-3.3.0_1
 libamd_comgr.so.1 rocm-comgr-3.3.0_1
 libOpenCL-ROCm.so.1 rocm-opencl-runtime-3.3.0_1
 libamdocl64.so rocm-opencl-runtime-3.3.0_1
+libhsa-ext-image64.so.1 rocm-hsa-ext-3.3.0_1
+libhsa-runtime-tools64.so.1 rocm-hsa-ext-3.3.0_1
diff --git a/srcpkgs/rocm-hsa-ext-devel b/srcpkgs/rocm-hsa-ext-devel
new file mode 120000
index 00000000000..d201e9f2fae
--- /dev/null
+++ b/srcpkgs/rocm-hsa-ext-devel
@@ -0,0 +1 @@
+rocm-hsa-ext
\ No newline at end of file
diff --git a/srcpkgs/rocm-hsa-ext/template b/srcpkgs/rocm-hsa-ext/template
new file mode 100644
index 00000000000..a8ca5220cab
--- /dev/null
+++ b/srcpkgs/rocm-hsa-ext/template
@@ -0,0 +1,41 @@
+# Template file for 'rocm-hsa-ext'
+pkgname=rocm-hsa-ext
+version=3.3.0
+revision=1
+archs="x86_64"
+hostmakedepends="tar"
+short_desc="Radeon Open Compute HSA runtime extensions"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute"
+_hsa_deb="hsa-ext-rocr-dev_1.1.30300.0-rocm-rel-3.3-19-23fc088b_amd64.deb"
+distfiles="https://repo.radeon.com/rocm/apt/debian/pool/main/h/hsa-ext-rocr-dev/$_hsa_deb"
+checksum=6b44e286b395d946b865ec1f3cc546356396785ac1fde591d07af02d0aa7c25d
+
+do_extract() {
+	ar x "${XBPS_SRCDISTDIR}/${pkgname}-${version}/${_hsa_deb}"
+	tar xvf data.tar.gz
+}
+
+do_install() {
+	_rocm_includes="opt/rocm-${version}/hsa/include"
+	
+	vmkdir usr
+	vcopy opt/rocm-${version}/hsa/lib usr
+	vcopy "$_rocm_includes" usr
+
+	# Extract license from one of the header files
+	awk 'BEGIN{HEADER=0} /\/\//{HEADER=1; print $0;} /^[^/]/{if(HEADER==1) exit;}' \
+		< "${_rocm_includes}/hsa/amd_hsa_tools_interfaces.h" \
+		| sed 's@^///*\( \|$\)@@' > LICENSE
+	vlicense LICENSE
+}
+
+rocm-hsa-ext-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove "usr/lib/*.so"
+	}
+}

From 3fbceea5da283259edac7ec3a6f7cba9d70cecff Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Tue, 28 Apr 2020 13:33:46 -0400
Subject: [PATCH 10/10] hashcat: add build option to link against ROCm [ci
 skip]

---
 srcpkgs/hashcat/files/rocm.patch     | 15 +++++++++++++++
 srcpkgs/hashcat/patches/tmpdir.patch | 21 +++++++++++++++++++++
 srcpkgs/hashcat/template             | 17 ++++++++++++++---
 3 files changed, 50 insertions(+), 3 deletions(-)
 create mode 100644 srcpkgs/hashcat/files/rocm.patch
 create mode 100644 srcpkgs/hashcat/patches/tmpdir.patch

diff --git a/srcpkgs/hashcat/files/rocm.patch b/srcpkgs/hashcat/files/rocm.patch
new file mode 100644
index 00000000000..f1e899d30ee
--- /dev/null
+++ b/srcpkgs/hashcat/files/rocm.patch
@@ -0,0 +1,15 @@
+diff -ur a/src/opencl.c b/src/opencl.c
+--- a/src/opencl.c	2018-12-02 05:58:48.000000000 -0500
++++ b/src/opencl.c	2020-04-28 13:24:12.602415333 -0400
+@@ -492,9 +492,9 @@
+ 
+   if (ocl->lib == NULL) ocl->lib = hc_dlopen ("cygOpenCL-1.dll", RTLD_NOW);
+   #else
+-  ocl->lib = hc_dlopen ("libOpenCL.so", RTLD_NOW);
++  ocl->lib = hc_dlopen ("libOpenCL-ROCm.so.1", RTLD_NOW);
+ 
+-  if (ocl->lib == NULL) ocl->lib = hc_dlopen ("libOpenCL.so.1", RTLD_NOW);
++  if (ocl->lib == NULL) ocl->lib = hc_dlopen ("libOpenCL-ROCm.so", RTLD_NOW);
+   #endif
+ 
+   if (ocl->lib == NULL)
diff --git a/srcpkgs/hashcat/patches/tmpdir.patch b/srcpkgs/hashcat/patches/tmpdir.patch
new file mode 100644
index 00000000000..0558a001c9c
--- /dev/null
+++ b/srcpkgs/hashcat/patches/tmpdir.patch
@@ -0,0 +1,21 @@
+Addresses https://github.com/hashcat/hashcat/issues/2379
+diff -ur a/src/folder.c b/src/folder.c
+--- src/folder.c	2018-12-02 05:58:48.000000000 -0500
++++ src/folder.c	2020-04-28 13:22:27.340522751 -0400
+@@ -457,16 +457,6 @@
+ 
+   hcfree (cpath);
+ 
+-  //if (getenv ("TMP") == NULL)
+-  if (1)
+-  {
+-    char *tmp;
+-
+-    hc_asprintf (&tmp, "TMP=%s", cpath_real);
+-
+-    putenv (tmp);
+-  }
+-
+   #if defined (_WIN)
+ 
+   naive_replace (cpath_real, '\\', '/');
diff --git a/srcpkgs/hashcat/template b/srcpkgs/hashcat/template
index e982f99cebf..7d3a8cb5a6b 100644
--- a/srcpkgs/hashcat/template
+++ b/srcpkgs/hashcat/template
@@ -1,15 +1,16 @@
 # Template file for 'hashcat'
 pkgname=hashcat
 version=5.1.0
-revision=2
+revision=3
 build_style=gnu-makefile
 make_build_args="PREFIX=/usr
  USE_SYSTEM_OPENCL=1 USE_SYSTEM_XXHASH=1
- DEPS_OPENCL_PATH=${XBPS_CROSS_BASE}/usr/include
+ DEPS_OPENCL_PATH=${XBPS_CROSS_BASE}/usr/include$(vopt_if rocm /rocm)
  DEPS_XXHASH_PATH=${XBPS_CROSS_BASE}/usr/include"
 make_use_env=yes
 make_install_args="$make_build_args"
-makedepends="gmp-devel opencl2-headers xxHash-devel"
+makedepends="gmp-devel xxHash-devel
+ $(vopt_if rocm rocm-opencl-runtime-devel opencl2-headers)"
 checkdepends="perl"
 short_desc="Advanced CPU-based password recovery utility"
 maintainer="Duncaen <duncaen@voidlinux.org>"
@@ -19,6 +20,9 @@ changelog="https://raw.githubusercontent.com/hashcat/hashcat/master/docs/changes
 distfiles="https://hashcat.net/files/hashcat-${version}.tar.gz"
 checksum=283beaa68e1eab41de080a58bb92349c8e47a2bb1b93d10f36ea30f418f1e338
 
+build_options="rocm"
+desc_option_rocm="Use ROCm OpenCL runtime"
+
 if [ "$XBPS_TARGET_ENDIAN" = "be" ]; then
 	broken="Not supported on big endian"
 fi
@@ -26,6 +30,13 @@ fi
 post_extract() {
 	sed '/^CC/d' -i src/Makefile
 }
+
+post_patch() {
+	if [ "$build_option_rocm" ]; then
+		patch -Np1 < ${FILESDIR}/rocm.patch
+	fi
+}
+
 post_install() {
 	rm -f ${DESTDIR}/usr/share/docs/hashcat/license.txt
 	vlicense docs/license.txt

^ permalink raw reply	[flat|nested] 61+ messages in thread

* Re: [PR PATCH] [Updated] New packages: ROCm core and OpenCL
  2020-04-19 13:34 [PR PATCH] New packages: ROCm core and OpenCL ahesford
                   ` (14 preceding siblings ...)
  2020-04-30 19:22 ` ahesford
@ 2020-04-30 19:32 ` ahesford
  2020-04-30 19:35 ` ahesford
                   ` (43 subsequent siblings)
  59 siblings, 0 replies; 61+ messages in thread
From: ahesford @ 2020-04-30 19:32 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 3893 bytes --]

There is an updated pull request by ahesford against master on the void-packages repository

https://github.com/ahesford/void-packages rocm
https://github.com/void-linux/void-packages/pull/21153

New packages: ROCm core and OpenCL
This PR includes several packages designed to bring the OpenCL portion of the AMD ROCm ecosystem to Void. It addresses Issue #19507. There are many other packages that AMD provides for GPGPU computing, but these can be added piecemeal as users demand.

The packages are currently only for `x86_64*`. While at least some of the packages will compile on other 64-bit architectures, I have no hardware to test. They are certainly not suitable for 32-bit architectures; some internal data structures rely on `uint64_t` values that are cast to pointers. At a
minimum, a thorough audit would be necessary to ensure that these casts are safe (e.g., that the values stored were only ever upcast from 32-bit pointers). More extensive work may be necessary to support 32-bit architectures, probably without significant benefit.

The packages successfully identify a Radeon RX 580 on an `x86_64` installation using both `clinfo` and `rocminfo` as provided. Furthermore, a version of `pyopencl` linked against these ROCm packages successfully runs a simple program that validates arithmetic on GPU-bound arrays.

There are caveats with this set of packages, almost all of which revolve around the incompatibilities between the Void-provided `ocl-icd` and the [Khronos OpenCL ICD loader](https://github.com/KhronosGroup/OpenCL-ID-Loader) required by (and built into) `rocm-opencl-runtime`.
1. All packages install into `/opt/rocm`. This keeps the environment closer to that officially sanctioned by AMD and helps avoid conflicts between other packages and those provided here. (For example, `clinfo` and the ICD loader itself.) Eventually, we may be able to move the files into `/usr`.
2. The Khronos OpenCL ICD loader built into `rocm-opencl-runtime` is an outdated, pre-release commit. If AMD can update its sources to use the release version of that loader (which has a backward-incompatible API change), we may be able to make ROCm compatible with `ocl-icd` or replace `ocl-icd` with the official Khronos loader.
3. In the meantime, to avoid `shlibs` conflicts, the OpenCL ICD loader is installed as `/opt/rocm/lib/libOpenCL-ROCm.so` (and an appropriately versioned shared library), which means that programs wishing to use the ROCm OpenCL must explicitly link against this library instead of the generic `libOpenCL.so`.
4. I do **not** recommend making any Void packages link against this specific library, because it will make those packages ROCm-only. For the time being, ROCm is intended for end-users to specifically link against. Linking Void packages against ROCm would requires the ICD loader used by ROCm be compatible with `ocl-icd`, or `ocl-icd` be replaced by the Khronos loader. However, because the Khronos loader changed its API for the release version, such a change is not yet appropriate.

Hopefully, if AMD updates its dependence on the Khronos ICD loader, we can resolve some of these caveats in the future and make ROCm a more natural Void component. For now, these packages are useful for those who need an AMD OpenCL solution and would rather custom-link software against the AMD ICD loader than hack the `amdgpu-pro` driver into an ICD compatible with `ocl-icd`.

Some patches were made to relocate some files in `/opt/rocm` and make everyting build on x86_64-musl`. Where appropriate, these patches will be pushed upstream to clean up the distribution and packaging.

Update: I pushed some new commits to update license information that triggerd an `xlint` failure. I've also disabled CI builds because they will time out on `rocm-llvm`.

A patch file from https://github.com/void-linux/void-packages/pull/21153.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-rocm-21153.patch --]
[-- Type: text/x-diff, Size: 35844 bytes --]

From 1226ae1e7c5eea64be3859bb36eee4fd8c6cccc6 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Mon, 13 Apr 2020 13:08:09 -0400
Subject: [PATCH 01/10] New package: roct-thunk-interface-3.3.0

---
 common/shlibs                                 |  1 +
 srcpkgs/roct-thunk-interface-devel            |  1 +
 .../patches/cmake-dev-libdir.patch            | 10 ++++++
 .../roct-thunk-interface/patches/musl.patch   | 29 ++++++++++++++++
 srcpkgs/roct-thunk-interface/template         | 33 +++++++++++++++++++
 5 files changed, 74 insertions(+)
 create mode 120000 srcpkgs/roct-thunk-interface-devel
 create mode 100644 srcpkgs/roct-thunk-interface/patches/cmake-dev-libdir.patch
 create mode 100644 srcpkgs/roct-thunk-interface/patches/musl.patch
 create mode 100644 srcpkgs/roct-thunk-interface/template

diff --git a/common/shlibs b/common/shlibs
index 6d39ce34c19..d89ae72ae3e 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3862,3 +3862,4 @@ libtagparser.so.9 tagparser-9.1.2_1
 libqtutilities.so.6 qtutilities-6.0.4_1
 libkdsoap.so.1.9.0 KDSoap-1.9.0_1
 libstoken.so.1 stoken-0.92_1
+libhsakmt.so.1 roct-thunk-interface-3.3.0_1
diff --git a/srcpkgs/roct-thunk-interface-devel b/srcpkgs/roct-thunk-interface-devel
new file mode 120000
index 00000000000..ac3f2cc684c
--- /dev/null
+++ b/srcpkgs/roct-thunk-interface-devel
@@ -0,0 +1 @@
+roct-thunk-interface
\ No newline at end of file
diff --git a/srcpkgs/roct-thunk-interface/patches/cmake-dev-libdir.patch b/srcpkgs/roct-thunk-interface/patches/cmake-dev-libdir.patch
new file mode 100644
index 00000000000..98c7f1e459c
--- /dev/null
+++ b/srcpkgs/roct-thunk-interface/patches/cmake-dev-libdir.patch
@@ -0,0 +1,10 @@
+--- CMakeLists.txt.old	2020-04-18 19:45:17.306081135 -0400
++++ CMakeLists.txt	2020-04-18 19:46:51.300753636 -0400
+@@ -146,6 +146,7 @@
+     COMMAND ${CMAKE_COMMAND}
+         -DSOURCE_DIR="${SOURCE_DIR}"
+         -DCMAKE_INSTALL_PREFIX="${CMAKE_INSTALL_PREFIX}"
++        -DCMAKE_INSTALL_LIBDIR="${CMAKE_INSTALL_LIBDIR}"
+         -DCPACK_RPM_PACKAGE_REQUIRES="hsakmt-roct"
+         -DCPACK_PACKAGING_INSTALL_PREFIX="${CPACK_PACKAGING_INSTALL_PREFIX}"
+         -DVERSION="${BUILD_VERSION_STRING}"
diff --git a/srcpkgs/roct-thunk-interface/patches/musl.patch b/srcpkgs/roct-thunk-interface/patches/musl.patch
new file mode 100644
index 00000000000..aeea9832411
--- /dev/null
+++ b/srcpkgs/roct-thunk-interface/patches/musl.patch
@@ -0,0 +1,29 @@
+diff -r -u old/src/libhsakmt.h new/src/libhsakmt.h
+--- src/libhsakmt.h	2020-03-04 15:00:47.000000000 -0500
++++ src/libhsakmt.h	2020-04-13 12:58:30.444865992 -0400
+@@ -54,6 +54,10 @@
+ #define CHECK_KFD_OPEN() \
+ 	do { if (kfd_open_count == 0 || hsakmt_forked) return HSAKMT_STATUS_KERNEL_IO_CHANNEL_NOT_OPENED; } while (0)
+ 
++/*On some platforms, a PAGE_SIZE macro eclipses the extern variable*/
++#ifdef PAGE_SIZE
++#undef PAGE_SIZE
++#endif
+ extern int PAGE_SIZE;
+ extern int PAGE_SHIFT;
+ 
+diff -r -u old/src/topology.c new/src/topology.c
+--- src/topology.c	2020-03-04 15:00:47.000000000 -0500
++++ src/topology.c	2020-04-13 13:01:31.209870701 -0400
+@@ -38,6 +38,11 @@
+ #include "libhsakmt.h"
+ #include "fmm.h"
+ 
++/*Needed on MUSL*/
++#ifndef MAXNAMLEN
++#define MAXNAMLEN PATH_MAX
++#endif
++
+ /* Number of memory banks added by thunk on top of topology
+  * This only includes static heaps like LDS, scratch and SVM,
+  * not for MMIO_REMAP heap. MMIO_REMAP memory bank is reported
diff --git a/srcpkgs/roct-thunk-interface/template b/srcpkgs/roct-thunk-interface/template
new file mode 100644
index 00000000000..55a1fc6074a
--- /dev/null
+++ b/srcpkgs/roct-thunk-interface/template
@@ -0,0 +1,33 @@
+# Template file for 'roct-thunk-interface'
+pkgname=roct-thunk-interface
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="ROCT-Thunk-Interface-roc-${version}"
+build_style=cmake
+make_build_target="all build-dev"
+make_install_target="install install-dev"
+hostmakedepends="cmake pkg-config"
+makedepends="pciutils-devel libnuma-devel"
+short_desc="Radeon Open Compute Thunk Interface"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="MIT"
+homepage="https://github.com/RadeonOpenCompute/ROCT-Thunk-Interface"
+distfiles="${homepage}/archive/roc-${version}.tar.gz"
+checksum=2cabe9d2cfa72031c05d11290837c476182e72d8dec2049298f691143fdd212b
+nocross=yes
+
+post_install() {
+	vlicense LICENSE.md
+}
+
+roct-thunk-interface-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove "usr/lib/*.so"
+		vmove usr/share/pkgconfig
+		vmove usr/lib/cmake
+	}
+}

From d8bb69aca8ebcd167198d858c11e7b7fa326c389 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Mon, 13 Apr 2020 15:27:27 -0400
Subject: [PATCH 02/10] New package: rocr-runtime-3.3.0

---
 common/shlibs                            |  1 +
 srcpkgs/rocr-runtime-devel               |  1 +
 srcpkgs/rocr-runtime/patches/cmake.patch | 27 +++++++++++++++++++++
 srcpkgs/rocr-runtime/template            | 30 ++++++++++++++++++++++++
 4 files changed, 59 insertions(+)
 create mode 120000 srcpkgs/rocr-runtime-devel
 create mode 100644 srcpkgs/rocr-runtime/patches/cmake.patch
 create mode 100644 srcpkgs/rocr-runtime/template

diff --git a/common/shlibs b/common/shlibs
index d89ae72ae3e..499f35752c2 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3863,3 +3863,4 @@ libqtutilities.so.6 qtutilities-6.0.4_1
 libkdsoap.so.1.9.0 KDSoap-1.9.0_1
 libstoken.so.1 stoken-0.92_1
 libhsakmt.so.1 roct-thunk-interface-3.3.0_1
+libhsa-runtime64.so.1 rocr-runtime-3.3.0_1
diff --git a/srcpkgs/rocr-runtime-devel b/srcpkgs/rocr-runtime-devel
new file mode 120000
index 00000000000..be838f22d81
--- /dev/null
+++ b/srcpkgs/rocr-runtime-devel
@@ -0,0 +1 @@
+rocr-runtime
\ No newline at end of file
diff --git a/srcpkgs/rocr-runtime/patches/cmake.patch b/srcpkgs/rocr-runtime/patches/cmake.patch
new file mode 100644
index 00000000000..93b74cd2297
--- /dev/null
+++ b/srcpkgs/rocr-runtime/patches/cmake.patch
@@ -0,0 +1,27 @@
+--- src/CMakeLists.txt.old	2020-04-18 20:01:48.549636995 -0400
++++ src/CMakeLists.txt	2020-04-18 20:04:00.177179781 -0400
+@@ -108,8 +108,8 @@
+ ## ROCr build internal versioning
+ add_definitions ( -DROCR_BUILD_ID=${PACKAGE_VERSION_STRING} )
+ 
+-## Set RUNPATH - ../../lib covers use of the legacy symlink in /hsa/lib/
+-set(CMAKE_INSTALL_RPATH "$ORIGIN;$ORIGIN/../../lib;$ORIGIN/../../lib64;$ORIGIN/../lib64")
++## Set RUNPATH
++set(CMAKE_INSTALL_RPATH "$ORIGIN;$ORIGIN/../lib")
+ 
+ ## ------------------------- Linux Compiler and Linker options -------------------------
+ set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -fexceptions -fno-rtti -fvisibility=hidden -Wno-error=sign-compare -Wno-sign-compare -Wno-write-strings -Wno-conversion-null -fno-math-errno -fno-threadsafe-statics -fmerge-all-constants -fms-extensions -Wno-error=comment -Wno-comment -Wno-error=pointer-arith -Wno-pointer-arith -Wno-error=unused-variable -Wno-error=unused-function" )
+@@ -185,11 +185,8 @@
+ add_custom_target ( hsa_lib_link2 ALL WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMAND ${CMAKE_COMMAND} -E create_symlink ../hsa/lib/${CORE_RUNTIME_LIBRARY}.so.${SO_MAJOR} ${CORE_RUNTIME_LIBRARY}-link.so.${SO_MAJOR} )
+ 
+ ## Set install information
+-install ( TARGETS ${CORE_RUNTIME_TARGET} LIBRARY DESTINATION hsa/lib )
+-install ( DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/inc/ DESTINATION hsa/include/hsa )
+-install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/hsa_include_link DESTINATION include PERMISSIONS OWNER_WRITE OWNER_READ RENAME hsa )
+-install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/${CORE_RUNTIME_LIBRARY}-link.so DESTINATION lib PERMISSIONS OWNER_WRITE OWNER_READ RENAME ${CORE_RUNTIME_LIBRARY}.so )
+-install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/${CORE_RUNTIME_LIBRARY}-link.so.${SO_MAJOR} DESTINATION lib PERMISSIONS OWNER_WRITE OWNER_READ RENAME ${CORE_RUNTIME_LIBRARY}.so.${SO_MAJOR} )
++install ( TARGETS ${CORE_RUNTIME_TARGET} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} )
++install ( DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/inc/ DESTINATION include/hsa )
+ 
+ ## Packaging directives
+ set ( CPACK_GENERATOR "DEB;RPM" CACHE STRING "Package types to build")
diff --git a/srcpkgs/rocr-runtime/template b/srcpkgs/rocr-runtime/template
new file mode 100644
index 00000000000..5ee22140f1f
--- /dev/null
+++ b/srcpkgs/rocr-runtime/template
@@ -0,0 +1,30 @@
+# Template file for 'rocr-runtime'
+pkgname=rocr-runtime
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="ROCR-Runtime-rocm-${version}"
+build_wrksrc="src"
+build_style=cmake
+hostmakedepends="cmake pkg-config"
+makedepends="roct-thunk-interface-devel elfutils-devel"
+short_desc="Radeon Open Compute HSA Runtime"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute/ROCR-Runtime"
+distfiles="${homepage}/archive/rocm-${version}.tar.gz"
+checksum=fa2d2d1f8a61d8a6952d377cf288d78c61776c3c2a666f163cafc3aa19ab0b61
+nocross=yes
+
+post_install() {
+	vlicense ../LICENSE.txt
+}
+
+rocr-runtime-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove "usr/lib/*.so"
+	}
+}

From 5991aaa587df9bdce5c93daf534974432a336acf Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Mon, 13 Apr 2020 18:07:34 -0400
Subject: [PATCH 03/10] New package: rocm-llvm-3.3.0

---
 srcpkgs/rocm-llvm/template | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)
 create mode 100644 srcpkgs/rocm-llvm/template

diff --git a/srcpkgs/rocm-llvm/template b/srcpkgs/rocm-llvm/template
new file mode 100644
index 00000000000..d6e75cd050c
--- /dev/null
+++ b/srcpkgs/rocm-llvm/template
@@ -0,0 +1,26 @@
+# Template file for 'rocm-llvm'
+pkgname=rocm-llvm
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="llvm-project-rocm-ocl-${version}"
+build_wrksrc=llvm
+build_style=cmake
+configure_args="-DCMAKE_INSTALL_PREFIX:PATH=/usr/lib/rocm-llvm
+	-DLLVM_ENABLE_PROJECTS='llvm;clang;lld' -DLLVM_TARGETS_TO_BUILD='AMDGPU'
+	-DLLVM_BUILD_DOCS=NO -DLLVM_ENABLE_OCAMLDOC=OFF
+	-DLLVM_ENABLE_SPHINX=NO -DLLVM_ENABLE_DOXYGEN=OFF
+	-DLLVM_INSTALL_UTILS=ON -DLLVM_VERSION_SUFFIX=roc -DOCAMLFIND=NO"
+hostmakedepends="cmake pkg-config python3"
+short_desc="Radeon Open Compute LLVM toolchain"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="Apache-2.0, NCSA, custom:LLVM-Exceptions"
+homepage="https://github.com/RadeonOpenCompute/llvm-project"
+distfiles="${homepage}/archive/rocm-ocl-${version}.tar.gz"
+checksum=a2bef7042e8e2f2cd8548cb246b88322e1c77188839983dcac8312d56f544dc8
+python_version=3
+nocross=yes
+
+post_install() {
+	vlicense LICENSE.TXT
+}

From 19c7a333ec5877c0e1e57ab9d1438bc0b31520a3 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Tue, 14 Apr 2020 10:25:31 -0400
Subject: [PATCH 04/10] New package: rocm-device-libs-3.3.0

---
 srcpkgs/rocm-device-libs/template | 37 +++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)
 create mode 100644 srcpkgs/rocm-device-libs/template

diff --git a/srcpkgs/rocm-device-libs/template b/srcpkgs/rocm-device-libs/template
new file mode 100644
index 00000000000..fcb4eb0d53e
--- /dev/null
+++ b/srcpkgs/rocm-device-libs/template
@@ -0,0 +1,37 @@
+# Template file for 'rocm-device-libs'
+pkgname=rocm-device-libs
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="ROCm-Device-Libs-rocm-ocl-${version}"
+build_style=cmake
+configure_args="-DLLVM_DIR:PATH=/usr/lib/rocm-llvm
+	-DCMAKE_INSTALL_LIBDIR:PATH=lib/rocm-device-libs"
+hostmakedepends="cmake rocm-llvm"
+short_desc="Radeon Open Compute device libraries"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute/ROCm-Device-Libs"
+distfiles="${homepage}/archive/rocm-ocl-${version}.tar.gz"
+checksum=706b08230790e08ca6a7a2fb7687d6131fd39a562148340e00fa37a6c06769c5
+nocross=yes
+
+pre_configure() {
+	# Put bytecodes in a lib/ subdirectory
+	vsed -i Packages.cmake -e 's@/lib/@/${CMAKE_INSTALL_LIBDIR}/@'
+	vsed -i OCL.cmake -e 's@DESTINATION lib$@DESTINATION ${CMAKE_INSTALL_LIBDIR}@'
+
+	# Build the prepare-builtins executable with native compiler
+	mkdir -p utils/build
+	cd utils/build
+	_prepare_builtins="$PWD/prepare-builtins/prepare-builtins"
+	cmake ${configure_args} ..
+	make ${makejobs}
+
+	# Add path to prepare-builtins for cmake
+	configure_args+=" -DPREPARE_BUILTINS='${_prepare_builtins}'"
+}
+
+post_install() {
+	vlicense LICENSE
+}

From 691d78f81e8346791c5556569cfa00b5b5d133ac Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Mon, 13 Apr 2020 18:30:00 -0400
Subject: [PATCH 05/10] New package: rocm-comgr-3.3.0

---
 common/shlibs               |  1 +
 srcpkgs/rocm-comgr-devel    |  1 +
 srcpkgs/rocm-comgr/template | 32 ++++++++++++++++++++++++++++++++
 3 files changed, 34 insertions(+)
 create mode 120000 srcpkgs/rocm-comgr-devel
 create mode 100644 srcpkgs/rocm-comgr/template

diff --git a/common/shlibs b/common/shlibs
index 499f35752c2..a53de3cf9e0 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3864,3 +3864,4 @@ libkdsoap.so.1.9.0 KDSoap-1.9.0_1
 libstoken.so.1 stoken-0.92_1
 libhsakmt.so.1 roct-thunk-interface-3.3.0_1
 libhsa-runtime64.so.1 rocr-runtime-3.3.0_1
+libamd_comgr.so.1 rocm-comgr-3.3.0_1
diff --git a/srcpkgs/rocm-comgr-devel b/srcpkgs/rocm-comgr-devel
new file mode 120000
index 00000000000..3f5ce255e07
--- /dev/null
+++ b/srcpkgs/rocm-comgr-devel
@@ -0,0 +1 @@
+rocm-comgr
\ No newline at end of file
diff --git a/srcpkgs/rocm-comgr/template b/srcpkgs/rocm-comgr/template
new file mode 100644
index 00000000000..c228bcd4d1f
--- /dev/null
+++ b/srcpkgs/rocm-comgr/template
@@ -0,0 +1,32 @@
+# Template file for 'rocm-comgr'
+pkgname=rocm-comgr
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="ROCm-CompilerSupport-rocm-${version}"
+build_wrksrc="lib/comgr"
+build_style=cmake
+configure_args="-DClang_DIR:PATH=/usr/lib/rocm-llvm/lib/cmake/clang"
+hostmakedepends="cmake pkg-config rocm-llvm"
+makedepends="rocm-device-libs"
+short_desc="Radeon Open Compute Code Object Manager"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="BSD-3-Clause"
+homepage="https://github.com/RadeonOpenCompute/ROCm-CompilerSupport"
+distfiles="${homepage}/archive/rocm-${version}.tar.gz"
+checksum=01e2524e0f28ecd6f46c9720f279207de935d826b0172158792aa3ec86af9ca7
+nocross=yes
+
+post_install() {
+	vlicense LICENSE.txt
+}
+
+rocm-comgr-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove "usr/lib/*.so"
+		vmove usr/lib/cmake
+	}
+}

From 34506fec471194f2746c0fca2b1a8f8de3c02f1c Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Fri, 17 Apr 2020 12:11:25 -0400
Subject: [PATCH 06/10] New package: rocminfo-3.3.0

---
 srcpkgs/rocminfo/template | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
 create mode 100644 srcpkgs/rocminfo/template

diff --git a/srcpkgs/rocminfo/template b/srcpkgs/rocminfo/template
new file mode 100644
index 00000000000..57d0640dd69
--- /dev/null
+++ b/srcpkgs/rocminfo/template
@@ -0,0 +1,22 @@
+# Template file for 'rocminfo'
+pkgname=rocminfo
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="rocminfo-rocm-${version}"
+build_style=cmake
+configure_args="-DROCM_DIR=/usr"
+hostmakedepends="cmake pkg-config"
+makedepends="rocr-runtime-devel"
+short_desc="Radeon Open Compute system information reporter"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute/rocminfo"
+distfiles="${homepage}/archive/rocm-${version}.tar.gz"
+checksum=e666f662c9e465aaabbbd0b109d87e017243cdf1a0898fabf5a90947bb3dbcd7
+nocross=yes
+python_version=3
+
+post_install() {
+	vlicense License.txt
+}

From 673ee21a6905ad3ca6877af58e936900c8d13bf1 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Sun, 19 Apr 2020 15:01:40 -0400
Subject: [PATCH 07/10] New package: rocm-bandwidth-test-3.3.0

---
 srcpkgs/rocm-bandwidth-test/template | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
 create mode 100644 srcpkgs/rocm-bandwidth-test/template

diff --git a/srcpkgs/rocm-bandwidth-test/template b/srcpkgs/rocm-bandwidth-test/template
new file mode 100644
index 00000000000..5c5058b693d
--- /dev/null
+++ b/srcpkgs/rocm-bandwidth-test/template
@@ -0,0 +1,20 @@
+# Template file for 'rocm-bandwidth-test'
+pkgname=rocm-bandwidth-test
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="rocm_bandwidth_test-rocm-${version}"
+build_style=cmake
+hostmakedepends="cmake"
+makedepends="rocr-runtime-devel roct-thunk-interface-devel"
+short_desc="Radeon Open Compute bandwidth test"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute/rocm_bandwidth_test"
+distfiles="${homepage}/archive/rocm-${version}.tar.gz"
+checksum=f5f914073018619dc91662d5bf630903dfa4db9136d603591917fdfb3c9164ce
+nocross=yes
+
+post_install() {
+	vlicense LICENSE.txt
+}

From f04a079a8f29a4171912c5d20135811d7b710ba3 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Tue, 14 Apr 2020 10:25:54 -0400
Subject: [PATCH 08/10] New package: rocm-opencl-runtime-3.3.0

---
 common/shlibs                                 |   2 +
 srcpkgs/rocm-opencl-runtime-clinfo            |   1 +
 srcpkgs/rocm-opencl-runtime-devel             |   1 +
 .../files/libelf-musl.patch                   |  21 +++
 .../files/runtime-musl.patch                  |  11 ++
 .../rocm-opencl-runtime/patches/cmake.patch   | 126 ++++++++++++++++++
 srcpkgs/rocm-opencl-runtime/template          |  84 ++++++++++++
 7 files changed, 246 insertions(+)
 create mode 120000 srcpkgs/rocm-opencl-runtime-clinfo
 create mode 120000 srcpkgs/rocm-opencl-runtime-devel
 create mode 100644 srcpkgs/rocm-opencl-runtime/files/libelf-musl.patch
 create mode 100644 srcpkgs/rocm-opencl-runtime/files/runtime-musl.patch
 create mode 100644 srcpkgs/rocm-opencl-runtime/patches/cmake.patch
 create mode 100644 srcpkgs/rocm-opencl-runtime/template

diff --git a/common/shlibs b/common/shlibs
index a53de3cf9e0..8cbc885e016 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3865,3 +3865,5 @@ libstoken.so.1 stoken-0.92_1
 libhsakmt.so.1 roct-thunk-interface-3.3.0_1
 libhsa-runtime64.so.1 rocr-runtime-3.3.0_1
 libamd_comgr.so.1 rocm-comgr-3.3.0_1
+libOpenCL-ROCm.so.1 rocm-opencl-runtime-3.3.0_1
+libamdocl64.so rocm-opencl-runtime-3.3.0_1
diff --git a/srcpkgs/rocm-opencl-runtime-clinfo b/srcpkgs/rocm-opencl-runtime-clinfo
new file mode 120000
index 00000000000..b2cda7e229d
--- /dev/null
+++ b/srcpkgs/rocm-opencl-runtime-clinfo
@@ -0,0 +1 @@
+rocm-opencl-runtime
\ No newline at end of file
diff --git a/srcpkgs/rocm-opencl-runtime-devel b/srcpkgs/rocm-opencl-runtime-devel
new file mode 120000
index 00000000000..b2cda7e229d
--- /dev/null
+++ b/srcpkgs/rocm-opencl-runtime-devel
@@ -0,0 +1 @@
+rocm-opencl-runtime
\ No newline at end of file
diff --git a/srcpkgs/rocm-opencl-runtime/files/libelf-musl.patch b/srcpkgs/rocm-opencl-runtime/files/libelf-musl.patch
new file mode 100644
index 00000000000..29469a9a351
--- /dev/null
+++ b/srcpkgs/rocm-opencl-runtime/files/libelf-musl.patch
@@ -0,0 +1,21 @@
+--- compiler/lib/loaders/elf/utils/libelf/_libelf.h	2020-04-28 15:50:53.243438174 -0400
++++ compiler/lib/loaders/elf/utils/libelf/_libelf.h	2020-04-28 15:51:54.293435415 -0400
+@@ -35,6 +35,7 @@
+ #include "_libelf_config.h"
+ 
+ #include "_elftc.h"
++#include <sys/cdefs.h>
+ 
+ /*
+  * Library-private data structures.
+--- compiler/lib/loaders/elf/utils/libelf/libelf.h	2020-04-28 15:50:53.244438174 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf.h	2020-04-28 15:52:12.375434593 -0400
+@@ -36,6 +36,8 @@
+ #define EM_HSAIL 0xAF5A
+ #endif
+ 
++#include <sys/cdefs.h>
++
+ /* Library private data structures */
+ typedef struct _Elf Elf;
+ typedef struct _Elf_Scn Elf_Scn;
diff --git a/srcpkgs/rocm-opencl-runtime/files/runtime-musl.patch b/srcpkgs/rocm-opencl-runtime/files/runtime-musl.patch
new file mode 100644
index 00000000000..ea18e90e09c
--- /dev/null
+++ b/srcpkgs/rocm-opencl-runtime/files/runtime-musl.patch
@@ -0,0 +1,11 @@
+--- runtime/os/os_posix.cpp.orig	2020-04-19 09:13:51.701982901 -0400
++++ runtime/os/os_posix.cpp	2020-04-19 09:14:04.156947422 -0400
+@@ -44,6 +44,8 @@
+ #include <algorithm>
+ #include <mutex>
+ 
++#include <libgen.h> // for basename
++
+ 
+ namespace amd {
+ 
diff --git a/srcpkgs/rocm-opencl-runtime/patches/cmake.patch b/srcpkgs/rocm-opencl-runtime/patches/cmake.patch
new file mode 100644
index 00000000000..2c96b99d45a
--- /dev/null
+++ b/srcpkgs/rocm-opencl-runtime/patches/cmake.patch
@@ -0,0 +1,126 @@
+--- OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/CMakeLists.txt	2019-09-10 11:53:28.000000000 -0400
++++ OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/CMakeLists.txt	2020-04-16 20:16:13.481180757 -0400
+@@ -73,11 +73,11 @@
+ 
+ set (OPENCL_ICD_LOADER_HEADERS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/inc CACHE PATH "Path to OpenCL Headers")
+ 
+-add_library (OpenCL ${OPENCL_ICD_LOADER_SOURCES})
+-set_target_properties (OpenCL PROPERTIES VERSION "1.2" SOVERSION "1")
++add_library (OpenCL-ROCm ${OPENCL_ICD_LOADER_SOURCES})
++set_target_properties (OpenCL-ROCm PROPERTIES VERSION "1.2" SOVERSION "1")
+ 
+ if (WIN32)
+-    target_link_libraries (OpenCL cfgmgr32.lib)
++    target_link_libraries (OpenCL-ROCm cfgmgr32.lib)
+ 
+     option (OPENCL_ICD_LOADER_REQUIRE_WDK "Build with D3DKMT support, which requires the Windows WDK." ON)
+     if (OPENCL_ICD_LOADER_REQUIRE_WDK)
+@@ -92,10 +92,10 @@
+             get_filename_component(WDK_DIRECTORY ${LATEST_D3DKMT_HEADER} DIRECTORY)
+             get_filename_component(WDK_DIRECTORY ${WDK_DIRECTORY} DIRECTORY)
+             message(STATUS "Found the Windows WDK in: ${WDK_DIRECTORY}")
+-            target_compile_definitions(OpenCL PRIVATE OPENCL_ICD_LOADER_REQUIRE_WDK)
+-            target_include_directories(OpenCL PRIVATE ${WDK_DIRECTORY}/um)
+-            target_include_directories(OpenCL PRIVATE ${WDK_DIRECTORY}/km)
+-            target_include_directories(OpenCL PRIVATE ${WDK_DIRECTORY}/shared)
++	    target_compile_definitions(OpenCL-ROCm PRIVATE OPENCL_ICD_LOADER_REQUIRE_WDK)
++	    target_include_directories(OpenCL-ROCm PRIVATE ${WDK_DIRECTORY}/um)
++	    target_include_directories(OpenCL-ROCm PRIVATE ${WDK_DIRECTORY}/km)
++	    target_include_directories(OpenCL-ROCm PRIVATE ${WDK_DIRECTORY}/shared)
+         else()
+             message(FATAL_ERROR "The Windows WDK was not found. Consider disabling OPENCL_ICD_LOADER_REQUIRE_WDK. Aborting.")
+         endif()
+@@ -113,25 +113,25 @@
+     endif()
+ else()
+     if (APPLE)
+-        target_link_libraries (OpenCL ${CMAKE_THREAD_LIBS_INIT})
++        target_link_libraries (OpenCL-ROCm ${CMAKE_THREAD_LIBS_INIT})
+     else ()
+-        set_target_properties (OpenCL PROPERTIES LINK_FLAGS "-Wl,--version-script -Wl,${CMAKE_CURRENT_SOURCE_DIR}/loader/linux/icd_exports.map")
+-        target_link_libraries (OpenCL ${CMAKE_THREAD_LIBS_INIT})
++        set_target_properties (OpenCL-ROCm PROPERTIES LINK_FLAGS "-Wl,--version-script -Wl,${CMAKE_CURRENT_SOURCE_DIR}/loader/linux/icd_exports.map")
++	target_link_libraries (OpenCL-ROCm ${CMAKE_THREAD_LIBS_INIT})
+     endif ()
+ endif ()
+ 
+ include_directories (${OPENCL_ICD_LOADER_HEADERS_DIR})
+ add_definitions (-DCL_TARGET_OPENCL_VERSION=220)
+ 
+-target_include_directories (OpenCL PRIVATE ${CMAKE_CURRENT_BINARY_DIR} loader)
+-target_link_libraries (OpenCL ${CMAKE_DL_LIBS})
++target_include_directories (OpenCL-ROCm PRIVATE ${CMAKE_CURRENT_BINARY_DIR} loader)
++target_link_libraries (OpenCL-ROCm ${CMAKE_DL_LIBS})
+ 
+ include (CTest)
+ if (BUILD_TESTING)
+     add_subdirectory (test)
+ endif()
+ 
+-install (TARGETS OpenCL
++install (TARGETS OpenCL-ROCm
+     RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+     ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
+     LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
+--- OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/test/loader_test/CMakeLists.txt	2019-09-10 11:53:28.000000000 -0400
++++ OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/test/loader_test/CMakeLists.txt	2020-04-16 20:16:56.647026589 -0400
+@@ -12,4 +12,4 @@
+     test_clgl.c
+     test_image_objects.c )
+ 
+-target_link_libraries (icd_loader_test OpenCL IcdLog)
++target_link_libraries (icd_loader_test OpenCL-ROCm IcdLog)
+--- ROCm-OpenCL-Runtime-roc-3.3.0/CMakeLists.txt	2020-04-28 07:29:51.864446603 -0400
++++ ROCm-OpenCL-Runtime-roc-3.3.0/CMakeLists.txt	2020-04-28 07:32:45.245793180 -0400
+@@ -101,30 +101,30 @@
+ rocm_setup_version( VERSION "2.0.0" )
+ 
+ # MAIN package
+-install(PROGRAMS $<TARGET_FILE:clinfo>
+-        DESTINATION bin/x86_64
++install(PROGRAMS $<TARGET_FILE:rocm-clinfo>
++        DESTINATION bin
+         COMPONENT MAIN)
+ install(PROGRAMS $<TARGET_FILE:amdocl64>
+-        DESTINATION lib/x86_64
++        DESTINATION lib
+         COMPONENT MAIN)
+-install(PROGRAMS $<TARGET_FILE:OpenCL>
+-        DESTINATION lib/x86_64
++install(PROGRAMS $<TARGET_FILE:OpenCL-ROCm>
++        DESTINATION lib
+         COMPONENT MAIN)
+-install(PROGRAMS $<TARGET_SONAME_FILE:OpenCL>
+-        DESTINATION lib/x86_64
++install(PROGRAMS $<TARGET_SONAME_FILE:OpenCL-ROCm>
++        DESTINATION lib
+         COMPONENT MAIN)
+ 
+ # DEV package
+ install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/api/opencl/khronos/headers/opencl2.2/CL"
+-        DESTINATION include
++	DESTINATION include/rocm
+         COMPONENT DEV
+         USE_SOURCE_PERMISSIONS
+         PATTERN cl_d3d10.h EXCLUDE
+         PATTERN cl_d3d11.h EXCLUDE
+         PATTERN cl_dx9_media_sharing.h EXCLUDE
+         PATTERN cl_egl.h EXCLUDE)
+-install(PROGRAMS $<TARGET_LINKER_FILE:OpenCL>
+-        DESTINATION lib/x86_64
++install(PROGRAMS $<TARGET_LINKER_FILE:OpenCL-ROCm>
++        DESTINATION lib
+         COMPONENT DEV)
+ 
+ # Generic CPACK variables
+--- ROCm-OpenCL-Runtime-roc-3.3.0/tools/clinfo/CMakeLists.txt	2020-04-28 07:29:51.882446535 -0400
++++ ROCm-OpenCL-Runtime-roc-3.3.0/tools/clinfo/CMakeLists.txt	2020-04-28 07:30:05.627394732 -0400
+@@ -6,6 +6,6 @@
+ 
+ add_definitions(-DHAVE_CL2_HPP)
+ 
+-add_executable(clinfo clinfo.cpp)
++add_executable(rocm-clinfo clinfo.cpp)
+ 
+-target_link_libraries(clinfo OpenCL)
++target_link_libraries(rocm-clinfo OpenCL-ROCm)
diff --git a/srcpkgs/rocm-opencl-runtime/template b/srcpkgs/rocm-opencl-runtime/template
new file mode 100644
index 00000000000..02aebb91bd8
--- /dev/null
+++ b/srcpkgs/rocm-opencl-runtime/template
@@ -0,0 +1,84 @@
+# Template file for 'rocm-opencl-runtime'
+pkgname=rocm-opencl-runtime
+version=3.3.0
+revision=1
+_ocl_icd_name="OpenCL-ICD-Loader"
+_ocl_icd_ver="6c03f8b58fafd9dd693eaac826749a5cfad515f8"
+archs="x86_64*"
+create_wrksrc=yes
+build_wrksrc="ROCm-OpenCL-Runtime-roc-${version}"
+build_style=cmake
+configure_args="-DUSE_COMGR_LIBRARY=yes"
+hostmakedepends="cmake pkg-config"
+makedepends="libglvnd-devel rocm-comgr-devel
+	roct-thunk-interface-devel rocr-runtime-devel"
+depends="rocm-comgr"
+short_desc="Radeon Open Compute OpenCL runtime"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="MIT"
+homepage="https://github.com/RadeonOpenCompute/ROCm-OpenCL-Runtime"
+_rocroot="https://github.com/RadeonOpenCompute"
+distfiles="${_rocroot}/ROCm-OpenCL-Runtime/archive/roc-${version}.tar.gz
+	${_rocroot}/rocm-cmake/archive/rocm-${version}.tar.gz
+	https://github.com/KhronosGroup/${_ocl_icd_name}/archive/${_ocl_icd_ver}.tar.gz"
+checksum="ac6999f1a491ab066286c2bd6adf50f08f831286f56e267879f9f7eced22f98e
+	76ed3ee8e56cf3246011cf7723c2abda539e1136e7e7f6909bfa45d268b8644f
+	c94d5bb6dc980c4d41d73e2b81663a19aabe494e923e2d0eec72a4c95b318438"
+nocross=yes
+
+if [ "$XBPS_LIBC" = "musl" ]; then
+	makedepends+=" musl-legacy-compat"
+fi
+
+post_patch() {
+	if [ "$XBPS_LIBC" = "musl" ]; then
+		# Remove dependence on glibc
+		patch -Np0 < ${FILESDIR}/libelf-musl.patch
+		patch -Np0 < ${FILESDIR}/runtime-musl.patch
+		vsed -e '/glibc_functions.cpp/d' -i api/opencl/amdocl/CMakeLists.txt
+	fi
+}
+
+pre_configure() {
+	# ROCm requires a very specific Khronos ICD loader version in the tree
+	# Keep the ICD loader config in /etc/OpenCL/rocm-vendors to avoid conflicts
+	_ocl_icd_dir="${_ocl_icd_name}-${_ocl_icd_ver}"
+	ln -sf "${wrksrc}/${_ocl_icd_dir}" api/opencl/khronos/icd
+	vsed -i "${wrksrc}/${_ocl_icd_dir}/loader/icd_platform.h" \
+		-e 's@/etc/OpenCL/vendors/@/etc/OpenCL/rocm-vendors/@g'
+
+	# CMake modules probably not useful anywhere but for this build
+	ln -sf "${wrksrc}/rocm-cmake-rocm-${version}/share/rocm/cmake"/*.cmake cmake
+
+	# Fix the dlopen macro to point to versioned libamd_comgr shared object
+	vsed -i 'runtime/device/comgrctx.cpp' \
+		-e 's/\blibamd_comgr\(32\)\?.so\b/&.1/g'
+}
+
+post_install() {
+	vlicense License
+
+	# Create descriptor to allow the ICD loader to find the driver
+	vmkdir etc/OpenCL/rocm-vendors
+	echo "libamdocl64.so" > "${DESTDIR}/etc/OpenCL/rocm-vendors/amdocl64.icd"
+	vmkdir etc/OpenCL/vendors
+	ln -s ../../OpenCL/rocm-vendors/amdocl64.icd \
+		${DESTDIR}/etc/OpenCL/vendors/rocm-amdocl64.icd
+}
+
+rocm-opencl-runtime-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/lib/libOpenCL-ROCm.so
+		vmove usr/include
+	}
+}
+
+rocm-opencl-runtime-clinfo_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - clinfo"
+	pkg_install() {
+		vmove usr/bin/rocm-clinfo
+	}
+}

From 79a3d596409285c6fe242b49c417b277bac4c8f7 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Thu, 30 Apr 2020 13:11:12 -0400
Subject: [PATCH 09/10] New package: rocm-hsa-ext-3.3.0

---
 common/shlibs                 |  2 ++
 srcpkgs/rocm-hsa-ext-devel    |  1 +
 srcpkgs/rocm-hsa-ext/template | 42 +++++++++++++++++++++++++++++++++++
 3 files changed, 45 insertions(+)
 create mode 120000 srcpkgs/rocm-hsa-ext-devel
 create mode 100644 srcpkgs/rocm-hsa-ext/template

diff --git a/common/shlibs b/common/shlibs
index 8cbc885e016..730e6d0d394 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3867,3 +3867,5 @@ libhsa-runtime64.so.1 rocr-runtime-3.3.0_1
 libamd_comgr.so.1 rocm-comgr-3.3.0_1
 libOpenCL-ROCm.so.1 rocm-opencl-runtime-3.3.0_1
 libamdocl64.so rocm-opencl-runtime-3.3.0_1
+libhsa-ext-image64.so.1 rocm-hsa-ext-3.3.0_1
+libhsa-runtime-tools64.so.1 rocm-hsa-ext-3.3.0_1
diff --git a/srcpkgs/rocm-hsa-ext-devel b/srcpkgs/rocm-hsa-ext-devel
new file mode 120000
index 00000000000..d201e9f2fae
--- /dev/null
+++ b/srcpkgs/rocm-hsa-ext-devel
@@ -0,0 +1 @@
+rocm-hsa-ext
\ No newline at end of file
diff --git a/srcpkgs/rocm-hsa-ext/template b/srcpkgs/rocm-hsa-ext/template
new file mode 100644
index 00000000000..a879f03480f
--- /dev/null
+++ b/srcpkgs/rocm-hsa-ext/template
@@ -0,0 +1,42 @@
+# Template file for 'rocm-hsa-ext'
+pkgname=rocm-hsa-ext
+version=3.3.0
+revision=1
+archs="x86_64"
+hostmakedepends="tar"
+short_desc="Radeon Open Compute HSA runtime extensions"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute"
+_hsa_deb="hsa-ext-rocr-dev_1.1.30300.0-rocm-rel-3.3-19-23fc088b_amd64.deb"
+distfiles="https://repo.radeon.com/rocm/apt/debian/pool/main/h/hsa-ext-rocr-dev/$_hsa_deb"
+checksum=6b44e286b395d946b865ec1f3cc546356396785ac1fde591d07af02d0aa7c25d
+repository=nonfree
+
+do_extract() {
+	ar x "${XBPS_SRCDISTDIR}/${pkgname}-${version}/${_hsa_deb}"
+	tar xvf data.tar.gz
+}
+
+do_install() {
+	_rocm_includes="opt/rocm-${version}/hsa/include"
+	
+	vmkdir usr
+	vcopy opt/rocm-${version}/hsa/lib usr
+	vcopy "$_rocm_includes" usr
+
+	# Extract license from one of the header files
+	awk 'BEGIN{HEADER=0} /\/\//{HEADER=1; print $0;} /^[^/]/{if(HEADER==1) exit;}' \
+		< "${_rocm_includes}/hsa/amd_hsa_tools_interfaces.h" \
+		| sed 's@^///*\( \|$\)@@' > LICENSE
+	vlicense LICENSE
+}
+
+rocm-hsa-ext-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove "usr/lib/*.so"
+	}
+}

From 2c48c949cb271cf45ae9fdfed5e99479c6ecf8e1 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Tue, 28 Apr 2020 13:33:46 -0400
Subject: [PATCH 10/10] hashcat: add build option to link against ROCm [ci
 skip]

---
 srcpkgs/hashcat/files/rocm.patch     | 15 +++++++++++++++
 srcpkgs/hashcat/patches/tmpdir.patch | 21 +++++++++++++++++++++
 srcpkgs/hashcat/template             | 17 ++++++++++++++---
 3 files changed, 50 insertions(+), 3 deletions(-)
 create mode 100644 srcpkgs/hashcat/files/rocm.patch
 create mode 100644 srcpkgs/hashcat/patches/tmpdir.patch

diff --git a/srcpkgs/hashcat/files/rocm.patch b/srcpkgs/hashcat/files/rocm.patch
new file mode 100644
index 00000000000..f1e899d30ee
--- /dev/null
+++ b/srcpkgs/hashcat/files/rocm.patch
@@ -0,0 +1,15 @@
+diff -ur a/src/opencl.c b/src/opencl.c
+--- a/src/opencl.c	2018-12-02 05:58:48.000000000 -0500
++++ b/src/opencl.c	2020-04-28 13:24:12.602415333 -0400
+@@ -492,9 +492,9 @@
+ 
+   if (ocl->lib == NULL) ocl->lib = hc_dlopen ("cygOpenCL-1.dll", RTLD_NOW);
+   #else
+-  ocl->lib = hc_dlopen ("libOpenCL.so", RTLD_NOW);
++  ocl->lib = hc_dlopen ("libOpenCL-ROCm.so.1", RTLD_NOW);
+ 
+-  if (ocl->lib == NULL) ocl->lib = hc_dlopen ("libOpenCL.so.1", RTLD_NOW);
++  if (ocl->lib == NULL) ocl->lib = hc_dlopen ("libOpenCL-ROCm.so", RTLD_NOW);
+   #endif
+ 
+   if (ocl->lib == NULL)
diff --git a/srcpkgs/hashcat/patches/tmpdir.patch b/srcpkgs/hashcat/patches/tmpdir.patch
new file mode 100644
index 00000000000..0558a001c9c
--- /dev/null
+++ b/srcpkgs/hashcat/patches/tmpdir.patch
@@ -0,0 +1,21 @@
+Addresses https://github.com/hashcat/hashcat/issues/2379
+diff -ur a/src/folder.c b/src/folder.c
+--- src/folder.c	2018-12-02 05:58:48.000000000 -0500
++++ src/folder.c	2020-04-28 13:22:27.340522751 -0400
+@@ -457,16 +457,6 @@
+ 
+   hcfree (cpath);
+ 
+-  //if (getenv ("TMP") == NULL)
+-  if (1)
+-  {
+-    char *tmp;
+-
+-    hc_asprintf (&tmp, "TMP=%s", cpath_real);
+-
+-    putenv (tmp);
+-  }
+-
+   #if defined (_WIN)
+ 
+   naive_replace (cpath_real, '\\', '/');
diff --git a/srcpkgs/hashcat/template b/srcpkgs/hashcat/template
index e982f99cebf..7d3a8cb5a6b 100644
--- a/srcpkgs/hashcat/template
+++ b/srcpkgs/hashcat/template
@@ -1,15 +1,16 @@
 # Template file for 'hashcat'
 pkgname=hashcat
 version=5.1.0
-revision=2
+revision=3
 build_style=gnu-makefile
 make_build_args="PREFIX=/usr
  USE_SYSTEM_OPENCL=1 USE_SYSTEM_XXHASH=1
- DEPS_OPENCL_PATH=${XBPS_CROSS_BASE}/usr/include
+ DEPS_OPENCL_PATH=${XBPS_CROSS_BASE}/usr/include$(vopt_if rocm /rocm)
  DEPS_XXHASH_PATH=${XBPS_CROSS_BASE}/usr/include"
 make_use_env=yes
 make_install_args="$make_build_args"
-makedepends="gmp-devel opencl2-headers xxHash-devel"
+makedepends="gmp-devel xxHash-devel
+ $(vopt_if rocm rocm-opencl-runtime-devel opencl2-headers)"
 checkdepends="perl"
 short_desc="Advanced CPU-based password recovery utility"
 maintainer="Duncaen <duncaen@voidlinux.org>"
@@ -19,6 +20,9 @@ changelog="https://raw.githubusercontent.com/hashcat/hashcat/master/docs/changes
 distfiles="https://hashcat.net/files/hashcat-${version}.tar.gz"
 checksum=283beaa68e1eab41de080a58bb92349c8e47a2bb1b93d10f36ea30f418f1e338
 
+build_options="rocm"
+desc_option_rocm="Use ROCm OpenCL runtime"
+
 if [ "$XBPS_TARGET_ENDIAN" = "be" ]; then
 	broken="Not supported on big endian"
 fi
@@ -26,6 +30,13 @@ fi
 post_extract() {
 	sed '/^CC/d' -i src/Makefile
 }
+
+post_patch() {
+	if [ "$build_option_rocm" ]; then
+		patch -Np1 < ${FILESDIR}/rocm.patch
+	fi
+}
+
 post_install() {
 	rm -f ${DESTDIR}/usr/share/docs/hashcat/license.txt
 	vlicense docs/license.txt

^ permalink raw reply	[flat|nested] 61+ messages in thread

* Re: New packages: ROCm core and OpenCL
  2020-04-19 13:34 [PR PATCH] New packages: ROCm core and OpenCL ahesford
                   ` (15 preceding siblings ...)
  2020-04-30 19:32 ` ahesford
@ 2020-04-30 19:35 ` ahesford
  2020-04-30 19:38 ` ahesford
                   ` (42 subsequent siblings)
  59 siblings, 0 replies; 61+ messages in thread
From: ahesford @ 2020-04-30 19:35 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 2123 bytes --]

New comment by ahesford on void-packages repository

https://github.com/void-linux/void-packages/pull/21153#issuecomment-622061907

Comment:
Still more updates:
* I didn't catch this with the last push, but the ROCm `libamdocl64.so` ICD installed by `rocm-opencl-runtime` _does_ work with `ocl-icd`, at least with `clinfo` from `ocl-icd`, `hashcat`, `darktable` (subject to the next point below) and a simple test with `pyopencl` installed as a wheel from PyPI (which installs its own copy of the ocl-icd loader). As a result, the `rocm-opencl-runtime` package now installs an ICD descriptor in `/etc/OpenCL/vendors` to allow discovery and use through `ocl-icd`.
* Because there may be lingering incompatibilities between the `libOpenCL` implementations, I still install the dedicated ROCm ICD loader at `/usr/lib/libOpenCL-ROCm.so*` and the `/etc/OpenCL/rocm-vendors` directory with an ICD descriptor pointing to `libamdocl64.so`. This allows isolation of the ROCm environment if desired.
* The `darktable` package requires OpenCL image support. AMD offers image support only through a closed-source extension library and claims a fully open-source version is "on [their] list of goals" (see [ROCm-OpenCL-Runtime Issue #59](https://github.com/RadeonOpenCompute/ROCm-OpenCL-Runtime/issues/59). I've wrapped the closed-source library in an optional package, `rocm-hsa-ext`, based on the Debian package of the library. The only license I can find relating to this software is in the header files that ship in the package, which asserts an NCSA license that does not seem to prohibit redistribution in binary form. Accordingly, I do not think `restricted` is required here. Because the source is not (yet) available, I've marked this extension package for the `nonfree` repo.

I hope that, with these new changes, ROCm will "just work" with (the majority of) the OpenCL-aware packages in the Void repos. I've left the `hashcat` modifications intact to allow explicit linking against the ROCm ICD loader as a non-default build option, but the standard build (with a patch folded into these modifications) should work too.

^ permalink raw reply	[flat|nested] 61+ messages in thread

* Re: New packages: ROCm core and OpenCL
  2020-04-19 13:34 [PR PATCH] New packages: ROCm core and OpenCL ahesford
                   ` (16 preceding siblings ...)
  2020-04-30 19:35 ` ahesford
@ 2020-04-30 19:38 ` ahesford
  2020-05-01  4:57 ` lemmi
                   ` (41 subsequent siblings)
  59 siblings, 0 replies; 61+ messages in thread
From: ahesford @ 2020-04-30 19:38 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 2124 bytes --]

New comment by ahesford on void-packages repository

https://github.com/void-linux/void-packages/pull/21153#issuecomment-622061907

Comment:
Still more updates:
* I didn't catch this with the last push, but the ROCm `libamdocl64.so` ICD installed by `rocm-opencl-runtime` _does_ work with `ocl-icd`, at least with `clinfo` from `ocl-icd`, `hashcat`, `darktable` (subject to the next point below) and a simple test with `pyopencl` installed as a wheel from PyPI (which installs its own copy of the ocl-icd loader). As a result, the `rocm-opencl-runtime` package now installs an ICD descriptor in `/etc/OpenCL/vendors` to allow discovery and use through `ocl-icd`.
* Because there may be lingering incompatibilities between the `libOpenCL` implementations, I still install the dedicated ROCm ICD loader at `/usr/lib/libOpenCL-ROCm.so*` and the `/etc/OpenCL/rocm-vendors` directory with an ICD descriptor pointing to `libamdocl64.so`. This allows isolation of the ROCm environment if desired.
* The `darktable` package requires OpenCL image support. AMD offers image support only through a closed-source extension library and claims a fully open-source version is "on [their] list of goals" (see [ROCm-OpenCL-Runtime Issue #59](https://github.com/RadeonOpenCompute/ROCm-OpenCL-Runtime/issues/59)). I've wrapped the closed-source library in an optional package, `rocm-hsa-ext`, based on the Debian package of the library. The only license I can find relating to this software is in the header files that ship in the package, which asserts an NCSA license that does not seem to prohibit redistribution in binary form. Accordingly, I do not think `restricted` is required here. Because the source is not (yet) available, I've marked this extension package for the `nonfree` repo.

I hope that, with these new changes, ROCm will "just work" with (the majority of) the OpenCL-aware packages in the Void repos. I've left the `hashcat` modifications intact to allow explicit linking against the ROCm ICD loader as a non-default build option, but the standard build (with a patch folded into these modifications) should work too.

^ permalink raw reply	[flat|nested] 61+ messages in thread

* Re: New packages: ROCm core and OpenCL
  2020-04-19 13:34 [PR PATCH] New packages: ROCm core and OpenCL ahesford
                   ` (17 preceding siblings ...)
  2020-04-30 19:38 ` ahesford
@ 2020-05-01  4:57 ` lemmi
  2020-05-01  5:10 ` ahesford
                   ` (40 subsequent siblings)
  59 siblings, 0 replies; 61+ messages in thread
From: lemmi @ 2020-05-01  4:57 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 11671 bytes --]

New comment by lemmi on void-packages repository

https://github.com/void-linux/void-packages/pull/21153#issuecomment-622248457

Comment:
Hey,

awesome work so far. For my purposes I built and installed `rocm-opencl-runtime` and `rocm-hsa-ext`. I used `LD_LIBRARY_PATH=/opt/rocm/lib <cmd>` to run `clinfo`, `blender`, `hashcat` and `darktable` with a vega64.

- `blender` cycles "works"
    - Too slow to be usable
    - AMDGPU-PRO drivers are several times faster
- `darktable` works
    - I can't make out a difference to the AMDGPU-PRO drivers
    - Depending on your card you may need to set `opencl_avoid_atomics=true` in `~/.config/darktable/darktablerc`
- `hashcat --benchmark` fails with `clCreateCommandQueue(): CL_OUT_OF_HOST_MEMORY`
    - might be unrelated, can't get the benchmark to run with AMDGPU-PRO, too
    - maybe some algorithms work, but I didn't test. This is the case fore AMDGPU-PRO
- `clinfo` output:
```
Number of platforms                               1
  Platform Name                                   AMD Accelerated Parallel Processing
  Platform Vendor                                 Advanced Micro Devices, Inc.
  Platform Version                                OpenCL 2.0 AMD-APP.internal (3098.0)
  Platform Profile                                FULL_PROFILE
  Platform Extensions                             cl_khr_icd cl_amd_object_metadata cl_amd_event_callback 
  Platform Max metadata object keys (AMD)         8
  Platform Extensions function suffix             AMD

  Platform Name                                   AMD Accelerated Parallel Processing
Number of devices                                 1
  Device Name                                     gfx900
  Device Vendor                                   Advanced Micro Devices, Inc.
  Device Vendor ID                                0x1002
  Device Version                                  OpenCL 2.0 
  Driver Version                                  3098.0 (HSA1.1,LC)
  Device OpenCL C Version                         OpenCL C 2.0 
  Device Type                                     GPU
  Device Board Name (AMD)                         Vega 10 XL/XT [Radeon RX Vega 56/64]
  Device Topology (AMD)                           PCI-E, 03:00.0
  Device Profile                                  FULL_PROFILE
  Device Available                                Yes
  Compiler Available                              Yes
  Linker Available                                Yes
  Max compute units                               64
  SIMD per compute unit (AMD)                     4
  SIMD width (AMD)                                16
  SIMD instruction width (AMD)                    1
  Max clock frequency                             1630MHz
  Graphics IP (AMD)                               9.0
  Device Partition                                (core)
    Max number of sub-devices                     64
    Supported partition types                     None
    Supported affinity domains                    (n/a)
  Max work item dimensions                        3
  Max work item sizes                             1024x1024x1024
  Max work group size                             256
  Preferred work group size (AMD)                 256
  Max work group size (AMD)                       1024
  Preferred work group size multiple              64
  Wavefront width (AMD)                           64
  Preferred / native vector sizes                 
    char                                                 4 / 4       
    short                                                2 / 2       
    int                                                  1 / 1       
    long                                                 1 / 1       
    half                                                 1 / 1        (cl_khr_fp16)
    float                                                1 / 1       
    double                                               1 / 1        (cl_khr_fp64)
  Half-precision Floating-point support           (cl_khr_fp16)
    Denormals                                     No
    Infinity and NANs                             No
    Round to nearest                              No
    Round to zero                                 No
    Round to infinity                             No
    IEEE754-2008 fused multiply-add               No
    Support is emulated in software               No
  Single-precision Floating-point support         (core)
    Denormals                                     Yes
    Infinity and NANs                             Yes
    Round to nearest                              Yes
    Round to zero                                 Yes
    Round to infinity                             Yes
    IEEE754-2008 fused multiply-add               Yes
    Support is emulated in software               No
    Correctly-rounded divide and sqrt operations  Yes
  Double-precision Floating-point support         (cl_khr_fp64)
    Denormals                                     Yes
    Infinity and NANs                             Yes
    Round to nearest                              Yes
    Round to zero                                 Yes
    Round to infinity                             Yes
    IEEE754-2008 fused multiply-add               Yes
    Support is emulated in software               No
  Address bits                                    64, Little-Endian
  Global memory size                              8573157376 (7.984GiB)
  Global free memory (AMD)                        8372224 (7.984GiB)
  Global memory channels (AMD)                    64
  Global memory banks per channel (AMD)           4
  Global memory bank width (AMD)                  256 bytes
  Error Correction support                        No
  Max memory allocation                           7287183769 (6.787GiB)
  Unified memory for Host and Device              No
  Shared Virtual Memory (SVM) capabilities        (core)
    Coarse-grained buffer sharing                 Yes
    Fine-grained buffer sharing                   Yes
    Fine-grained system sharing                   No
    Atomics                                       No
  Minimum alignment for any data type             128 bytes
  Alignment of base address                       1024 bits (128 bytes)
  Preferred alignment for atomics                 
    SVM                                           0 bytes
    Global                                        0 bytes
    Local                                         0 bytes
  Max size for global variable                    7287183769 (6.787GiB)
  Preferred total size of global vars             8573157376 (7.984GiB)
  Global Memory cache type                        Read/Write
  Global Memory cache size                        16384 (16KiB)
  Global Memory cache line size                   64 bytes
  Image support                                   Yes
    Max number of samplers per kernel             26751
    Max size for 1D images from buffer            65536 pixels
    Max 1D or 2D image array size                 2048 images
    Base address alignment for 2D image buffers   256 bytes
    Pitch alignment for 2D image buffers          256 pixels
    Max 2D image size                             16384x16384 pixels
    Max 3D image size                             2048x2048x2048 pixels
    Max number of read image args                 128
    Max number of write image args                8
    Max number of read/write image args           64
  Max number of pipe args                         16
  Max active pipe reservations                    16
  Max pipe packet size                            2992216473 (2.787GiB)
  Local memory type                               Local
  Local memory size                               65536 (64KiB)
  Local memory syze per CU (AMD)                  65536 (64KiB)
  Local memory banks (AMD)                        32
  Max number of constant args                     8
  Max constant buffer size                        7287183769 (6.787GiB)
  Preferred constant buffer size (AMD)            16384 (16KiB)
  Max size of kernel argument                     1024
  Queue properties (on host)                      
    Out-of-order execution                        No
    Profiling                                     Yes
  Queue properties (on device)                    
    Out-of-order execution                        Yes
    Profiling                                     Yes
    Preferred size                                262144 (256KiB)
    Max size                                      8388608 (8MiB)
  Max queues on device                            1
  Max events on device                            1024
  Prefer user sync for interop                    Yes
  Number of P2P devices (AMD)                     0
  P2P devices (AMD)                               <printDeviceInfo:147: get number of CL_DEVICE_P2P_DEVICES_AMD : error -30>
  Profiling timer resolution                      1ns
  Profiling timer offset since Epoch (AMD)        0ns (Thu Jan  1 01:00:00 1970)
  Execution capabilities                          
    Run OpenCL kernels                            Yes
    Run native kernels                            No
    Thread trace supported (AMD)                  No
    Number of async queues (AMD)                  8
    Max real-time compute queues (AMD)            8
    Max real-time compute units (AMD)             64
  printf() buffer size                            4194304 (4MiB)
  Built-in kernels                                (n/a)
  Device Extensions                               cl_khr_fp64 cl_khr_global_int32_base_atomics cl_khr_global_int32_extended_atomics cl_khr_local_int32_base_atomics cl_khr_local_int32_extended_atomics cl_khr_int64_base_atomics cl_khr_int64_extended_atomics cl_khr_3d_image_writes cl_khr_byte_addressable_store cl_khr_fp16 cl_khr_gl_sharing cl_amd_device_attribute_query cl_amd_media_ops cl_amd_media_ops2 cl_khr_image2d_from_buffer cl_khr_subgroups cl_khr_depth_images cl_amd_copy_buffer_p2p cl_amd_assembly_program 

NULL platform behavior
  clGetPlatformInfo(NULL, CL_PLATFORM_NAME, ...)  AMD Accelerated Parallel Processing
  clGetDeviceIDs(NULL, CL_DEVICE_TYPE_ALL, ...)   Success [AMD]
  clCreateContext(NULL, ...) [default]            Success [AMD]
  clCreateContextFromType(NULL, CL_DEVICE_TYPE_DEFAULT)  Success (1)
    Platform Name                                 AMD Accelerated Parallel Processing
    Device Name                                   gfx900
  clCreateContextFromType(NULL, CL_DEVICE_TYPE_CPU)  No devices found in platform
  clCreateContextFromType(NULL, CL_DEVICE_TYPE_GPU)  Success (1)
    Platform Name                                 AMD Accelerated Parallel Processing
    Device Name                                   gfx900
  clCreateContextFromType(NULL, CL_DEVICE_TYPE_ACCELERATOR)  No devices found in platform
  clCreateContextFromType(NULL, CL_DEVICE_TYPE_CUSTOM)  No devices found in platform
  clCreateContextFromType(NULL, CL_DEVICE_TYPE_ALL)  Success (1)
    Platform Name                                 AMD Accelerated Parallel Processing
    Device Name                                   gfx900

ICD loader properties
  ICD loader Name                                 OpenCL ICD Loader
  ICD loader Vendor                               OCL Icd free software
  ICD loader Version                              2.2.12
  ICD loader Profile                              OpenCL 2.2
```

^ permalink raw reply	[flat|nested] 61+ messages in thread

* Re: New packages: ROCm core and OpenCL
  2020-04-19 13:34 [PR PATCH] New packages: ROCm core and OpenCL ahesford
                   ` (18 preceding siblings ...)
  2020-05-01  4:57 ` lemmi
@ 2020-05-01  5:10 ` ahesford
  2020-05-01  5:12 ` ahesford
                   ` (39 subsequent siblings)
  59 siblings, 0 replies; 61+ messages in thread
From: ahesford @ 2020-05-01  5:10 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1058 bytes --]

New comment by ahesford on void-packages repository

https://github.com/void-linux/void-packages/pull/21153#issuecomment-622251408

Comment:
Thanks for recording this. LD_LIBRARY_PATH is not necessary anymore because the reworked packages install libraries in `/usr`.

I suspect you ran `hashcat` from an official package. That version has a problem with ROCm because it sets the TMP environment variable as a "workaround" for bad argument parsing by some OCL compilers. ROCm uses the TMP variable (or TEMP, if found) as the location where OCL compilation objects are stored. `hashcat` sets this to `/use/share/hashcat`, so the ROCm OCL compiler can't write the objects it wants to and fails. There are two ways around this:
1. Build the version of `hashcat` in this PR; it includes a patch to undo the TMP set, or
2. Run `hashcat` as root to allow it to write the build products it wants (they will be deleted when the program exits).
I've [filed an issue upstream](https://github.com/hashcat/hashcat/issues/2379) to address this problematic behavior.

^ permalink raw reply	[flat|nested] 61+ messages in thread

* Re: New packages: ROCm core and OpenCL
  2020-04-19 13:34 [PR PATCH] New packages: ROCm core and OpenCL ahesford
                   ` (19 preceding siblings ...)
  2020-05-01  5:10 ` ahesford
@ 2020-05-01  5:12 ` ahesford
  2020-05-01 14:04 ` [PR PATCH] [Updated] " ahesford
                   ` (38 subsequent siblings)
  59 siblings, 0 replies; 61+ messages in thread
From: ahesford @ 2020-05-01  5:12 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1060 bytes --]

New comment by ahesford on void-packages repository

https://github.com/void-linux/void-packages/pull/21153#issuecomment-622251408

Comment:
Thanks for recording this. LD_LIBRARY_PATH is not necessary anymore because the reworked packages install libraries in `/usr`.

I suspect you ran `hashcat` from an official package. That version has a problem with ROCm because it sets the TMP environment variable as a "workaround" for bad argument parsing by some OCL compilers. ROCm uses the TMP variable (or TEMP, if found) as the location where OCL compilation objects are stored. `hashcat` sets this to `/use/share/hashcat`, so the ROCm OCL compiler can't write the objects it wants to and fails. There are two ways around this:
1. Build the version of `hashcat` in this PR; it includes a patch to undo the TMP set, or
2. Run `hashcat` as root to allow it to write the build products it wants (they will be deleted when the program exits).

I've [filed an issue upstream](https://github.com/hashcat/hashcat/issues/2379) to address this problematic behavior.

^ permalink raw reply	[flat|nested] 61+ messages in thread

* Re: [PR PATCH] [Updated] New packages: ROCm core and OpenCL
  2020-04-19 13:34 [PR PATCH] New packages: ROCm core and OpenCL ahesford
                   ` (20 preceding siblings ...)
  2020-05-01  5:12 ` ahesford
@ 2020-05-01 14:04 ` ahesford
  2020-05-01 19:36 ` ahesford
                   ` (37 subsequent siblings)
  59 siblings, 0 replies; 61+ messages in thread
From: ahesford @ 2020-05-01 14:04 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 3893 bytes --]

There is an updated pull request by ahesford against master on the void-packages repository

https://github.com/ahesford/void-packages rocm
https://github.com/void-linux/void-packages/pull/21153

New packages: ROCm core and OpenCL
This PR includes several packages designed to bring the OpenCL portion of the AMD ROCm ecosystem to Void. It addresses Issue #19507. There are many other packages that AMD provides for GPGPU computing, but these can be added piecemeal as users demand.

The packages are currently only for `x86_64*`. While at least some of the packages will compile on other 64-bit architectures, I have no hardware to test. They are certainly not suitable for 32-bit architectures; some internal data structures rely on `uint64_t` values that are cast to pointers. At a
minimum, a thorough audit would be necessary to ensure that these casts are safe (e.g., that the values stored were only ever upcast from 32-bit pointers). More extensive work may be necessary to support 32-bit architectures, probably without significant benefit.

The packages successfully identify a Radeon RX 580 on an `x86_64` installation using both `clinfo` and `rocminfo` as provided. Furthermore, a version of `pyopencl` linked against these ROCm packages successfully runs a simple program that validates arithmetic on GPU-bound arrays.

There are caveats with this set of packages, almost all of which revolve around the incompatibilities between the Void-provided `ocl-icd` and the [Khronos OpenCL ICD loader](https://github.com/KhronosGroup/OpenCL-ID-Loader) required by (and built into) `rocm-opencl-runtime`.
1. All packages install into `/opt/rocm`. This keeps the environment closer to that officially sanctioned by AMD and helps avoid conflicts between other packages and those provided here. (For example, `clinfo` and the ICD loader itself.) Eventually, we may be able to move the files into `/usr`.
2. The Khronos OpenCL ICD loader built into `rocm-opencl-runtime` is an outdated, pre-release commit. If AMD can update its sources to use the release version of that loader (which has a backward-incompatible API change), we may be able to make ROCm compatible with `ocl-icd` or replace `ocl-icd` with the official Khronos loader.
3. In the meantime, to avoid `shlibs` conflicts, the OpenCL ICD loader is installed as `/opt/rocm/lib/libOpenCL-ROCm.so` (and an appropriately versioned shared library), which means that programs wishing to use the ROCm OpenCL must explicitly link against this library instead of the generic `libOpenCL.so`.
4. I do **not** recommend making any Void packages link against this specific library, because it will make those packages ROCm-only. For the time being, ROCm is intended for end-users to specifically link against. Linking Void packages against ROCm would requires the ICD loader used by ROCm be compatible with `ocl-icd`, or `ocl-icd` be replaced by the Khronos loader. However, because the Khronos loader changed its API for the release version, such a change is not yet appropriate.

Hopefully, if AMD updates its dependence on the Khronos ICD loader, we can resolve some of these caveats in the future and make ROCm a more natural Void component. For now, these packages are useful for those who need an AMD OpenCL solution and would rather custom-link software against the AMD ICD loader than hack the `amdgpu-pro` driver into an ICD compatible with `ocl-icd`.

Some patches were made to relocate some files in `/opt/rocm` and make everyting build on x86_64-musl`. Where appropriate, these patches will be pushed upstream to clean up the distribution and packaging.

Update: I pushed some new commits to update license information that triggerd an `xlint` failure. I've also disabled CI builds because they will time out on `rocm-llvm`.

A patch file from https://github.com/void-linux/void-packages/pull/21153.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-rocm-21153.patch --]
[-- Type: text/x-diff, Size: 35844 bytes --]

From 2a80c4a12b3162c62bb162bd0a4be0f53de8681a Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Mon, 13 Apr 2020 13:08:09 -0400
Subject: [PATCH 01/10] New package: roct-thunk-interface-3.3.0

---
 common/shlibs                                 |  1 +
 srcpkgs/roct-thunk-interface-devel            |  1 +
 .../patches/cmake-dev-libdir.patch            | 10 ++++++
 .../roct-thunk-interface/patches/musl.patch   | 29 ++++++++++++++++
 srcpkgs/roct-thunk-interface/template         | 33 +++++++++++++++++++
 5 files changed, 74 insertions(+)
 create mode 120000 srcpkgs/roct-thunk-interface-devel
 create mode 100644 srcpkgs/roct-thunk-interface/patches/cmake-dev-libdir.patch
 create mode 100644 srcpkgs/roct-thunk-interface/patches/musl.patch
 create mode 100644 srcpkgs/roct-thunk-interface/template

diff --git a/common/shlibs b/common/shlibs
index 820f037f267..0b2cc3bcce7 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3860,3 +3860,4 @@ libtagparser.so.9 tagparser-9.1.2_1
 libqtutilities.so.6 qtutilities-6.0.4_1
 libkdsoap.so.1.9.0 KDSoap-1.9.0_1
 libstoken.so.1 stoken-0.92_1
+libhsakmt.so.1 roct-thunk-interface-3.3.0_1
diff --git a/srcpkgs/roct-thunk-interface-devel b/srcpkgs/roct-thunk-interface-devel
new file mode 120000
index 00000000000..ac3f2cc684c
--- /dev/null
+++ b/srcpkgs/roct-thunk-interface-devel
@@ -0,0 +1 @@
+roct-thunk-interface
\ No newline at end of file
diff --git a/srcpkgs/roct-thunk-interface/patches/cmake-dev-libdir.patch b/srcpkgs/roct-thunk-interface/patches/cmake-dev-libdir.patch
new file mode 100644
index 00000000000..98c7f1e459c
--- /dev/null
+++ b/srcpkgs/roct-thunk-interface/patches/cmake-dev-libdir.patch
@@ -0,0 +1,10 @@
+--- CMakeLists.txt.old	2020-04-18 19:45:17.306081135 -0400
++++ CMakeLists.txt	2020-04-18 19:46:51.300753636 -0400
+@@ -146,6 +146,7 @@
+     COMMAND ${CMAKE_COMMAND}
+         -DSOURCE_DIR="${SOURCE_DIR}"
+         -DCMAKE_INSTALL_PREFIX="${CMAKE_INSTALL_PREFIX}"
++        -DCMAKE_INSTALL_LIBDIR="${CMAKE_INSTALL_LIBDIR}"
+         -DCPACK_RPM_PACKAGE_REQUIRES="hsakmt-roct"
+         -DCPACK_PACKAGING_INSTALL_PREFIX="${CPACK_PACKAGING_INSTALL_PREFIX}"
+         -DVERSION="${BUILD_VERSION_STRING}"
diff --git a/srcpkgs/roct-thunk-interface/patches/musl.patch b/srcpkgs/roct-thunk-interface/patches/musl.patch
new file mode 100644
index 00000000000..aeea9832411
--- /dev/null
+++ b/srcpkgs/roct-thunk-interface/patches/musl.patch
@@ -0,0 +1,29 @@
+diff -r -u old/src/libhsakmt.h new/src/libhsakmt.h
+--- src/libhsakmt.h	2020-03-04 15:00:47.000000000 -0500
++++ src/libhsakmt.h	2020-04-13 12:58:30.444865992 -0400
+@@ -54,6 +54,10 @@
+ #define CHECK_KFD_OPEN() \
+ 	do { if (kfd_open_count == 0 || hsakmt_forked) return HSAKMT_STATUS_KERNEL_IO_CHANNEL_NOT_OPENED; } while (0)
+ 
++/*On some platforms, a PAGE_SIZE macro eclipses the extern variable*/
++#ifdef PAGE_SIZE
++#undef PAGE_SIZE
++#endif
+ extern int PAGE_SIZE;
+ extern int PAGE_SHIFT;
+ 
+diff -r -u old/src/topology.c new/src/topology.c
+--- src/topology.c	2020-03-04 15:00:47.000000000 -0500
++++ src/topology.c	2020-04-13 13:01:31.209870701 -0400
+@@ -38,6 +38,11 @@
+ #include "libhsakmt.h"
+ #include "fmm.h"
+ 
++/*Needed on MUSL*/
++#ifndef MAXNAMLEN
++#define MAXNAMLEN PATH_MAX
++#endif
++
+ /* Number of memory banks added by thunk on top of topology
+  * This only includes static heaps like LDS, scratch and SVM,
+  * not for MMIO_REMAP heap. MMIO_REMAP memory bank is reported
diff --git a/srcpkgs/roct-thunk-interface/template b/srcpkgs/roct-thunk-interface/template
new file mode 100644
index 00000000000..55a1fc6074a
--- /dev/null
+++ b/srcpkgs/roct-thunk-interface/template
@@ -0,0 +1,33 @@
+# Template file for 'roct-thunk-interface'
+pkgname=roct-thunk-interface
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="ROCT-Thunk-Interface-roc-${version}"
+build_style=cmake
+make_build_target="all build-dev"
+make_install_target="install install-dev"
+hostmakedepends="cmake pkg-config"
+makedepends="pciutils-devel libnuma-devel"
+short_desc="Radeon Open Compute Thunk Interface"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="MIT"
+homepage="https://github.com/RadeonOpenCompute/ROCT-Thunk-Interface"
+distfiles="${homepage}/archive/roc-${version}.tar.gz"
+checksum=2cabe9d2cfa72031c05d11290837c476182e72d8dec2049298f691143fdd212b
+nocross=yes
+
+post_install() {
+	vlicense LICENSE.md
+}
+
+roct-thunk-interface-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove "usr/lib/*.so"
+		vmove usr/share/pkgconfig
+		vmove usr/lib/cmake
+	}
+}

From 2f24bf3c109b1a49ae9dc0699610cf1d0b9b7f01 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Mon, 13 Apr 2020 15:27:27 -0400
Subject: [PATCH 02/10] New package: rocr-runtime-3.3.0

---
 common/shlibs                            |  1 +
 srcpkgs/rocr-runtime-devel               |  1 +
 srcpkgs/rocr-runtime/patches/cmake.patch | 27 +++++++++++++++++++++
 srcpkgs/rocr-runtime/template            | 30 ++++++++++++++++++++++++
 4 files changed, 59 insertions(+)
 create mode 120000 srcpkgs/rocr-runtime-devel
 create mode 100644 srcpkgs/rocr-runtime/patches/cmake.patch
 create mode 100644 srcpkgs/rocr-runtime/template

diff --git a/common/shlibs b/common/shlibs
index 0b2cc3bcce7..781bf28cf44 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3861,3 +3861,4 @@ libqtutilities.so.6 qtutilities-6.0.4_1
 libkdsoap.so.1.9.0 KDSoap-1.9.0_1
 libstoken.so.1 stoken-0.92_1
 libhsakmt.so.1 roct-thunk-interface-3.3.0_1
+libhsa-runtime64.so.1 rocr-runtime-3.3.0_1
diff --git a/srcpkgs/rocr-runtime-devel b/srcpkgs/rocr-runtime-devel
new file mode 120000
index 00000000000..be838f22d81
--- /dev/null
+++ b/srcpkgs/rocr-runtime-devel
@@ -0,0 +1 @@
+rocr-runtime
\ No newline at end of file
diff --git a/srcpkgs/rocr-runtime/patches/cmake.patch b/srcpkgs/rocr-runtime/patches/cmake.patch
new file mode 100644
index 00000000000..93b74cd2297
--- /dev/null
+++ b/srcpkgs/rocr-runtime/patches/cmake.patch
@@ -0,0 +1,27 @@
+--- src/CMakeLists.txt.old	2020-04-18 20:01:48.549636995 -0400
++++ src/CMakeLists.txt	2020-04-18 20:04:00.177179781 -0400
+@@ -108,8 +108,8 @@
+ ## ROCr build internal versioning
+ add_definitions ( -DROCR_BUILD_ID=${PACKAGE_VERSION_STRING} )
+ 
+-## Set RUNPATH - ../../lib covers use of the legacy symlink in /hsa/lib/
+-set(CMAKE_INSTALL_RPATH "$ORIGIN;$ORIGIN/../../lib;$ORIGIN/../../lib64;$ORIGIN/../lib64")
++## Set RUNPATH
++set(CMAKE_INSTALL_RPATH "$ORIGIN;$ORIGIN/../lib")
+ 
+ ## ------------------------- Linux Compiler and Linker options -------------------------
+ set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -fexceptions -fno-rtti -fvisibility=hidden -Wno-error=sign-compare -Wno-sign-compare -Wno-write-strings -Wno-conversion-null -fno-math-errno -fno-threadsafe-statics -fmerge-all-constants -fms-extensions -Wno-error=comment -Wno-comment -Wno-error=pointer-arith -Wno-pointer-arith -Wno-error=unused-variable -Wno-error=unused-function" )
+@@ -185,11 +185,8 @@
+ add_custom_target ( hsa_lib_link2 ALL WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMAND ${CMAKE_COMMAND} -E create_symlink ../hsa/lib/${CORE_RUNTIME_LIBRARY}.so.${SO_MAJOR} ${CORE_RUNTIME_LIBRARY}-link.so.${SO_MAJOR} )
+ 
+ ## Set install information
+-install ( TARGETS ${CORE_RUNTIME_TARGET} LIBRARY DESTINATION hsa/lib )
+-install ( DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/inc/ DESTINATION hsa/include/hsa )
+-install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/hsa_include_link DESTINATION include PERMISSIONS OWNER_WRITE OWNER_READ RENAME hsa )
+-install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/${CORE_RUNTIME_LIBRARY}-link.so DESTINATION lib PERMISSIONS OWNER_WRITE OWNER_READ RENAME ${CORE_RUNTIME_LIBRARY}.so )
+-install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/${CORE_RUNTIME_LIBRARY}-link.so.${SO_MAJOR} DESTINATION lib PERMISSIONS OWNER_WRITE OWNER_READ RENAME ${CORE_RUNTIME_LIBRARY}.so.${SO_MAJOR} )
++install ( TARGETS ${CORE_RUNTIME_TARGET} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} )
++install ( DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/inc/ DESTINATION include/hsa )
+ 
+ ## Packaging directives
+ set ( CPACK_GENERATOR "DEB;RPM" CACHE STRING "Package types to build")
diff --git a/srcpkgs/rocr-runtime/template b/srcpkgs/rocr-runtime/template
new file mode 100644
index 00000000000..5ee22140f1f
--- /dev/null
+++ b/srcpkgs/rocr-runtime/template
@@ -0,0 +1,30 @@
+# Template file for 'rocr-runtime'
+pkgname=rocr-runtime
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="ROCR-Runtime-rocm-${version}"
+build_wrksrc="src"
+build_style=cmake
+hostmakedepends="cmake pkg-config"
+makedepends="roct-thunk-interface-devel elfutils-devel"
+short_desc="Radeon Open Compute HSA Runtime"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute/ROCR-Runtime"
+distfiles="${homepage}/archive/rocm-${version}.tar.gz"
+checksum=fa2d2d1f8a61d8a6952d377cf288d78c61776c3c2a666f163cafc3aa19ab0b61
+nocross=yes
+
+post_install() {
+	vlicense ../LICENSE.txt
+}
+
+rocr-runtime-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove "usr/lib/*.so"
+	}
+}

From 6eca0caa1b246736b6ca6bd1c3028bbf933535e1 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Mon, 13 Apr 2020 18:07:34 -0400
Subject: [PATCH 03/10] New package: rocm-llvm-3.3.0

---
 srcpkgs/rocm-llvm/template | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)
 create mode 100644 srcpkgs/rocm-llvm/template

diff --git a/srcpkgs/rocm-llvm/template b/srcpkgs/rocm-llvm/template
new file mode 100644
index 00000000000..d6e75cd050c
--- /dev/null
+++ b/srcpkgs/rocm-llvm/template
@@ -0,0 +1,26 @@
+# Template file for 'rocm-llvm'
+pkgname=rocm-llvm
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="llvm-project-rocm-ocl-${version}"
+build_wrksrc=llvm
+build_style=cmake
+configure_args="-DCMAKE_INSTALL_PREFIX:PATH=/usr/lib/rocm-llvm
+	-DLLVM_ENABLE_PROJECTS='llvm;clang;lld' -DLLVM_TARGETS_TO_BUILD='AMDGPU'
+	-DLLVM_BUILD_DOCS=NO -DLLVM_ENABLE_OCAMLDOC=OFF
+	-DLLVM_ENABLE_SPHINX=NO -DLLVM_ENABLE_DOXYGEN=OFF
+	-DLLVM_INSTALL_UTILS=ON -DLLVM_VERSION_SUFFIX=roc -DOCAMLFIND=NO"
+hostmakedepends="cmake pkg-config python3"
+short_desc="Radeon Open Compute LLVM toolchain"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="Apache-2.0, NCSA, custom:LLVM-Exceptions"
+homepage="https://github.com/RadeonOpenCompute/llvm-project"
+distfiles="${homepage}/archive/rocm-ocl-${version}.tar.gz"
+checksum=a2bef7042e8e2f2cd8548cb246b88322e1c77188839983dcac8312d56f544dc8
+python_version=3
+nocross=yes
+
+post_install() {
+	vlicense LICENSE.TXT
+}

From 9b6c6609edc132206b45353d8f14dfd87d9ae6eb Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Tue, 14 Apr 2020 10:25:31 -0400
Subject: [PATCH 04/10] New package: rocm-device-libs-3.3.0

---
 srcpkgs/rocm-device-libs/template | 37 +++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)
 create mode 100644 srcpkgs/rocm-device-libs/template

diff --git a/srcpkgs/rocm-device-libs/template b/srcpkgs/rocm-device-libs/template
new file mode 100644
index 00000000000..fcb4eb0d53e
--- /dev/null
+++ b/srcpkgs/rocm-device-libs/template
@@ -0,0 +1,37 @@
+# Template file for 'rocm-device-libs'
+pkgname=rocm-device-libs
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="ROCm-Device-Libs-rocm-ocl-${version}"
+build_style=cmake
+configure_args="-DLLVM_DIR:PATH=/usr/lib/rocm-llvm
+	-DCMAKE_INSTALL_LIBDIR:PATH=lib/rocm-device-libs"
+hostmakedepends="cmake rocm-llvm"
+short_desc="Radeon Open Compute device libraries"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute/ROCm-Device-Libs"
+distfiles="${homepage}/archive/rocm-ocl-${version}.tar.gz"
+checksum=706b08230790e08ca6a7a2fb7687d6131fd39a562148340e00fa37a6c06769c5
+nocross=yes
+
+pre_configure() {
+	# Put bytecodes in a lib/ subdirectory
+	vsed -i Packages.cmake -e 's@/lib/@/${CMAKE_INSTALL_LIBDIR}/@'
+	vsed -i OCL.cmake -e 's@DESTINATION lib$@DESTINATION ${CMAKE_INSTALL_LIBDIR}@'
+
+	# Build the prepare-builtins executable with native compiler
+	mkdir -p utils/build
+	cd utils/build
+	_prepare_builtins="$PWD/prepare-builtins/prepare-builtins"
+	cmake ${configure_args} ..
+	make ${makejobs}
+
+	# Add path to prepare-builtins for cmake
+	configure_args+=" -DPREPARE_BUILTINS='${_prepare_builtins}'"
+}
+
+post_install() {
+	vlicense LICENSE
+}

From fa27402432a2fec03e04ec5fd99355f04500c54b Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Mon, 13 Apr 2020 18:30:00 -0400
Subject: [PATCH 05/10] New package: rocm-comgr-3.3.0

---
 common/shlibs               |  1 +
 srcpkgs/rocm-comgr-devel    |  1 +
 srcpkgs/rocm-comgr/template | 32 ++++++++++++++++++++++++++++++++
 3 files changed, 34 insertions(+)
 create mode 120000 srcpkgs/rocm-comgr-devel
 create mode 100644 srcpkgs/rocm-comgr/template

diff --git a/common/shlibs b/common/shlibs
index 781bf28cf44..1c33c573714 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3862,3 +3862,4 @@ libkdsoap.so.1.9.0 KDSoap-1.9.0_1
 libstoken.so.1 stoken-0.92_1
 libhsakmt.so.1 roct-thunk-interface-3.3.0_1
 libhsa-runtime64.so.1 rocr-runtime-3.3.0_1
+libamd_comgr.so.1 rocm-comgr-3.3.0_1
diff --git a/srcpkgs/rocm-comgr-devel b/srcpkgs/rocm-comgr-devel
new file mode 120000
index 00000000000..3f5ce255e07
--- /dev/null
+++ b/srcpkgs/rocm-comgr-devel
@@ -0,0 +1 @@
+rocm-comgr
\ No newline at end of file
diff --git a/srcpkgs/rocm-comgr/template b/srcpkgs/rocm-comgr/template
new file mode 100644
index 00000000000..c228bcd4d1f
--- /dev/null
+++ b/srcpkgs/rocm-comgr/template
@@ -0,0 +1,32 @@
+# Template file for 'rocm-comgr'
+pkgname=rocm-comgr
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="ROCm-CompilerSupport-rocm-${version}"
+build_wrksrc="lib/comgr"
+build_style=cmake
+configure_args="-DClang_DIR:PATH=/usr/lib/rocm-llvm/lib/cmake/clang"
+hostmakedepends="cmake pkg-config rocm-llvm"
+makedepends="rocm-device-libs"
+short_desc="Radeon Open Compute Code Object Manager"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="BSD-3-Clause"
+homepage="https://github.com/RadeonOpenCompute/ROCm-CompilerSupport"
+distfiles="${homepage}/archive/rocm-${version}.tar.gz"
+checksum=01e2524e0f28ecd6f46c9720f279207de935d826b0172158792aa3ec86af9ca7
+nocross=yes
+
+post_install() {
+	vlicense LICENSE.txt
+}
+
+rocm-comgr-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove "usr/lib/*.so"
+		vmove usr/lib/cmake
+	}
+}

From 21faef31b022bdeed174886a02a4a4a687ead020 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Fri, 17 Apr 2020 12:11:25 -0400
Subject: [PATCH 06/10] New package: rocminfo-3.3.0

---
 srcpkgs/rocminfo/template | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
 create mode 100644 srcpkgs/rocminfo/template

diff --git a/srcpkgs/rocminfo/template b/srcpkgs/rocminfo/template
new file mode 100644
index 00000000000..57d0640dd69
--- /dev/null
+++ b/srcpkgs/rocminfo/template
@@ -0,0 +1,22 @@
+# Template file for 'rocminfo'
+pkgname=rocminfo
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="rocminfo-rocm-${version}"
+build_style=cmake
+configure_args="-DROCM_DIR=/usr"
+hostmakedepends="cmake pkg-config"
+makedepends="rocr-runtime-devel"
+short_desc="Radeon Open Compute system information reporter"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute/rocminfo"
+distfiles="${homepage}/archive/rocm-${version}.tar.gz"
+checksum=e666f662c9e465aaabbbd0b109d87e017243cdf1a0898fabf5a90947bb3dbcd7
+nocross=yes
+python_version=3
+
+post_install() {
+	vlicense License.txt
+}

From ecd269a63ea40fe465d17ed74256620a2ae087e3 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Sun, 19 Apr 2020 15:01:40 -0400
Subject: [PATCH 07/10] New package: rocm-bandwidth-test-3.3.0

---
 srcpkgs/rocm-bandwidth-test/template | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
 create mode 100644 srcpkgs/rocm-bandwidth-test/template

diff --git a/srcpkgs/rocm-bandwidth-test/template b/srcpkgs/rocm-bandwidth-test/template
new file mode 100644
index 00000000000..5c5058b693d
--- /dev/null
+++ b/srcpkgs/rocm-bandwidth-test/template
@@ -0,0 +1,20 @@
+# Template file for 'rocm-bandwidth-test'
+pkgname=rocm-bandwidth-test
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="rocm_bandwidth_test-rocm-${version}"
+build_style=cmake
+hostmakedepends="cmake"
+makedepends="rocr-runtime-devel roct-thunk-interface-devel"
+short_desc="Radeon Open Compute bandwidth test"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute/rocm_bandwidth_test"
+distfiles="${homepage}/archive/rocm-${version}.tar.gz"
+checksum=f5f914073018619dc91662d5bf630903dfa4db9136d603591917fdfb3c9164ce
+nocross=yes
+
+post_install() {
+	vlicense LICENSE.txt
+}

From 283ad279e045baea6a9eec32f38a1a3d456a85d7 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Tue, 14 Apr 2020 10:25:54 -0400
Subject: [PATCH 08/10] New package: rocm-opencl-runtime-3.3.0

---
 common/shlibs                                 |   2 +
 srcpkgs/rocm-opencl-runtime-clinfo            |   1 +
 srcpkgs/rocm-opencl-runtime-devel             |   1 +
 .../files/libelf-musl.patch                   |  21 +++
 .../files/runtime-musl.patch                  |  11 ++
 .../rocm-opencl-runtime/patches/cmake.patch   | 126 ++++++++++++++++++
 srcpkgs/rocm-opencl-runtime/template          |  84 ++++++++++++
 7 files changed, 246 insertions(+)
 create mode 120000 srcpkgs/rocm-opencl-runtime-clinfo
 create mode 120000 srcpkgs/rocm-opencl-runtime-devel
 create mode 100644 srcpkgs/rocm-opencl-runtime/files/libelf-musl.patch
 create mode 100644 srcpkgs/rocm-opencl-runtime/files/runtime-musl.patch
 create mode 100644 srcpkgs/rocm-opencl-runtime/patches/cmake.patch
 create mode 100644 srcpkgs/rocm-opencl-runtime/template

diff --git a/common/shlibs b/common/shlibs
index 1c33c573714..6fc139f970b 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3863,3 +3863,5 @@ libstoken.so.1 stoken-0.92_1
 libhsakmt.so.1 roct-thunk-interface-3.3.0_1
 libhsa-runtime64.so.1 rocr-runtime-3.3.0_1
 libamd_comgr.so.1 rocm-comgr-3.3.0_1
+libOpenCL-ROCm.so.1 rocm-opencl-runtime-3.3.0_1
+libamdocl64.so rocm-opencl-runtime-3.3.0_1
diff --git a/srcpkgs/rocm-opencl-runtime-clinfo b/srcpkgs/rocm-opencl-runtime-clinfo
new file mode 120000
index 00000000000..b2cda7e229d
--- /dev/null
+++ b/srcpkgs/rocm-opencl-runtime-clinfo
@@ -0,0 +1 @@
+rocm-opencl-runtime
\ No newline at end of file
diff --git a/srcpkgs/rocm-opencl-runtime-devel b/srcpkgs/rocm-opencl-runtime-devel
new file mode 120000
index 00000000000..b2cda7e229d
--- /dev/null
+++ b/srcpkgs/rocm-opencl-runtime-devel
@@ -0,0 +1 @@
+rocm-opencl-runtime
\ No newline at end of file
diff --git a/srcpkgs/rocm-opencl-runtime/files/libelf-musl.patch b/srcpkgs/rocm-opencl-runtime/files/libelf-musl.patch
new file mode 100644
index 00000000000..29469a9a351
--- /dev/null
+++ b/srcpkgs/rocm-opencl-runtime/files/libelf-musl.patch
@@ -0,0 +1,21 @@
+--- compiler/lib/loaders/elf/utils/libelf/_libelf.h	2020-04-28 15:50:53.243438174 -0400
++++ compiler/lib/loaders/elf/utils/libelf/_libelf.h	2020-04-28 15:51:54.293435415 -0400
+@@ -35,6 +35,7 @@
+ #include "_libelf_config.h"
+ 
+ #include "_elftc.h"
++#include <sys/cdefs.h>
+ 
+ /*
+  * Library-private data structures.
+--- compiler/lib/loaders/elf/utils/libelf/libelf.h	2020-04-28 15:50:53.244438174 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf.h	2020-04-28 15:52:12.375434593 -0400
+@@ -36,6 +36,8 @@
+ #define EM_HSAIL 0xAF5A
+ #endif
+ 
++#include <sys/cdefs.h>
++
+ /* Library private data structures */
+ typedef struct _Elf Elf;
+ typedef struct _Elf_Scn Elf_Scn;
diff --git a/srcpkgs/rocm-opencl-runtime/files/runtime-musl.patch b/srcpkgs/rocm-opencl-runtime/files/runtime-musl.patch
new file mode 100644
index 00000000000..ea18e90e09c
--- /dev/null
+++ b/srcpkgs/rocm-opencl-runtime/files/runtime-musl.patch
@@ -0,0 +1,11 @@
+--- runtime/os/os_posix.cpp.orig	2020-04-19 09:13:51.701982901 -0400
++++ runtime/os/os_posix.cpp	2020-04-19 09:14:04.156947422 -0400
+@@ -44,6 +44,8 @@
+ #include <algorithm>
+ #include <mutex>
+ 
++#include <libgen.h> // for basename
++
+ 
+ namespace amd {
+ 
diff --git a/srcpkgs/rocm-opencl-runtime/patches/cmake.patch b/srcpkgs/rocm-opencl-runtime/patches/cmake.patch
new file mode 100644
index 00000000000..2c96b99d45a
--- /dev/null
+++ b/srcpkgs/rocm-opencl-runtime/patches/cmake.patch
@@ -0,0 +1,126 @@
+--- OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/CMakeLists.txt	2019-09-10 11:53:28.000000000 -0400
++++ OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/CMakeLists.txt	2020-04-16 20:16:13.481180757 -0400
+@@ -73,11 +73,11 @@
+ 
+ set (OPENCL_ICD_LOADER_HEADERS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/inc CACHE PATH "Path to OpenCL Headers")
+ 
+-add_library (OpenCL ${OPENCL_ICD_LOADER_SOURCES})
+-set_target_properties (OpenCL PROPERTIES VERSION "1.2" SOVERSION "1")
++add_library (OpenCL-ROCm ${OPENCL_ICD_LOADER_SOURCES})
++set_target_properties (OpenCL-ROCm PROPERTIES VERSION "1.2" SOVERSION "1")
+ 
+ if (WIN32)
+-    target_link_libraries (OpenCL cfgmgr32.lib)
++    target_link_libraries (OpenCL-ROCm cfgmgr32.lib)
+ 
+     option (OPENCL_ICD_LOADER_REQUIRE_WDK "Build with D3DKMT support, which requires the Windows WDK." ON)
+     if (OPENCL_ICD_LOADER_REQUIRE_WDK)
+@@ -92,10 +92,10 @@
+             get_filename_component(WDK_DIRECTORY ${LATEST_D3DKMT_HEADER} DIRECTORY)
+             get_filename_component(WDK_DIRECTORY ${WDK_DIRECTORY} DIRECTORY)
+             message(STATUS "Found the Windows WDK in: ${WDK_DIRECTORY}")
+-            target_compile_definitions(OpenCL PRIVATE OPENCL_ICD_LOADER_REQUIRE_WDK)
+-            target_include_directories(OpenCL PRIVATE ${WDK_DIRECTORY}/um)
+-            target_include_directories(OpenCL PRIVATE ${WDK_DIRECTORY}/km)
+-            target_include_directories(OpenCL PRIVATE ${WDK_DIRECTORY}/shared)
++	    target_compile_definitions(OpenCL-ROCm PRIVATE OPENCL_ICD_LOADER_REQUIRE_WDK)
++	    target_include_directories(OpenCL-ROCm PRIVATE ${WDK_DIRECTORY}/um)
++	    target_include_directories(OpenCL-ROCm PRIVATE ${WDK_DIRECTORY}/km)
++	    target_include_directories(OpenCL-ROCm PRIVATE ${WDK_DIRECTORY}/shared)
+         else()
+             message(FATAL_ERROR "The Windows WDK was not found. Consider disabling OPENCL_ICD_LOADER_REQUIRE_WDK. Aborting.")
+         endif()
+@@ -113,25 +113,25 @@
+     endif()
+ else()
+     if (APPLE)
+-        target_link_libraries (OpenCL ${CMAKE_THREAD_LIBS_INIT})
++        target_link_libraries (OpenCL-ROCm ${CMAKE_THREAD_LIBS_INIT})
+     else ()
+-        set_target_properties (OpenCL PROPERTIES LINK_FLAGS "-Wl,--version-script -Wl,${CMAKE_CURRENT_SOURCE_DIR}/loader/linux/icd_exports.map")
+-        target_link_libraries (OpenCL ${CMAKE_THREAD_LIBS_INIT})
++        set_target_properties (OpenCL-ROCm PROPERTIES LINK_FLAGS "-Wl,--version-script -Wl,${CMAKE_CURRENT_SOURCE_DIR}/loader/linux/icd_exports.map")
++	target_link_libraries (OpenCL-ROCm ${CMAKE_THREAD_LIBS_INIT})
+     endif ()
+ endif ()
+ 
+ include_directories (${OPENCL_ICD_LOADER_HEADERS_DIR})
+ add_definitions (-DCL_TARGET_OPENCL_VERSION=220)
+ 
+-target_include_directories (OpenCL PRIVATE ${CMAKE_CURRENT_BINARY_DIR} loader)
+-target_link_libraries (OpenCL ${CMAKE_DL_LIBS})
++target_include_directories (OpenCL-ROCm PRIVATE ${CMAKE_CURRENT_BINARY_DIR} loader)
++target_link_libraries (OpenCL-ROCm ${CMAKE_DL_LIBS})
+ 
+ include (CTest)
+ if (BUILD_TESTING)
+     add_subdirectory (test)
+ endif()
+ 
+-install (TARGETS OpenCL
++install (TARGETS OpenCL-ROCm
+     RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+     ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
+     LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
+--- OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/test/loader_test/CMakeLists.txt	2019-09-10 11:53:28.000000000 -0400
++++ OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/test/loader_test/CMakeLists.txt	2020-04-16 20:16:56.647026589 -0400
+@@ -12,4 +12,4 @@
+     test_clgl.c
+     test_image_objects.c )
+ 
+-target_link_libraries (icd_loader_test OpenCL IcdLog)
++target_link_libraries (icd_loader_test OpenCL-ROCm IcdLog)
+--- ROCm-OpenCL-Runtime-roc-3.3.0/CMakeLists.txt	2020-04-28 07:29:51.864446603 -0400
++++ ROCm-OpenCL-Runtime-roc-3.3.0/CMakeLists.txt	2020-04-28 07:32:45.245793180 -0400
+@@ -101,30 +101,30 @@
+ rocm_setup_version( VERSION "2.0.0" )
+ 
+ # MAIN package
+-install(PROGRAMS $<TARGET_FILE:clinfo>
+-        DESTINATION bin/x86_64
++install(PROGRAMS $<TARGET_FILE:rocm-clinfo>
++        DESTINATION bin
+         COMPONENT MAIN)
+ install(PROGRAMS $<TARGET_FILE:amdocl64>
+-        DESTINATION lib/x86_64
++        DESTINATION lib
+         COMPONENT MAIN)
+-install(PROGRAMS $<TARGET_FILE:OpenCL>
+-        DESTINATION lib/x86_64
++install(PROGRAMS $<TARGET_FILE:OpenCL-ROCm>
++        DESTINATION lib
+         COMPONENT MAIN)
+-install(PROGRAMS $<TARGET_SONAME_FILE:OpenCL>
+-        DESTINATION lib/x86_64
++install(PROGRAMS $<TARGET_SONAME_FILE:OpenCL-ROCm>
++        DESTINATION lib
+         COMPONENT MAIN)
+ 
+ # DEV package
+ install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/api/opencl/khronos/headers/opencl2.2/CL"
+-        DESTINATION include
++	DESTINATION include/rocm
+         COMPONENT DEV
+         USE_SOURCE_PERMISSIONS
+         PATTERN cl_d3d10.h EXCLUDE
+         PATTERN cl_d3d11.h EXCLUDE
+         PATTERN cl_dx9_media_sharing.h EXCLUDE
+         PATTERN cl_egl.h EXCLUDE)
+-install(PROGRAMS $<TARGET_LINKER_FILE:OpenCL>
+-        DESTINATION lib/x86_64
++install(PROGRAMS $<TARGET_LINKER_FILE:OpenCL-ROCm>
++        DESTINATION lib
+         COMPONENT DEV)
+ 
+ # Generic CPACK variables
+--- ROCm-OpenCL-Runtime-roc-3.3.0/tools/clinfo/CMakeLists.txt	2020-04-28 07:29:51.882446535 -0400
++++ ROCm-OpenCL-Runtime-roc-3.3.0/tools/clinfo/CMakeLists.txt	2020-04-28 07:30:05.627394732 -0400
+@@ -6,6 +6,6 @@
+ 
+ add_definitions(-DHAVE_CL2_HPP)
+ 
+-add_executable(clinfo clinfo.cpp)
++add_executable(rocm-clinfo clinfo.cpp)
+ 
+-target_link_libraries(clinfo OpenCL)
++target_link_libraries(rocm-clinfo OpenCL-ROCm)
diff --git a/srcpkgs/rocm-opencl-runtime/template b/srcpkgs/rocm-opencl-runtime/template
new file mode 100644
index 00000000000..02aebb91bd8
--- /dev/null
+++ b/srcpkgs/rocm-opencl-runtime/template
@@ -0,0 +1,84 @@
+# Template file for 'rocm-opencl-runtime'
+pkgname=rocm-opencl-runtime
+version=3.3.0
+revision=1
+_ocl_icd_name="OpenCL-ICD-Loader"
+_ocl_icd_ver="6c03f8b58fafd9dd693eaac826749a5cfad515f8"
+archs="x86_64*"
+create_wrksrc=yes
+build_wrksrc="ROCm-OpenCL-Runtime-roc-${version}"
+build_style=cmake
+configure_args="-DUSE_COMGR_LIBRARY=yes"
+hostmakedepends="cmake pkg-config"
+makedepends="libglvnd-devel rocm-comgr-devel
+	roct-thunk-interface-devel rocr-runtime-devel"
+depends="rocm-comgr"
+short_desc="Radeon Open Compute OpenCL runtime"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="MIT"
+homepage="https://github.com/RadeonOpenCompute/ROCm-OpenCL-Runtime"
+_rocroot="https://github.com/RadeonOpenCompute"
+distfiles="${_rocroot}/ROCm-OpenCL-Runtime/archive/roc-${version}.tar.gz
+	${_rocroot}/rocm-cmake/archive/rocm-${version}.tar.gz
+	https://github.com/KhronosGroup/${_ocl_icd_name}/archive/${_ocl_icd_ver}.tar.gz"
+checksum="ac6999f1a491ab066286c2bd6adf50f08f831286f56e267879f9f7eced22f98e
+	76ed3ee8e56cf3246011cf7723c2abda539e1136e7e7f6909bfa45d268b8644f
+	c94d5bb6dc980c4d41d73e2b81663a19aabe494e923e2d0eec72a4c95b318438"
+nocross=yes
+
+if [ "$XBPS_LIBC" = "musl" ]; then
+	makedepends+=" musl-legacy-compat"
+fi
+
+post_patch() {
+	if [ "$XBPS_LIBC" = "musl" ]; then
+		# Remove dependence on glibc
+		patch -Np0 < ${FILESDIR}/libelf-musl.patch
+		patch -Np0 < ${FILESDIR}/runtime-musl.patch
+		vsed -e '/glibc_functions.cpp/d' -i api/opencl/amdocl/CMakeLists.txt
+	fi
+}
+
+pre_configure() {
+	# ROCm requires a very specific Khronos ICD loader version in the tree
+	# Keep the ICD loader config in /etc/OpenCL/rocm-vendors to avoid conflicts
+	_ocl_icd_dir="${_ocl_icd_name}-${_ocl_icd_ver}"
+	ln -sf "${wrksrc}/${_ocl_icd_dir}" api/opencl/khronos/icd
+	vsed -i "${wrksrc}/${_ocl_icd_dir}/loader/icd_platform.h" \
+		-e 's@/etc/OpenCL/vendors/@/etc/OpenCL/rocm-vendors/@g'
+
+	# CMake modules probably not useful anywhere but for this build
+	ln -sf "${wrksrc}/rocm-cmake-rocm-${version}/share/rocm/cmake"/*.cmake cmake
+
+	# Fix the dlopen macro to point to versioned libamd_comgr shared object
+	vsed -i 'runtime/device/comgrctx.cpp' \
+		-e 's/\blibamd_comgr\(32\)\?.so\b/&.1/g'
+}
+
+post_install() {
+	vlicense License
+
+	# Create descriptor to allow the ICD loader to find the driver
+	vmkdir etc/OpenCL/rocm-vendors
+	echo "libamdocl64.so" > "${DESTDIR}/etc/OpenCL/rocm-vendors/amdocl64.icd"
+	vmkdir etc/OpenCL/vendors
+	ln -s ../../OpenCL/rocm-vendors/amdocl64.icd \
+		${DESTDIR}/etc/OpenCL/vendors/rocm-amdocl64.icd
+}
+
+rocm-opencl-runtime-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/lib/libOpenCL-ROCm.so
+		vmove usr/include
+	}
+}
+
+rocm-opencl-runtime-clinfo_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - clinfo"
+	pkg_install() {
+		vmove usr/bin/rocm-clinfo
+	}
+}

From 3834bc1a54075b215d3c744829eab4fce89371c3 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Thu, 30 Apr 2020 13:11:12 -0400
Subject: [PATCH 09/10] New package: rocm-hsa-ext-3.3.0

---
 common/shlibs                 |  2 ++
 srcpkgs/rocm-hsa-ext-devel    |  1 +
 srcpkgs/rocm-hsa-ext/template | 42 +++++++++++++++++++++++++++++++++++
 3 files changed, 45 insertions(+)
 create mode 120000 srcpkgs/rocm-hsa-ext-devel
 create mode 100644 srcpkgs/rocm-hsa-ext/template

diff --git a/common/shlibs b/common/shlibs
index 6fc139f970b..fd32576b66c 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3865,3 +3865,5 @@ libhsa-runtime64.so.1 rocr-runtime-3.3.0_1
 libamd_comgr.so.1 rocm-comgr-3.3.0_1
 libOpenCL-ROCm.so.1 rocm-opencl-runtime-3.3.0_1
 libamdocl64.so rocm-opencl-runtime-3.3.0_1
+libhsa-ext-image64.so.1 rocm-hsa-ext-3.3.0_1
+libhsa-runtime-tools64.so.1 rocm-hsa-ext-3.3.0_1
diff --git a/srcpkgs/rocm-hsa-ext-devel b/srcpkgs/rocm-hsa-ext-devel
new file mode 120000
index 00000000000..d201e9f2fae
--- /dev/null
+++ b/srcpkgs/rocm-hsa-ext-devel
@@ -0,0 +1 @@
+rocm-hsa-ext
\ No newline at end of file
diff --git a/srcpkgs/rocm-hsa-ext/template b/srcpkgs/rocm-hsa-ext/template
new file mode 100644
index 00000000000..a879f03480f
--- /dev/null
+++ b/srcpkgs/rocm-hsa-ext/template
@@ -0,0 +1,42 @@
+# Template file for 'rocm-hsa-ext'
+pkgname=rocm-hsa-ext
+version=3.3.0
+revision=1
+archs="x86_64"
+hostmakedepends="tar"
+short_desc="Radeon Open Compute HSA runtime extensions"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute"
+_hsa_deb="hsa-ext-rocr-dev_1.1.30300.0-rocm-rel-3.3-19-23fc088b_amd64.deb"
+distfiles="https://repo.radeon.com/rocm/apt/debian/pool/main/h/hsa-ext-rocr-dev/$_hsa_deb"
+checksum=6b44e286b395d946b865ec1f3cc546356396785ac1fde591d07af02d0aa7c25d
+repository=nonfree
+
+do_extract() {
+	ar x "${XBPS_SRCDISTDIR}/${pkgname}-${version}/${_hsa_deb}"
+	tar xvf data.tar.gz
+}
+
+do_install() {
+	_rocm_includes="opt/rocm-${version}/hsa/include"
+	
+	vmkdir usr
+	vcopy opt/rocm-${version}/hsa/lib usr
+	vcopy "$_rocm_includes" usr
+
+	# Extract license from one of the header files
+	awk 'BEGIN{HEADER=0} /\/\//{HEADER=1; print $0;} /^[^/]/{if(HEADER==1) exit;}' \
+		< "${_rocm_includes}/hsa/amd_hsa_tools_interfaces.h" \
+		| sed 's@^///*\( \|$\)@@' > LICENSE
+	vlicense LICENSE
+}
+
+rocm-hsa-ext-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove "usr/lib/*.so"
+	}
+}

From 91443875ded665db0cc03bf8a49b991368bd2aeb Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Tue, 28 Apr 2020 13:33:46 -0400
Subject: [PATCH 10/10] hashcat: add build option to link against ROCm [ci
 skip]

---
 srcpkgs/hashcat/files/rocm.patch     | 15 +++++++++++++++
 srcpkgs/hashcat/patches/tmpdir.patch | 21 +++++++++++++++++++++
 srcpkgs/hashcat/template             | 17 ++++++++++++++---
 3 files changed, 50 insertions(+), 3 deletions(-)
 create mode 100644 srcpkgs/hashcat/files/rocm.patch
 create mode 100644 srcpkgs/hashcat/patches/tmpdir.patch

diff --git a/srcpkgs/hashcat/files/rocm.patch b/srcpkgs/hashcat/files/rocm.patch
new file mode 100644
index 00000000000..f1e899d30ee
--- /dev/null
+++ b/srcpkgs/hashcat/files/rocm.patch
@@ -0,0 +1,15 @@
+diff -ur a/src/opencl.c b/src/opencl.c
+--- a/src/opencl.c	2018-12-02 05:58:48.000000000 -0500
++++ b/src/opencl.c	2020-04-28 13:24:12.602415333 -0400
+@@ -492,9 +492,9 @@
+ 
+   if (ocl->lib == NULL) ocl->lib = hc_dlopen ("cygOpenCL-1.dll", RTLD_NOW);
+   #else
+-  ocl->lib = hc_dlopen ("libOpenCL.so", RTLD_NOW);
++  ocl->lib = hc_dlopen ("libOpenCL-ROCm.so.1", RTLD_NOW);
+ 
+-  if (ocl->lib == NULL) ocl->lib = hc_dlopen ("libOpenCL.so.1", RTLD_NOW);
++  if (ocl->lib == NULL) ocl->lib = hc_dlopen ("libOpenCL-ROCm.so", RTLD_NOW);
+   #endif
+ 
+   if (ocl->lib == NULL)
diff --git a/srcpkgs/hashcat/patches/tmpdir.patch b/srcpkgs/hashcat/patches/tmpdir.patch
new file mode 100644
index 00000000000..0558a001c9c
--- /dev/null
+++ b/srcpkgs/hashcat/patches/tmpdir.patch
@@ -0,0 +1,21 @@
+Addresses https://github.com/hashcat/hashcat/issues/2379
+diff -ur a/src/folder.c b/src/folder.c
+--- src/folder.c	2018-12-02 05:58:48.000000000 -0500
++++ src/folder.c	2020-04-28 13:22:27.340522751 -0400
+@@ -457,16 +457,6 @@
+ 
+   hcfree (cpath);
+ 
+-  //if (getenv ("TMP") == NULL)
+-  if (1)
+-  {
+-    char *tmp;
+-
+-    hc_asprintf (&tmp, "TMP=%s", cpath_real);
+-
+-    putenv (tmp);
+-  }
+-
+   #if defined (_WIN)
+ 
+   naive_replace (cpath_real, '\\', '/');
diff --git a/srcpkgs/hashcat/template b/srcpkgs/hashcat/template
index e982f99cebf..7d3a8cb5a6b 100644
--- a/srcpkgs/hashcat/template
+++ b/srcpkgs/hashcat/template
@@ -1,15 +1,16 @@
 # Template file for 'hashcat'
 pkgname=hashcat
 version=5.1.0
-revision=2
+revision=3
 build_style=gnu-makefile
 make_build_args="PREFIX=/usr
  USE_SYSTEM_OPENCL=1 USE_SYSTEM_XXHASH=1
- DEPS_OPENCL_PATH=${XBPS_CROSS_BASE}/usr/include
+ DEPS_OPENCL_PATH=${XBPS_CROSS_BASE}/usr/include$(vopt_if rocm /rocm)
  DEPS_XXHASH_PATH=${XBPS_CROSS_BASE}/usr/include"
 make_use_env=yes
 make_install_args="$make_build_args"
-makedepends="gmp-devel opencl2-headers xxHash-devel"
+makedepends="gmp-devel xxHash-devel
+ $(vopt_if rocm rocm-opencl-runtime-devel opencl2-headers)"
 checkdepends="perl"
 short_desc="Advanced CPU-based password recovery utility"
 maintainer="Duncaen <duncaen@voidlinux.org>"
@@ -19,6 +20,9 @@ changelog="https://raw.githubusercontent.com/hashcat/hashcat/master/docs/changes
 distfiles="https://hashcat.net/files/hashcat-${version}.tar.gz"
 checksum=283beaa68e1eab41de080a58bb92349c8e47a2bb1b93d10f36ea30f418f1e338
 
+build_options="rocm"
+desc_option_rocm="Use ROCm OpenCL runtime"
+
 if [ "$XBPS_TARGET_ENDIAN" = "be" ]; then
 	broken="Not supported on big endian"
 fi
@@ -26,6 +30,13 @@ fi
 post_extract() {
 	sed '/^CC/d' -i src/Makefile
 }
+
+post_patch() {
+	if [ "$build_option_rocm" ]; then
+		patch -Np1 < ${FILESDIR}/rocm.patch
+	fi
+}
+
 post_install() {
 	rm -f ${DESTDIR}/usr/share/docs/hashcat/license.txt
 	vlicense docs/license.txt

^ permalink raw reply	[flat|nested] 61+ messages in thread

* Re: [PR PATCH] [Updated] New packages: ROCm core and OpenCL
  2020-04-19 13:34 [PR PATCH] New packages: ROCm core and OpenCL ahesford
                   ` (21 preceding siblings ...)
  2020-05-01 14:04 ` [PR PATCH] [Updated] " ahesford
@ 2020-05-01 19:36 ` ahesford
  2020-05-02  1:34 ` ahesford
                   ` (36 subsequent siblings)
  59 siblings, 0 replies; 61+ messages in thread
From: ahesford @ 2020-05-01 19:36 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 3893 bytes --]

There is an updated pull request by ahesford against master on the void-packages repository

https://github.com/ahesford/void-packages rocm
https://github.com/void-linux/void-packages/pull/21153

New packages: ROCm core and OpenCL
This PR includes several packages designed to bring the OpenCL portion of the AMD ROCm ecosystem to Void. It addresses Issue #19507. There are many other packages that AMD provides for GPGPU computing, but these can be added piecemeal as users demand.

The packages are currently only for `x86_64*`. While at least some of the packages will compile on other 64-bit architectures, I have no hardware to test. They are certainly not suitable for 32-bit architectures; some internal data structures rely on `uint64_t` values that are cast to pointers. At a
minimum, a thorough audit would be necessary to ensure that these casts are safe (e.g., that the values stored were only ever upcast from 32-bit pointers). More extensive work may be necessary to support 32-bit architectures, probably without significant benefit.

The packages successfully identify a Radeon RX 580 on an `x86_64` installation using both `clinfo` and `rocminfo` as provided. Furthermore, a version of `pyopencl` linked against these ROCm packages successfully runs a simple program that validates arithmetic on GPU-bound arrays.

There are caveats with this set of packages, almost all of which revolve around the incompatibilities between the Void-provided `ocl-icd` and the [Khronos OpenCL ICD loader](https://github.com/KhronosGroup/OpenCL-ID-Loader) required by (and built into) `rocm-opencl-runtime`.
1. All packages install into `/opt/rocm`. This keeps the environment closer to that officially sanctioned by AMD and helps avoid conflicts between other packages and those provided here. (For example, `clinfo` and the ICD loader itself.) Eventually, we may be able to move the files into `/usr`.
2. The Khronos OpenCL ICD loader built into `rocm-opencl-runtime` is an outdated, pre-release commit. If AMD can update its sources to use the release version of that loader (which has a backward-incompatible API change), we may be able to make ROCm compatible with `ocl-icd` or replace `ocl-icd` with the official Khronos loader.
3. In the meantime, to avoid `shlibs` conflicts, the OpenCL ICD loader is installed as `/opt/rocm/lib/libOpenCL-ROCm.so` (and an appropriately versioned shared library), which means that programs wishing to use the ROCm OpenCL must explicitly link against this library instead of the generic `libOpenCL.so`.
4. I do **not** recommend making any Void packages link against this specific library, because it will make those packages ROCm-only. For the time being, ROCm is intended for end-users to specifically link against. Linking Void packages against ROCm would requires the ICD loader used by ROCm be compatible with `ocl-icd`, or `ocl-icd` be replaced by the Khronos loader. However, because the Khronos loader changed its API for the release version, such a change is not yet appropriate.

Hopefully, if AMD updates its dependence on the Khronos ICD loader, we can resolve some of these caveats in the future and make ROCm a more natural Void component. For now, these packages are useful for those who need an AMD OpenCL solution and would rather custom-link software against the AMD ICD loader than hack the `amdgpu-pro` driver into an ICD compatible with `ocl-icd`.

Some patches were made to relocate some files in `/opt/rocm` and make everyting build on x86_64-musl`. Where appropriate, these patches will be pushed upstream to clean up the distribution and packaging.

Update: I pushed some new commits to update license information that triggerd an `xlint` failure. I've also disabled CI builds because they will time out on `rocm-llvm`.

A patch file from https://github.com/void-linux/void-packages/pull/21153.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-rocm-21153.patch --]
[-- Type: text/x-diff, Size: 35844 bytes --]

From 2a80c4a12b3162c62bb162bd0a4be0f53de8681a Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Mon, 13 Apr 2020 13:08:09 -0400
Subject: [PATCH 01/10] New package: roct-thunk-interface-3.3.0

---
 common/shlibs                                 |  1 +
 srcpkgs/roct-thunk-interface-devel            |  1 +
 .../patches/cmake-dev-libdir.patch            | 10 ++++++
 .../roct-thunk-interface/patches/musl.patch   | 29 ++++++++++++++++
 srcpkgs/roct-thunk-interface/template         | 33 +++++++++++++++++++
 5 files changed, 74 insertions(+)
 create mode 120000 srcpkgs/roct-thunk-interface-devel
 create mode 100644 srcpkgs/roct-thunk-interface/patches/cmake-dev-libdir.patch
 create mode 100644 srcpkgs/roct-thunk-interface/patches/musl.patch
 create mode 100644 srcpkgs/roct-thunk-interface/template

diff --git a/common/shlibs b/common/shlibs
index 820f037f267..0b2cc3bcce7 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3860,3 +3860,4 @@ libtagparser.so.9 tagparser-9.1.2_1
 libqtutilities.so.6 qtutilities-6.0.4_1
 libkdsoap.so.1.9.0 KDSoap-1.9.0_1
 libstoken.so.1 stoken-0.92_1
+libhsakmt.so.1 roct-thunk-interface-3.3.0_1
diff --git a/srcpkgs/roct-thunk-interface-devel b/srcpkgs/roct-thunk-interface-devel
new file mode 120000
index 00000000000..ac3f2cc684c
--- /dev/null
+++ b/srcpkgs/roct-thunk-interface-devel
@@ -0,0 +1 @@
+roct-thunk-interface
\ No newline at end of file
diff --git a/srcpkgs/roct-thunk-interface/patches/cmake-dev-libdir.patch b/srcpkgs/roct-thunk-interface/patches/cmake-dev-libdir.patch
new file mode 100644
index 00000000000..98c7f1e459c
--- /dev/null
+++ b/srcpkgs/roct-thunk-interface/patches/cmake-dev-libdir.patch
@@ -0,0 +1,10 @@
+--- CMakeLists.txt.old	2020-04-18 19:45:17.306081135 -0400
++++ CMakeLists.txt	2020-04-18 19:46:51.300753636 -0400
+@@ -146,6 +146,7 @@
+     COMMAND ${CMAKE_COMMAND}
+         -DSOURCE_DIR="${SOURCE_DIR}"
+         -DCMAKE_INSTALL_PREFIX="${CMAKE_INSTALL_PREFIX}"
++        -DCMAKE_INSTALL_LIBDIR="${CMAKE_INSTALL_LIBDIR}"
+         -DCPACK_RPM_PACKAGE_REQUIRES="hsakmt-roct"
+         -DCPACK_PACKAGING_INSTALL_PREFIX="${CPACK_PACKAGING_INSTALL_PREFIX}"
+         -DVERSION="${BUILD_VERSION_STRING}"
diff --git a/srcpkgs/roct-thunk-interface/patches/musl.patch b/srcpkgs/roct-thunk-interface/patches/musl.patch
new file mode 100644
index 00000000000..aeea9832411
--- /dev/null
+++ b/srcpkgs/roct-thunk-interface/patches/musl.patch
@@ -0,0 +1,29 @@
+diff -r -u old/src/libhsakmt.h new/src/libhsakmt.h
+--- src/libhsakmt.h	2020-03-04 15:00:47.000000000 -0500
++++ src/libhsakmt.h	2020-04-13 12:58:30.444865992 -0400
+@@ -54,6 +54,10 @@
+ #define CHECK_KFD_OPEN() \
+ 	do { if (kfd_open_count == 0 || hsakmt_forked) return HSAKMT_STATUS_KERNEL_IO_CHANNEL_NOT_OPENED; } while (0)
+ 
++/*On some platforms, a PAGE_SIZE macro eclipses the extern variable*/
++#ifdef PAGE_SIZE
++#undef PAGE_SIZE
++#endif
+ extern int PAGE_SIZE;
+ extern int PAGE_SHIFT;
+ 
+diff -r -u old/src/topology.c new/src/topology.c
+--- src/topology.c	2020-03-04 15:00:47.000000000 -0500
++++ src/topology.c	2020-04-13 13:01:31.209870701 -0400
+@@ -38,6 +38,11 @@
+ #include "libhsakmt.h"
+ #include "fmm.h"
+ 
++/*Needed on MUSL*/
++#ifndef MAXNAMLEN
++#define MAXNAMLEN PATH_MAX
++#endif
++
+ /* Number of memory banks added by thunk on top of topology
+  * This only includes static heaps like LDS, scratch and SVM,
+  * not for MMIO_REMAP heap. MMIO_REMAP memory bank is reported
diff --git a/srcpkgs/roct-thunk-interface/template b/srcpkgs/roct-thunk-interface/template
new file mode 100644
index 00000000000..55a1fc6074a
--- /dev/null
+++ b/srcpkgs/roct-thunk-interface/template
@@ -0,0 +1,33 @@
+# Template file for 'roct-thunk-interface'
+pkgname=roct-thunk-interface
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="ROCT-Thunk-Interface-roc-${version}"
+build_style=cmake
+make_build_target="all build-dev"
+make_install_target="install install-dev"
+hostmakedepends="cmake pkg-config"
+makedepends="pciutils-devel libnuma-devel"
+short_desc="Radeon Open Compute Thunk Interface"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="MIT"
+homepage="https://github.com/RadeonOpenCompute/ROCT-Thunk-Interface"
+distfiles="${homepage}/archive/roc-${version}.tar.gz"
+checksum=2cabe9d2cfa72031c05d11290837c476182e72d8dec2049298f691143fdd212b
+nocross=yes
+
+post_install() {
+	vlicense LICENSE.md
+}
+
+roct-thunk-interface-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove "usr/lib/*.so"
+		vmove usr/share/pkgconfig
+		vmove usr/lib/cmake
+	}
+}

From 2f24bf3c109b1a49ae9dc0699610cf1d0b9b7f01 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Mon, 13 Apr 2020 15:27:27 -0400
Subject: [PATCH 02/10] New package: rocr-runtime-3.3.0

---
 common/shlibs                            |  1 +
 srcpkgs/rocr-runtime-devel               |  1 +
 srcpkgs/rocr-runtime/patches/cmake.patch | 27 +++++++++++++++++++++
 srcpkgs/rocr-runtime/template            | 30 ++++++++++++++++++++++++
 4 files changed, 59 insertions(+)
 create mode 120000 srcpkgs/rocr-runtime-devel
 create mode 100644 srcpkgs/rocr-runtime/patches/cmake.patch
 create mode 100644 srcpkgs/rocr-runtime/template

diff --git a/common/shlibs b/common/shlibs
index 0b2cc3bcce7..781bf28cf44 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3861,3 +3861,4 @@ libqtutilities.so.6 qtutilities-6.0.4_1
 libkdsoap.so.1.9.0 KDSoap-1.9.0_1
 libstoken.so.1 stoken-0.92_1
 libhsakmt.so.1 roct-thunk-interface-3.3.0_1
+libhsa-runtime64.so.1 rocr-runtime-3.3.0_1
diff --git a/srcpkgs/rocr-runtime-devel b/srcpkgs/rocr-runtime-devel
new file mode 120000
index 00000000000..be838f22d81
--- /dev/null
+++ b/srcpkgs/rocr-runtime-devel
@@ -0,0 +1 @@
+rocr-runtime
\ No newline at end of file
diff --git a/srcpkgs/rocr-runtime/patches/cmake.patch b/srcpkgs/rocr-runtime/patches/cmake.patch
new file mode 100644
index 00000000000..93b74cd2297
--- /dev/null
+++ b/srcpkgs/rocr-runtime/patches/cmake.patch
@@ -0,0 +1,27 @@
+--- src/CMakeLists.txt.old	2020-04-18 20:01:48.549636995 -0400
++++ src/CMakeLists.txt	2020-04-18 20:04:00.177179781 -0400
+@@ -108,8 +108,8 @@
+ ## ROCr build internal versioning
+ add_definitions ( -DROCR_BUILD_ID=${PACKAGE_VERSION_STRING} )
+ 
+-## Set RUNPATH - ../../lib covers use of the legacy symlink in /hsa/lib/
+-set(CMAKE_INSTALL_RPATH "$ORIGIN;$ORIGIN/../../lib;$ORIGIN/../../lib64;$ORIGIN/../lib64")
++## Set RUNPATH
++set(CMAKE_INSTALL_RPATH "$ORIGIN;$ORIGIN/../lib")
+ 
+ ## ------------------------- Linux Compiler and Linker options -------------------------
+ set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -fexceptions -fno-rtti -fvisibility=hidden -Wno-error=sign-compare -Wno-sign-compare -Wno-write-strings -Wno-conversion-null -fno-math-errno -fno-threadsafe-statics -fmerge-all-constants -fms-extensions -Wno-error=comment -Wno-comment -Wno-error=pointer-arith -Wno-pointer-arith -Wno-error=unused-variable -Wno-error=unused-function" )
+@@ -185,11 +185,8 @@
+ add_custom_target ( hsa_lib_link2 ALL WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMAND ${CMAKE_COMMAND} -E create_symlink ../hsa/lib/${CORE_RUNTIME_LIBRARY}.so.${SO_MAJOR} ${CORE_RUNTIME_LIBRARY}-link.so.${SO_MAJOR} )
+ 
+ ## Set install information
+-install ( TARGETS ${CORE_RUNTIME_TARGET} LIBRARY DESTINATION hsa/lib )
+-install ( DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/inc/ DESTINATION hsa/include/hsa )
+-install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/hsa_include_link DESTINATION include PERMISSIONS OWNER_WRITE OWNER_READ RENAME hsa )
+-install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/${CORE_RUNTIME_LIBRARY}-link.so DESTINATION lib PERMISSIONS OWNER_WRITE OWNER_READ RENAME ${CORE_RUNTIME_LIBRARY}.so )
+-install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/${CORE_RUNTIME_LIBRARY}-link.so.${SO_MAJOR} DESTINATION lib PERMISSIONS OWNER_WRITE OWNER_READ RENAME ${CORE_RUNTIME_LIBRARY}.so.${SO_MAJOR} )
++install ( TARGETS ${CORE_RUNTIME_TARGET} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} )
++install ( DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/inc/ DESTINATION include/hsa )
+ 
+ ## Packaging directives
+ set ( CPACK_GENERATOR "DEB;RPM" CACHE STRING "Package types to build")
diff --git a/srcpkgs/rocr-runtime/template b/srcpkgs/rocr-runtime/template
new file mode 100644
index 00000000000..5ee22140f1f
--- /dev/null
+++ b/srcpkgs/rocr-runtime/template
@@ -0,0 +1,30 @@
+# Template file for 'rocr-runtime'
+pkgname=rocr-runtime
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="ROCR-Runtime-rocm-${version}"
+build_wrksrc="src"
+build_style=cmake
+hostmakedepends="cmake pkg-config"
+makedepends="roct-thunk-interface-devel elfutils-devel"
+short_desc="Radeon Open Compute HSA Runtime"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute/ROCR-Runtime"
+distfiles="${homepage}/archive/rocm-${version}.tar.gz"
+checksum=fa2d2d1f8a61d8a6952d377cf288d78c61776c3c2a666f163cafc3aa19ab0b61
+nocross=yes
+
+post_install() {
+	vlicense ../LICENSE.txt
+}
+
+rocr-runtime-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove "usr/lib/*.so"
+	}
+}

From 6eca0caa1b246736b6ca6bd1c3028bbf933535e1 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Mon, 13 Apr 2020 18:07:34 -0400
Subject: [PATCH 03/10] New package: rocm-llvm-3.3.0

---
 srcpkgs/rocm-llvm/template | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)
 create mode 100644 srcpkgs/rocm-llvm/template

diff --git a/srcpkgs/rocm-llvm/template b/srcpkgs/rocm-llvm/template
new file mode 100644
index 00000000000..d6e75cd050c
--- /dev/null
+++ b/srcpkgs/rocm-llvm/template
@@ -0,0 +1,26 @@
+# Template file for 'rocm-llvm'
+pkgname=rocm-llvm
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="llvm-project-rocm-ocl-${version}"
+build_wrksrc=llvm
+build_style=cmake
+configure_args="-DCMAKE_INSTALL_PREFIX:PATH=/usr/lib/rocm-llvm
+	-DLLVM_ENABLE_PROJECTS='llvm;clang;lld' -DLLVM_TARGETS_TO_BUILD='AMDGPU'
+	-DLLVM_BUILD_DOCS=NO -DLLVM_ENABLE_OCAMLDOC=OFF
+	-DLLVM_ENABLE_SPHINX=NO -DLLVM_ENABLE_DOXYGEN=OFF
+	-DLLVM_INSTALL_UTILS=ON -DLLVM_VERSION_SUFFIX=roc -DOCAMLFIND=NO"
+hostmakedepends="cmake pkg-config python3"
+short_desc="Radeon Open Compute LLVM toolchain"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="Apache-2.0, NCSA, custom:LLVM-Exceptions"
+homepage="https://github.com/RadeonOpenCompute/llvm-project"
+distfiles="${homepage}/archive/rocm-ocl-${version}.tar.gz"
+checksum=a2bef7042e8e2f2cd8548cb246b88322e1c77188839983dcac8312d56f544dc8
+python_version=3
+nocross=yes
+
+post_install() {
+	vlicense LICENSE.TXT
+}

From 9b6c6609edc132206b45353d8f14dfd87d9ae6eb Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Tue, 14 Apr 2020 10:25:31 -0400
Subject: [PATCH 04/10] New package: rocm-device-libs-3.3.0

---
 srcpkgs/rocm-device-libs/template | 37 +++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)
 create mode 100644 srcpkgs/rocm-device-libs/template

diff --git a/srcpkgs/rocm-device-libs/template b/srcpkgs/rocm-device-libs/template
new file mode 100644
index 00000000000..fcb4eb0d53e
--- /dev/null
+++ b/srcpkgs/rocm-device-libs/template
@@ -0,0 +1,37 @@
+# Template file for 'rocm-device-libs'
+pkgname=rocm-device-libs
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="ROCm-Device-Libs-rocm-ocl-${version}"
+build_style=cmake
+configure_args="-DLLVM_DIR:PATH=/usr/lib/rocm-llvm
+	-DCMAKE_INSTALL_LIBDIR:PATH=lib/rocm-device-libs"
+hostmakedepends="cmake rocm-llvm"
+short_desc="Radeon Open Compute device libraries"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute/ROCm-Device-Libs"
+distfiles="${homepage}/archive/rocm-ocl-${version}.tar.gz"
+checksum=706b08230790e08ca6a7a2fb7687d6131fd39a562148340e00fa37a6c06769c5
+nocross=yes
+
+pre_configure() {
+	# Put bytecodes in a lib/ subdirectory
+	vsed -i Packages.cmake -e 's@/lib/@/${CMAKE_INSTALL_LIBDIR}/@'
+	vsed -i OCL.cmake -e 's@DESTINATION lib$@DESTINATION ${CMAKE_INSTALL_LIBDIR}@'
+
+	# Build the prepare-builtins executable with native compiler
+	mkdir -p utils/build
+	cd utils/build
+	_prepare_builtins="$PWD/prepare-builtins/prepare-builtins"
+	cmake ${configure_args} ..
+	make ${makejobs}
+
+	# Add path to prepare-builtins for cmake
+	configure_args+=" -DPREPARE_BUILTINS='${_prepare_builtins}'"
+}
+
+post_install() {
+	vlicense LICENSE
+}

From fa27402432a2fec03e04ec5fd99355f04500c54b Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Mon, 13 Apr 2020 18:30:00 -0400
Subject: [PATCH 05/10] New package: rocm-comgr-3.3.0

---
 common/shlibs               |  1 +
 srcpkgs/rocm-comgr-devel    |  1 +
 srcpkgs/rocm-comgr/template | 32 ++++++++++++++++++++++++++++++++
 3 files changed, 34 insertions(+)
 create mode 120000 srcpkgs/rocm-comgr-devel
 create mode 100644 srcpkgs/rocm-comgr/template

diff --git a/common/shlibs b/common/shlibs
index 781bf28cf44..1c33c573714 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3862,3 +3862,4 @@ libkdsoap.so.1.9.0 KDSoap-1.9.0_1
 libstoken.so.1 stoken-0.92_1
 libhsakmt.so.1 roct-thunk-interface-3.3.0_1
 libhsa-runtime64.so.1 rocr-runtime-3.3.0_1
+libamd_comgr.so.1 rocm-comgr-3.3.0_1
diff --git a/srcpkgs/rocm-comgr-devel b/srcpkgs/rocm-comgr-devel
new file mode 120000
index 00000000000..3f5ce255e07
--- /dev/null
+++ b/srcpkgs/rocm-comgr-devel
@@ -0,0 +1 @@
+rocm-comgr
\ No newline at end of file
diff --git a/srcpkgs/rocm-comgr/template b/srcpkgs/rocm-comgr/template
new file mode 100644
index 00000000000..c228bcd4d1f
--- /dev/null
+++ b/srcpkgs/rocm-comgr/template
@@ -0,0 +1,32 @@
+# Template file for 'rocm-comgr'
+pkgname=rocm-comgr
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="ROCm-CompilerSupport-rocm-${version}"
+build_wrksrc="lib/comgr"
+build_style=cmake
+configure_args="-DClang_DIR:PATH=/usr/lib/rocm-llvm/lib/cmake/clang"
+hostmakedepends="cmake pkg-config rocm-llvm"
+makedepends="rocm-device-libs"
+short_desc="Radeon Open Compute Code Object Manager"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="BSD-3-Clause"
+homepage="https://github.com/RadeonOpenCompute/ROCm-CompilerSupport"
+distfiles="${homepage}/archive/rocm-${version}.tar.gz"
+checksum=01e2524e0f28ecd6f46c9720f279207de935d826b0172158792aa3ec86af9ca7
+nocross=yes
+
+post_install() {
+	vlicense LICENSE.txt
+}
+
+rocm-comgr-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove "usr/lib/*.so"
+		vmove usr/lib/cmake
+	}
+}

From 21faef31b022bdeed174886a02a4a4a687ead020 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Fri, 17 Apr 2020 12:11:25 -0400
Subject: [PATCH 06/10] New package: rocminfo-3.3.0

---
 srcpkgs/rocminfo/template | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
 create mode 100644 srcpkgs/rocminfo/template

diff --git a/srcpkgs/rocminfo/template b/srcpkgs/rocminfo/template
new file mode 100644
index 00000000000..57d0640dd69
--- /dev/null
+++ b/srcpkgs/rocminfo/template
@@ -0,0 +1,22 @@
+# Template file for 'rocminfo'
+pkgname=rocminfo
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="rocminfo-rocm-${version}"
+build_style=cmake
+configure_args="-DROCM_DIR=/usr"
+hostmakedepends="cmake pkg-config"
+makedepends="rocr-runtime-devel"
+short_desc="Radeon Open Compute system information reporter"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute/rocminfo"
+distfiles="${homepage}/archive/rocm-${version}.tar.gz"
+checksum=e666f662c9e465aaabbbd0b109d87e017243cdf1a0898fabf5a90947bb3dbcd7
+nocross=yes
+python_version=3
+
+post_install() {
+	vlicense License.txt
+}

From ecd269a63ea40fe465d17ed74256620a2ae087e3 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Sun, 19 Apr 2020 15:01:40 -0400
Subject: [PATCH 07/10] New package: rocm-bandwidth-test-3.3.0

---
 srcpkgs/rocm-bandwidth-test/template | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
 create mode 100644 srcpkgs/rocm-bandwidth-test/template

diff --git a/srcpkgs/rocm-bandwidth-test/template b/srcpkgs/rocm-bandwidth-test/template
new file mode 100644
index 00000000000..5c5058b693d
--- /dev/null
+++ b/srcpkgs/rocm-bandwidth-test/template
@@ -0,0 +1,20 @@
+# Template file for 'rocm-bandwidth-test'
+pkgname=rocm-bandwidth-test
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="rocm_bandwidth_test-rocm-${version}"
+build_style=cmake
+hostmakedepends="cmake"
+makedepends="rocr-runtime-devel roct-thunk-interface-devel"
+short_desc="Radeon Open Compute bandwidth test"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute/rocm_bandwidth_test"
+distfiles="${homepage}/archive/rocm-${version}.tar.gz"
+checksum=f5f914073018619dc91662d5bf630903dfa4db9136d603591917fdfb3c9164ce
+nocross=yes
+
+post_install() {
+	vlicense LICENSE.txt
+}

From 283ad279e045baea6a9eec32f38a1a3d456a85d7 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Tue, 14 Apr 2020 10:25:54 -0400
Subject: [PATCH 08/10] New package: rocm-opencl-runtime-3.3.0

---
 common/shlibs                                 |   2 +
 srcpkgs/rocm-opencl-runtime-clinfo            |   1 +
 srcpkgs/rocm-opencl-runtime-devel             |   1 +
 .../files/libelf-musl.patch                   |  21 +++
 .../files/runtime-musl.patch                  |  11 ++
 .../rocm-opencl-runtime/patches/cmake.patch   | 126 ++++++++++++++++++
 srcpkgs/rocm-opencl-runtime/template          |  84 ++++++++++++
 7 files changed, 246 insertions(+)
 create mode 120000 srcpkgs/rocm-opencl-runtime-clinfo
 create mode 120000 srcpkgs/rocm-opencl-runtime-devel
 create mode 100644 srcpkgs/rocm-opencl-runtime/files/libelf-musl.patch
 create mode 100644 srcpkgs/rocm-opencl-runtime/files/runtime-musl.patch
 create mode 100644 srcpkgs/rocm-opencl-runtime/patches/cmake.patch
 create mode 100644 srcpkgs/rocm-opencl-runtime/template

diff --git a/common/shlibs b/common/shlibs
index 1c33c573714..6fc139f970b 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3863,3 +3863,5 @@ libstoken.so.1 stoken-0.92_1
 libhsakmt.so.1 roct-thunk-interface-3.3.0_1
 libhsa-runtime64.so.1 rocr-runtime-3.3.0_1
 libamd_comgr.so.1 rocm-comgr-3.3.0_1
+libOpenCL-ROCm.so.1 rocm-opencl-runtime-3.3.0_1
+libamdocl64.so rocm-opencl-runtime-3.3.0_1
diff --git a/srcpkgs/rocm-opencl-runtime-clinfo b/srcpkgs/rocm-opencl-runtime-clinfo
new file mode 120000
index 00000000000..b2cda7e229d
--- /dev/null
+++ b/srcpkgs/rocm-opencl-runtime-clinfo
@@ -0,0 +1 @@
+rocm-opencl-runtime
\ No newline at end of file
diff --git a/srcpkgs/rocm-opencl-runtime-devel b/srcpkgs/rocm-opencl-runtime-devel
new file mode 120000
index 00000000000..b2cda7e229d
--- /dev/null
+++ b/srcpkgs/rocm-opencl-runtime-devel
@@ -0,0 +1 @@
+rocm-opencl-runtime
\ No newline at end of file
diff --git a/srcpkgs/rocm-opencl-runtime/files/libelf-musl.patch b/srcpkgs/rocm-opencl-runtime/files/libelf-musl.patch
new file mode 100644
index 00000000000..29469a9a351
--- /dev/null
+++ b/srcpkgs/rocm-opencl-runtime/files/libelf-musl.patch
@@ -0,0 +1,21 @@
+--- compiler/lib/loaders/elf/utils/libelf/_libelf.h	2020-04-28 15:50:53.243438174 -0400
++++ compiler/lib/loaders/elf/utils/libelf/_libelf.h	2020-04-28 15:51:54.293435415 -0400
+@@ -35,6 +35,7 @@
+ #include "_libelf_config.h"
+ 
+ #include "_elftc.h"
++#include <sys/cdefs.h>
+ 
+ /*
+  * Library-private data structures.
+--- compiler/lib/loaders/elf/utils/libelf/libelf.h	2020-04-28 15:50:53.244438174 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf.h	2020-04-28 15:52:12.375434593 -0400
+@@ -36,6 +36,8 @@
+ #define EM_HSAIL 0xAF5A
+ #endif
+ 
++#include <sys/cdefs.h>
++
+ /* Library private data structures */
+ typedef struct _Elf Elf;
+ typedef struct _Elf_Scn Elf_Scn;
diff --git a/srcpkgs/rocm-opencl-runtime/files/runtime-musl.patch b/srcpkgs/rocm-opencl-runtime/files/runtime-musl.patch
new file mode 100644
index 00000000000..ea18e90e09c
--- /dev/null
+++ b/srcpkgs/rocm-opencl-runtime/files/runtime-musl.patch
@@ -0,0 +1,11 @@
+--- runtime/os/os_posix.cpp.orig	2020-04-19 09:13:51.701982901 -0400
++++ runtime/os/os_posix.cpp	2020-04-19 09:14:04.156947422 -0400
+@@ -44,6 +44,8 @@
+ #include <algorithm>
+ #include <mutex>
+ 
++#include <libgen.h> // for basename
++
+ 
+ namespace amd {
+ 
diff --git a/srcpkgs/rocm-opencl-runtime/patches/cmake.patch b/srcpkgs/rocm-opencl-runtime/patches/cmake.patch
new file mode 100644
index 00000000000..2c96b99d45a
--- /dev/null
+++ b/srcpkgs/rocm-opencl-runtime/patches/cmake.patch
@@ -0,0 +1,126 @@
+--- OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/CMakeLists.txt	2019-09-10 11:53:28.000000000 -0400
++++ OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/CMakeLists.txt	2020-04-16 20:16:13.481180757 -0400
+@@ -73,11 +73,11 @@
+ 
+ set (OPENCL_ICD_LOADER_HEADERS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/inc CACHE PATH "Path to OpenCL Headers")
+ 
+-add_library (OpenCL ${OPENCL_ICD_LOADER_SOURCES})
+-set_target_properties (OpenCL PROPERTIES VERSION "1.2" SOVERSION "1")
++add_library (OpenCL-ROCm ${OPENCL_ICD_LOADER_SOURCES})
++set_target_properties (OpenCL-ROCm PROPERTIES VERSION "1.2" SOVERSION "1")
+ 
+ if (WIN32)
+-    target_link_libraries (OpenCL cfgmgr32.lib)
++    target_link_libraries (OpenCL-ROCm cfgmgr32.lib)
+ 
+     option (OPENCL_ICD_LOADER_REQUIRE_WDK "Build with D3DKMT support, which requires the Windows WDK." ON)
+     if (OPENCL_ICD_LOADER_REQUIRE_WDK)
+@@ -92,10 +92,10 @@
+             get_filename_component(WDK_DIRECTORY ${LATEST_D3DKMT_HEADER} DIRECTORY)
+             get_filename_component(WDK_DIRECTORY ${WDK_DIRECTORY} DIRECTORY)
+             message(STATUS "Found the Windows WDK in: ${WDK_DIRECTORY}")
+-            target_compile_definitions(OpenCL PRIVATE OPENCL_ICD_LOADER_REQUIRE_WDK)
+-            target_include_directories(OpenCL PRIVATE ${WDK_DIRECTORY}/um)
+-            target_include_directories(OpenCL PRIVATE ${WDK_DIRECTORY}/km)
+-            target_include_directories(OpenCL PRIVATE ${WDK_DIRECTORY}/shared)
++	    target_compile_definitions(OpenCL-ROCm PRIVATE OPENCL_ICD_LOADER_REQUIRE_WDK)
++	    target_include_directories(OpenCL-ROCm PRIVATE ${WDK_DIRECTORY}/um)
++	    target_include_directories(OpenCL-ROCm PRIVATE ${WDK_DIRECTORY}/km)
++	    target_include_directories(OpenCL-ROCm PRIVATE ${WDK_DIRECTORY}/shared)
+         else()
+             message(FATAL_ERROR "The Windows WDK was not found. Consider disabling OPENCL_ICD_LOADER_REQUIRE_WDK. Aborting.")
+         endif()
+@@ -113,25 +113,25 @@
+     endif()
+ else()
+     if (APPLE)
+-        target_link_libraries (OpenCL ${CMAKE_THREAD_LIBS_INIT})
++        target_link_libraries (OpenCL-ROCm ${CMAKE_THREAD_LIBS_INIT})
+     else ()
+-        set_target_properties (OpenCL PROPERTIES LINK_FLAGS "-Wl,--version-script -Wl,${CMAKE_CURRENT_SOURCE_DIR}/loader/linux/icd_exports.map")
+-        target_link_libraries (OpenCL ${CMAKE_THREAD_LIBS_INIT})
++        set_target_properties (OpenCL-ROCm PROPERTIES LINK_FLAGS "-Wl,--version-script -Wl,${CMAKE_CURRENT_SOURCE_DIR}/loader/linux/icd_exports.map")
++	target_link_libraries (OpenCL-ROCm ${CMAKE_THREAD_LIBS_INIT})
+     endif ()
+ endif ()
+ 
+ include_directories (${OPENCL_ICD_LOADER_HEADERS_DIR})
+ add_definitions (-DCL_TARGET_OPENCL_VERSION=220)
+ 
+-target_include_directories (OpenCL PRIVATE ${CMAKE_CURRENT_BINARY_DIR} loader)
+-target_link_libraries (OpenCL ${CMAKE_DL_LIBS})
++target_include_directories (OpenCL-ROCm PRIVATE ${CMAKE_CURRENT_BINARY_DIR} loader)
++target_link_libraries (OpenCL-ROCm ${CMAKE_DL_LIBS})
+ 
+ include (CTest)
+ if (BUILD_TESTING)
+     add_subdirectory (test)
+ endif()
+ 
+-install (TARGETS OpenCL
++install (TARGETS OpenCL-ROCm
+     RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+     ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
+     LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
+--- OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/test/loader_test/CMakeLists.txt	2019-09-10 11:53:28.000000000 -0400
++++ OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/test/loader_test/CMakeLists.txt	2020-04-16 20:16:56.647026589 -0400
+@@ -12,4 +12,4 @@
+     test_clgl.c
+     test_image_objects.c )
+ 
+-target_link_libraries (icd_loader_test OpenCL IcdLog)
++target_link_libraries (icd_loader_test OpenCL-ROCm IcdLog)
+--- ROCm-OpenCL-Runtime-roc-3.3.0/CMakeLists.txt	2020-04-28 07:29:51.864446603 -0400
++++ ROCm-OpenCL-Runtime-roc-3.3.0/CMakeLists.txt	2020-04-28 07:32:45.245793180 -0400
+@@ -101,30 +101,30 @@
+ rocm_setup_version( VERSION "2.0.0" )
+ 
+ # MAIN package
+-install(PROGRAMS $<TARGET_FILE:clinfo>
+-        DESTINATION bin/x86_64
++install(PROGRAMS $<TARGET_FILE:rocm-clinfo>
++        DESTINATION bin
+         COMPONENT MAIN)
+ install(PROGRAMS $<TARGET_FILE:amdocl64>
+-        DESTINATION lib/x86_64
++        DESTINATION lib
+         COMPONENT MAIN)
+-install(PROGRAMS $<TARGET_FILE:OpenCL>
+-        DESTINATION lib/x86_64
++install(PROGRAMS $<TARGET_FILE:OpenCL-ROCm>
++        DESTINATION lib
+         COMPONENT MAIN)
+-install(PROGRAMS $<TARGET_SONAME_FILE:OpenCL>
+-        DESTINATION lib/x86_64
++install(PROGRAMS $<TARGET_SONAME_FILE:OpenCL-ROCm>
++        DESTINATION lib
+         COMPONENT MAIN)
+ 
+ # DEV package
+ install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/api/opencl/khronos/headers/opencl2.2/CL"
+-        DESTINATION include
++	DESTINATION include/rocm
+         COMPONENT DEV
+         USE_SOURCE_PERMISSIONS
+         PATTERN cl_d3d10.h EXCLUDE
+         PATTERN cl_d3d11.h EXCLUDE
+         PATTERN cl_dx9_media_sharing.h EXCLUDE
+         PATTERN cl_egl.h EXCLUDE)
+-install(PROGRAMS $<TARGET_LINKER_FILE:OpenCL>
+-        DESTINATION lib/x86_64
++install(PROGRAMS $<TARGET_LINKER_FILE:OpenCL-ROCm>
++        DESTINATION lib
+         COMPONENT DEV)
+ 
+ # Generic CPACK variables
+--- ROCm-OpenCL-Runtime-roc-3.3.0/tools/clinfo/CMakeLists.txt	2020-04-28 07:29:51.882446535 -0400
++++ ROCm-OpenCL-Runtime-roc-3.3.0/tools/clinfo/CMakeLists.txt	2020-04-28 07:30:05.627394732 -0400
+@@ -6,6 +6,6 @@
+ 
+ add_definitions(-DHAVE_CL2_HPP)
+ 
+-add_executable(clinfo clinfo.cpp)
++add_executable(rocm-clinfo clinfo.cpp)
+ 
+-target_link_libraries(clinfo OpenCL)
++target_link_libraries(rocm-clinfo OpenCL-ROCm)
diff --git a/srcpkgs/rocm-opencl-runtime/template b/srcpkgs/rocm-opencl-runtime/template
new file mode 100644
index 00000000000..02aebb91bd8
--- /dev/null
+++ b/srcpkgs/rocm-opencl-runtime/template
@@ -0,0 +1,84 @@
+# Template file for 'rocm-opencl-runtime'
+pkgname=rocm-opencl-runtime
+version=3.3.0
+revision=1
+_ocl_icd_name="OpenCL-ICD-Loader"
+_ocl_icd_ver="6c03f8b58fafd9dd693eaac826749a5cfad515f8"
+archs="x86_64*"
+create_wrksrc=yes
+build_wrksrc="ROCm-OpenCL-Runtime-roc-${version}"
+build_style=cmake
+configure_args="-DUSE_COMGR_LIBRARY=yes"
+hostmakedepends="cmake pkg-config"
+makedepends="libglvnd-devel rocm-comgr-devel
+	roct-thunk-interface-devel rocr-runtime-devel"
+depends="rocm-comgr"
+short_desc="Radeon Open Compute OpenCL runtime"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="MIT"
+homepage="https://github.com/RadeonOpenCompute/ROCm-OpenCL-Runtime"
+_rocroot="https://github.com/RadeonOpenCompute"
+distfiles="${_rocroot}/ROCm-OpenCL-Runtime/archive/roc-${version}.tar.gz
+	${_rocroot}/rocm-cmake/archive/rocm-${version}.tar.gz
+	https://github.com/KhronosGroup/${_ocl_icd_name}/archive/${_ocl_icd_ver}.tar.gz"
+checksum="ac6999f1a491ab066286c2bd6adf50f08f831286f56e267879f9f7eced22f98e
+	76ed3ee8e56cf3246011cf7723c2abda539e1136e7e7f6909bfa45d268b8644f
+	c94d5bb6dc980c4d41d73e2b81663a19aabe494e923e2d0eec72a4c95b318438"
+nocross=yes
+
+if [ "$XBPS_LIBC" = "musl" ]; then
+	makedepends+=" musl-legacy-compat"
+fi
+
+post_patch() {
+	if [ "$XBPS_LIBC" = "musl" ]; then
+		# Remove dependence on glibc
+		patch -Np0 < ${FILESDIR}/libelf-musl.patch
+		patch -Np0 < ${FILESDIR}/runtime-musl.patch
+		vsed -e '/glibc_functions.cpp/d' -i api/opencl/amdocl/CMakeLists.txt
+	fi
+}
+
+pre_configure() {
+	# ROCm requires a very specific Khronos ICD loader version in the tree
+	# Keep the ICD loader config in /etc/OpenCL/rocm-vendors to avoid conflicts
+	_ocl_icd_dir="${_ocl_icd_name}-${_ocl_icd_ver}"
+	ln -sf "${wrksrc}/${_ocl_icd_dir}" api/opencl/khronos/icd
+	vsed -i "${wrksrc}/${_ocl_icd_dir}/loader/icd_platform.h" \
+		-e 's@/etc/OpenCL/vendors/@/etc/OpenCL/rocm-vendors/@g'
+
+	# CMake modules probably not useful anywhere but for this build
+	ln -sf "${wrksrc}/rocm-cmake-rocm-${version}/share/rocm/cmake"/*.cmake cmake
+
+	# Fix the dlopen macro to point to versioned libamd_comgr shared object
+	vsed -i 'runtime/device/comgrctx.cpp' \
+		-e 's/\blibamd_comgr\(32\)\?.so\b/&.1/g'
+}
+
+post_install() {
+	vlicense License
+
+	# Create descriptor to allow the ICD loader to find the driver
+	vmkdir etc/OpenCL/rocm-vendors
+	echo "libamdocl64.so" > "${DESTDIR}/etc/OpenCL/rocm-vendors/amdocl64.icd"
+	vmkdir etc/OpenCL/vendors
+	ln -s ../../OpenCL/rocm-vendors/amdocl64.icd \
+		${DESTDIR}/etc/OpenCL/vendors/rocm-amdocl64.icd
+}
+
+rocm-opencl-runtime-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/lib/libOpenCL-ROCm.so
+		vmove usr/include
+	}
+}
+
+rocm-opencl-runtime-clinfo_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - clinfo"
+	pkg_install() {
+		vmove usr/bin/rocm-clinfo
+	}
+}

From 3834bc1a54075b215d3c744829eab4fce89371c3 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Thu, 30 Apr 2020 13:11:12 -0400
Subject: [PATCH 09/10] New package: rocm-hsa-ext-3.3.0

---
 common/shlibs                 |  2 ++
 srcpkgs/rocm-hsa-ext-devel    |  1 +
 srcpkgs/rocm-hsa-ext/template | 42 +++++++++++++++++++++++++++++++++++
 3 files changed, 45 insertions(+)
 create mode 120000 srcpkgs/rocm-hsa-ext-devel
 create mode 100644 srcpkgs/rocm-hsa-ext/template

diff --git a/common/shlibs b/common/shlibs
index 6fc139f970b..fd32576b66c 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3865,3 +3865,5 @@ libhsa-runtime64.so.1 rocr-runtime-3.3.0_1
 libamd_comgr.so.1 rocm-comgr-3.3.0_1
 libOpenCL-ROCm.so.1 rocm-opencl-runtime-3.3.0_1
 libamdocl64.so rocm-opencl-runtime-3.3.0_1
+libhsa-ext-image64.so.1 rocm-hsa-ext-3.3.0_1
+libhsa-runtime-tools64.so.1 rocm-hsa-ext-3.3.0_1
diff --git a/srcpkgs/rocm-hsa-ext-devel b/srcpkgs/rocm-hsa-ext-devel
new file mode 120000
index 00000000000..d201e9f2fae
--- /dev/null
+++ b/srcpkgs/rocm-hsa-ext-devel
@@ -0,0 +1 @@
+rocm-hsa-ext
\ No newline at end of file
diff --git a/srcpkgs/rocm-hsa-ext/template b/srcpkgs/rocm-hsa-ext/template
new file mode 100644
index 00000000000..a879f03480f
--- /dev/null
+++ b/srcpkgs/rocm-hsa-ext/template
@@ -0,0 +1,42 @@
+# Template file for 'rocm-hsa-ext'
+pkgname=rocm-hsa-ext
+version=3.3.0
+revision=1
+archs="x86_64"
+hostmakedepends="tar"
+short_desc="Radeon Open Compute HSA runtime extensions"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute"
+_hsa_deb="hsa-ext-rocr-dev_1.1.30300.0-rocm-rel-3.3-19-23fc088b_amd64.deb"
+distfiles="https://repo.radeon.com/rocm/apt/debian/pool/main/h/hsa-ext-rocr-dev/$_hsa_deb"
+checksum=6b44e286b395d946b865ec1f3cc546356396785ac1fde591d07af02d0aa7c25d
+repository=nonfree
+
+do_extract() {
+	ar x "${XBPS_SRCDISTDIR}/${pkgname}-${version}/${_hsa_deb}"
+	tar xvf data.tar.gz
+}
+
+do_install() {
+	_rocm_includes="opt/rocm-${version}/hsa/include"
+	
+	vmkdir usr
+	vcopy opt/rocm-${version}/hsa/lib usr
+	vcopy "$_rocm_includes" usr
+
+	# Extract license from one of the header files
+	awk 'BEGIN{HEADER=0} /\/\//{HEADER=1; print $0;} /^[^/]/{if(HEADER==1) exit;}' \
+		< "${_rocm_includes}/hsa/amd_hsa_tools_interfaces.h" \
+		| sed 's@^///*\( \|$\)@@' > LICENSE
+	vlicense LICENSE
+}
+
+rocm-hsa-ext-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove "usr/lib/*.so"
+	}
+}

From 91443875ded665db0cc03bf8a49b991368bd2aeb Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Tue, 28 Apr 2020 13:33:46 -0400
Subject: [PATCH 10/10] hashcat: add build option to link against ROCm [ci
 skip]

---
 srcpkgs/hashcat/files/rocm.patch     | 15 +++++++++++++++
 srcpkgs/hashcat/patches/tmpdir.patch | 21 +++++++++++++++++++++
 srcpkgs/hashcat/template             | 17 ++++++++++++++---
 3 files changed, 50 insertions(+), 3 deletions(-)
 create mode 100644 srcpkgs/hashcat/files/rocm.patch
 create mode 100644 srcpkgs/hashcat/patches/tmpdir.patch

diff --git a/srcpkgs/hashcat/files/rocm.patch b/srcpkgs/hashcat/files/rocm.patch
new file mode 100644
index 00000000000..f1e899d30ee
--- /dev/null
+++ b/srcpkgs/hashcat/files/rocm.patch
@@ -0,0 +1,15 @@
+diff -ur a/src/opencl.c b/src/opencl.c
+--- a/src/opencl.c	2018-12-02 05:58:48.000000000 -0500
++++ b/src/opencl.c	2020-04-28 13:24:12.602415333 -0400
+@@ -492,9 +492,9 @@
+ 
+   if (ocl->lib == NULL) ocl->lib = hc_dlopen ("cygOpenCL-1.dll", RTLD_NOW);
+   #else
+-  ocl->lib = hc_dlopen ("libOpenCL.so", RTLD_NOW);
++  ocl->lib = hc_dlopen ("libOpenCL-ROCm.so.1", RTLD_NOW);
+ 
+-  if (ocl->lib == NULL) ocl->lib = hc_dlopen ("libOpenCL.so.1", RTLD_NOW);
++  if (ocl->lib == NULL) ocl->lib = hc_dlopen ("libOpenCL-ROCm.so", RTLD_NOW);
+   #endif
+ 
+   if (ocl->lib == NULL)
diff --git a/srcpkgs/hashcat/patches/tmpdir.patch b/srcpkgs/hashcat/patches/tmpdir.patch
new file mode 100644
index 00000000000..0558a001c9c
--- /dev/null
+++ b/srcpkgs/hashcat/patches/tmpdir.patch
@@ -0,0 +1,21 @@
+Addresses https://github.com/hashcat/hashcat/issues/2379
+diff -ur a/src/folder.c b/src/folder.c
+--- src/folder.c	2018-12-02 05:58:48.000000000 -0500
++++ src/folder.c	2020-04-28 13:22:27.340522751 -0400
+@@ -457,16 +457,6 @@
+ 
+   hcfree (cpath);
+ 
+-  //if (getenv ("TMP") == NULL)
+-  if (1)
+-  {
+-    char *tmp;
+-
+-    hc_asprintf (&tmp, "TMP=%s", cpath_real);
+-
+-    putenv (tmp);
+-  }
+-
+   #if defined (_WIN)
+ 
+   naive_replace (cpath_real, '\\', '/');
diff --git a/srcpkgs/hashcat/template b/srcpkgs/hashcat/template
index e982f99cebf..7d3a8cb5a6b 100644
--- a/srcpkgs/hashcat/template
+++ b/srcpkgs/hashcat/template
@@ -1,15 +1,16 @@
 # Template file for 'hashcat'
 pkgname=hashcat
 version=5.1.0
-revision=2
+revision=3
 build_style=gnu-makefile
 make_build_args="PREFIX=/usr
  USE_SYSTEM_OPENCL=1 USE_SYSTEM_XXHASH=1
- DEPS_OPENCL_PATH=${XBPS_CROSS_BASE}/usr/include
+ DEPS_OPENCL_PATH=${XBPS_CROSS_BASE}/usr/include$(vopt_if rocm /rocm)
  DEPS_XXHASH_PATH=${XBPS_CROSS_BASE}/usr/include"
 make_use_env=yes
 make_install_args="$make_build_args"
-makedepends="gmp-devel opencl2-headers xxHash-devel"
+makedepends="gmp-devel xxHash-devel
+ $(vopt_if rocm rocm-opencl-runtime-devel opencl2-headers)"
 checkdepends="perl"
 short_desc="Advanced CPU-based password recovery utility"
 maintainer="Duncaen <duncaen@voidlinux.org>"
@@ -19,6 +20,9 @@ changelog="https://raw.githubusercontent.com/hashcat/hashcat/master/docs/changes
 distfiles="https://hashcat.net/files/hashcat-${version}.tar.gz"
 checksum=283beaa68e1eab41de080a58bb92349c8e47a2bb1b93d10f36ea30f418f1e338
 
+build_options="rocm"
+desc_option_rocm="Use ROCm OpenCL runtime"
+
 if [ "$XBPS_TARGET_ENDIAN" = "be" ]; then
 	broken="Not supported on big endian"
 fi
@@ -26,6 +30,13 @@ fi
 post_extract() {
 	sed '/^CC/d' -i src/Makefile
 }
+
+post_patch() {
+	if [ "$build_option_rocm" ]; then
+		patch -Np1 < ${FILESDIR}/rocm.patch
+	fi
+}
+
 post_install() {
 	rm -f ${DESTDIR}/usr/share/docs/hashcat/license.txt
 	vlicense docs/license.txt

^ permalink raw reply	[flat|nested] 61+ messages in thread

* Re: [PR PATCH] [Updated] New packages: ROCm core and OpenCL
  2020-04-19 13:34 [PR PATCH] New packages: ROCm core and OpenCL ahesford
                   ` (22 preceding siblings ...)
  2020-05-01 19:36 ` ahesford
@ 2020-05-02  1:34 ` ahesford
  2020-05-02  3:29 ` ahesford
                   ` (35 subsequent siblings)
  59 siblings, 0 replies; 61+ messages in thread
From: ahesford @ 2020-05-02  1:34 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 3893 bytes --]

There is an updated pull request by ahesford against master on the void-packages repository

https://github.com/ahesford/void-packages rocm
https://github.com/void-linux/void-packages/pull/21153

New packages: ROCm core and OpenCL
This PR includes several packages designed to bring the OpenCL portion of the AMD ROCm ecosystem to Void. It addresses Issue #19507. There are many other packages that AMD provides for GPGPU computing, but these can be added piecemeal as users demand.

The packages are currently only for `x86_64*`. While at least some of the packages will compile on other 64-bit architectures, I have no hardware to test. They are certainly not suitable for 32-bit architectures; some internal data structures rely on `uint64_t` values that are cast to pointers. At a
minimum, a thorough audit would be necessary to ensure that these casts are safe (e.g., that the values stored were only ever upcast from 32-bit pointers). More extensive work may be necessary to support 32-bit architectures, probably without significant benefit.

The packages successfully identify a Radeon RX 580 on an `x86_64` installation using both `clinfo` and `rocminfo` as provided. Furthermore, a version of `pyopencl` linked against these ROCm packages successfully runs a simple program that validates arithmetic on GPU-bound arrays.

There are caveats with this set of packages, almost all of which revolve around the incompatibilities between the Void-provided `ocl-icd` and the [Khronos OpenCL ICD loader](https://github.com/KhronosGroup/OpenCL-ID-Loader) required by (and built into) `rocm-opencl-runtime`.
1. All packages install into `/opt/rocm`. This keeps the environment closer to that officially sanctioned by AMD and helps avoid conflicts between other packages and those provided here. (For example, `clinfo` and the ICD loader itself.) Eventually, we may be able to move the files into `/usr`.
2. The Khronos OpenCL ICD loader built into `rocm-opencl-runtime` is an outdated, pre-release commit. If AMD can update its sources to use the release version of that loader (which has a backward-incompatible API change), we may be able to make ROCm compatible with `ocl-icd` or replace `ocl-icd` with the official Khronos loader.
3. In the meantime, to avoid `shlibs` conflicts, the OpenCL ICD loader is installed as `/opt/rocm/lib/libOpenCL-ROCm.so` (and an appropriately versioned shared library), which means that programs wishing to use the ROCm OpenCL must explicitly link against this library instead of the generic `libOpenCL.so`.
4. I do **not** recommend making any Void packages link against this specific library, because it will make those packages ROCm-only. For the time being, ROCm is intended for end-users to specifically link against. Linking Void packages against ROCm would requires the ICD loader used by ROCm be compatible with `ocl-icd`, or `ocl-icd` be replaced by the Khronos loader. However, because the Khronos loader changed its API for the release version, such a change is not yet appropriate.

Hopefully, if AMD updates its dependence on the Khronos ICD loader, we can resolve some of these caveats in the future and make ROCm a more natural Void component. For now, these packages are useful for those who need an AMD OpenCL solution and would rather custom-link software against the AMD ICD loader than hack the `amdgpu-pro` driver into an ICD compatible with `ocl-icd`.

Some patches were made to relocate some files in `/opt/rocm` and make everyting build on x86_64-musl`. Where appropriate, these patches will be pushed upstream to clean up the distribution and packaging.

Update: I pushed some new commits to update license information that triggerd an `xlint` failure. I've also disabled CI builds because they will time out on `rocm-llvm`.

A patch file from https://github.com/void-linux/void-packages/pull/21153.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-rocm-21153.patch --]
[-- Type: text/x-diff, Size: 38679 bytes --]

From fb4cb149ad13b184ab0316f6e5c69281659d7bf6 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Mon, 13 Apr 2020 13:08:09 -0400
Subject: [PATCH 01/10] New package: roct-thunk-interface-3.3.0

---
 common/shlibs                                 |  1 +
 srcpkgs/roct-thunk-interface-devel            |  1 +
 .../patches/cmake-dev-libdir.patch            | 10 ++++++
 .../roct-thunk-interface/patches/musl.patch   | 29 ++++++++++++++++
 srcpkgs/roct-thunk-interface/template         | 33 +++++++++++++++++++
 srcpkgs/roct-thunk-interface/update           |  1 +
 6 files changed, 75 insertions(+)
 create mode 120000 srcpkgs/roct-thunk-interface-devel
 create mode 100644 srcpkgs/roct-thunk-interface/patches/cmake-dev-libdir.patch
 create mode 100644 srcpkgs/roct-thunk-interface/patches/musl.patch
 create mode 100644 srcpkgs/roct-thunk-interface/template
 create mode 100644 srcpkgs/roct-thunk-interface/update

diff --git a/common/shlibs b/common/shlibs
index 9fb74043e9f..756bf934477 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3862,3 +3862,4 @@ libkdsoap.so.1.9.0 KDSoap-1.9.0_1
 libstoken.so.1 stoken-0.92_1
 libjpegxr.so.0 jxrlib-0.2.2_1
 libjxrglue.so.0 jxrlib-0.2.2_1
+libhsakmt.so.1 roct-thunk-interface-3.3.0_1
diff --git a/srcpkgs/roct-thunk-interface-devel b/srcpkgs/roct-thunk-interface-devel
new file mode 120000
index 00000000000..ac3f2cc684c
--- /dev/null
+++ b/srcpkgs/roct-thunk-interface-devel
@@ -0,0 +1 @@
+roct-thunk-interface
\ No newline at end of file
diff --git a/srcpkgs/roct-thunk-interface/patches/cmake-dev-libdir.patch b/srcpkgs/roct-thunk-interface/patches/cmake-dev-libdir.patch
new file mode 100644
index 00000000000..98c7f1e459c
--- /dev/null
+++ b/srcpkgs/roct-thunk-interface/patches/cmake-dev-libdir.patch
@@ -0,0 +1,10 @@
+--- CMakeLists.txt.old	2020-04-18 19:45:17.306081135 -0400
++++ CMakeLists.txt	2020-04-18 19:46:51.300753636 -0400
+@@ -146,6 +146,7 @@
+     COMMAND ${CMAKE_COMMAND}
+         -DSOURCE_DIR="${SOURCE_DIR}"
+         -DCMAKE_INSTALL_PREFIX="${CMAKE_INSTALL_PREFIX}"
++        -DCMAKE_INSTALL_LIBDIR="${CMAKE_INSTALL_LIBDIR}"
+         -DCPACK_RPM_PACKAGE_REQUIRES="hsakmt-roct"
+         -DCPACK_PACKAGING_INSTALL_PREFIX="${CPACK_PACKAGING_INSTALL_PREFIX}"
+         -DVERSION="${BUILD_VERSION_STRING}"
diff --git a/srcpkgs/roct-thunk-interface/patches/musl.patch b/srcpkgs/roct-thunk-interface/patches/musl.patch
new file mode 100644
index 00000000000..aeea9832411
--- /dev/null
+++ b/srcpkgs/roct-thunk-interface/patches/musl.patch
@@ -0,0 +1,29 @@
+diff -r -u old/src/libhsakmt.h new/src/libhsakmt.h
+--- src/libhsakmt.h	2020-03-04 15:00:47.000000000 -0500
++++ src/libhsakmt.h	2020-04-13 12:58:30.444865992 -0400
+@@ -54,6 +54,10 @@
+ #define CHECK_KFD_OPEN() \
+ 	do { if (kfd_open_count == 0 || hsakmt_forked) return HSAKMT_STATUS_KERNEL_IO_CHANNEL_NOT_OPENED; } while (0)
+ 
++/*On some platforms, a PAGE_SIZE macro eclipses the extern variable*/
++#ifdef PAGE_SIZE
++#undef PAGE_SIZE
++#endif
+ extern int PAGE_SIZE;
+ extern int PAGE_SHIFT;
+ 
+diff -r -u old/src/topology.c new/src/topology.c
+--- src/topology.c	2020-03-04 15:00:47.000000000 -0500
++++ src/topology.c	2020-04-13 13:01:31.209870701 -0400
+@@ -38,6 +38,11 @@
+ #include "libhsakmt.h"
+ #include "fmm.h"
+ 
++/*Needed on MUSL*/
++#ifndef MAXNAMLEN
++#define MAXNAMLEN PATH_MAX
++#endif
++
+ /* Number of memory banks added by thunk on top of topology
+  * This only includes static heaps like LDS, scratch and SVM,
+  * not for MMIO_REMAP heap. MMIO_REMAP memory bank is reported
diff --git a/srcpkgs/roct-thunk-interface/template b/srcpkgs/roct-thunk-interface/template
new file mode 100644
index 00000000000..55a1fc6074a
--- /dev/null
+++ b/srcpkgs/roct-thunk-interface/template
@@ -0,0 +1,33 @@
+# Template file for 'roct-thunk-interface'
+pkgname=roct-thunk-interface
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="ROCT-Thunk-Interface-roc-${version}"
+build_style=cmake
+make_build_target="all build-dev"
+make_install_target="install install-dev"
+hostmakedepends="cmake pkg-config"
+makedepends="pciutils-devel libnuma-devel"
+short_desc="Radeon Open Compute Thunk Interface"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="MIT"
+homepage="https://github.com/RadeonOpenCompute/ROCT-Thunk-Interface"
+distfiles="${homepage}/archive/roc-${version}.tar.gz"
+checksum=2cabe9d2cfa72031c05d11290837c476182e72d8dec2049298f691143fdd212b
+nocross=yes
+
+post_install() {
+	vlicense LICENSE.md
+}
+
+roct-thunk-interface-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove "usr/lib/*.so"
+		vmove usr/share/pkgconfig
+		vmove usr/lib/cmake
+	}
+}
diff --git a/srcpkgs/roct-thunk-interface/update b/srcpkgs/roct-thunk-interface/update
new file mode 100644
index 00000000000..8385f4d1215
--- /dev/null
+++ b/srcpkgs/roct-thunk-interface/update
@@ -0,0 +1 @@
+pattern='roc-\K[\d.]+'

From 2e92c3ce3705f9222dc927871ebb8aee6d1a19e8 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Mon, 13 Apr 2020 15:27:27 -0400
Subject: [PATCH 02/10] New package: rocr-runtime-3.3.0

---
 common/shlibs                            |  1 +
 srcpkgs/rocr-runtime-devel               |  1 +
 srcpkgs/rocr-runtime/patches/cmake.patch | 27 +++++++++++++++++++++
 srcpkgs/rocr-runtime/template            | 30 ++++++++++++++++++++++++
 srcpkgs/rocr-runtime/update              |  1 +
 5 files changed, 60 insertions(+)
 create mode 120000 srcpkgs/rocr-runtime-devel
 create mode 100644 srcpkgs/rocr-runtime/patches/cmake.patch
 create mode 100644 srcpkgs/rocr-runtime/template
 create mode 100644 srcpkgs/rocr-runtime/update

diff --git a/common/shlibs b/common/shlibs
index 756bf934477..2c1a1a7885f 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3863,3 +3863,4 @@ libstoken.so.1 stoken-0.92_1
 libjpegxr.so.0 jxrlib-0.2.2_1
 libjxrglue.so.0 jxrlib-0.2.2_1
 libhsakmt.so.1 roct-thunk-interface-3.3.0_1
+libhsa-runtime64.so.1 rocr-runtime-3.3.0_1
diff --git a/srcpkgs/rocr-runtime-devel b/srcpkgs/rocr-runtime-devel
new file mode 120000
index 00000000000..be838f22d81
--- /dev/null
+++ b/srcpkgs/rocr-runtime-devel
@@ -0,0 +1 @@
+rocr-runtime
\ No newline at end of file
diff --git a/srcpkgs/rocr-runtime/patches/cmake.patch b/srcpkgs/rocr-runtime/patches/cmake.patch
new file mode 100644
index 00000000000..93b74cd2297
--- /dev/null
+++ b/srcpkgs/rocr-runtime/patches/cmake.patch
@@ -0,0 +1,27 @@
+--- src/CMakeLists.txt.old	2020-04-18 20:01:48.549636995 -0400
++++ src/CMakeLists.txt	2020-04-18 20:04:00.177179781 -0400
+@@ -108,8 +108,8 @@
+ ## ROCr build internal versioning
+ add_definitions ( -DROCR_BUILD_ID=${PACKAGE_VERSION_STRING} )
+ 
+-## Set RUNPATH - ../../lib covers use of the legacy symlink in /hsa/lib/
+-set(CMAKE_INSTALL_RPATH "$ORIGIN;$ORIGIN/../../lib;$ORIGIN/../../lib64;$ORIGIN/../lib64")
++## Set RUNPATH
++set(CMAKE_INSTALL_RPATH "$ORIGIN;$ORIGIN/../lib")
+ 
+ ## ------------------------- Linux Compiler and Linker options -------------------------
+ set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -fexceptions -fno-rtti -fvisibility=hidden -Wno-error=sign-compare -Wno-sign-compare -Wno-write-strings -Wno-conversion-null -fno-math-errno -fno-threadsafe-statics -fmerge-all-constants -fms-extensions -Wno-error=comment -Wno-comment -Wno-error=pointer-arith -Wno-pointer-arith -Wno-error=unused-variable -Wno-error=unused-function" )
+@@ -185,11 +185,8 @@
+ add_custom_target ( hsa_lib_link2 ALL WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMAND ${CMAKE_COMMAND} -E create_symlink ../hsa/lib/${CORE_RUNTIME_LIBRARY}.so.${SO_MAJOR} ${CORE_RUNTIME_LIBRARY}-link.so.${SO_MAJOR} )
+ 
+ ## Set install information
+-install ( TARGETS ${CORE_RUNTIME_TARGET} LIBRARY DESTINATION hsa/lib )
+-install ( DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/inc/ DESTINATION hsa/include/hsa )
+-install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/hsa_include_link DESTINATION include PERMISSIONS OWNER_WRITE OWNER_READ RENAME hsa )
+-install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/${CORE_RUNTIME_LIBRARY}-link.so DESTINATION lib PERMISSIONS OWNER_WRITE OWNER_READ RENAME ${CORE_RUNTIME_LIBRARY}.so )
+-install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/${CORE_RUNTIME_LIBRARY}-link.so.${SO_MAJOR} DESTINATION lib PERMISSIONS OWNER_WRITE OWNER_READ RENAME ${CORE_RUNTIME_LIBRARY}.so.${SO_MAJOR} )
++install ( TARGETS ${CORE_RUNTIME_TARGET} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} )
++install ( DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/inc/ DESTINATION include/hsa )
+ 
+ ## Packaging directives
+ set ( CPACK_GENERATOR "DEB;RPM" CACHE STRING "Package types to build")
diff --git a/srcpkgs/rocr-runtime/template b/srcpkgs/rocr-runtime/template
new file mode 100644
index 00000000000..5ee22140f1f
--- /dev/null
+++ b/srcpkgs/rocr-runtime/template
@@ -0,0 +1,30 @@
+# Template file for 'rocr-runtime'
+pkgname=rocr-runtime
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="ROCR-Runtime-rocm-${version}"
+build_wrksrc="src"
+build_style=cmake
+hostmakedepends="cmake pkg-config"
+makedepends="roct-thunk-interface-devel elfutils-devel"
+short_desc="Radeon Open Compute HSA Runtime"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute/ROCR-Runtime"
+distfiles="${homepage}/archive/rocm-${version}.tar.gz"
+checksum=fa2d2d1f8a61d8a6952d377cf288d78c61776c3c2a666f163cafc3aa19ab0b61
+nocross=yes
+
+post_install() {
+	vlicense ../LICENSE.txt
+}
+
+rocr-runtime-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove "usr/lib/*.so"
+	}
+}
diff --git a/srcpkgs/rocr-runtime/update b/srcpkgs/rocr-runtime/update
new file mode 100644
index 00000000000..86197bc3eea
--- /dev/null
+++ b/srcpkgs/rocr-runtime/update
@@ -0,0 +1 @@
+pattern='rocm-\K[\d.]+'

From 6e48643479e605098721335929e23d93f21c05c8 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Mon, 13 Apr 2020 18:07:34 -0400
Subject: [PATCH 03/10] New package: rocm-llvm-3.3.0

---
 srcpkgs/rocm-llvm/template | 26 ++++++++++++++++++++++++++
 srcpkgs/rocm-llvm/update   |  1 +
 2 files changed, 27 insertions(+)
 create mode 100644 srcpkgs/rocm-llvm/template
 create mode 100644 srcpkgs/rocm-llvm/update

diff --git a/srcpkgs/rocm-llvm/template b/srcpkgs/rocm-llvm/template
new file mode 100644
index 00000000000..d6e75cd050c
--- /dev/null
+++ b/srcpkgs/rocm-llvm/template
@@ -0,0 +1,26 @@
+# Template file for 'rocm-llvm'
+pkgname=rocm-llvm
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="llvm-project-rocm-ocl-${version}"
+build_wrksrc=llvm
+build_style=cmake
+configure_args="-DCMAKE_INSTALL_PREFIX:PATH=/usr/lib/rocm-llvm
+	-DLLVM_ENABLE_PROJECTS='llvm;clang;lld' -DLLVM_TARGETS_TO_BUILD='AMDGPU'
+	-DLLVM_BUILD_DOCS=NO -DLLVM_ENABLE_OCAMLDOC=OFF
+	-DLLVM_ENABLE_SPHINX=NO -DLLVM_ENABLE_DOXYGEN=OFF
+	-DLLVM_INSTALL_UTILS=ON -DLLVM_VERSION_SUFFIX=roc -DOCAMLFIND=NO"
+hostmakedepends="cmake pkg-config python3"
+short_desc="Radeon Open Compute LLVM toolchain"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="Apache-2.0, NCSA, custom:LLVM-Exceptions"
+homepage="https://github.com/RadeonOpenCompute/llvm-project"
+distfiles="${homepage}/archive/rocm-ocl-${version}.tar.gz"
+checksum=a2bef7042e8e2f2cd8548cb246b88322e1c77188839983dcac8312d56f544dc8
+python_version=3
+nocross=yes
+
+post_install() {
+	vlicense LICENSE.TXT
+}
diff --git a/srcpkgs/rocm-llvm/update b/srcpkgs/rocm-llvm/update
new file mode 100644
index 00000000000..6a73667d3c1
--- /dev/null
+++ b/srcpkgs/rocm-llvm/update
@@ -0,0 +1 @@
+pattern='rocm-ocl-\K[\d.]+'

From 7836e91d10640304793696ed010dc8cbb187f2ec Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Tue, 14 Apr 2020 10:25:31 -0400
Subject: [PATCH 04/10] New package: rocm-device-libs-3.3.0

---
 srcpkgs/rocm-device-libs/template | 37 +++++++++++++++++++++++++++++++
 srcpkgs/rocm-device-libs/update   |  1 +
 2 files changed, 38 insertions(+)
 create mode 100644 srcpkgs/rocm-device-libs/template
 create mode 100644 srcpkgs/rocm-device-libs/update

diff --git a/srcpkgs/rocm-device-libs/template b/srcpkgs/rocm-device-libs/template
new file mode 100644
index 00000000000..fcb4eb0d53e
--- /dev/null
+++ b/srcpkgs/rocm-device-libs/template
@@ -0,0 +1,37 @@
+# Template file for 'rocm-device-libs'
+pkgname=rocm-device-libs
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="ROCm-Device-Libs-rocm-ocl-${version}"
+build_style=cmake
+configure_args="-DLLVM_DIR:PATH=/usr/lib/rocm-llvm
+	-DCMAKE_INSTALL_LIBDIR:PATH=lib/rocm-device-libs"
+hostmakedepends="cmake rocm-llvm"
+short_desc="Radeon Open Compute device libraries"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute/ROCm-Device-Libs"
+distfiles="${homepage}/archive/rocm-ocl-${version}.tar.gz"
+checksum=706b08230790e08ca6a7a2fb7687d6131fd39a562148340e00fa37a6c06769c5
+nocross=yes
+
+pre_configure() {
+	# Put bytecodes in a lib/ subdirectory
+	vsed -i Packages.cmake -e 's@/lib/@/${CMAKE_INSTALL_LIBDIR}/@'
+	vsed -i OCL.cmake -e 's@DESTINATION lib$@DESTINATION ${CMAKE_INSTALL_LIBDIR}@'
+
+	# Build the prepare-builtins executable with native compiler
+	mkdir -p utils/build
+	cd utils/build
+	_prepare_builtins="$PWD/prepare-builtins/prepare-builtins"
+	cmake ${configure_args} ..
+	make ${makejobs}
+
+	# Add path to prepare-builtins for cmake
+	configure_args+=" -DPREPARE_BUILTINS='${_prepare_builtins}'"
+}
+
+post_install() {
+	vlicense LICENSE
+}
diff --git a/srcpkgs/rocm-device-libs/update b/srcpkgs/rocm-device-libs/update
new file mode 100644
index 00000000000..6a73667d3c1
--- /dev/null
+++ b/srcpkgs/rocm-device-libs/update
@@ -0,0 +1 @@
+pattern='rocm-ocl-\K[\d.]+'

From 903ec6a390fde653b10633c1045a54557dcd1fd7 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Mon, 13 Apr 2020 18:30:00 -0400
Subject: [PATCH 05/10] New package: rocm-comgr-3.3.0

---
 common/shlibs               |  1 +
 srcpkgs/rocm-comgr-devel    |  1 +
 srcpkgs/rocm-comgr/template | 32 ++++++++++++++++++++++++++++++++
 srcpkgs/rocm-comgr/update   |  1 +
 4 files changed, 35 insertions(+)
 create mode 120000 srcpkgs/rocm-comgr-devel
 create mode 100644 srcpkgs/rocm-comgr/template
 create mode 100644 srcpkgs/rocm-comgr/update

diff --git a/common/shlibs b/common/shlibs
index 2c1a1a7885f..ac06600be49 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3864,3 +3864,4 @@ libjpegxr.so.0 jxrlib-0.2.2_1
 libjxrglue.so.0 jxrlib-0.2.2_1
 libhsakmt.so.1 roct-thunk-interface-3.3.0_1
 libhsa-runtime64.so.1 rocr-runtime-3.3.0_1
+libamd_comgr.so.1 rocm-comgr-3.3.0_1
diff --git a/srcpkgs/rocm-comgr-devel b/srcpkgs/rocm-comgr-devel
new file mode 120000
index 00000000000..3f5ce255e07
--- /dev/null
+++ b/srcpkgs/rocm-comgr-devel
@@ -0,0 +1 @@
+rocm-comgr
\ No newline at end of file
diff --git a/srcpkgs/rocm-comgr/template b/srcpkgs/rocm-comgr/template
new file mode 100644
index 00000000000..c228bcd4d1f
--- /dev/null
+++ b/srcpkgs/rocm-comgr/template
@@ -0,0 +1,32 @@
+# Template file for 'rocm-comgr'
+pkgname=rocm-comgr
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="ROCm-CompilerSupport-rocm-${version}"
+build_wrksrc="lib/comgr"
+build_style=cmake
+configure_args="-DClang_DIR:PATH=/usr/lib/rocm-llvm/lib/cmake/clang"
+hostmakedepends="cmake pkg-config rocm-llvm"
+makedepends="rocm-device-libs"
+short_desc="Radeon Open Compute Code Object Manager"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="BSD-3-Clause"
+homepage="https://github.com/RadeonOpenCompute/ROCm-CompilerSupport"
+distfiles="${homepage}/archive/rocm-${version}.tar.gz"
+checksum=01e2524e0f28ecd6f46c9720f279207de935d826b0172158792aa3ec86af9ca7
+nocross=yes
+
+post_install() {
+	vlicense LICENSE.txt
+}
+
+rocm-comgr-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove "usr/lib/*.so"
+		vmove usr/lib/cmake
+	}
+}
diff --git a/srcpkgs/rocm-comgr/update b/srcpkgs/rocm-comgr/update
new file mode 100644
index 00000000000..86197bc3eea
--- /dev/null
+++ b/srcpkgs/rocm-comgr/update
@@ -0,0 +1 @@
+pattern='rocm-\K[\d.]+'

From a37b4d2851ca17194b50f13410d84ae721ba3444 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Fri, 17 Apr 2020 12:11:25 -0400
Subject: [PATCH 06/10] New package: rocminfo-3.3.0

---
 srcpkgs/rocminfo/template | 22 ++++++++++++++++++++++
 srcpkgs/rocminfo/update   |  1 +
 2 files changed, 23 insertions(+)
 create mode 100644 srcpkgs/rocminfo/template
 create mode 100644 srcpkgs/rocminfo/update

diff --git a/srcpkgs/rocminfo/template b/srcpkgs/rocminfo/template
new file mode 100644
index 00000000000..57d0640dd69
--- /dev/null
+++ b/srcpkgs/rocminfo/template
@@ -0,0 +1,22 @@
+# Template file for 'rocminfo'
+pkgname=rocminfo
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="rocminfo-rocm-${version}"
+build_style=cmake
+configure_args="-DROCM_DIR=/usr"
+hostmakedepends="cmake pkg-config"
+makedepends="rocr-runtime-devel"
+short_desc="Radeon Open Compute system information reporter"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute/rocminfo"
+distfiles="${homepage}/archive/rocm-${version}.tar.gz"
+checksum=e666f662c9e465aaabbbd0b109d87e017243cdf1a0898fabf5a90947bb3dbcd7
+nocross=yes
+python_version=3
+
+post_install() {
+	vlicense License.txt
+}
diff --git a/srcpkgs/rocminfo/update b/srcpkgs/rocminfo/update
new file mode 100644
index 00000000000..86197bc3eea
--- /dev/null
+++ b/srcpkgs/rocminfo/update
@@ -0,0 +1 @@
+pattern='rocm-\K[\d.]+'

From 73237ebeef312876936320b14faec6a10c56ae19 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Sun, 19 Apr 2020 15:01:40 -0400
Subject: [PATCH 07/10] New package: rocm-bandwidth-test-3.3.0

---
 srcpkgs/rocm-bandwidth-test/template | 20 ++++++++++++++++++++
 srcpkgs/rocm-bandwidth-test/update   |  1 +
 2 files changed, 21 insertions(+)
 create mode 100644 srcpkgs/rocm-bandwidth-test/template
 create mode 100644 srcpkgs/rocm-bandwidth-test/update

diff --git a/srcpkgs/rocm-bandwidth-test/template b/srcpkgs/rocm-bandwidth-test/template
new file mode 100644
index 00000000000..5c5058b693d
--- /dev/null
+++ b/srcpkgs/rocm-bandwidth-test/template
@@ -0,0 +1,20 @@
+# Template file for 'rocm-bandwidth-test'
+pkgname=rocm-bandwidth-test
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="rocm_bandwidth_test-rocm-${version}"
+build_style=cmake
+hostmakedepends="cmake"
+makedepends="rocr-runtime-devel roct-thunk-interface-devel"
+short_desc="Radeon Open Compute bandwidth test"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute/rocm_bandwidth_test"
+distfiles="${homepage}/archive/rocm-${version}.tar.gz"
+checksum=f5f914073018619dc91662d5bf630903dfa4db9136d603591917fdfb3c9164ce
+nocross=yes
+
+post_install() {
+	vlicense LICENSE.txt
+}
diff --git a/srcpkgs/rocm-bandwidth-test/update b/srcpkgs/rocm-bandwidth-test/update
new file mode 100644
index 00000000000..86197bc3eea
--- /dev/null
+++ b/srcpkgs/rocm-bandwidth-test/update
@@ -0,0 +1 @@
+pattern='rocm-\K[\d.]+'

From e9e40519bdae4af1923294484174faf9e8cd4714 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Tue, 14 Apr 2020 10:25:54 -0400
Subject: [PATCH 08/10] New package: rocm-opencl-runtime-3.3.0

---
 common/shlibs                                 |   2 +
 srcpkgs/rocm-opencl-runtime-clinfo            |   1 +
 srcpkgs/rocm-opencl-runtime-devel             |   1 +
 .../files/libelf-musl.patch                   |  21 +++
 .../files/runtime-musl.patch                  |  11 ++
 .../rocm-opencl-runtime/patches/cmake.patch   | 126 ++++++++++++++++++
 srcpkgs/rocm-opencl-runtime/template          |  84 ++++++++++++
 srcpkgs/rocm-opencl-runtime/update            |   1 +
 8 files changed, 247 insertions(+)
 create mode 120000 srcpkgs/rocm-opencl-runtime-clinfo
 create mode 120000 srcpkgs/rocm-opencl-runtime-devel
 create mode 100644 srcpkgs/rocm-opencl-runtime/files/libelf-musl.patch
 create mode 100644 srcpkgs/rocm-opencl-runtime/files/runtime-musl.patch
 create mode 100644 srcpkgs/rocm-opencl-runtime/patches/cmake.patch
 create mode 100644 srcpkgs/rocm-opencl-runtime/template
 create mode 100644 srcpkgs/rocm-opencl-runtime/update

diff --git a/common/shlibs b/common/shlibs
index ac06600be49..8eee9b0bad8 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3865,3 +3865,5 @@ libjxrglue.so.0 jxrlib-0.2.2_1
 libhsakmt.so.1 roct-thunk-interface-3.3.0_1
 libhsa-runtime64.so.1 rocr-runtime-3.3.0_1
 libamd_comgr.so.1 rocm-comgr-3.3.0_1
+libOpenCL-ROCm.so.1 rocm-opencl-runtime-3.3.0_1
+libamdocl64.so rocm-opencl-runtime-3.3.0_1
diff --git a/srcpkgs/rocm-opencl-runtime-clinfo b/srcpkgs/rocm-opencl-runtime-clinfo
new file mode 120000
index 00000000000..b2cda7e229d
--- /dev/null
+++ b/srcpkgs/rocm-opencl-runtime-clinfo
@@ -0,0 +1 @@
+rocm-opencl-runtime
\ No newline at end of file
diff --git a/srcpkgs/rocm-opencl-runtime-devel b/srcpkgs/rocm-opencl-runtime-devel
new file mode 120000
index 00000000000..b2cda7e229d
--- /dev/null
+++ b/srcpkgs/rocm-opencl-runtime-devel
@@ -0,0 +1 @@
+rocm-opencl-runtime
\ No newline at end of file
diff --git a/srcpkgs/rocm-opencl-runtime/files/libelf-musl.patch b/srcpkgs/rocm-opencl-runtime/files/libelf-musl.patch
new file mode 100644
index 00000000000..29469a9a351
--- /dev/null
+++ b/srcpkgs/rocm-opencl-runtime/files/libelf-musl.patch
@@ -0,0 +1,21 @@
+--- compiler/lib/loaders/elf/utils/libelf/_libelf.h	2020-04-28 15:50:53.243438174 -0400
++++ compiler/lib/loaders/elf/utils/libelf/_libelf.h	2020-04-28 15:51:54.293435415 -0400
+@@ -35,6 +35,7 @@
+ #include "_libelf_config.h"
+ 
+ #include "_elftc.h"
++#include <sys/cdefs.h>
+ 
+ /*
+  * Library-private data structures.
+--- compiler/lib/loaders/elf/utils/libelf/libelf.h	2020-04-28 15:50:53.244438174 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf.h	2020-04-28 15:52:12.375434593 -0400
+@@ -36,6 +36,8 @@
+ #define EM_HSAIL 0xAF5A
+ #endif
+ 
++#include <sys/cdefs.h>
++
+ /* Library private data structures */
+ typedef struct _Elf Elf;
+ typedef struct _Elf_Scn Elf_Scn;
diff --git a/srcpkgs/rocm-opencl-runtime/files/runtime-musl.patch b/srcpkgs/rocm-opencl-runtime/files/runtime-musl.patch
new file mode 100644
index 00000000000..ea18e90e09c
--- /dev/null
+++ b/srcpkgs/rocm-opencl-runtime/files/runtime-musl.patch
@@ -0,0 +1,11 @@
+--- runtime/os/os_posix.cpp.orig	2020-04-19 09:13:51.701982901 -0400
++++ runtime/os/os_posix.cpp	2020-04-19 09:14:04.156947422 -0400
+@@ -44,6 +44,8 @@
+ #include <algorithm>
+ #include <mutex>
+ 
++#include <libgen.h> // for basename
++
+ 
+ namespace amd {
+ 
diff --git a/srcpkgs/rocm-opencl-runtime/patches/cmake.patch b/srcpkgs/rocm-opencl-runtime/patches/cmake.patch
new file mode 100644
index 00000000000..2c96b99d45a
--- /dev/null
+++ b/srcpkgs/rocm-opencl-runtime/patches/cmake.patch
@@ -0,0 +1,126 @@
+--- OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/CMakeLists.txt	2019-09-10 11:53:28.000000000 -0400
++++ OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/CMakeLists.txt	2020-04-16 20:16:13.481180757 -0400
+@@ -73,11 +73,11 @@
+ 
+ set (OPENCL_ICD_LOADER_HEADERS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/inc CACHE PATH "Path to OpenCL Headers")
+ 
+-add_library (OpenCL ${OPENCL_ICD_LOADER_SOURCES})
+-set_target_properties (OpenCL PROPERTIES VERSION "1.2" SOVERSION "1")
++add_library (OpenCL-ROCm ${OPENCL_ICD_LOADER_SOURCES})
++set_target_properties (OpenCL-ROCm PROPERTIES VERSION "1.2" SOVERSION "1")
+ 
+ if (WIN32)
+-    target_link_libraries (OpenCL cfgmgr32.lib)
++    target_link_libraries (OpenCL-ROCm cfgmgr32.lib)
+ 
+     option (OPENCL_ICD_LOADER_REQUIRE_WDK "Build with D3DKMT support, which requires the Windows WDK." ON)
+     if (OPENCL_ICD_LOADER_REQUIRE_WDK)
+@@ -92,10 +92,10 @@
+             get_filename_component(WDK_DIRECTORY ${LATEST_D3DKMT_HEADER} DIRECTORY)
+             get_filename_component(WDK_DIRECTORY ${WDK_DIRECTORY} DIRECTORY)
+             message(STATUS "Found the Windows WDK in: ${WDK_DIRECTORY}")
+-            target_compile_definitions(OpenCL PRIVATE OPENCL_ICD_LOADER_REQUIRE_WDK)
+-            target_include_directories(OpenCL PRIVATE ${WDK_DIRECTORY}/um)
+-            target_include_directories(OpenCL PRIVATE ${WDK_DIRECTORY}/km)
+-            target_include_directories(OpenCL PRIVATE ${WDK_DIRECTORY}/shared)
++	    target_compile_definitions(OpenCL-ROCm PRIVATE OPENCL_ICD_LOADER_REQUIRE_WDK)
++	    target_include_directories(OpenCL-ROCm PRIVATE ${WDK_DIRECTORY}/um)
++	    target_include_directories(OpenCL-ROCm PRIVATE ${WDK_DIRECTORY}/km)
++	    target_include_directories(OpenCL-ROCm PRIVATE ${WDK_DIRECTORY}/shared)
+         else()
+             message(FATAL_ERROR "The Windows WDK was not found. Consider disabling OPENCL_ICD_LOADER_REQUIRE_WDK. Aborting.")
+         endif()
+@@ -113,25 +113,25 @@
+     endif()
+ else()
+     if (APPLE)
+-        target_link_libraries (OpenCL ${CMAKE_THREAD_LIBS_INIT})
++        target_link_libraries (OpenCL-ROCm ${CMAKE_THREAD_LIBS_INIT})
+     else ()
+-        set_target_properties (OpenCL PROPERTIES LINK_FLAGS "-Wl,--version-script -Wl,${CMAKE_CURRENT_SOURCE_DIR}/loader/linux/icd_exports.map")
+-        target_link_libraries (OpenCL ${CMAKE_THREAD_LIBS_INIT})
++        set_target_properties (OpenCL-ROCm PROPERTIES LINK_FLAGS "-Wl,--version-script -Wl,${CMAKE_CURRENT_SOURCE_DIR}/loader/linux/icd_exports.map")
++	target_link_libraries (OpenCL-ROCm ${CMAKE_THREAD_LIBS_INIT})
+     endif ()
+ endif ()
+ 
+ include_directories (${OPENCL_ICD_LOADER_HEADERS_DIR})
+ add_definitions (-DCL_TARGET_OPENCL_VERSION=220)
+ 
+-target_include_directories (OpenCL PRIVATE ${CMAKE_CURRENT_BINARY_DIR} loader)
+-target_link_libraries (OpenCL ${CMAKE_DL_LIBS})
++target_include_directories (OpenCL-ROCm PRIVATE ${CMAKE_CURRENT_BINARY_DIR} loader)
++target_link_libraries (OpenCL-ROCm ${CMAKE_DL_LIBS})
+ 
+ include (CTest)
+ if (BUILD_TESTING)
+     add_subdirectory (test)
+ endif()
+ 
+-install (TARGETS OpenCL
++install (TARGETS OpenCL-ROCm
+     RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+     ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
+     LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
+--- OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/test/loader_test/CMakeLists.txt	2019-09-10 11:53:28.000000000 -0400
++++ OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/test/loader_test/CMakeLists.txt	2020-04-16 20:16:56.647026589 -0400
+@@ -12,4 +12,4 @@
+     test_clgl.c
+     test_image_objects.c )
+ 
+-target_link_libraries (icd_loader_test OpenCL IcdLog)
++target_link_libraries (icd_loader_test OpenCL-ROCm IcdLog)
+--- ROCm-OpenCL-Runtime-roc-3.3.0/CMakeLists.txt	2020-04-28 07:29:51.864446603 -0400
++++ ROCm-OpenCL-Runtime-roc-3.3.0/CMakeLists.txt	2020-04-28 07:32:45.245793180 -0400
+@@ -101,30 +101,30 @@
+ rocm_setup_version( VERSION "2.0.0" )
+ 
+ # MAIN package
+-install(PROGRAMS $<TARGET_FILE:clinfo>
+-        DESTINATION bin/x86_64
++install(PROGRAMS $<TARGET_FILE:rocm-clinfo>
++        DESTINATION bin
+         COMPONENT MAIN)
+ install(PROGRAMS $<TARGET_FILE:amdocl64>
+-        DESTINATION lib/x86_64
++        DESTINATION lib
+         COMPONENT MAIN)
+-install(PROGRAMS $<TARGET_FILE:OpenCL>
+-        DESTINATION lib/x86_64
++install(PROGRAMS $<TARGET_FILE:OpenCL-ROCm>
++        DESTINATION lib
+         COMPONENT MAIN)
+-install(PROGRAMS $<TARGET_SONAME_FILE:OpenCL>
+-        DESTINATION lib/x86_64
++install(PROGRAMS $<TARGET_SONAME_FILE:OpenCL-ROCm>
++        DESTINATION lib
+         COMPONENT MAIN)
+ 
+ # DEV package
+ install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/api/opencl/khronos/headers/opencl2.2/CL"
+-        DESTINATION include
++	DESTINATION include/rocm
+         COMPONENT DEV
+         USE_SOURCE_PERMISSIONS
+         PATTERN cl_d3d10.h EXCLUDE
+         PATTERN cl_d3d11.h EXCLUDE
+         PATTERN cl_dx9_media_sharing.h EXCLUDE
+         PATTERN cl_egl.h EXCLUDE)
+-install(PROGRAMS $<TARGET_LINKER_FILE:OpenCL>
+-        DESTINATION lib/x86_64
++install(PROGRAMS $<TARGET_LINKER_FILE:OpenCL-ROCm>
++        DESTINATION lib
+         COMPONENT DEV)
+ 
+ # Generic CPACK variables
+--- ROCm-OpenCL-Runtime-roc-3.3.0/tools/clinfo/CMakeLists.txt	2020-04-28 07:29:51.882446535 -0400
++++ ROCm-OpenCL-Runtime-roc-3.3.0/tools/clinfo/CMakeLists.txt	2020-04-28 07:30:05.627394732 -0400
+@@ -6,6 +6,6 @@
+ 
+ add_definitions(-DHAVE_CL2_HPP)
+ 
+-add_executable(clinfo clinfo.cpp)
++add_executable(rocm-clinfo clinfo.cpp)
+ 
+-target_link_libraries(clinfo OpenCL)
++target_link_libraries(rocm-clinfo OpenCL-ROCm)
diff --git a/srcpkgs/rocm-opencl-runtime/template b/srcpkgs/rocm-opencl-runtime/template
new file mode 100644
index 00000000000..02aebb91bd8
--- /dev/null
+++ b/srcpkgs/rocm-opencl-runtime/template
@@ -0,0 +1,84 @@
+# Template file for 'rocm-opencl-runtime'
+pkgname=rocm-opencl-runtime
+version=3.3.0
+revision=1
+_ocl_icd_name="OpenCL-ICD-Loader"
+_ocl_icd_ver="6c03f8b58fafd9dd693eaac826749a5cfad515f8"
+archs="x86_64*"
+create_wrksrc=yes
+build_wrksrc="ROCm-OpenCL-Runtime-roc-${version}"
+build_style=cmake
+configure_args="-DUSE_COMGR_LIBRARY=yes"
+hostmakedepends="cmake pkg-config"
+makedepends="libglvnd-devel rocm-comgr-devel
+	roct-thunk-interface-devel rocr-runtime-devel"
+depends="rocm-comgr"
+short_desc="Radeon Open Compute OpenCL runtime"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="MIT"
+homepage="https://github.com/RadeonOpenCompute/ROCm-OpenCL-Runtime"
+_rocroot="https://github.com/RadeonOpenCompute"
+distfiles="${_rocroot}/ROCm-OpenCL-Runtime/archive/roc-${version}.tar.gz
+	${_rocroot}/rocm-cmake/archive/rocm-${version}.tar.gz
+	https://github.com/KhronosGroup/${_ocl_icd_name}/archive/${_ocl_icd_ver}.tar.gz"
+checksum="ac6999f1a491ab066286c2bd6adf50f08f831286f56e267879f9f7eced22f98e
+	76ed3ee8e56cf3246011cf7723c2abda539e1136e7e7f6909bfa45d268b8644f
+	c94d5bb6dc980c4d41d73e2b81663a19aabe494e923e2d0eec72a4c95b318438"
+nocross=yes
+
+if [ "$XBPS_LIBC" = "musl" ]; then
+	makedepends+=" musl-legacy-compat"
+fi
+
+post_patch() {
+	if [ "$XBPS_LIBC" = "musl" ]; then
+		# Remove dependence on glibc
+		patch -Np0 < ${FILESDIR}/libelf-musl.patch
+		patch -Np0 < ${FILESDIR}/runtime-musl.patch
+		vsed -e '/glibc_functions.cpp/d' -i api/opencl/amdocl/CMakeLists.txt
+	fi
+}
+
+pre_configure() {
+	# ROCm requires a very specific Khronos ICD loader version in the tree
+	# Keep the ICD loader config in /etc/OpenCL/rocm-vendors to avoid conflicts
+	_ocl_icd_dir="${_ocl_icd_name}-${_ocl_icd_ver}"
+	ln -sf "${wrksrc}/${_ocl_icd_dir}" api/opencl/khronos/icd
+	vsed -i "${wrksrc}/${_ocl_icd_dir}/loader/icd_platform.h" \
+		-e 's@/etc/OpenCL/vendors/@/etc/OpenCL/rocm-vendors/@g'
+
+	# CMake modules probably not useful anywhere but for this build
+	ln -sf "${wrksrc}/rocm-cmake-rocm-${version}/share/rocm/cmake"/*.cmake cmake
+
+	# Fix the dlopen macro to point to versioned libamd_comgr shared object
+	vsed -i 'runtime/device/comgrctx.cpp' \
+		-e 's/\blibamd_comgr\(32\)\?.so\b/&.1/g'
+}
+
+post_install() {
+	vlicense License
+
+	# Create descriptor to allow the ICD loader to find the driver
+	vmkdir etc/OpenCL/rocm-vendors
+	echo "libamdocl64.so" > "${DESTDIR}/etc/OpenCL/rocm-vendors/amdocl64.icd"
+	vmkdir etc/OpenCL/vendors
+	ln -s ../../OpenCL/rocm-vendors/amdocl64.icd \
+		${DESTDIR}/etc/OpenCL/vendors/rocm-amdocl64.icd
+}
+
+rocm-opencl-runtime-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/lib/libOpenCL-ROCm.so
+		vmove usr/include
+	}
+}
+
+rocm-opencl-runtime-clinfo_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - clinfo"
+	pkg_install() {
+		vmove usr/bin/rocm-clinfo
+	}
+}
diff --git a/srcpkgs/rocm-opencl-runtime/update b/srcpkgs/rocm-opencl-runtime/update
new file mode 100644
index 00000000000..8385f4d1215
--- /dev/null
+++ b/srcpkgs/rocm-opencl-runtime/update
@@ -0,0 +1 @@
+pattern='roc-\K[\d.]+'

From a50e542c5612b112c2b6f28053dd2263cfbe0904 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Thu, 30 Apr 2020 13:11:12 -0400
Subject: [PATCH 09/10] New package: rocm-hsa-ext-3.3.0

---
 common/shlibs                 |  2 ++
 srcpkgs/rocm-hsa-ext-devel    |  1 +
 srcpkgs/rocm-hsa-ext/template | 42 +++++++++++++++++++++++++++++++++++
 srcpkgs/rocm-hsa-ext/update   |  2 ++
 4 files changed, 47 insertions(+)
 create mode 120000 srcpkgs/rocm-hsa-ext-devel
 create mode 100644 srcpkgs/rocm-hsa-ext/template
 create mode 100644 srcpkgs/rocm-hsa-ext/update

diff --git a/common/shlibs b/common/shlibs
index 8eee9b0bad8..7d0ef902f8d 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3867,3 +3867,5 @@ libhsa-runtime64.so.1 rocr-runtime-3.3.0_1
 libamd_comgr.so.1 rocm-comgr-3.3.0_1
 libOpenCL-ROCm.so.1 rocm-opencl-runtime-3.3.0_1
 libamdocl64.so rocm-opencl-runtime-3.3.0_1
+libhsa-ext-image64.so.1 rocm-hsa-ext-3.3.0_1
+libhsa-runtime-tools64.so.1 rocm-hsa-ext-3.3.0_1
diff --git a/srcpkgs/rocm-hsa-ext-devel b/srcpkgs/rocm-hsa-ext-devel
new file mode 120000
index 00000000000..d201e9f2fae
--- /dev/null
+++ b/srcpkgs/rocm-hsa-ext-devel
@@ -0,0 +1 @@
+rocm-hsa-ext
\ No newline at end of file
diff --git a/srcpkgs/rocm-hsa-ext/template b/srcpkgs/rocm-hsa-ext/template
new file mode 100644
index 00000000000..a879f03480f
--- /dev/null
+++ b/srcpkgs/rocm-hsa-ext/template
@@ -0,0 +1,42 @@
+# Template file for 'rocm-hsa-ext'
+pkgname=rocm-hsa-ext
+version=3.3.0
+revision=1
+archs="x86_64"
+hostmakedepends="tar"
+short_desc="Radeon Open Compute HSA runtime extensions"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute"
+_hsa_deb="hsa-ext-rocr-dev_1.1.30300.0-rocm-rel-3.3-19-23fc088b_amd64.deb"
+distfiles="https://repo.radeon.com/rocm/apt/debian/pool/main/h/hsa-ext-rocr-dev/$_hsa_deb"
+checksum=6b44e286b395d946b865ec1f3cc546356396785ac1fde591d07af02d0aa7c25d
+repository=nonfree
+
+do_extract() {
+	ar x "${XBPS_SRCDISTDIR}/${pkgname}-${version}/${_hsa_deb}"
+	tar xvf data.tar.gz
+}
+
+do_install() {
+	_rocm_includes="opt/rocm-${version}/hsa/include"
+	
+	vmkdir usr
+	vcopy opt/rocm-${version}/hsa/lib usr
+	vcopy "$_rocm_includes" usr
+
+	# Extract license from one of the header files
+	awk 'BEGIN{HEADER=0} /\/\//{HEADER=1; print $0;} /^[^/]/{if(HEADER==1) exit;}' \
+		< "${_rocm_includes}/hsa/amd_hsa_tools_interfaces.h" \
+		| sed 's@^///*\( \|$\)@@' > LICENSE
+	vlicense LICENSE
+}
+
+rocm-hsa-ext-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove "usr/lib/*.so"
+	}
+}
diff --git a/srcpkgs/rocm-hsa-ext/update b/srcpkgs/rocm-hsa-ext/update
new file mode 100644
index 00000000000..84252d2e3b8
--- /dev/null
+++ b/srcpkgs/rocm-hsa-ext/update
@@ -0,0 +1,2 @@
+site='https://repo.radeon.com/rocm/apt/debian/pool/main/h/'
+pattern='hsa-ext-rocr-dev\K[\d.]+'

From afd1d81c99a39831b15135bce74c2b57955d7395 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Tue, 28 Apr 2020 13:33:46 -0400
Subject: [PATCH 10/10] hashcat: add build option to link against ROCm [ci
 skip]

---
 srcpkgs/hashcat/files/rocm.patch     | 15 +++++++++++++++
 srcpkgs/hashcat/patches/tmpdir.patch | 21 +++++++++++++++++++++
 srcpkgs/hashcat/template             | 17 ++++++++++++++---
 3 files changed, 50 insertions(+), 3 deletions(-)
 create mode 100644 srcpkgs/hashcat/files/rocm.patch
 create mode 100644 srcpkgs/hashcat/patches/tmpdir.patch

diff --git a/srcpkgs/hashcat/files/rocm.patch b/srcpkgs/hashcat/files/rocm.patch
new file mode 100644
index 00000000000..f1e899d30ee
--- /dev/null
+++ b/srcpkgs/hashcat/files/rocm.patch
@@ -0,0 +1,15 @@
+diff -ur a/src/opencl.c b/src/opencl.c
+--- a/src/opencl.c	2018-12-02 05:58:48.000000000 -0500
++++ b/src/opencl.c	2020-04-28 13:24:12.602415333 -0400
+@@ -492,9 +492,9 @@
+ 
+   if (ocl->lib == NULL) ocl->lib = hc_dlopen ("cygOpenCL-1.dll", RTLD_NOW);
+   #else
+-  ocl->lib = hc_dlopen ("libOpenCL.so", RTLD_NOW);
++  ocl->lib = hc_dlopen ("libOpenCL-ROCm.so.1", RTLD_NOW);
+ 
+-  if (ocl->lib == NULL) ocl->lib = hc_dlopen ("libOpenCL.so.1", RTLD_NOW);
++  if (ocl->lib == NULL) ocl->lib = hc_dlopen ("libOpenCL-ROCm.so", RTLD_NOW);
+   #endif
+ 
+   if (ocl->lib == NULL)
diff --git a/srcpkgs/hashcat/patches/tmpdir.patch b/srcpkgs/hashcat/patches/tmpdir.patch
new file mode 100644
index 00000000000..0558a001c9c
--- /dev/null
+++ b/srcpkgs/hashcat/patches/tmpdir.patch
@@ -0,0 +1,21 @@
+Addresses https://github.com/hashcat/hashcat/issues/2379
+diff -ur a/src/folder.c b/src/folder.c
+--- src/folder.c	2018-12-02 05:58:48.000000000 -0500
++++ src/folder.c	2020-04-28 13:22:27.340522751 -0400
+@@ -457,16 +457,6 @@
+ 
+   hcfree (cpath);
+ 
+-  //if (getenv ("TMP") == NULL)
+-  if (1)
+-  {
+-    char *tmp;
+-
+-    hc_asprintf (&tmp, "TMP=%s", cpath_real);
+-
+-    putenv (tmp);
+-  }
+-
+   #if defined (_WIN)
+ 
+   naive_replace (cpath_real, '\\', '/');
diff --git a/srcpkgs/hashcat/template b/srcpkgs/hashcat/template
index e982f99cebf..7d3a8cb5a6b 100644
--- a/srcpkgs/hashcat/template
+++ b/srcpkgs/hashcat/template
@@ -1,15 +1,16 @@
 # Template file for 'hashcat'
 pkgname=hashcat
 version=5.1.0
-revision=2
+revision=3
 build_style=gnu-makefile
 make_build_args="PREFIX=/usr
  USE_SYSTEM_OPENCL=1 USE_SYSTEM_XXHASH=1
- DEPS_OPENCL_PATH=${XBPS_CROSS_BASE}/usr/include
+ DEPS_OPENCL_PATH=${XBPS_CROSS_BASE}/usr/include$(vopt_if rocm /rocm)
  DEPS_XXHASH_PATH=${XBPS_CROSS_BASE}/usr/include"
 make_use_env=yes
 make_install_args="$make_build_args"
-makedepends="gmp-devel opencl2-headers xxHash-devel"
+makedepends="gmp-devel xxHash-devel
+ $(vopt_if rocm rocm-opencl-runtime-devel opencl2-headers)"
 checkdepends="perl"
 short_desc="Advanced CPU-based password recovery utility"
 maintainer="Duncaen <duncaen@voidlinux.org>"
@@ -19,6 +20,9 @@ changelog="https://raw.githubusercontent.com/hashcat/hashcat/master/docs/changes
 distfiles="https://hashcat.net/files/hashcat-${version}.tar.gz"
 checksum=283beaa68e1eab41de080a58bb92349c8e47a2bb1b93d10f36ea30f418f1e338
 
+build_options="rocm"
+desc_option_rocm="Use ROCm OpenCL runtime"
+
 if [ "$XBPS_TARGET_ENDIAN" = "be" ]; then
 	broken="Not supported on big endian"
 fi
@@ -26,6 +30,13 @@ fi
 post_extract() {
 	sed '/^CC/d' -i src/Makefile
 }
+
+post_patch() {
+	if [ "$build_option_rocm" ]; then
+		patch -Np1 < ${FILESDIR}/rocm.patch
+	fi
+}
+
 post_install() {
 	rm -f ${DESTDIR}/usr/share/docs/hashcat/license.txt
 	vlicense docs/license.txt

^ permalink raw reply	[flat|nested] 61+ messages in thread

* Re: [PR PATCH] [Updated] New packages: ROCm core and OpenCL
  2020-04-19 13:34 [PR PATCH] New packages: ROCm core and OpenCL ahesford
                   ` (23 preceding siblings ...)
  2020-05-02  1:34 ` ahesford
@ 2020-05-02  3:29 ` ahesford
  2020-05-05 14:24 ` ahesford
                   ` (34 subsequent siblings)
  59 siblings, 0 replies; 61+ messages in thread
From: ahesford @ 2020-05-02  3:29 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 3893 bytes --]

There is an updated pull request by ahesford against master on the void-packages repository

https://github.com/ahesford/void-packages rocm
https://github.com/void-linux/void-packages/pull/21153

New packages: ROCm core and OpenCL
This PR includes several packages designed to bring the OpenCL portion of the AMD ROCm ecosystem to Void. It addresses Issue #19507. There are many other packages that AMD provides for GPGPU computing, but these can be added piecemeal as users demand.

The packages are currently only for `x86_64*`. While at least some of the packages will compile on other 64-bit architectures, I have no hardware to test. They are certainly not suitable for 32-bit architectures; some internal data structures rely on `uint64_t` values that are cast to pointers. At a
minimum, a thorough audit would be necessary to ensure that these casts are safe (e.g., that the values stored were only ever upcast from 32-bit pointers). More extensive work may be necessary to support 32-bit architectures, probably without significant benefit.

The packages successfully identify a Radeon RX 580 on an `x86_64` installation using both `clinfo` and `rocminfo` as provided. Furthermore, a version of `pyopencl` linked against these ROCm packages successfully runs a simple program that validates arithmetic on GPU-bound arrays.

There are caveats with this set of packages, almost all of which revolve around the incompatibilities between the Void-provided `ocl-icd` and the [Khronos OpenCL ICD loader](https://github.com/KhronosGroup/OpenCL-ID-Loader) required by (and built into) `rocm-opencl-runtime`.
1. All packages install into `/opt/rocm`. This keeps the environment closer to that officially sanctioned by AMD and helps avoid conflicts between other packages and those provided here. (For example, `clinfo` and the ICD loader itself.) Eventually, we may be able to move the files into `/usr`.
2. The Khronos OpenCL ICD loader built into `rocm-opencl-runtime` is an outdated, pre-release commit. If AMD can update its sources to use the release version of that loader (which has a backward-incompatible API change), we may be able to make ROCm compatible with `ocl-icd` or replace `ocl-icd` with the official Khronos loader.
3. In the meantime, to avoid `shlibs` conflicts, the OpenCL ICD loader is installed as `/opt/rocm/lib/libOpenCL-ROCm.so` (and an appropriately versioned shared library), which means that programs wishing to use the ROCm OpenCL must explicitly link against this library instead of the generic `libOpenCL.so`.
4. I do **not** recommend making any Void packages link against this specific library, because it will make those packages ROCm-only. For the time being, ROCm is intended for end-users to specifically link against. Linking Void packages against ROCm would requires the ICD loader used by ROCm be compatible with `ocl-icd`, or `ocl-icd` be replaced by the Khronos loader. However, because the Khronos loader changed its API for the release version, such a change is not yet appropriate.

Hopefully, if AMD updates its dependence on the Khronos ICD loader, we can resolve some of these caveats in the future and make ROCm a more natural Void component. For now, these packages are useful for those who need an AMD OpenCL solution and would rather custom-link software against the AMD ICD loader than hack the `amdgpu-pro` driver into an ICD compatible with `ocl-icd`.

Some patches were made to relocate some files in `/opt/rocm` and make everyting build on x86_64-musl`. Where appropriate, these patches will be pushed upstream to clean up the distribution and packaging.

Update: I pushed some new commits to update license information that triggerd an `xlint` failure. I've also disabled CI builds because they will time out on `rocm-llvm`.

A patch file from https://github.com/void-linux/void-packages/pull/21153.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-rocm-21153.patch --]
[-- Type: text/x-diff, Size: 39062 bytes --]

From 4e14f704aa1dd148bac02167f18f28c2ce905fb3 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Mon, 13 Apr 2020 13:08:09 -0400
Subject: [PATCH 01/10] New package: ROCT-Thunk-Interface-3.3.0

---
 common/shlibs                                 |  1 +
 srcpkgs/ROCT-Thunk-Interface-devel            |  1 +
 .../patches/cmake-dev-libdir.patch            | 10 ++++++
 .../ROCT-Thunk-Interface/patches/musl.patch   | 29 ++++++++++++++++
 srcpkgs/ROCT-Thunk-Interface/template         | 33 +++++++++++++++++++
 srcpkgs/ROCT-Thunk-Interface/update           |  1 +
 6 files changed, 75 insertions(+)
 create mode 120000 srcpkgs/ROCT-Thunk-Interface-devel
 create mode 100644 srcpkgs/ROCT-Thunk-Interface/patches/cmake-dev-libdir.patch
 create mode 100644 srcpkgs/ROCT-Thunk-Interface/patches/musl.patch
 create mode 100644 srcpkgs/ROCT-Thunk-Interface/template
 create mode 100644 srcpkgs/ROCT-Thunk-Interface/update

diff --git a/common/shlibs b/common/shlibs
index 9fb74043e9f..b6881ab8041 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3862,3 +3862,4 @@ libkdsoap.so.1.9.0 KDSoap-1.9.0_1
 libstoken.so.1 stoken-0.92_1
 libjpegxr.so.0 jxrlib-0.2.2_1
 libjxrglue.so.0 jxrlib-0.2.2_1
+libhsakmt.so.1 ROCT-Thunk-Interface-3.3.0_1
diff --git a/srcpkgs/ROCT-Thunk-Interface-devel b/srcpkgs/ROCT-Thunk-Interface-devel
new file mode 120000
index 00000000000..7e43c209e3d
--- /dev/null
+++ b/srcpkgs/ROCT-Thunk-Interface-devel
@@ -0,0 +1 @@
+ROCT-Thunk-Interface
\ No newline at end of file
diff --git a/srcpkgs/ROCT-Thunk-Interface/patches/cmake-dev-libdir.patch b/srcpkgs/ROCT-Thunk-Interface/patches/cmake-dev-libdir.patch
new file mode 100644
index 00000000000..98c7f1e459c
--- /dev/null
+++ b/srcpkgs/ROCT-Thunk-Interface/patches/cmake-dev-libdir.patch
@@ -0,0 +1,10 @@
+--- CMakeLists.txt.old	2020-04-18 19:45:17.306081135 -0400
++++ CMakeLists.txt	2020-04-18 19:46:51.300753636 -0400
+@@ -146,6 +146,7 @@
+     COMMAND ${CMAKE_COMMAND}
+         -DSOURCE_DIR="${SOURCE_DIR}"
+         -DCMAKE_INSTALL_PREFIX="${CMAKE_INSTALL_PREFIX}"
++        -DCMAKE_INSTALL_LIBDIR="${CMAKE_INSTALL_LIBDIR}"
+         -DCPACK_RPM_PACKAGE_REQUIRES="hsakmt-roct"
+         -DCPACK_PACKAGING_INSTALL_PREFIX="${CPACK_PACKAGING_INSTALL_PREFIX}"
+         -DVERSION="${BUILD_VERSION_STRING}"
diff --git a/srcpkgs/ROCT-Thunk-Interface/patches/musl.patch b/srcpkgs/ROCT-Thunk-Interface/patches/musl.patch
new file mode 100644
index 00000000000..aeea9832411
--- /dev/null
+++ b/srcpkgs/ROCT-Thunk-Interface/patches/musl.patch
@@ -0,0 +1,29 @@
+diff -r -u old/src/libhsakmt.h new/src/libhsakmt.h
+--- src/libhsakmt.h	2020-03-04 15:00:47.000000000 -0500
++++ src/libhsakmt.h	2020-04-13 12:58:30.444865992 -0400
+@@ -54,6 +54,10 @@
+ #define CHECK_KFD_OPEN() \
+ 	do { if (kfd_open_count == 0 || hsakmt_forked) return HSAKMT_STATUS_KERNEL_IO_CHANNEL_NOT_OPENED; } while (0)
+ 
++/*On some platforms, a PAGE_SIZE macro eclipses the extern variable*/
++#ifdef PAGE_SIZE
++#undef PAGE_SIZE
++#endif
+ extern int PAGE_SIZE;
+ extern int PAGE_SHIFT;
+ 
+diff -r -u old/src/topology.c new/src/topology.c
+--- src/topology.c	2020-03-04 15:00:47.000000000 -0500
++++ src/topology.c	2020-04-13 13:01:31.209870701 -0400
+@@ -38,6 +38,11 @@
+ #include "libhsakmt.h"
+ #include "fmm.h"
+ 
++/*Needed on MUSL*/
++#ifndef MAXNAMLEN
++#define MAXNAMLEN PATH_MAX
++#endif
++
+ /* Number of memory banks added by thunk on top of topology
+  * This only includes static heaps like LDS, scratch and SVM,
+  * not for MMIO_REMAP heap. MMIO_REMAP memory bank is reported
diff --git a/srcpkgs/ROCT-Thunk-Interface/template b/srcpkgs/ROCT-Thunk-Interface/template
new file mode 100644
index 00000000000..8c680b2af29
--- /dev/null
+++ b/srcpkgs/ROCT-Thunk-Interface/template
@@ -0,0 +1,33 @@
+# Template file for 'ROCT-Thunk-Interface'
+pkgname=ROCT-Thunk-Interface
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="${pkgname}-roc-${version}"
+build_style=cmake
+make_build_target="all build-dev"
+make_install_target="install install-dev"
+hostmakedepends="cmake pkg-config"
+makedepends="pciutils-devel libnuma-devel"
+short_desc="Radeon Open Compute thunk interface"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="MIT"
+homepage="https://github.com/RadeonOpenCompute/ROCT-Thunk-Interface"
+distfiles="${homepage}/archive/roc-${version}.tar.gz"
+checksum=2cabe9d2cfa72031c05d11290837c476182e72d8dec2049298f691143fdd212b
+nocross=yes
+
+post_install() {
+	vlicense LICENSE.md
+}
+
+ROCT-Thunk-Interface-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove "usr/lib/*.so"
+		vmove usr/share/pkgconfig
+		vmove usr/lib/cmake
+	}
+}
diff --git a/srcpkgs/ROCT-Thunk-Interface/update b/srcpkgs/ROCT-Thunk-Interface/update
new file mode 100644
index 00000000000..8385f4d1215
--- /dev/null
+++ b/srcpkgs/ROCT-Thunk-Interface/update
@@ -0,0 +1 @@
+pattern='roc-\K[\d.]+'

From adbc8018be727e0f9c9fb95dc46e56d2f573bdef Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Mon, 13 Apr 2020 15:27:27 -0400
Subject: [PATCH 02/10] New package: ROCR-Runtime-3.3.0

---
 common/shlibs                            |  1 +
 srcpkgs/ROCR-Runtime-devel               |  1 +
 srcpkgs/ROCR-Runtime/patches/cmake.patch | 27 +++++++++++++++++++++
 srcpkgs/ROCR-Runtime/template            | 30 ++++++++++++++++++++++++
 srcpkgs/ROCR-Runtime/update              |  1 +
 5 files changed, 60 insertions(+)
 create mode 120000 srcpkgs/ROCR-Runtime-devel
 create mode 100644 srcpkgs/ROCR-Runtime/patches/cmake.patch
 create mode 100644 srcpkgs/ROCR-Runtime/template
 create mode 100644 srcpkgs/ROCR-Runtime/update

diff --git a/common/shlibs b/common/shlibs
index b6881ab8041..39c61e0529a 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3863,3 +3863,4 @@ libstoken.so.1 stoken-0.92_1
 libjpegxr.so.0 jxrlib-0.2.2_1
 libjxrglue.so.0 jxrlib-0.2.2_1
 libhsakmt.so.1 ROCT-Thunk-Interface-3.3.0_1
+libhsa-runtime64.so.1 ROCR-Runtime-3.3.0_1
diff --git a/srcpkgs/ROCR-Runtime-devel b/srcpkgs/ROCR-Runtime-devel
new file mode 120000
index 00000000000..a733fb9fbab
--- /dev/null
+++ b/srcpkgs/ROCR-Runtime-devel
@@ -0,0 +1 @@
+ROCR-Runtime
\ No newline at end of file
diff --git a/srcpkgs/ROCR-Runtime/patches/cmake.patch b/srcpkgs/ROCR-Runtime/patches/cmake.patch
new file mode 100644
index 00000000000..93b74cd2297
--- /dev/null
+++ b/srcpkgs/ROCR-Runtime/patches/cmake.patch
@@ -0,0 +1,27 @@
+--- src/CMakeLists.txt.old	2020-04-18 20:01:48.549636995 -0400
++++ src/CMakeLists.txt	2020-04-18 20:04:00.177179781 -0400
+@@ -108,8 +108,8 @@
+ ## ROCr build internal versioning
+ add_definitions ( -DROCR_BUILD_ID=${PACKAGE_VERSION_STRING} )
+ 
+-## Set RUNPATH - ../../lib covers use of the legacy symlink in /hsa/lib/
+-set(CMAKE_INSTALL_RPATH "$ORIGIN;$ORIGIN/../../lib;$ORIGIN/../../lib64;$ORIGIN/../lib64")
++## Set RUNPATH
++set(CMAKE_INSTALL_RPATH "$ORIGIN;$ORIGIN/../lib")
+ 
+ ## ------------------------- Linux Compiler and Linker options -------------------------
+ set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -fexceptions -fno-rtti -fvisibility=hidden -Wno-error=sign-compare -Wno-sign-compare -Wno-write-strings -Wno-conversion-null -fno-math-errno -fno-threadsafe-statics -fmerge-all-constants -fms-extensions -Wno-error=comment -Wno-comment -Wno-error=pointer-arith -Wno-pointer-arith -Wno-error=unused-variable -Wno-error=unused-function" )
+@@ -185,11 +185,8 @@
+ add_custom_target ( hsa_lib_link2 ALL WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMAND ${CMAKE_COMMAND} -E create_symlink ../hsa/lib/${CORE_RUNTIME_LIBRARY}.so.${SO_MAJOR} ${CORE_RUNTIME_LIBRARY}-link.so.${SO_MAJOR} )
+ 
+ ## Set install information
+-install ( TARGETS ${CORE_RUNTIME_TARGET} LIBRARY DESTINATION hsa/lib )
+-install ( DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/inc/ DESTINATION hsa/include/hsa )
+-install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/hsa_include_link DESTINATION include PERMISSIONS OWNER_WRITE OWNER_READ RENAME hsa )
+-install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/${CORE_RUNTIME_LIBRARY}-link.so DESTINATION lib PERMISSIONS OWNER_WRITE OWNER_READ RENAME ${CORE_RUNTIME_LIBRARY}.so )
+-install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/${CORE_RUNTIME_LIBRARY}-link.so.${SO_MAJOR} DESTINATION lib PERMISSIONS OWNER_WRITE OWNER_READ RENAME ${CORE_RUNTIME_LIBRARY}.so.${SO_MAJOR} )
++install ( TARGETS ${CORE_RUNTIME_TARGET} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} )
++install ( DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/inc/ DESTINATION include/hsa )
+ 
+ ## Packaging directives
+ set ( CPACK_GENERATOR "DEB;RPM" CACHE STRING "Package types to build")
diff --git a/srcpkgs/ROCR-Runtime/template b/srcpkgs/ROCR-Runtime/template
new file mode 100644
index 00000000000..95b7e701afb
--- /dev/null
+++ b/srcpkgs/ROCR-Runtime/template
@@ -0,0 +1,30 @@
+# Template file for 'ROCR-Runtime'
+pkgname=ROCR-Runtime
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="${pkgname}-rocm-${version}"
+build_wrksrc="src"
+build_style=cmake
+hostmakedepends="cmake pkg-config"
+makedepends="ROCT-Thunk-Interface-devel elfutils-devel"
+short_desc="Radeon Open Compute HSA runtime"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute/ROCR-Runtime"
+distfiles="${homepage}/archive/rocm-${version}.tar.gz"
+checksum=fa2d2d1f8a61d8a6952d377cf288d78c61776c3c2a666f163cafc3aa19ab0b61
+nocross=yes
+
+post_install() {
+	vlicense ../LICENSE.txt
+}
+
+ROCR-Runtime-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove "usr/lib/*.so"
+	}
+}
diff --git a/srcpkgs/ROCR-Runtime/update b/srcpkgs/ROCR-Runtime/update
new file mode 100644
index 00000000000..86197bc3eea
--- /dev/null
+++ b/srcpkgs/ROCR-Runtime/update
@@ -0,0 +1 @@
+pattern='rocm-\K[\d.]+'

From 67948ab0a271fa1c1e6094de6b3631de6c2788f5 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Mon, 13 Apr 2020 18:07:34 -0400
Subject: [PATCH 03/10] New package: ROCm-llvm-3.3.0

---
 srcpkgs/ROCm-llvm/template | 26 ++++++++++++++++++++++++++
 srcpkgs/ROCm-llvm/update   |  1 +
 2 files changed, 27 insertions(+)
 create mode 100644 srcpkgs/ROCm-llvm/template
 create mode 100644 srcpkgs/ROCm-llvm/update

diff --git a/srcpkgs/ROCm-llvm/template b/srcpkgs/ROCm-llvm/template
new file mode 100644
index 00000000000..4c3095b21f4
--- /dev/null
+++ b/srcpkgs/ROCm-llvm/template
@@ -0,0 +1,26 @@
+# Template file for 'ROCm-llvm'
+pkgname=ROCm-llvm
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="llvm-project-rocm-ocl-${version}"
+build_wrksrc=llvm
+build_style=cmake
+configure_args="-DCMAKE_INSTALL_PREFIX:PATH=/usr/lib/rocm-llvm
+	-DLLVM_ENABLE_PROJECTS='llvm;clang;lld' -DLLVM_TARGETS_TO_BUILD='AMDGPU'
+	-DLLVM_BUILD_DOCS=NO -DLLVM_ENABLE_OCAMLDOC=OFF
+	-DLLVM_ENABLE_SPHINX=NO -DLLVM_ENABLE_DOXYGEN=OFF
+	-DLLVM_INSTALL_UTILS=ON -DLLVM_VERSION_SUFFIX=roc -DOCAMLFIND=NO"
+hostmakedepends="cmake pkg-config python3"
+short_desc="Radeon Open Compute LLVM toolchain"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="Apache-2.0, NCSA, custom:LLVM-Exceptions"
+homepage="https://github.com/RadeonOpenCompute/llvm-project"
+distfiles="${homepage}/archive/rocm-ocl-${version}.tar.gz"
+checksum=a2bef7042e8e2f2cd8548cb246b88322e1c77188839983dcac8312d56f544dc8
+python_version=3
+nocross=yes
+
+post_install() {
+	vlicense LICENSE.TXT
+}
diff --git a/srcpkgs/ROCm-llvm/update b/srcpkgs/ROCm-llvm/update
new file mode 100644
index 00000000000..6a73667d3c1
--- /dev/null
+++ b/srcpkgs/ROCm-llvm/update
@@ -0,0 +1 @@
+pattern='rocm-ocl-\K[\d.]+'

From 5e0f2b9e4bc9264fb7381bde7ab28c9412431177 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Tue, 14 Apr 2020 10:25:31 -0400
Subject: [PATCH 04/10] New package: ROCm-Device-Libs-3.3.0

---
 srcpkgs/ROCm-Device-Libs/template | 37 +++++++++++++++++++++++++++++++
 srcpkgs/ROCm-Device-Libs/update   |  1 +
 2 files changed, 38 insertions(+)
 create mode 100644 srcpkgs/ROCm-Device-Libs/template
 create mode 100644 srcpkgs/ROCm-Device-Libs/update

diff --git a/srcpkgs/ROCm-Device-Libs/template b/srcpkgs/ROCm-Device-Libs/template
new file mode 100644
index 00000000000..8086cd86450
--- /dev/null
+++ b/srcpkgs/ROCm-Device-Libs/template
@@ -0,0 +1,37 @@
+# Template file for 'ROCm-Device-Libs'
+pkgname=ROCm-Device-Libs
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="${pkgname}-rocm-ocl-${version}"
+build_style=cmake
+configure_args="-DLLVM_DIR:PATH=/usr/lib/rocm-llvm
+	-DCMAKE_INSTALL_LIBDIR:PATH=lib/rocm-device-libs"
+hostmakedepends="cmake ROCm-llvm"
+short_desc="Radeon Open Compute device libraries"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute/ROCm-Device-Libs"
+distfiles="${homepage}/archive/rocm-ocl-${version}.tar.gz"
+checksum=706b08230790e08ca6a7a2fb7687d6131fd39a562148340e00fa37a6c06769c5
+nocross=yes
+
+pre_configure() {
+	# Put bytecodes in a lib/ subdirectory
+	vsed -i Packages.cmake -e 's@/lib/@/${CMAKE_INSTALL_LIBDIR}/@'
+	vsed -i OCL.cmake -e 's@DESTINATION lib$@DESTINATION ${CMAKE_INSTALL_LIBDIR}@'
+
+	# Build the prepare-builtins executable with native compiler
+	mkdir -p utils/build
+	cd utils/build
+	_prepare_builtins="$PWD/prepare-builtins/prepare-builtins"
+	cmake ${configure_args} ..
+	make ${makejobs}
+
+	# Add path to prepare-builtins for cmake
+	configure_args+=" -DPREPARE_BUILTINS='${_prepare_builtins}'"
+}
+
+post_install() {
+	vlicense LICENSE
+}
diff --git a/srcpkgs/ROCm-Device-Libs/update b/srcpkgs/ROCm-Device-Libs/update
new file mode 100644
index 00000000000..6a73667d3c1
--- /dev/null
+++ b/srcpkgs/ROCm-Device-Libs/update
@@ -0,0 +1 @@
+pattern='rocm-ocl-\K[\d.]+'

From dc5933dad5b1dd800a83ea1d15eb43b968bb384b Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Mon, 13 Apr 2020 18:30:00 -0400
Subject: [PATCH 05/10] New package: ROCm-CompilerSupport-3.3.0

---
 common/shlibs                         |  1 +
 srcpkgs/ROCm-CompilerSupport-devel    |  1 +
 srcpkgs/ROCm-CompilerSupport/template | 32 +++++++++++++++++++++++++++
 srcpkgs/ROCm-CompilerSupport/update   |  1 +
 4 files changed, 35 insertions(+)
 create mode 120000 srcpkgs/ROCm-CompilerSupport-devel
 create mode 100644 srcpkgs/ROCm-CompilerSupport/template
 create mode 100644 srcpkgs/ROCm-CompilerSupport/update

diff --git a/common/shlibs b/common/shlibs
index 39c61e0529a..fa3a047017e 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3864,3 +3864,4 @@ libjpegxr.so.0 jxrlib-0.2.2_1
 libjxrglue.so.0 jxrlib-0.2.2_1
 libhsakmt.so.1 ROCT-Thunk-Interface-3.3.0_1
 libhsa-runtime64.so.1 ROCR-Runtime-3.3.0_1
+libamd_comgr.so.1 ROCm-CompilerSupport-3.3.0_1
diff --git a/srcpkgs/ROCm-CompilerSupport-devel b/srcpkgs/ROCm-CompilerSupport-devel
new file mode 120000
index 00000000000..877aeafeeae
--- /dev/null
+++ b/srcpkgs/ROCm-CompilerSupport-devel
@@ -0,0 +1 @@
+ROCm-CompilerSupport
\ No newline at end of file
diff --git a/srcpkgs/ROCm-CompilerSupport/template b/srcpkgs/ROCm-CompilerSupport/template
new file mode 100644
index 00000000000..df56f7a3837
--- /dev/null
+++ b/srcpkgs/ROCm-CompilerSupport/template
@@ -0,0 +1,32 @@
+# Template file for 'ROCm-CompilerSupport'
+pkgname=ROCm-CompilerSupport
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="${pkgname}-rocm-${version}"
+build_wrksrc="lib/comgr"
+build_style=cmake
+configure_args="-DClang_DIR:PATH=/usr/lib/rocm-llvm/lib/cmake/clang"
+hostmakedepends="cmake pkg-config ROCm-llvm"
+makedepends="ROCm-Device-Libs"
+short_desc="Radeon Open Compute compiler support"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="BSD-3-Clause"
+homepage="https://github.com/RadeonOpenCompute/ROCm-CompilerSupport"
+distfiles="${homepage}/archive/rocm-${version}.tar.gz"
+checksum=01e2524e0f28ecd6f46c9720f279207de935d826b0172158792aa3ec86af9ca7
+nocross=yes
+
+post_install() {
+	vlicense LICENSE.txt
+}
+
+ROCm-CompilerSupport-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove "usr/lib/*.so"
+		vmove usr/lib/cmake
+	}
+}
diff --git a/srcpkgs/ROCm-CompilerSupport/update b/srcpkgs/ROCm-CompilerSupport/update
new file mode 100644
index 00000000000..86197bc3eea
--- /dev/null
+++ b/srcpkgs/ROCm-CompilerSupport/update
@@ -0,0 +1 @@
+pattern='rocm-\K[\d.]+'

From 3aa384140cc749323990965e937656dc4d09b40f Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Fri, 17 Apr 2020 12:11:25 -0400
Subject: [PATCH 06/10] New package: rocminfo-3.3.0

---
 srcpkgs/rocminfo/template | 22 ++++++++++++++++++++++
 srcpkgs/rocminfo/update   |  1 +
 2 files changed, 23 insertions(+)
 create mode 100644 srcpkgs/rocminfo/template
 create mode 100644 srcpkgs/rocminfo/update

diff --git a/srcpkgs/rocminfo/template b/srcpkgs/rocminfo/template
new file mode 100644
index 00000000000..7a075c7f7ac
--- /dev/null
+++ b/srcpkgs/rocminfo/template
@@ -0,0 +1,22 @@
+# Template file for 'rocminfo'
+pkgname=rocminfo
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="${pkgname}-rocm-${version}"
+build_style=cmake
+configure_args="-DROCM_DIR=/usr"
+hostmakedepends="cmake pkg-config"
+makedepends="ROCR-Runtime-devel"
+short_desc="Radeon Open Compute system information reporter"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute/rocminfo"
+distfiles="${homepage}/archive/rocm-${version}.tar.gz"
+checksum=e666f662c9e465aaabbbd0b109d87e017243cdf1a0898fabf5a90947bb3dbcd7
+nocross=yes
+python_version=3
+
+post_install() {
+	vlicense License.txt
+}
diff --git a/srcpkgs/rocminfo/update b/srcpkgs/rocminfo/update
new file mode 100644
index 00000000000..86197bc3eea
--- /dev/null
+++ b/srcpkgs/rocminfo/update
@@ -0,0 +1 @@
+pattern='rocm-\K[\d.]+'

From eaf4ef69f866a0ec2035dc4acfed4c1b701f6c01 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Sun, 19 Apr 2020 15:01:40 -0400
Subject: [PATCH 07/10] New package: rocm_bandwidth_test-3.3.0

---
 srcpkgs/rocm_bandwidth_test/template | 20 ++++++++++++++++++++
 srcpkgs/rocm_bandwidth_test/update   |  1 +
 2 files changed, 21 insertions(+)
 create mode 100644 srcpkgs/rocm_bandwidth_test/template
 create mode 100644 srcpkgs/rocm_bandwidth_test/update

diff --git a/srcpkgs/rocm_bandwidth_test/template b/srcpkgs/rocm_bandwidth_test/template
new file mode 100644
index 00000000000..6de7f2d6614
--- /dev/null
+++ b/srcpkgs/rocm_bandwidth_test/template
@@ -0,0 +1,20 @@
+# Template file for 'rocm_bandwidth_test'
+pkgname=rocm_bandwidth_test
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="${pkgname}-rocm-${version}"
+build_style=cmake
+hostmakedepends="cmake"
+makedepends="ROCR-Runtime-devel ROCT-Thunk-Interface-devel"
+short_desc="Radeon Open Compute bandwidth test"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute/rocm_bandwidth_test"
+distfiles="${homepage}/archive/rocm-${version}.tar.gz"
+checksum=f5f914073018619dc91662d5bf630903dfa4db9136d603591917fdfb3c9164ce
+nocross=yes
+
+post_install() {
+	vlicense LICENSE.txt
+}
diff --git a/srcpkgs/rocm_bandwidth_test/update b/srcpkgs/rocm_bandwidth_test/update
new file mode 100644
index 00000000000..86197bc3eea
--- /dev/null
+++ b/srcpkgs/rocm_bandwidth_test/update
@@ -0,0 +1 @@
+pattern='rocm-\K[\d.]+'

From 3989b1833dcc3db02bc03df2f8fbe69ddb862a8a Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Tue, 14 Apr 2020 10:25:54 -0400
Subject: [PATCH 08/10] New package: ROCm-OpenCL-Runtime-3.3.0

---
 common/shlibs                                 |   2 +
 srcpkgs/ROCm-OpenCL-Runtime-clinfo            |   1 +
 srcpkgs/ROCm-OpenCL-Runtime-devel             |   1 +
 .../files/libelf-musl.patch                   |  21 +++
 .../files/runtime-musl.patch                  |  11 ++
 .../ROCm-OpenCL-Runtime/patches/cmake.patch   | 126 ++++++++++++++++++
 srcpkgs/ROCm-OpenCL-Runtime/template          |  84 ++++++++++++
 srcpkgs/ROCm-OpenCL-Runtime/update            |   1 +
 8 files changed, 247 insertions(+)
 create mode 120000 srcpkgs/ROCm-OpenCL-Runtime-clinfo
 create mode 120000 srcpkgs/ROCm-OpenCL-Runtime-devel
 create mode 100644 srcpkgs/ROCm-OpenCL-Runtime/files/libelf-musl.patch
 create mode 100644 srcpkgs/ROCm-OpenCL-Runtime/files/runtime-musl.patch
 create mode 100644 srcpkgs/ROCm-OpenCL-Runtime/patches/cmake.patch
 create mode 100644 srcpkgs/ROCm-OpenCL-Runtime/template
 create mode 100644 srcpkgs/ROCm-OpenCL-Runtime/update

diff --git a/common/shlibs b/common/shlibs
index fa3a047017e..a612449ad1f 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3865,3 +3865,5 @@ libjxrglue.so.0 jxrlib-0.2.2_1
 libhsakmt.so.1 ROCT-Thunk-Interface-3.3.0_1
 libhsa-runtime64.so.1 ROCR-Runtime-3.3.0_1
 libamd_comgr.so.1 ROCm-CompilerSupport-3.3.0_1
+libOpenCL-ROCm.so.1 ROCm-OpenCL-Runtime-3.3.0_1
+libamdocl64.so ROCm-OpenCL-Runtime-3.3.0_1
diff --git a/srcpkgs/ROCm-OpenCL-Runtime-clinfo b/srcpkgs/ROCm-OpenCL-Runtime-clinfo
new file mode 120000
index 00000000000..21f2041b8fb
--- /dev/null
+++ b/srcpkgs/ROCm-OpenCL-Runtime-clinfo
@@ -0,0 +1 @@
+ROCm-OpenCL-Runtime
\ No newline at end of file
diff --git a/srcpkgs/ROCm-OpenCL-Runtime-devel b/srcpkgs/ROCm-OpenCL-Runtime-devel
new file mode 120000
index 00000000000..21f2041b8fb
--- /dev/null
+++ b/srcpkgs/ROCm-OpenCL-Runtime-devel
@@ -0,0 +1 @@
+ROCm-OpenCL-Runtime
\ No newline at end of file
diff --git a/srcpkgs/ROCm-OpenCL-Runtime/files/libelf-musl.patch b/srcpkgs/ROCm-OpenCL-Runtime/files/libelf-musl.patch
new file mode 100644
index 00000000000..29469a9a351
--- /dev/null
+++ b/srcpkgs/ROCm-OpenCL-Runtime/files/libelf-musl.patch
@@ -0,0 +1,21 @@
+--- compiler/lib/loaders/elf/utils/libelf/_libelf.h	2020-04-28 15:50:53.243438174 -0400
++++ compiler/lib/loaders/elf/utils/libelf/_libelf.h	2020-04-28 15:51:54.293435415 -0400
+@@ -35,6 +35,7 @@
+ #include "_libelf_config.h"
+ 
+ #include "_elftc.h"
++#include <sys/cdefs.h>
+ 
+ /*
+  * Library-private data structures.
+--- compiler/lib/loaders/elf/utils/libelf/libelf.h	2020-04-28 15:50:53.244438174 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf.h	2020-04-28 15:52:12.375434593 -0400
+@@ -36,6 +36,8 @@
+ #define EM_HSAIL 0xAF5A
+ #endif
+ 
++#include <sys/cdefs.h>
++
+ /* Library private data structures */
+ typedef struct _Elf Elf;
+ typedef struct _Elf_Scn Elf_Scn;
diff --git a/srcpkgs/ROCm-OpenCL-Runtime/files/runtime-musl.patch b/srcpkgs/ROCm-OpenCL-Runtime/files/runtime-musl.patch
new file mode 100644
index 00000000000..ea18e90e09c
--- /dev/null
+++ b/srcpkgs/ROCm-OpenCL-Runtime/files/runtime-musl.patch
@@ -0,0 +1,11 @@
+--- runtime/os/os_posix.cpp.orig	2020-04-19 09:13:51.701982901 -0400
++++ runtime/os/os_posix.cpp	2020-04-19 09:14:04.156947422 -0400
+@@ -44,6 +44,8 @@
+ #include <algorithm>
+ #include <mutex>
+ 
++#include <libgen.h> // for basename
++
+ 
+ namespace amd {
+ 
diff --git a/srcpkgs/ROCm-OpenCL-Runtime/patches/cmake.patch b/srcpkgs/ROCm-OpenCL-Runtime/patches/cmake.patch
new file mode 100644
index 00000000000..2c96b99d45a
--- /dev/null
+++ b/srcpkgs/ROCm-OpenCL-Runtime/patches/cmake.patch
@@ -0,0 +1,126 @@
+--- OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/CMakeLists.txt	2019-09-10 11:53:28.000000000 -0400
++++ OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/CMakeLists.txt	2020-04-16 20:16:13.481180757 -0400
+@@ -73,11 +73,11 @@
+ 
+ set (OPENCL_ICD_LOADER_HEADERS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/inc CACHE PATH "Path to OpenCL Headers")
+ 
+-add_library (OpenCL ${OPENCL_ICD_LOADER_SOURCES})
+-set_target_properties (OpenCL PROPERTIES VERSION "1.2" SOVERSION "1")
++add_library (OpenCL-ROCm ${OPENCL_ICD_LOADER_SOURCES})
++set_target_properties (OpenCL-ROCm PROPERTIES VERSION "1.2" SOVERSION "1")
+ 
+ if (WIN32)
+-    target_link_libraries (OpenCL cfgmgr32.lib)
++    target_link_libraries (OpenCL-ROCm cfgmgr32.lib)
+ 
+     option (OPENCL_ICD_LOADER_REQUIRE_WDK "Build with D3DKMT support, which requires the Windows WDK." ON)
+     if (OPENCL_ICD_LOADER_REQUIRE_WDK)
+@@ -92,10 +92,10 @@
+             get_filename_component(WDK_DIRECTORY ${LATEST_D3DKMT_HEADER} DIRECTORY)
+             get_filename_component(WDK_DIRECTORY ${WDK_DIRECTORY} DIRECTORY)
+             message(STATUS "Found the Windows WDK in: ${WDK_DIRECTORY}")
+-            target_compile_definitions(OpenCL PRIVATE OPENCL_ICD_LOADER_REQUIRE_WDK)
+-            target_include_directories(OpenCL PRIVATE ${WDK_DIRECTORY}/um)
+-            target_include_directories(OpenCL PRIVATE ${WDK_DIRECTORY}/km)
+-            target_include_directories(OpenCL PRIVATE ${WDK_DIRECTORY}/shared)
++	    target_compile_definitions(OpenCL-ROCm PRIVATE OPENCL_ICD_LOADER_REQUIRE_WDK)
++	    target_include_directories(OpenCL-ROCm PRIVATE ${WDK_DIRECTORY}/um)
++	    target_include_directories(OpenCL-ROCm PRIVATE ${WDK_DIRECTORY}/km)
++	    target_include_directories(OpenCL-ROCm PRIVATE ${WDK_DIRECTORY}/shared)
+         else()
+             message(FATAL_ERROR "The Windows WDK was not found. Consider disabling OPENCL_ICD_LOADER_REQUIRE_WDK. Aborting.")
+         endif()
+@@ -113,25 +113,25 @@
+     endif()
+ else()
+     if (APPLE)
+-        target_link_libraries (OpenCL ${CMAKE_THREAD_LIBS_INIT})
++        target_link_libraries (OpenCL-ROCm ${CMAKE_THREAD_LIBS_INIT})
+     else ()
+-        set_target_properties (OpenCL PROPERTIES LINK_FLAGS "-Wl,--version-script -Wl,${CMAKE_CURRENT_SOURCE_DIR}/loader/linux/icd_exports.map")
+-        target_link_libraries (OpenCL ${CMAKE_THREAD_LIBS_INIT})
++        set_target_properties (OpenCL-ROCm PROPERTIES LINK_FLAGS "-Wl,--version-script -Wl,${CMAKE_CURRENT_SOURCE_DIR}/loader/linux/icd_exports.map")
++	target_link_libraries (OpenCL-ROCm ${CMAKE_THREAD_LIBS_INIT})
+     endif ()
+ endif ()
+ 
+ include_directories (${OPENCL_ICD_LOADER_HEADERS_DIR})
+ add_definitions (-DCL_TARGET_OPENCL_VERSION=220)
+ 
+-target_include_directories (OpenCL PRIVATE ${CMAKE_CURRENT_BINARY_DIR} loader)
+-target_link_libraries (OpenCL ${CMAKE_DL_LIBS})
++target_include_directories (OpenCL-ROCm PRIVATE ${CMAKE_CURRENT_BINARY_DIR} loader)
++target_link_libraries (OpenCL-ROCm ${CMAKE_DL_LIBS})
+ 
+ include (CTest)
+ if (BUILD_TESTING)
+     add_subdirectory (test)
+ endif()
+ 
+-install (TARGETS OpenCL
++install (TARGETS OpenCL-ROCm
+     RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+     ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
+     LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
+--- OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/test/loader_test/CMakeLists.txt	2019-09-10 11:53:28.000000000 -0400
++++ OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/test/loader_test/CMakeLists.txt	2020-04-16 20:16:56.647026589 -0400
+@@ -12,4 +12,4 @@
+     test_clgl.c
+     test_image_objects.c )
+ 
+-target_link_libraries (icd_loader_test OpenCL IcdLog)
++target_link_libraries (icd_loader_test OpenCL-ROCm IcdLog)
+--- ROCm-OpenCL-Runtime-roc-3.3.0/CMakeLists.txt	2020-04-28 07:29:51.864446603 -0400
++++ ROCm-OpenCL-Runtime-roc-3.3.0/CMakeLists.txt	2020-04-28 07:32:45.245793180 -0400
+@@ -101,30 +101,30 @@
+ rocm_setup_version( VERSION "2.0.0" )
+ 
+ # MAIN package
+-install(PROGRAMS $<TARGET_FILE:clinfo>
+-        DESTINATION bin/x86_64
++install(PROGRAMS $<TARGET_FILE:rocm-clinfo>
++        DESTINATION bin
+         COMPONENT MAIN)
+ install(PROGRAMS $<TARGET_FILE:amdocl64>
+-        DESTINATION lib/x86_64
++        DESTINATION lib
+         COMPONENT MAIN)
+-install(PROGRAMS $<TARGET_FILE:OpenCL>
+-        DESTINATION lib/x86_64
++install(PROGRAMS $<TARGET_FILE:OpenCL-ROCm>
++        DESTINATION lib
+         COMPONENT MAIN)
+-install(PROGRAMS $<TARGET_SONAME_FILE:OpenCL>
+-        DESTINATION lib/x86_64
++install(PROGRAMS $<TARGET_SONAME_FILE:OpenCL-ROCm>
++        DESTINATION lib
+         COMPONENT MAIN)
+ 
+ # DEV package
+ install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/api/opencl/khronos/headers/opencl2.2/CL"
+-        DESTINATION include
++	DESTINATION include/rocm
+         COMPONENT DEV
+         USE_SOURCE_PERMISSIONS
+         PATTERN cl_d3d10.h EXCLUDE
+         PATTERN cl_d3d11.h EXCLUDE
+         PATTERN cl_dx9_media_sharing.h EXCLUDE
+         PATTERN cl_egl.h EXCLUDE)
+-install(PROGRAMS $<TARGET_LINKER_FILE:OpenCL>
+-        DESTINATION lib/x86_64
++install(PROGRAMS $<TARGET_LINKER_FILE:OpenCL-ROCm>
++        DESTINATION lib
+         COMPONENT DEV)
+ 
+ # Generic CPACK variables
+--- ROCm-OpenCL-Runtime-roc-3.3.0/tools/clinfo/CMakeLists.txt	2020-04-28 07:29:51.882446535 -0400
++++ ROCm-OpenCL-Runtime-roc-3.3.0/tools/clinfo/CMakeLists.txt	2020-04-28 07:30:05.627394732 -0400
+@@ -6,6 +6,6 @@
+ 
+ add_definitions(-DHAVE_CL2_HPP)
+ 
+-add_executable(clinfo clinfo.cpp)
++add_executable(rocm-clinfo clinfo.cpp)
+ 
+-target_link_libraries(clinfo OpenCL)
++target_link_libraries(rocm-clinfo OpenCL-ROCm)
diff --git a/srcpkgs/ROCm-OpenCL-Runtime/template b/srcpkgs/ROCm-OpenCL-Runtime/template
new file mode 100644
index 00000000000..f6699a1d4c0
--- /dev/null
+++ b/srcpkgs/ROCm-OpenCL-Runtime/template
@@ -0,0 +1,84 @@
+# Template file for 'ROCm-OpenCL-Runtime'
+pkgname=ROCm-OpenCL-Runtime
+version=3.3.0
+revision=1
+_ocl_icd_name="OpenCL-ICD-Loader"
+_ocl_icd_ver="6c03f8b58fafd9dd693eaac826749a5cfad515f8"
+archs="x86_64*"
+create_wrksrc=yes
+build_wrksrc="${pkgname}-roc-${version}"
+build_style=cmake
+configure_args="-DUSE_COMGR_LIBRARY=yes"
+hostmakedepends="cmake pkg-config"
+makedepends="libglvnd-devel ROCm-CompilerSupport-devel
+	ROCT-Thunk-Interface-devel ROCR-Runtime-devel"
+depends="ROCm-CompilerSupport"
+short_desc="Radeon Open Compute OpenCL runtime"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="MIT"
+homepage="https://github.com/RadeonOpenCompute/ROCm-OpenCL-Runtime"
+_rocroot="https://github.com/RadeonOpenCompute"
+distfiles="${_rocroot}/ROCm-OpenCL-Runtime/archive/roc-${version}.tar.gz
+	${_rocroot}/rocm-cmake/archive/rocm-${version}.tar.gz
+	https://github.com/KhronosGroup/${_ocl_icd_name}/archive/${_ocl_icd_ver}.tar.gz"
+checksum="ac6999f1a491ab066286c2bd6adf50f08f831286f56e267879f9f7eced22f98e
+	76ed3ee8e56cf3246011cf7723c2abda539e1136e7e7f6909bfa45d268b8644f
+	c94d5bb6dc980c4d41d73e2b81663a19aabe494e923e2d0eec72a4c95b318438"
+nocross=yes
+
+if [ "$XBPS_LIBC" = "musl" ]; then
+	makedepends+=" musl-legacy-compat"
+fi
+
+post_patch() {
+	if [ "$XBPS_LIBC" = "musl" ]; then
+		# Remove dependence on glibc
+		patch -Np0 < ${FILESDIR}/libelf-musl.patch
+		patch -Np0 < ${FILESDIR}/runtime-musl.patch
+		vsed -e '/glibc_functions.cpp/d' -i api/opencl/amdocl/CMakeLists.txt
+	fi
+}
+
+pre_configure() {
+	# ROCm requires a very specific Khronos ICD loader version in the tree
+	# Keep the ICD loader config in /etc/OpenCL/rocm-vendors to avoid conflicts
+	_ocl_icd_dir="${_ocl_icd_name}-${_ocl_icd_ver}"
+	ln -sf "${wrksrc}/${_ocl_icd_dir}" api/opencl/khronos/icd
+	vsed -i "${wrksrc}/${_ocl_icd_dir}/loader/icd_platform.h" \
+		-e 's@/etc/OpenCL/vendors/@/etc/OpenCL/rocm-vendors/@g'
+
+	# CMake modules probably not useful anywhere but for this build
+	ln -sf "${wrksrc}/rocm-cmake-rocm-${version}/share/rocm/cmake"/*.cmake cmake
+
+	# Fix the dlopen macro to point to versioned libamd_comgr shared object
+	vsed -i 'runtime/device/comgrctx.cpp' \
+		-e 's/\blibamd_comgr\(32\)\?.so\b/&.1/g'
+}
+
+post_install() {
+	vlicense License
+
+	# Create descriptor to allow the ICD loader to find the driver
+	vmkdir etc/OpenCL/rocm-vendors
+	echo "libamdocl64.so" > "${DESTDIR}/etc/OpenCL/rocm-vendors/amdocl64.icd"
+	vmkdir etc/OpenCL/vendors
+	ln -s ../../OpenCL/rocm-vendors/amdocl64.icd \
+		${DESTDIR}/etc/OpenCL/vendors/rocm-amdocl64.icd
+}
+
+ROCm-OpenCL-Runtime-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/lib/libOpenCL-ROCm.so
+		vmove usr/include
+	}
+}
+
+ROCm-OpenCL-Runtime-clinfo_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - clinfo"
+	pkg_install() {
+		vmove usr/bin/rocm-clinfo
+	}
+}
diff --git a/srcpkgs/ROCm-OpenCL-Runtime/update b/srcpkgs/ROCm-OpenCL-Runtime/update
new file mode 100644
index 00000000000..8385f4d1215
--- /dev/null
+++ b/srcpkgs/ROCm-OpenCL-Runtime/update
@@ -0,0 +1 @@
+pattern='roc-\K[\d.]+'

From 26a8eaa13fd34b4531f5cd902bd38a2b6319a3c7 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Thu, 30 Apr 2020 13:11:12 -0400
Subject: [PATCH 09/10] New package: ROCR-Runtime-hsa-ext-3.3.0

---
 common/shlibs                         |  2 ++
 srcpkgs/ROCR-Runtime-hsa-ext-devel    |  1 +
 srcpkgs/ROCR-Runtime-hsa-ext/template | 42 +++++++++++++++++++++++++++
 srcpkgs/ROCR-Runtime-hsa-ext/update   |  2 ++
 4 files changed, 47 insertions(+)
 create mode 120000 srcpkgs/ROCR-Runtime-hsa-ext-devel
 create mode 100644 srcpkgs/ROCR-Runtime-hsa-ext/template
 create mode 100644 srcpkgs/ROCR-Runtime-hsa-ext/update

diff --git a/common/shlibs b/common/shlibs
index a612449ad1f..151c92e4be1 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3867,3 +3867,5 @@ libhsa-runtime64.so.1 ROCR-Runtime-3.3.0_1
 libamd_comgr.so.1 ROCm-CompilerSupport-3.3.0_1
 libOpenCL-ROCm.so.1 ROCm-OpenCL-Runtime-3.3.0_1
 libamdocl64.so ROCm-OpenCL-Runtime-3.3.0_1
+libhsa-ext-image64.so.1 ROCR-Runtime-hsa-ext-3.3.0_1
+libhsa-runtime-tools64.so.1 ROCR-Runtime-hsa-ext-3.3.0_1
diff --git a/srcpkgs/ROCR-Runtime-hsa-ext-devel b/srcpkgs/ROCR-Runtime-hsa-ext-devel
new file mode 120000
index 00000000000..6ee1b14911b
--- /dev/null
+++ b/srcpkgs/ROCR-Runtime-hsa-ext-devel
@@ -0,0 +1 @@
+ROCR-Runtime-hsa-ext
\ No newline at end of file
diff --git a/srcpkgs/ROCR-Runtime-hsa-ext/template b/srcpkgs/ROCR-Runtime-hsa-ext/template
new file mode 100644
index 00000000000..475cad751de
--- /dev/null
+++ b/srcpkgs/ROCR-Runtime-hsa-ext/template
@@ -0,0 +1,42 @@
+# Template file for 'ROCR-Runtime-hsa-ext'
+pkgname=ROCR-Runtime-hsa-ext
+version=3.3.0
+revision=1
+archs="x86_64"
+hostmakedepends="tar"
+short_desc="Radeon Open Compute HSA runtime extensions"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute"
+_hsa_deb="hsa-ext-rocr-dev_1.1.30300.0-rocm-rel-3.3-19-23fc088b_amd64.deb"
+distfiles="https://repo.radeon.com/rocm/apt/debian/pool/main/h/hsa-ext-rocr-dev/$_hsa_deb"
+checksum=6b44e286b395d946b865ec1f3cc546356396785ac1fde591d07af02d0aa7c25d
+repository=nonfree
+
+do_extract() {
+	ar x "${XBPS_SRCDISTDIR}/${pkgname}-${version}/${_hsa_deb}"
+	tar xvf data.tar.gz
+}
+
+do_install() {
+	_rocm_includes="opt/rocm-${version}/hsa/include"
+
+	vmkdir usr
+	vcopy opt/rocm-${version}/hsa/lib usr
+	vcopy "$_rocm_includes" usr
+
+	# Extract license from one of the header files
+	awk 'BEGIN{HEADER=0} /\/\//{HEADER=1; print $0;} /^[^/]/{if(HEADER==1) exit;}' \
+		< "${_rocm_includes}/hsa/amd_hsa_tools_interfaces.h" \
+		| sed 's@^///*\( \|$\)@@' > LICENSE
+	vlicense LICENSE
+}
+
+ROCR-Runtime-hsa-ext-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove "usr/lib/*.so"
+	}
+}
diff --git a/srcpkgs/ROCR-Runtime-hsa-ext/update b/srcpkgs/ROCR-Runtime-hsa-ext/update
new file mode 100644
index 00000000000..84252d2e3b8
--- /dev/null
+++ b/srcpkgs/ROCR-Runtime-hsa-ext/update
@@ -0,0 +1,2 @@
+site='https://repo.radeon.com/rocm/apt/debian/pool/main/h/'
+pattern='hsa-ext-rocr-dev\K[\d.]+'

From b5d10ba975512a845ec1daa9f72811eb37a826e7 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Tue, 28 Apr 2020 13:33:46 -0400
Subject: [PATCH 10/10] hashcat: add build option to link against ROCm [ci
 skip]

---
 srcpkgs/hashcat/files/rocm.patch     | 15 +++++++++++++++
 srcpkgs/hashcat/patches/tmpdir.patch | 21 +++++++++++++++++++++
 srcpkgs/hashcat/template             | 17 ++++++++++++++---
 3 files changed, 50 insertions(+), 3 deletions(-)
 create mode 100644 srcpkgs/hashcat/files/rocm.patch
 create mode 100644 srcpkgs/hashcat/patches/tmpdir.patch

diff --git a/srcpkgs/hashcat/files/rocm.patch b/srcpkgs/hashcat/files/rocm.patch
new file mode 100644
index 00000000000..f1e899d30ee
--- /dev/null
+++ b/srcpkgs/hashcat/files/rocm.patch
@@ -0,0 +1,15 @@
+diff -ur a/src/opencl.c b/src/opencl.c
+--- a/src/opencl.c	2018-12-02 05:58:48.000000000 -0500
++++ b/src/opencl.c	2020-04-28 13:24:12.602415333 -0400
+@@ -492,9 +492,9 @@
+ 
+   if (ocl->lib == NULL) ocl->lib = hc_dlopen ("cygOpenCL-1.dll", RTLD_NOW);
+   #else
+-  ocl->lib = hc_dlopen ("libOpenCL.so", RTLD_NOW);
++  ocl->lib = hc_dlopen ("libOpenCL-ROCm.so.1", RTLD_NOW);
+ 
+-  if (ocl->lib == NULL) ocl->lib = hc_dlopen ("libOpenCL.so.1", RTLD_NOW);
++  if (ocl->lib == NULL) ocl->lib = hc_dlopen ("libOpenCL-ROCm.so", RTLD_NOW);
+   #endif
+ 
+   if (ocl->lib == NULL)
diff --git a/srcpkgs/hashcat/patches/tmpdir.patch b/srcpkgs/hashcat/patches/tmpdir.patch
new file mode 100644
index 00000000000..0558a001c9c
--- /dev/null
+++ b/srcpkgs/hashcat/patches/tmpdir.patch
@@ -0,0 +1,21 @@
+Addresses https://github.com/hashcat/hashcat/issues/2379
+diff -ur a/src/folder.c b/src/folder.c
+--- src/folder.c	2018-12-02 05:58:48.000000000 -0500
++++ src/folder.c	2020-04-28 13:22:27.340522751 -0400
+@@ -457,16 +457,6 @@
+ 
+   hcfree (cpath);
+ 
+-  //if (getenv ("TMP") == NULL)
+-  if (1)
+-  {
+-    char *tmp;
+-
+-    hc_asprintf (&tmp, "TMP=%s", cpath_real);
+-
+-    putenv (tmp);
+-  }
+-
+   #if defined (_WIN)
+ 
+   naive_replace (cpath_real, '\\', '/');
diff --git a/srcpkgs/hashcat/template b/srcpkgs/hashcat/template
index e982f99cebf..3f19be5e41d 100644
--- a/srcpkgs/hashcat/template
+++ b/srcpkgs/hashcat/template
@@ -1,15 +1,16 @@
 # Template file for 'hashcat'
 pkgname=hashcat
 version=5.1.0
-revision=2
+revision=3
 build_style=gnu-makefile
 make_build_args="PREFIX=/usr
  USE_SYSTEM_OPENCL=1 USE_SYSTEM_XXHASH=1
- DEPS_OPENCL_PATH=${XBPS_CROSS_BASE}/usr/include
+ DEPS_OPENCL_PATH=${XBPS_CROSS_BASE}/usr/include$(vopt_if rocm /rocm)
  DEPS_XXHASH_PATH=${XBPS_CROSS_BASE}/usr/include"
 make_use_env=yes
 make_install_args="$make_build_args"
-makedepends="gmp-devel opencl2-headers xxHash-devel"
+makedepends="gmp-devel xxHash-devel
+ $(vopt_if rocm ROCm-OpenCL-Runtime-devel opencl2-headers)"
 checkdepends="perl"
 short_desc="Advanced CPU-based password recovery utility"
 maintainer="Duncaen <duncaen@voidlinux.org>"
@@ -19,6 +20,9 @@ changelog="https://raw.githubusercontent.com/hashcat/hashcat/master/docs/changes
 distfiles="https://hashcat.net/files/hashcat-${version}.tar.gz"
 checksum=283beaa68e1eab41de080a58bb92349c8e47a2bb1b93d10f36ea30f418f1e338
 
+build_options="rocm"
+desc_option_rocm="Use ROCm OpenCL runtime"
+
 if [ "$XBPS_TARGET_ENDIAN" = "be" ]; then
 	broken="Not supported on big endian"
 fi
@@ -26,6 +30,13 @@ fi
 post_extract() {
 	sed '/^CC/d' -i src/Makefile
 }
+
+post_patch() {
+	if [ "$build_option_rocm" ]; then
+		patch -Np1 < ${FILESDIR}/rocm.patch
+	fi
+}
+
 post_install() {
 	rm -f ${DESTDIR}/usr/share/docs/hashcat/license.txt
 	vlicense docs/license.txt

^ permalink raw reply	[flat|nested] 61+ messages in thread

* Re: [PR PATCH] [Updated] New packages: ROCm core and OpenCL
  2020-04-19 13:34 [PR PATCH] New packages: ROCm core and OpenCL ahesford
                   ` (24 preceding siblings ...)
  2020-05-02  3:29 ` ahesford
@ 2020-05-05 14:24 ` ahesford
  2020-05-05 14:26 ` ahesford
                   ` (33 subsequent siblings)
  59 siblings, 0 replies; 61+ messages in thread
From: ahesford @ 2020-05-05 14:24 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 3893 bytes --]

There is an updated pull request by ahesford against master on the void-packages repository

https://github.com/ahesford/void-packages rocm
https://github.com/void-linux/void-packages/pull/21153

New packages: ROCm core and OpenCL
This PR includes several packages designed to bring the OpenCL portion of the AMD ROCm ecosystem to Void. It addresses Issue #19507. There are many other packages that AMD provides for GPGPU computing, but these can be added piecemeal as users demand.

The packages are currently only for `x86_64*`. While at least some of the packages will compile on other 64-bit architectures, I have no hardware to test. They are certainly not suitable for 32-bit architectures; some internal data structures rely on `uint64_t` values that are cast to pointers. At a
minimum, a thorough audit would be necessary to ensure that these casts are safe (e.g., that the values stored were only ever upcast from 32-bit pointers). More extensive work may be necessary to support 32-bit architectures, probably without significant benefit.

The packages successfully identify a Radeon RX 580 on an `x86_64` installation using both `clinfo` and `rocminfo` as provided. Furthermore, a version of `pyopencl` linked against these ROCm packages successfully runs a simple program that validates arithmetic on GPU-bound arrays.

There are caveats with this set of packages, almost all of which revolve around the incompatibilities between the Void-provided `ocl-icd` and the [Khronos OpenCL ICD loader](https://github.com/KhronosGroup/OpenCL-ID-Loader) required by (and built into) `rocm-opencl-runtime`.
1. All packages install into `/opt/rocm`. This keeps the environment closer to that officially sanctioned by AMD and helps avoid conflicts between other packages and those provided here. (For example, `clinfo` and the ICD loader itself.) Eventually, we may be able to move the files into `/usr`.
2. The Khronos OpenCL ICD loader built into `rocm-opencl-runtime` is an outdated, pre-release commit. If AMD can update its sources to use the release version of that loader (which has a backward-incompatible API change), we may be able to make ROCm compatible with `ocl-icd` or replace `ocl-icd` with the official Khronos loader.
3. In the meantime, to avoid `shlibs` conflicts, the OpenCL ICD loader is installed as `/opt/rocm/lib/libOpenCL-ROCm.so` (and an appropriately versioned shared library), which means that programs wishing to use the ROCm OpenCL must explicitly link against this library instead of the generic `libOpenCL.so`.
4. I do **not** recommend making any Void packages link against this specific library, because it will make those packages ROCm-only. For the time being, ROCm is intended for end-users to specifically link against. Linking Void packages against ROCm would requires the ICD loader used by ROCm be compatible with `ocl-icd`, or `ocl-icd` be replaced by the Khronos loader. However, because the Khronos loader changed its API for the release version, such a change is not yet appropriate.

Hopefully, if AMD updates its dependence on the Khronos ICD loader, we can resolve some of these caveats in the future and make ROCm a more natural Void component. For now, these packages are useful for those who need an AMD OpenCL solution and would rather custom-link software against the AMD ICD loader than hack the `amdgpu-pro` driver into an ICD compatible with `ocl-icd`.

Some patches were made to relocate some files in `/opt/rocm` and make everyting build on x86_64-musl`. Where appropriate, these patches will be pushed upstream to clean up the distribution and packaging.

Update: I pushed some new commits to update license information that triggerd an `xlint` failure. I've also disabled CI builds because they will time out on `rocm-llvm`.

A patch file from https://github.com/void-linux/void-packages/pull/21153.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-rocm-21153.patch --]
[-- Type: text/x-diff, Size: 38985 bytes --]

From cc86dec132a842cb6adbcf601c3947c782b4e086 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Mon, 13 Apr 2020 13:08:09 -0400
Subject: [PATCH 01/10] New package: ROCT-Thunk-Interface-3.3.0

---
 common/shlibs                                 |  1 +
 srcpkgs/ROCT-Thunk-Interface-devel            |  1 +
 .../patches/cmake-dev-libdir.patch            | 10 ++++++
 .../ROCT-Thunk-Interface/patches/musl.patch   | 29 ++++++++++++++++
 srcpkgs/ROCT-Thunk-Interface/template         | 33 +++++++++++++++++++
 srcpkgs/ROCT-Thunk-Interface/update           |  1 +
 6 files changed, 75 insertions(+)
 create mode 120000 srcpkgs/ROCT-Thunk-Interface-devel
 create mode 100644 srcpkgs/ROCT-Thunk-Interface/patches/cmake-dev-libdir.patch
 create mode 100644 srcpkgs/ROCT-Thunk-Interface/patches/musl.patch
 create mode 100644 srcpkgs/ROCT-Thunk-Interface/template
 create mode 100644 srcpkgs/ROCT-Thunk-Interface/update

diff --git a/common/shlibs b/common/shlibs
index 7a1e5b5d5eb..906dc414723 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3876,3 +3876,4 @@ libhidrd_opt.so.0 hidrd-0.2.0_1
 libhidrd_strm.so.0 hidrd-0.2.0_1
 libhidrd_fmt.so.0 hidrd-0.2.0_1
 
+libhsakmt.so.1 ROCT-Thunk-Interface-3.3.0_1
diff --git a/srcpkgs/ROCT-Thunk-Interface-devel b/srcpkgs/ROCT-Thunk-Interface-devel
new file mode 120000
index 00000000000..7e43c209e3d
--- /dev/null
+++ b/srcpkgs/ROCT-Thunk-Interface-devel
@@ -0,0 +1 @@
+ROCT-Thunk-Interface
\ No newline at end of file
diff --git a/srcpkgs/ROCT-Thunk-Interface/patches/cmake-dev-libdir.patch b/srcpkgs/ROCT-Thunk-Interface/patches/cmake-dev-libdir.patch
new file mode 100644
index 00000000000..98c7f1e459c
--- /dev/null
+++ b/srcpkgs/ROCT-Thunk-Interface/patches/cmake-dev-libdir.patch
@@ -0,0 +1,10 @@
+--- CMakeLists.txt.old	2020-04-18 19:45:17.306081135 -0400
++++ CMakeLists.txt	2020-04-18 19:46:51.300753636 -0400
+@@ -146,6 +146,7 @@
+     COMMAND ${CMAKE_COMMAND}
+         -DSOURCE_DIR="${SOURCE_DIR}"
+         -DCMAKE_INSTALL_PREFIX="${CMAKE_INSTALL_PREFIX}"
++        -DCMAKE_INSTALL_LIBDIR="${CMAKE_INSTALL_LIBDIR}"
+         -DCPACK_RPM_PACKAGE_REQUIRES="hsakmt-roct"
+         -DCPACK_PACKAGING_INSTALL_PREFIX="${CPACK_PACKAGING_INSTALL_PREFIX}"
+         -DVERSION="${BUILD_VERSION_STRING}"
diff --git a/srcpkgs/ROCT-Thunk-Interface/patches/musl.patch b/srcpkgs/ROCT-Thunk-Interface/patches/musl.patch
new file mode 100644
index 00000000000..aeea9832411
--- /dev/null
+++ b/srcpkgs/ROCT-Thunk-Interface/patches/musl.patch
@@ -0,0 +1,29 @@
+diff -r -u old/src/libhsakmt.h new/src/libhsakmt.h
+--- src/libhsakmt.h	2020-03-04 15:00:47.000000000 -0500
++++ src/libhsakmt.h	2020-04-13 12:58:30.444865992 -0400
+@@ -54,6 +54,10 @@
+ #define CHECK_KFD_OPEN() \
+ 	do { if (kfd_open_count == 0 || hsakmt_forked) return HSAKMT_STATUS_KERNEL_IO_CHANNEL_NOT_OPENED; } while (0)
+ 
++/*On some platforms, a PAGE_SIZE macro eclipses the extern variable*/
++#ifdef PAGE_SIZE
++#undef PAGE_SIZE
++#endif
+ extern int PAGE_SIZE;
+ extern int PAGE_SHIFT;
+ 
+diff -r -u old/src/topology.c new/src/topology.c
+--- src/topology.c	2020-03-04 15:00:47.000000000 -0500
++++ src/topology.c	2020-04-13 13:01:31.209870701 -0400
+@@ -38,6 +38,11 @@
+ #include "libhsakmt.h"
+ #include "fmm.h"
+ 
++/*Needed on MUSL*/
++#ifndef MAXNAMLEN
++#define MAXNAMLEN PATH_MAX
++#endif
++
+ /* Number of memory banks added by thunk on top of topology
+  * This only includes static heaps like LDS, scratch and SVM,
+  * not for MMIO_REMAP heap. MMIO_REMAP memory bank is reported
diff --git a/srcpkgs/ROCT-Thunk-Interface/template b/srcpkgs/ROCT-Thunk-Interface/template
new file mode 100644
index 00000000000..8c680b2af29
--- /dev/null
+++ b/srcpkgs/ROCT-Thunk-Interface/template
@@ -0,0 +1,33 @@
+# Template file for 'ROCT-Thunk-Interface'
+pkgname=ROCT-Thunk-Interface
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="${pkgname}-roc-${version}"
+build_style=cmake
+make_build_target="all build-dev"
+make_install_target="install install-dev"
+hostmakedepends="cmake pkg-config"
+makedepends="pciutils-devel libnuma-devel"
+short_desc="Radeon Open Compute thunk interface"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="MIT"
+homepage="https://github.com/RadeonOpenCompute/ROCT-Thunk-Interface"
+distfiles="${homepage}/archive/roc-${version}.tar.gz"
+checksum=2cabe9d2cfa72031c05d11290837c476182e72d8dec2049298f691143fdd212b
+nocross=yes
+
+post_install() {
+	vlicense LICENSE.md
+}
+
+ROCT-Thunk-Interface-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove "usr/lib/*.so"
+		vmove usr/share/pkgconfig
+		vmove usr/lib/cmake
+	}
+}
diff --git a/srcpkgs/ROCT-Thunk-Interface/update b/srcpkgs/ROCT-Thunk-Interface/update
new file mode 100644
index 00000000000..8385f4d1215
--- /dev/null
+++ b/srcpkgs/ROCT-Thunk-Interface/update
@@ -0,0 +1 @@
+pattern='roc-\K[\d.]+'

From 0c958bb84f8a78b11df9f60547421c8253224f6a Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Mon, 13 Apr 2020 15:27:27 -0400
Subject: [PATCH 02/10] New package: ROCR-Runtime-3.3.0

---
 common/shlibs                            |  1 +
 srcpkgs/ROCR-Runtime-devel               |  1 +
 srcpkgs/ROCR-Runtime/patches/cmake.patch | 27 +++++++++++++++++++++
 srcpkgs/ROCR-Runtime/template            | 30 ++++++++++++++++++++++++
 srcpkgs/ROCR-Runtime/update              |  1 +
 5 files changed, 60 insertions(+)
 create mode 120000 srcpkgs/ROCR-Runtime-devel
 create mode 100644 srcpkgs/ROCR-Runtime/patches/cmake.patch
 create mode 100644 srcpkgs/ROCR-Runtime/template
 create mode 100644 srcpkgs/ROCR-Runtime/update

diff --git a/common/shlibs b/common/shlibs
index 906dc414723..2efbbb7b3b6 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3877,3 +3877,4 @@ libhidrd_strm.so.0 hidrd-0.2.0_1
 libhidrd_fmt.so.0 hidrd-0.2.0_1
 
 libhsakmt.so.1 ROCT-Thunk-Interface-3.3.0_1
+libhsa-runtime64.so.1 ROCR-Runtime-3.3.0_1
diff --git a/srcpkgs/ROCR-Runtime-devel b/srcpkgs/ROCR-Runtime-devel
new file mode 120000
index 00000000000..a733fb9fbab
--- /dev/null
+++ b/srcpkgs/ROCR-Runtime-devel
@@ -0,0 +1 @@
+ROCR-Runtime
\ No newline at end of file
diff --git a/srcpkgs/ROCR-Runtime/patches/cmake.patch b/srcpkgs/ROCR-Runtime/patches/cmake.patch
new file mode 100644
index 00000000000..93b74cd2297
--- /dev/null
+++ b/srcpkgs/ROCR-Runtime/patches/cmake.patch
@@ -0,0 +1,27 @@
+--- src/CMakeLists.txt.old	2020-04-18 20:01:48.549636995 -0400
++++ src/CMakeLists.txt	2020-04-18 20:04:00.177179781 -0400
+@@ -108,8 +108,8 @@
+ ## ROCr build internal versioning
+ add_definitions ( -DROCR_BUILD_ID=${PACKAGE_VERSION_STRING} )
+ 
+-## Set RUNPATH - ../../lib covers use of the legacy symlink in /hsa/lib/
+-set(CMAKE_INSTALL_RPATH "$ORIGIN;$ORIGIN/../../lib;$ORIGIN/../../lib64;$ORIGIN/../lib64")
++## Set RUNPATH
++set(CMAKE_INSTALL_RPATH "$ORIGIN;$ORIGIN/../lib")
+ 
+ ## ------------------------- Linux Compiler and Linker options -------------------------
+ set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -fexceptions -fno-rtti -fvisibility=hidden -Wno-error=sign-compare -Wno-sign-compare -Wno-write-strings -Wno-conversion-null -fno-math-errno -fno-threadsafe-statics -fmerge-all-constants -fms-extensions -Wno-error=comment -Wno-comment -Wno-error=pointer-arith -Wno-pointer-arith -Wno-error=unused-variable -Wno-error=unused-function" )
+@@ -185,11 +185,8 @@
+ add_custom_target ( hsa_lib_link2 ALL WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMAND ${CMAKE_COMMAND} -E create_symlink ../hsa/lib/${CORE_RUNTIME_LIBRARY}.so.${SO_MAJOR} ${CORE_RUNTIME_LIBRARY}-link.so.${SO_MAJOR} )
+ 
+ ## Set install information
+-install ( TARGETS ${CORE_RUNTIME_TARGET} LIBRARY DESTINATION hsa/lib )
+-install ( DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/inc/ DESTINATION hsa/include/hsa )
+-install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/hsa_include_link DESTINATION include PERMISSIONS OWNER_WRITE OWNER_READ RENAME hsa )
+-install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/${CORE_RUNTIME_LIBRARY}-link.so DESTINATION lib PERMISSIONS OWNER_WRITE OWNER_READ RENAME ${CORE_RUNTIME_LIBRARY}.so )
+-install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/${CORE_RUNTIME_LIBRARY}-link.so.${SO_MAJOR} DESTINATION lib PERMISSIONS OWNER_WRITE OWNER_READ RENAME ${CORE_RUNTIME_LIBRARY}.so.${SO_MAJOR} )
++install ( TARGETS ${CORE_RUNTIME_TARGET} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} )
++install ( DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/inc/ DESTINATION include/hsa )
+ 
+ ## Packaging directives
+ set ( CPACK_GENERATOR "DEB;RPM" CACHE STRING "Package types to build")
diff --git a/srcpkgs/ROCR-Runtime/template b/srcpkgs/ROCR-Runtime/template
new file mode 100644
index 00000000000..95b7e701afb
--- /dev/null
+++ b/srcpkgs/ROCR-Runtime/template
@@ -0,0 +1,30 @@
+# Template file for 'ROCR-Runtime'
+pkgname=ROCR-Runtime
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="${pkgname}-rocm-${version}"
+build_wrksrc="src"
+build_style=cmake
+hostmakedepends="cmake pkg-config"
+makedepends="ROCT-Thunk-Interface-devel elfutils-devel"
+short_desc="Radeon Open Compute HSA runtime"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute/ROCR-Runtime"
+distfiles="${homepage}/archive/rocm-${version}.tar.gz"
+checksum=fa2d2d1f8a61d8a6952d377cf288d78c61776c3c2a666f163cafc3aa19ab0b61
+nocross=yes
+
+post_install() {
+	vlicense ../LICENSE.txt
+}
+
+ROCR-Runtime-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove "usr/lib/*.so"
+	}
+}
diff --git a/srcpkgs/ROCR-Runtime/update b/srcpkgs/ROCR-Runtime/update
new file mode 100644
index 00000000000..86197bc3eea
--- /dev/null
+++ b/srcpkgs/ROCR-Runtime/update
@@ -0,0 +1 @@
+pattern='rocm-\K[\d.]+'

From cabac50d551b9760dbc20effc0d4d05c7dfd922e Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Mon, 13 Apr 2020 18:07:34 -0400
Subject: [PATCH 03/10] New package: ROCm-llvm-3.3.0

---
 srcpkgs/ROCm-llvm/template | 26 ++++++++++++++++++++++++++
 srcpkgs/ROCm-llvm/update   |  1 +
 2 files changed, 27 insertions(+)
 create mode 100644 srcpkgs/ROCm-llvm/template
 create mode 100644 srcpkgs/ROCm-llvm/update

diff --git a/srcpkgs/ROCm-llvm/template b/srcpkgs/ROCm-llvm/template
new file mode 100644
index 00000000000..4c3095b21f4
--- /dev/null
+++ b/srcpkgs/ROCm-llvm/template
@@ -0,0 +1,26 @@
+# Template file for 'ROCm-llvm'
+pkgname=ROCm-llvm
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="llvm-project-rocm-ocl-${version}"
+build_wrksrc=llvm
+build_style=cmake
+configure_args="-DCMAKE_INSTALL_PREFIX:PATH=/usr/lib/rocm-llvm
+	-DLLVM_ENABLE_PROJECTS='llvm;clang;lld' -DLLVM_TARGETS_TO_BUILD='AMDGPU'
+	-DLLVM_BUILD_DOCS=NO -DLLVM_ENABLE_OCAMLDOC=OFF
+	-DLLVM_ENABLE_SPHINX=NO -DLLVM_ENABLE_DOXYGEN=OFF
+	-DLLVM_INSTALL_UTILS=ON -DLLVM_VERSION_SUFFIX=roc -DOCAMLFIND=NO"
+hostmakedepends="cmake pkg-config python3"
+short_desc="Radeon Open Compute LLVM toolchain"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="Apache-2.0, NCSA, custom:LLVM-Exceptions"
+homepage="https://github.com/RadeonOpenCompute/llvm-project"
+distfiles="${homepage}/archive/rocm-ocl-${version}.tar.gz"
+checksum=a2bef7042e8e2f2cd8548cb246b88322e1c77188839983dcac8312d56f544dc8
+python_version=3
+nocross=yes
+
+post_install() {
+	vlicense LICENSE.TXT
+}
diff --git a/srcpkgs/ROCm-llvm/update b/srcpkgs/ROCm-llvm/update
new file mode 100644
index 00000000000..6a73667d3c1
--- /dev/null
+++ b/srcpkgs/ROCm-llvm/update
@@ -0,0 +1 @@
+pattern='rocm-ocl-\K[\d.]+'

From b20a6d352b008c17d9ac51daee6ceb43ca3cf516 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Tue, 14 Apr 2020 10:25:31 -0400
Subject: [PATCH 04/10] New package: ROCm-Device-Libs-3.3.0

---
 srcpkgs/ROCm-Device-Libs/template | 37 +++++++++++++++++++++++++++++++
 srcpkgs/ROCm-Device-Libs/update   |  1 +
 2 files changed, 38 insertions(+)
 create mode 100644 srcpkgs/ROCm-Device-Libs/template
 create mode 100644 srcpkgs/ROCm-Device-Libs/update

diff --git a/srcpkgs/ROCm-Device-Libs/template b/srcpkgs/ROCm-Device-Libs/template
new file mode 100644
index 00000000000..8086cd86450
--- /dev/null
+++ b/srcpkgs/ROCm-Device-Libs/template
@@ -0,0 +1,37 @@
+# Template file for 'ROCm-Device-Libs'
+pkgname=ROCm-Device-Libs
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="${pkgname}-rocm-ocl-${version}"
+build_style=cmake
+configure_args="-DLLVM_DIR:PATH=/usr/lib/rocm-llvm
+	-DCMAKE_INSTALL_LIBDIR:PATH=lib/rocm-device-libs"
+hostmakedepends="cmake ROCm-llvm"
+short_desc="Radeon Open Compute device libraries"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute/ROCm-Device-Libs"
+distfiles="${homepage}/archive/rocm-ocl-${version}.tar.gz"
+checksum=706b08230790e08ca6a7a2fb7687d6131fd39a562148340e00fa37a6c06769c5
+nocross=yes
+
+pre_configure() {
+	# Put bytecodes in a lib/ subdirectory
+	vsed -i Packages.cmake -e 's@/lib/@/${CMAKE_INSTALL_LIBDIR}/@'
+	vsed -i OCL.cmake -e 's@DESTINATION lib$@DESTINATION ${CMAKE_INSTALL_LIBDIR}@'
+
+	# Build the prepare-builtins executable with native compiler
+	mkdir -p utils/build
+	cd utils/build
+	_prepare_builtins="$PWD/prepare-builtins/prepare-builtins"
+	cmake ${configure_args} ..
+	make ${makejobs}
+
+	# Add path to prepare-builtins for cmake
+	configure_args+=" -DPREPARE_BUILTINS='${_prepare_builtins}'"
+}
+
+post_install() {
+	vlicense LICENSE
+}
diff --git a/srcpkgs/ROCm-Device-Libs/update b/srcpkgs/ROCm-Device-Libs/update
new file mode 100644
index 00000000000..6a73667d3c1
--- /dev/null
+++ b/srcpkgs/ROCm-Device-Libs/update
@@ -0,0 +1 @@
+pattern='rocm-ocl-\K[\d.]+'

From 3a12101dabe2128199051190be69bdd88ba23360 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Mon, 13 Apr 2020 18:30:00 -0400
Subject: [PATCH 05/10] New package: ROCm-CompilerSupport-3.3.0

---
 common/shlibs                         |  1 +
 srcpkgs/ROCm-CompilerSupport-devel    |  1 +
 srcpkgs/ROCm-CompilerSupport/template | 32 +++++++++++++++++++++++++++
 srcpkgs/ROCm-CompilerSupport/update   |  1 +
 4 files changed, 35 insertions(+)
 create mode 120000 srcpkgs/ROCm-CompilerSupport-devel
 create mode 100644 srcpkgs/ROCm-CompilerSupport/template
 create mode 100644 srcpkgs/ROCm-CompilerSupport/update

diff --git a/common/shlibs b/common/shlibs
index 2efbbb7b3b6..570f135543f 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3878,3 +3878,4 @@ libhidrd_fmt.so.0 hidrd-0.2.0_1
 
 libhsakmt.so.1 ROCT-Thunk-Interface-3.3.0_1
 libhsa-runtime64.so.1 ROCR-Runtime-3.3.0_1
+libamd_comgr.so.1 ROCm-CompilerSupport-3.3.0_1
diff --git a/srcpkgs/ROCm-CompilerSupport-devel b/srcpkgs/ROCm-CompilerSupport-devel
new file mode 120000
index 00000000000..877aeafeeae
--- /dev/null
+++ b/srcpkgs/ROCm-CompilerSupport-devel
@@ -0,0 +1 @@
+ROCm-CompilerSupport
\ No newline at end of file
diff --git a/srcpkgs/ROCm-CompilerSupport/template b/srcpkgs/ROCm-CompilerSupport/template
new file mode 100644
index 00000000000..df56f7a3837
--- /dev/null
+++ b/srcpkgs/ROCm-CompilerSupport/template
@@ -0,0 +1,32 @@
+# Template file for 'ROCm-CompilerSupport'
+pkgname=ROCm-CompilerSupport
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="${pkgname}-rocm-${version}"
+build_wrksrc="lib/comgr"
+build_style=cmake
+configure_args="-DClang_DIR:PATH=/usr/lib/rocm-llvm/lib/cmake/clang"
+hostmakedepends="cmake pkg-config ROCm-llvm"
+makedepends="ROCm-Device-Libs"
+short_desc="Radeon Open Compute compiler support"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="BSD-3-Clause"
+homepage="https://github.com/RadeonOpenCompute/ROCm-CompilerSupport"
+distfiles="${homepage}/archive/rocm-${version}.tar.gz"
+checksum=01e2524e0f28ecd6f46c9720f279207de935d826b0172158792aa3ec86af9ca7
+nocross=yes
+
+post_install() {
+	vlicense LICENSE.txt
+}
+
+ROCm-CompilerSupport-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove "usr/lib/*.so"
+		vmove usr/lib/cmake
+	}
+}
diff --git a/srcpkgs/ROCm-CompilerSupport/update b/srcpkgs/ROCm-CompilerSupport/update
new file mode 100644
index 00000000000..86197bc3eea
--- /dev/null
+++ b/srcpkgs/ROCm-CompilerSupport/update
@@ -0,0 +1 @@
+pattern='rocm-\K[\d.]+'

From 89a16358639d4a718c11497f009cbd1934961e24 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Fri, 17 Apr 2020 12:11:25 -0400
Subject: [PATCH 06/10] New package: rocminfo-3.3.0

---
 srcpkgs/rocminfo/template | 22 ++++++++++++++++++++++
 srcpkgs/rocminfo/update   |  1 +
 2 files changed, 23 insertions(+)
 create mode 100644 srcpkgs/rocminfo/template
 create mode 100644 srcpkgs/rocminfo/update

diff --git a/srcpkgs/rocminfo/template b/srcpkgs/rocminfo/template
new file mode 100644
index 00000000000..7a075c7f7ac
--- /dev/null
+++ b/srcpkgs/rocminfo/template
@@ -0,0 +1,22 @@
+# Template file for 'rocminfo'
+pkgname=rocminfo
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="${pkgname}-rocm-${version}"
+build_style=cmake
+configure_args="-DROCM_DIR=/usr"
+hostmakedepends="cmake pkg-config"
+makedepends="ROCR-Runtime-devel"
+short_desc="Radeon Open Compute system information reporter"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute/rocminfo"
+distfiles="${homepage}/archive/rocm-${version}.tar.gz"
+checksum=e666f662c9e465aaabbbd0b109d87e017243cdf1a0898fabf5a90947bb3dbcd7
+nocross=yes
+python_version=3
+
+post_install() {
+	vlicense License.txt
+}
diff --git a/srcpkgs/rocminfo/update b/srcpkgs/rocminfo/update
new file mode 100644
index 00000000000..86197bc3eea
--- /dev/null
+++ b/srcpkgs/rocminfo/update
@@ -0,0 +1 @@
+pattern='rocm-\K[\d.]+'

From 20c364974c12e04383dbd37b5460fc0d92afed5e Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Sun, 19 Apr 2020 15:01:40 -0400
Subject: [PATCH 07/10] New package: rocm_bandwidth_test-3.3.0

---
 srcpkgs/rocm_bandwidth_test/template | 20 ++++++++++++++++++++
 srcpkgs/rocm_bandwidth_test/update   |  1 +
 2 files changed, 21 insertions(+)
 create mode 100644 srcpkgs/rocm_bandwidth_test/template
 create mode 100644 srcpkgs/rocm_bandwidth_test/update

diff --git a/srcpkgs/rocm_bandwidth_test/template b/srcpkgs/rocm_bandwidth_test/template
new file mode 100644
index 00000000000..6de7f2d6614
--- /dev/null
+++ b/srcpkgs/rocm_bandwidth_test/template
@@ -0,0 +1,20 @@
+# Template file for 'rocm_bandwidth_test'
+pkgname=rocm_bandwidth_test
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="${pkgname}-rocm-${version}"
+build_style=cmake
+hostmakedepends="cmake"
+makedepends="ROCR-Runtime-devel ROCT-Thunk-Interface-devel"
+short_desc="Radeon Open Compute bandwidth test"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute/rocm_bandwidth_test"
+distfiles="${homepage}/archive/rocm-${version}.tar.gz"
+checksum=f5f914073018619dc91662d5bf630903dfa4db9136d603591917fdfb3c9164ce
+nocross=yes
+
+post_install() {
+	vlicense LICENSE.txt
+}
diff --git a/srcpkgs/rocm_bandwidth_test/update b/srcpkgs/rocm_bandwidth_test/update
new file mode 100644
index 00000000000..86197bc3eea
--- /dev/null
+++ b/srcpkgs/rocm_bandwidth_test/update
@@ -0,0 +1 @@
+pattern='rocm-\K[\d.]+'

From 5ef5d3f43c6dc6773da9d9c052280f134ec83344 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Tue, 14 Apr 2020 10:25:54 -0400
Subject: [PATCH 08/10] New package: ROCm-OpenCL-Runtime-3.3.0

---
 common/shlibs                                 |   2 +
 srcpkgs/ROCm-OpenCL-Runtime-clinfo            |   1 +
 srcpkgs/ROCm-OpenCL-Runtime-devel             |   1 +
 .../files/libelf-musl.patch                   |  21 +++
 .../files/runtime-musl.patch                  |  11 ++
 .../ROCm-OpenCL-Runtime/patches/cmake.patch   | 126 ++++++++++++++++++
 srcpkgs/ROCm-OpenCL-Runtime/template          |  84 ++++++++++++
 srcpkgs/ROCm-OpenCL-Runtime/update            |   1 +
 8 files changed, 247 insertions(+)
 create mode 120000 srcpkgs/ROCm-OpenCL-Runtime-clinfo
 create mode 120000 srcpkgs/ROCm-OpenCL-Runtime-devel
 create mode 100644 srcpkgs/ROCm-OpenCL-Runtime/files/libelf-musl.patch
 create mode 100644 srcpkgs/ROCm-OpenCL-Runtime/files/runtime-musl.patch
 create mode 100644 srcpkgs/ROCm-OpenCL-Runtime/patches/cmake.patch
 create mode 100644 srcpkgs/ROCm-OpenCL-Runtime/template
 create mode 100644 srcpkgs/ROCm-OpenCL-Runtime/update

diff --git a/common/shlibs b/common/shlibs
index 570f135543f..6311c7612a7 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3879,3 +3879,5 @@ libhidrd_fmt.so.0 hidrd-0.2.0_1
 libhsakmt.so.1 ROCT-Thunk-Interface-3.3.0_1
 libhsa-runtime64.so.1 ROCR-Runtime-3.3.0_1
 libamd_comgr.so.1 ROCm-CompilerSupport-3.3.0_1
+libOpenCL-ROCm.so.1 ROCm-OpenCL-Runtime-3.3.0_1
+libamdocl64.so ROCm-OpenCL-Runtime-3.3.0_1
diff --git a/srcpkgs/ROCm-OpenCL-Runtime-clinfo b/srcpkgs/ROCm-OpenCL-Runtime-clinfo
new file mode 120000
index 00000000000..21f2041b8fb
--- /dev/null
+++ b/srcpkgs/ROCm-OpenCL-Runtime-clinfo
@@ -0,0 +1 @@
+ROCm-OpenCL-Runtime
\ No newline at end of file
diff --git a/srcpkgs/ROCm-OpenCL-Runtime-devel b/srcpkgs/ROCm-OpenCL-Runtime-devel
new file mode 120000
index 00000000000..21f2041b8fb
--- /dev/null
+++ b/srcpkgs/ROCm-OpenCL-Runtime-devel
@@ -0,0 +1 @@
+ROCm-OpenCL-Runtime
\ No newline at end of file
diff --git a/srcpkgs/ROCm-OpenCL-Runtime/files/libelf-musl.patch b/srcpkgs/ROCm-OpenCL-Runtime/files/libelf-musl.patch
new file mode 100644
index 00000000000..29469a9a351
--- /dev/null
+++ b/srcpkgs/ROCm-OpenCL-Runtime/files/libelf-musl.patch
@@ -0,0 +1,21 @@
+--- compiler/lib/loaders/elf/utils/libelf/_libelf.h	2020-04-28 15:50:53.243438174 -0400
++++ compiler/lib/loaders/elf/utils/libelf/_libelf.h	2020-04-28 15:51:54.293435415 -0400
+@@ -35,6 +35,7 @@
+ #include "_libelf_config.h"
+ 
+ #include "_elftc.h"
++#include <sys/cdefs.h>
+ 
+ /*
+  * Library-private data structures.
+--- compiler/lib/loaders/elf/utils/libelf/libelf.h	2020-04-28 15:50:53.244438174 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf.h	2020-04-28 15:52:12.375434593 -0400
+@@ -36,6 +36,8 @@
+ #define EM_HSAIL 0xAF5A
+ #endif
+ 
++#include <sys/cdefs.h>
++
+ /* Library private data structures */
+ typedef struct _Elf Elf;
+ typedef struct _Elf_Scn Elf_Scn;
diff --git a/srcpkgs/ROCm-OpenCL-Runtime/files/runtime-musl.patch b/srcpkgs/ROCm-OpenCL-Runtime/files/runtime-musl.patch
new file mode 100644
index 00000000000..ea18e90e09c
--- /dev/null
+++ b/srcpkgs/ROCm-OpenCL-Runtime/files/runtime-musl.patch
@@ -0,0 +1,11 @@
+--- runtime/os/os_posix.cpp.orig	2020-04-19 09:13:51.701982901 -0400
++++ runtime/os/os_posix.cpp	2020-04-19 09:14:04.156947422 -0400
+@@ -44,6 +44,8 @@
+ #include <algorithm>
+ #include <mutex>
+ 
++#include <libgen.h> // for basename
++
+ 
+ namespace amd {
+ 
diff --git a/srcpkgs/ROCm-OpenCL-Runtime/patches/cmake.patch b/srcpkgs/ROCm-OpenCL-Runtime/patches/cmake.patch
new file mode 100644
index 00000000000..2c96b99d45a
--- /dev/null
+++ b/srcpkgs/ROCm-OpenCL-Runtime/patches/cmake.patch
@@ -0,0 +1,126 @@
+--- OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/CMakeLists.txt	2019-09-10 11:53:28.000000000 -0400
++++ OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/CMakeLists.txt	2020-04-16 20:16:13.481180757 -0400
+@@ -73,11 +73,11 @@
+ 
+ set (OPENCL_ICD_LOADER_HEADERS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/inc CACHE PATH "Path to OpenCL Headers")
+ 
+-add_library (OpenCL ${OPENCL_ICD_LOADER_SOURCES})
+-set_target_properties (OpenCL PROPERTIES VERSION "1.2" SOVERSION "1")
++add_library (OpenCL-ROCm ${OPENCL_ICD_LOADER_SOURCES})
++set_target_properties (OpenCL-ROCm PROPERTIES VERSION "1.2" SOVERSION "1")
+ 
+ if (WIN32)
+-    target_link_libraries (OpenCL cfgmgr32.lib)
++    target_link_libraries (OpenCL-ROCm cfgmgr32.lib)
+ 
+     option (OPENCL_ICD_LOADER_REQUIRE_WDK "Build with D3DKMT support, which requires the Windows WDK." ON)
+     if (OPENCL_ICD_LOADER_REQUIRE_WDK)
+@@ -92,10 +92,10 @@
+             get_filename_component(WDK_DIRECTORY ${LATEST_D3DKMT_HEADER} DIRECTORY)
+             get_filename_component(WDK_DIRECTORY ${WDK_DIRECTORY} DIRECTORY)
+             message(STATUS "Found the Windows WDK in: ${WDK_DIRECTORY}")
+-            target_compile_definitions(OpenCL PRIVATE OPENCL_ICD_LOADER_REQUIRE_WDK)
+-            target_include_directories(OpenCL PRIVATE ${WDK_DIRECTORY}/um)
+-            target_include_directories(OpenCL PRIVATE ${WDK_DIRECTORY}/km)
+-            target_include_directories(OpenCL PRIVATE ${WDK_DIRECTORY}/shared)
++	    target_compile_definitions(OpenCL-ROCm PRIVATE OPENCL_ICD_LOADER_REQUIRE_WDK)
++	    target_include_directories(OpenCL-ROCm PRIVATE ${WDK_DIRECTORY}/um)
++	    target_include_directories(OpenCL-ROCm PRIVATE ${WDK_DIRECTORY}/km)
++	    target_include_directories(OpenCL-ROCm PRIVATE ${WDK_DIRECTORY}/shared)
+         else()
+             message(FATAL_ERROR "The Windows WDK was not found. Consider disabling OPENCL_ICD_LOADER_REQUIRE_WDK. Aborting.")
+         endif()
+@@ -113,25 +113,25 @@
+     endif()
+ else()
+     if (APPLE)
+-        target_link_libraries (OpenCL ${CMAKE_THREAD_LIBS_INIT})
++        target_link_libraries (OpenCL-ROCm ${CMAKE_THREAD_LIBS_INIT})
+     else ()
+-        set_target_properties (OpenCL PROPERTIES LINK_FLAGS "-Wl,--version-script -Wl,${CMAKE_CURRENT_SOURCE_DIR}/loader/linux/icd_exports.map")
+-        target_link_libraries (OpenCL ${CMAKE_THREAD_LIBS_INIT})
++        set_target_properties (OpenCL-ROCm PROPERTIES LINK_FLAGS "-Wl,--version-script -Wl,${CMAKE_CURRENT_SOURCE_DIR}/loader/linux/icd_exports.map")
++	target_link_libraries (OpenCL-ROCm ${CMAKE_THREAD_LIBS_INIT})
+     endif ()
+ endif ()
+ 
+ include_directories (${OPENCL_ICD_LOADER_HEADERS_DIR})
+ add_definitions (-DCL_TARGET_OPENCL_VERSION=220)
+ 
+-target_include_directories (OpenCL PRIVATE ${CMAKE_CURRENT_BINARY_DIR} loader)
+-target_link_libraries (OpenCL ${CMAKE_DL_LIBS})
++target_include_directories (OpenCL-ROCm PRIVATE ${CMAKE_CURRENT_BINARY_DIR} loader)
++target_link_libraries (OpenCL-ROCm ${CMAKE_DL_LIBS})
+ 
+ include (CTest)
+ if (BUILD_TESTING)
+     add_subdirectory (test)
+ endif()
+ 
+-install (TARGETS OpenCL
++install (TARGETS OpenCL-ROCm
+     RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+     ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
+     LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
+--- OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/test/loader_test/CMakeLists.txt	2019-09-10 11:53:28.000000000 -0400
++++ OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/test/loader_test/CMakeLists.txt	2020-04-16 20:16:56.647026589 -0400
+@@ -12,4 +12,4 @@
+     test_clgl.c
+     test_image_objects.c )
+ 
+-target_link_libraries (icd_loader_test OpenCL IcdLog)
++target_link_libraries (icd_loader_test OpenCL-ROCm IcdLog)
+--- ROCm-OpenCL-Runtime-roc-3.3.0/CMakeLists.txt	2020-04-28 07:29:51.864446603 -0400
++++ ROCm-OpenCL-Runtime-roc-3.3.0/CMakeLists.txt	2020-04-28 07:32:45.245793180 -0400
+@@ -101,30 +101,30 @@
+ rocm_setup_version( VERSION "2.0.0" )
+ 
+ # MAIN package
+-install(PROGRAMS $<TARGET_FILE:clinfo>
+-        DESTINATION bin/x86_64
++install(PROGRAMS $<TARGET_FILE:rocm-clinfo>
++        DESTINATION bin
+         COMPONENT MAIN)
+ install(PROGRAMS $<TARGET_FILE:amdocl64>
+-        DESTINATION lib/x86_64
++        DESTINATION lib
+         COMPONENT MAIN)
+-install(PROGRAMS $<TARGET_FILE:OpenCL>
+-        DESTINATION lib/x86_64
++install(PROGRAMS $<TARGET_FILE:OpenCL-ROCm>
++        DESTINATION lib
+         COMPONENT MAIN)
+-install(PROGRAMS $<TARGET_SONAME_FILE:OpenCL>
+-        DESTINATION lib/x86_64
++install(PROGRAMS $<TARGET_SONAME_FILE:OpenCL-ROCm>
++        DESTINATION lib
+         COMPONENT MAIN)
+ 
+ # DEV package
+ install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/api/opencl/khronos/headers/opencl2.2/CL"
+-        DESTINATION include
++	DESTINATION include/rocm
+         COMPONENT DEV
+         USE_SOURCE_PERMISSIONS
+         PATTERN cl_d3d10.h EXCLUDE
+         PATTERN cl_d3d11.h EXCLUDE
+         PATTERN cl_dx9_media_sharing.h EXCLUDE
+         PATTERN cl_egl.h EXCLUDE)
+-install(PROGRAMS $<TARGET_LINKER_FILE:OpenCL>
+-        DESTINATION lib/x86_64
++install(PROGRAMS $<TARGET_LINKER_FILE:OpenCL-ROCm>
++        DESTINATION lib
+         COMPONENT DEV)
+ 
+ # Generic CPACK variables
+--- ROCm-OpenCL-Runtime-roc-3.3.0/tools/clinfo/CMakeLists.txt	2020-04-28 07:29:51.882446535 -0400
++++ ROCm-OpenCL-Runtime-roc-3.3.0/tools/clinfo/CMakeLists.txt	2020-04-28 07:30:05.627394732 -0400
+@@ -6,6 +6,6 @@
+ 
+ add_definitions(-DHAVE_CL2_HPP)
+ 
+-add_executable(clinfo clinfo.cpp)
++add_executable(rocm-clinfo clinfo.cpp)
+ 
+-target_link_libraries(clinfo OpenCL)
++target_link_libraries(rocm-clinfo OpenCL-ROCm)
diff --git a/srcpkgs/ROCm-OpenCL-Runtime/template b/srcpkgs/ROCm-OpenCL-Runtime/template
new file mode 100644
index 00000000000..f6699a1d4c0
--- /dev/null
+++ b/srcpkgs/ROCm-OpenCL-Runtime/template
@@ -0,0 +1,84 @@
+# Template file for 'ROCm-OpenCL-Runtime'
+pkgname=ROCm-OpenCL-Runtime
+version=3.3.0
+revision=1
+_ocl_icd_name="OpenCL-ICD-Loader"
+_ocl_icd_ver="6c03f8b58fafd9dd693eaac826749a5cfad515f8"
+archs="x86_64*"
+create_wrksrc=yes
+build_wrksrc="${pkgname}-roc-${version}"
+build_style=cmake
+configure_args="-DUSE_COMGR_LIBRARY=yes"
+hostmakedepends="cmake pkg-config"
+makedepends="libglvnd-devel ROCm-CompilerSupport-devel
+	ROCT-Thunk-Interface-devel ROCR-Runtime-devel"
+depends="ROCm-CompilerSupport"
+short_desc="Radeon Open Compute OpenCL runtime"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="MIT"
+homepage="https://github.com/RadeonOpenCompute/ROCm-OpenCL-Runtime"
+_rocroot="https://github.com/RadeonOpenCompute"
+distfiles="${_rocroot}/ROCm-OpenCL-Runtime/archive/roc-${version}.tar.gz
+	${_rocroot}/rocm-cmake/archive/rocm-${version}.tar.gz
+	https://github.com/KhronosGroup/${_ocl_icd_name}/archive/${_ocl_icd_ver}.tar.gz"
+checksum="ac6999f1a491ab066286c2bd6adf50f08f831286f56e267879f9f7eced22f98e
+	76ed3ee8e56cf3246011cf7723c2abda539e1136e7e7f6909bfa45d268b8644f
+	c94d5bb6dc980c4d41d73e2b81663a19aabe494e923e2d0eec72a4c95b318438"
+nocross=yes
+
+if [ "$XBPS_LIBC" = "musl" ]; then
+	makedepends+=" musl-legacy-compat"
+fi
+
+post_patch() {
+	if [ "$XBPS_LIBC" = "musl" ]; then
+		# Remove dependence on glibc
+		patch -Np0 < ${FILESDIR}/libelf-musl.patch
+		patch -Np0 < ${FILESDIR}/runtime-musl.patch
+		vsed -e '/glibc_functions.cpp/d' -i api/opencl/amdocl/CMakeLists.txt
+	fi
+}
+
+pre_configure() {
+	# ROCm requires a very specific Khronos ICD loader version in the tree
+	# Keep the ICD loader config in /etc/OpenCL/rocm-vendors to avoid conflicts
+	_ocl_icd_dir="${_ocl_icd_name}-${_ocl_icd_ver}"
+	ln -sf "${wrksrc}/${_ocl_icd_dir}" api/opencl/khronos/icd
+	vsed -i "${wrksrc}/${_ocl_icd_dir}/loader/icd_platform.h" \
+		-e 's@/etc/OpenCL/vendors/@/etc/OpenCL/rocm-vendors/@g'
+
+	# CMake modules probably not useful anywhere but for this build
+	ln -sf "${wrksrc}/rocm-cmake-rocm-${version}/share/rocm/cmake"/*.cmake cmake
+
+	# Fix the dlopen macro to point to versioned libamd_comgr shared object
+	vsed -i 'runtime/device/comgrctx.cpp' \
+		-e 's/\blibamd_comgr\(32\)\?.so\b/&.1/g'
+}
+
+post_install() {
+	vlicense License
+
+	# Create descriptor to allow the ICD loader to find the driver
+	vmkdir etc/OpenCL/rocm-vendors
+	echo "libamdocl64.so" > "${DESTDIR}/etc/OpenCL/rocm-vendors/amdocl64.icd"
+	vmkdir etc/OpenCL/vendors
+	ln -s ../../OpenCL/rocm-vendors/amdocl64.icd \
+		${DESTDIR}/etc/OpenCL/vendors/rocm-amdocl64.icd
+}
+
+ROCm-OpenCL-Runtime-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/lib/libOpenCL-ROCm.so
+		vmove usr/include
+	}
+}
+
+ROCm-OpenCL-Runtime-clinfo_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - clinfo"
+	pkg_install() {
+		vmove usr/bin/rocm-clinfo
+	}
+}
diff --git a/srcpkgs/ROCm-OpenCL-Runtime/update b/srcpkgs/ROCm-OpenCL-Runtime/update
new file mode 100644
index 00000000000..8385f4d1215
--- /dev/null
+++ b/srcpkgs/ROCm-OpenCL-Runtime/update
@@ -0,0 +1 @@
+pattern='roc-\K[\d.]+'

From ac732b8b7416417d5443f4bf5c275d49bc931a24 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Thu, 30 Apr 2020 13:11:12 -0400
Subject: [PATCH 09/10] New package: ROCR-Runtime-hsa-ext-3.3.0

---
 common/shlibs                         |  2 ++
 srcpkgs/ROCR-Runtime-hsa-ext-devel    |  1 +
 srcpkgs/ROCR-Runtime-hsa-ext/template | 42 +++++++++++++++++++++++++++
 srcpkgs/ROCR-Runtime-hsa-ext/update   |  2 ++
 4 files changed, 47 insertions(+)
 create mode 120000 srcpkgs/ROCR-Runtime-hsa-ext-devel
 create mode 100644 srcpkgs/ROCR-Runtime-hsa-ext/template
 create mode 100644 srcpkgs/ROCR-Runtime-hsa-ext/update

diff --git a/common/shlibs b/common/shlibs
index 6311c7612a7..e870e8158c9 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3881,3 +3881,5 @@ libhsa-runtime64.so.1 ROCR-Runtime-3.3.0_1
 libamd_comgr.so.1 ROCm-CompilerSupport-3.3.0_1
 libOpenCL-ROCm.so.1 ROCm-OpenCL-Runtime-3.3.0_1
 libamdocl64.so ROCm-OpenCL-Runtime-3.3.0_1
+libhsa-ext-image64.so.1 ROCR-Runtime-hsa-ext-3.3.0_1
+libhsa-runtime-tools64.so.1 ROCR-Runtime-hsa-ext-3.3.0_1
diff --git a/srcpkgs/ROCR-Runtime-hsa-ext-devel b/srcpkgs/ROCR-Runtime-hsa-ext-devel
new file mode 120000
index 00000000000..6ee1b14911b
--- /dev/null
+++ b/srcpkgs/ROCR-Runtime-hsa-ext-devel
@@ -0,0 +1 @@
+ROCR-Runtime-hsa-ext
\ No newline at end of file
diff --git a/srcpkgs/ROCR-Runtime-hsa-ext/template b/srcpkgs/ROCR-Runtime-hsa-ext/template
new file mode 100644
index 00000000000..475cad751de
--- /dev/null
+++ b/srcpkgs/ROCR-Runtime-hsa-ext/template
@@ -0,0 +1,42 @@
+# Template file for 'ROCR-Runtime-hsa-ext'
+pkgname=ROCR-Runtime-hsa-ext
+version=3.3.0
+revision=1
+archs="x86_64"
+hostmakedepends="tar"
+short_desc="Radeon Open Compute HSA runtime extensions"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute"
+_hsa_deb="hsa-ext-rocr-dev_1.1.30300.0-rocm-rel-3.3-19-23fc088b_amd64.deb"
+distfiles="https://repo.radeon.com/rocm/apt/debian/pool/main/h/hsa-ext-rocr-dev/$_hsa_deb"
+checksum=6b44e286b395d946b865ec1f3cc546356396785ac1fde591d07af02d0aa7c25d
+repository=nonfree
+
+do_extract() {
+	ar x "${XBPS_SRCDISTDIR}/${pkgname}-${version}/${_hsa_deb}"
+	tar xvf data.tar.gz
+}
+
+do_install() {
+	_rocm_includes="opt/rocm-${version}/hsa/include"
+
+	vmkdir usr
+	vcopy opt/rocm-${version}/hsa/lib usr
+	vcopy "$_rocm_includes" usr
+
+	# Extract license from one of the header files
+	awk 'BEGIN{HEADER=0} /\/\//{HEADER=1; print $0;} /^[^/]/{if(HEADER==1) exit;}' \
+		< "${_rocm_includes}/hsa/amd_hsa_tools_interfaces.h" \
+		| sed 's@^///*\( \|$\)@@' > LICENSE
+	vlicense LICENSE
+}
+
+ROCR-Runtime-hsa-ext-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove "usr/lib/*.so"
+	}
+}
diff --git a/srcpkgs/ROCR-Runtime-hsa-ext/update b/srcpkgs/ROCR-Runtime-hsa-ext/update
new file mode 100644
index 00000000000..84252d2e3b8
--- /dev/null
+++ b/srcpkgs/ROCR-Runtime-hsa-ext/update
@@ -0,0 +1,2 @@
+site='https://repo.radeon.com/rocm/apt/debian/pool/main/h/'
+pattern='hsa-ext-rocr-dev\K[\d.]+'

From b1148e91e93278ac72a1c722bd306b40c9c3a12d Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Tue, 28 Apr 2020 13:33:46 -0400
Subject: [PATCH 10/10] hashcat: add build option to link against ROCm [ci
 skip]

---
 srcpkgs/hashcat/files/rocm.patch     | 15 +++++++++++++++
 srcpkgs/hashcat/patches/tmpdir.patch | 21 +++++++++++++++++++++
 srcpkgs/hashcat/template             | 17 ++++++++++++++---
 3 files changed, 50 insertions(+), 3 deletions(-)
 create mode 100644 srcpkgs/hashcat/files/rocm.patch
 create mode 100644 srcpkgs/hashcat/patches/tmpdir.patch

diff --git a/srcpkgs/hashcat/files/rocm.patch b/srcpkgs/hashcat/files/rocm.patch
new file mode 100644
index 00000000000..f1e899d30ee
--- /dev/null
+++ b/srcpkgs/hashcat/files/rocm.patch
@@ -0,0 +1,15 @@
+diff -ur a/src/opencl.c b/src/opencl.c
+--- a/src/opencl.c	2018-12-02 05:58:48.000000000 -0500
++++ b/src/opencl.c	2020-04-28 13:24:12.602415333 -0400
+@@ -492,9 +492,9 @@
+ 
+   if (ocl->lib == NULL) ocl->lib = hc_dlopen ("cygOpenCL-1.dll", RTLD_NOW);
+   #else
+-  ocl->lib = hc_dlopen ("libOpenCL.so", RTLD_NOW);
++  ocl->lib = hc_dlopen ("libOpenCL-ROCm.so.1", RTLD_NOW);
+ 
+-  if (ocl->lib == NULL) ocl->lib = hc_dlopen ("libOpenCL.so.1", RTLD_NOW);
++  if (ocl->lib == NULL) ocl->lib = hc_dlopen ("libOpenCL-ROCm.so", RTLD_NOW);
+   #endif
+ 
+   if (ocl->lib == NULL)
diff --git a/srcpkgs/hashcat/patches/tmpdir.patch b/srcpkgs/hashcat/patches/tmpdir.patch
new file mode 100644
index 00000000000..0558a001c9c
--- /dev/null
+++ b/srcpkgs/hashcat/patches/tmpdir.patch
@@ -0,0 +1,21 @@
+Addresses https://github.com/hashcat/hashcat/issues/2379
+diff -ur a/src/folder.c b/src/folder.c
+--- src/folder.c	2018-12-02 05:58:48.000000000 -0500
++++ src/folder.c	2020-04-28 13:22:27.340522751 -0400
+@@ -457,16 +457,6 @@
+ 
+   hcfree (cpath);
+ 
+-  //if (getenv ("TMP") == NULL)
+-  if (1)
+-  {
+-    char *tmp;
+-
+-    hc_asprintf (&tmp, "TMP=%s", cpath_real);
+-
+-    putenv (tmp);
+-  }
+-
+   #if defined (_WIN)
+ 
+   naive_replace (cpath_real, '\\', '/');
diff --git a/srcpkgs/hashcat/template b/srcpkgs/hashcat/template
index e982f99cebf..3f19be5e41d 100644
--- a/srcpkgs/hashcat/template
+++ b/srcpkgs/hashcat/template
@@ -1,15 +1,16 @@
 # Template file for 'hashcat'
 pkgname=hashcat
 version=5.1.0
-revision=2
+revision=3
 build_style=gnu-makefile
 make_build_args="PREFIX=/usr
  USE_SYSTEM_OPENCL=1 USE_SYSTEM_XXHASH=1
- DEPS_OPENCL_PATH=${XBPS_CROSS_BASE}/usr/include
+ DEPS_OPENCL_PATH=${XBPS_CROSS_BASE}/usr/include$(vopt_if rocm /rocm)
  DEPS_XXHASH_PATH=${XBPS_CROSS_BASE}/usr/include"
 make_use_env=yes
 make_install_args="$make_build_args"
-makedepends="gmp-devel opencl2-headers xxHash-devel"
+makedepends="gmp-devel xxHash-devel
+ $(vopt_if rocm ROCm-OpenCL-Runtime-devel opencl2-headers)"
 checkdepends="perl"
 short_desc="Advanced CPU-based password recovery utility"
 maintainer="Duncaen <duncaen@voidlinux.org>"
@@ -19,6 +20,9 @@ changelog="https://raw.githubusercontent.com/hashcat/hashcat/master/docs/changes
 distfiles="https://hashcat.net/files/hashcat-${version}.tar.gz"
 checksum=283beaa68e1eab41de080a58bb92349c8e47a2bb1b93d10f36ea30f418f1e338
 
+build_options="rocm"
+desc_option_rocm="Use ROCm OpenCL runtime"
+
 if [ "$XBPS_TARGET_ENDIAN" = "be" ]; then
 	broken="Not supported on big endian"
 fi
@@ -26,6 +30,13 @@ fi
 post_extract() {
 	sed '/^CC/d' -i src/Makefile
 }
+
+post_patch() {
+	if [ "$build_option_rocm" ]; then
+		patch -Np1 < ${FILESDIR}/rocm.patch
+	fi
+}
+
 post_install() {
 	rm -f ${DESTDIR}/usr/share/docs/hashcat/license.txt
 	vlicense docs/license.txt

^ permalink raw reply	[flat|nested] 61+ messages in thread

* Re: [PR PATCH] [Updated] New packages: ROCm core and OpenCL
  2020-04-19 13:34 [PR PATCH] New packages: ROCm core and OpenCL ahesford
                   ` (25 preceding siblings ...)
  2020-05-05 14:24 ` ahesford
@ 2020-05-05 14:26 ` ahesford
  2020-05-07 14:18 ` ahesford
                   ` (32 subsequent siblings)
  59 siblings, 0 replies; 61+ messages in thread
From: ahesford @ 2020-05-05 14:26 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 3893 bytes --]

There is an updated pull request by ahesford against master on the void-packages repository

https://github.com/ahesford/void-packages rocm
https://github.com/void-linux/void-packages/pull/21153

New packages: ROCm core and OpenCL
This PR includes several packages designed to bring the OpenCL portion of the AMD ROCm ecosystem to Void. It addresses Issue #19507. There are many other packages that AMD provides for GPGPU computing, but these can be added piecemeal as users demand.

The packages are currently only for `x86_64*`. While at least some of the packages will compile on other 64-bit architectures, I have no hardware to test. They are certainly not suitable for 32-bit architectures; some internal data structures rely on `uint64_t` values that are cast to pointers. At a
minimum, a thorough audit would be necessary to ensure that these casts are safe (e.g., that the values stored were only ever upcast from 32-bit pointers). More extensive work may be necessary to support 32-bit architectures, probably without significant benefit.

The packages successfully identify a Radeon RX 580 on an `x86_64` installation using both `clinfo` and `rocminfo` as provided. Furthermore, a version of `pyopencl` linked against these ROCm packages successfully runs a simple program that validates arithmetic on GPU-bound arrays.

There are caveats with this set of packages, almost all of which revolve around the incompatibilities between the Void-provided `ocl-icd` and the [Khronos OpenCL ICD loader](https://github.com/KhronosGroup/OpenCL-ID-Loader) required by (and built into) `rocm-opencl-runtime`.
1. All packages install into `/opt/rocm`. This keeps the environment closer to that officially sanctioned by AMD and helps avoid conflicts between other packages and those provided here. (For example, `clinfo` and the ICD loader itself.) Eventually, we may be able to move the files into `/usr`.
2. The Khronos OpenCL ICD loader built into `rocm-opencl-runtime` is an outdated, pre-release commit. If AMD can update its sources to use the release version of that loader (which has a backward-incompatible API change), we may be able to make ROCm compatible with `ocl-icd` or replace `ocl-icd` with the official Khronos loader.
3. In the meantime, to avoid `shlibs` conflicts, the OpenCL ICD loader is installed as `/opt/rocm/lib/libOpenCL-ROCm.so` (and an appropriately versioned shared library), which means that programs wishing to use the ROCm OpenCL must explicitly link against this library instead of the generic `libOpenCL.so`.
4. I do **not** recommend making any Void packages link against this specific library, because it will make those packages ROCm-only. For the time being, ROCm is intended for end-users to specifically link against. Linking Void packages against ROCm would requires the ICD loader used by ROCm be compatible with `ocl-icd`, or `ocl-icd` be replaced by the Khronos loader. However, because the Khronos loader changed its API for the release version, such a change is not yet appropriate.

Hopefully, if AMD updates its dependence on the Khronos ICD loader, we can resolve some of these caveats in the future and make ROCm a more natural Void component. For now, these packages are useful for those who need an AMD OpenCL solution and would rather custom-link software against the AMD ICD loader than hack the `amdgpu-pro` driver into an ICD compatible with `ocl-icd`.

Some patches were made to relocate some files in `/opt/rocm` and make everyting build on x86_64-musl`. Where appropriate, these patches will be pushed upstream to clean up the distribution and packaging.

Update: I pushed some new commits to update license information that triggerd an `xlint` failure. I've also disabled CI builds because they will time out on `rocm-llvm`.

A patch file from https://github.com/void-linux/void-packages/pull/21153.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-rocm-21153.patch --]
[-- Type: text/x-diff, Size: 39001 bytes --]

From cc86dec132a842cb6adbcf601c3947c782b4e086 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Mon, 13 Apr 2020 13:08:09 -0400
Subject: [PATCH 01/10] New package: ROCT-Thunk-Interface-3.3.0

---
 common/shlibs                                 |  1 +
 srcpkgs/ROCT-Thunk-Interface-devel            |  1 +
 .../patches/cmake-dev-libdir.patch            | 10 ++++++
 .../ROCT-Thunk-Interface/patches/musl.patch   | 29 ++++++++++++++++
 srcpkgs/ROCT-Thunk-Interface/template         | 33 +++++++++++++++++++
 srcpkgs/ROCT-Thunk-Interface/update           |  1 +
 6 files changed, 75 insertions(+)
 create mode 120000 srcpkgs/ROCT-Thunk-Interface-devel
 create mode 100644 srcpkgs/ROCT-Thunk-Interface/patches/cmake-dev-libdir.patch
 create mode 100644 srcpkgs/ROCT-Thunk-Interface/patches/musl.patch
 create mode 100644 srcpkgs/ROCT-Thunk-Interface/template
 create mode 100644 srcpkgs/ROCT-Thunk-Interface/update

diff --git a/common/shlibs b/common/shlibs
index 7a1e5b5d5eb..906dc414723 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3876,3 +3876,4 @@ libhidrd_opt.so.0 hidrd-0.2.0_1
 libhidrd_strm.so.0 hidrd-0.2.0_1
 libhidrd_fmt.so.0 hidrd-0.2.0_1
 
+libhsakmt.so.1 ROCT-Thunk-Interface-3.3.0_1
diff --git a/srcpkgs/ROCT-Thunk-Interface-devel b/srcpkgs/ROCT-Thunk-Interface-devel
new file mode 120000
index 00000000000..7e43c209e3d
--- /dev/null
+++ b/srcpkgs/ROCT-Thunk-Interface-devel
@@ -0,0 +1 @@
+ROCT-Thunk-Interface
\ No newline at end of file
diff --git a/srcpkgs/ROCT-Thunk-Interface/patches/cmake-dev-libdir.patch b/srcpkgs/ROCT-Thunk-Interface/patches/cmake-dev-libdir.patch
new file mode 100644
index 00000000000..98c7f1e459c
--- /dev/null
+++ b/srcpkgs/ROCT-Thunk-Interface/patches/cmake-dev-libdir.patch
@@ -0,0 +1,10 @@
+--- CMakeLists.txt.old	2020-04-18 19:45:17.306081135 -0400
++++ CMakeLists.txt	2020-04-18 19:46:51.300753636 -0400
+@@ -146,6 +146,7 @@
+     COMMAND ${CMAKE_COMMAND}
+         -DSOURCE_DIR="${SOURCE_DIR}"
+         -DCMAKE_INSTALL_PREFIX="${CMAKE_INSTALL_PREFIX}"
++        -DCMAKE_INSTALL_LIBDIR="${CMAKE_INSTALL_LIBDIR}"
+         -DCPACK_RPM_PACKAGE_REQUIRES="hsakmt-roct"
+         -DCPACK_PACKAGING_INSTALL_PREFIX="${CPACK_PACKAGING_INSTALL_PREFIX}"
+         -DVERSION="${BUILD_VERSION_STRING}"
diff --git a/srcpkgs/ROCT-Thunk-Interface/patches/musl.patch b/srcpkgs/ROCT-Thunk-Interface/patches/musl.patch
new file mode 100644
index 00000000000..aeea9832411
--- /dev/null
+++ b/srcpkgs/ROCT-Thunk-Interface/patches/musl.patch
@@ -0,0 +1,29 @@
+diff -r -u old/src/libhsakmt.h new/src/libhsakmt.h
+--- src/libhsakmt.h	2020-03-04 15:00:47.000000000 -0500
++++ src/libhsakmt.h	2020-04-13 12:58:30.444865992 -0400
+@@ -54,6 +54,10 @@
+ #define CHECK_KFD_OPEN() \
+ 	do { if (kfd_open_count == 0 || hsakmt_forked) return HSAKMT_STATUS_KERNEL_IO_CHANNEL_NOT_OPENED; } while (0)
+ 
++/*On some platforms, a PAGE_SIZE macro eclipses the extern variable*/
++#ifdef PAGE_SIZE
++#undef PAGE_SIZE
++#endif
+ extern int PAGE_SIZE;
+ extern int PAGE_SHIFT;
+ 
+diff -r -u old/src/topology.c new/src/topology.c
+--- src/topology.c	2020-03-04 15:00:47.000000000 -0500
++++ src/topology.c	2020-04-13 13:01:31.209870701 -0400
+@@ -38,6 +38,11 @@
+ #include "libhsakmt.h"
+ #include "fmm.h"
+ 
++/*Needed on MUSL*/
++#ifndef MAXNAMLEN
++#define MAXNAMLEN PATH_MAX
++#endif
++
+ /* Number of memory banks added by thunk on top of topology
+  * This only includes static heaps like LDS, scratch and SVM,
+  * not for MMIO_REMAP heap. MMIO_REMAP memory bank is reported
diff --git a/srcpkgs/ROCT-Thunk-Interface/template b/srcpkgs/ROCT-Thunk-Interface/template
new file mode 100644
index 00000000000..8c680b2af29
--- /dev/null
+++ b/srcpkgs/ROCT-Thunk-Interface/template
@@ -0,0 +1,33 @@
+# Template file for 'ROCT-Thunk-Interface'
+pkgname=ROCT-Thunk-Interface
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="${pkgname}-roc-${version}"
+build_style=cmake
+make_build_target="all build-dev"
+make_install_target="install install-dev"
+hostmakedepends="cmake pkg-config"
+makedepends="pciutils-devel libnuma-devel"
+short_desc="Radeon Open Compute thunk interface"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="MIT"
+homepage="https://github.com/RadeonOpenCompute/ROCT-Thunk-Interface"
+distfiles="${homepage}/archive/roc-${version}.tar.gz"
+checksum=2cabe9d2cfa72031c05d11290837c476182e72d8dec2049298f691143fdd212b
+nocross=yes
+
+post_install() {
+	vlicense LICENSE.md
+}
+
+ROCT-Thunk-Interface-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove "usr/lib/*.so"
+		vmove usr/share/pkgconfig
+		vmove usr/lib/cmake
+	}
+}
diff --git a/srcpkgs/ROCT-Thunk-Interface/update b/srcpkgs/ROCT-Thunk-Interface/update
new file mode 100644
index 00000000000..8385f4d1215
--- /dev/null
+++ b/srcpkgs/ROCT-Thunk-Interface/update
@@ -0,0 +1 @@
+pattern='roc-\K[\d.]+'

From 0c958bb84f8a78b11df9f60547421c8253224f6a Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Mon, 13 Apr 2020 15:27:27 -0400
Subject: [PATCH 02/10] New package: ROCR-Runtime-3.3.0

---
 common/shlibs                            |  1 +
 srcpkgs/ROCR-Runtime-devel               |  1 +
 srcpkgs/ROCR-Runtime/patches/cmake.patch | 27 +++++++++++++++++++++
 srcpkgs/ROCR-Runtime/template            | 30 ++++++++++++++++++++++++
 srcpkgs/ROCR-Runtime/update              |  1 +
 5 files changed, 60 insertions(+)
 create mode 120000 srcpkgs/ROCR-Runtime-devel
 create mode 100644 srcpkgs/ROCR-Runtime/patches/cmake.patch
 create mode 100644 srcpkgs/ROCR-Runtime/template
 create mode 100644 srcpkgs/ROCR-Runtime/update

diff --git a/common/shlibs b/common/shlibs
index 906dc414723..2efbbb7b3b6 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3877,3 +3877,4 @@ libhidrd_strm.so.0 hidrd-0.2.0_1
 libhidrd_fmt.so.0 hidrd-0.2.0_1
 
 libhsakmt.so.1 ROCT-Thunk-Interface-3.3.0_1
+libhsa-runtime64.so.1 ROCR-Runtime-3.3.0_1
diff --git a/srcpkgs/ROCR-Runtime-devel b/srcpkgs/ROCR-Runtime-devel
new file mode 120000
index 00000000000..a733fb9fbab
--- /dev/null
+++ b/srcpkgs/ROCR-Runtime-devel
@@ -0,0 +1 @@
+ROCR-Runtime
\ No newline at end of file
diff --git a/srcpkgs/ROCR-Runtime/patches/cmake.patch b/srcpkgs/ROCR-Runtime/patches/cmake.patch
new file mode 100644
index 00000000000..93b74cd2297
--- /dev/null
+++ b/srcpkgs/ROCR-Runtime/patches/cmake.patch
@@ -0,0 +1,27 @@
+--- src/CMakeLists.txt.old	2020-04-18 20:01:48.549636995 -0400
++++ src/CMakeLists.txt	2020-04-18 20:04:00.177179781 -0400
+@@ -108,8 +108,8 @@
+ ## ROCr build internal versioning
+ add_definitions ( -DROCR_BUILD_ID=${PACKAGE_VERSION_STRING} )
+ 
+-## Set RUNPATH - ../../lib covers use of the legacy symlink in /hsa/lib/
+-set(CMAKE_INSTALL_RPATH "$ORIGIN;$ORIGIN/../../lib;$ORIGIN/../../lib64;$ORIGIN/../lib64")
++## Set RUNPATH
++set(CMAKE_INSTALL_RPATH "$ORIGIN;$ORIGIN/../lib")
+ 
+ ## ------------------------- Linux Compiler and Linker options -------------------------
+ set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -fexceptions -fno-rtti -fvisibility=hidden -Wno-error=sign-compare -Wno-sign-compare -Wno-write-strings -Wno-conversion-null -fno-math-errno -fno-threadsafe-statics -fmerge-all-constants -fms-extensions -Wno-error=comment -Wno-comment -Wno-error=pointer-arith -Wno-pointer-arith -Wno-error=unused-variable -Wno-error=unused-function" )
+@@ -185,11 +185,8 @@
+ add_custom_target ( hsa_lib_link2 ALL WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMAND ${CMAKE_COMMAND} -E create_symlink ../hsa/lib/${CORE_RUNTIME_LIBRARY}.so.${SO_MAJOR} ${CORE_RUNTIME_LIBRARY}-link.so.${SO_MAJOR} )
+ 
+ ## Set install information
+-install ( TARGETS ${CORE_RUNTIME_TARGET} LIBRARY DESTINATION hsa/lib )
+-install ( DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/inc/ DESTINATION hsa/include/hsa )
+-install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/hsa_include_link DESTINATION include PERMISSIONS OWNER_WRITE OWNER_READ RENAME hsa )
+-install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/${CORE_RUNTIME_LIBRARY}-link.so DESTINATION lib PERMISSIONS OWNER_WRITE OWNER_READ RENAME ${CORE_RUNTIME_LIBRARY}.so )
+-install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/${CORE_RUNTIME_LIBRARY}-link.so.${SO_MAJOR} DESTINATION lib PERMISSIONS OWNER_WRITE OWNER_READ RENAME ${CORE_RUNTIME_LIBRARY}.so.${SO_MAJOR} )
++install ( TARGETS ${CORE_RUNTIME_TARGET} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} )
++install ( DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/inc/ DESTINATION include/hsa )
+ 
+ ## Packaging directives
+ set ( CPACK_GENERATOR "DEB;RPM" CACHE STRING "Package types to build")
diff --git a/srcpkgs/ROCR-Runtime/template b/srcpkgs/ROCR-Runtime/template
new file mode 100644
index 00000000000..95b7e701afb
--- /dev/null
+++ b/srcpkgs/ROCR-Runtime/template
@@ -0,0 +1,30 @@
+# Template file for 'ROCR-Runtime'
+pkgname=ROCR-Runtime
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="${pkgname}-rocm-${version}"
+build_wrksrc="src"
+build_style=cmake
+hostmakedepends="cmake pkg-config"
+makedepends="ROCT-Thunk-Interface-devel elfutils-devel"
+short_desc="Radeon Open Compute HSA runtime"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute/ROCR-Runtime"
+distfiles="${homepage}/archive/rocm-${version}.tar.gz"
+checksum=fa2d2d1f8a61d8a6952d377cf288d78c61776c3c2a666f163cafc3aa19ab0b61
+nocross=yes
+
+post_install() {
+	vlicense ../LICENSE.txt
+}
+
+ROCR-Runtime-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove "usr/lib/*.so"
+	}
+}
diff --git a/srcpkgs/ROCR-Runtime/update b/srcpkgs/ROCR-Runtime/update
new file mode 100644
index 00000000000..86197bc3eea
--- /dev/null
+++ b/srcpkgs/ROCR-Runtime/update
@@ -0,0 +1 @@
+pattern='rocm-\K[\d.]+'

From cabac50d551b9760dbc20effc0d4d05c7dfd922e Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Mon, 13 Apr 2020 18:07:34 -0400
Subject: [PATCH 03/10] New package: ROCm-llvm-3.3.0

---
 srcpkgs/ROCm-llvm/template | 26 ++++++++++++++++++++++++++
 srcpkgs/ROCm-llvm/update   |  1 +
 2 files changed, 27 insertions(+)
 create mode 100644 srcpkgs/ROCm-llvm/template
 create mode 100644 srcpkgs/ROCm-llvm/update

diff --git a/srcpkgs/ROCm-llvm/template b/srcpkgs/ROCm-llvm/template
new file mode 100644
index 00000000000..4c3095b21f4
--- /dev/null
+++ b/srcpkgs/ROCm-llvm/template
@@ -0,0 +1,26 @@
+# Template file for 'ROCm-llvm'
+pkgname=ROCm-llvm
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="llvm-project-rocm-ocl-${version}"
+build_wrksrc=llvm
+build_style=cmake
+configure_args="-DCMAKE_INSTALL_PREFIX:PATH=/usr/lib/rocm-llvm
+	-DLLVM_ENABLE_PROJECTS='llvm;clang;lld' -DLLVM_TARGETS_TO_BUILD='AMDGPU'
+	-DLLVM_BUILD_DOCS=NO -DLLVM_ENABLE_OCAMLDOC=OFF
+	-DLLVM_ENABLE_SPHINX=NO -DLLVM_ENABLE_DOXYGEN=OFF
+	-DLLVM_INSTALL_UTILS=ON -DLLVM_VERSION_SUFFIX=roc -DOCAMLFIND=NO"
+hostmakedepends="cmake pkg-config python3"
+short_desc="Radeon Open Compute LLVM toolchain"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="Apache-2.0, NCSA, custom:LLVM-Exceptions"
+homepage="https://github.com/RadeonOpenCompute/llvm-project"
+distfiles="${homepage}/archive/rocm-ocl-${version}.tar.gz"
+checksum=a2bef7042e8e2f2cd8548cb246b88322e1c77188839983dcac8312d56f544dc8
+python_version=3
+nocross=yes
+
+post_install() {
+	vlicense LICENSE.TXT
+}
diff --git a/srcpkgs/ROCm-llvm/update b/srcpkgs/ROCm-llvm/update
new file mode 100644
index 00000000000..6a73667d3c1
--- /dev/null
+++ b/srcpkgs/ROCm-llvm/update
@@ -0,0 +1 @@
+pattern='rocm-ocl-\K[\d.]+'

From b20a6d352b008c17d9ac51daee6ceb43ca3cf516 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Tue, 14 Apr 2020 10:25:31 -0400
Subject: [PATCH 04/10] New package: ROCm-Device-Libs-3.3.0

---
 srcpkgs/ROCm-Device-Libs/template | 37 +++++++++++++++++++++++++++++++
 srcpkgs/ROCm-Device-Libs/update   |  1 +
 2 files changed, 38 insertions(+)
 create mode 100644 srcpkgs/ROCm-Device-Libs/template
 create mode 100644 srcpkgs/ROCm-Device-Libs/update

diff --git a/srcpkgs/ROCm-Device-Libs/template b/srcpkgs/ROCm-Device-Libs/template
new file mode 100644
index 00000000000..8086cd86450
--- /dev/null
+++ b/srcpkgs/ROCm-Device-Libs/template
@@ -0,0 +1,37 @@
+# Template file for 'ROCm-Device-Libs'
+pkgname=ROCm-Device-Libs
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="${pkgname}-rocm-ocl-${version}"
+build_style=cmake
+configure_args="-DLLVM_DIR:PATH=/usr/lib/rocm-llvm
+	-DCMAKE_INSTALL_LIBDIR:PATH=lib/rocm-device-libs"
+hostmakedepends="cmake ROCm-llvm"
+short_desc="Radeon Open Compute device libraries"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute/ROCm-Device-Libs"
+distfiles="${homepage}/archive/rocm-ocl-${version}.tar.gz"
+checksum=706b08230790e08ca6a7a2fb7687d6131fd39a562148340e00fa37a6c06769c5
+nocross=yes
+
+pre_configure() {
+	# Put bytecodes in a lib/ subdirectory
+	vsed -i Packages.cmake -e 's@/lib/@/${CMAKE_INSTALL_LIBDIR}/@'
+	vsed -i OCL.cmake -e 's@DESTINATION lib$@DESTINATION ${CMAKE_INSTALL_LIBDIR}@'
+
+	# Build the prepare-builtins executable with native compiler
+	mkdir -p utils/build
+	cd utils/build
+	_prepare_builtins="$PWD/prepare-builtins/prepare-builtins"
+	cmake ${configure_args} ..
+	make ${makejobs}
+
+	# Add path to prepare-builtins for cmake
+	configure_args+=" -DPREPARE_BUILTINS='${_prepare_builtins}'"
+}
+
+post_install() {
+	vlicense LICENSE
+}
diff --git a/srcpkgs/ROCm-Device-Libs/update b/srcpkgs/ROCm-Device-Libs/update
new file mode 100644
index 00000000000..6a73667d3c1
--- /dev/null
+++ b/srcpkgs/ROCm-Device-Libs/update
@@ -0,0 +1 @@
+pattern='rocm-ocl-\K[\d.]+'

From 3a12101dabe2128199051190be69bdd88ba23360 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Mon, 13 Apr 2020 18:30:00 -0400
Subject: [PATCH 05/10] New package: ROCm-CompilerSupport-3.3.0

---
 common/shlibs                         |  1 +
 srcpkgs/ROCm-CompilerSupport-devel    |  1 +
 srcpkgs/ROCm-CompilerSupport/template | 32 +++++++++++++++++++++++++++
 srcpkgs/ROCm-CompilerSupport/update   |  1 +
 4 files changed, 35 insertions(+)
 create mode 120000 srcpkgs/ROCm-CompilerSupport-devel
 create mode 100644 srcpkgs/ROCm-CompilerSupport/template
 create mode 100644 srcpkgs/ROCm-CompilerSupport/update

diff --git a/common/shlibs b/common/shlibs
index 2efbbb7b3b6..570f135543f 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3878,3 +3878,4 @@ libhidrd_fmt.so.0 hidrd-0.2.0_1
 
 libhsakmt.so.1 ROCT-Thunk-Interface-3.3.0_1
 libhsa-runtime64.so.1 ROCR-Runtime-3.3.0_1
+libamd_comgr.so.1 ROCm-CompilerSupport-3.3.0_1
diff --git a/srcpkgs/ROCm-CompilerSupport-devel b/srcpkgs/ROCm-CompilerSupport-devel
new file mode 120000
index 00000000000..877aeafeeae
--- /dev/null
+++ b/srcpkgs/ROCm-CompilerSupport-devel
@@ -0,0 +1 @@
+ROCm-CompilerSupport
\ No newline at end of file
diff --git a/srcpkgs/ROCm-CompilerSupport/template b/srcpkgs/ROCm-CompilerSupport/template
new file mode 100644
index 00000000000..df56f7a3837
--- /dev/null
+++ b/srcpkgs/ROCm-CompilerSupport/template
@@ -0,0 +1,32 @@
+# Template file for 'ROCm-CompilerSupport'
+pkgname=ROCm-CompilerSupport
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="${pkgname}-rocm-${version}"
+build_wrksrc="lib/comgr"
+build_style=cmake
+configure_args="-DClang_DIR:PATH=/usr/lib/rocm-llvm/lib/cmake/clang"
+hostmakedepends="cmake pkg-config ROCm-llvm"
+makedepends="ROCm-Device-Libs"
+short_desc="Radeon Open Compute compiler support"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="BSD-3-Clause"
+homepage="https://github.com/RadeonOpenCompute/ROCm-CompilerSupport"
+distfiles="${homepage}/archive/rocm-${version}.tar.gz"
+checksum=01e2524e0f28ecd6f46c9720f279207de935d826b0172158792aa3ec86af9ca7
+nocross=yes
+
+post_install() {
+	vlicense LICENSE.txt
+}
+
+ROCm-CompilerSupport-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove "usr/lib/*.so"
+		vmove usr/lib/cmake
+	}
+}
diff --git a/srcpkgs/ROCm-CompilerSupport/update b/srcpkgs/ROCm-CompilerSupport/update
new file mode 100644
index 00000000000..86197bc3eea
--- /dev/null
+++ b/srcpkgs/ROCm-CompilerSupport/update
@@ -0,0 +1 @@
+pattern='rocm-\K[\d.]+'

From 89a16358639d4a718c11497f009cbd1934961e24 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Fri, 17 Apr 2020 12:11:25 -0400
Subject: [PATCH 06/10] New package: rocminfo-3.3.0

---
 srcpkgs/rocminfo/template | 22 ++++++++++++++++++++++
 srcpkgs/rocminfo/update   |  1 +
 2 files changed, 23 insertions(+)
 create mode 100644 srcpkgs/rocminfo/template
 create mode 100644 srcpkgs/rocminfo/update

diff --git a/srcpkgs/rocminfo/template b/srcpkgs/rocminfo/template
new file mode 100644
index 00000000000..7a075c7f7ac
--- /dev/null
+++ b/srcpkgs/rocminfo/template
@@ -0,0 +1,22 @@
+# Template file for 'rocminfo'
+pkgname=rocminfo
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="${pkgname}-rocm-${version}"
+build_style=cmake
+configure_args="-DROCM_DIR=/usr"
+hostmakedepends="cmake pkg-config"
+makedepends="ROCR-Runtime-devel"
+short_desc="Radeon Open Compute system information reporter"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute/rocminfo"
+distfiles="${homepage}/archive/rocm-${version}.tar.gz"
+checksum=e666f662c9e465aaabbbd0b109d87e017243cdf1a0898fabf5a90947bb3dbcd7
+nocross=yes
+python_version=3
+
+post_install() {
+	vlicense License.txt
+}
diff --git a/srcpkgs/rocminfo/update b/srcpkgs/rocminfo/update
new file mode 100644
index 00000000000..86197bc3eea
--- /dev/null
+++ b/srcpkgs/rocminfo/update
@@ -0,0 +1 @@
+pattern='rocm-\K[\d.]+'

From 20c364974c12e04383dbd37b5460fc0d92afed5e Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Sun, 19 Apr 2020 15:01:40 -0400
Subject: [PATCH 07/10] New package: rocm_bandwidth_test-3.3.0

---
 srcpkgs/rocm_bandwidth_test/template | 20 ++++++++++++++++++++
 srcpkgs/rocm_bandwidth_test/update   |  1 +
 2 files changed, 21 insertions(+)
 create mode 100644 srcpkgs/rocm_bandwidth_test/template
 create mode 100644 srcpkgs/rocm_bandwidth_test/update

diff --git a/srcpkgs/rocm_bandwidth_test/template b/srcpkgs/rocm_bandwidth_test/template
new file mode 100644
index 00000000000..6de7f2d6614
--- /dev/null
+++ b/srcpkgs/rocm_bandwidth_test/template
@@ -0,0 +1,20 @@
+# Template file for 'rocm_bandwidth_test'
+pkgname=rocm_bandwidth_test
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="${pkgname}-rocm-${version}"
+build_style=cmake
+hostmakedepends="cmake"
+makedepends="ROCR-Runtime-devel ROCT-Thunk-Interface-devel"
+short_desc="Radeon Open Compute bandwidth test"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute/rocm_bandwidth_test"
+distfiles="${homepage}/archive/rocm-${version}.tar.gz"
+checksum=f5f914073018619dc91662d5bf630903dfa4db9136d603591917fdfb3c9164ce
+nocross=yes
+
+post_install() {
+	vlicense LICENSE.txt
+}
diff --git a/srcpkgs/rocm_bandwidth_test/update b/srcpkgs/rocm_bandwidth_test/update
new file mode 100644
index 00000000000..86197bc3eea
--- /dev/null
+++ b/srcpkgs/rocm_bandwidth_test/update
@@ -0,0 +1 @@
+pattern='rocm-\K[\d.]+'

From 5ef5d3f43c6dc6773da9d9c052280f134ec83344 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Tue, 14 Apr 2020 10:25:54 -0400
Subject: [PATCH 08/10] New package: ROCm-OpenCL-Runtime-3.3.0

---
 common/shlibs                                 |   2 +
 srcpkgs/ROCm-OpenCL-Runtime-clinfo            |   1 +
 srcpkgs/ROCm-OpenCL-Runtime-devel             |   1 +
 .../files/libelf-musl.patch                   |  21 +++
 .../files/runtime-musl.patch                  |  11 ++
 .../ROCm-OpenCL-Runtime/patches/cmake.patch   | 126 ++++++++++++++++++
 srcpkgs/ROCm-OpenCL-Runtime/template          |  84 ++++++++++++
 srcpkgs/ROCm-OpenCL-Runtime/update            |   1 +
 8 files changed, 247 insertions(+)
 create mode 120000 srcpkgs/ROCm-OpenCL-Runtime-clinfo
 create mode 120000 srcpkgs/ROCm-OpenCL-Runtime-devel
 create mode 100644 srcpkgs/ROCm-OpenCL-Runtime/files/libelf-musl.patch
 create mode 100644 srcpkgs/ROCm-OpenCL-Runtime/files/runtime-musl.patch
 create mode 100644 srcpkgs/ROCm-OpenCL-Runtime/patches/cmake.patch
 create mode 100644 srcpkgs/ROCm-OpenCL-Runtime/template
 create mode 100644 srcpkgs/ROCm-OpenCL-Runtime/update

diff --git a/common/shlibs b/common/shlibs
index 570f135543f..6311c7612a7 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3879,3 +3879,5 @@ libhidrd_fmt.so.0 hidrd-0.2.0_1
 libhsakmt.so.1 ROCT-Thunk-Interface-3.3.0_1
 libhsa-runtime64.so.1 ROCR-Runtime-3.3.0_1
 libamd_comgr.so.1 ROCm-CompilerSupport-3.3.0_1
+libOpenCL-ROCm.so.1 ROCm-OpenCL-Runtime-3.3.0_1
+libamdocl64.so ROCm-OpenCL-Runtime-3.3.0_1
diff --git a/srcpkgs/ROCm-OpenCL-Runtime-clinfo b/srcpkgs/ROCm-OpenCL-Runtime-clinfo
new file mode 120000
index 00000000000..21f2041b8fb
--- /dev/null
+++ b/srcpkgs/ROCm-OpenCL-Runtime-clinfo
@@ -0,0 +1 @@
+ROCm-OpenCL-Runtime
\ No newline at end of file
diff --git a/srcpkgs/ROCm-OpenCL-Runtime-devel b/srcpkgs/ROCm-OpenCL-Runtime-devel
new file mode 120000
index 00000000000..21f2041b8fb
--- /dev/null
+++ b/srcpkgs/ROCm-OpenCL-Runtime-devel
@@ -0,0 +1 @@
+ROCm-OpenCL-Runtime
\ No newline at end of file
diff --git a/srcpkgs/ROCm-OpenCL-Runtime/files/libelf-musl.patch b/srcpkgs/ROCm-OpenCL-Runtime/files/libelf-musl.patch
new file mode 100644
index 00000000000..29469a9a351
--- /dev/null
+++ b/srcpkgs/ROCm-OpenCL-Runtime/files/libelf-musl.patch
@@ -0,0 +1,21 @@
+--- compiler/lib/loaders/elf/utils/libelf/_libelf.h	2020-04-28 15:50:53.243438174 -0400
++++ compiler/lib/loaders/elf/utils/libelf/_libelf.h	2020-04-28 15:51:54.293435415 -0400
+@@ -35,6 +35,7 @@
+ #include "_libelf_config.h"
+ 
+ #include "_elftc.h"
++#include <sys/cdefs.h>
+ 
+ /*
+  * Library-private data structures.
+--- compiler/lib/loaders/elf/utils/libelf/libelf.h	2020-04-28 15:50:53.244438174 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf.h	2020-04-28 15:52:12.375434593 -0400
+@@ -36,6 +36,8 @@
+ #define EM_HSAIL 0xAF5A
+ #endif
+ 
++#include <sys/cdefs.h>
++
+ /* Library private data structures */
+ typedef struct _Elf Elf;
+ typedef struct _Elf_Scn Elf_Scn;
diff --git a/srcpkgs/ROCm-OpenCL-Runtime/files/runtime-musl.patch b/srcpkgs/ROCm-OpenCL-Runtime/files/runtime-musl.patch
new file mode 100644
index 00000000000..ea18e90e09c
--- /dev/null
+++ b/srcpkgs/ROCm-OpenCL-Runtime/files/runtime-musl.patch
@@ -0,0 +1,11 @@
+--- runtime/os/os_posix.cpp.orig	2020-04-19 09:13:51.701982901 -0400
++++ runtime/os/os_posix.cpp	2020-04-19 09:14:04.156947422 -0400
+@@ -44,6 +44,8 @@
+ #include <algorithm>
+ #include <mutex>
+ 
++#include <libgen.h> // for basename
++
+ 
+ namespace amd {
+ 
diff --git a/srcpkgs/ROCm-OpenCL-Runtime/patches/cmake.patch b/srcpkgs/ROCm-OpenCL-Runtime/patches/cmake.patch
new file mode 100644
index 00000000000..2c96b99d45a
--- /dev/null
+++ b/srcpkgs/ROCm-OpenCL-Runtime/patches/cmake.patch
@@ -0,0 +1,126 @@
+--- OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/CMakeLists.txt	2019-09-10 11:53:28.000000000 -0400
++++ OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/CMakeLists.txt	2020-04-16 20:16:13.481180757 -0400
+@@ -73,11 +73,11 @@
+ 
+ set (OPENCL_ICD_LOADER_HEADERS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/inc CACHE PATH "Path to OpenCL Headers")
+ 
+-add_library (OpenCL ${OPENCL_ICD_LOADER_SOURCES})
+-set_target_properties (OpenCL PROPERTIES VERSION "1.2" SOVERSION "1")
++add_library (OpenCL-ROCm ${OPENCL_ICD_LOADER_SOURCES})
++set_target_properties (OpenCL-ROCm PROPERTIES VERSION "1.2" SOVERSION "1")
+ 
+ if (WIN32)
+-    target_link_libraries (OpenCL cfgmgr32.lib)
++    target_link_libraries (OpenCL-ROCm cfgmgr32.lib)
+ 
+     option (OPENCL_ICD_LOADER_REQUIRE_WDK "Build with D3DKMT support, which requires the Windows WDK." ON)
+     if (OPENCL_ICD_LOADER_REQUIRE_WDK)
+@@ -92,10 +92,10 @@
+             get_filename_component(WDK_DIRECTORY ${LATEST_D3DKMT_HEADER} DIRECTORY)
+             get_filename_component(WDK_DIRECTORY ${WDK_DIRECTORY} DIRECTORY)
+             message(STATUS "Found the Windows WDK in: ${WDK_DIRECTORY}")
+-            target_compile_definitions(OpenCL PRIVATE OPENCL_ICD_LOADER_REQUIRE_WDK)
+-            target_include_directories(OpenCL PRIVATE ${WDK_DIRECTORY}/um)
+-            target_include_directories(OpenCL PRIVATE ${WDK_DIRECTORY}/km)
+-            target_include_directories(OpenCL PRIVATE ${WDK_DIRECTORY}/shared)
++	    target_compile_definitions(OpenCL-ROCm PRIVATE OPENCL_ICD_LOADER_REQUIRE_WDK)
++	    target_include_directories(OpenCL-ROCm PRIVATE ${WDK_DIRECTORY}/um)
++	    target_include_directories(OpenCL-ROCm PRIVATE ${WDK_DIRECTORY}/km)
++	    target_include_directories(OpenCL-ROCm PRIVATE ${WDK_DIRECTORY}/shared)
+         else()
+             message(FATAL_ERROR "The Windows WDK was not found. Consider disabling OPENCL_ICD_LOADER_REQUIRE_WDK. Aborting.")
+         endif()
+@@ -113,25 +113,25 @@
+     endif()
+ else()
+     if (APPLE)
+-        target_link_libraries (OpenCL ${CMAKE_THREAD_LIBS_INIT})
++        target_link_libraries (OpenCL-ROCm ${CMAKE_THREAD_LIBS_INIT})
+     else ()
+-        set_target_properties (OpenCL PROPERTIES LINK_FLAGS "-Wl,--version-script -Wl,${CMAKE_CURRENT_SOURCE_DIR}/loader/linux/icd_exports.map")
+-        target_link_libraries (OpenCL ${CMAKE_THREAD_LIBS_INIT})
++        set_target_properties (OpenCL-ROCm PROPERTIES LINK_FLAGS "-Wl,--version-script -Wl,${CMAKE_CURRENT_SOURCE_DIR}/loader/linux/icd_exports.map")
++	target_link_libraries (OpenCL-ROCm ${CMAKE_THREAD_LIBS_INIT})
+     endif ()
+ endif ()
+ 
+ include_directories (${OPENCL_ICD_LOADER_HEADERS_DIR})
+ add_definitions (-DCL_TARGET_OPENCL_VERSION=220)
+ 
+-target_include_directories (OpenCL PRIVATE ${CMAKE_CURRENT_BINARY_DIR} loader)
+-target_link_libraries (OpenCL ${CMAKE_DL_LIBS})
++target_include_directories (OpenCL-ROCm PRIVATE ${CMAKE_CURRENT_BINARY_DIR} loader)
++target_link_libraries (OpenCL-ROCm ${CMAKE_DL_LIBS})
+ 
+ include (CTest)
+ if (BUILD_TESTING)
+     add_subdirectory (test)
+ endif()
+ 
+-install (TARGETS OpenCL
++install (TARGETS OpenCL-ROCm
+     RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+     ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
+     LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
+--- OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/test/loader_test/CMakeLists.txt	2019-09-10 11:53:28.000000000 -0400
++++ OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/test/loader_test/CMakeLists.txt	2020-04-16 20:16:56.647026589 -0400
+@@ -12,4 +12,4 @@
+     test_clgl.c
+     test_image_objects.c )
+ 
+-target_link_libraries (icd_loader_test OpenCL IcdLog)
++target_link_libraries (icd_loader_test OpenCL-ROCm IcdLog)
+--- ROCm-OpenCL-Runtime-roc-3.3.0/CMakeLists.txt	2020-04-28 07:29:51.864446603 -0400
++++ ROCm-OpenCL-Runtime-roc-3.3.0/CMakeLists.txt	2020-04-28 07:32:45.245793180 -0400
+@@ -101,30 +101,30 @@
+ rocm_setup_version( VERSION "2.0.0" )
+ 
+ # MAIN package
+-install(PROGRAMS $<TARGET_FILE:clinfo>
+-        DESTINATION bin/x86_64
++install(PROGRAMS $<TARGET_FILE:rocm-clinfo>
++        DESTINATION bin
+         COMPONENT MAIN)
+ install(PROGRAMS $<TARGET_FILE:amdocl64>
+-        DESTINATION lib/x86_64
++        DESTINATION lib
+         COMPONENT MAIN)
+-install(PROGRAMS $<TARGET_FILE:OpenCL>
+-        DESTINATION lib/x86_64
++install(PROGRAMS $<TARGET_FILE:OpenCL-ROCm>
++        DESTINATION lib
+         COMPONENT MAIN)
+-install(PROGRAMS $<TARGET_SONAME_FILE:OpenCL>
+-        DESTINATION lib/x86_64
++install(PROGRAMS $<TARGET_SONAME_FILE:OpenCL-ROCm>
++        DESTINATION lib
+         COMPONENT MAIN)
+ 
+ # DEV package
+ install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/api/opencl/khronos/headers/opencl2.2/CL"
+-        DESTINATION include
++	DESTINATION include/rocm
+         COMPONENT DEV
+         USE_SOURCE_PERMISSIONS
+         PATTERN cl_d3d10.h EXCLUDE
+         PATTERN cl_d3d11.h EXCLUDE
+         PATTERN cl_dx9_media_sharing.h EXCLUDE
+         PATTERN cl_egl.h EXCLUDE)
+-install(PROGRAMS $<TARGET_LINKER_FILE:OpenCL>
+-        DESTINATION lib/x86_64
++install(PROGRAMS $<TARGET_LINKER_FILE:OpenCL-ROCm>
++        DESTINATION lib
+         COMPONENT DEV)
+ 
+ # Generic CPACK variables
+--- ROCm-OpenCL-Runtime-roc-3.3.0/tools/clinfo/CMakeLists.txt	2020-04-28 07:29:51.882446535 -0400
++++ ROCm-OpenCL-Runtime-roc-3.3.0/tools/clinfo/CMakeLists.txt	2020-04-28 07:30:05.627394732 -0400
+@@ -6,6 +6,6 @@
+ 
+ add_definitions(-DHAVE_CL2_HPP)
+ 
+-add_executable(clinfo clinfo.cpp)
++add_executable(rocm-clinfo clinfo.cpp)
+ 
+-target_link_libraries(clinfo OpenCL)
++target_link_libraries(rocm-clinfo OpenCL-ROCm)
diff --git a/srcpkgs/ROCm-OpenCL-Runtime/template b/srcpkgs/ROCm-OpenCL-Runtime/template
new file mode 100644
index 00000000000..f6699a1d4c0
--- /dev/null
+++ b/srcpkgs/ROCm-OpenCL-Runtime/template
@@ -0,0 +1,84 @@
+# Template file for 'ROCm-OpenCL-Runtime'
+pkgname=ROCm-OpenCL-Runtime
+version=3.3.0
+revision=1
+_ocl_icd_name="OpenCL-ICD-Loader"
+_ocl_icd_ver="6c03f8b58fafd9dd693eaac826749a5cfad515f8"
+archs="x86_64*"
+create_wrksrc=yes
+build_wrksrc="${pkgname}-roc-${version}"
+build_style=cmake
+configure_args="-DUSE_COMGR_LIBRARY=yes"
+hostmakedepends="cmake pkg-config"
+makedepends="libglvnd-devel ROCm-CompilerSupport-devel
+	ROCT-Thunk-Interface-devel ROCR-Runtime-devel"
+depends="ROCm-CompilerSupport"
+short_desc="Radeon Open Compute OpenCL runtime"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="MIT"
+homepage="https://github.com/RadeonOpenCompute/ROCm-OpenCL-Runtime"
+_rocroot="https://github.com/RadeonOpenCompute"
+distfiles="${_rocroot}/ROCm-OpenCL-Runtime/archive/roc-${version}.tar.gz
+	${_rocroot}/rocm-cmake/archive/rocm-${version}.tar.gz
+	https://github.com/KhronosGroup/${_ocl_icd_name}/archive/${_ocl_icd_ver}.tar.gz"
+checksum="ac6999f1a491ab066286c2bd6adf50f08f831286f56e267879f9f7eced22f98e
+	76ed3ee8e56cf3246011cf7723c2abda539e1136e7e7f6909bfa45d268b8644f
+	c94d5bb6dc980c4d41d73e2b81663a19aabe494e923e2d0eec72a4c95b318438"
+nocross=yes
+
+if [ "$XBPS_LIBC" = "musl" ]; then
+	makedepends+=" musl-legacy-compat"
+fi
+
+post_patch() {
+	if [ "$XBPS_LIBC" = "musl" ]; then
+		# Remove dependence on glibc
+		patch -Np0 < ${FILESDIR}/libelf-musl.patch
+		patch -Np0 < ${FILESDIR}/runtime-musl.patch
+		vsed -e '/glibc_functions.cpp/d' -i api/opencl/amdocl/CMakeLists.txt
+	fi
+}
+
+pre_configure() {
+	# ROCm requires a very specific Khronos ICD loader version in the tree
+	# Keep the ICD loader config in /etc/OpenCL/rocm-vendors to avoid conflicts
+	_ocl_icd_dir="${_ocl_icd_name}-${_ocl_icd_ver}"
+	ln -sf "${wrksrc}/${_ocl_icd_dir}" api/opencl/khronos/icd
+	vsed -i "${wrksrc}/${_ocl_icd_dir}/loader/icd_platform.h" \
+		-e 's@/etc/OpenCL/vendors/@/etc/OpenCL/rocm-vendors/@g'
+
+	# CMake modules probably not useful anywhere but for this build
+	ln -sf "${wrksrc}/rocm-cmake-rocm-${version}/share/rocm/cmake"/*.cmake cmake
+
+	# Fix the dlopen macro to point to versioned libamd_comgr shared object
+	vsed -i 'runtime/device/comgrctx.cpp' \
+		-e 's/\blibamd_comgr\(32\)\?.so\b/&.1/g'
+}
+
+post_install() {
+	vlicense License
+
+	# Create descriptor to allow the ICD loader to find the driver
+	vmkdir etc/OpenCL/rocm-vendors
+	echo "libamdocl64.so" > "${DESTDIR}/etc/OpenCL/rocm-vendors/amdocl64.icd"
+	vmkdir etc/OpenCL/vendors
+	ln -s ../../OpenCL/rocm-vendors/amdocl64.icd \
+		${DESTDIR}/etc/OpenCL/vendors/rocm-amdocl64.icd
+}
+
+ROCm-OpenCL-Runtime-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/lib/libOpenCL-ROCm.so
+		vmove usr/include
+	}
+}
+
+ROCm-OpenCL-Runtime-clinfo_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - clinfo"
+	pkg_install() {
+		vmove usr/bin/rocm-clinfo
+	}
+}
diff --git a/srcpkgs/ROCm-OpenCL-Runtime/update b/srcpkgs/ROCm-OpenCL-Runtime/update
new file mode 100644
index 00000000000..8385f4d1215
--- /dev/null
+++ b/srcpkgs/ROCm-OpenCL-Runtime/update
@@ -0,0 +1 @@
+pattern='roc-\K[\d.]+'

From 789f5187b31789b4b180ca451c55f22674e12391 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Thu, 30 Apr 2020 13:11:12 -0400
Subject: [PATCH 09/10] New package: ROCR-Runtime-hsa-ext-3.3.0

---
 common/shlibs                         |  2 ++
 srcpkgs/ROCR-Runtime-hsa-ext-devel    |  1 +
 srcpkgs/ROCR-Runtime-hsa-ext/template | 43 +++++++++++++++++++++++++++
 srcpkgs/ROCR-Runtime-hsa-ext/update   |  2 ++
 4 files changed, 48 insertions(+)
 create mode 120000 srcpkgs/ROCR-Runtime-hsa-ext-devel
 create mode 100644 srcpkgs/ROCR-Runtime-hsa-ext/template
 create mode 100644 srcpkgs/ROCR-Runtime-hsa-ext/update

diff --git a/common/shlibs b/common/shlibs
index 6311c7612a7..e870e8158c9 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3881,3 +3881,5 @@ libhsa-runtime64.so.1 ROCR-Runtime-3.3.0_1
 libamd_comgr.so.1 ROCm-CompilerSupport-3.3.0_1
 libOpenCL-ROCm.so.1 ROCm-OpenCL-Runtime-3.3.0_1
 libamdocl64.so ROCm-OpenCL-Runtime-3.3.0_1
+libhsa-ext-image64.so.1 ROCR-Runtime-hsa-ext-3.3.0_1
+libhsa-runtime-tools64.so.1 ROCR-Runtime-hsa-ext-3.3.0_1
diff --git a/srcpkgs/ROCR-Runtime-hsa-ext-devel b/srcpkgs/ROCR-Runtime-hsa-ext-devel
new file mode 120000
index 00000000000..6ee1b14911b
--- /dev/null
+++ b/srcpkgs/ROCR-Runtime-hsa-ext-devel
@@ -0,0 +1 @@
+ROCR-Runtime-hsa-ext
\ No newline at end of file
diff --git a/srcpkgs/ROCR-Runtime-hsa-ext/template b/srcpkgs/ROCR-Runtime-hsa-ext/template
new file mode 100644
index 00000000000..235ae92146b
--- /dev/null
+++ b/srcpkgs/ROCR-Runtime-hsa-ext/template
@@ -0,0 +1,43 @@
+# Template file for 'ROCR-Runtime-hsa-ext'
+pkgname=ROCR-Runtime-hsa-ext
+version=3.3.0
+revision=1
+archs="x86_64"
+hostmakedepends="tar"
+short_desc="Radeon Open Compute HSA runtime extensions"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute"
+_hsa_deb="hsa-ext-rocr-dev_1.1.30300.0-rocm-rel-3.3-19-23fc088b_amd64.deb"
+distfiles="https://repo.radeon.com/rocm/apt/debian/pool/main/h/hsa-ext-rocr-dev/$_hsa_deb"
+checksum=6b44e286b395d946b865ec1f3cc546356396785ac1fde591d07af02d0aa7c25d
+repository=nonfree
+restricted=yes
+
+do_extract() {
+	ar x "${XBPS_SRCDISTDIR}/${pkgname}-${version}/${_hsa_deb}"
+	tar xvf data.tar.gz
+}
+
+do_install() {
+	_rocm_includes="opt/rocm-${version}/hsa/include"
+
+	vmkdir usr
+	vcopy opt/rocm-${version}/hsa/lib usr
+	vcopy "$_rocm_includes" usr
+
+	# Extract license from one of the header files
+	awk 'BEGIN{HEADER=0} /\/\//{HEADER=1; print $0;} /^[^/]/{if(HEADER==1) exit;}' \
+		< "${_rocm_includes}/hsa/amd_hsa_tools_interfaces.h" \
+		| sed 's@^///*\( \|$\)@@' > LICENSE
+	vlicense LICENSE
+}
+
+ROCR-Runtime-hsa-ext-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove "usr/lib/*.so"
+	}
+}
diff --git a/srcpkgs/ROCR-Runtime-hsa-ext/update b/srcpkgs/ROCR-Runtime-hsa-ext/update
new file mode 100644
index 00000000000..84252d2e3b8
--- /dev/null
+++ b/srcpkgs/ROCR-Runtime-hsa-ext/update
@@ -0,0 +1,2 @@
+site='https://repo.radeon.com/rocm/apt/debian/pool/main/h/'
+pattern='hsa-ext-rocr-dev\K[\d.]+'

From bf525835c189240b63135757e62d41e37d55294b Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Tue, 28 Apr 2020 13:33:46 -0400
Subject: [PATCH 10/10] hashcat: add build option to link against ROCm [ci
 skip]

---
 srcpkgs/hashcat/files/rocm.patch     | 15 +++++++++++++++
 srcpkgs/hashcat/patches/tmpdir.patch | 21 +++++++++++++++++++++
 srcpkgs/hashcat/template             | 17 ++++++++++++++---
 3 files changed, 50 insertions(+), 3 deletions(-)
 create mode 100644 srcpkgs/hashcat/files/rocm.patch
 create mode 100644 srcpkgs/hashcat/patches/tmpdir.patch

diff --git a/srcpkgs/hashcat/files/rocm.patch b/srcpkgs/hashcat/files/rocm.patch
new file mode 100644
index 00000000000..f1e899d30ee
--- /dev/null
+++ b/srcpkgs/hashcat/files/rocm.patch
@@ -0,0 +1,15 @@
+diff -ur a/src/opencl.c b/src/opencl.c
+--- a/src/opencl.c	2018-12-02 05:58:48.000000000 -0500
++++ b/src/opencl.c	2020-04-28 13:24:12.602415333 -0400
+@@ -492,9 +492,9 @@
+ 
+   if (ocl->lib == NULL) ocl->lib = hc_dlopen ("cygOpenCL-1.dll", RTLD_NOW);
+   #else
+-  ocl->lib = hc_dlopen ("libOpenCL.so", RTLD_NOW);
++  ocl->lib = hc_dlopen ("libOpenCL-ROCm.so.1", RTLD_NOW);
+ 
+-  if (ocl->lib == NULL) ocl->lib = hc_dlopen ("libOpenCL.so.1", RTLD_NOW);
++  if (ocl->lib == NULL) ocl->lib = hc_dlopen ("libOpenCL-ROCm.so", RTLD_NOW);
+   #endif
+ 
+   if (ocl->lib == NULL)
diff --git a/srcpkgs/hashcat/patches/tmpdir.patch b/srcpkgs/hashcat/patches/tmpdir.patch
new file mode 100644
index 00000000000..0558a001c9c
--- /dev/null
+++ b/srcpkgs/hashcat/patches/tmpdir.patch
@@ -0,0 +1,21 @@
+Addresses https://github.com/hashcat/hashcat/issues/2379
+diff -ur a/src/folder.c b/src/folder.c
+--- src/folder.c	2018-12-02 05:58:48.000000000 -0500
++++ src/folder.c	2020-04-28 13:22:27.340522751 -0400
+@@ -457,16 +457,6 @@
+ 
+   hcfree (cpath);
+ 
+-  //if (getenv ("TMP") == NULL)
+-  if (1)
+-  {
+-    char *tmp;
+-
+-    hc_asprintf (&tmp, "TMP=%s", cpath_real);
+-
+-    putenv (tmp);
+-  }
+-
+   #if defined (_WIN)
+ 
+   naive_replace (cpath_real, '\\', '/');
diff --git a/srcpkgs/hashcat/template b/srcpkgs/hashcat/template
index e982f99cebf..3f19be5e41d 100644
--- a/srcpkgs/hashcat/template
+++ b/srcpkgs/hashcat/template
@@ -1,15 +1,16 @@
 # Template file for 'hashcat'
 pkgname=hashcat
 version=5.1.0
-revision=2
+revision=3
 build_style=gnu-makefile
 make_build_args="PREFIX=/usr
  USE_SYSTEM_OPENCL=1 USE_SYSTEM_XXHASH=1
- DEPS_OPENCL_PATH=${XBPS_CROSS_BASE}/usr/include
+ DEPS_OPENCL_PATH=${XBPS_CROSS_BASE}/usr/include$(vopt_if rocm /rocm)
  DEPS_XXHASH_PATH=${XBPS_CROSS_BASE}/usr/include"
 make_use_env=yes
 make_install_args="$make_build_args"
-makedepends="gmp-devel opencl2-headers xxHash-devel"
+makedepends="gmp-devel xxHash-devel
+ $(vopt_if rocm ROCm-OpenCL-Runtime-devel opencl2-headers)"
 checkdepends="perl"
 short_desc="Advanced CPU-based password recovery utility"
 maintainer="Duncaen <duncaen@voidlinux.org>"
@@ -19,6 +20,9 @@ changelog="https://raw.githubusercontent.com/hashcat/hashcat/master/docs/changes
 distfiles="https://hashcat.net/files/hashcat-${version}.tar.gz"
 checksum=283beaa68e1eab41de080a58bb92349c8e47a2bb1b93d10f36ea30f418f1e338
 
+build_options="rocm"
+desc_option_rocm="Use ROCm OpenCL runtime"
+
 if [ "$XBPS_TARGET_ENDIAN" = "be" ]; then
 	broken="Not supported on big endian"
 fi
@@ -26,6 +30,13 @@ fi
 post_extract() {
 	sed '/^CC/d' -i src/Makefile
 }
+
+post_patch() {
+	if [ "$build_option_rocm" ]; then
+		patch -Np1 < ${FILESDIR}/rocm.patch
+	fi
+}
+
 post_install() {
 	rm -f ${DESTDIR}/usr/share/docs/hashcat/license.txt
 	vlicense docs/license.txt

^ permalink raw reply	[flat|nested] 61+ messages in thread

* Re: [PR PATCH] [Updated] New packages: ROCm core and OpenCL
  2020-04-19 13:34 [PR PATCH] New packages: ROCm core and OpenCL ahesford
                   ` (26 preceding siblings ...)
  2020-05-05 14:26 ` ahesford
@ 2020-05-07 14:18 ` ahesford
  2020-05-07 16:01 ` ahesford
                   ` (31 subsequent siblings)
  59 siblings, 0 replies; 61+ messages in thread
From: ahesford @ 2020-05-07 14:18 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 3893 bytes --]

There is an updated pull request by ahesford against master on the void-packages repository

https://github.com/ahesford/void-packages rocm
https://github.com/void-linux/void-packages/pull/21153

New packages: ROCm core and OpenCL
This PR includes several packages designed to bring the OpenCL portion of the AMD ROCm ecosystem to Void. It addresses Issue #19507. There are many other packages that AMD provides for GPGPU computing, but these can be added piecemeal as users demand.

The packages are currently only for `x86_64*`. While at least some of the packages will compile on other 64-bit architectures, I have no hardware to test. They are certainly not suitable for 32-bit architectures; some internal data structures rely on `uint64_t` values that are cast to pointers. At a
minimum, a thorough audit would be necessary to ensure that these casts are safe (e.g., that the values stored were only ever upcast from 32-bit pointers). More extensive work may be necessary to support 32-bit architectures, probably without significant benefit.

The packages successfully identify a Radeon RX 580 on an `x86_64` installation using both `clinfo` and `rocminfo` as provided. Furthermore, a version of `pyopencl` linked against these ROCm packages successfully runs a simple program that validates arithmetic on GPU-bound arrays.

There are caveats with this set of packages, almost all of which revolve around the incompatibilities between the Void-provided `ocl-icd` and the [Khronos OpenCL ICD loader](https://github.com/KhronosGroup/OpenCL-ID-Loader) required by (and built into) `rocm-opencl-runtime`.
1. All packages install into `/opt/rocm`. This keeps the environment closer to that officially sanctioned by AMD and helps avoid conflicts between other packages and those provided here. (For example, `clinfo` and the ICD loader itself.) Eventually, we may be able to move the files into `/usr`.
2. The Khronos OpenCL ICD loader built into `rocm-opencl-runtime` is an outdated, pre-release commit. If AMD can update its sources to use the release version of that loader (which has a backward-incompatible API change), we may be able to make ROCm compatible with `ocl-icd` or replace `ocl-icd` with the official Khronos loader.
3. In the meantime, to avoid `shlibs` conflicts, the OpenCL ICD loader is installed as `/opt/rocm/lib/libOpenCL-ROCm.so` (and an appropriately versioned shared library), which means that programs wishing to use the ROCm OpenCL must explicitly link against this library instead of the generic `libOpenCL.so`.
4. I do **not** recommend making any Void packages link against this specific library, because it will make those packages ROCm-only. For the time being, ROCm is intended for end-users to specifically link against. Linking Void packages against ROCm would requires the ICD loader used by ROCm be compatible with `ocl-icd`, or `ocl-icd` be replaced by the Khronos loader. However, because the Khronos loader changed its API for the release version, such a change is not yet appropriate.

Hopefully, if AMD updates its dependence on the Khronos ICD loader, we can resolve some of these caveats in the future and make ROCm a more natural Void component. For now, these packages are useful for those who need an AMD OpenCL solution and would rather custom-link software against the AMD ICD loader than hack the `amdgpu-pro` driver into an ICD compatible with `ocl-icd`.

Some patches were made to relocate some files in `/opt/rocm` and make everyting build on x86_64-musl`. Where appropriate, these patches will be pushed upstream to clean up the distribution and packaging.

Update: I pushed some new commits to update license information that triggerd an `xlint` failure. I've also disabled CI builds because they will time out on `rocm-llvm`.

A patch file from https://github.com/void-linux/void-packages/pull/21153.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-rocm-21153.patch --]
[-- Type: text/x-diff, Size: 39022 bytes --]

From bbc0c840a7208d34e66cc2b875cb72ec1b09a694 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Mon, 13 Apr 2020 13:08:09 -0400
Subject: [PATCH 01/10] New package: ROCT-Thunk-Interface-3.3.0

---
 common/shlibs                                 |  2 ++
 srcpkgs/ROCT-Thunk-Interface-devel            |  1 +
 .../patches/cmake-dev-libdir.patch            | 10 ++++++
 .../ROCT-Thunk-Interface/patches/musl.patch   | 29 ++++++++++++++++
 srcpkgs/ROCT-Thunk-Interface/template         | 33 +++++++++++++++++++
 srcpkgs/ROCT-Thunk-Interface/update           |  1 +
 6 files changed, 76 insertions(+)
 create mode 120000 srcpkgs/ROCT-Thunk-Interface-devel
 create mode 100644 srcpkgs/ROCT-Thunk-Interface/patches/cmake-dev-libdir.patch
 create mode 100644 srcpkgs/ROCT-Thunk-Interface/patches/musl.patch
 create mode 100644 srcpkgs/ROCT-Thunk-Interface/template
 create mode 100644 srcpkgs/ROCT-Thunk-Interface/update

diff --git a/common/shlibs b/common/shlibs
index 4bdc03e8b23..34aa1dc0993 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3875,3 +3875,5 @@ libhidrd_opt.so.0 hidrd-0.2.0_1
 libhidrd_strm.so.0 hidrd-0.2.0_1
 libhidrd_fmt.so.0 hidrd-0.2.0_1
 libjcat.so.1 libjcat-0.1.2_1
+
+libhsakmt.so.1 ROCT-Thunk-Interface-3.3.0_1
diff --git a/srcpkgs/ROCT-Thunk-Interface-devel b/srcpkgs/ROCT-Thunk-Interface-devel
new file mode 120000
index 00000000000..7e43c209e3d
--- /dev/null
+++ b/srcpkgs/ROCT-Thunk-Interface-devel
@@ -0,0 +1 @@
+ROCT-Thunk-Interface
\ No newline at end of file
diff --git a/srcpkgs/ROCT-Thunk-Interface/patches/cmake-dev-libdir.patch b/srcpkgs/ROCT-Thunk-Interface/patches/cmake-dev-libdir.patch
new file mode 100644
index 00000000000..98c7f1e459c
--- /dev/null
+++ b/srcpkgs/ROCT-Thunk-Interface/patches/cmake-dev-libdir.patch
@@ -0,0 +1,10 @@
+--- CMakeLists.txt.old	2020-04-18 19:45:17.306081135 -0400
++++ CMakeLists.txt	2020-04-18 19:46:51.300753636 -0400
+@@ -146,6 +146,7 @@
+     COMMAND ${CMAKE_COMMAND}
+         -DSOURCE_DIR="${SOURCE_DIR}"
+         -DCMAKE_INSTALL_PREFIX="${CMAKE_INSTALL_PREFIX}"
++        -DCMAKE_INSTALL_LIBDIR="${CMAKE_INSTALL_LIBDIR}"
+         -DCPACK_RPM_PACKAGE_REQUIRES="hsakmt-roct"
+         -DCPACK_PACKAGING_INSTALL_PREFIX="${CPACK_PACKAGING_INSTALL_PREFIX}"
+         -DVERSION="${BUILD_VERSION_STRING}"
diff --git a/srcpkgs/ROCT-Thunk-Interface/patches/musl.patch b/srcpkgs/ROCT-Thunk-Interface/patches/musl.patch
new file mode 100644
index 00000000000..aeea9832411
--- /dev/null
+++ b/srcpkgs/ROCT-Thunk-Interface/patches/musl.patch
@@ -0,0 +1,29 @@
+diff -r -u old/src/libhsakmt.h new/src/libhsakmt.h
+--- src/libhsakmt.h	2020-03-04 15:00:47.000000000 -0500
++++ src/libhsakmt.h	2020-04-13 12:58:30.444865992 -0400
+@@ -54,6 +54,10 @@
+ #define CHECK_KFD_OPEN() \
+ 	do { if (kfd_open_count == 0 || hsakmt_forked) return HSAKMT_STATUS_KERNEL_IO_CHANNEL_NOT_OPENED; } while (0)
+ 
++/*On some platforms, a PAGE_SIZE macro eclipses the extern variable*/
++#ifdef PAGE_SIZE
++#undef PAGE_SIZE
++#endif
+ extern int PAGE_SIZE;
+ extern int PAGE_SHIFT;
+ 
+diff -r -u old/src/topology.c new/src/topology.c
+--- src/topology.c	2020-03-04 15:00:47.000000000 -0500
++++ src/topology.c	2020-04-13 13:01:31.209870701 -0400
+@@ -38,6 +38,11 @@
+ #include "libhsakmt.h"
+ #include "fmm.h"
+ 
++/*Needed on MUSL*/
++#ifndef MAXNAMLEN
++#define MAXNAMLEN PATH_MAX
++#endif
++
+ /* Number of memory banks added by thunk on top of topology
+  * This only includes static heaps like LDS, scratch and SVM,
+  * not for MMIO_REMAP heap. MMIO_REMAP memory bank is reported
diff --git a/srcpkgs/ROCT-Thunk-Interface/template b/srcpkgs/ROCT-Thunk-Interface/template
new file mode 100644
index 00000000000..8c680b2af29
--- /dev/null
+++ b/srcpkgs/ROCT-Thunk-Interface/template
@@ -0,0 +1,33 @@
+# Template file for 'ROCT-Thunk-Interface'
+pkgname=ROCT-Thunk-Interface
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="${pkgname}-roc-${version}"
+build_style=cmake
+make_build_target="all build-dev"
+make_install_target="install install-dev"
+hostmakedepends="cmake pkg-config"
+makedepends="pciutils-devel libnuma-devel"
+short_desc="Radeon Open Compute thunk interface"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="MIT"
+homepage="https://github.com/RadeonOpenCompute/ROCT-Thunk-Interface"
+distfiles="${homepage}/archive/roc-${version}.tar.gz"
+checksum=2cabe9d2cfa72031c05d11290837c476182e72d8dec2049298f691143fdd212b
+nocross=yes
+
+post_install() {
+	vlicense LICENSE.md
+}
+
+ROCT-Thunk-Interface-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove "usr/lib/*.so"
+		vmove usr/share/pkgconfig
+		vmove usr/lib/cmake
+	}
+}
diff --git a/srcpkgs/ROCT-Thunk-Interface/update b/srcpkgs/ROCT-Thunk-Interface/update
new file mode 100644
index 00000000000..8385f4d1215
--- /dev/null
+++ b/srcpkgs/ROCT-Thunk-Interface/update
@@ -0,0 +1 @@
+pattern='roc-\K[\d.]+'

From 10f5b13fb0fca23ffc3c51eab5f60981740c0337 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Mon, 13 Apr 2020 15:27:27 -0400
Subject: [PATCH 02/10] New package: ROCR-Runtime-3.3.0

---
 common/shlibs                            |  1 +
 srcpkgs/ROCR-Runtime-devel               |  1 +
 srcpkgs/ROCR-Runtime/patches/cmake.patch | 27 +++++++++++++++++++++
 srcpkgs/ROCR-Runtime/template            | 30 ++++++++++++++++++++++++
 srcpkgs/ROCR-Runtime/update              |  1 +
 5 files changed, 60 insertions(+)
 create mode 120000 srcpkgs/ROCR-Runtime-devel
 create mode 100644 srcpkgs/ROCR-Runtime/patches/cmake.patch
 create mode 100644 srcpkgs/ROCR-Runtime/template
 create mode 100644 srcpkgs/ROCR-Runtime/update

diff --git a/common/shlibs b/common/shlibs
index 34aa1dc0993..447a5e23a43 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3877,3 +3877,4 @@ libhidrd_fmt.so.0 hidrd-0.2.0_1
 libjcat.so.1 libjcat-0.1.2_1
 
 libhsakmt.so.1 ROCT-Thunk-Interface-3.3.0_1
+libhsa-runtime64.so.1 ROCR-Runtime-3.3.0_1
diff --git a/srcpkgs/ROCR-Runtime-devel b/srcpkgs/ROCR-Runtime-devel
new file mode 120000
index 00000000000..a733fb9fbab
--- /dev/null
+++ b/srcpkgs/ROCR-Runtime-devel
@@ -0,0 +1 @@
+ROCR-Runtime
\ No newline at end of file
diff --git a/srcpkgs/ROCR-Runtime/patches/cmake.patch b/srcpkgs/ROCR-Runtime/patches/cmake.patch
new file mode 100644
index 00000000000..93b74cd2297
--- /dev/null
+++ b/srcpkgs/ROCR-Runtime/patches/cmake.patch
@@ -0,0 +1,27 @@
+--- src/CMakeLists.txt.old	2020-04-18 20:01:48.549636995 -0400
++++ src/CMakeLists.txt	2020-04-18 20:04:00.177179781 -0400
+@@ -108,8 +108,8 @@
+ ## ROCr build internal versioning
+ add_definitions ( -DROCR_BUILD_ID=${PACKAGE_VERSION_STRING} )
+ 
+-## Set RUNPATH - ../../lib covers use of the legacy symlink in /hsa/lib/
+-set(CMAKE_INSTALL_RPATH "$ORIGIN;$ORIGIN/../../lib;$ORIGIN/../../lib64;$ORIGIN/../lib64")
++## Set RUNPATH
++set(CMAKE_INSTALL_RPATH "$ORIGIN;$ORIGIN/../lib")
+ 
+ ## ------------------------- Linux Compiler and Linker options -------------------------
+ set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -fexceptions -fno-rtti -fvisibility=hidden -Wno-error=sign-compare -Wno-sign-compare -Wno-write-strings -Wno-conversion-null -fno-math-errno -fno-threadsafe-statics -fmerge-all-constants -fms-extensions -Wno-error=comment -Wno-comment -Wno-error=pointer-arith -Wno-pointer-arith -Wno-error=unused-variable -Wno-error=unused-function" )
+@@ -185,11 +185,8 @@
+ add_custom_target ( hsa_lib_link2 ALL WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMAND ${CMAKE_COMMAND} -E create_symlink ../hsa/lib/${CORE_RUNTIME_LIBRARY}.so.${SO_MAJOR} ${CORE_RUNTIME_LIBRARY}-link.so.${SO_MAJOR} )
+ 
+ ## Set install information
+-install ( TARGETS ${CORE_RUNTIME_TARGET} LIBRARY DESTINATION hsa/lib )
+-install ( DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/inc/ DESTINATION hsa/include/hsa )
+-install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/hsa_include_link DESTINATION include PERMISSIONS OWNER_WRITE OWNER_READ RENAME hsa )
+-install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/${CORE_RUNTIME_LIBRARY}-link.so DESTINATION lib PERMISSIONS OWNER_WRITE OWNER_READ RENAME ${CORE_RUNTIME_LIBRARY}.so )
+-install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/${CORE_RUNTIME_LIBRARY}-link.so.${SO_MAJOR} DESTINATION lib PERMISSIONS OWNER_WRITE OWNER_READ RENAME ${CORE_RUNTIME_LIBRARY}.so.${SO_MAJOR} )
++install ( TARGETS ${CORE_RUNTIME_TARGET} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} )
++install ( DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/inc/ DESTINATION include/hsa )
+ 
+ ## Packaging directives
+ set ( CPACK_GENERATOR "DEB;RPM" CACHE STRING "Package types to build")
diff --git a/srcpkgs/ROCR-Runtime/template b/srcpkgs/ROCR-Runtime/template
new file mode 100644
index 00000000000..95b7e701afb
--- /dev/null
+++ b/srcpkgs/ROCR-Runtime/template
@@ -0,0 +1,30 @@
+# Template file for 'ROCR-Runtime'
+pkgname=ROCR-Runtime
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="${pkgname}-rocm-${version}"
+build_wrksrc="src"
+build_style=cmake
+hostmakedepends="cmake pkg-config"
+makedepends="ROCT-Thunk-Interface-devel elfutils-devel"
+short_desc="Radeon Open Compute HSA runtime"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute/ROCR-Runtime"
+distfiles="${homepage}/archive/rocm-${version}.tar.gz"
+checksum=fa2d2d1f8a61d8a6952d377cf288d78c61776c3c2a666f163cafc3aa19ab0b61
+nocross=yes
+
+post_install() {
+	vlicense ../LICENSE.txt
+}
+
+ROCR-Runtime-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove "usr/lib/*.so"
+	}
+}
diff --git a/srcpkgs/ROCR-Runtime/update b/srcpkgs/ROCR-Runtime/update
new file mode 100644
index 00000000000..86197bc3eea
--- /dev/null
+++ b/srcpkgs/ROCR-Runtime/update
@@ -0,0 +1 @@
+pattern='rocm-\K[\d.]+'

From 10c4bf56844a682e5b4deea4e67eee2259e2f461 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Mon, 13 Apr 2020 18:07:34 -0400
Subject: [PATCH 03/10] New package: ROCm-llvm-3.3.0

---
 srcpkgs/ROCm-llvm/template | 26 ++++++++++++++++++++++++++
 srcpkgs/ROCm-llvm/update   |  1 +
 2 files changed, 27 insertions(+)
 create mode 100644 srcpkgs/ROCm-llvm/template
 create mode 100644 srcpkgs/ROCm-llvm/update

diff --git a/srcpkgs/ROCm-llvm/template b/srcpkgs/ROCm-llvm/template
new file mode 100644
index 00000000000..4c3095b21f4
--- /dev/null
+++ b/srcpkgs/ROCm-llvm/template
@@ -0,0 +1,26 @@
+# Template file for 'ROCm-llvm'
+pkgname=ROCm-llvm
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="llvm-project-rocm-ocl-${version}"
+build_wrksrc=llvm
+build_style=cmake
+configure_args="-DCMAKE_INSTALL_PREFIX:PATH=/usr/lib/rocm-llvm
+	-DLLVM_ENABLE_PROJECTS='llvm;clang;lld' -DLLVM_TARGETS_TO_BUILD='AMDGPU'
+	-DLLVM_BUILD_DOCS=NO -DLLVM_ENABLE_OCAMLDOC=OFF
+	-DLLVM_ENABLE_SPHINX=NO -DLLVM_ENABLE_DOXYGEN=OFF
+	-DLLVM_INSTALL_UTILS=ON -DLLVM_VERSION_SUFFIX=roc -DOCAMLFIND=NO"
+hostmakedepends="cmake pkg-config python3"
+short_desc="Radeon Open Compute LLVM toolchain"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="Apache-2.0, NCSA, custom:LLVM-Exceptions"
+homepage="https://github.com/RadeonOpenCompute/llvm-project"
+distfiles="${homepage}/archive/rocm-ocl-${version}.tar.gz"
+checksum=a2bef7042e8e2f2cd8548cb246b88322e1c77188839983dcac8312d56f544dc8
+python_version=3
+nocross=yes
+
+post_install() {
+	vlicense LICENSE.TXT
+}
diff --git a/srcpkgs/ROCm-llvm/update b/srcpkgs/ROCm-llvm/update
new file mode 100644
index 00000000000..6a73667d3c1
--- /dev/null
+++ b/srcpkgs/ROCm-llvm/update
@@ -0,0 +1 @@
+pattern='rocm-ocl-\K[\d.]+'

From 22e98db9716a80699f9ee0c660be4422dcb9941e Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Tue, 14 Apr 2020 10:25:31 -0400
Subject: [PATCH 04/10] New package: ROCm-Device-Libs-3.3.0

---
 srcpkgs/ROCm-Device-Libs/template | 37 +++++++++++++++++++++++++++++++
 srcpkgs/ROCm-Device-Libs/update   |  1 +
 2 files changed, 38 insertions(+)
 create mode 100644 srcpkgs/ROCm-Device-Libs/template
 create mode 100644 srcpkgs/ROCm-Device-Libs/update

diff --git a/srcpkgs/ROCm-Device-Libs/template b/srcpkgs/ROCm-Device-Libs/template
new file mode 100644
index 00000000000..8086cd86450
--- /dev/null
+++ b/srcpkgs/ROCm-Device-Libs/template
@@ -0,0 +1,37 @@
+# Template file for 'ROCm-Device-Libs'
+pkgname=ROCm-Device-Libs
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="${pkgname}-rocm-ocl-${version}"
+build_style=cmake
+configure_args="-DLLVM_DIR:PATH=/usr/lib/rocm-llvm
+	-DCMAKE_INSTALL_LIBDIR:PATH=lib/rocm-device-libs"
+hostmakedepends="cmake ROCm-llvm"
+short_desc="Radeon Open Compute device libraries"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute/ROCm-Device-Libs"
+distfiles="${homepage}/archive/rocm-ocl-${version}.tar.gz"
+checksum=706b08230790e08ca6a7a2fb7687d6131fd39a562148340e00fa37a6c06769c5
+nocross=yes
+
+pre_configure() {
+	# Put bytecodes in a lib/ subdirectory
+	vsed -i Packages.cmake -e 's@/lib/@/${CMAKE_INSTALL_LIBDIR}/@'
+	vsed -i OCL.cmake -e 's@DESTINATION lib$@DESTINATION ${CMAKE_INSTALL_LIBDIR}@'
+
+	# Build the prepare-builtins executable with native compiler
+	mkdir -p utils/build
+	cd utils/build
+	_prepare_builtins="$PWD/prepare-builtins/prepare-builtins"
+	cmake ${configure_args} ..
+	make ${makejobs}
+
+	# Add path to prepare-builtins for cmake
+	configure_args+=" -DPREPARE_BUILTINS='${_prepare_builtins}'"
+}
+
+post_install() {
+	vlicense LICENSE
+}
diff --git a/srcpkgs/ROCm-Device-Libs/update b/srcpkgs/ROCm-Device-Libs/update
new file mode 100644
index 00000000000..6a73667d3c1
--- /dev/null
+++ b/srcpkgs/ROCm-Device-Libs/update
@@ -0,0 +1 @@
+pattern='rocm-ocl-\K[\d.]+'

From b3a571c635026054c579a4826b2cda9df84f1490 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Mon, 13 Apr 2020 18:30:00 -0400
Subject: [PATCH 05/10] New package: ROCm-CompilerSupport-3.3.0

---
 common/shlibs                         |  1 +
 srcpkgs/ROCm-CompilerSupport-devel    |  1 +
 srcpkgs/ROCm-CompilerSupport/template | 32 +++++++++++++++++++++++++++
 srcpkgs/ROCm-CompilerSupport/update   |  1 +
 4 files changed, 35 insertions(+)
 create mode 120000 srcpkgs/ROCm-CompilerSupport-devel
 create mode 100644 srcpkgs/ROCm-CompilerSupport/template
 create mode 100644 srcpkgs/ROCm-CompilerSupport/update

diff --git a/common/shlibs b/common/shlibs
index 447a5e23a43..83cc61a42be 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3878,3 +3878,4 @@ libjcat.so.1 libjcat-0.1.2_1
 
 libhsakmt.so.1 ROCT-Thunk-Interface-3.3.0_1
 libhsa-runtime64.so.1 ROCR-Runtime-3.3.0_1
+libamd_comgr.so.1 ROCm-CompilerSupport-3.3.0_1
diff --git a/srcpkgs/ROCm-CompilerSupport-devel b/srcpkgs/ROCm-CompilerSupport-devel
new file mode 120000
index 00000000000..877aeafeeae
--- /dev/null
+++ b/srcpkgs/ROCm-CompilerSupport-devel
@@ -0,0 +1 @@
+ROCm-CompilerSupport
\ No newline at end of file
diff --git a/srcpkgs/ROCm-CompilerSupport/template b/srcpkgs/ROCm-CompilerSupport/template
new file mode 100644
index 00000000000..df56f7a3837
--- /dev/null
+++ b/srcpkgs/ROCm-CompilerSupport/template
@@ -0,0 +1,32 @@
+# Template file for 'ROCm-CompilerSupport'
+pkgname=ROCm-CompilerSupport
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="${pkgname}-rocm-${version}"
+build_wrksrc="lib/comgr"
+build_style=cmake
+configure_args="-DClang_DIR:PATH=/usr/lib/rocm-llvm/lib/cmake/clang"
+hostmakedepends="cmake pkg-config ROCm-llvm"
+makedepends="ROCm-Device-Libs"
+short_desc="Radeon Open Compute compiler support"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="BSD-3-Clause"
+homepage="https://github.com/RadeonOpenCompute/ROCm-CompilerSupport"
+distfiles="${homepage}/archive/rocm-${version}.tar.gz"
+checksum=01e2524e0f28ecd6f46c9720f279207de935d826b0172158792aa3ec86af9ca7
+nocross=yes
+
+post_install() {
+	vlicense LICENSE.txt
+}
+
+ROCm-CompilerSupport-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove "usr/lib/*.so"
+		vmove usr/lib/cmake
+	}
+}
diff --git a/srcpkgs/ROCm-CompilerSupport/update b/srcpkgs/ROCm-CompilerSupport/update
new file mode 100644
index 00000000000..86197bc3eea
--- /dev/null
+++ b/srcpkgs/ROCm-CompilerSupport/update
@@ -0,0 +1 @@
+pattern='rocm-\K[\d.]+'

From 85102ff0449de3a64be795d640b19b3b4b2f4dab Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Fri, 17 Apr 2020 12:11:25 -0400
Subject: [PATCH 06/10] New package: rocminfo-3.3.0

---
 srcpkgs/rocminfo/template | 22 ++++++++++++++++++++++
 srcpkgs/rocminfo/update   |  1 +
 2 files changed, 23 insertions(+)
 create mode 100644 srcpkgs/rocminfo/template
 create mode 100644 srcpkgs/rocminfo/update

diff --git a/srcpkgs/rocminfo/template b/srcpkgs/rocminfo/template
new file mode 100644
index 00000000000..7a075c7f7ac
--- /dev/null
+++ b/srcpkgs/rocminfo/template
@@ -0,0 +1,22 @@
+# Template file for 'rocminfo'
+pkgname=rocminfo
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="${pkgname}-rocm-${version}"
+build_style=cmake
+configure_args="-DROCM_DIR=/usr"
+hostmakedepends="cmake pkg-config"
+makedepends="ROCR-Runtime-devel"
+short_desc="Radeon Open Compute system information reporter"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute/rocminfo"
+distfiles="${homepage}/archive/rocm-${version}.tar.gz"
+checksum=e666f662c9e465aaabbbd0b109d87e017243cdf1a0898fabf5a90947bb3dbcd7
+nocross=yes
+python_version=3
+
+post_install() {
+	vlicense License.txt
+}
diff --git a/srcpkgs/rocminfo/update b/srcpkgs/rocminfo/update
new file mode 100644
index 00000000000..86197bc3eea
--- /dev/null
+++ b/srcpkgs/rocminfo/update
@@ -0,0 +1 @@
+pattern='rocm-\K[\d.]+'

From 40a616fc416c824da8a95d3daaa8c1235d6bdc40 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Sun, 19 Apr 2020 15:01:40 -0400
Subject: [PATCH 07/10] New package: rocm_bandwidth_test-3.3.0

---
 srcpkgs/rocm_bandwidth_test/template | 20 ++++++++++++++++++++
 srcpkgs/rocm_bandwidth_test/update   |  1 +
 2 files changed, 21 insertions(+)
 create mode 100644 srcpkgs/rocm_bandwidth_test/template
 create mode 100644 srcpkgs/rocm_bandwidth_test/update

diff --git a/srcpkgs/rocm_bandwidth_test/template b/srcpkgs/rocm_bandwidth_test/template
new file mode 100644
index 00000000000..6de7f2d6614
--- /dev/null
+++ b/srcpkgs/rocm_bandwidth_test/template
@@ -0,0 +1,20 @@
+# Template file for 'rocm_bandwidth_test'
+pkgname=rocm_bandwidth_test
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="${pkgname}-rocm-${version}"
+build_style=cmake
+hostmakedepends="cmake"
+makedepends="ROCR-Runtime-devel ROCT-Thunk-Interface-devel"
+short_desc="Radeon Open Compute bandwidth test"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute/rocm_bandwidth_test"
+distfiles="${homepage}/archive/rocm-${version}.tar.gz"
+checksum=f5f914073018619dc91662d5bf630903dfa4db9136d603591917fdfb3c9164ce
+nocross=yes
+
+post_install() {
+	vlicense LICENSE.txt
+}
diff --git a/srcpkgs/rocm_bandwidth_test/update b/srcpkgs/rocm_bandwidth_test/update
new file mode 100644
index 00000000000..86197bc3eea
--- /dev/null
+++ b/srcpkgs/rocm_bandwidth_test/update
@@ -0,0 +1 @@
+pattern='rocm-\K[\d.]+'

From 7ca769a7fb95482a6bab6df5b9820e9e250e7102 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Tue, 14 Apr 2020 10:25:54 -0400
Subject: [PATCH 08/10] New package: ROCm-OpenCL-Runtime-3.3.0

---
 common/shlibs                                 |   2 +
 srcpkgs/ROCm-OpenCL-Runtime-clinfo            |   1 +
 srcpkgs/ROCm-OpenCL-Runtime-devel             |   1 +
 .../files/libelf-musl.patch                   |  21 +++
 .../files/runtime-musl.patch                  |  11 ++
 .../ROCm-OpenCL-Runtime/patches/cmake.patch   | 126 ++++++++++++++++++
 srcpkgs/ROCm-OpenCL-Runtime/template          |  84 ++++++++++++
 srcpkgs/ROCm-OpenCL-Runtime/update            |   1 +
 8 files changed, 247 insertions(+)
 create mode 120000 srcpkgs/ROCm-OpenCL-Runtime-clinfo
 create mode 120000 srcpkgs/ROCm-OpenCL-Runtime-devel
 create mode 100644 srcpkgs/ROCm-OpenCL-Runtime/files/libelf-musl.patch
 create mode 100644 srcpkgs/ROCm-OpenCL-Runtime/files/runtime-musl.patch
 create mode 100644 srcpkgs/ROCm-OpenCL-Runtime/patches/cmake.patch
 create mode 100644 srcpkgs/ROCm-OpenCL-Runtime/template
 create mode 100644 srcpkgs/ROCm-OpenCL-Runtime/update

diff --git a/common/shlibs b/common/shlibs
index 83cc61a42be..99326e93f0f 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3879,3 +3879,5 @@ libjcat.so.1 libjcat-0.1.2_1
 libhsakmt.so.1 ROCT-Thunk-Interface-3.3.0_1
 libhsa-runtime64.so.1 ROCR-Runtime-3.3.0_1
 libamd_comgr.so.1 ROCm-CompilerSupport-3.3.0_1
+libOpenCL-ROCm.so.1 ROCm-OpenCL-Runtime-3.3.0_1
+libamdocl64.so ROCm-OpenCL-Runtime-3.3.0_1
diff --git a/srcpkgs/ROCm-OpenCL-Runtime-clinfo b/srcpkgs/ROCm-OpenCL-Runtime-clinfo
new file mode 120000
index 00000000000..21f2041b8fb
--- /dev/null
+++ b/srcpkgs/ROCm-OpenCL-Runtime-clinfo
@@ -0,0 +1 @@
+ROCm-OpenCL-Runtime
\ No newline at end of file
diff --git a/srcpkgs/ROCm-OpenCL-Runtime-devel b/srcpkgs/ROCm-OpenCL-Runtime-devel
new file mode 120000
index 00000000000..21f2041b8fb
--- /dev/null
+++ b/srcpkgs/ROCm-OpenCL-Runtime-devel
@@ -0,0 +1 @@
+ROCm-OpenCL-Runtime
\ No newline at end of file
diff --git a/srcpkgs/ROCm-OpenCL-Runtime/files/libelf-musl.patch b/srcpkgs/ROCm-OpenCL-Runtime/files/libelf-musl.patch
new file mode 100644
index 00000000000..29469a9a351
--- /dev/null
+++ b/srcpkgs/ROCm-OpenCL-Runtime/files/libelf-musl.patch
@@ -0,0 +1,21 @@
+--- compiler/lib/loaders/elf/utils/libelf/_libelf.h	2020-04-28 15:50:53.243438174 -0400
++++ compiler/lib/loaders/elf/utils/libelf/_libelf.h	2020-04-28 15:51:54.293435415 -0400
+@@ -35,6 +35,7 @@
+ #include "_libelf_config.h"
+ 
+ #include "_elftc.h"
++#include <sys/cdefs.h>
+ 
+ /*
+  * Library-private data structures.
+--- compiler/lib/loaders/elf/utils/libelf/libelf.h	2020-04-28 15:50:53.244438174 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf.h	2020-04-28 15:52:12.375434593 -0400
+@@ -36,6 +36,8 @@
+ #define EM_HSAIL 0xAF5A
+ #endif
+ 
++#include <sys/cdefs.h>
++
+ /* Library private data structures */
+ typedef struct _Elf Elf;
+ typedef struct _Elf_Scn Elf_Scn;
diff --git a/srcpkgs/ROCm-OpenCL-Runtime/files/runtime-musl.patch b/srcpkgs/ROCm-OpenCL-Runtime/files/runtime-musl.patch
new file mode 100644
index 00000000000..ea18e90e09c
--- /dev/null
+++ b/srcpkgs/ROCm-OpenCL-Runtime/files/runtime-musl.patch
@@ -0,0 +1,11 @@
+--- runtime/os/os_posix.cpp.orig	2020-04-19 09:13:51.701982901 -0400
++++ runtime/os/os_posix.cpp	2020-04-19 09:14:04.156947422 -0400
+@@ -44,6 +44,8 @@
+ #include <algorithm>
+ #include <mutex>
+ 
++#include <libgen.h> // for basename
++
+ 
+ namespace amd {
+ 
diff --git a/srcpkgs/ROCm-OpenCL-Runtime/patches/cmake.patch b/srcpkgs/ROCm-OpenCL-Runtime/patches/cmake.patch
new file mode 100644
index 00000000000..2c96b99d45a
--- /dev/null
+++ b/srcpkgs/ROCm-OpenCL-Runtime/patches/cmake.patch
@@ -0,0 +1,126 @@
+--- OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/CMakeLists.txt	2019-09-10 11:53:28.000000000 -0400
++++ OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/CMakeLists.txt	2020-04-16 20:16:13.481180757 -0400
+@@ -73,11 +73,11 @@
+ 
+ set (OPENCL_ICD_LOADER_HEADERS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/inc CACHE PATH "Path to OpenCL Headers")
+ 
+-add_library (OpenCL ${OPENCL_ICD_LOADER_SOURCES})
+-set_target_properties (OpenCL PROPERTIES VERSION "1.2" SOVERSION "1")
++add_library (OpenCL-ROCm ${OPENCL_ICD_LOADER_SOURCES})
++set_target_properties (OpenCL-ROCm PROPERTIES VERSION "1.2" SOVERSION "1")
+ 
+ if (WIN32)
+-    target_link_libraries (OpenCL cfgmgr32.lib)
++    target_link_libraries (OpenCL-ROCm cfgmgr32.lib)
+ 
+     option (OPENCL_ICD_LOADER_REQUIRE_WDK "Build with D3DKMT support, which requires the Windows WDK." ON)
+     if (OPENCL_ICD_LOADER_REQUIRE_WDK)
+@@ -92,10 +92,10 @@
+             get_filename_component(WDK_DIRECTORY ${LATEST_D3DKMT_HEADER} DIRECTORY)
+             get_filename_component(WDK_DIRECTORY ${WDK_DIRECTORY} DIRECTORY)
+             message(STATUS "Found the Windows WDK in: ${WDK_DIRECTORY}")
+-            target_compile_definitions(OpenCL PRIVATE OPENCL_ICD_LOADER_REQUIRE_WDK)
+-            target_include_directories(OpenCL PRIVATE ${WDK_DIRECTORY}/um)
+-            target_include_directories(OpenCL PRIVATE ${WDK_DIRECTORY}/km)
+-            target_include_directories(OpenCL PRIVATE ${WDK_DIRECTORY}/shared)
++	    target_compile_definitions(OpenCL-ROCm PRIVATE OPENCL_ICD_LOADER_REQUIRE_WDK)
++	    target_include_directories(OpenCL-ROCm PRIVATE ${WDK_DIRECTORY}/um)
++	    target_include_directories(OpenCL-ROCm PRIVATE ${WDK_DIRECTORY}/km)
++	    target_include_directories(OpenCL-ROCm PRIVATE ${WDK_DIRECTORY}/shared)
+         else()
+             message(FATAL_ERROR "The Windows WDK was not found. Consider disabling OPENCL_ICD_LOADER_REQUIRE_WDK. Aborting.")
+         endif()
+@@ -113,25 +113,25 @@
+     endif()
+ else()
+     if (APPLE)
+-        target_link_libraries (OpenCL ${CMAKE_THREAD_LIBS_INIT})
++        target_link_libraries (OpenCL-ROCm ${CMAKE_THREAD_LIBS_INIT})
+     else ()
+-        set_target_properties (OpenCL PROPERTIES LINK_FLAGS "-Wl,--version-script -Wl,${CMAKE_CURRENT_SOURCE_DIR}/loader/linux/icd_exports.map")
+-        target_link_libraries (OpenCL ${CMAKE_THREAD_LIBS_INIT})
++        set_target_properties (OpenCL-ROCm PROPERTIES LINK_FLAGS "-Wl,--version-script -Wl,${CMAKE_CURRENT_SOURCE_DIR}/loader/linux/icd_exports.map")
++	target_link_libraries (OpenCL-ROCm ${CMAKE_THREAD_LIBS_INIT})
+     endif ()
+ endif ()
+ 
+ include_directories (${OPENCL_ICD_LOADER_HEADERS_DIR})
+ add_definitions (-DCL_TARGET_OPENCL_VERSION=220)
+ 
+-target_include_directories (OpenCL PRIVATE ${CMAKE_CURRENT_BINARY_DIR} loader)
+-target_link_libraries (OpenCL ${CMAKE_DL_LIBS})
++target_include_directories (OpenCL-ROCm PRIVATE ${CMAKE_CURRENT_BINARY_DIR} loader)
++target_link_libraries (OpenCL-ROCm ${CMAKE_DL_LIBS})
+ 
+ include (CTest)
+ if (BUILD_TESTING)
+     add_subdirectory (test)
+ endif()
+ 
+-install (TARGETS OpenCL
++install (TARGETS OpenCL-ROCm
+     RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+     ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
+     LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
+--- OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/test/loader_test/CMakeLists.txt	2019-09-10 11:53:28.000000000 -0400
++++ OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/test/loader_test/CMakeLists.txt	2020-04-16 20:16:56.647026589 -0400
+@@ -12,4 +12,4 @@
+     test_clgl.c
+     test_image_objects.c )
+ 
+-target_link_libraries (icd_loader_test OpenCL IcdLog)
++target_link_libraries (icd_loader_test OpenCL-ROCm IcdLog)
+--- ROCm-OpenCL-Runtime-roc-3.3.0/CMakeLists.txt	2020-04-28 07:29:51.864446603 -0400
++++ ROCm-OpenCL-Runtime-roc-3.3.0/CMakeLists.txt	2020-04-28 07:32:45.245793180 -0400
+@@ -101,30 +101,30 @@
+ rocm_setup_version( VERSION "2.0.0" )
+ 
+ # MAIN package
+-install(PROGRAMS $<TARGET_FILE:clinfo>
+-        DESTINATION bin/x86_64
++install(PROGRAMS $<TARGET_FILE:rocm-clinfo>
++        DESTINATION bin
+         COMPONENT MAIN)
+ install(PROGRAMS $<TARGET_FILE:amdocl64>
+-        DESTINATION lib/x86_64
++        DESTINATION lib
+         COMPONENT MAIN)
+-install(PROGRAMS $<TARGET_FILE:OpenCL>
+-        DESTINATION lib/x86_64
++install(PROGRAMS $<TARGET_FILE:OpenCL-ROCm>
++        DESTINATION lib
+         COMPONENT MAIN)
+-install(PROGRAMS $<TARGET_SONAME_FILE:OpenCL>
+-        DESTINATION lib/x86_64
++install(PROGRAMS $<TARGET_SONAME_FILE:OpenCL-ROCm>
++        DESTINATION lib
+         COMPONENT MAIN)
+ 
+ # DEV package
+ install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/api/opencl/khronos/headers/opencl2.2/CL"
+-        DESTINATION include
++	DESTINATION include/rocm
+         COMPONENT DEV
+         USE_SOURCE_PERMISSIONS
+         PATTERN cl_d3d10.h EXCLUDE
+         PATTERN cl_d3d11.h EXCLUDE
+         PATTERN cl_dx9_media_sharing.h EXCLUDE
+         PATTERN cl_egl.h EXCLUDE)
+-install(PROGRAMS $<TARGET_LINKER_FILE:OpenCL>
+-        DESTINATION lib/x86_64
++install(PROGRAMS $<TARGET_LINKER_FILE:OpenCL-ROCm>
++        DESTINATION lib
+         COMPONENT DEV)
+ 
+ # Generic CPACK variables
+--- ROCm-OpenCL-Runtime-roc-3.3.0/tools/clinfo/CMakeLists.txt	2020-04-28 07:29:51.882446535 -0400
++++ ROCm-OpenCL-Runtime-roc-3.3.0/tools/clinfo/CMakeLists.txt	2020-04-28 07:30:05.627394732 -0400
+@@ -6,6 +6,6 @@
+ 
+ add_definitions(-DHAVE_CL2_HPP)
+ 
+-add_executable(clinfo clinfo.cpp)
++add_executable(rocm-clinfo clinfo.cpp)
+ 
+-target_link_libraries(clinfo OpenCL)
++target_link_libraries(rocm-clinfo OpenCL-ROCm)
diff --git a/srcpkgs/ROCm-OpenCL-Runtime/template b/srcpkgs/ROCm-OpenCL-Runtime/template
new file mode 100644
index 00000000000..f6699a1d4c0
--- /dev/null
+++ b/srcpkgs/ROCm-OpenCL-Runtime/template
@@ -0,0 +1,84 @@
+# Template file for 'ROCm-OpenCL-Runtime'
+pkgname=ROCm-OpenCL-Runtime
+version=3.3.0
+revision=1
+_ocl_icd_name="OpenCL-ICD-Loader"
+_ocl_icd_ver="6c03f8b58fafd9dd693eaac826749a5cfad515f8"
+archs="x86_64*"
+create_wrksrc=yes
+build_wrksrc="${pkgname}-roc-${version}"
+build_style=cmake
+configure_args="-DUSE_COMGR_LIBRARY=yes"
+hostmakedepends="cmake pkg-config"
+makedepends="libglvnd-devel ROCm-CompilerSupport-devel
+	ROCT-Thunk-Interface-devel ROCR-Runtime-devel"
+depends="ROCm-CompilerSupport"
+short_desc="Radeon Open Compute OpenCL runtime"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="MIT"
+homepage="https://github.com/RadeonOpenCompute/ROCm-OpenCL-Runtime"
+_rocroot="https://github.com/RadeonOpenCompute"
+distfiles="${_rocroot}/ROCm-OpenCL-Runtime/archive/roc-${version}.tar.gz
+	${_rocroot}/rocm-cmake/archive/rocm-${version}.tar.gz
+	https://github.com/KhronosGroup/${_ocl_icd_name}/archive/${_ocl_icd_ver}.tar.gz"
+checksum="ac6999f1a491ab066286c2bd6adf50f08f831286f56e267879f9f7eced22f98e
+	76ed3ee8e56cf3246011cf7723c2abda539e1136e7e7f6909bfa45d268b8644f
+	c94d5bb6dc980c4d41d73e2b81663a19aabe494e923e2d0eec72a4c95b318438"
+nocross=yes
+
+if [ "$XBPS_LIBC" = "musl" ]; then
+	makedepends+=" musl-legacy-compat"
+fi
+
+post_patch() {
+	if [ "$XBPS_LIBC" = "musl" ]; then
+		# Remove dependence on glibc
+		patch -Np0 < ${FILESDIR}/libelf-musl.patch
+		patch -Np0 < ${FILESDIR}/runtime-musl.patch
+		vsed -e '/glibc_functions.cpp/d' -i api/opencl/amdocl/CMakeLists.txt
+	fi
+}
+
+pre_configure() {
+	# ROCm requires a very specific Khronos ICD loader version in the tree
+	# Keep the ICD loader config in /etc/OpenCL/rocm-vendors to avoid conflicts
+	_ocl_icd_dir="${_ocl_icd_name}-${_ocl_icd_ver}"
+	ln -sf "${wrksrc}/${_ocl_icd_dir}" api/opencl/khronos/icd
+	vsed -i "${wrksrc}/${_ocl_icd_dir}/loader/icd_platform.h" \
+		-e 's@/etc/OpenCL/vendors/@/etc/OpenCL/rocm-vendors/@g'
+
+	# CMake modules probably not useful anywhere but for this build
+	ln -sf "${wrksrc}/rocm-cmake-rocm-${version}/share/rocm/cmake"/*.cmake cmake
+
+	# Fix the dlopen macro to point to versioned libamd_comgr shared object
+	vsed -i 'runtime/device/comgrctx.cpp' \
+		-e 's/\blibamd_comgr\(32\)\?.so\b/&.1/g'
+}
+
+post_install() {
+	vlicense License
+
+	# Create descriptor to allow the ICD loader to find the driver
+	vmkdir etc/OpenCL/rocm-vendors
+	echo "libamdocl64.so" > "${DESTDIR}/etc/OpenCL/rocm-vendors/amdocl64.icd"
+	vmkdir etc/OpenCL/vendors
+	ln -s ../../OpenCL/rocm-vendors/amdocl64.icd \
+		${DESTDIR}/etc/OpenCL/vendors/rocm-amdocl64.icd
+}
+
+ROCm-OpenCL-Runtime-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/lib/libOpenCL-ROCm.so
+		vmove usr/include
+	}
+}
+
+ROCm-OpenCL-Runtime-clinfo_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - clinfo"
+	pkg_install() {
+		vmove usr/bin/rocm-clinfo
+	}
+}
diff --git a/srcpkgs/ROCm-OpenCL-Runtime/update b/srcpkgs/ROCm-OpenCL-Runtime/update
new file mode 100644
index 00000000000..8385f4d1215
--- /dev/null
+++ b/srcpkgs/ROCm-OpenCL-Runtime/update
@@ -0,0 +1 @@
+pattern='roc-\K[\d.]+'

From e7e9396f27d38f7069a7dec63c18ebf4c7263db9 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Thu, 30 Apr 2020 13:11:12 -0400
Subject: [PATCH 09/10] New package: ROCR-Runtime-hsa-ext-3.3.0

---
 common/shlibs                         |  2 ++
 srcpkgs/ROCR-Runtime-hsa-ext-devel    |  1 +
 srcpkgs/ROCR-Runtime-hsa-ext/template | 43 +++++++++++++++++++++++++++
 srcpkgs/ROCR-Runtime-hsa-ext/update   |  2 ++
 4 files changed, 48 insertions(+)
 create mode 120000 srcpkgs/ROCR-Runtime-hsa-ext-devel
 create mode 100644 srcpkgs/ROCR-Runtime-hsa-ext/template
 create mode 100644 srcpkgs/ROCR-Runtime-hsa-ext/update

diff --git a/common/shlibs b/common/shlibs
index 99326e93f0f..10854dc8b19 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3881,3 +3881,5 @@ libhsa-runtime64.so.1 ROCR-Runtime-3.3.0_1
 libamd_comgr.so.1 ROCm-CompilerSupport-3.3.0_1
 libOpenCL-ROCm.so.1 ROCm-OpenCL-Runtime-3.3.0_1
 libamdocl64.so ROCm-OpenCL-Runtime-3.3.0_1
+libhsa-ext-image64.so.1 ROCR-Runtime-hsa-ext-3.3.0_1
+libhsa-runtime-tools64.so.1 ROCR-Runtime-hsa-ext-3.3.0_1
diff --git a/srcpkgs/ROCR-Runtime-hsa-ext-devel b/srcpkgs/ROCR-Runtime-hsa-ext-devel
new file mode 120000
index 00000000000..6ee1b14911b
--- /dev/null
+++ b/srcpkgs/ROCR-Runtime-hsa-ext-devel
@@ -0,0 +1 @@
+ROCR-Runtime-hsa-ext
\ No newline at end of file
diff --git a/srcpkgs/ROCR-Runtime-hsa-ext/template b/srcpkgs/ROCR-Runtime-hsa-ext/template
new file mode 100644
index 00000000000..235ae92146b
--- /dev/null
+++ b/srcpkgs/ROCR-Runtime-hsa-ext/template
@@ -0,0 +1,43 @@
+# Template file for 'ROCR-Runtime-hsa-ext'
+pkgname=ROCR-Runtime-hsa-ext
+version=3.3.0
+revision=1
+archs="x86_64"
+hostmakedepends="tar"
+short_desc="Radeon Open Compute HSA runtime extensions"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute"
+_hsa_deb="hsa-ext-rocr-dev_1.1.30300.0-rocm-rel-3.3-19-23fc088b_amd64.deb"
+distfiles="https://repo.radeon.com/rocm/apt/debian/pool/main/h/hsa-ext-rocr-dev/$_hsa_deb"
+checksum=6b44e286b395d946b865ec1f3cc546356396785ac1fde591d07af02d0aa7c25d
+repository=nonfree
+restricted=yes
+
+do_extract() {
+	ar x "${XBPS_SRCDISTDIR}/${pkgname}-${version}/${_hsa_deb}"
+	tar xvf data.tar.gz
+}
+
+do_install() {
+	_rocm_includes="opt/rocm-${version}/hsa/include"
+
+	vmkdir usr
+	vcopy opt/rocm-${version}/hsa/lib usr
+	vcopy "$_rocm_includes" usr
+
+	# Extract license from one of the header files
+	awk 'BEGIN{HEADER=0} /\/\//{HEADER=1; print $0;} /^[^/]/{if(HEADER==1) exit;}' \
+		< "${_rocm_includes}/hsa/amd_hsa_tools_interfaces.h" \
+		| sed 's@^///*\( \|$\)@@' > LICENSE
+	vlicense LICENSE
+}
+
+ROCR-Runtime-hsa-ext-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove "usr/lib/*.so"
+	}
+}
diff --git a/srcpkgs/ROCR-Runtime-hsa-ext/update b/srcpkgs/ROCR-Runtime-hsa-ext/update
new file mode 100644
index 00000000000..84252d2e3b8
--- /dev/null
+++ b/srcpkgs/ROCR-Runtime-hsa-ext/update
@@ -0,0 +1,2 @@
+site='https://repo.radeon.com/rocm/apt/debian/pool/main/h/'
+pattern='hsa-ext-rocr-dev\K[\d.]+'

From 8406ca056b301618419723e40d687d4018ad40b7 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Tue, 28 Apr 2020 13:33:46 -0400
Subject: [PATCH 10/10] hashcat: add build option to link against ROCm [ci
 skip]

---
 srcpkgs/hashcat/files/rocm.patch     | 15 +++++++++++++++
 srcpkgs/hashcat/patches/tmpdir.patch | 21 +++++++++++++++++++++
 srcpkgs/hashcat/template             | 17 ++++++++++++++---
 3 files changed, 50 insertions(+), 3 deletions(-)
 create mode 100644 srcpkgs/hashcat/files/rocm.patch
 create mode 100644 srcpkgs/hashcat/patches/tmpdir.patch

diff --git a/srcpkgs/hashcat/files/rocm.patch b/srcpkgs/hashcat/files/rocm.patch
new file mode 100644
index 00000000000..f1e899d30ee
--- /dev/null
+++ b/srcpkgs/hashcat/files/rocm.patch
@@ -0,0 +1,15 @@
+diff -ur a/src/opencl.c b/src/opencl.c
+--- a/src/opencl.c	2018-12-02 05:58:48.000000000 -0500
++++ b/src/opencl.c	2020-04-28 13:24:12.602415333 -0400
+@@ -492,9 +492,9 @@
+ 
+   if (ocl->lib == NULL) ocl->lib = hc_dlopen ("cygOpenCL-1.dll", RTLD_NOW);
+   #else
+-  ocl->lib = hc_dlopen ("libOpenCL.so", RTLD_NOW);
++  ocl->lib = hc_dlopen ("libOpenCL-ROCm.so.1", RTLD_NOW);
+ 
+-  if (ocl->lib == NULL) ocl->lib = hc_dlopen ("libOpenCL.so.1", RTLD_NOW);
++  if (ocl->lib == NULL) ocl->lib = hc_dlopen ("libOpenCL-ROCm.so", RTLD_NOW);
+   #endif
+ 
+   if (ocl->lib == NULL)
diff --git a/srcpkgs/hashcat/patches/tmpdir.patch b/srcpkgs/hashcat/patches/tmpdir.patch
new file mode 100644
index 00000000000..0558a001c9c
--- /dev/null
+++ b/srcpkgs/hashcat/patches/tmpdir.patch
@@ -0,0 +1,21 @@
+Addresses https://github.com/hashcat/hashcat/issues/2379
+diff -ur a/src/folder.c b/src/folder.c
+--- src/folder.c	2018-12-02 05:58:48.000000000 -0500
++++ src/folder.c	2020-04-28 13:22:27.340522751 -0400
+@@ -457,16 +457,6 @@
+ 
+   hcfree (cpath);
+ 
+-  //if (getenv ("TMP") == NULL)
+-  if (1)
+-  {
+-    char *tmp;
+-
+-    hc_asprintf (&tmp, "TMP=%s", cpath_real);
+-
+-    putenv (tmp);
+-  }
+-
+   #if defined (_WIN)
+ 
+   naive_replace (cpath_real, '\\', '/');
diff --git a/srcpkgs/hashcat/template b/srcpkgs/hashcat/template
index e982f99cebf..3f19be5e41d 100644
--- a/srcpkgs/hashcat/template
+++ b/srcpkgs/hashcat/template
@@ -1,15 +1,16 @@
 # Template file for 'hashcat'
 pkgname=hashcat
 version=5.1.0
-revision=2
+revision=3
 build_style=gnu-makefile
 make_build_args="PREFIX=/usr
  USE_SYSTEM_OPENCL=1 USE_SYSTEM_XXHASH=1
- DEPS_OPENCL_PATH=${XBPS_CROSS_BASE}/usr/include
+ DEPS_OPENCL_PATH=${XBPS_CROSS_BASE}/usr/include$(vopt_if rocm /rocm)
  DEPS_XXHASH_PATH=${XBPS_CROSS_BASE}/usr/include"
 make_use_env=yes
 make_install_args="$make_build_args"
-makedepends="gmp-devel opencl2-headers xxHash-devel"
+makedepends="gmp-devel xxHash-devel
+ $(vopt_if rocm ROCm-OpenCL-Runtime-devel opencl2-headers)"
 checkdepends="perl"
 short_desc="Advanced CPU-based password recovery utility"
 maintainer="Duncaen <duncaen@voidlinux.org>"
@@ -19,6 +20,9 @@ changelog="https://raw.githubusercontent.com/hashcat/hashcat/master/docs/changes
 distfiles="https://hashcat.net/files/hashcat-${version}.tar.gz"
 checksum=283beaa68e1eab41de080a58bb92349c8e47a2bb1b93d10f36ea30f418f1e338
 
+build_options="rocm"
+desc_option_rocm="Use ROCm OpenCL runtime"
+
 if [ "$XBPS_TARGET_ENDIAN" = "be" ]; then
 	broken="Not supported on big endian"
 fi
@@ -26,6 +30,13 @@ fi
 post_extract() {
 	sed '/^CC/d' -i src/Makefile
 }
+
+post_patch() {
+	if [ "$build_option_rocm" ]; then
+		patch -Np1 < ${FILESDIR}/rocm.patch
+	fi
+}
+
 post_install() {
 	rm -f ${DESTDIR}/usr/share/docs/hashcat/license.txt
 	vlicense docs/license.txt

^ permalink raw reply	[flat|nested] 61+ messages in thread

* Re: [PR PATCH] [Updated] New packages: ROCm core and OpenCL
  2020-04-19 13:34 [PR PATCH] New packages: ROCm core and OpenCL ahesford
                   ` (27 preceding siblings ...)
  2020-05-07 14:18 ` ahesford
@ 2020-05-07 16:01 ` ahesford
  2020-05-08 14:40 ` ahesford
                   ` (30 subsequent siblings)
  59 siblings, 0 replies; 61+ messages in thread
From: ahesford @ 2020-05-07 16:01 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 3893 bytes --]

There is an updated pull request by ahesford against master on the void-packages repository

https://github.com/ahesford/void-packages rocm
https://github.com/void-linux/void-packages/pull/21153

New packages: ROCm core and OpenCL
This PR includes several packages designed to bring the OpenCL portion of the AMD ROCm ecosystem to Void. It addresses Issue #19507. There are many other packages that AMD provides for GPGPU computing, but these can be added piecemeal as users demand.

The packages are currently only for `x86_64*`. While at least some of the packages will compile on other 64-bit architectures, I have no hardware to test. They are certainly not suitable for 32-bit architectures; some internal data structures rely on `uint64_t` values that are cast to pointers. At a
minimum, a thorough audit would be necessary to ensure that these casts are safe (e.g., that the values stored were only ever upcast from 32-bit pointers). More extensive work may be necessary to support 32-bit architectures, probably without significant benefit.

The packages successfully identify a Radeon RX 580 on an `x86_64` installation using both `clinfo` and `rocminfo` as provided. Furthermore, a version of `pyopencl` linked against these ROCm packages successfully runs a simple program that validates arithmetic on GPU-bound arrays.

There are caveats with this set of packages, almost all of which revolve around the incompatibilities between the Void-provided `ocl-icd` and the [Khronos OpenCL ICD loader](https://github.com/KhronosGroup/OpenCL-ID-Loader) required by (and built into) `rocm-opencl-runtime`.
1. All packages install into `/opt/rocm`. This keeps the environment closer to that officially sanctioned by AMD and helps avoid conflicts between other packages and those provided here. (For example, `clinfo` and the ICD loader itself.) Eventually, we may be able to move the files into `/usr`.
2. The Khronos OpenCL ICD loader built into `rocm-opencl-runtime` is an outdated, pre-release commit. If AMD can update its sources to use the release version of that loader (which has a backward-incompatible API change), we may be able to make ROCm compatible with `ocl-icd` or replace `ocl-icd` with the official Khronos loader.
3. In the meantime, to avoid `shlibs` conflicts, the OpenCL ICD loader is installed as `/opt/rocm/lib/libOpenCL-ROCm.so` (and an appropriately versioned shared library), which means that programs wishing to use the ROCm OpenCL must explicitly link against this library instead of the generic `libOpenCL.so`.
4. I do **not** recommend making any Void packages link against this specific library, because it will make those packages ROCm-only. For the time being, ROCm is intended for end-users to specifically link against. Linking Void packages against ROCm would requires the ICD loader used by ROCm be compatible with `ocl-icd`, or `ocl-icd` be replaced by the Khronos loader. However, because the Khronos loader changed its API for the release version, such a change is not yet appropriate.

Hopefully, if AMD updates its dependence on the Khronos ICD loader, we can resolve some of these caveats in the future and make ROCm a more natural Void component. For now, these packages are useful for those who need an AMD OpenCL solution and would rather custom-link software against the AMD ICD loader than hack the `amdgpu-pro` driver into an ICD compatible with `ocl-icd`.

Some patches were made to relocate some files in `/opt/rocm` and make everyting build on x86_64-musl`. Where appropriate, these patches will be pushed upstream to clean up the distribution and packaging.

Update: I pushed some new commits to update license information that triggerd an `xlint` failure. I've also disabled CI builds because they will time out on `rocm-llvm`.

A patch file from https://github.com/void-linux/void-packages/pull/21153.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-rocm-21153.patch --]
[-- Type: text/x-diff, Size: 39470 bytes --]

From bbc0c840a7208d34e66cc2b875cb72ec1b09a694 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Mon, 13 Apr 2020 13:08:09 -0400
Subject: [PATCH 01/10] New package: ROCT-Thunk-Interface-3.3.0

---
 common/shlibs                                 |  2 ++
 srcpkgs/ROCT-Thunk-Interface-devel            |  1 +
 .../patches/cmake-dev-libdir.patch            | 10 ++++++
 .../ROCT-Thunk-Interface/patches/musl.patch   | 29 ++++++++++++++++
 srcpkgs/ROCT-Thunk-Interface/template         | 33 +++++++++++++++++++
 srcpkgs/ROCT-Thunk-Interface/update           |  1 +
 6 files changed, 76 insertions(+)
 create mode 120000 srcpkgs/ROCT-Thunk-Interface-devel
 create mode 100644 srcpkgs/ROCT-Thunk-Interface/patches/cmake-dev-libdir.patch
 create mode 100644 srcpkgs/ROCT-Thunk-Interface/patches/musl.patch
 create mode 100644 srcpkgs/ROCT-Thunk-Interface/template
 create mode 100644 srcpkgs/ROCT-Thunk-Interface/update

diff --git a/common/shlibs b/common/shlibs
index 4bdc03e8b23..34aa1dc0993 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3875,3 +3875,5 @@ libhidrd_opt.so.0 hidrd-0.2.0_1
 libhidrd_strm.so.0 hidrd-0.2.0_1
 libhidrd_fmt.so.0 hidrd-0.2.0_1
 libjcat.so.1 libjcat-0.1.2_1
+
+libhsakmt.so.1 ROCT-Thunk-Interface-3.3.0_1
diff --git a/srcpkgs/ROCT-Thunk-Interface-devel b/srcpkgs/ROCT-Thunk-Interface-devel
new file mode 120000
index 00000000000..7e43c209e3d
--- /dev/null
+++ b/srcpkgs/ROCT-Thunk-Interface-devel
@@ -0,0 +1 @@
+ROCT-Thunk-Interface
\ No newline at end of file
diff --git a/srcpkgs/ROCT-Thunk-Interface/patches/cmake-dev-libdir.patch b/srcpkgs/ROCT-Thunk-Interface/patches/cmake-dev-libdir.patch
new file mode 100644
index 00000000000..98c7f1e459c
--- /dev/null
+++ b/srcpkgs/ROCT-Thunk-Interface/patches/cmake-dev-libdir.patch
@@ -0,0 +1,10 @@
+--- CMakeLists.txt.old	2020-04-18 19:45:17.306081135 -0400
++++ CMakeLists.txt	2020-04-18 19:46:51.300753636 -0400
+@@ -146,6 +146,7 @@
+     COMMAND ${CMAKE_COMMAND}
+         -DSOURCE_DIR="${SOURCE_DIR}"
+         -DCMAKE_INSTALL_PREFIX="${CMAKE_INSTALL_PREFIX}"
++        -DCMAKE_INSTALL_LIBDIR="${CMAKE_INSTALL_LIBDIR}"
+         -DCPACK_RPM_PACKAGE_REQUIRES="hsakmt-roct"
+         -DCPACK_PACKAGING_INSTALL_PREFIX="${CPACK_PACKAGING_INSTALL_PREFIX}"
+         -DVERSION="${BUILD_VERSION_STRING}"
diff --git a/srcpkgs/ROCT-Thunk-Interface/patches/musl.patch b/srcpkgs/ROCT-Thunk-Interface/patches/musl.patch
new file mode 100644
index 00000000000..aeea9832411
--- /dev/null
+++ b/srcpkgs/ROCT-Thunk-Interface/patches/musl.patch
@@ -0,0 +1,29 @@
+diff -r -u old/src/libhsakmt.h new/src/libhsakmt.h
+--- src/libhsakmt.h	2020-03-04 15:00:47.000000000 -0500
++++ src/libhsakmt.h	2020-04-13 12:58:30.444865992 -0400
+@@ -54,6 +54,10 @@
+ #define CHECK_KFD_OPEN() \
+ 	do { if (kfd_open_count == 0 || hsakmt_forked) return HSAKMT_STATUS_KERNEL_IO_CHANNEL_NOT_OPENED; } while (0)
+ 
++/*On some platforms, a PAGE_SIZE macro eclipses the extern variable*/
++#ifdef PAGE_SIZE
++#undef PAGE_SIZE
++#endif
+ extern int PAGE_SIZE;
+ extern int PAGE_SHIFT;
+ 
+diff -r -u old/src/topology.c new/src/topology.c
+--- src/topology.c	2020-03-04 15:00:47.000000000 -0500
++++ src/topology.c	2020-04-13 13:01:31.209870701 -0400
+@@ -38,6 +38,11 @@
+ #include "libhsakmt.h"
+ #include "fmm.h"
+ 
++/*Needed on MUSL*/
++#ifndef MAXNAMLEN
++#define MAXNAMLEN PATH_MAX
++#endif
++
+ /* Number of memory banks added by thunk on top of topology
+  * This only includes static heaps like LDS, scratch and SVM,
+  * not for MMIO_REMAP heap. MMIO_REMAP memory bank is reported
diff --git a/srcpkgs/ROCT-Thunk-Interface/template b/srcpkgs/ROCT-Thunk-Interface/template
new file mode 100644
index 00000000000..8c680b2af29
--- /dev/null
+++ b/srcpkgs/ROCT-Thunk-Interface/template
@@ -0,0 +1,33 @@
+# Template file for 'ROCT-Thunk-Interface'
+pkgname=ROCT-Thunk-Interface
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="${pkgname}-roc-${version}"
+build_style=cmake
+make_build_target="all build-dev"
+make_install_target="install install-dev"
+hostmakedepends="cmake pkg-config"
+makedepends="pciutils-devel libnuma-devel"
+short_desc="Radeon Open Compute thunk interface"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="MIT"
+homepage="https://github.com/RadeonOpenCompute/ROCT-Thunk-Interface"
+distfiles="${homepage}/archive/roc-${version}.tar.gz"
+checksum=2cabe9d2cfa72031c05d11290837c476182e72d8dec2049298f691143fdd212b
+nocross=yes
+
+post_install() {
+	vlicense LICENSE.md
+}
+
+ROCT-Thunk-Interface-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove "usr/lib/*.so"
+		vmove usr/share/pkgconfig
+		vmove usr/lib/cmake
+	}
+}
diff --git a/srcpkgs/ROCT-Thunk-Interface/update b/srcpkgs/ROCT-Thunk-Interface/update
new file mode 100644
index 00000000000..8385f4d1215
--- /dev/null
+++ b/srcpkgs/ROCT-Thunk-Interface/update
@@ -0,0 +1 @@
+pattern='roc-\K[\d.]+'

From 10f5b13fb0fca23ffc3c51eab5f60981740c0337 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Mon, 13 Apr 2020 15:27:27 -0400
Subject: [PATCH 02/10] New package: ROCR-Runtime-3.3.0

---
 common/shlibs                            |  1 +
 srcpkgs/ROCR-Runtime-devel               |  1 +
 srcpkgs/ROCR-Runtime/patches/cmake.patch | 27 +++++++++++++++++++++
 srcpkgs/ROCR-Runtime/template            | 30 ++++++++++++++++++++++++
 srcpkgs/ROCR-Runtime/update              |  1 +
 5 files changed, 60 insertions(+)
 create mode 120000 srcpkgs/ROCR-Runtime-devel
 create mode 100644 srcpkgs/ROCR-Runtime/patches/cmake.patch
 create mode 100644 srcpkgs/ROCR-Runtime/template
 create mode 100644 srcpkgs/ROCR-Runtime/update

diff --git a/common/shlibs b/common/shlibs
index 34aa1dc0993..447a5e23a43 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3877,3 +3877,4 @@ libhidrd_fmt.so.0 hidrd-0.2.0_1
 libjcat.so.1 libjcat-0.1.2_1
 
 libhsakmt.so.1 ROCT-Thunk-Interface-3.3.0_1
+libhsa-runtime64.so.1 ROCR-Runtime-3.3.0_1
diff --git a/srcpkgs/ROCR-Runtime-devel b/srcpkgs/ROCR-Runtime-devel
new file mode 120000
index 00000000000..a733fb9fbab
--- /dev/null
+++ b/srcpkgs/ROCR-Runtime-devel
@@ -0,0 +1 @@
+ROCR-Runtime
\ No newline at end of file
diff --git a/srcpkgs/ROCR-Runtime/patches/cmake.patch b/srcpkgs/ROCR-Runtime/patches/cmake.patch
new file mode 100644
index 00000000000..93b74cd2297
--- /dev/null
+++ b/srcpkgs/ROCR-Runtime/patches/cmake.patch
@@ -0,0 +1,27 @@
+--- src/CMakeLists.txt.old	2020-04-18 20:01:48.549636995 -0400
++++ src/CMakeLists.txt	2020-04-18 20:04:00.177179781 -0400
+@@ -108,8 +108,8 @@
+ ## ROCr build internal versioning
+ add_definitions ( -DROCR_BUILD_ID=${PACKAGE_VERSION_STRING} )
+ 
+-## Set RUNPATH - ../../lib covers use of the legacy symlink in /hsa/lib/
+-set(CMAKE_INSTALL_RPATH "$ORIGIN;$ORIGIN/../../lib;$ORIGIN/../../lib64;$ORIGIN/../lib64")
++## Set RUNPATH
++set(CMAKE_INSTALL_RPATH "$ORIGIN;$ORIGIN/../lib")
+ 
+ ## ------------------------- Linux Compiler and Linker options -------------------------
+ set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -fexceptions -fno-rtti -fvisibility=hidden -Wno-error=sign-compare -Wno-sign-compare -Wno-write-strings -Wno-conversion-null -fno-math-errno -fno-threadsafe-statics -fmerge-all-constants -fms-extensions -Wno-error=comment -Wno-comment -Wno-error=pointer-arith -Wno-pointer-arith -Wno-error=unused-variable -Wno-error=unused-function" )
+@@ -185,11 +185,8 @@
+ add_custom_target ( hsa_lib_link2 ALL WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMAND ${CMAKE_COMMAND} -E create_symlink ../hsa/lib/${CORE_RUNTIME_LIBRARY}.so.${SO_MAJOR} ${CORE_RUNTIME_LIBRARY}-link.so.${SO_MAJOR} )
+ 
+ ## Set install information
+-install ( TARGETS ${CORE_RUNTIME_TARGET} LIBRARY DESTINATION hsa/lib )
+-install ( DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/inc/ DESTINATION hsa/include/hsa )
+-install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/hsa_include_link DESTINATION include PERMISSIONS OWNER_WRITE OWNER_READ RENAME hsa )
+-install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/${CORE_RUNTIME_LIBRARY}-link.so DESTINATION lib PERMISSIONS OWNER_WRITE OWNER_READ RENAME ${CORE_RUNTIME_LIBRARY}.so )
+-install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/${CORE_RUNTIME_LIBRARY}-link.so.${SO_MAJOR} DESTINATION lib PERMISSIONS OWNER_WRITE OWNER_READ RENAME ${CORE_RUNTIME_LIBRARY}.so.${SO_MAJOR} )
++install ( TARGETS ${CORE_RUNTIME_TARGET} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} )
++install ( DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/inc/ DESTINATION include/hsa )
+ 
+ ## Packaging directives
+ set ( CPACK_GENERATOR "DEB;RPM" CACHE STRING "Package types to build")
diff --git a/srcpkgs/ROCR-Runtime/template b/srcpkgs/ROCR-Runtime/template
new file mode 100644
index 00000000000..95b7e701afb
--- /dev/null
+++ b/srcpkgs/ROCR-Runtime/template
@@ -0,0 +1,30 @@
+# Template file for 'ROCR-Runtime'
+pkgname=ROCR-Runtime
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="${pkgname}-rocm-${version}"
+build_wrksrc="src"
+build_style=cmake
+hostmakedepends="cmake pkg-config"
+makedepends="ROCT-Thunk-Interface-devel elfutils-devel"
+short_desc="Radeon Open Compute HSA runtime"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute/ROCR-Runtime"
+distfiles="${homepage}/archive/rocm-${version}.tar.gz"
+checksum=fa2d2d1f8a61d8a6952d377cf288d78c61776c3c2a666f163cafc3aa19ab0b61
+nocross=yes
+
+post_install() {
+	vlicense ../LICENSE.txt
+}
+
+ROCR-Runtime-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove "usr/lib/*.so"
+	}
+}
diff --git a/srcpkgs/ROCR-Runtime/update b/srcpkgs/ROCR-Runtime/update
new file mode 100644
index 00000000000..86197bc3eea
--- /dev/null
+++ b/srcpkgs/ROCR-Runtime/update
@@ -0,0 +1 @@
+pattern='rocm-\K[\d.]+'

From 10c4bf56844a682e5b4deea4e67eee2259e2f461 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Mon, 13 Apr 2020 18:07:34 -0400
Subject: [PATCH 03/10] New package: ROCm-llvm-3.3.0

---
 srcpkgs/ROCm-llvm/template | 26 ++++++++++++++++++++++++++
 srcpkgs/ROCm-llvm/update   |  1 +
 2 files changed, 27 insertions(+)
 create mode 100644 srcpkgs/ROCm-llvm/template
 create mode 100644 srcpkgs/ROCm-llvm/update

diff --git a/srcpkgs/ROCm-llvm/template b/srcpkgs/ROCm-llvm/template
new file mode 100644
index 00000000000..4c3095b21f4
--- /dev/null
+++ b/srcpkgs/ROCm-llvm/template
@@ -0,0 +1,26 @@
+# Template file for 'ROCm-llvm'
+pkgname=ROCm-llvm
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="llvm-project-rocm-ocl-${version}"
+build_wrksrc=llvm
+build_style=cmake
+configure_args="-DCMAKE_INSTALL_PREFIX:PATH=/usr/lib/rocm-llvm
+	-DLLVM_ENABLE_PROJECTS='llvm;clang;lld' -DLLVM_TARGETS_TO_BUILD='AMDGPU'
+	-DLLVM_BUILD_DOCS=NO -DLLVM_ENABLE_OCAMLDOC=OFF
+	-DLLVM_ENABLE_SPHINX=NO -DLLVM_ENABLE_DOXYGEN=OFF
+	-DLLVM_INSTALL_UTILS=ON -DLLVM_VERSION_SUFFIX=roc -DOCAMLFIND=NO"
+hostmakedepends="cmake pkg-config python3"
+short_desc="Radeon Open Compute LLVM toolchain"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="Apache-2.0, NCSA, custom:LLVM-Exceptions"
+homepage="https://github.com/RadeonOpenCompute/llvm-project"
+distfiles="${homepage}/archive/rocm-ocl-${version}.tar.gz"
+checksum=a2bef7042e8e2f2cd8548cb246b88322e1c77188839983dcac8312d56f544dc8
+python_version=3
+nocross=yes
+
+post_install() {
+	vlicense LICENSE.TXT
+}
diff --git a/srcpkgs/ROCm-llvm/update b/srcpkgs/ROCm-llvm/update
new file mode 100644
index 00000000000..6a73667d3c1
--- /dev/null
+++ b/srcpkgs/ROCm-llvm/update
@@ -0,0 +1 @@
+pattern='rocm-ocl-\K[\d.]+'

From 22e98db9716a80699f9ee0c660be4422dcb9941e Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Tue, 14 Apr 2020 10:25:31 -0400
Subject: [PATCH 04/10] New package: ROCm-Device-Libs-3.3.0

---
 srcpkgs/ROCm-Device-Libs/template | 37 +++++++++++++++++++++++++++++++
 srcpkgs/ROCm-Device-Libs/update   |  1 +
 2 files changed, 38 insertions(+)
 create mode 100644 srcpkgs/ROCm-Device-Libs/template
 create mode 100644 srcpkgs/ROCm-Device-Libs/update

diff --git a/srcpkgs/ROCm-Device-Libs/template b/srcpkgs/ROCm-Device-Libs/template
new file mode 100644
index 00000000000..8086cd86450
--- /dev/null
+++ b/srcpkgs/ROCm-Device-Libs/template
@@ -0,0 +1,37 @@
+# Template file for 'ROCm-Device-Libs'
+pkgname=ROCm-Device-Libs
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="${pkgname}-rocm-ocl-${version}"
+build_style=cmake
+configure_args="-DLLVM_DIR:PATH=/usr/lib/rocm-llvm
+	-DCMAKE_INSTALL_LIBDIR:PATH=lib/rocm-device-libs"
+hostmakedepends="cmake ROCm-llvm"
+short_desc="Radeon Open Compute device libraries"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute/ROCm-Device-Libs"
+distfiles="${homepage}/archive/rocm-ocl-${version}.tar.gz"
+checksum=706b08230790e08ca6a7a2fb7687d6131fd39a562148340e00fa37a6c06769c5
+nocross=yes
+
+pre_configure() {
+	# Put bytecodes in a lib/ subdirectory
+	vsed -i Packages.cmake -e 's@/lib/@/${CMAKE_INSTALL_LIBDIR}/@'
+	vsed -i OCL.cmake -e 's@DESTINATION lib$@DESTINATION ${CMAKE_INSTALL_LIBDIR}@'
+
+	# Build the prepare-builtins executable with native compiler
+	mkdir -p utils/build
+	cd utils/build
+	_prepare_builtins="$PWD/prepare-builtins/prepare-builtins"
+	cmake ${configure_args} ..
+	make ${makejobs}
+
+	# Add path to prepare-builtins for cmake
+	configure_args+=" -DPREPARE_BUILTINS='${_prepare_builtins}'"
+}
+
+post_install() {
+	vlicense LICENSE
+}
diff --git a/srcpkgs/ROCm-Device-Libs/update b/srcpkgs/ROCm-Device-Libs/update
new file mode 100644
index 00000000000..6a73667d3c1
--- /dev/null
+++ b/srcpkgs/ROCm-Device-Libs/update
@@ -0,0 +1 @@
+pattern='rocm-ocl-\K[\d.]+'

From b3a571c635026054c579a4826b2cda9df84f1490 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Mon, 13 Apr 2020 18:30:00 -0400
Subject: [PATCH 05/10] New package: ROCm-CompilerSupport-3.3.0

---
 common/shlibs                         |  1 +
 srcpkgs/ROCm-CompilerSupport-devel    |  1 +
 srcpkgs/ROCm-CompilerSupport/template | 32 +++++++++++++++++++++++++++
 srcpkgs/ROCm-CompilerSupport/update   |  1 +
 4 files changed, 35 insertions(+)
 create mode 120000 srcpkgs/ROCm-CompilerSupport-devel
 create mode 100644 srcpkgs/ROCm-CompilerSupport/template
 create mode 100644 srcpkgs/ROCm-CompilerSupport/update

diff --git a/common/shlibs b/common/shlibs
index 447a5e23a43..83cc61a42be 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3878,3 +3878,4 @@ libjcat.so.1 libjcat-0.1.2_1
 
 libhsakmt.so.1 ROCT-Thunk-Interface-3.3.0_1
 libhsa-runtime64.so.1 ROCR-Runtime-3.3.0_1
+libamd_comgr.so.1 ROCm-CompilerSupport-3.3.0_1
diff --git a/srcpkgs/ROCm-CompilerSupport-devel b/srcpkgs/ROCm-CompilerSupport-devel
new file mode 120000
index 00000000000..877aeafeeae
--- /dev/null
+++ b/srcpkgs/ROCm-CompilerSupport-devel
@@ -0,0 +1 @@
+ROCm-CompilerSupport
\ No newline at end of file
diff --git a/srcpkgs/ROCm-CompilerSupport/template b/srcpkgs/ROCm-CompilerSupport/template
new file mode 100644
index 00000000000..df56f7a3837
--- /dev/null
+++ b/srcpkgs/ROCm-CompilerSupport/template
@@ -0,0 +1,32 @@
+# Template file for 'ROCm-CompilerSupport'
+pkgname=ROCm-CompilerSupport
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="${pkgname}-rocm-${version}"
+build_wrksrc="lib/comgr"
+build_style=cmake
+configure_args="-DClang_DIR:PATH=/usr/lib/rocm-llvm/lib/cmake/clang"
+hostmakedepends="cmake pkg-config ROCm-llvm"
+makedepends="ROCm-Device-Libs"
+short_desc="Radeon Open Compute compiler support"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="BSD-3-Clause"
+homepage="https://github.com/RadeonOpenCompute/ROCm-CompilerSupport"
+distfiles="${homepage}/archive/rocm-${version}.tar.gz"
+checksum=01e2524e0f28ecd6f46c9720f279207de935d826b0172158792aa3ec86af9ca7
+nocross=yes
+
+post_install() {
+	vlicense LICENSE.txt
+}
+
+ROCm-CompilerSupport-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove "usr/lib/*.so"
+		vmove usr/lib/cmake
+	}
+}
diff --git a/srcpkgs/ROCm-CompilerSupport/update b/srcpkgs/ROCm-CompilerSupport/update
new file mode 100644
index 00000000000..86197bc3eea
--- /dev/null
+++ b/srcpkgs/ROCm-CompilerSupport/update
@@ -0,0 +1 @@
+pattern='rocm-\K[\d.]+'

From 85102ff0449de3a64be795d640b19b3b4b2f4dab Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Fri, 17 Apr 2020 12:11:25 -0400
Subject: [PATCH 06/10] New package: rocminfo-3.3.0

---
 srcpkgs/rocminfo/template | 22 ++++++++++++++++++++++
 srcpkgs/rocminfo/update   |  1 +
 2 files changed, 23 insertions(+)
 create mode 100644 srcpkgs/rocminfo/template
 create mode 100644 srcpkgs/rocminfo/update

diff --git a/srcpkgs/rocminfo/template b/srcpkgs/rocminfo/template
new file mode 100644
index 00000000000..7a075c7f7ac
--- /dev/null
+++ b/srcpkgs/rocminfo/template
@@ -0,0 +1,22 @@
+# Template file for 'rocminfo'
+pkgname=rocminfo
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="${pkgname}-rocm-${version}"
+build_style=cmake
+configure_args="-DROCM_DIR=/usr"
+hostmakedepends="cmake pkg-config"
+makedepends="ROCR-Runtime-devel"
+short_desc="Radeon Open Compute system information reporter"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute/rocminfo"
+distfiles="${homepage}/archive/rocm-${version}.tar.gz"
+checksum=e666f662c9e465aaabbbd0b109d87e017243cdf1a0898fabf5a90947bb3dbcd7
+nocross=yes
+python_version=3
+
+post_install() {
+	vlicense License.txt
+}
diff --git a/srcpkgs/rocminfo/update b/srcpkgs/rocminfo/update
new file mode 100644
index 00000000000..86197bc3eea
--- /dev/null
+++ b/srcpkgs/rocminfo/update
@@ -0,0 +1 @@
+pattern='rocm-\K[\d.]+'

From 40a616fc416c824da8a95d3daaa8c1235d6bdc40 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Sun, 19 Apr 2020 15:01:40 -0400
Subject: [PATCH 07/10] New package: rocm_bandwidth_test-3.3.0

---
 srcpkgs/rocm_bandwidth_test/template | 20 ++++++++++++++++++++
 srcpkgs/rocm_bandwidth_test/update   |  1 +
 2 files changed, 21 insertions(+)
 create mode 100644 srcpkgs/rocm_bandwidth_test/template
 create mode 100644 srcpkgs/rocm_bandwidth_test/update

diff --git a/srcpkgs/rocm_bandwidth_test/template b/srcpkgs/rocm_bandwidth_test/template
new file mode 100644
index 00000000000..6de7f2d6614
--- /dev/null
+++ b/srcpkgs/rocm_bandwidth_test/template
@@ -0,0 +1,20 @@
+# Template file for 'rocm_bandwidth_test'
+pkgname=rocm_bandwidth_test
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="${pkgname}-rocm-${version}"
+build_style=cmake
+hostmakedepends="cmake"
+makedepends="ROCR-Runtime-devel ROCT-Thunk-Interface-devel"
+short_desc="Radeon Open Compute bandwidth test"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute/rocm_bandwidth_test"
+distfiles="${homepage}/archive/rocm-${version}.tar.gz"
+checksum=f5f914073018619dc91662d5bf630903dfa4db9136d603591917fdfb3c9164ce
+nocross=yes
+
+post_install() {
+	vlicense LICENSE.txt
+}
diff --git a/srcpkgs/rocm_bandwidth_test/update b/srcpkgs/rocm_bandwidth_test/update
new file mode 100644
index 00000000000..86197bc3eea
--- /dev/null
+++ b/srcpkgs/rocm_bandwidth_test/update
@@ -0,0 +1 @@
+pattern='rocm-\K[\d.]+'

From 7ca769a7fb95482a6bab6df5b9820e9e250e7102 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Tue, 14 Apr 2020 10:25:54 -0400
Subject: [PATCH 08/10] New package: ROCm-OpenCL-Runtime-3.3.0

---
 common/shlibs                                 |   2 +
 srcpkgs/ROCm-OpenCL-Runtime-clinfo            |   1 +
 srcpkgs/ROCm-OpenCL-Runtime-devel             |   1 +
 .../files/libelf-musl.patch                   |  21 +++
 .../files/runtime-musl.patch                  |  11 ++
 .../ROCm-OpenCL-Runtime/patches/cmake.patch   | 126 ++++++++++++++++++
 srcpkgs/ROCm-OpenCL-Runtime/template          |  84 ++++++++++++
 srcpkgs/ROCm-OpenCL-Runtime/update            |   1 +
 8 files changed, 247 insertions(+)
 create mode 120000 srcpkgs/ROCm-OpenCL-Runtime-clinfo
 create mode 120000 srcpkgs/ROCm-OpenCL-Runtime-devel
 create mode 100644 srcpkgs/ROCm-OpenCL-Runtime/files/libelf-musl.patch
 create mode 100644 srcpkgs/ROCm-OpenCL-Runtime/files/runtime-musl.patch
 create mode 100644 srcpkgs/ROCm-OpenCL-Runtime/patches/cmake.patch
 create mode 100644 srcpkgs/ROCm-OpenCL-Runtime/template
 create mode 100644 srcpkgs/ROCm-OpenCL-Runtime/update

diff --git a/common/shlibs b/common/shlibs
index 83cc61a42be..99326e93f0f 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3879,3 +3879,5 @@ libjcat.so.1 libjcat-0.1.2_1
 libhsakmt.so.1 ROCT-Thunk-Interface-3.3.0_1
 libhsa-runtime64.so.1 ROCR-Runtime-3.3.0_1
 libamd_comgr.so.1 ROCm-CompilerSupport-3.3.0_1
+libOpenCL-ROCm.so.1 ROCm-OpenCL-Runtime-3.3.0_1
+libamdocl64.so ROCm-OpenCL-Runtime-3.3.0_1
diff --git a/srcpkgs/ROCm-OpenCL-Runtime-clinfo b/srcpkgs/ROCm-OpenCL-Runtime-clinfo
new file mode 120000
index 00000000000..21f2041b8fb
--- /dev/null
+++ b/srcpkgs/ROCm-OpenCL-Runtime-clinfo
@@ -0,0 +1 @@
+ROCm-OpenCL-Runtime
\ No newline at end of file
diff --git a/srcpkgs/ROCm-OpenCL-Runtime-devel b/srcpkgs/ROCm-OpenCL-Runtime-devel
new file mode 120000
index 00000000000..21f2041b8fb
--- /dev/null
+++ b/srcpkgs/ROCm-OpenCL-Runtime-devel
@@ -0,0 +1 @@
+ROCm-OpenCL-Runtime
\ No newline at end of file
diff --git a/srcpkgs/ROCm-OpenCL-Runtime/files/libelf-musl.patch b/srcpkgs/ROCm-OpenCL-Runtime/files/libelf-musl.patch
new file mode 100644
index 00000000000..29469a9a351
--- /dev/null
+++ b/srcpkgs/ROCm-OpenCL-Runtime/files/libelf-musl.patch
@@ -0,0 +1,21 @@
+--- compiler/lib/loaders/elf/utils/libelf/_libelf.h	2020-04-28 15:50:53.243438174 -0400
++++ compiler/lib/loaders/elf/utils/libelf/_libelf.h	2020-04-28 15:51:54.293435415 -0400
+@@ -35,6 +35,7 @@
+ #include "_libelf_config.h"
+ 
+ #include "_elftc.h"
++#include <sys/cdefs.h>
+ 
+ /*
+  * Library-private data structures.
+--- compiler/lib/loaders/elf/utils/libelf/libelf.h	2020-04-28 15:50:53.244438174 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf.h	2020-04-28 15:52:12.375434593 -0400
+@@ -36,6 +36,8 @@
+ #define EM_HSAIL 0xAF5A
+ #endif
+ 
++#include <sys/cdefs.h>
++
+ /* Library private data structures */
+ typedef struct _Elf Elf;
+ typedef struct _Elf_Scn Elf_Scn;
diff --git a/srcpkgs/ROCm-OpenCL-Runtime/files/runtime-musl.patch b/srcpkgs/ROCm-OpenCL-Runtime/files/runtime-musl.patch
new file mode 100644
index 00000000000..ea18e90e09c
--- /dev/null
+++ b/srcpkgs/ROCm-OpenCL-Runtime/files/runtime-musl.patch
@@ -0,0 +1,11 @@
+--- runtime/os/os_posix.cpp.orig	2020-04-19 09:13:51.701982901 -0400
++++ runtime/os/os_posix.cpp	2020-04-19 09:14:04.156947422 -0400
+@@ -44,6 +44,8 @@
+ #include <algorithm>
+ #include <mutex>
+ 
++#include <libgen.h> // for basename
++
+ 
+ namespace amd {
+ 
diff --git a/srcpkgs/ROCm-OpenCL-Runtime/patches/cmake.patch b/srcpkgs/ROCm-OpenCL-Runtime/patches/cmake.patch
new file mode 100644
index 00000000000..2c96b99d45a
--- /dev/null
+++ b/srcpkgs/ROCm-OpenCL-Runtime/patches/cmake.patch
@@ -0,0 +1,126 @@
+--- OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/CMakeLists.txt	2019-09-10 11:53:28.000000000 -0400
++++ OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/CMakeLists.txt	2020-04-16 20:16:13.481180757 -0400
+@@ -73,11 +73,11 @@
+ 
+ set (OPENCL_ICD_LOADER_HEADERS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/inc CACHE PATH "Path to OpenCL Headers")
+ 
+-add_library (OpenCL ${OPENCL_ICD_LOADER_SOURCES})
+-set_target_properties (OpenCL PROPERTIES VERSION "1.2" SOVERSION "1")
++add_library (OpenCL-ROCm ${OPENCL_ICD_LOADER_SOURCES})
++set_target_properties (OpenCL-ROCm PROPERTIES VERSION "1.2" SOVERSION "1")
+ 
+ if (WIN32)
+-    target_link_libraries (OpenCL cfgmgr32.lib)
++    target_link_libraries (OpenCL-ROCm cfgmgr32.lib)
+ 
+     option (OPENCL_ICD_LOADER_REQUIRE_WDK "Build with D3DKMT support, which requires the Windows WDK." ON)
+     if (OPENCL_ICD_LOADER_REQUIRE_WDK)
+@@ -92,10 +92,10 @@
+             get_filename_component(WDK_DIRECTORY ${LATEST_D3DKMT_HEADER} DIRECTORY)
+             get_filename_component(WDK_DIRECTORY ${WDK_DIRECTORY} DIRECTORY)
+             message(STATUS "Found the Windows WDK in: ${WDK_DIRECTORY}")
+-            target_compile_definitions(OpenCL PRIVATE OPENCL_ICD_LOADER_REQUIRE_WDK)
+-            target_include_directories(OpenCL PRIVATE ${WDK_DIRECTORY}/um)
+-            target_include_directories(OpenCL PRIVATE ${WDK_DIRECTORY}/km)
+-            target_include_directories(OpenCL PRIVATE ${WDK_DIRECTORY}/shared)
++	    target_compile_definitions(OpenCL-ROCm PRIVATE OPENCL_ICD_LOADER_REQUIRE_WDK)
++	    target_include_directories(OpenCL-ROCm PRIVATE ${WDK_DIRECTORY}/um)
++	    target_include_directories(OpenCL-ROCm PRIVATE ${WDK_DIRECTORY}/km)
++	    target_include_directories(OpenCL-ROCm PRIVATE ${WDK_DIRECTORY}/shared)
+         else()
+             message(FATAL_ERROR "The Windows WDK was not found. Consider disabling OPENCL_ICD_LOADER_REQUIRE_WDK. Aborting.")
+         endif()
+@@ -113,25 +113,25 @@
+     endif()
+ else()
+     if (APPLE)
+-        target_link_libraries (OpenCL ${CMAKE_THREAD_LIBS_INIT})
++        target_link_libraries (OpenCL-ROCm ${CMAKE_THREAD_LIBS_INIT})
+     else ()
+-        set_target_properties (OpenCL PROPERTIES LINK_FLAGS "-Wl,--version-script -Wl,${CMAKE_CURRENT_SOURCE_DIR}/loader/linux/icd_exports.map")
+-        target_link_libraries (OpenCL ${CMAKE_THREAD_LIBS_INIT})
++        set_target_properties (OpenCL-ROCm PROPERTIES LINK_FLAGS "-Wl,--version-script -Wl,${CMAKE_CURRENT_SOURCE_DIR}/loader/linux/icd_exports.map")
++	target_link_libraries (OpenCL-ROCm ${CMAKE_THREAD_LIBS_INIT})
+     endif ()
+ endif ()
+ 
+ include_directories (${OPENCL_ICD_LOADER_HEADERS_DIR})
+ add_definitions (-DCL_TARGET_OPENCL_VERSION=220)
+ 
+-target_include_directories (OpenCL PRIVATE ${CMAKE_CURRENT_BINARY_DIR} loader)
+-target_link_libraries (OpenCL ${CMAKE_DL_LIBS})
++target_include_directories (OpenCL-ROCm PRIVATE ${CMAKE_CURRENT_BINARY_DIR} loader)
++target_link_libraries (OpenCL-ROCm ${CMAKE_DL_LIBS})
+ 
+ include (CTest)
+ if (BUILD_TESTING)
+     add_subdirectory (test)
+ endif()
+ 
+-install (TARGETS OpenCL
++install (TARGETS OpenCL-ROCm
+     RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+     ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
+     LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
+--- OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/test/loader_test/CMakeLists.txt	2019-09-10 11:53:28.000000000 -0400
++++ OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/test/loader_test/CMakeLists.txt	2020-04-16 20:16:56.647026589 -0400
+@@ -12,4 +12,4 @@
+     test_clgl.c
+     test_image_objects.c )
+ 
+-target_link_libraries (icd_loader_test OpenCL IcdLog)
++target_link_libraries (icd_loader_test OpenCL-ROCm IcdLog)
+--- ROCm-OpenCL-Runtime-roc-3.3.0/CMakeLists.txt	2020-04-28 07:29:51.864446603 -0400
++++ ROCm-OpenCL-Runtime-roc-3.3.0/CMakeLists.txt	2020-04-28 07:32:45.245793180 -0400
+@@ -101,30 +101,30 @@
+ rocm_setup_version( VERSION "2.0.0" )
+ 
+ # MAIN package
+-install(PROGRAMS $<TARGET_FILE:clinfo>
+-        DESTINATION bin/x86_64
++install(PROGRAMS $<TARGET_FILE:rocm-clinfo>
++        DESTINATION bin
+         COMPONENT MAIN)
+ install(PROGRAMS $<TARGET_FILE:amdocl64>
+-        DESTINATION lib/x86_64
++        DESTINATION lib
+         COMPONENT MAIN)
+-install(PROGRAMS $<TARGET_FILE:OpenCL>
+-        DESTINATION lib/x86_64
++install(PROGRAMS $<TARGET_FILE:OpenCL-ROCm>
++        DESTINATION lib
+         COMPONENT MAIN)
+-install(PROGRAMS $<TARGET_SONAME_FILE:OpenCL>
+-        DESTINATION lib/x86_64
++install(PROGRAMS $<TARGET_SONAME_FILE:OpenCL-ROCm>
++        DESTINATION lib
+         COMPONENT MAIN)
+ 
+ # DEV package
+ install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/api/opencl/khronos/headers/opencl2.2/CL"
+-        DESTINATION include
++	DESTINATION include/rocm
+         COMPONENT DEV
+         USE_SOURCE_PERMISSIONS
+         PATTERN cl_d3d10.h EXCLUDE
+         PATTERN cl_d3d11.h EXCLUDE
+         PATTERN cl_dx9_media_sharing.h EXCLUDE
+         PATTERN cl_egl.h EXCLUDE)
+-install(PROGRAMS $<TARGET_LINKER_FILE:OpenCL>
+-        DESTINATION lib/x86_64
++install(PROGRAMS $<TARGET_LINKER_FILE:OpenCL-ROCm>
++        DESTINATION lib
+         COMPONENT DEV)
+ 
+ # Generic CPACK variables
+--- ROCm-OpenCL-Runtime-roc-3.3.0/tools/clinfo/CMakeLists.txt	2020-04-28 07:29:51.882446535 -0400
++++ ROCm-OpenCL-Runtime-roc-3.3.0/tools/clinfo/CMakeLists.txt	2020-04-28 07:30:05.627394732 -0400
+@@ -6,6 +6,6 @@
+ 
+ add_definitions(-DHAVE_CL2_HPP)
+ 
+-add_executable(clinfo clinfo.cpp)
++add_executable(rocm-clinfo clinfo.cpp)
+ 
+-target_link_libraries(clinfo OpenCL)
++target_link_libraries(rocm-clinfo OpenCL-ROCm)
diff --git a/srcpkgs/ROCm-OpenCL-Runtime/template b/srcpkgs/ROCm-OpenCL-Runtime/template
new file mode 100644
index 00000000000..f6699a1d4c0
--- /dev/null
+++ b/srcpkgs/ROCm-OpenCL-Runtime/template
@@ -0,0 +1,84 @@
+# Template file for 'ROCm-OpenCL-Runtime'
+pkgname=ROCm-OpenCL-Runtime
+version=3.3.0
+revision=1
+_ocl_icd_name="OpenCL-ICD-Loader"
+_ocl_icd_ver="6c03f8b58fafd9dd693eaac826749a5cfad515f8"
+archs="x86_64*"
+create_wrksrc=yes
+build_wrksrc="${pkgname}-roc-${version}"
+build_style=cmake
+configure_args="-DUSE_COMGR_LIBRARY=yes"
+hostmakedepends="cmake pkg-config"
+makedepends="libglvnd-devel ROCm-CompilerSupport-devel
+	ROCT-Thunk-Interface-devel ROCR-Runtime-devel"
+depends="ROCm-CompilerSupport"
+short_desc="Radeon Open Compute OpenCL runtime"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="MIT"
+homepage="https://github.com/RadeonOpenCompute/ROCm-OpenCL-Runtime"
+_rocroot="https://github.com/RadeonOpenCompute"
+distfiles="${_rocroot}/ROCm-OpenCL-Runtime/archive/roc-${version}.tar.gz
+	${_rocroot}/rocm-cmake/archive/rocm-${version}.tar.gz
+	https://github.com/KhronosGroup/${_ocl_icd_name}/archive/${_ocl_icd_ver}.tar.gz"
+checksum="ac6999f1a491ab066286c2bd6adf50f08f831286f56e267879f9f7eced22f98e
+	76ed3ee8e56cf3246011cf7723c2abda539e1136e7e7f6909bfa45d268b8644f
+	c94d5bb6dc980c4d41d73e2b81663a19aabe494e923e2d0eec72a4c95b318438"
+nocross=yes
+
+if [ "$XBPS_LIBC" = "musl" ]; then
+	makedepends+=" musl-legacy-compat"
+fi
+
+post_patch() {
+	if [ "$XBPS_LIBC" = "musl" ]; then
+		# Remove dependence on glibc
+		patch -Np0 < ${FILESDIR}/libelf-musl.patch
+		patch -Np0 < ${FILESDIR}/runtime-musl.patch
+		vsed -e '/glibc_functions.cpp/d' -i api/opencl/amdocl/CMakeLists.txt
+	fi
+}
+
+pre_configure() {
+	# ROCm requires a very specific Khronos ICD loader version in the tree
+	# Keep the ICD loader config in /etc/OpenCL/rocm-vendors to avoid conflicts
+	_ocl_icd_dir="${_ocl_icd_name}-${_ocl_icd_ver}"
+	ln -sf "${wrksrc}/${_ocl_icd_dir}" api/opencl/khronos/icd
+	vsed -i "${wrksrc}/${_ocl_icd_dir}/loader/icd_platform.h" \
+		-e 's@/etc/OpenCL/vendors/@/etc/OpenCL/rocm-vendors/@g'
+
+	# CMake modules probably not useful anywhere but for this build
+	ln -sf "${wrksrc}/rocm-cmake-rocm-${version}/share/rocm/cmake"/*.cmake cmake
+
+	# Fix the dlopen macro to point to versioned libamd_comgr shared object
+	vsed -i 'runtime/device/comgrctx.cpp' \
+		-e 's/\blibamd_comgr\(32\)\?.so\b/&.1/g'
+}
+
+post_install() {
+	vlicense License
+
+	# Create descriptor to allow the ICD loader to find the driver
+	vmkdir etc/OpenCL/rocm-vendors
+	echo "libamdocl64.so" > "${DESTDIR}/etc/OpenCL/rocm-vendors/amdocl64.icd"
+	vmkdir etc/OpenCL/vendors
+	ln -s ../../OpenCL/rocm-vendors/amdocl64.icd \
+		${DESTDIR}/etc/OpenCL/vendors/rocm-amdocl64.icd
+}
+
+ROCm-OpenCL-Runtime-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/lib/libOpenCL-ROCm.so
+		vmove usr/include
+	}
+}
+
+ROCm-OpenCL-Runtime-clinfo_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - clinfo"
+	pkg_install() {
+		vmove usr/bin/rocm-clinfo
+	}
+}
diff --git a/srcpkgs/ROCm-OpenCL-Runtime/update b/srcpkgs/ROCm-OpenCL-Runtime/update
new file mode 100644
index 00000000000..8385f4d1215
--- /dev/null
+++ b/srcpkgs/ROCm-OpenCL-Runtime/update
@@ -0,0 +1 @@
+pattern='roc-\K[\d.]+'

From e7e9396f27d38f7069a7dec63c18ebf4c7263db9 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Thu, 30 Apr 2020 13:11:12 -0400
Subject: [PATCH 09/10] New package: ROCR-Runtime-hsa-ext-3.3.0

---
 common/shlibs                         |  2 ++
 srcpkgs/ROCR-Runtime-hsa-ext-devel    |  1 +
 srcpkgs/ROCR-Runtime-hsa-ext/template | 43 +++++++++++++++++++++++++++
 srcpkgs/ROCR-Runtime-hsa-ext/update   |  2 ++
 4 files changed, 48 insertions(+)
 create mode 120000 srcpkgs/ROCR-Runtime-hsa-ext-devel
 create mode 100644 srcpkgs/ROCR-Runtime-hsa-ext/template
 create mode 100644 srcpkgs/ROCR-Runtime-hsa-ext/update

diff --git a/common/shlibs b/common/shlibs
index 99326e93f0f..10854dc8b19 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3881,3 +3881,5 @@ libhsa-runtime64.so.1 ROCR-Runtime-3.3.0_1
 libamd_comgr.so.1 ROCm-CompilerSupport-3.3.0_1
 libOpenCL-ROCm.so.1 ROCm-OpenCL-Runtime-3.3.0_1
 libamdocl64.so ROCm-OpenCL-Runtime-3.3.0_1
+libhsa-ext-image64.so.1 ROCR-Runtime-hsa-ext-3.3.0_1
+libhsa-runtime-tools64.so.1 ROCR-Runtime-hsa-ext-3.3.0_1
diff --git a/srcpkgs/ROCR-Runtime-hsa-ext-devel b/srcpkgs/ROCR-Runtime-hsa-ext-devel
new file mode 120000
index 00000000000..6ee1b14911b
--- /dev/null
+++ b/srcpkgs/ROCR-Runtime-hsa-ext-devel
@@ -0,0 +1 @@
+ROCR-Runtime-hsa-ext
\ No newline at end of file
diff --git a/srcpkgs/ROCR-Runtime-hsa-ext/template b/srcpkgs/ROCR-Runtime-hsa-ext/template
new file mode 100644
index 00000000000..235ae92146b
--- /dev/null
+++ b/srcpkgs/ROCR-Runtime-hsa-ext/template
@@ -0,0 +1,43 @@
+# Template file for 'ROCR-Runtime-hsa-ext'
+pkgname=ROCR-Runtime-hsa-ext
+version=3.3.0
+revision=1
+archs="x86_64"
+hostmakedepends="tar"
+short_desc="Radeon Open Compute HSA runtime extensions"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute"
+_hsa_deb="hsa-ext-rocr-dev_1.1.30300.0-rocm-rel-3.3-19-23fc088b_amd64.deb"
+distfiles="https://repo.radeon.com/rocm/apt/debian/pool/main/h/hsa-ext-rocr-dev/$_hsa_deb"
+checksum=6b44e286b395d946b865ec1f3cc546356396785ac1fde591d07af02d0aa7c25d
+repository=nonfree
+restricted=yes
+
+do_extract() {
+	ar x "${XBPS_SRCDISTDIR}/${pkgname}-${version}/${_hsa_deb}"
+	tar xvf data.tar.gz
+}
+
+do_install() {
+	_rocm_includes="opt/rocm-${version}/hsa/include"
+
+	vmkdir usr
+	vcopy opt/rocm-${version}/hsa/lib usr
+	vcopy "$_rocm_includes" usr
+
+	# Extract license from one of the header files
+	awk 'BEGIN{HEADER=0} /\/\//{HEADER=1; print $0;} /^[^/]/{if(HEADER==1) exit;}' \
+		< "${_rocm_includes}/hsa/amd_hsa_tools_interfaces.h" \
+		| sed 's@^///*\( \|$\)@@' > LICENSE
+	vlicense LICENSE
+}
+
+ROCR-Runtime-hsa-ext-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove "usr/lib/*.so"
+	}
+}
diff --git a/srcpkgs/ROCR-Runtime-hsa-ext/update b/srcpkgs/ROCR-Runtime-hsa-ext/update
new file mode 100644
index 00000000000..84252d2e3b8
--- /dev/null
+++ b/srcpkgs/ROCR-Runtime-hsa-ext/update
@@ -0,0 +1,2 @@
+site='https://repo.radeon.com/rocm/apt/debian/pool/main/h/'
+pattern='hsa-ext-rocr-dev\K[\d.]+'

From bb3851323681935097e8438ff970db45ab9102c8 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Tue, 28 Apr 2020 13:33:46 -0400
Subject: [PATCH 10/10] hashcat: add build option to link against ROCm [ci
 skip]

---
 srcpkgs/hashcat/files/rocm.patch     | 15 ++++++++++++++
 srcpkgs/hashcat/patches/tmpdir.patch | 30 ++++++++++++++++++++++++++++
 srcpkgs/hashcat/template             | 17 +++++++++++++---
 3 files changed, 59 insertions(+), 3 deletions(-)
 create mode 100644 srcpkgs/hashcat/files/rocm.patch
 create mode 100644 srcpkgs/hashcat/patches/tmpdir.patch

diff --git a/srcpkgs/hashcat/files/rocm.patch b/srcpkgs/hashcat/files/rocm.patch
new file mode 100644
index 00000000000..f1e899d30ee
--- /dev/null
+++ b/srcpkgs/hashcat/files/rocm.patch
@@ -0,0 +1,15 @@
+diff -ur a/src/opencl.c b/src/opencl.c
+--- a/src/opencl.c	2018-12-02 05:58:48.000000000 -0500
++++ b/src/opencl.c	2020-04-28 13:24:12.602415333 -0400
+@@ -492,9 +492,9 @@
+ 
+   if (ocl->lib == NULL) ocl->lib = hc_dlopen ("cygOpenCL-1.dll", RTLD_NOW);
+   #else
+-  ocl->lib = hc_dlopen ("libOpenCL.so", RTLD_NOW);
++  ocl->lib = hc_dlopen ("libOpenCL-ROCm.so.1", RTLD_NOW);
+ 
+-  if (ocl->lib == NULL) ocl->lib = hc_dlopen ("libOpenCL.so.1", RTLD_NOW);
++  if (ocl->lib == NULL) ocl->lib = hc_dlopen ("libOpenCL-ROCm.so", RTLD_NOW);
+   #endif
+ 
+   if (ocl->lib == NULL)
diff --git a/srcpkgs/hashcat/patches/tmpdir.patch b/srcpkgs/hashcat/patches/tmpdir.patch
new file mode 100644
index 00000000000..c6aab72db16
--- /dev/null
+++ b/srcpkgs/hashcat/patches/tmpdir.patch
@@ -0,0 +1,30 @@
+diff --git src/folder.c src/folder.c
+index 0c313f31..e54910b1 100644
+--- src/folder.c
++++ src/folder.c
+@@ -462,9 +462,24 @@ int folder_config_init (hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const char *ins
+   {
+     char *tmp;
+ 
+-    hc_asprintf (&tmp, "TMP=%s", cpath_real);
++    #if defined (_POSIX)
++    // Setting TMP may break POSIX temporary directory semantics
++    // Fix it by setting the POSIX-ly correct TMPDIR if it is not already set
++    if (getenv ("TMPDIR") == NULL) {
++      if (getenv("TMP") != NULL) {
++        // TMP was specified in the environment, promote it to TMPDIR
++        hc_asprintf (&tmp, "TMPDIR=%s", getenv("TMP"));
++        putenv (tmp);
++        hcfree (tmp);
++      } else {
++        putenv ("TMPDIR=/tmp");
++      }
++    }
++    #endif
+ 
++    hc_asprintf (&tmp, "TMP=%s", cpath_real);
+     putenv (tmp);
++    hcfree (tmp);
+   }
+ 
+   #if defined (_WIN)
diff --git a/srcpkgs/hashcat/template b/srcpkgs/hashcat/template
index e982f99cebf..3f19be5e41d 100644
--- a/srcpkgs/hashcat/template
+++ b/srcpkgs/hashcat/template
@@ -1,15 +1,16 @@
 # Template file for 'hashcat'
 pkgname=hashcat
 version=5.1.0
-revision=2
+revision=3
 build_style=gnu-makefile
 make_build_args="PREFIX=/usr
  USE_SYSTEM_OPENCL=1 USE_SYSTEM_XXHASH=1
- DEPS_OPENCL_PATH=${XBPS_CROSS_BASE}/usr/include
+ DEPS_OPENCL_PATH=${XBPS_CROSS_BASE}/usr/include$(vopt_if rocm /rocm)
  DEPS_XXHASH_PATH=${XBPS_CROSS_BASE}/usr/include"
 make_use_env=yes
 make_install_args="$make_build_args"
-makedepends="gmp-devel opencl2-headers xxHash-devel"
+makedepends="gmp-devel xxHash-devel
+ $(vopt_if rocm ROCm-OpenCL-Runtime-devel opencl2-headers)"
 checkdepends="perl"
 short_desc="Advanced CPU-based password recovery utility"
 maintainer="Duncaen <duncaen@voidlinux.org>"
@@ -19,6 +20,9 @@ changelog="https://raw.githubusercontent.com/hashcat/hashcat/master/docs/changes
 distfiles="https://hashcat.net/files/hashcat-${version}.tar.gz"
 checksum=283beaa68e1eab41de080a58bb92349c8e47a2bb1b93d10f36ea30f418f1e338
 
+build_options="rocm"
+desc_option_rocm="Use ROCm OpenCL runtime"
+
 if [ "$XBPS_TARGET_ENDIAN" = "be" ]; then
 	broken="Not supported on big endian"
 fi
@@ -26,6 +30,13 @@ fi
 post_extract() {
 	sed '/^CC/d' -i src/Makefile
 }
+
+post_patch() {
+	if [ "$build_option_rocm" ]; then
+		patch -Np1 < ${FILESDIR}/rocm.patch
+	fi
+}
+
 post_install() {
 	rm -f ${DESTDIR}/usr/share/docs/hashcat/license.txt
 	vlicense docs/license.txt

^ permalink raw reply	[flat|nested] 61+ messages in thread

* Re: [PR PATCH] [Updated] New packages: ROCm core and OpenCL
  2020-04-19 13:34 [PR PATCH] New packages: ROCm core and OpenCL ahesford
                   ` (28 preceding siblings ...)
  2020-05-07 16:01 ` ahesford
@ 2020-05-08 14:40 ` ahesford
  2020-05-11 18:02 ` ericonr
                   ` (29 subsequent siblings)
  59 siblings, 0 replies; 61+ messages in thread
From: ahesford @ 2020-05-08 14:40 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 3893 bytes --]

There is an updated pull request by ahesford against master on the void-packages repository

https://github.com/ahesford/void-packages rocm
https://github.com/void-linux/void-packages/pull/21153

New packages: ROCm core and OpenCL
This PR includes several packages designed to bring the OpenCL portion of the AMD ROCm ecosystem to Void. It addresses Issue #19507. There are many other packages that AMD provides for GPGPU computing, but these can be added piecemeal as users demand.

The packages are currently only for `x86_64*`. While at least some of the packages will compile on other 64-bit architectures, I have no hardware to test. They are certainly not suitable for 32-bit architectures; some internal data structures rely on `uint64_t` values that are cast to pointers. At a
minimum, a thorough audit would be necessary to ensure that these casts are safe (e.g., that the values stored were only ever upcast from 32-bit pointers). More extensive work may be necessary to support 32-bit architectures, probably without significant benefit.

The packages successfully identify a Radeon RX 580 on an `x86_64` installation using both `clinfo` and `rocminfo` as provided. Furthermore, a version of `pyopencl` linked against these ROCm packages successfully runs a simple program that validates arithmetic on GPU-bound arrays.

There are caveats with this set of packages, almost all of which revolve around the incompatibilities between the Void-provided `ocl-icd` and the [Khronos OpenCL ICD loader](https://github.com/KhronosGroup/OpenCL-ID-Loader) required by (and built into) `rocm-opencl-runtime`.
1. All packages install into `/opt/rocm`. This keeps the environment closer to that officially sanctioned by AMD and helps avoid conflicts between other packages and those provided here. (For example, `clinfo` and the ICD loader itself.) Eventually, we may be able to move the files into `/usr`.
2. The Khronos OpenCL ICD loader built into `rocm-opencl-runtime` is an outdated, pre-release commit. If AMD can update its sources to use the release version of that loader (which has a backward-incompatible API change), we may be able to make ROCm compatible with `ocl-icd` or replace `ocl-icd` with the official Khronos loader.
3. In the meantime, to avoid `shlibs` conflicts, the OpenCL ICD loader is installed as `/opt/rocm/lib/libOpenCL-ROCm.so` (and an appropriately versioned shared library), which means that programs wishing to use the ROCm OpenCL must explicitly link against this library instead of the generic `libOpenCL.so`.
4. I do **not** recommend making any Void packages link against this specific library, because it will make those packages ROCm-only. For the time being, ROCm is intended for end-users to specifically link against. Linking Void packages against ROCm would requires the ICD loader used by ROCm be compatible with `ocl-icd`, or `ocl-icd` be replaced by the Khronos loader. However, because the Khronos loader changed its API for the release version, such a change is not yet appropriate.

Hopefully, if AMD updates its dependence on the Khronos ICD loader, we can resolve some of these caveats in the future and make ROCm a more natural Void component. For now, these packages are useful for those who need an AMD OpenCL solution and would rather custom-link software against the AMD ICD loader than hack the `amdgpu-pro` driver into an ICD compatible with `ocl-icd`.

Some patches were made to relocate some files in `/opt/rocm` and make everyting build on x86_64-musl`. Where appropriate, these patches will be pushed upstream to clean up the distribution and packaging.

Update: I pushed some new commits to update license information that triggerd an `xlint` failure. I've also disabled CI builds because they will time out on `rocm-llvm`.

A patch file from https://github.com/void-linux/void-packages/pull/21153.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-rocm-21153.patch --]
[-- Type: text/x-diff, Size: 39470 bytes --]

From 608290612f6081d4a54304391ac005e5010a4cce Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Mon, 13 Apr 2020 13:08:09 -0400
Subject: [PATCH 01/10] New package: ROCT-Thunk-Interface-3.3.0

---
 common/shlibs                                 |  2 ++
 srcpkgs/ROCT-Thunk-Interface-devel            |  1 +
 .../patches/cmake-dev-libdir.patch            | 10 ++++++
 .../ROCT-Thunk-Interface/patches/musl.patch   | 29 ++++++++++++++++
 srcpkgs/ROCT-Thunk-Interface/template         | 33 +++++++++++++++++++
 srcpkgs/ROCT-Thunk-Interface/update           |  1 +
 6 files changed, 76 insertions(+)
 create mode 120000 srcpkgs/ROCT-Thunk-Interface-devel
 create mode 100644 srcpkgs/ROCT-Thunk-Interface/patches/cmake-dev-libdir.patch
 create mode 100644 srcpkgs/ROCT-Thunk-Interface/patches/musl.patch
 create mode 100644 srcpkgs/ROCT-Thunk-Interface/template
 create mode 100644 srcpkgs/ROCT-Thunk-Interface/update

diff --git a/common/shlibs b/common/shlibs
index fa8af66f925..329b2d47445 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3875,3 +3875,5 @@ libhidrd_opt.so.0 hidrd-0.2.0_1
 libhidrd_strm.so.0 hidrd-0.2.0_1
 libhidrd_fmt.so.0 hidrd-0.2.0_1
 libjcat.so.1 libjcat-0.1.2_1
+
+libhsakmt.so.1 ROCT-Thunk-Interface-3.3.0_1
diff --git a/srcpkgs/ROCT-Thunk-Interface-devel b/srcpkgs/ROCT-Thunk-Interface-devel
new file mode 120000
index 00000000000..7e43c209e3d
--- /dev/null
+++ b/srcpkgs/ROCT-Thunk-Interface-devel
@@ -0,0 +1 @@
+ROCT-Thunk-Interface
\ No newline at end of file
diff --git a/srcpkgs/ROCT-Thunk-Interface/patches/cmake-dev-libdir.patch b/srcpkgs/ROCT-Thunk-Interface/patches/cmake-dev-libdir.patch
new file mode 100644
index 00000000000..98c7f1e459c
--- /dev/null
+++ b/srcpkgs/ROCT-Thunk-Interface/patches/cmake-dev-libdir.patch
@@ -0,0 +1,10 @@
+--- CMakeLists.txt.old	2020-04-18 19:45:17.306081135 -0400
++++ CMakeLists.txt	2020-04-18 19:46:51.300753636 -0400
+@@ -146,6 +146,7 @@
+     COMMAND ${CMAKE_COMMAND}
+         -DSOURCE_DIR="${SOURCE_DIR}"
+         -DCMAKE_INSTALL_PREFIX="${CMAKE_INSTALL_PREFIX}"
++        -DCMAKE_INSTALL_LIBDIR="${CMAKE_INSTALL_LIBDIR}"
+         -DCPACK_RPM_PACKAGE_REQUIRES="hsakmt-roct"
+         -DCPACK_PACKAGING_INSTALL_PREFIX="${CPACK_PACKAGING_INSTALL_PREFIX}"
+         -DVERSION="${BUILD_VERSION_STRING}"
diff --git a/srcpkgs/ROCT-Thunk-Interface/patches/musl.patch b/srcpkgs/ROCT-Thunk-Interface/patches/musl.patch
new file mode 100644
index 00000000000..aeea9832411
--- /dev/null
+++ b/srcpkgs/ROCT-Thunk-Interface/patches/musl.patch
@@ -0,0 +1,29 @@
+diff -r -u old/src/libhsakmt.h new/src/libhsakmt.h
+--- src/libhsakmt.h	2020-03-04 15:00:47.000000000 -0500
++++ src/libhsakmt.h	2020-04-13 12:58:30.444865992 -0400
+@@ -54,6 +54,10 @@
+ #define CHECK_KFD_OPEN() \
+ 	do { if (kfd_open_count == 0 || hsakmt_forked) return HSAKMT_STATUS_KERNEL_IO_CHANNEL_NOT_OPENED; } while (0)
+ 
++/*On some platforms, a PAGE_SIZE macro eclipses the extern variable*/
++#ifdef PAGE_SIZE
++#undef PAGE_SIZE
++#endif
+ extern int PAGE_SIZE;
+ extern int PAGE_SHIFT;
+ 
+diff -r -u old/src/topology.c new/src/topology.c
+--- src/topology.c	2020-03-04 15:00:47.000000000 -0500
++++ src/topology.c	2020-04-13 13:01:31.209870701 -0400
+@@ -38,6 +38,11 @@
+ #include "libhsakmt.h"
+ #include "fmm.h"
+ 
++/*Needed on MUSL*/
++#ifndef MAXNAMLEN
++#define MAXNAMLEN PATH_MAX
++#endif
++
+ /* Number of memory banks added by thunk on top of topology
+  * This only includes static heaps like LDS, scratch and SVM,
+  * not for MMIO_REMAP heap. MMIO_REMAP memory bank is reported
diff --git a/srcpkgs/ROCT-Thunk-Interface/template b/srcpkgs/ROCT-Thunk-Interface/template
new file mode 100644
index 00000000000..8c680b2af29
--- /dev/null
+++ b/srcpkgs/ROCT-Thunk-Interface/template
@@ -0,0 +1,33 @@
+# Template file for 'ROCT-Thunk-Interface'
+pkgname=ROCT-Thunk-Interface
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="${pkgname}-roc-${version}"
+build_style=cmake
+make_build_target="all build-dev"
+make_install_target="install install-dev"
+hostmakedepends="cmake pkg-config"
+makedepends="pciutils-devel libnuma-devel"
+short_desc="Radeon Open Compute thunk interface"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="MIT"
+homepage="https://github.com/RadeonOpenCompute/ROCT-Thunk-Interface"
+distfiles="${homepage}/archive/roc-${version}.tar.gz"
+checksum=2cabe9d2cfa72031c05d11290837c476182e72d8dec2049298f691143fdd212b
+nocross=yes
+
+post_install() {
+	vlicense LICENSE.md
+}
+
+ROCT-Thunk-Interface-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove "usr/lib/*.so"
+		vmove usr/share/pkgconfig
+		vmove usr/lib/cmake
+	}
+}
diff --git a/srcpkgs/ROCT-Thunk-Interface/update b/srcpkgs/ROCT-Thunk-Interface/update
new file mode 100644
index 00000000000..8385f4d1215
--- /dev/null
+++ b/srcpkgs/ROCT-Thunk-Interface/update
@@ -0,0 +1 @@
+pattern='roc-\K[\d.]+'

From 11cf5aae6752b329d496aea191cc1da922d579c5 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Mon, 13 Apr 2020 15:27:27 -0400
Subject: [PATCH 02/10] New package: ROCR-Runtime-3.3.0

---
 common/shlibs                            |  1 +
 srcpkgs/ROCR-Runtime-devel               |  1 +
 srcpkgs/ROCR-Runtime/patches/cmake.patch | 27 +++++++++++++++++++++
 srcpkgs/ROCR-Runtime/template            | 30 ++++++++++++++++++++++++
 srcpkgs/ROCR-Runtime/update              |  1 +
 5 files changed, 60 insertions(+)
 create mode 120000 srcpkgs/ROCR-Runtime-devel
 create mode 100644 srcpkgs/ROCR-Runtime/patches/cmake.patch
 create mode 100644 srcpkgs/ROCR-Runtime/template
 create mode 100644 srcpkgs/ROCR-Runtime/update

diff --git a/common/shlibs b/common/shlibs
index 329b2d47445..992a0efdc93 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3877,3 +3877,4 @@ libhidrd_fmt.so.0 hidrd-0.2.0_1
 libjcat.so.1 libjcat-0.1.2_1
 
 libhsakmt.so.1 ROCT-Thunk-Interface-3.3.0_1
+libhsa-runtime64.so.1 ROCR-Runtime-3.3.0_1
diff --git a/srcpkgs/ROCR-Runtime-devel b/srcpkgs/ROCR-Runtime-devel
new file mode 120000
index 00000000000..a733fb9fbab
--- /dev/null
+++ b/srcpkgs/ROCR-Runtime-devel
@@ -0,0 +1 @@
+ROCR-Runtime
\ No newline at end of file
diff --git a/srcpkgs/ROCR-Runtime/patches/cmake.patch b/srcpkgs/ROCR-Runtime/patches/cmake.patch
new file mode 100644
index 00000000000..93b74cd2297
--- /dev/null
+++ b/srcpkgs/ROCR-Runtime/patches/cmake.patch
@@ -0,0 +1,27 @@
+--- src/CMakeLists.txt.old	2020-04-18 20:01:48.549636995 -0400
++++ src/CMakeLists.txt	2020-04-18 20:04:00.177179781 -0400
+@@ -108,8 +108,8 @@
+ ## ROCr build internal versioning
+ add_definitions ( -DROCR_BUILD_ID=${PACKAGE_VERSION_STRING} )
+ 
+-## Set RUNPATH - ../../lib covers use of the legacy symlink in /hsa/lib/
+-set(CMAKE_INSTALL_RPATH "$ORIGIN;$ORIGIN/../../lib;$ORIGIN/../../lib64;$ORIGIN/../lib64")
++## Set RUNPATH
++set(CMAKE_INSTALL_RPATH "$ORIGIN;$ORIGIN/../lib")
+ 
+ ## ------------------------- Linux Compiler and Linker options -------------------------
+ set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -fexceptions -fno-rtti -fvisibility=hidden -Wno-error=sign-compare -Wno-sign-compare -Wno-write-strings -Wno-conversion-null -fno-math-errno -fno-threadsafe-statics -fmerge-all-constants -fms-extensions -Wno-error=comment -Wno-comment -Wno-error=pointer-arith -Wno-pointer-arith -Wno-error=unused-variable -Wno-error=unused-function" )
+@@ -185,11 +185,8 @@
+ add_custom_target ( hsa_lib_link2 ALL WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMAND ${CMAKE_COMMAND} -E create_symlink ../hsa/lib/${CORE_RUNTIME_LIBRARY}.so.${SO_MAJOR} ${CORE_RUNTIME_LIBRARY}-link.so.${SO_MAJOR} )
+ 
+ ## Set install information
+-install ( TARGETS ${CORE_RUNTIME_TARGET} LIBRARY DESTINATION hsa/lib )
+-install ( DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/inc/ DESTINATION hsa/include/hsa )
+-install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/hsa_include_link DESTINATION include PERMISSIONS OWNER_WRITE OWNER_READ RENAME hsa )
+-install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/${CORE_RUNTIME_LIBRARY}-link.so DESTINATION lib PERMISSIONS OWNER_WRITE OWNER_READ RENAME ${CORE_RUNTIME_LIBRARY}.so )
+-install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/${CORE_RUNTIME_LIBRARY}-link.so.${SO_MAJOR} DESTINATION lib PERMISSIONS OWNER_WRITE OWNER_READ RENAME ${CORE_RUNTIME_LIBRARY}.so.${SO_MAJOR} )
++install ( TARGETS ${CORE_RUNTIME_TARGET} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} )
++install ( DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/inc/ DESTINATION include/hsa )
+ 
+ ## Packaging directives
+ set ( CPACK_GENERATOR "DEB;RPM" CACHE STRING "Package types to build")
diff --git a/srcpkgs/ROCR-Runtime/template b/srcpkgs/ROCR-Runtime/template
new file mode 100644
index 00000000000..95b7e701afb
--- /dev/null
+++ b/srcpkgs/ROCR-Runtime/template
@@ -0,0 +1,30 @@
+# Template file for 'ROCR-Runtime'
+pkgname=ROCR-Runtime
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="${pkgname}-rocm-${version}"
+build_wrksrc="src"
+build_style=cmake
+hostmakedepends="cmake pkg-config"
+makedepends="ROCT-Thunk-Interface-devel elfutils-devel"
+short_desc="Radeon Open Compute HSA runtime"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute/ROCR-Runtime"
+distfiles="${homepage}/archive/rocm-${version}.tar.gz"
+checksum=fa2d2d1f8a61d8a6952d377cf288d78c61776c3c2a666f163cafc3aa19ab0b61
+nocross=yes
+
+post_install() {
+	vlicense ../LICENSE.txt
+}
+
+ROCR-Runtime-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove "usr/lib/*.so"
+	}
+}
diff --git a/srcpkgs/ROCR-Runtime/update b/srcpkgs/ROCR-Runtime/update
new file mode 100644
index 00000000000..86197bc3eea
--- /dev/null
+++ b/srcpkgs/ROCR-Runtime/update
@@ -0,0 +1 @@
+pattern='rocm-\K[\d.]+'

From 4d7f427ce5b446400db7260a681e155eede5d4c7 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Mon, 13 Apr 2020 18:07:34 -0400
Subject: [PATCH 03/10] New package: ROCm-llvm-3.3.0

---
 srcpkgs/ROCm-llvm/template | 26 ++++++++++++++++++++++++++
 srcpkgs/ROCm-llvm/update   |  1 +
 2 files changed, 27 insertions(+)
 create mode 100644 srcpkgs/ROCm-llvm/template
 create mode 100644 srcpkgs/ROCm-llvm/update

diff --git a/srcpkgs/ROCm-llvm/template b/srcpkgs/ROCm-llvm/template
new file mode 100644
index 00000000000..4c3095b21f4
--- /dev/null
+++ b/srcpkgs/ROCm-llvm/template
@@ -0,0 +1,26 @@
+# Template file for 'ROCm-llvm'
+pkgname=ROCm-llvm
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="llvm-project-rocm-ocl-${version}"
+build_wrksrc=llvm
+build_style=cmake
+configure_args="-DCMAKE_INSTALL_PREFIX:PATH=/usr/lib/rocm-llvm
+	-DLLVM_ENABLE_PROJECTS='llvm;clang;lld' -DLLVM_TARGETS_TO_BUILD='AMDGPU'
+	-DLLVM_BUILD_DOCS=NO -DLLVM_ENABLE_OCAMLDOC=OFF
+	-DLLVM_ENABLE_SPHINX=NO -DLLVM_ENABLE_DOXYGEN=OFF
+	-DLLVM_INSTALL_UTILS=ON -DLLVM_VERSION_SUFFIX=roc -DOCAMLFIND=NO"
+hostmakedepends="cmake pkg-config python3"
+short_desc="Radeon Open Compute LLVM toolchain"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="Apache-2.0, NCSA, custom:LLVM-Exceptions"
+homepage="https://github.com/RadeonOpenCompute/llvm-project"
+distfiles="${homepage}/archive/rocm-ocl-${version}.tar.gz"
+checksum=a2bef7042e8e2f2cd8548cb246b88322e1c77188839983dcac8312d56f544dc8
+python_version=3
+nocross=yes
+
+post_install() {
+	vlicense LICENSE.TXT
+}
diff --git a/srcpkgs/ROCm-llvm/update b/srcpkgs/ROCm-llvm/update
new file mode 100644
index 00000000000..6a73667d3c1
--- /dev/null
+++ b/srcpkgs/ROCm-llvm/update
@@ -0,0 +1 @@
+pattern='rocm-ocl-\K[\d.]+'

From a452e778af82981c46e40c248becf616a293b899 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Tue, 14 Apr 2020 10:25:31 -0400
Subject: [PATCH 04/10] New package: ROCm-Device-Libs-3.3.0

---
 srcpkgs/ROCm-Device-Libs/template | 37 +++++++++++++++++++++++++++++++
 srcpkgs/ROCm-Device-Libs/update   |  1 +
 2 files changed, 38 insertions(+)
 create mode 100644 srcpkgs/ROCm-Device-Libs/template
 create mode 100644 srcpkgs/ROCm-Device-Libs/update

diff --git a/srcpkgs/ROCm-Device-Libs/template b/srcpkgs/ROCm-Device-Libs/template
new file mode 100644
index 00000000000..8086cd86450
--- /dev/null
+++ b/srcpkgs/ROCm-Device-Libs/template
@@ -0,0 +1,37 @@
+# Template file for 'ROCm-Device-Libs'
+pkgname=ROCm-Device-Libs
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="${pkgname}-rocm-ocl-${version}"
+build_style=cmake
+configure_args="-DLLVM_DIR:PATH=/usr/lib/rocm-llvm
+	-DCMAKE_INSTALL_LIBDIR:PATH=lib/rocm-device-libs"
+hostmakedepends="cmake ROCm-llvm"
+short_desc="Radeon Open Compute device libraries"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute/ROCm-Device-Libs"
+distfiles="${homepage}/archive/rocm-ocl-${version}.tar.gz"
+checksum=706b08230790e08ca6a7a2fb7687d6131fd39a562148340e00fa37a6c06769c5
+nocross=yes
+
+pre_configure() {
+	# Put bytecodes in a lib/ subdirectory
+	vsed -i Packages.cmake -e 's@/lib/@/${CMAKE_INSTALL_LIBDIR}/@'
+	vsed -i OCL.cmake -e 's@DESTINATION lib$@DESTINATION ${CMAKE_INSTALL_LIBDIR}@'
+
+	# Build the prepare-builtins executable with native compiler
+	mkdir -p utils/build
+	cd utils/build
+	_prepare_builtins="$PWD/prepare-builtins/prepare-builtins"
+	cmake ${configure_args} ..
+	make ${makejobs}
+
+	# Add path to prepare-builtins for cmake
+	configure_args+=" -DPREPARE_BUILTINS='${_prepare_builtins}'"
+}
+
+post_install() {
+	vlicense LICENSE
+}
diff --git a/srcpkgs/ROCm-Device-Libs/update b/srcpkgs/ROCm-Device-Libs/update
new file mode 100644
index 00000000000..6a73667d3c1
--- /dev/null
+++ b/srcpkgs/ROCm-Device-Libs/update
@@ -0,0 +1 @@
+pattern='rocm-ocl-\K[\d.]+'

From 45b9a6fda6064515cd6b95425af547c2c8677930 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Mon, 13 Apr 2020 18:30:00 -0400
Subject: [PATCH 05/10] New package: ROCm-CompilerSupport-3.3.0

---
 common/shlibs                         |  1 +
 srcpkgs/ROCm-CompilerSupport-devel    |  1 +
 srcpkgs/ROCm-CompilerSupport/template | 32 +++++++++++++++++++++++++++
 srcpkgs/ROCm-CompilerSupport/update   |  1 +
 4 files changed, 35 insertions(+)
 create mode 120000 srcpkgs/ROCm-CompilerSupport-devel
 create mode 100644 srcpkgs/ROCm-CompilerSupport/template
 create mode 100644 srcpkgs/ROCm-CompilerSupport/update

diff --git a/common/shlibs b/common/shlibs
index 992a0efdc93..4450bc95691 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3878,3 +3878,4 @@ libjcat.so.1 libjcat-0.1.2_1
 
 libhsakmt.so.1 ROCT-Thunk-Interface-3.3.0_1
 libhsa-runtime64.so.1 ROCR-Runtime-3.3.0_1
+libamd_comgr.so.1 ROCm-CompilerSupport-3.3.0_1
diff --git a/srcpkgs/ROCm-CompilerSupport-devel b/srcpkgs/ROCm-CompilerSupport-devel
new file mode 120000
index 00000000000..877aeafeeae
--- /dev/null
+++ b/srcpkgs/ROCm-CompilerSupport-devel
@@ -0,0 +1 @@
+ROCm-CompilerSupport
\ No newline at end of file
diff --git a/srcpkgs/ROCm-CompilerSupport/template b/srcpkgs/ROCm-CompilerSupport/template
new file mode 100644
index 00000000000..df56f7a3837
--- /dev/null
+++ b/srcpkgs/ROCm-CompilerSupport/template
@@ -0,0 +1,32 @@
+# Template file for 'ROCm-CompilerSupport'
+pkgname=ROCm-CompilerSupport
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="${pkgname}-rocm-${version}"
+build_wrksrc="lib/comgr"
+build_style=cmake
+configure_args="-DClang_DIR:PATH=/usr/lib/rocm-llvm/lib/cmake/clang"
+hostmakedepends="cmake pkg-config ROCm-llvm"
+makedepends="ROCm-Device-Libs"
+short_desc="Radeon Open Compute compiler support"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="BSD-3-Clause"
+homepage="https://github.com/RadeonOpenCompute/ROCm-CompilerSupport"
+distfiles="${homepage}/archive/rocm-${version}.tar.gz"
+checksum=01e2524e0f28ecd6f46c9720f279207de935d826b0172158792aa3ec86af9ca7
+nocross=yes
+
+post_install() {
+	vlicense LICENSE.txt
+}
+
+ROCm-CompilerSupport-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove "usr/lib/*.so"
+		vmove usr/lib/cmake
+	}
+}
diff --git a/srcpkgs/ROCm-CompilerSupport/update b/srcpkgs/ROCm-CompilerSupport/update
new file mode 100644
index 00000000000..86197bc3eea
--- /dev/null
+++ b/srcpkgs/ROCm-CompilerSupport/update
@@ -0,0 +1 @@
+pattern='rocm-\K[\d.]+'

From f38646d10e5ed2f4f8ab2e4211622a1fb3f42436 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Fri, 17 Apr 2020 12:11:25 -0400
Subject: [PATCH 06/10] New package: rocminfo-3.3.0

---
 srcpkgs/rocminfo/template | 22 ++++++++++++++++++++++
 srcpkgs/rocminfo/update   |  1 +
 2 files changed, 23 insertions(+)
 create mode 100644 srcpkgs/rocminfo/template
 create mode 100644 srcpkgs/rocminfo/update

diff --git a/srcpkgs/rocminfo/template b/srcpkgs/rocminfo/template
new file mode 100644
index 00000000000..7a075c7f7ac
--- /dev/null
+++ b/srcpkgs/rocminfo/template
@@ -0,0 +1,22 @@
+# Template file for 'rocminfo'
+pkgname=rocminfo
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="${pkgname}-rocm-${version}"
+build_style=cmake
+configure_args="-DROCM_DIR=/usr"
+hostmakedepends="cmake pkg-config"
+makedepends="ROCR-Runtime-devel"
+short_desc="Radeon Open Compute system information reporter"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute/rocminfo"
+distfiles="${homepage}/archive/rocm-${version}.tar.gz"
+checksum=e666f662c9e465aaabbbd0b109d87e017243cdf1a0898fabf5a90947bb3dbcd7
+nocross=yes
+python_version=3
+
+post_install() {
+	vlicense License.txt
+}
diff --git a/srcpkgs/rocminfo/update b/srcpkgs/rocminfo/update
new file mode 100644
index 00000000000..86197bc3eea
--- /dev/null
+++ b/srcpkgs/rocminfo/update
@@ -0,0 +1 @@
+pattern='rocm-\K[\d.]+'

From 8077a77473a9bb53903599ad21046db649f27c9a Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Sun, 19 Apr 2020 15:01:40 -0400
Subject: [PATCH 07/10] New package: rocm_bandwidth_test-3.3.0

---
 srcpkgs/rocm_bandwidth_test/template | 20 ++++++++++++++++++++
 srcpkgs/rocm_bandwidth_test/update   |  1 +
 2 files changed, 21 insertions(+)
 create mode 100644 srcpkgs/rocm_bandwidth_test/template
 create mode 100644 srcpkgs/rocm_bandwidth_test/update

diff --git a/srcpkgs/rocm_bandwidth_test/template b/srcpkgs/rocm_bandwidth_test/template
new file mode 100644
index 00000000000..6de7f2d6614
--- /dev/null
+++ b/srcpkgs/rocm_bandwidth_test/template
@@ -0,0 +1,20 @@
+# Template file for 'rocm_bandwidth_test'
+pkgname=rocm_bandwidth_test
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="${pkgname}-rocm-${version}"
+build_style=cmake
+hostmakedepends="cmake"
+makedepends="ROCR-Runtime-devel ROCT-Thunk-Interface-devel"
+short_desc="Radeon Open Compute bandwidth test"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute/rocm_bandwidth_test"
+distfiles="${homepage}/archive/rocm-${version}.tar.gz"
+checksum=f5f914073018619dc91662d5bf630903dfa4db9136d603591917fdfb3c9164ce
+nocross=yes
+
+post_install() {
+	vlicense LICENSE.txt
+}
diff --git a/srcpkgs/rocm_bandwidth_test/update b/srcpkgs/rocm_bandwidth_test/update
new file mode 100644
index 00000000000..86197bc3eea
--- /dev/null
+++ b/srcpkgs/rocm_bandwidth_test/update
@@ -0,0 +1 @@
+pattern='rocm-\K[\d.]+'

From bd99fca011e8b5fa05a727ca1fcdb85797397f8f Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Tue, 14 Apr 2020 10:25:54 -0400
Subject: [PATCH 08/10] New package: ROCm-OpenCL-Runtime-3.3.0

---
 common/shlibs                                 |   2 +
 srcpkgs/ROCm-OpenCL-Runtime-clinfo            |   1 +
 srcpkgs/ROCm-OpenCL-Runtime-devel             |   1 +
 .../files/libelf-musl.patch                   |  21 +++
 .../files/runtime-musl.patch                  |  11 ++
 .../ROCm-OpenCL-Runtime/patches/cmake.patch   | 126 ++++++++++++++++++
 srcpkgs/ROCm-OpenCL-Runtime/template          |  84 ++++++++++++
 srcpkgs/ROCm-OpenCL-Runtime/update            |   1 +
 8 files changed, 247 insertions(+)
 create mode 120000 srcpkgs/ROCm-OpenCL-Runtime-clinfo
 create mode 120000 srcpkgs/ROCm-OpenCL-Runtime-devel
 create mode 100644 srcpkgs/ROCm-OpenCL-Runtime/files/libelf-musl.patch
 create mode 100644 srcpkgs/ROCm-OpenCL-Runtime/files/runtime-musl.patch
 create mode 100644 srcpkgs/ROCm-OpenCL-Runtime/patches/cmake.patch
 create mode 100644 srcpkgs/ROCm-OpenCL-Runtime/template
 create mode 100644 srcpkgs/ROCm-OpenCL-Runtime/update

diff --git a/common/shlibs b/common/shlibs
index 4450bc95691..9c46574ca48 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3879,3 +3879,5 @@ libjcat.so.1 libjcat-0.1.2_1
 libhsakmt.so.1 ROCT-Thunk-Interface-3.3.0_1
 libhsa-runtime64.so.1 ROCR-Runtime-3.3.0_1
 libamd_comgr.so.1 ROCm-CompilerSupport-3.3.0_1
+libOpenCL-ROCm.so.1 ROCm-OpenCL-Runtime-3.3.0_1
+libamdocl64.so ROCm-OpenCL-Runtime-3.3.0_1
diff --git a/srcpkgs/ROCm-OpenCL-Runtime-clinfo b/srcpkgs/ROCm-OpenCL-Runtime-clinfo
new file mode 120000
index 00000000000..21f2041b8fb
--- /dev/null
+++ b/srcpkgs/ROCm-OpenCL-Runtime-clinfo
@@ -0,0 +1 @@
+ROCm-OpenCL-Runtime
\ No newline at end of file
diff --git a/srcpkgs/ROCm-OpenCL-Runtime-devel b/srcpkgs/ROCm-OpenCL-Runtime-devel
new file mode 120000
index 00000000000..21f2041b8fb
--- /dev/null
+++ b/srcpkgs/ROCm-OpenCL-Runtime-devel
@@ -0,0 +1 @@
+ROCm-OpenCL-Runtime
\ No newline at end of file
diff --git a/srcpkgs/ROCm-OpenCL-Runtime/files/libelf-musl.patch b/srcpkgs/ROCm-OpenCL-Runtime/files/libelf-musl.patch
new file mode 100644
index 00000000000..29469a9a351
--- /dev/null
+++ b/srcpkgs/ROCm-OpenCL-Runtime/files/libelf-musl.patch
@@ -0,0 +1,21 @@
+--- compiler/lib/loaders/elf/utils/libelf/_libelf.h	2020-04-28 15:50:53.243438174 -0400
++++ compiler/lib/loaders/elf/utils/libelf/_libelf.h	2020-04-28 15:51:54.293435415 -0400
+@@ -35,6 +35,7 @@
+ #include "_libelf_config.h"
+ 
+ #include "_elftc.h"
++#include <sys/cdefs.h>
+ 
+ /*
+  * Library-private data structures.
+--- compiler/lib/loaders/elf/utils/libelf/libelf.h	2020-04-28 15:50:53.244438174 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf.h	2020-04-28 15:52:12.375434593 -0400
+@@ -36,6 +36,8 @@
+ #define EM_HSAIL 0xAF5A
+ #endif
+ 
++#include <sys/cdefs.h>
++
+ /* Library private data structures */
+ typedef struct _Elf Elf;
+ typedef struct _Elf_Scn Elf_Scn;
diff --git a/srcpkgs/ROCm-OpenCL-Runtime/files/runtime-musl.patch b/srcpkgs/ROCm-OpenCL-Runtime/files/runtime-musl.patch
new file mode 100644
index 00000000000..ea18e90e09c
--- /dev/null
+++ b/srcpkgs/ROCm-OpenCL-Runtime/files/runtime-musl.patch
@@ -0,0 +1,11 @@
+--- runtime/os/os_posix.cpp.orig	2020-04-19 09:13:51.701982901 -0400
++++ runtime/os/os_posix.cpp	2020-04-19 09:14:04.156947422 -0400
+@@ -44,6 +44,8 @@
+ #include <algorithm>
+ #include <mutex>
+ 
++#include <libgen.h> // for basename
++
+ 
+ namespace amd {
+ 
diff --git a/srcpkgs/ROCm-OpenCL-Runtime/patches/cmake.patch b/srcpkgs/ROCm-OpenCL-Runtime/patches/cmake.patch
new file mode 100644
index 00000000000..2c96b99d45a
--- /dev/null
+++ b/srcpkgs/ROCm-OpenCL-Runtime/patches/cmake.patch
@@ -0,0 +1,126 @@
+--- OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/CMakeLists.txt	2019-09-10 11:53:28.000000000 -0400
++++ OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/CMakeLists.txt	2020-04-16 20:16:13.481180757 -0400
+@@ -73,11 +73,11 @@
+ 
+ set (OPENCL_ICD_LOADER_HEADERS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/inc CACHE PATH "Path to OpenCL Headers")
+ 
+-add_library (OpenCL ${OPENCL_ICD_LOADER_SOURCES})
+-set_target_properties (OpenCL PROPERTIES VERSION "1.2" SOVERSION "1")
++add_library (OpenCL-ROCm ${OPENCL_ICD_LOADER_SOURCES})
++set_target_properties (OpenCL-ROCm PROPERTIES VERSION "1.2" SOVERSION "1")
+ 
+ if (WIN32)
+-    target_link_libraries (OpenCL cfgmgr32.lib)
++    target_link_libraries (OpenCL-ROCm cfgmgr32.lib)
+ 
+     option (OPENCL_ICD_LOADER_REQUIRE_WDK "Build with D3DKMT support, which requires the Windows WDK." ON)
+     if (OPENCL_ICD_LOADER_REQUIRE_WDK)
+@@ -92,10 +92,10 @@
+             get_filename_component(WDK_DIRECTORY ${LATEST_D3DKMT_HEADER} DIRECTORY)
+             get_filename_component(WDK_DIRECTORY ${WDK_DIRECTORY} DIRECTORY)
+             message(STATUS "Found the Windows WDK in: ${WDK_DIRECTORY}")
+-            target_compile_definitions(OpenCL PRIVATE OPENCL_ICD_LOADER_REQUIRE_WDK)
+-            target_include_directories(OpenCL PRIVATE ${WDK_DIRECTORY}/um)
+-            target_include_directories(OpenCL PRIVATE ${WDK_DIRECTORY}/km)
+-            target_include_directories(OpenCL PRIVATE ${WDK_DIRECTORY}/shared)
++	    target_compile_definitions(OpenCL-ROCm PRIVATE OPENCL_ICD_LOADER_REQUIRE_WDK)
++	    target_include_directories(OpenCL-ROCm PRIVATE ${WDK_DIRECTORY}/um)
++	    target_include_directories(OpenCL-ROCm PRIVATE ${WDK_DIRECTORY}/km)
++	    target_include_directories(OpenCL-ROCm PRIVATE ${WDK_DIRECTORY}/shared)
+         else()
+             message(FATAL_ERROR "The Windows WDK was not found. Consider disabling OPENCL_ICD_LOADER_REQUIRE_WDK. Aborting.")
+         endif()
+@@ -113,25 +113,25 @@
+     endif()
+ else()
+     if (APPLE)
+-        target_link_libraries (OpenCL ${CMAKE_THREAD_LIBS_INIT})
++        target_link_libraries (OpenCL-ROCm ${CMAKE_THREAD_LIBS_INIT})
+     else ()
+-        set_target_properties (OpenCL PROPERTIES LINK_FLAGS "-Wl,--version-script -Wl,${CMAKE_CURRENT_SOURCE_DIR}/loader/linux/icd_exports.map")
+-        target_link_libraries (OpenCL ${CMAKE_THREAD_LIBS_INIT})
++        set_target_properties (OpenCL-ROCm PROPERTIES LINK_FLAGS "-Wl,--version-script -Wl,${CMAKE_CURRENT_SOURCE_DIR}/loader/linux/icd_exports.map")
++	target_link_libraries (OpenCL-ROCm ${CMAKE_THREAD_LIBS_INIT})
+     endif ()
+ endif ()
+ 
+ include_directories (${OPENCL_ICD_LOADER_HEADERS_DIR})
+ add_definitions (-DCL_TARGET_OPENCL_VERSION=220)
+ 
+-target_include_directories (OpenCL PRIVATE ${CMAKE_CURRENT_BINARY_DIR} loader)
+-target_link_libraries (OpenCL ${CMAKE_DL_LIBS})
++target_include_directories (OpenCL-ROCm PRIVATE ${CMAKE_CURRENT_BINARY_DIR} loader)
++target_link_libraries (OpenCL-ROCm ${CMAKE_DL_LIBS})
+ 
+ include (CTest)
+ if (BUILD_TESTING)
+     add_subdirectory (test)
+ endif()
+ 
+-install (TARGETS OpenCL
++install (TARGETS OpenCL-ROCm
+     RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+     ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
+     LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
+--- OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/test/loader_test/CMakeLists.txt	2019-09-10 11:53:28.000000000 -0400
++++ OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/test/loader_test/CMakeLists.txt	2020-04-16 20:16:56.647026589 -0400
+@@ -12,4 +12,4 @@
+     test_clgl.c
+     test_image_objects.c )
+ 
+-target_link_libraries (icd_loader_test OpenCL IcdLog)
++target_link_libraries (icd_loader_test OpenCL-ROCm IcdLog)
+--- ROCm-OpenCL-Runtime-roc-3.3.0/CMakeLists.txt	2020-04-28 07:29:51.864446603 -0400
++++ ROCm-OpenCL-Runtime-roc-3.3.0/CMakeLists.txt	2020-04-28 07:32:45.245793180 -0400
+@@ -101,30 +101,30 @@
+ rocm_setup_version( VERSION "2.0.0" )
+ 
+ # MAIN package
+-install(PROGRAMS $<TARGET_FILE:clinfo>
+-        DESTINATION bin/x86_64
++install(PROGRAMS $<TARGET_FILE:rocm-clinfo>
++        DESTINATION bin
+         COMPONENT MAIN)
+ install(PROGRAMS $<TARGET_FILE:amdocl64>
+-        DESTINATION lib/x86_64
++        DESTINATION lib
+         COMPONENT MAIN)
+-install(PROGRAMS $<TARGET_FILE:OpenCL>
+-        DESTINATION lib/x86_64
++install(PROGRAMS $<TARGET_FILE:OpenCL-ROCm>
++        DESTINATION lib
+         COMPONENT MAIN)
+-install(PROGRAMS $<TARGET_SONAME_FILE:OpenCL>
+-        DESTINATION lib/x86_64
++install(PROGRAMS $<TARGET_SONAME_FILE:OpenCL-ROCm>
++        DESTINATION lib
+         COMPONENT MAIN)
+ 
+ # DEV package
+ install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/api/opencl/khronos/headers/opencl2.2/CL"
+-        DESTINATION include
++	DESTINATION include/rocm
+         COMPONENT DEV
+         USE_SOURCE_PERMISSIONS
+         PATTERN cl_d3d10.h EXCLUDE
+         PATTERN cl_d3d11.h EXCLUDE
+         PATTERN cl_dx9_media_sharing.h EXCLUDE
+         PATTERN cl_egl.h EXCLUDE)
+-install(PROGRAMS $<TARGET_LINKER_FILE:OpenCL>
+-        DESTINATION lib/x86_64
++install(PROGRAMS $<TARGET_LINKER_FILE:OpenCL-ROCm>
++        DESTINATION lib
+         COMPONENT DEV)
+ 
+ # Generic CPACK variables
+--- ROCm-OpenCL-Runtime-roc-3.3.0/tools/clinfo/CMakeLists.txt	2020-04-28 07:29:51.882446535 -0400
++++ ROCm-OpenCL-Runtime-roc-3.3.0/tools/clinfo/CMakeLists.txt	2020-04-28 07:30:05.627394732 -0400
+@@ -6,6 +6,6 @@
+ 
+ add_definitions(-DHAVE_CL2_HPP)
+ 
+-add_executable(clinfo clinfo.cpp)
++add_executable(rocm-clinfo clinfo.cpp)
+ 
+-target_link_libraries(clinfo OpenCL)
++target_link_libraries(rocm-clinfo OpenCL-ROCm)
diff --git a/srcpkgs/ROCm-OpenCL-Runtime/template b/srcpkgs/ROCm-OpenCL-Runtime/template
new file mode 100644
index 00000000000..f6699a1d4c0
--- /dev/null
+++ b/srcpkgs/ROCm-OpenCL-Runtime/template
@@ -0,0 +1,84 @@
+# Template file for 'ROCm-OpenCL-Runtime'
+pkgname=ROCm-OpenCL-Runtime
+version=3.3.0
+revision=1
+_ocl_icd_name="OpenCL-ICD-Loader"
+_ocl_icd_ver="6c03f8b58fafd9dd693eaac826749a5cfad515f8"
+archs="x86_64*"
+create_wrksrc=yes
+build_wrksrc="${pkgname}-roc-${version}"
+build_style=cmake
+configure_args="-DUSE_COMGR_LIBRARY=yes"
+hostmakedepends="cmake pkg-config"
+makedepends="libglvnd-devel ROCm-CompilerSupport-devel
+	ROCT-Thunk-Interface-devel ROCR-Runtime-devel"
+depends="ROCm-CompilerSupport"
+short_desc="Radeon Open Compute OpenCL runtime"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="MIT"
+homepage="https://github.com/RadeonOpenCompute/ROCm-OpenCL-Runtime"
+_rocroot="https://github.com/RadeonOpenCompute"
+distfiles="${_rocroot}/ROCm-OpenCL-Runtime/archive/roc-${version}.tar.gz
+	${_rocroot}/rocm-cmake/archive/rocm-${version}.tar.gz
+	https://github.com/KhronosGroup/${_ocl_icd_name}/archive/${_ocl_icd_ver}.tar.gz"
+checksum="ac6999f1a491ab066286c2bd6adf50f08f831286f56e267879f9f7eced22f98e
+	76ed3ee8e56cf3246011cf7723c2abda539e1136e7e7f6909bfa45d268b8644f
+	c94d5bb6dc980c4d41d73e2b81663a19aabe494e923e2d0eec72a4c95b318438"
+nocross=yes
+
+if [ "$XBPS_LIBC" = "musl" ]; then
+	makedepends+=" musl-legacy-compat"
+fi
+
+post_patch() {
+	if [ "$XBPS_LIBC" = "musl" ]; then
+		# Remove dependence on glibc
+		patch -Np0 < ${FILESDIR}/libelf-musl.patch
+		patch -Np0 < ${FILESDIR}/runtime-musl.patch
+		vsed -e '/glibc_functions.cpp/d' -i api/opencl/amdocl/CMakeLists.txt
+	fi
+}
+
+pre_configure() {
+	# ROCm requires a very specific Khronos ICD loader version in the tree
+	# Keep the ICD loader config in /etc/OpenCL/rocm-vendors to avoid conflicts
+	_ocl_icd_dir="${_ocl_icd_name}-${_ocl_icd_ver}"
+	ln -sf "${wrksrc}/${_ocl_icd_dir}" api/opencl/khronos/icd
+	vsed -i "${wrksrc}/${_ocl_icd_dir}/loader/icd_platform.h" \
+		-e 's@/etc/OpenCL/vendors/@/etc/OpenCL/rocm-vendors/@g'
+
+	# CMake modules probably not useful anywhere but for this build
+	ln -sf "${wrksrc}/rocm-cmake-rocm-${version}/share/rocm/cmake"/*.cmake cmake
+
+	# Fix the dlopen macro to point to versioned libamd_comgr shared object
+	vsed -i 'runtime/device/comgrctx.cpp' \
+		-e 's/\blibamd_comgr\(32\)\?.so\b/&.1/g'
+}
+
+post_install() {
+	vlicense License
+
+	# Create descriptor to allow the ICD loader to find the driver
+	vmkdir etc/OpenCL/rocm-vendors
+	echo "libamdocl64.so" > "${DESTDIR}/etc/OpenCL/rocm-vendors/amdocl64.icd"
+	vmkdir etc/OpenCL/vendors
+	ln -s ../../OpenCL/rocm-vendors/amdocl64.icd \
+		${DESTDIR}/etc/OpenCL/vendors/rocm-amdocl64.icd
+}
+
+ROCm-OpenCL-Runtime-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/lib/libOpenCL-ROCm.so
+		vmove usr/include
+	}
+}
+
+ROCm-OpenCL-Runtime-clinfo_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - clinfo"
+	pkg_install() {
+		vmove usr/bin/rocm-clinfo
+	}
+}
diff --git a/srcpkgs/ROCm-OpenCL-Runtime/update b/srcpkgs/ROCm-OpenCL-Runtime/update
new file mode 100644
index 00000000000..8385f4d1215
--- /dev/null
+++ b/srcpkgs/ROCm-OpenCL-Runtime/update
@@ -0,0 +1 @@
+pattern='roc-\K[\d.]+'

From 1f26a78ac43895d537400bc3fb131774e1857c67 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Thu, 30 Apr 2020 13:11:12 -0400
Subject: [PATCH 09/10] New package: ROCR-Runtime-hsa-ext-3.3.0

---
 common/shlibs                         |  2 ++
 srcpkgs/ROCR-Runtime-hsa-ext-devel    |  1 +
 srcpkgs/ROCR-Runtime-hsa-ext/template | 43 +++++++++++++++++++++++++++
 srcpkgs/ROCR-Runtime-hsa-ext/update   |  2 ++
 4 files changed, 48 insertions(+)
 create mode 120000 srcpkgs/ROCR-Runtime-hsa-ext-devel
 create mode 100644 srcpkgs/ROCR-Runtime-hsa-ext/template
 create mode 100644 srcpkgs/ROCR-Runtime-hsa-ext/update

diff --git a/common/shlibs b/common/shlibs
index 9c46574ca48..a5de9a12acf 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3881,3 +3881,5 @@ libhsa-runtime64.so.1 ROCR-Runtime-3.3.0_1
 libamd_comgr.so.1 ROCm-CompilerSupport-3.3.0_1
 libOpenCL-ROCm.so.1 ROCm-OpenCL-Runtime-3.3.0_1
 libamdocl64.so ROCm-OpenCL-Runtime-3.3.0_1
+libhsa-ext-image64.so.1 ROCR-Runtime-hsa-ext-3.3.0_1
+libhsa-runtime-tools64.so.1 ROCR-Runtime-hsa-ext-3.3.0_1
diff --git a/srcpkgs/ROCR-Runtime-hsa-ext-devel b/srcpkgs/ROCR-Runtime-hsa-ext-devel
new file mode 120000
index 00000000000..6ee1b14911b
--- /dev/null
+++ b/srcpkgs/ROCR-Runtime-hsa-ext-devel
@@ -0,0 +1 @@
+ROCR-Runtime-hsa-ext
\ No newline at end of file
diff --git a/srcpkgs/ROCR-Runtime-hsa-ext/template b/srcpkgs/ROCR-Runtime-hsa-ext/template
new file mode 100644
index 00000000000..235ae92146b
--- /dev/null
+++ b/srcpkgs/ROCR-Runtime-hsa-ext/template
@@ -0,0 +1,43 @@
+# Template file for 'ROCR-Runtime-hsa-ext'
+pkgname=ROCR-Runtime-hsa-ext
+version=3.3.0
+revision=1
+archs="x86_64"
+hostmakedepends="tar"
+short_desc="Radeon Open Compute HSA runtime extensions"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute"
+_hsa_deb="hsa-ext-rocr-dev_1.1.30300.0-rocm-rel-3.3-19-23fc088b_amd64.deb"
+distfiles="https://repo.radeon.com/rocm/apt/debian/pool/main/h/hsa-ext-rocr-dev/$_hsa_deb"
+checksum=6b44e286b395d946b865ec1f3cc546356396785ac1fde591d07af02d0aa7c25d
+repository=nonfree
+restricted=yes
+
+do_extract() {
+	ar x "${XBPS_SRCDISTDIR}/${pkgname}-${version}/${_hsa_deb}"
+	tar xvf data.tar.gz
+}
+
+do_install() {
+	_rocm_includes="opt/rocm-${version}/hsa/include"
+
+	vmkdir usr
+	vcopy opt/rocm-${version}/hsa/lib usr
+	vcopy "$_rocm_includes" usr
+
+	# Extract license from one of the header files
+	awk 'BEGIN{HEADER=0} /\/\//{HEADER=1; print $0;} /^[^/]/{if(HEADER==1) exit;}' \
+		< "${_rocm_includes}/hsa/amd_hsa_tools_interfaces.h" \
+		| sed 's@^///*\( \|$\)@@' > LICENSE
+	vlicense LICENSE
+}
+
+ROCR-Runtime-hsa-ext-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove "usr/lib/*.so"
+	}
+}
diff --git a/srcpkgs/ROCR-Runtime-hsa-ext/update b/srcpkgs/ROCR-Runtime-hsa-ext/update
new file mode 100644
index 00000000000..84252d2e3b8
--- /dev/null
+++ b/srcpkgs/ROCR-Runtime-hsa-ext/update
@@ -0,0 +1,2 @@
+site='https://repo.radeon.com/rocm/apt/debian/pool/main/h/'
+pattern='hsa-ext-rocr-dev\K[\d.]+'

From 823436b12a88e238e9a557d3bb4e66c1603c74b5 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Tue, 28 Apr 2020 13:33:46 -0400
Subject: [PATCH 10/10] hashcat: add build option to link against ROCm [ci
 skip]

---
 srcpkgs/hashcat/files/rocm.patch     | 15 ++++++++++++++
 srcpkgs/hashcat/patches/tmpdir.patch | 30 ++++++++++++++++++++++++++++
 srcpkgs/hashcat/template             | 17 +++++++++++++---
 3 files changed, 59 insertions(+), 3 deletions(-)
 create mode 100644 srcpkgs/hashcat/files/rocm.patch
 create mode 100644 srcpkgs/hashcat/patches/tmpdir.patch

diff --git a/srcpkgs/hashcat/files/rocm.patch b/srcpkgs/hashcat/files/rocm.patch
new file mode 100644
index 00000000000..f1e899d30ee
--- /dev/null
+++ b/srcpkgs/hashcat/files/rocm.patch
@@ -0,0 +1,15 @@
+diff -ur a/src/opencl.c b/src/opencl.c
+--- a/src/opencl.c	2018-12-02 05:58:48.000000000 -0500
++++ b/src/opencl.c	2020-04-28 13:24:12.602415333 -0400
+@@ -492,9 +492,9 @@
+ 
+   if (ocl->lib == NULL) ocl->lib = hc_dlopen ("cygOpenCL-1.dll", RTLD_NOW);
+   #else
+-  ocl->lib = hc_dlopen ("libOpenCL.so", RTLD_NOW);
++  ocl->lib = hc_dlopen ("libOpenCL-ROCm.so.1", RTLD_NOW);
+ 
+-  if (ocl->lib == NULL) ocl->lib = hc_dlopen ("libOpenCL.so.1", RTLD_NOW);
++  if (ocl->lib == NULL) ocl->lib = hc_dlopen ("libOpenCL-ROCm.so", RTLD_NOW);
+   #endif
+ 
+   if (ocl->lib == NULL)
diff --git a/srcpkgs/hashcat/patches/tmpdir.patch b/srcpkgs/hashcat/patches/tmpdir.patch
new file mode 100644
index 00000000000..c6aab72db16
--- /dev/null
+++ b/srcpkgs/hashcat/patches/tmpdir.patch
@@ -0,0 +1,30 @@
+diff --git src/folder.c src/folder.c
+index 0c313f31..e54910b1 100644
+--- src/folder.c
++++ src/folder.c
+@@ -462,9 +462,24 @@ int folder_config_init (hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const char *ins
+   {
+     char *tmp;
+ 
+-    hc_asprintf (&tmp, "TMP=%s", cpath_real);
++    #if defined (_POSIX)
++    // Setting TMP may break POSIX temporary directory semantics
++    // Fix it by setting the POSIX-ly correct TMPDIR if it is not already set
++    if (getenv ("TMPDIR") == NULL) {
++      if (getenv("TMP") != NULL) {
++        // TMP was specified in the environment, promote it to TMPDIR
++        hc_asprintf (&tmp, "TMPDIR=%s", getenv("TMP"));
++        putenv (tmp);
++        hcfree (tmp);
++      } else {
++        putenv ("TMPDIR=/tmp");
++      }
++    }
++    #endif
+ 
++    hc_asprintf (&tmp, "TMP=%s", cpath_real);
+     putenv (tmp);
++    hcfree (tmp);
+   }
+ 
+   #if defined (_WIN)
diff --git a/srcpkgs/hashcat/template b/srcpkgs/hashcat/template
index e982f99cebf..3f19be5e41d 100644
--- a/srcpkgs/hashcat/template
+++ b/srcpkgs/hashcat/template
@@ -1,15 +1,16 @@
 # Template file for 'hashcat'
 pkgname=hashcat
 version=5.1.0
-revision=2
+revision=3
 build_style=gnu-makefile
 make_build_args="PREFIX=/usr
  USE_SYSTEM_OPENCL=1 USE_SYSTEM_XXHASH=1
- DEPS_OPENCL_PATH=${XBPS_CROSS_BASE}/usr/include
+ DEPS_OPENCL_PATH=${XBPS_CROSS_BASE}/usr/include$(vopt_if rocm /rocm)
  DEPS_XXHASH_PATH=${XBPS_CROSS_BASE}/usr/include"
 make_use_env=yes
 make_install_args="$make_build_args"
-makedepends="gmp-devel opencl2-headers xxHash-devel"
+makedepends="gmp-devel xxHash-devel
+ $(vopt_if rocm ROCm-OpenCL-Runtime-devel opencl2-headers)"
 checkdepends="perl"
 short_desc="Advanced CPU-based password recovery utility"
 maintainer="Duncaen <duncaen@voidlinux.org>"
@@ -19,6 +20,9 @@ changelog="https://raw.githubusercontent.com/hashcat/hashcat/master/docs/changes
 distfiles="https://hashcat.net/files/hashcat-${version}.tar.gz"
 checksum=283beaa68e1eab41de080a58bb92349c8e47a2bb1b93d10f36ea30f418f1e338
 
+build_options="rocm"
+desc_option_rocm="Use ROCm OpenCL runtime"
+
 if [ "$XBPS_TARGET_ENDIAN" = "be" ]; then
 	broken="Not supported on big endian"
 fi
@@ -26,6 +30,13 @@ fi
 post_extract() {
 	sed '/^CC/d' -i src/Makefile
 }
+
+post_patch() {
+	if [ "$build_option_rocm" ]; then
+		patch -Np1 < ${FILESDIR}/rocm.patch
+	fi
+}
+
 post_install() {
 	rm -f ${DESTDIR}/usr/share/docs/hashcat/license.txt
 	vlicense docs/license.txt

^ permalink raw reply	[flat|nested] 61+ messages in thread

* Re: New packages: ROCm core and OpenCL
  2020-04-19 13:34 [PR PATCH] New packages: ROCm core and OpenCL ahesford
                   ` (29 preceding siblings ...)
  2020-05-08 14:40 ` ahesford
@ 2020-05-11 18:02 ` ericonr
  2020-05-11 18:07 ` ahesford
                   ` (28 subsequent siblings)
  59 siblings, 0 replies; 61+ messages in thread
From: ericonr @ 2020-05-11 18:02 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 180 bytes --]

New comment by ericonr on void-packages repository

https://github.com/void-linux/void-packages/pull/21153#issuecomment-626861816

Comment:
Does this help close #8792 and #13568 ?

^ permalink raw reply	[flat|nested] 61+ messages in thread

* Re: New packages: ROCm core and OpenCL
  2020-04-19 13:34 [PR PATCH] New packages: ROCm core and OpenCL ahesford
                   ` (30 preceding siblings ...)
  2020-05-11 18:02 ` ericonr
@ 2020-05-11 18:07 ` ahesford
  2020-05-11 18:07 ` ahesford
                   ` (27 subsequent siblings)
  59 siblings, 0 replies; 61+ messages in thread
From: ahesford @ 2020-05-11 18:07 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 290 bytes --]

New comment by ahesford on void-packages repository

https://github.com/void-linux/void-packages/pull/21153#issuecomment-626864296

Comment:
This should be seen as superseding #8792 #13568 since it provides a more featureful and liberally licensed alternative that we can properly support.

^ permalink raw reply	[flat|nested] 61+ messages in thread

* Re: New packages: ROCm core and OpenCL
  2020-04-19 13:34 [PR PATCH] New packages: ROCm core and OpenCL ahesford
                   ` (31 preceding siblings ...)
  2020-05-11 18:07 ` ahesford
@ 2020-05-11 18:07 ` ahesford
  2020-05-11 18:52 ` [PR PATCH] [Updated] " ahesford
                   ` (26 subsequent siblings)
  59 siblings, 0 replies; 61+ messages in thread
From: ahesford @ 2020-05-11 18:07 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 294 bytes --]

New comment by ahesford on void-packages repository

https://github.com/void-linux/void-packages/pull/21153#issuecomment-626864296

Comment:
This should be seen as superseding #8792 and #13568 since it provides a more featureful and liberally licensed alternative that we can properly support.

^ permalink raw reply	[flat|nested] 61+ messages in thread

* Re: [PR PATCH] [Updated] New packages: ROCm core and OpenCL
  2020-04-19 13:34 [PR PATCH] New packages: ROCm core and OpenCL ahesford
                   ` (32 preceding siblings ...)
  2020-05-11 18:07 ` ahesford
@ 2020-05-11 18:52 ` ahesford
  2020-05-11 20:03 ` ahesford
                   ` (25 subsequent siblings)
  59 siblings, 0 replies; 61+ messages in thread
From: ahesford @ 2020-05-11 18:52 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 3893 bytes --]

There is an updated pull request by ahesford against master on the void-packages repository

https://github.com/ahesford/void-packages rocm
https://github.com/void-linux/void-packages/pull/21153

New packages: ROCm core and OpenCL
This PR includes several packages designed to bring the OpenCL portion of the AMD ROCm ecosystem to Void. It addresses Issue #19507. There are many other packages that AMD provides for GPGPU computing, but these can be added piecemeal as users demand.

The packages are currently only for `x86_64*`. While at least some of the packages will compile on other 64-bit architectures, I have no hardware to test. They are certainly not suitable for 32-bit architectures; some internal data structures rely on `uint64_t` values that are cast to pointers. At a
minimum, a thorough audit would be necessary to ensure that these casts are safe (e.g., that the values stored were only ever upcast from 32-bit pointers). More extensive work may be necessary to support 32-bit architectures, probably without significant benefit.

The packages successfully identify a Radeon RX 580 on an `x86_64` installation using both `clinfo` and `rocminfo` as provided. Furthermore, a version of `pyopencl` linked against these ROCm packages successfully runs a simple program that validates arithmetic on GPU-bound arrays.

There are caveats with this set of packages, almost all of which revolve around the incompatibilities between the Void-provided `ocl-icd` and the [Khronos OpenCL ICD loader](https://github.com/KhronosGroup/OpenCL-ID-Loader) required by (and built into) `rocm-opencl-runtime`.
1. All packages install into `/opt/rocm`. This keeps the environment closer to that officially sanctioned by AMD and helps avoid conflicts between other packages and those provided here. (For example, `clinfo` and the ICD loader itself.) Eventually, we may be able to move the files into `/usr`.
2. The Khronos OpenCL ICD loader built into `rocm-opencl-runtime` is an outdated, pre-release commit. If AMD can update its sources to use the release version of that loader (which has a backward-incompatible API change), we may be able to make ROCm compatible with `ocl-icd` or replace `ocl-icd` with the official Khronos loader.
3. In the meantime, to avoid `shlibs` conflicts, the OpenCL ICD loader is installed as `/opt/rocm/lib/libOpenCL-ROCm.so` (and an appropriately versioned shared library), which means that programs wishing to use the ROCm OpenCL must explicitly link against this library instead of the generic `libOpenCL.so`.
4. I do **not** recommend making any Void packages link against this specific library, because it will make those packages ROCm-only. For the time being, ROCm is intended for end-users to specifically link against. Linking Void packages against ROCm would requires the ICD loader used by ROCm be compatible with `ocl-icd`, or `ocl-icd` be replaced by the Khronos loader. However, because the Khronos loader changed its API for the release version, such a change is not yet appropriate.

Hopefully, if AMD updates its dependence on the Khronos ICD loader, we can resolve some of these caveats in the future and make ROCm a more natural Void component. For now, these packages are useful for those who need an AMD OpenCL solution and would rather custom-link software against the AMD ICD loader than hack the `amdgpu-pro` driver into an ICD compatible with `ocl-icd`.

Some patches were made to relocate some files in `/opt/rocm` and make everyting build on x86_64-musl`. Where appropriate, these patches will be pushed upstream to clean up the distribution and packaging.

Update: I pushed some new commits to update license information that triggerd an `xlint` failure. I've also disabled CI builds because they will time out on `rocm-llvm`.

A patch file from https://github.com/void-linux/void-packages/pull/21153.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-rocm-21153.patch --]
[-- Type: text/x-diff, Size: 39530 bytes --]

From 8597ad3e9027847ef7c6190eb69ed06975cdaad4 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Mon, 13 Apr 2020 13:08:09 -0400
Subject: [PATCH 01/10] New package: ROCT-Thunk-Interface-3.3.0

---
 common/shlibs                                 |  1 +
 srcpkgs/ROCT-Thunk-Interface-devel            |  1 +
 .../patches/cmake-dev-libdir.patch            | 10 ++++++
 .../ROCT-Thunk-Interface/patches/musl.patch   | 29 ++++++++++++++++
 srcpkgs/ROCT-Thunk-Interface/template         | 33 +++++++++++++++++++
 srcpkgs/ROCT-Thunk-Interface/update           |  1 +
 6 files changed, 75 insertions(+)
 create mode 120000 srcpkgs/ROCT-Thunk-Interface-devel
 create mode 100644 srcpkgs/ROCT-Thunk-Interface/patches/cmake-dev-libdir.patch
 create mode 100644 srcpkgs/ROCT-Thunk-Interface/patches/musl.patch
 create mode 100644 srcpkgs/ROCT-Thunk-Interface/template
 create mode 100644 srcpkgs/ROCT-Thunk-Interface/update

diff --git a/common/shlibs b/common/shlibs
index 7693053e46b..118f896e187 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3876,3 +3876,4 @@ libhidrd_opt.so.0 hidrd-0.2.0_1
 libhidrd_strm.so.0 hidrd-0.2.0_1
 libhidrd_fmt.so.0 hidrd-0.2.0_1
 libjcat.so.1 libjcat-0.1.2_1
+libhsakmt.so.1 ROCT-Thunk-Interface-3.3.0_1
diff --git a/srcpkgs/ROCT-Thunk-Interface-devel b/srcpkgs/ROCT-Thunk-Interface-devel
new file mode 120000
index 00000000000..7e43c209e3d
--- /dev/null
+++ b/srcpkgs/ROCT-Thunk-Interface-devel
@@ -0,0 +1 @@
+ROCT-Thunk-Interface
\ No newline at end of file
diff --git a/srcpkgs/ROCT-Thunk-Interface/patches/cmake-dev-libdir.patch b/srcpkgs/ROCT-Thunk-Interface/patches/cmake-dev-libdir.patch
new file mode 100644
index 00000000000..98c7f1e459c
--- /dev/null
+++ b/srcpkgs/ROCT-Thunk-Interface/patches/cmake-dev-libdir.patch
@@ -0,0 +1,10 @@
+--- CMakeLists.txt.old	2020-04-18 19:45:17.306081135 -0400
++++ CMakeLists.txt	2020-04-18 19:46:51.300753636 -0400
+@@ -146,6 +146,7 @@
+     COMMAND ${CMAKE_COMMAND}
+         -DSOURCE_DIR="${SOURCE_DIR}"
+         -DCMAKE_INSTALL_PREFIX="${CMAKE_INSTALL_PREFIX}"
++        -DCMAKE_INSTALL_LIBDIR="${CMAKE_INSTALL_LIBDIR}"
+         -DCPACK_RPM_PACKAGE_REQUIRES="hsakmt-roct"
+         -DCPACK_PACKAGING_INSTALL_PREFIX="${CPACK_PACKAGING_INSTALL_PREFIX}"
+         -DVERSION="${BUILD_VERSION_STRING}"
diff --git a/srcpkgs/ROCT-Thunk-Interface/patches/musl.patch b/srcpkgs/ROCT-Thunk-Interface/patches/musl.patch
new file mode 100644
index 00000000000..aeea9832411
--- /dev/null
+++ b/srcpkgs/ROCT-Thunk-Interface/patches/musl.patch
@@ -0,0 +1,29 @@
+diff -r -u old/src/libhsakmt.h new/src/libhsakmt.h
+--- src/libhsakmt.h	2020-03-04 15:00:47.000000000 -0500
++++ src/libhsakmt.h	2020-04-13 12:58:30.444865992 -0400
+@@ -54,6 +54,10 @@
+ #define CHECK_KFD_OPEN() \
+ 	do { if (kfd_open_count == 0 || hsakmt_forked) return HSAKMT_STATUS_KERNEL_IO_CHANNEL_NOT_OPENED; } while (0)
+ 
++/*On some platforms, a PAGE_SIZE macro eclipses the extern variable*/
++#ifdef PAGE_SIZE
++#undef PAGE_SIZE
++#endif
+ extern int PAGE_SIZE;
+ extern int PAGE_SHIFT;
+ 
+diff -r -u old/src/topology.c new/src/topology.c
+--- src/topology.c	2020-03-04 15:00:47.000000000 -0500
++++ src/topology.c	2020-04-13 13:01:31.209870701 -0400
+@@ -38,6 +38,11 @@
+ #include "libhsakmt.h"
+ #include "fmm.h"
+ 
++/*Needed on MUSL*/
++#ifndef MAXNAMLEN
++#define MAXNAMLEN PATH_MAX
++#endif
++
+ /* Number of memory banks added by thunk on top of topology
+  * This only includes static heaps like LDS, scratch and SVM,
+  * not for MMIO_REMAP heap. MMIO_REMAP memory bank is reported
diff --git a/srcpkgs/ROCT-Thunk-Interface/template b/srcpkgs/ROCT-Thunk-Interface/template
new file mode 100644
index 00000000000..8c680b2af29
--- /dev/null
+++ b/srcpkgs/ROCT-Thunk-Interface/template
@@ -0,0 +1,33 @@
+# Template file for 'ROCT-Thunk-Interface'
+pkgname=ROCT-Thunk-Interface
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="${pkgname}-roc-${version}"
+build_style=cmake
+make_build_target="all build-dev"
+make_install_target="install install-dev"
+hostmakedepends="cmake pkg-config"
+makedepends="pciutils-devel libnuma-devel"
+short_desc="Radeon Open Compute thunk interface"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="MIT"
+homepage="https://github.com/RadeonOpenCompute/ROCT-Thunk-Interface"
+distfiles="${homepage}/archive/roc-${version}.tar.gz"
+checksum=2cabe9d2cfa72031c05d11290837c476182e72d8dec2049298f691143fdd212b
+nocross=yes
+
+post_install() {
+	vlicense LICENSE.md
+}
+
+ROCT-Thunk-Interface-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove "usr/lib/*.so"
+		vmove usr/share/pkgconfig
+		vmove usr/lib/cmake
+	}
+}
diff --git a/srcpkgs/ROCT-Thunk-Interface/update b/srcpkgs/ROCT-Thunk-Interface/update
new file mode 100644
index 00000000000..8385f4d1215
--- /dev/null
+++ b/srcpkgs/ROCT-Thunk-Interface/update
@@ -0,0 +1 @@
+pattern='roc-\K[\d.]+'

From 1981ee18dbf52d1294e402080547f22397ed8458 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Mon, 13 Apr 2020 15:27:27 -0400
Subject: [PATCH 02/10] New package: ROCR-Runtime-3.3.0

---
 common/shlibs                            |  1 +
 srcpkgs/ROCR-Runtime-devel               |  1 +
 srcpkgs/ROCR-Runtime/patches/cmake.patch | 27 +++++++++++++++++++++
 srcpkgs/ROCR-Runtime/template            | 30 ++++++++++++++++++++++++
 srcpkgs/ROCR-Runtime/update              |  1 +
 5 files changed, 60 insertions(+)
 create mode 120000 srcpkgs/ROCR-Runtime-devel
 create mode 100644 srcpkgs/ROCR-Runtime/patches/cmake.patch
 create mode 100644 srcpkgs/ROCR-Runtime/template
 create mode 100644 srcpkgs/ROCR-Runtime/update

diff --git a/common/shlibs b/common/shlibs
index 118f896e187..46a83863bcd 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3877,3 +3877,4 @@ libhidrd_strm.so.0 hidrd-0.2.0_1
 libhidrd_fmt.so.0 hidrd-0.2.0_1
 libjcat.so.1 libjcat-0.1.2_1
 libhsakmt.so.1 ROCT-Thunk-Interface-3.3.0_1
+libhsa-runtime64.so.1 ROCR-Runtime-3.3.0_1
diff --git a/srcpkgs/ROCR-Runtime-devel b/srcpkgs/ROCR-Runtime-devel
new file mode 120000
index 00000000000..a733fb9fbab
--- /dev/null
+++ b/srcpkgs/ROCR-Runtime-devel
@@ -0,0 +1 @@
+ROCR-Runtime
\ No newline at end of file
diff --git a/srcpkgs/ROCR-Runtime/patches/cmake.patch b/srcpkgs/ROCR-Runtime/patches/cmake.patch
new file mode 100644
index 00000000000..93b74cd2297
--- /dev/null
+++ b/srcpkgs/ROCR-Runtime/patches/cmake.patch
@@ -0,0 +1,27 @@
+--- src/CMakeLists.txt.old	2020-04-18 20:01:48.549636995 -0400
++++ src/CMakeLists.txt	2020-04-18 20:04:00.177179781 -0400
+@@ -108,8 +108,8 @@
+ ## ROCr build internal versioning
+ add_definitions ( -DROCR_BUILD_ID=${PACKAGE_VERSION_STRING} )
+ 
+-## Set RUNPATH - ../../lib covers use of the legacy symlink in /hsa/lib/
+-set(CMAKE_INSTALL_RPATH "$ORIGIN;$ORIGIN/../../lib;$ORIGIN/../../lib64;$ORIGIN/../lib64")
++## Set RUNPATH
++set(CMAKE_INSTALL_RPATH "$ORIGIN;$ORIGIN/../lib")
+ 
+ ## ------------------------- Linux Compiler and Linker options -------------------------
+ set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -fexceptions -fno-rtti -fvisibility=hidden -Wno-error=sign-compare -Wno-sign-compare -Wno-write-strings -Wno-conversion-null -fno-math-errno -fno-threadsafe-statics -fmerge-all-constants -fms-extensions -Wno-error=comment -Wno-comment -Wno-error=pointer-arith -Wno-pointer-arith -Wno-error=unused-variable -Wno-error=unused-function" )
+@@ -185,11 +185,8 @@
+ add_custom_target ( hsa_lib_link2 ALL WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMAND ${CMAKE_COMMAND} -E create_symlink ../hsa/lib/${CORE_RUNTIME_LIBRARY}.so.${SO_MAJOR} ${CORE_RUNTIME_LIBRARY}-link.so.${SO_MAJOR} )
+ 
+ ## Set install information
+-install ( TARGETS ${CORE_RUNTIME_TARGET} LIBRARY DESTINATION hsa/lib )
+-install ( DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/inc/ DESTINATION hsa/include/hsa )
+-install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/hsa_include_link DESTINATION include PERMISSIONS OWNER_WRITE OWNER_READ RENAME hsa )
+-install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/${CORE_RUNTIME_LIBRARY}-link.so DESTINATION lib PERMISSIONS OWNER_WRITE OWNER_READ RENAME ${CORE_RUNTIME_LIBRARY}.so )
+-install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/${CORE_RUNTIME_LIBRARY}-link.so.${SO_MAJOR} DESTINATION lib PERMISSIONS OWNER_WRITE OWNER_READ RENAME ${CORE_RUNTIME_LIBRARY}.so.${SO_MAJOR} )
++install ( TARGETS ${CORE_RUNTIME_TARGET} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} )
++install ( DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/inc/ DESTINATION include/hsa )
+ 
+ ## Packaging directives
+ set ( CPACK_GENERATOR "DEB;RPM" CACHE STRING "Package types to build")
diff --git a/srcpkgs/ROCR-Runtime/template b/srcpkgs/ROCR-Runtime/template
new file mode 100644
index 00000000000..95b7e701afb
--- /dev/null
+++ b/srcpkgs/ROCR-Runtime/template
@@ -0,0 +1,30 @@
+# Template file for 'ROCR-Runtime'
+pkgname=ROCR-Runtime
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="${pkgname}-rocm-${version}"
+build_wrksrc="src"
+build_style=cmake
+hostmakedepends="cmake pkg-config"
+makedepends="ROCT-Thunk-Interface-devel elfutils-devel"
+short_desc="Radeon Open Compute HSA runtime"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute/ROCR-Runtime"
+distfiles="${homepage}/archive/rocm-${version}.tar.gz"
+checksum=fa2d2d1f8a61d8a6952d377cf288d78c61776c3c2a666f163cafc3aa19ab0b61
+nocross=yes
+
+post_install() {
+	vlicense ../LICENSE.txt
+}
+
+ROCR-Runtime-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove "usr/lib/*.so"
+	}
+}
diff --git a/srcpkgs/ROCR-Runtime/update b/srcpkgs/ROCR-Runtime/update
new file mode 100644
index 00000000000..86197bc3eea
--- /dev/null
+++ b/srcpkgs/ROCR-Runtime/update
@@ -0,0 +1 @@
+pattern='rocm-\K[\d.]+'

From 0d0627adca7950c6cc9e0989fb6089c8b51f243f Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Mon, 13 Apr 2020 18:07:34 -0400
Subject: [PATCH 03/10] New package: ROCm-llvm-3.3.0

---
 srcpkgs/ROCm-llvm/template | 26 ++++++++++++++++++++++++++
 srcpkgs/ROCm-llvm/update   |  1 +
 2 files changed, 27 insertions(+)
 create mode 100644 srcpkgs/ROCm-llvm/template
 create mode 100644 srcpkgs/ROCm-llvm/update

diff --git a/srcpkgs/ROCm-llvm/template b/srcpkgs/ROCm-llvm/template
new file mode 100644
index 00000000000..4c3095b21f4
--- /dev/null
+++ b/srcpkgs/ROCm-llvm/template
@@ -0,0 +1,26 @@
+# Template file for 'ROCm-llvm'
+pkgname=ROCm-llvm
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="llvm-project-rocm-ocl-${version}"
+build_wrksrc=llvm
+build_style=cmake
+configure_args="-DCMAKE_INSTALL_PREFIX:PATH=/usr/lib/rocm-llvm
+	-DLLVM_ENABLE_PROJECTS='llvm;clang;lld' -DLLVM_TARGETS_TO_BUILD='AMDGPU'
+	-DLLVM_BUILD_DOCS=NO -DLLVM_ENABLE_OCAMLDOC=OFF
+	-DLLVM_ENABLE_SPHINX=NO -DLLVM_ENABLE_DOXYGEN=OFF
+	-DLLVM_INSTALL_UTILS=ON -DLLVM_VERSION_SUFFIX=roc -DOCAMLFIND=NO"
+hostmakedepends="cmake pkg-config python3"
+short_desc="Radeon Open Compute LLVM toolchain"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="Apache-2.0, NCSA, custom:LLVM-Exceptions"
+homepage="https://github.com/RadeonOpenCompute/llvm-project"
+distfiles="${homepage}/archive/rocm-ocl-${version}.tar.gz"
+checksum=a2bef7042e8e2f2cd8548cb246b88322e1c77188839983dcac8312d56f544dc8
+python_version=3
+nocross=yes
+
+post_install() {
+	vlicense LICENSE.TXT
+}
diff --git a/srcpkgs/ROCm-llvm/update b/srcpkgs/ROCm-llvm/update
new file mode 100644
index 00000000000..6a73667d3c1
--- /dev/null
+++ b/srcpkgs/ROCm-llvm/update
@@ -0,0 +1 @@
+pattern='rocm-ocl-\K[\d.]+'

From aa604d0df608b25b9a50cf64e84d4f9ea6c4df7a Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Tue, 14 Apr 2020 10:25:31 -0400
Subject: [PATCH 04/10] New package: ROCm-Device-Libs-3.3.0

---
 srcpkgs/ROCm-Device-Libs/template | 37 +++++++++++++++++++++++++++++++
 srcpkgs/ROCm-Device-Libs/update   |  1 +
 2 files changed, 38 insertions(+)
 create mode 100644 srcpkgs/ROCm-Device-Libs/template
 create mode 100644 srcpkgs/ROCm-Device-Libs/update

diff --git a/srcpkgs/ROCm-Device-Libs/template b/srcpkgs/ROCm-Device-Libs/template
new file mode 100644
index 00000000000..8086cd86450
--- /dev/null
+++ b/srcpkgs/ROCm-Device-Libs/template
@@ -0,0 +1,37 @@
+# Template file for 'ROCm-Device-Libs'
+pkgname=ROCm-Device-Libs
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="${pkgname}-rocm-ocl-${version}"
+build_style=cmake
+configure_args="-DLLVM_DIR:PATH=/usr/lib/rocm-llvm
+	-DCMAKE_INSTALL_LIBDIR:PATH=lib/rocm-device-libs"
+hostmakedepends="cmake ROCm-llvm"
+short_desc="Radeon Open Compute device libraries"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute/ROCm-Device-Libs"
+distfiles="${homepage}/archive/rocm-ocl-${version}.tar.gz"
+checksum=706b08230790e08ca6a7a2fb7687d6131fd39a562148340e00fa37a6c06769c5
+nocross=yes
+
+pre_configure() {
+	# Put bytecodes in a lib/ subdirectory
+	vsed -i Packages.cmake -e 's@/lib/@/${CMAKE_INSTALL_LIBDIR}/@'
+	vsed -i OCL.cmake -e 's@DESTINATION lib$@DESTINATION ${CMAKE_INSTALL_LIBDIR}@'
+
+	# Build the prepare-builtins executable with native compiler
+	mkdir -p utils/build
+	cd utils/build
+	_prepare_builtins="$PWD/prepare-builtins/prepare-builtins"
+	cmake ${configure_args} ..
+	make ${makejobs}
+
+	# Add path to prepare-builtins for cmake
+	configure_args+=" -DPREPARE_BUILTINS='${_prepare_builtins}'"
+}
+
+post_install() {
+	vlicense LICENSE
+}
diff --git a/srcpkgs/ROCm-Device-Libs/update b/srcpkgs/ROCm-Device-Libs/update
new file mode 100644
index 00000000000..6a73667d3c1
--- /dev/null
+++ b/srcpkgs/ROCm-Device-Libs/update
@@ -0,0 +1 @@
+pattern='rocm-ocl-\K[\d.]+'

From 12705d6d4d6d4c500ab7867ad5f79b2d63301a34 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Mon, 13 Apr 2020 18:30:00 -0400
Subject: [PATCH 05/10] New package: ROCm-CompilerSupport-3.3.0

---
 common/shlibs                         |  1 +
 srcpkgs/ROCm-CompilerSupport-devel    |  1 +
 srcpkgs/ROCm-CompilerSupport/template | 32 +++++++++++++++++++++++++++
 srcpkgs/ROCm-CompilerSupport/update   |  1 +
 4 files changed, 35 insertions(+)
 create mode 120000 srcpkgs/ROCm-CompilerSupport-devel
 create mode 100644 srcpkgs/ROCm-CompilerSupport/template
 create mode 100644 srcpkgs/ROCm-CompilerSupport/update

diff --git a/common/shlibs b/common/shlibs
index 46a83863bcd..42748d6c8bb 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3878,3 +3878,4 @@ libhidrd_fmt.so.0 hidrd-0.2.0_1
 libjcat.so.1 libjcat-0.1.2_1
 libhsakmt.so.1 ROCT-Thunk-Interface-3.3.0_1
 libhsa-runtime64.so.1 ROCR-Runtime-3.3.0_1
+libamd_comgr.so.1 ROCm-CompilerSupport-3.3.0_1
diff --git a/srcpkgs/ROCm-CompilerSupport-devel b/srcpkgs/ROCm-CompilerSupport-devel
new file mode 120000
index 00000000000..877aeafeeae
--- /dev/null
+++ b/srcpkgs/ROCm-CompilerSupport-devel
@@ -0,0 +1 @@
+ROCm-CompilerSupport
\ No newline at end of file
diff --git a/srcpkgs/ROCm-CompilerSupport/template b/srcpkgs/ROCm-CompilerSupport/template
new file mode 100644
index 00000000000..df56f7a3837
--- /dev/null
+++ b/srcpkgs/ROCm-CompilerSupport/template
@@ -0,0 +1,32 @@
+# Template file for 'ROCm-CompilerSupport'
+pkgname=ROCm-CompilerSupport
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="${pkgname}-rocm-${version}"
+build_wrksrc="lib/comgr"
+build_style=cmake
+configure_args="-DClang_DIR:PATH=/usr/lib/rocm-llvm/lib/cmake/clang"
+hostmakedepends="cmake pkg-config ROCm-llvm"
+makedepends="ROCm-Device-Libs"
+short_desc="Radeon Open Compute compiler support"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="BSD-3-Clause"
+homepage="https://github.com/RadeonOpenCompute/ROCm-CompilerSupport"
+distfiles="${homepage}/archive/rocm-${version}.tar.gz"
+checksum=01e2524e0f28ecd6f46c9720f279207de935d826b0172158792aa3ec86af9ca7
+nocross=yes
+
+post_install() {
+	vlicense LICENSE.txt
+}
+
+ROCm-CompilerSupport-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove "usr/lib/*.so"
+		vmove usr/lib/cmake
+	}
+}
diff --git a/srcpkgs/ROCm-CompilerSupport/update b/srcpkgs/ROCm-CompilerSupport/update
new file mode 100644
index 00000000000..86197bc3eea
--- /dev/null
+++ b/srcpkgs/ROCm-CompilerSupport/update
@@ -0,0 +1 @@
+pattern='rocm-\K[\d.]+'

From f3408c285cac4e5b99114688f107d80fef8cc00c Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Fri, 17 Apr 2020 12:11:25 -0400
Subject: [PATCH 06/10] New package: rocminfo-3.3.0

---
 srcpkgs/rocminfo/template | 22 ++++++++++++++++++++++
 srcpkgs/rocminfo/update   |  1 +
 2 files changed, 23 insertions(+)
 create mode 100644 srcpkgs/rocminfo/template
 create mode 100644 srcpkgs/rocminfo/update

diff --git a/srcpkgs/rocminfo/template b/srcpkgs/rocminfo/template
new file mode 100644
index 00000000000..7a075c7f7ac
--- /dev/null
+++ b/srcpkgs/rocminfo/template
@@ -0,0 +1,22 @@
+# Template file for 'rocminfo'
+pkgname=rocminfo
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="${pkgname}-rocm-${version}"
+build_style=cmake
+configure_args="-DROCM_DIR=/usr"
+hostmakedepends="cmake pkg-config"
+makedepends="ROCR-Runtime-devel"
+short_desc="Radeon Open Compute system information reporter"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute/rocminfo"
+distfiles="${homepage}/archive/rocm-${version}.tar.gz"
+checksum=e666f662c9e465aaabbbd0b109d87e017243cdf1a0898fabf5a90947bb3dbcd7
+nocross=yes
+python_version=3
+
+post_install() {
+	vlicense License.txt
+}
diff --git a/srcpkgs/rocminfo/update b/srcpkgs/rocminfo/update
new file mode 100644
index 00000000000..86197bc3eea
--- /dev/null
+++ b/srcpkgs/rocminfo/update
@@ -0,0 +1 @@
+pattern='rocm-\K[\d.]+'

From 9f45c89a0e4a841db58eec8dd5896cda1afccf9c Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Sun, 19 Apr 2020 15:01:40 -0400
Subject: [PATCH 07/10] New package: rocm_bandwidth_test-3.3.0

---
 srcpkgs/rocm_bandwidth_test/template | 20 ++++++++++++++++++++
 srcpkgs/rocm_bandwidth_test/update   |  1 +
 2 files changed, 21 insertions(+)
 create mode 100644 srcpkgs/rocm_bandwidth_test/template
 create mode 100644 srcpkgs/rocm_bandwidth_test/update

diff --git a/srcpkgs/rocm_bandwidth_test/template b/srcpkgs/rocm_bandwidth_test/template
new file mode 100644
index 00000000000..6de7f2d6614
--- /dev/null
+++ b/srcpkgs/rocm_bandwidth_test/template
@@ -0,0 +1,20 @@
+# Template file for 'rocm_bandwidth_test'
+pkgname=rocm_bandwidth_test
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="${pkgname}-rocm-${version}"
+build_style=cmake
+hostmakedepends="cmake"
+makedepends="ROCR-Runtime-devel ROCT-Thunk-Interface-devel"
+short_desc="Radeon Open Compute bandwidth test"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute/rocm_bandwidth_test"
+distfiles="${homepage}/archive/rocm-${version}.tar.gz"
+checksum=f5f914073018619dc91662d5bf630903dfa4db9136d603591917fdfb3c9164ce
+nocross=yes
+
+post_install() {
+	vlicense LICENSE.txt
+}
diff --git a/srcpkgs/rocm_bandwidth_test/update b/srcpkgs/rocm_bandwidth_test/update
new file mode 100644
index 00000000000..86197bc3eea
--- /dev/null
+++ b/srcpkgs/rocm_bandwidth_test/update
@@ -0,0 +1 @@
+pattern='rocm-\K[\d.]+'

From b298a879caf7a733ff4f491dc6175a17da80748f Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Tue, 14 Apr 2020 10:25:54 -0400
Subject: [PATCH 08/10] New package: ROCm-OpenCL-Runtime-3.3.0

---
 common/shlibs                                 |   2 +
 srcpkgs/ROCm-OpenCL-Runtime-clinfo            |   1 +
 srcpkgs/ROCm-OpenCL-Runtime-devel             |   1 +
 .../files/libelf-musl.patch                   |  21 +++
 .../files/runtime-musl.patch                  |  11 ++
 .../ROCm-OpenCL-Runtime/patches/cmake.patch   | 126 ++++++++++++++++++
 srcpkgs/ROCm-OpenCL-Runtime/template          |  84 ++++++++++++
 srcpkgs/ROCm-OpenCL-Runtime/update            |   1 +
 8 files changed, 247 insertions(+)
 create mode 120000 srcpkgs/ROCm-OpenCL-Runtime-clinfo
 create mode 120000 srcpkgs/ROCm-OpenCL-Runtime-devel
 create mode 100644 srcpkgs/ROCm-OpenCL-Runtime/files/libelf-musl.patch
 create mode 100644 srcpkgs/ROCm-OpenCL-Runtime/files/runtime-musl.patch
 create mode 100644 srcpkgs/ROCm-OpenCL-Runtime/patches/cmake.patch
 create mode 100644 srcpkgs/ROCm-OpenCL-Runtime/template
 create mode 100644 srcpkgs/ROCm-OpenCL-Runtime/update

diff --git a/common/shlibs b/common/shlibs
index 42748d6c8bb..0885a3759c5 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3879,3 +3879,5 @@ libjcat.so.1 libjcat-0.1.2_1
 libhsakmt.so.1 ROCT-Thunk-Interface-3.3.0_1
 libhsa-runtime64.so.1 ROCR-Runtime-3.3.0_1
 libamd_comgr.so.1 ROCm-CompilerSupport-3.3.0_1
+libOpenCL-ROCm.so.1 ROCm-OpenCL-Runtime-3.3.0_1
+libamdocl64.so ROCm-OpenCL-Runtime-3.3.0_1
diff --git a/srcpkgs/ROCm-OpenCL-Runtime-clinfo b/srcpkgs/ROCm-OpenCL-Runtime-clinfo
new file mode 120000
index 00000000000..21f2041b8fb
--- /dev/null
+++ b/srcpkgs/ROCm-OpenCL-Runtime-clinfo
@@ -0,0 +1 @@
+ROCm-OpenCL-Runtime
\ No newline at end of file
diff --git a/srcpkgs/ROCm-OpenCL-Runtime-devel b/srcpkgs/ROCm-OpenCL-Runtime-devel
new file mode 120000
index 00000000000..21f2041b8fb
--- /dev/null
+++ b/srcpkgs/ROCm-OpenCL-Runtime-devel
@@ -0,0 +1 @@
+ROCm-OpenCL-Runtime
\ No newline at end of file
diff --git a/srcpkgs/ROCm-OpenCL-Runtime/files/libelf-musl.patch b/srcpkgs/ROCm-OpenCL-Runtime/files/libelf-musl.patch
new file mode 100644
index 00000000000..29469a9a351
--- /dev/null
+++ b/srcpkgs/ROCm-OpenCL-Runtime/files/libelf-musl.patch
@@ -0,0 +1,21 @@
+--- compiler/lib/loaders/elf/utils/libelf/_libelf.h	2020-04-28 15:50:53.243438174 -0400
++++ compiler/lib/loaders/elf/utils/libelf/_libelf.h	2020-04-28 15:51:54.293435415 -0400
+@@ -35,6 +35,7 @@
+ #include "_libelf_config.h"
+ 
+ #include "_elftc.h"
++#include <sys/cdefs.h>
+ 
+ /*
+  * Library-private data structures.
+--- compiler/lib/loaders/elf/utils/libelf/libelf.h	2020-04-28 15:50:53.244438174 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf.h	2020-04-28 15:52:12.375434593 -0400
+@@ -36,6 +36,8 @@
+ #define EM_HSAIL 0xAF5A
+ #endif
+ 
++#include <sys/cdefs.h>
++
+ /* Library private data structures */
+ typedef struct _Elf Elf;
+ typedef struct _Elf_Scn Elf_Scn;
diff --git a/srcpkgs/ROCm-OpenCL-Runtime/files/runtime-musl.patch b/srcpkgs/ROCm-OpenCL-Runtime/files/runtime-musl.patch
new file mode 100644
index 00000000000..ea18e90e09c
--- /dev/null
+++ b/srcpkgs/ROCm-OpenCL-Runtime/files/runtime-musl.patch
@@ -0,0 +1,11 @@
+--- runtime/os/os_posix.cpp.orig	2020-04-19 09:13:51.701982901 -0400
++++ runtime/os/os_posix.cpp	2020-04-19 09:14:04.156947422 -0400
+@@ -44,6 +44,8 @@
+ #include <algorithm>
+ #include <mutex>
+ 
++#include <libgen.h> // for basename
++
+ 
+ namespace amd {
+ 
diff --git a/srcpkgs/ROCm-OpenCL-Runtime/patches/cmake.patch b/srcpkgs/ROCm-OpenCL-Runtime/patches/cmake.patch
new file mode 100644
index 00000000000..2c96b99d45a
--- /dev/null
+++ b/srcpkgs/ROCm-OpenCL-Runtime/patches/cmake.patch
@@ -0,0 +1,126 @@
+--- OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/CMakeLists.txt	2019-09-10 11:53:28.000000000 -0400
++++ OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/CMakeLists.txt	2020-04-16 20:16:13.481180757 -0400
+@@ -73,11 +73,11 @@
+ 
+ set (OPENCL_ICD_LOADER_HEADERS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/inc CACHE PATH "Path to OpenCL Headers")
+ 
+-add_library (OpenCL ${OPENCL_ICD_LOADER_SOURCES})
+-set_target_properties (OpenCL PROPERTIES VERSION "1.2" SOVERSION "1")
++add_library (OpenCL-ROCm ${OPENCL_ICD_LOADER_SOURCES})
++set_target_properties (OpenCL-ROCm PROPERTIES VERSION "1.2" SOVERSION "1")
+ 
+ if (WIN32)
+-    target_link_libraries (OpenCL cfgmgr32.lib)
++    target_link_libraries (OpenCL-ROCm cfgmgr32.lib)
+ 
+     option (OPENCL_ICD_LOADER_REQUIRE_WDK "Build with D3DKMT support, which requires the Windows WDK." ON)
+     if (OPENCL_ICD_LOADER_REQUIRE_WDK)
+@@ -92,10 +92,10 @@
+             get_filename_component(WDK_DIRECTORY ${LATEST_D3DKMT_HEADER} DIRECTORY)
+             get_filename_component(WDK_DIRECTORY ${WDK_DIRECTORY} DIRECTORY)
+             message(STATUS "Found the Windows WDK in: ${WDK_DIRECTORY}")
+-            target_compile_definitions(OpenCL PRIVATE OPENCL_ICD_LOADER_REQUIRE_WDK)
+-            target_include_directories(OpenCL PRIVATE ${WDK_DIRECTORY}/um)
+-            target_include_directories(OpenCL PRIVATE ${WDK_DIRECTORY}/km)
+-            target_include_directories(OpenCL PRIVATE ${WDK_DIRECTORY}/shared)
++	    target_compile_definitions(OpenCL-ROCm PRIVATE OPENCL_ICD_LOADER_REQUIRE_WDK)
++	    target_include_directories(OpenCL-ROCm PRIVATE ${WDK_DIRECTORY}/um)
++	    target_include_directories(OpenCL-ROCm PRIVATE ${WDK_DIRECTORY}/km)
++	    target_include_directories(OpenCL-ROCm PRIVATE ${WDK_DIRECTORY}/shared)
+         else()
+             message(FATAL_ERROR "The Windows WDK was not found. Consider disabling OPENCL_ICD_LOADER_REQUIRE_WDK. Aborting.")
+         endif()
+@@ -113,25 +113,25 @@
+     endif()
+ else()
+     if (APPLE)
+-        target_link_libraries (OpenCL ${CMAKE_THREAD_LIBS_INIT})
++        target_link_libraries (OpenCL-ROCm ${CMAKE_THREAD_LIBS_INIT})
+     else ()
+-        set_target_properties (OpenCL PROPERTIES LINK_FLAGS "-Wl,--version-script -Wl,${CMAKE_CURRENT_SOURCE_DIR}/loader/linux/icd_exports.map")
+-        target_link_libraries (OpenCL ${CMAKE_THREAD_LIBS_INIT})
++        set_target_properties (OpenCL-ROCm PROPERTIES LINK_FLAGS "-Wl,--version-script -Wl,${CMAKE_CURRENT_SOURCE_DIR}/loader/linux/icd_exports.map")
++	target_link_libraries (OpenCL-ROCm ${CMAKE_THREAD_LIBS_INIT})
+     endif ()
+ endif ()
+ 
+ include_directories (${OPENCL_ICD_LOADER_HEADERS_DIR})
+ add_definitions (-DCL_TARGET_OPENCL_VERSION=220)
+ 
+-target_include_directories (OpenCL PRIVATE ${CMAKE_CURRENT_BINARY_DIR} loader)
+-target_link_libraries (OpenCL ${CMAKE_DL_LIBS})
++target_include_directories (OpenCL-ROCm PRIVATE ${CMAKE_CURRENT_BINARY_DIR} loader)
++target_link_libraries (OpenCL-ROCm ${CMAKE_DL_LIBS})
+ 
+ include (CTest)
+ if (BUILD_TESTING)
+     add_subdirectory (test)
+ endif()
+ 
+-install (TARGETS OpenCL
++install (TARGETS OpenCL-ROCm
+     RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+     ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
+     LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
+--- OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/test/loader_test/CMakeLists.txt	2019-09-10 11:53:28.000000000 -0400
++++ OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/test/loader_test/CMakeLists.txt	2020-04-16 20:16:56.647026589 -0400
+@@ -12,4 +12,4 @@
+     test_clgl.c
+     test_image_objects.c )
+ 
+-target_link_libraries (icd_loader_test OpenCL IcdLog)
++target_link_libraries (icd_loader_test OpenCL-ROCm IcdLog)
+--- ROCm-OpenCL-Runtime-roc-3.3.0/CMakeLists.txt	2020-04-28 07:29:51.864446603 -0400
++++ ROCm-OpenCL-Runtime-roc-3.3.0/CMakeLists.txt	2020-04-28 07:32:45.245793180 -0400
+@@ -101,30 +101,30 @@
+ rocm_setup_version( VERSION "2.0.0" )
+ 
+ # MAIN package
+-install(PROGRAMS $<TARGET_FILE:clinfo>
+-        DESTINATION bin/x86_64
++install(PROGRAMS $<TARGET_FILE:rocm-clinfo>
++        DESTINATION bin
+         COMPONENT MAIN)
+ install(PROGRAMS $<TARGET_FILE:amdocl64>
+-        DESTINATION lib/x86_64
++        DESTINATION lib
+         COMPONENT MAIN)
+-install(PROGRAMS $<TARGET_FILE:OpenCL>
+-        DESTINATION lib/x86_64
++install(PROGRAMS $<TARGET_FILE:OpenCL-ROCm>
++        DESTINATION lib
+         COMPONENT MAIN)
+-install(PROGRAMS $<TARGET_SONAME_FILE:OpenCL>
+-        DESTINATION lib/x86_64
++install(PROGRAMS $<TARGET_SONAME_FILE:OpenCL-ROCm>
++        DESTINATION lib
+         COMPONENT MAIN)
+ 
+ # DEV package
+ install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/api/opencl/khronos/headers/opencl2.2/CL"
+-        DESTINATION include
++	DESTINATION include/rocm
+         COMPONENT DEV
+         USE_SOURCE_PERMISSIONS
+         PATTERN cl_d3d10.h EXCLUDE
+         PATTERN cl_d3d11.h EXCLUDE
+         PATTERN cl_dx9_media_sharing.h EXCLUDE
+         PATTERN cl_egl.h EXCLUDE)
+-install(PROGRAMS $<TARGET_LINKER_FILE:OpenCL>
+-        DESTINATION lib/x86_64
++install(PROGRAMS $<TARGET_LINKER_FILE:OpenCL-ROCm>
++        DESTINATION lib
+         COMPONENT DEV)
+ 
+ # Generic CPACK variables
+--- ROCm-OpenCL-Runtime-roc-3.3.0/tools/clinfo/CMakeLists.txt	2020-04-28 07:29:51.882446535 -0400
++++ ROCm-OpenCL-Runtime-roc-3.3.0/tools/clinfo/CMakeLists.txt	2020-04-28 07:30:05.627394732 -0400
+@@ -6,6 +6,6 @@
+ 
+ add_definitions(-DHAVE_CL2_HPP)
+ 
+-add_executable(clinfo clinfo.cpp)
++add_executable(rocm-clinfo clinfo.cpp)
+ 
+-target_link_libraries(clinfo OpenCL)
++target_link_libraries(rocm-clinfo OpenCL-ROCm)
diff --git a/srcpkgs/ROCm-OpenCL-Runtime/template b/srcpkgs/ROCm-OpenCL-Runtime/template
new file mode 100644
index 00000000000..f6699a1d4c0
--- /dev/null
+++ b/srcpkgs/ROCm-OpenCL-Runtime/template
@@ -0,0 +1,84 @@
+# Template file for 'ROCm-OpenCL-Runtime'
+pkgname=ROCm-OpenCL-Runtime
+version=3.3.0
+revision=1
+_ocl_icd_name="OpenCL-ICD-Loader"
+_ocl_icd_ver="6c03f8b58fafd9dd693eaac826749a5cfad515f8"
+archs="x86_64*"
+create_wrksrc=yes
+build_wrksrc="${pkgname}-roc-${version}"
+build_style=cmake
+configure_args="-DUSE_COMGR_LIBRARY=yes"
+hostmakedepends="cmake pkg-config"
+makedepends="libglvnd-devel ROCm-CompilerSupport-devel
+	ROCT-Thunk-Interface-devel ROCR-Runtime-devel"
+depends="ROCm-CompilerSupport"
+short_desc="Radeon Open Compute OpenCL runtime"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="MIT"
+homepage="https://github.com/RadeonOpenCompute/ROCm-OpenCL-Runtime"
+_rocroot="https://github.com/RadeonOpenCompute"
+distfiles="${_rocroot}/ROCm-OpenCL-Runtime/archive/roc-${version}.tar.gz
+	${_rocroot}/rocm-cmake/archive/rocm-${version}.tar.gz
+	https://github.com/KhronosGroup/${_ocl_icd_name}/archive/${_ocl_icd_ver}.tar.gz"
+checksum="ac6999f1a491ab066286c2bd6adf50f08f831286f56e267879f9f7eced22f98e
+	76ed3ee8e56cf3246011cf7723c2abda539e1136e7e7f6909bfa45d268b8644f
+	c94d5bb6dc980c4d41d73e2b81663a19aabe494e923e2d0eec72a4c95b318438"
+nocross=yes
+
+if [ "$XBPS_LIBC" = "musl" ]; then
+	makedepends+=" musl-legacy-compat"
+fi
+
+post_patch() {
+	if [ "$XBPS_LIBC" = "musl" ]; then
+		# Remove dependence on glibc
+		patch -Np0 < ${FILESDIR}/libelf-musl.patch
+		patch -Np0 < ${FILESDIR}/runtime-musl.patch
+		vsed -e '/glibc_functions.cpp/d' -i api/opencl/amdocl/CMakeLists.txt
+	fi
+}
+
+pre_configure() {
+	# ROCm requires a very specific Khronos ICD loader version in the tree
+	# Keep the ICD loader config in /etc/OpenCL/rocm-vendors to avoid conflicts
+	_ocl_icd_dir="${_ocl_icd_name}-${_ocl_icd_ver}"
+	ln -sf "${wrksrc}/${_ocl_icd_dir}" api/opencl/khronos/icd
+	vsed -i "${wrksrc}/${_ocl_icd_dir}/loader/icd_platform.h" \
+		-e 's@/etc/OpenCL/vendors/@/etc/OpenCL/rocm-vendors/@g'
+
+	# CMake modules probably not useful anywhere but for this build
+	ln -sf "${wrksrc}/rocm-cmake-rocm-${version}/share/rocm/cmake"/*.cmake cmake
+
+	# Fix the dlopen macro to point to versioned libamd_comgr shared object
+	vsed -i 'runtime/device/comgrctx.cpp' \
+		-e 's/\blibamd_comgr\(32\)\?.so\b/&.1/g'
+}
+
+post_install() {
+	vlicense License
+
+	# Create descriptor to allow the ICD loader to find the driver
+	vmkdir etc/OpenCL/rocm-vendors
+	echo "libamdocl64.so" > "${DESTDIR}/etc/OpenCL/rocm-vendors/amdocl64.icd"
+	vmkdir etc/OpenCL/vendors
+	ln -s ../../OpenCL/rocm-vendors/amdocl64.icd \
+		${DESTDIR}/etc/OpenCL/vendors/rocm-amdocl64.icd
+}
+
+ROCm-OpenCL-Runtime-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/lib/libOpenCL-ROCm.so
+		vmove usr/include
+	}
+}
+
+ROCm-OpenCL-Runtime-clinfo_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - clinfo"
+	pkg_install() {
+		vmove usr/bin/rocm-clinfo
+	}
+}
diff --git a/srcpkgs/ROCm-OpenCL-Runtime/update b/srcpkgs/ROCm-OpenCL-Runtime/update
new file mode 100644
index 00000000000..8385f4d1215
--- /dev/null
+++ b/srcpkgs/ROCm-OpenCL-Runtime/update
@@ -0,0 +1 @@
+pattern='roc-\K[\d.]+'

From 40fd881e665651d848b6489c3a0d11ea05865569 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Thu, 30 Apr 2020 13:11:12 -0400
Subject: [PATCH 09/10] New package: ROCR-Runtime-hsa-ext-3.3.0

---
 common/shlibs                         |  2 ++
 srcpkgs/ROCR-Runtime-hsa-ext-devel    |  1 +
 srcpkgs/ROCR-Runtime-hsa-ext/template | 43 +++++++++++++++++++++++++++
 srcpkgs/ROCR-Runtime-hsa-ext/update   |  2 ++
 4 files changed, 48 insertions(+)
 create mode 120000 srcpkgs/ROCR-Runtime-hsa-ext-devel
 create mode 100644 srcpkgs/ROCR-Runtime-hsa-ext/template
 create mode 100644 srcpkgs/ROCR-Runtime-hsa-ext/update

diff --git a/common/shlibs b/common/shlibs
index 0885a3759c5..a01e031c03b 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3881,3 +3881,5 @@ libhsa-runtime64.so.1 ROCR-Runtime-3.3.0_1
 libamd_comgr.so.1 ROCm-CompilerSupport-3.3.0_1
 libOpenCL-ROCm.so.1 ROCm-OpenCL-Runtime-3.3.0_1
 libamdocl64.so ROCm-OpenCL-Runtime-3.3.0_1
+libhsa-ext-image64.so.1 ROCR-Runtime-hsa-ext-3.3.0_1
+libhsa-runtime-tools64.so.1 ROCR-Runtime-hsa-ext-3.3.0_1
diff --git a/srcpkgs/ROCR-Runtime-hsa-ext-devel b/srcpkgs/ROCR-Runtime-hsa-ext-devel
new file mode 120000
index 00000000000..6ee1b14911b
--- /dev/null
+++ b/srcpkgs/ROCR-Runtime-hsa-ext-devel
@@ -0,0 +1 @@
+ROCR-Runtime-hsa-ext
\ No newline at end of file
diff --git a/srcpkgs/ROCR-Runtime-hsa-ext/template b/srcpkgs/ROCR-Runtime-hsa-ext/template
new file mode 100644
index 00000000000..235ae92146b
--- /dev/null
+++ b/srcpkgs/ROCR-Runtime-hsa-ext/template
@@ -0,0 +1,43 @@
+# Template file for 'ROCR-Runtime-hsa-ext'
+pkgname=ROCR-Runtime-hsa-ext
+version=3.3.0
+revision=1
+archs="x86_64"
+hostmakedepends="tar"
+short_desc="Radeon Open Compute HSA runtime extensions"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute"
+_hsa_deb="hsa-ext-rocr-dev_1.1.30300.0-rocm-rel-3.3-19-23fc088b_amd64.deb"
+distfiles="https://repo.radeon.com/rocm/apt/debian/pool/main/h/hsa-ext-rocr-dev/$_hsa_deb"
+checksum=6b44e286b395d946b865ec1f3cc546356396785ac1fde591d07af02d0aa7c25d
+repository=nonfree
+restricted=yes
+
+do_extract() {
+	ar x "${XBPS_SRCDISTDIR}/${pkgname}-${version}/${_hsa_deb}"
+	tar xvf data.tar.gz
+}
+
+do_install() {
+	_rocm_includes="opt/rocm-${version}/hsa/include"
+
+	vmkdir usr
+	vcopy opt/rocm-${version}/hsa/lib usr
+	vcopy "$_rocm_includes" usr
+
+	# Extract license from one of the header files
+	awk 'BEGIN{HEADER=0} /\/\//{HEADER=1; print $0;} /^[^/]/{if(HEADER==1) exit;}' \
+		< "${_rocm_includes}/hsa/amd_hsa_tools_interfaces.h" \
+		| sed 's@^///*\( \|$\)@@' > LICENSE
+	vlicense LICENSE
+}
+
+ROCR-Runtime-hsa-ext-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove "usr/lib/*.so"
+	}
+}
diff --git a/srcpkgs/ROCR-Runtime-hsa-ext/update b/srcpkgs/ROCR-Runtime-hsa-ext/update
new file mode 100644
index 00000000000..84252d2e3b8
--- /dev/null
+++ b/srcpkgs/ROCR-Runtime-hsa-ext/update
@@ -0,0 +1,2 @@
+site='https://repo.radeon.com/rocm/apt/debian/pool/main/h/'
+pattern='hsa-ext-rocr-dev\K[\d.]+'

From a0049a0046efdf38ef5d26761972309397e20e3f Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Tue, 28 Apr 2020 13:33:46 -0400
Subject: [PATCH 10/10] hashcat: add build option to link against ROCm [ci
 skip]

---
 srcpkgs/hashcat/files/rocm.patch     | 15 ++++++++++++++
 srcpkgs/hashcat/patches/tmpdir.patch | 30 ++++++++++++++++++++++++++++
 srcpkgs/hashcat/template             | 17 +++++++++++++---
 3 files changed, 59 insertions(+), 3 deletions(-)
 create mode 100644 srcpkgs/hashcat/files/rocm.patch
 create mode 100644 srcpkgs/hashcat/patches/tmpdir.patch

diff --git a/srcpkgs/hashcat/files/rocm.patch b/srcpkgs/hashcat/files/rocm.patch
new file mode 100644
index 00000000000..f1e899d30ee
--- /dev/null
+++ b/srcpkgs/hashcat/files/rocm.patch
@@ -0,0 +1,15 @@
+diff -ur a/src/opencl.c b/src/opencl.c
+--- a/src/opencl.c	2018-12-02 05:58:48.000000000 -0500
++++ b/src/opencl.c	2020-04-28 13:24:12.602415333 -0400
+@@ -492,9 +492,9 @@
+ 
+   if (ocl->lib == NULL) ocl->lib = hc_dlopen ("cygOpenCL-1.dll", RTLD_NOW);
+   #else
+-  ocl->lib = hc_dlopen ("libOpenCL.so", RTLD_NOW);
++  ocl->lib = hc_dlopen ("libOpenCL-ROCm.so.1", RTLD_NOW);
+ 
+-  if (ocl->lib == NULL) ocl->lib = hc_dlopen ("libOpenCL.so.1", RTLD_NOW);
++  if (ocl->lib == NULL) ocl->lib = hc_dlopen ("libOpenCL-ROCm.so", RTLD_NOW);
+   #endif
+ 
+   if (ocl->lib == NULL)
diff --git a/srcpkgs/hashcat/patches/tmpdir.patch b/srcpkgs/hashcat/patches/tmpdir.patch
new file mode 100644
index 00000000000..c6aab72db16
--- /dev/null
+++ b/srcpkgs/hashcat/patches/tmpdir.patch
@@ -0,0 +1,30 @@
+diff --git src/folder.c src/folder.c
+index 0c313f31..e54910b1 100644
+--- src/folder.c
++++ src/folder.c
+@@ -462,9 +462,24 @@ int folder_config_init (hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const char *ins
+   {
+     char *tmp;
+ 
+-    hc_asprintf (&tmp, "TMP=%s", cpath_real);
++    #if defined (_POSIX)
++    // Setting TMP may break POSIX temporary directory semantics
++    // Fix it by setting the POSIX-ly correct TMPDIR if it is not already set
++    if (getenv ("TMPDIR") == NULL) {
++      if (getenv("TMP") != NULL) {
++        // TMP was specified in the environment, promote it to TMPDIR
++        hc_asprintf (&tmp, "TMPDIR=%s", getenv("TMP"));
++        putenv (tmp);
++        hcfree (tmp);
++      } else {
++        putenv ("TMPDIR=/tmp");
++      }
++    }
++    #endif
+ 
++    hc_asprintf (&tmp, "TMP=%s", cpath_real);
+     putenv (tmp);
++    hcfree (tmp);
+   }
+ 
+   #if defined (_WIN)
diff --git a/srcpkgs/hashcat/template b/srcpkgs/hashcat/template
index e982f99cebf..3f19be5e41d 100644
--- a/srcpkgs/hashcat/template
+++ b/srcpkgs/hashcat/template
@@ -1,15 +1,16 @@
 # Template file for 'hashcat'
 pkgname=hashcat
 version=5.1.0
-revision=2
+revision=3
 build_style=gnu-makefile
 make_build_args="PREFIX=/usr
  USE_SYSTEM_OPENCL=1 USE_SYSTEM_XXHASH=1
- DEPS_OPENCL_PATH=${XBPS_CROSS_BASE}/usr/include
+ DEPS_OPENCL_PATH=${XBPS_CROSS_BASE}/usr/include$(vopt_if rocm /rocm)
  DEPS_XXHASH_PATH=${XBPS_CROSS_BASE}/usr/include"
 make_use_env=yes
 make_install_args="$make_build_args"
-makedepends="gmp-devel opencl2-headers xxHash-devel"
+makedepends="gmp-devel xxHash-devel
+ $(vopt_if rocm ROCm-OpenCL-Runtime-devel opencl2-headers)"
 checkdepends="perl"
 short_desc="Advanced CPU-based password recovery utility"
 maintainer="Duncaen <duncaen@voidlinux.org>"
@@ -19,6 +20,9 @@ changelog="https://raw.githubusercontent.com/hashcat/hashcat/master/docs/changes
 distfiles="https://hashcat.net/files/hashcat-${version}.tar.gz"
 checksum=283beaa68e1eab41de080a58bb92349c8e47a2bb1b93d10f36ea30f418f1e338
 
+build_options="rocm"
+desc_option_rocm="Use ROCm OpenCL runtime"
+
 if [ "$XBPS_TARGET_ENDIAN" = "be" ]; then
 	broken="Not supported on big endian"
 fi
@@ -26,6 +30,13 @@ fi
 post_extract() {
 	sed '/^CC/d' -i src/Makefile
 }
+
+post_patch() {
+	if [ "$build_option_rocm" ]; then
+		patch -Np1 < ${FILESDIR}/rocm.patch
+	fi
+}
+
 post_install() {
 	rm -f ${DESTDIR}/usr/share/docs/hashcat/license.txt
 	vlicense docs/license.txt

^ permalink raw reply	[flat|nested] 61+ messages in thread

* Re: [PR PATCH] [Updated] New packages: ROCm core and OpenCL
  2020-04-19 13:34 [PR PATCH] New packages: ROCm core and OpenCL ahesford
                   ` (33 preceding siblings ...)
  2020-05-11 18:52 ` [PR PATCH] [Updated] " ahesford
@ 2020-05-11 20:03 ` ahesford
  2020-05-14 18:04 ` FiCacador
                   ` (24 subsequent siblings)
  59 siblings, 0 replies; 61+ messages in thread
From: ahesford @ 2020-05-11 20:03 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 3893 bytes --]

There is an updated pull request by ahesford against master on the void-packages repository

https://github.com/ahesford/void-packages rocm
https://github.com/void-linux/void-packages/pull/21153

New packages: ROCm core and OpenCL
This PR includes several packages designed to bring the OpenCL portion of the AMD ROCm ecosystem to Void. It addresses Issue #19507. There are many other packages that AMD provides for GPGPU computing, but these can be added piecemeal as users demand.

The packages are currently only for `x86_64*`. While at least some of the packages will compile on other 64-bit architectures, I have no hardware to test. They are certainly not suitable for 32-bit architectures; some internal data structures rely on `uint64_t` values that are cast to pointers. At a
minimum, a thorough audit would be necessary to ensure that these casts are safe (e.g., that the values stored were only ever upcast from 32-bit pointers). More extensive work may be necessary to support 32-bit architectures, probably without significant benefit.

The packages successfully identify a Radeon RX 580 on an `x86_64` installation using both `clinfo` and `rocminfo` as provided. Furthermore, a version of `pyopencl` linked against these ROCm packages successfully runs a simple program that validates arithmetic on GPU-bound arrays.

There are caveats with this set of packages, almost all of which revolve around the incompatibilities between the Void-provided `ocl-icd` and the [Khronos OpenCL ICD loader](https://github.com/KhronosGroup/OpenCL-ID-Loader) required by (and built into) `rocm-opencl-runtime`.
1. All packages install into `/opt/rocm`. This keeps the environment closer to that officially sanctioned by AMD and helps avoid conflicts between other packages and those provided here. (For example, `clinfo` and the ICD loader itself.) Eventually, we may be able to move the files into `/usr`.
2. The Khronos OpenCL ICD loader built into `rocm-opencl-runtime` is an outdated, pre-release commit. If AMD can update its sources to use the release version of that loader (which has a backward-incompatible API change), we may be able to make ROCm compatible with `ocl-icd` or replace `ocl-icd` with the official Khronos loader.
3. In the meantime, to avoid `shlibs` conflicts, the OpenCL ICD loader is installed as `/opt/rocm/lib/libOpenCL-ROCm.so` (and an appropriately versioned shared library), which means that programs wishing to use the ROCm OpenCL must explicitly link against this library instead of the generic `libOpenCL.so`.
4. I do **not** recommend making any Void packages link against this specific library, because it will make those packages ROCm-only. For the time being, ROCm is intended for end-users to specifically link against. Linking Void packages against ROCm would requires the ICD loader used by ROCm be compatible with `ocl-icd`, or `ocl-icd` be replaced by the Khronos loader. However, because the Khronos loader changed its API for the release version, such a change is not yet appropriate.

Hopefully, if AMD updates its dependence on the Khronos ICD loader, we can resolve some of these caveats in the future and make ROCm a more natural Void component. For now, these packages are useful for those who need an AMD OpenCL solution and would rather custom-link software against the AMD ICD loader than hack the `amdgpu-pro` driver into an ICD compatible with `ocl-icd`.

Some patches were made to relocate some files in `/opt/rocm` and make everyting build on x86_64-musl`. Where appropriate, these patches will be pushed upstream to clean up the distribution and packaging.

Update: I pushed some new commits to update license information that triggerd an `xlint` failure. I've also disabled CI builds because they will time out on `rocm-llvm`.

A patch file from https://github.com/void-linux/void-packages/pull/21153.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-rocm-21153.patch --]
[-- Type: text/x-diff, Size: 38016 bytes --]

From 8597ad3e9027847ef7c6190eb69ed06975cdaad4 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Mon, 13 Apr 2020 13:08:09 -0400
Subject: [PATCH 01/10] New package: ROCT-Thunk-Interface-3.3.0

---
 common/shlibs                                 |  1 +
 srcpkgs/ROCT-Thunk-Interface-devel            |  1 +
 .../patches/cmake-dev-libdir.patch            | 10 ++++++
 .../ROCT-Thunk-Interface/patches/musl.patch   | 29 ++++++++++++++++
 srcpkgs/ROCT-Thunk-Interface/template         | 33 +++++++++++++++++++
 srcpkgs/ROCT-Thunk-Interface/update           |  1 +
 6 files changed, 75 insertions(+)
 create mode 120000 srcpkgs/ROCT-Thunk-Interface-devel
 create mode 100644 srcpkgs/ROCT-Thunk-Interface/patches/cmake-dev-libdir.patch
 create mode 100644 srcpkgs/ROCT-Thunk-Interface/patches/musl.patch
 create mode 100644 srcpkgs/ROCT-Thunk-Interface/template
 create mode 100644 srcpkgs/ROCT-Thunk-Interface/update

diff --git a/common/shlibs b/common/shlibs
index 7693053e46b..118f896e187 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3876,3 +3876,4 @@ libhidrd_opt.so.0 hidrd-0.2.0_1
 libhidrd_strm.so.0 hidrd-0.2.0_1
 libhidrd_fmt.so.0 hidrd-0.2.0_1
 libjcat.so.1 libjcat-0.1.2_1
+libhsakmt.so.1 ROCT-Thunk-Interface-3.3.0_1
diff --git a/srcpkgs/ROCT-Thunk-Interface-devel b/srcpkgs/ROCT-Thunk-Interface-devel
new file mode 120000
index 00000000000..7e43c209e3d
--- /dev/null
+++ b/srcpkgs/ROCT-Thunk-Interface-devel
@@ -0,0 +1 @@
+ROCT-Thunk-Interface
\ No newline at end of file
diff --git a/srcpkgs/ROCT-Thunk-Interface/patches/cmake-dev-libdir.patch b/srcpkgs/ROCT-Thunk-Interface/patches/cmake-dev-libdir.patch
new file mode 100644
index 00000000000..98c7f1e459c
--- /dev/null
+++ b/srcpkgs/ROCT-Thunk-Interface/patches/cmake-dev-libdir.patch
@@ -0,0 +1,10 @@
+--- CMakeLists.txt.old	2020-04-18 19:45:17.306081135 -0400
++++ CMakeLists.txt	2020-04-18 19:46:51.300753636 -0400
+@@ -146,6 +146,7 @@
+     COMMAND ${CMAKE_COMMAND}
+         -DSOURCE_DIR="${SOURCE_DIR}"
+         -DCMAKE_INSTALL_PREFIX="${CMAKE_INSTALL_PREFIX}"
++        -DCMAKE_INSTALL_LIBDIR="${CMAKE_INSTALL_LIBDIR}"
+         -DCPACK_RPM_PACKAGE_REQUIRES="hsakmt-roct"
+         -DCPACK_PACKAGING_INSTALL_PREFIX="${CPACK_PACKAGING_INSTALL_PREFIX}"
+         -DVERSION="${BUILD_VERSION_STRING}"
diff --git a/srcpkgs/ROCT-Thunk-Interface/patches/musl.patch b/srcpkgs/ROCT-Thunk-Interface/patches/musl.patch
new file mode 100644
index 00000000000..aeea9832411
--- /dev/null
+++ b/srcpkgs/ROCT-Thunk-Interface/patches/musl.patch
@@ -0,0 +1,29 @@
+diff -r -u old/src/libhsakmt.h new/src/libhsakmt.h
+--- src/libhsakmt.h	2020-03-04 15:00:47.000000000 -0500
++++ src/libhsakmt.h	2020-04-13 12:58:30.444865992 -0400
+@@ -54,6 +54,10 @@
+ #define CHECK_KFD_OPEN() \
+ 	do { if (kfd_open_count == 0 || hsakmt_forked) return HSAKMT_STATUS_KERNEL_IO_CHANNEL_NOT_OPENED; } while (0)
+ 
++/*On some platforms, a PAGE_SIZE macro eclipses the extern variable*/
++#ifdef PAGE_SIZE
++#undef PAGE_SIZE
++#endif
+ extern int PAGE_SIZE;
+ extern int PAGE_SHIFT;
+ 
+diff -r -u old/src/topology.c new/src/topology.c
+--- src/topology.c	2020-03-04 15:00:47.000000000 -0500
++++ src/topology.c	2020-04-13 13:01:31.209870701 -0400
+@@ -38,6 +38,11 @@
+ #include "libhsakmt.h"
+ #include "fmm.h"
+ 
++/*Needed on MUSL*/
++#ifndef MAXNAMLEN
++#define MAXNAMLEN PATH_MAX
++#endif
++
+ /* Number of memory banks added by thunk on top of topology
+  * This only includes static heaps like LDS, scratch and SVM,
+  * not for MMIO_REMAP heap. MMIO_REMAP memory bank is reported
diff --git a/srcpkgs/ROCT-Thunk-Interface/template b/srcpkgs/ROCT-Thunk-Interface/template
new file mode 100644
index 00000000000..8c680b2af29
--- /dev/null
+++ b/srcpkgs/ROCT-Thunk-Interface/template
@@ -0,0 +1,33 @@
+# Template file for 'ROCT-Thunk-Interface'
+pkgname=ROCT-Thunk-Interface
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="${pkgname}-roc-${version}"
+build_style=cmake
+make_build_target="all build-dev"
+make_install_target="install install-dev"
+hostmakedepends="cmake pkg-config"
+makedepends="pciutils-devel libnuma-devel"
+short_desc="Radeon Open Compute thunk interface"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="MIT"
+homepage="https://github.com/RadeonOpenCompute/ROCT-Thunk-Interface"
+distfiles="${homepage}/archive/roc-${version}.tar.gz"
+checksum=2cabe9d2cfa72031c05d11290837c476182e72d8dec2049298f691143fdd212b
+nocross=yes
+
+post_install() {
+	vlicense LICENSE.md
+}
+
+ROCT-Thunk-Interface-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove "usr/lib/*.so"
+		vmove usr/share/pkgconfig
+		vmove usr/lib/cmake
+	}
+}
diff --git a/srcpkgs/ROCT-Thunk-Interface/update b/srcpkgs/ROCT-Thunk-Interface/update
new file mode 100644
index 00000000000..8385f4d1215
--- /dev/null
+++ b/srcpkgs/ROCT-Thunk-Interface/update
@@ -0,0 +1 @@
+pattern='roc-\K[\d.]+'

From 1981ee18dbf52d1294e402080547f22397ed8458 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Mon, 13 Apr 2020 15:27:27 -0400
Subject: [PATCH 02/10] New package: ROCR-Runtime-3.3.0

---
 common/shlibs                            |  1 +
 srcpkgs/ROCR-Runtime-devel               |  1 +
 srcpkgs/ROCR-Runtime/patches/cmake.patch | 27 +++++++++++++++++++++
 srcpkgs/ROCR-Runtime/template            | 30 ++++++++++++++++++++++++
 srcpkgs/ROCR-Runtime/update              |  1 +
 5 files changed, 60 insertions(+)
 create mode 120000 srcpkgs/ROCR-Runtime-devel
 create mode 100644 srcpkgs/ROCR-Runtime/patches/cmake.patch
 create mode 100644 srcpkgs/ROCR-Runtime/template
 create mode 100644 srcpkgs/ROCR-Runtime/update

diff --git a/common/shlibs b/common/shlibs
index 118f896e187..46a83863bcd 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3877,3 +3877,4 @@ libhidrd_strm.so.0 hidrd-0.2.0_1
 libhidrd_fmt.so.0 hidrd-0.2.0_1
 libjcat.so.1 libjcat-0.1.2_1
 libhsakmt.so.1 ROCT-Thunk-Interface-3.3.0_1
+libhsa-runtime64.so.1 ROCR-Runtime-3.3.0_1
diff --git a/srcpkgs/ROCR-Runtime-devel b/srcpkgs/ROCR-Runtime-devel
new file mode 120000
index 00000000000..a733fb9fbab
--- /dev/null
+++ b/srcpkgs/ROCR-Runtime-devel
@@ -0,0 +1 @@
+ROCR-Runtime
\ No newline at end of file
diff --git a/srcpkgs/ROCR-Runtime/patches/cmake.patch b/srcpkgs/ROCR-Runtime/patches/cmake.patch
new file mode 100644
index 00000000000..93b74cd2297
--- /dev/null
+++ b/srcpkgs/ROCR-Runtime/patches/cmake.patch
@@ -0,0 +1,27 @@
+--- src/CMakeLists.txt.old	2020-04-18 20:01:48.549636995 -0400
++++ src/CMakeLists.txt	2020-04-18 20:04:00.177179781 -0400
+@@ -108,8 +108,8 @@
+ ## ROCr build internal versioning
+ add_definitions ( -DROCR_BUILD_ID=${PACKAGE_VERSION_STRING} )
+ 
+-## Set RUNPATH - ../../lib covers use of the legacy symlink in /hsa/lib/
+-set(CMAKE_INSTALL_RPATH "$ORIGIN;$ORIGIN/../../lib;$ORIGIN/../../lib64;$ORIGIN/../lib64")
++## Set RUNPATH
++set(CMAKE_INSTALL_RPATH "$ORIGIN;$ORIGIN/../lib")
+ 
+ ## ------------------------- Linux Compiler and Linker options -------------------------
+ set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -fexceptions -fno-rtti -fvisibility=hidden -Wno-error=sign-compare -Wno-sign-compare -Wno-write-strings -Wno-conversion-null -fno-math-errno -fno-threadsafe-statics -fmerge-all-constants -fms-extensions -Wno-error=comment -Wno-comment -Wno-error=pointer-arith -Wno-pointer-arith -Wno-error=unused-variable -Wno-error=unused-function" )
+@@ -185,11 +185,8 @@
+ add_custom_target ( hsa_lib_link2 ALL WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMAND ${CMAKE_COMMAND} -E create_symlink ../hsa/lib/${CORE_RUNTIME_LIBRARY}.so.${SO_MAJOR} ${CORE_RUNTIME_LIBRARY}-link.so.${SO_MAJOR} )
+ 
+ ## Set install information
+-install ( TARGETS ${CORE_RUNTIME_TARGET} LIBRARY DESTINATION hsa/lib )
+-install ( DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/inc/ DESTINATION hsa/include/hsa )
+-install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/hsa_include_link DESTINATION include PERMISSIONS OWNER_WRITE OWNER_READ RENAME hsa )
+-install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/${CORE_RUNTIME_LIBRARY}-link.so DESTINATION lib PERMISSIONS OWNER_WRITE OWNER_READ RENAME ${CORE_RUNTIME_LIBRARY}.so )
+-install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/${CORE_RUNTIME_LIBRARY}-link.so.${SO_MAJOR} DESTINATION lib PERMISSIONS OWNER_WRITE OWNER_READ RENAME ${CORE_RUNTIME_LIBRARY}.so.${SO_MAJOR} )
++install ( TARGETS ${CORE_RUNTIME_TARGET} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} )
++install ( DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/inc/ DESTINATION include/hsa )
+ 
+ ## Packaging directives
+ set ( CPACK_GENERATOR "DEB;RPM" CACHE STRING "Package types to build")
diff --git a/srcpkgs/ROCR-Runtime/template b/srcpkgs/ROCR-Runtime/template
new file mode 100644
index 00000000000..95b7e701afb
--- /dev/null
+++ b/srcpkgs/ROCR-Runtime/template
@@ -0,0 +1,30 @@
+# Template file for 'ROCR-Runtime'
+pkgname=ROCR-Runtime
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="${pkgname}-rocm-${version}"
+build_wrksrc="src"
+build_style=cmake
+hostmakedepends="cmake pkg-config"
+makedepends="ROCT-Thunk-Interface-devel elfutils-devel"
+short_desc="Radeon Open Compute HSA runtime"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute/ROCR-Runtime"
+distfiles="${homepage}/archive/rocm-${version}.tar.gz"
+checksum=fa2d2d1f8a61d8a6952d377cf288d78c61776c3c2a666f163cafc3aa19ab0b61
+nocross=yes
+
+post_install() {
+	vlicense ../LICENSE.txt
+}
+
+ROCR-Runtime-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove "usr/lib/*.so"
+	}
+}
diff --git a/srcpkgs/ROCR-Runtime/update b/srcpkgs/ROCR-Runtime/update
new file mode 100644
index 00000000000..86197bc3eea
--- /dev/null
+++ b/srcpkgs/ROCR-Runtime/update
@@ -0,0 +1 @@
+pattern='rocm-\K[\d.]+'

From 0d0627adca7950c6cc9e0989fb6089c8b51f243f Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Mon, 13 Apr 2020 18:07:34 -0400
Subject: [PATCH 03/10] New package: ROCm-llvm-3.3.0

---
 srcpkgs/ROCm-llvm/template | 26 ++++++++++++++++++++++++++
 srcpkgs/ROCm-llvm/update   |  1 +
 2 files changed, 27 insertions(+)
 create mode 100644 srcpkgs/ROCm-llvm/template
 create mode 100644 srcpkgs/ROCm-llvm/update

diff --git a/srcpkgs/ROCm-llvm/template b/srcpkgs/ROCm-llvm/template
new file mode 100644
index 00000000000..4c3095b21f4
--- /dev/null
+++ b/srcpkgs/ROCm-llvm/template
@@ -0,0 +1,26 @@
+# Template file for 'ROCm-llvm'
+pkgname=ROCm-llvm
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="llvm-project-rocm-ocl-${version}"
+build_wrksrc=llvm
+build_style=cmake
+configure_args="-DCMAKE_INSTALL_PREFIX:PATH=/usr/lib/rocm-llvm
+	-DLLVM_ENABLE_PROJECTS='llvm;clang;lld' -DLLVM_TARGETS_TO_BUILD='AMDGPU'
+	-DLLVM_BUILD_DOCS=NO -DLLVM_ENABLE_OCAMLDOC=OFF
+	-DLLVM_ENABLE_SPHINX=NO -DLLVM_ENABLE_DOXYGEN=OFF
+	-DLLVM_INSTALL_UTILS=ON -DLLVM_VERSION_SUFFIX=roc -DOCAMLFIND=NO"
+hostmakedepends="cmake pkg-config python3"
+short_desc="Radeon Open Compute LLVM toolchain"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="Apache-2.0, NCSA, custom:LLVM-Exceptions"
+homepage="https://github.com/RadeonOpenCompute/llvm-project"
+distfiles="${homepage}/archive/rocm-ocl-${version}.tar.gz"
+checksum=a2bef7042e8e2f2cd8548cb246b88322e1c77188839983dcac8312d56f544dc8
+python_version=3
+nocross=yes
+
+post_install() {
+	vlicense LICENSE.TXT
+}
diff --git a/srcpkgs/ROCm-llvm/update b/srcpkgs/ROCm-llvm/update
new file mode 100644
index 00000000000..6a73667d3c1
--- /dev/null
+++ b/srcpkgs/ROCm-llvm/update
@@ -0,0 +1 @@
+pattern='rocm-ocl-\K[\d.]+'

From aa604d0df608b25b9a50cf64e84d4f9ea6c4df7a Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Tue, 14 Apr 2020 10:25:31 -0400
Subject: [PATCH 04/10] New package: ROCm-Device-Libs-3.3.0

---
 srcpkgs/ROCm-Device-Libs/template | 37 +++++++++++++++++++++++++++++++
 srcpkgs/ROCm-Device-Libs/update   |  1 +
 2 files changed, 38 insertions(+)
 create mode 100644 srcpkgs/ROCm-Device-Libs/template
 create mode 100644 srcpkgs/ROCm-Device-Libs/update

diff --git a/srcpkgs/ROCm-Device-Libs/template b/srcpkgs/ROCm-Device-Libs/template
new file mode 100644
index 00000000000..8086cd86450
--- /dev/null
+++ b/srcpkgs/ROCm-Device-Libs/template
@@ -0,0 +1,37 @@
+# Template file for 'ROCm-Device-Libs'
+pkgname=ROCm-Device-Libs
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="${pkgname}-rocm-ocl-${version}"
+build_style=cmake
+configure_args="-DLLVM_DIR:PATH=/usr/lib/rocm-llvm
+	-DCMAKE_INSTALL_LIBDIR:PATH=lib/rocm-device-libs"
+hostmakedepends="cmake ROCm-llvm"
+short_desc="Radeon Open Compute device libraries"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute/ROCm-Device-Libs"
+distfiles="${homepage}/archive/rocm-ocl-${version}.tar.gz"
+checksum=706b08230790e08ca6a7a2fb7687d6131fd39a562148340e00fa37a6c06769c5
+nocross=yes
+
+pre_configure() {
+	# Put bytecodes in a lib/ subdirectory
+	vsed -i Packages.cmake -e 's@/lib/@/${CMAKE_INSTALL_LIBDIR}/@'
+	vsed -i OCL.cmake -e 's@DESTINATION lib$@DESTINATION ${CMAKE_INSTALL_LIBDIR}@'
+
+	# Build the prepare-builtins executable with native compiler
+	mkdir -p utils/build
+	cd utils/build
+	_prepare_builtins="$PWD/prepare-builtins/prepare-builtins"
+	cmake ${configure_args} ..
+	make ${makejobs}
+
+	# Add path to prepare-builtins for cmake
+	configure_args+=" -DPREPARE_BUILTINS='${_prepare_builtins}'"
+}
+
+post_install() {
+	vlicense LICENSE
+}
diff --git a/srcpkgs/ROCm-Device-Libs/update b/srcpkgs/ROCm-Device-Libs/update
new file mode 100644
index 00000000000..6a73667d3c1
--- /dev/null
+++ b/srcpkgs/ROCm-Device-Libs/update
@@ -0,0 +1 @@
+pattern='rocm-ocl-\K[\d.]+'

From 12705d6d4d6d4c500ab7867ad5f79b2d63301a34 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Mon, 13 Apr 2020 18:30:00 -0400
Subject: [PATCH 05/10] New package: ROCm-CompilerSupport-3.3.0

---
 common/shlibs                         |  1 +
 srcpkgs/ROCm-CompilerSupport-devel    |  1 +
 srcpkgs/ROCm-CompilerSupport/template | 32 +++++++++++++++++++++++++++
 srcpkgs/ROCm-CompilerSupport/update   |  1 +
 4 files changed, 35 insertions(+)
 create mode 120000 srcpkgs/ROCm-CompilerSupport-devel
 create mode 100644 srcpkgs/ROCm-CompilerSupport/template
 create mode 100644 srcpkgs/ROCm-CompilerSupport/update

diff --git a/common/shlibs b/common/shlibs
index 46a83863bcd..42748d6c8bb 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3878,3 +3878,4 @@ libhidrd_fmt.so.0 hidrd-0.2.0_1
 libjcat.so.1 libjcat-0.1.2_1
 libhsakmt.so.1 ROCT-Thunk-Interface-3.3.0_1
 libhsa-runtime64.so.1 ROCR-Runtime-3.3.0_1
+libamd_comgr.so.1 ROCm-CompilerSupport-3.3.0_1
diff --git a/srcpkgs/ROCm-CompilerSupport-devel b/srcpkgs/ROCm-CompilerSupport-devel
new file mode 120000
index 00000000000..877aeafeeae
--- /dev/null
+++ b/srcpkgs/ROCm-CompilerSupport-devel
@@ -0,0 +1 @@
+ROCm-CompilerSupport
\ No newline at end of file
diff --git a/srcpkgs/ROCm-CompilerSupport/template b/srcpkgs/ROCm-CompilerSupport/template
new file mode 100644
index 00000000000..df56f7a3837
--- /dev/null
+++ b/srcpkgs/ROCm-CompilerSupport/template
@@ -0,0 +1,32 @@
+# Template file for 'ROCm-CompilerSupport'
+pkgname=ROCm-CompilerSupport
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="${pkgname}-rocm-${version}"
+build_wrksrc="lib/comgr"
+build_style=cmake
+configure_args="-DClang_DIR:PATH=/usr/lib/rocm-llvm/lib/cmake/clang"
+hostmakedepends="cmake pkg-config ROCm-llvm"
+makedepends="ROCm-Device-Libs"
+short_desc="Radeon Open Compute compiler support"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="BSD-3-Clause"
+homepage="https://github.com/RadeonOpenCompute/ROCm-CompilerSupport"
+distfiles="${homepage}/archive/rocm-${version}.tar.gz"
+checksum=01e2524e0f28ecd6f46c9720f279207de935d826b0172158792aa3ec86af9ca7
+nocross=yes
+
+post_install() {
+	vlicense LICENSE.txt
+}
+
+ROCm-CompilerSupport-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove "usr/lib/*.so"
+		vmove usr/lib/cmake
+	}
+}
diff --git a/srcpkgs/ROCm-CompilerSupport/update b/srcpkgs/ROCm-CompilerSupport/update
new file mode 100644
index 00000000000..86197bc3eea
--- /dev/null
+++ b/srcpkgs/ROCm-CompilerSupport/update
@@ -0,0 +1 @@
+pattern='rocm-\K[\d.]+'

From f3408c285cac4e5b99114688f107d80fef8cc00c Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Fri, 17 Apr 2020 12:11:25 -0400
Subject: [PATCH 06/10] New package: rocminfo-3.3.0

---
 srcpkgs/rocminfo/template | 22 ++++++++++++++++++++++
 srcpkgs/rocminfo/update   |  1 +
 2 files changed, 23 insertions(+)
 create mode 100644 srcpkgs/rocminfo/template
 create mode 100644 srcpkgs/rocminfo/update

diff --git a/srcpkgs/rocminfo/template b/srcpkgs/rocminfo/template
new file mode 100644
index 00000000000..7a075c7f7ac
--- /dev/null
+++ b/srcpkgs/rocminfo/template
@@ -0,0 +1,22 @@
+# Template file for 'rocminfo'
+pkgname=rocminfo
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="${pkgname}-rocm-${version}"
+build_style=cmake
+configure_args="-DROCM_DIR=/usr"
+hostmakedepends="cmake pkg-config"
+makedepends="ROCR-Runtime-devel"
+short_desc="Radeon Open Compute system information reporter"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute/rocminfo"
+distfiles="${homepage}/archive/rocm-${version}.tar.gz"
+checksum=e666f662c9e465aaabbbd0b109d87e017243cdf1a0898fabf5a90947bb3dbcd7
+nocross=yes
+python_version=3
+
+post_install() {
+	vlicense License.txt
+}
diff --git a/srcpkgs/rocminfo/update b/srcpkgs/rocminfo/update
new file mode 100644
index 00000000000..86197bc3eea
--- /dev/null
+++ b/srcpkgs/rocminfo/update
@@ -0,0 +1 @@
+pattern='rocm-\K[\d.]+'

From 9f45c89a0e4a841db58eec8dd5896cda1afccf9c Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Sun, 19 Apr 2020 15:01:40 -0400
Subject: [PATCH 07/10] New package: rocm_bandwidth_test-3.3.0

---
 srcpkgs/rocm_bandwidth_test/template | 20 ++++++++++++++++++++
 srcpkgs/rocm_bandwidth_test/update   |  1 +
 2 files changed, 21 insertions(+)
 create mode 100644 srcpkgs/rocm_bandwidth_test/template
 create mode 100644 srcpkgs/rocm_bandwidth_test/update

diff --git a/srcpkgs/rocm_bandwidth_test/template b/srcpkgs/rocm_bandwidth_test/template
new file mode 100644
index 00000000000..6de7f2d6614
--- /dev/null
+++ b/srcpkgs/rocm_bandwidth_test/template
@@ -0,0 +1,20 @@
+# Template file for 'rocm_bandwidth_test'
+pkgname=rocm_bandwidth_test
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="${pkgname}-rocm-${version}"
+build_style=cmake
+hostmakedepends="cmake"
+makedepends="ROCR-Runtime-devel ROCT-Thunk-Interface-devel"
+short_desc="Radeon Open Compute bandwidth test"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute/rocm_bandwidth_test"
+distfiles="${homepage}/archive/rocm-${version}.tar.gz"
+checksum=f5f914073018619dc91662d5bf630903dfa4db9136d603591917fdfb3c9164ce
+nocross=yes
+
+post_install() {
+	vlicense LICENSE.txt
+}
diff --git a/srcpkgs/rocm_bandwidth_test/update b/srcpkgs/rocm_bandwidth_test/update
new file mode 100644
index 00000000000..86197bc3eea
--- /dev/null
+++ b/srcpkgs/rocm_bandwidth_test/update
@@ -0,0 +1 @@
+pattern='rocm-\K[\d.]+'

From b298a879caf7a733ff4f491dc6175a17da80748f Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Tue, 14 Apr 2020 10:25:54 -0400
Subject: [PATCH 08/10] New package: ROCm-OpenCL-Runtime-3.3.0

---
 common/shlibs                                 |   2 +
 srcpkgs/ROCm-OpenCL-Runtime-clinfo            |   1 +
 srcpkgs/ROCm-OpenCL-Runtime-devel             |   1 +
 .../files/libelf-musl.patch                   |  21 +++
 .../files/runtime-musl.patch                  |  11 ++
 .../ROCm-OpenCL-Runtime/patches/cmake.patch   | 126 ++++++++++++++++++
 srcpkgs/ROCm-OpenCL-Runtime/template          |  84 ++++++++++++
 srcpkgs/ROCm-OpenCL-Runtime/update            |   1 +
 8 files changed, 247 insertions(+)
 create mode 120000 srcpkgs/ROCm-OpenCL-Runtime-clinfo
 create mode 120000 srcpkgs/ROCm-OpenCL-Runtime-devel
 create mode 100644 srcpkgs/ROCm-OpenCL-Runtime/files/libelf-musl.patch
 create mode 100644 srcpkgs/ROCm-OpenCL-Runtime/files/runtime-musl.patch
 create mode 100644 srcpkgs/ROCm-OpenCL-Runtime/patches/cmake.patch
 create mode 100644 srcpkgs/ROCm-OpenCL-Runtime/template
 create mode 100644 srcpkgs/ROCm-OpenCL-Runtime/update

diff --git a/common/shlibs b/common/shlibs
index 42748d6c8bb..0885a3759c5 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3879,3 +3879,5 @@ libjcat.so.1 libjcat-0.1.2_1
 libhsakmt.so.1 ROCT-Thunk-Interface-3.3.0_1
 libhsa-runtime64.so.1 ROCR-Runtime-3.3.0_1
 libamd_comgr.so.1 ROCm-CompilerSupport-3.3.0_1
+libOpenCL-ROCm.so.1 ROCm-OpenCL-Runtime-3.3.0_1
+libamdocl64.so ROCm-OpenCL-Runtime-3.3.0_1
diff --git a/srcpkgs/ROCm-OpenCL-Runtime-clinfo b/srcpkgs/ROCm-OpenCL-Runtime-clinfo
new file mode 120000
index 00000000000..21f2041b8fb
--- /dev/null
+++ b/srcpkgs/ROCm-OpenCL-Runtime-clinfo
@@ -0,0 +1 @@
+ROCm-OpenCL-Runtime
\ No newline at end of file
diff --git a/srcpkgs/ROCm-OpenCL-Runtime-devel b/srcpkgs/ROCm-OpenCL-Runtime-devel
new file mode 120000
index 00000000000..21f2041b8fb
--- /dev/null
+++ b/srcpkgs/ROCm-OpenCL-Runtime-devel
@@ -0,0 +1 @@
+ROCm-OpenCL-Runtime
\ No newline at end of file
diff --git a/srcpkgs/ROCm-OpenCL-Runtime/files/libelf-musl.patch b/srcpkgs/ROCm-OpenCL-Runtime/files/libelf-musl.patch
new file mode 100644
index 00000000000..29469a9a351
--- /dev/null
+++ b/srcpkgs/ROCm-OpenCL-Runtime/files/libelf-musl.patch
@@ -0,0 +1,21 @@
+--- compiler/lib/loaders/elf/utils/libelf/_libelf.h	2020-04-28 15:50:53.243438174 -0400
++++ compiler/lib/loaders/elf/utils/libelf/_libelf.h	2020-04-28 15:51:54.293435415 -0400
+@@ -35,6 +35,7 @@
+ #include "_libelf_config.h"
+ 
+ #include "_elftc.h"
++#include <sys/cdefs.h>
+ 
+ /*
+  * Library-private data structures.
+--- compiler/lib/loaders/elf/utils/libelf/libelf.h	2020-04-28 15:50:53.244438174 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf.h	2020-04-28 15:52:12.375434593 -0400
+@@ -36,6 +36,8 @@
+ #define EM_HSAIL 0xAF5A
+ #endif
+ 
++#include <sys/cdefs.h>
++
+ /* Library private data structures */
+ typedef struct _Elf Elf;
+ typedef struct _Elf_Scn Elf_Scn;
diff --git a/srcpkgs/ROCm-OpenCL-Runtime/files/runtime-musl.patch b/srcpkgs/ROCm-OpenCL-Runtime/files/runtime-musl.patch
new file mode 100644
index 00000000000..ea18e90e09c
--- /dev/null
+++ b/srcpkgs/ROCm-OpenCL-Runtime/files/runtime-musl.patch
@@ -0,0 +1,11 @@
+--- runtime/os/os_posix.cpp.orig	2020-04-19 09:13:51.701982901 -0400
++++ runtime/os/os_posix.cpp	2020-04-19 09:14:04.156947422 -0400
+@@ -44,6 +44,8 @@
+ #include <algorithm>
+ #include <mutex>
+ 
++#include <libgen.h> // for basename
++
+ 
+ namespace amd {
+ 
diff --git a/srcpkgs/ROCm-OpenCL-Runtime/patches/cmake.patch b/srcpkgs/ROCm-OpenCL-Runtime/patches/cmake.patch
new file mode 100644
index 00000000000..2c96b99d45a
--- /dev/null
+++ b/srcpkgs/ROCm-OpenCL-Runtime/patches/cmake.patch
@@ -0,0 +1,126 @@
+--- OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/CMakeLists.txt	2019-09-10 11:53:28.000000000 -0400
++++ OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/CMakeLists.txt	2020-04-16 20:16:13.481180757 -0400
+@@ -73,11 +73,11 @@
+ 
+ set (OPENCL_ICD_LOADER_HEADERS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/inc CACHE PATH "Path to OpenCL Headers")
+ 
+-add_library (OpenCL ${OPENCL_ICD_LOADER_SOURCES})
+-set_target_properties (OpenCL PROPERTIES VERSION "1.2" SOVERSION "1")
++add_library (OpenCL-ROCm ${OPENCL_ICD_LOADER_SOURCES})
++set_target_properties (OpenCL-ROCm PROPERTIES VERSION "1.2" SOVERSION "1")
+ 
+ if (WIN32)
+-    target_link_libraries (OpenCL cfgmgr32.lib)
++    target_link_libraries (OpenCL-ROCm cfgmgr32.lib)
+ 
+     option (OPENCL_ICD_LOADER_REQUIRE_WDK "Build with D3DKMT support, which requires the Windows WDK." ON)
+     if (OPENCL_ICD_LOADER_REQUIRE_WDK)
+@@ -92,10 +92,10 @@
+             get_filename_component(WDK_DIRECTORY ${LATEST_D3DKMT_HEADER} DIRECTORY)
+             get_filename_component(WDK_DIRECTORY ${WDK_DIRECTORY} DIRECTORY)
+             message(STATUS "Found the Windows WDK in: ${WDK_DIRECTORY}")
+-            target_compile_definitions(OpenCL PRIVATE OPENCL_ICD_LOADER_REQUIRE_WDK)
+-            target_include_directories(OpenCL PRIVATE ${WDK_DIRECTORY}/um)
+-            target_include_directories(OpenCL PRIVATE ${WDK_DIRECTORY}/km)
+-            target_include_directories(OpenCL PRIVATE ${WDK_DIRECTORY}/shared)
++	    target_compile_definitions(OpenCL-ROCm PRIVATE OPENCL_ICD_LOADER_REQUIRE_WDK)
++	    target_include_directories(OpenCL-ROCm PRIVATE ${WDK_DIRECTORY}/um)
++	    target_include_directories(OpenCL-ROCm PRIVATE ${WDK_DIRECTORY}/km)
++	    target_include_directories(OpenCL-ROCm PRIVATE ${WDK_DIRECTORY}/shared)
+         else()
+             message(FATAL_ERROR "The Windows WDK was not found. Consider disabling OPENCL_ICD_LOADER_REQUIRE_WDK. Aborting.")
+         endif()
+@@ -113,25 +113,25 @@
+     endif()
+ else()
+     if (APPLE)
+-        target_link_libraries (OpenCL ${CMAKE_THREAD_LIBS_INIT})
++        target_link_libraries (OpenCL-ROCm ${CMAKE_THREAD_LIBS_INIT})
+     else ()
+-        set_target_properties (OpenCL PROPERTIES LINK_FLAGS "-Wl,--version-script -Wl,${CMAKE_CURRENT_SOURCE_DIR}/loader/linux/icd_exports.map")
+-        target_link_libraries (OpenCL ${CMAKE_THREAD_LIBS_INIT})
++        set_target_properties (OpenCL-ROCm PROPERTIES LINK_FLAGS "-Wl,--version-script -Wl,${CMAKE_CURRENT_SOURCE_DIR}/loader/linux/icd_exports.map")
++	target_link_libraries (OpenCL-ROCm ${CMAKE_THREAD_LIBS_INIT})
+     endif ()
+ endif ()
+ 
+ include_directories (${OPENCL_ICD_LOADER_HEADERS_DIR})
+ add_definitions (-DCL_TARGET_OPENCL_VERSION=220)
+ 
+-target_include_directories (OpenCL PRIVATE ${CMAKE_CURRENT_BINARY_DIR} loader)
+-target_link_libraries (OpenCL ${CMAKE_DL_LIBS})
++target_include_directories (OpenCL-ROCm PRIVATE ${CMAKE_CURRENT_BINARY_DIR} loader)
++target_link_libraries (OpenCL-ROCm ${CMAKE_DL_LIBS})
+ 
+ include (CTest)
+ if (BUILD_TESTING)
+     add_subdirectory (test)
+ endif()
+ 
+-install (TARGETS OpenCL
++install (TARGETS OpenCL-ROCm
+     RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+     ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
+     LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
+--- OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/test/loader_test/CMakeLists.txt	2019-09-10 11:53:28.000000000 -0400
++++ OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/test/loader_test/CMakeLists.txt	2020-04-16 20:16:56.647026589 -0400
+@@ -12,4 +12,4 @@
+     test_clgl.c
+     test_image_objects.c )
+ 
+-target_link_libraries (icd_loader_test OpenCL IcdLog)
++target_link_libraries (icd_loader_test OpenCL-ROCm IcdLog)
+--- ROCm-OpenCL-Runtime-roc-3.3.0/CMakeLists.txt	2020-04-28 07:29:51.864446603 -0400
++++ ROCm-OpenCL-Runtime-roc-3.3.0/CMakeLists.txt	2020-04-28 07:32:45.245793180 -0400
+@@ -101,30 +101,30 @@
+ rocm_setup_version( VERSION "2.0.0" )
+ 
+ # MAIN package
+-install(PROGRAMS $<TARGET_FILE:clinfo>
+-        DESTINATION bin/x86_64
++install(PROGRAMS $<TARGET_FILE:rocm-clinfo>
++        DESTINATION bin
+         COMPONENT MAIN)
+ install(PROGRAMS $<TARGET_FILE:amdocl64>
+-        DESTINATION lib/x86_64
++        DESTINATION lib
+         COMPONENT MAIN)
+-install(PROGRAMS $<TARGET_FILE:OpenCL>
+-        DESTINATION lib/x86_64
++install(PROGRAMS $<TARGET_FILE:OpenCL-ROCm>
++        DESTINATION lib
+         COMPONENT MAIN)
+-install(PROGRAMS $<TARGET_SONAME_FILE:OpenCL>
+-        DESTINATION lib/x86_64
++install(PROGRAMS $<TARGET_SONAME_FILE:OpenCL-ROCm>
++        DESTINATION lib
+         COMPONENT MAIN)
+ 
+ # DEV package
+ install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/api/opencl/khronos/headers/opencl2.2/CL"
+-        DESTINATION include
++	DESTINATION include/rocm
+         COMPONENT DEV
+         USE_SOURCE_PERMISSIONS
+         PATTERN cl_d3d10.h EXCLUDE
+         PATTERN cl_d3d11.h EXCLUDE
+         PATTERN cl_dx9_media_sharing.h EXCLUDE
+         PATTERN cl_egl.h EXCLUDE)
+-install(PROGRAMS $<TARGET_LINKER_FILE:OpenCL>
+-        DESTINATION lib/x86_64
++install(PROGRAMS $<TARGET_LINKER_FILE:OpenCL-ROCm>
++        DESTINATION lib
+         COMPONENT DEV)
+ 
+ # Generic CPACK variables
+--- ROCm-OpenCL-Runtime-roc-3.3.0/tools/clinfo/CMakeLists.txt	2020-04-28 07:29:51.882446535 -0400
++++ ROCm-OpenCL-Runtime-roc-3.3.0/tools/clinfo/CMakeLists.txt	2020-04-28 07:30:05.627394732 -0400
+@@ -6,6 +6,6 @@
+ 
+ add_definitions(-DHAVE_CL2_HPP)
+ 
+-add_executable(clinfo clinfo.cpp)
++add_executable(rocm-clinfo clinfo.cpp)
+ 
+-target_link_libraries(clinfo OpenCL)
++target_link_libraries(rocm-clinfo OpenCL-ROCm)
diff --git a/srcpkgs/ROCm-OpenCL-Runtime/template b/srcpkgs/ROCm-OpenCL-Runtime/template
new file mode 100644
index 00000000000..f6699a1d4c0
--- /dev/null
+++ b/srcpkgs/ROCm-OpenCL-Runtime/template
@@ -0,0 +1,84 @@
+# Template file for 'ROCm-OpenCL-Runtime'
+pkgname=ROCm-OpenCL-Runtime
+version=3.3.0
+revision=1
+_ocl_icd_name="OpenCL-ICD-Loader"
+_ocl_icd_ver="6c03f8b58fafd9dd693eaac826749a5cfad515f8"
+archs="x86_64*"
+create_wrksrc=yes
+build_wrksrc="${pkgname}-roc-${version}"
+build_style=cmake
+configure_args="-DUSE_COMGR_LIBRARY=yes"
+hostmakedepends="cmake pkg-config"
+makedepends="libglvnd-devel ROCm-CompilerSupport-devel
+	ROCT-Thunk-Interface-devel ROCR-Runtime-devel"
+depends="ROCm-CompilerSupport"
+short_desc="Radeon Open Compute OpenCL runtime"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="MIT"
+homepage="https://github.com/RadeonOpenCompute/ROCm-OpenCL-Runtime"
+_rocroot="https://github.com/RadeonOpenCompute"
+distfiles="${_rocroot}/ROCm-OpenCL-Runtime/archive/roc-${version}.tar.gz
+	${_rocroot}/rocm-cmake/archive/rocm-${version}.tar.gz
+	https://github.com/KhronosGroup/${_ocl_icd_name}/archive/${_ocl_icd_ver}.tar.gz"
+checksum="ac6999f1a491ab066286c2bd6adf50f08f831286f56e267879f9f7eced22f98e
+	76ed3ee8e56cf3246011cf7723c2abda539e1136e7e7f6909bfa45d268b8644f
+	c94d5bb6dc980c4d41d73e2b81663a19aabe494e923e2d0eec72a4c95b318438"
+nocross=yes
+
+if [ "$XBPS_LIBC" = "musl" ]; then
+	makedepends+=" musl-legacy-compat"
+fi
+
+post_patch() {
+	if [ "$XBPS_LIBC" = "musl" ]; then
+		# Remove dependence on glibc
+		patch -Np0 < ${FILESDIR}/libelf-musl.patch
+		patch -Np0 < ${FILESDIR}/runtime-musl.patch
+		vsed -e '/glibc_functions.cpp/d' -i api/opencl/amdocl/CMakeLists.txt
+	fi
+}
+
+pre_configure() {
+	# ROCm requires a very specific Khronos ICD loader version in the tree
+	# Keep the ICD loader config in /etc/OpenCL/rocm-vendors to avoid conflicts
+	_ocl_icd_dir="${_ocl_icd_name}-${_ocl_icd_ver}"
+	ln -sf "${wrksrc}/${_ocl_icd_dir}" api/opencl/khronos/icd
+	vsed -i "${wrksrc}/${_ocl_icd_dir}/loader/icd_platform.h" \
+		-e 's@/etc/OpenCL/vendors/@/etc/OpenCL/rocm-vendors/@g'
+
+	# CMake modules probably not useful anywhere but for this build
+	ln -sf "${wrksrc}/rocm-cmake-rocm-${version}/share/rocm/cmake"/*.cmake cmake
+
+	# Fix the dlopen macro to point to versioned libamd_comgr shared object
+	vsed -i 'runtime/device/comgrctx.cpp' \
+		-e 's/\blibamd_comgr\(32\)\?.so\b/&.1/g'
+}
+
+post_install() {
+	vlicense License
+
+	# Create descriptor to allow the ICD loader to find the driver
+	vmkdir etc/OpenCL/rocm-vendors
+	echo "libamdocl64.so" > "${DESTDIR}/etc/OpenCL/rocm-vendors/amdocl64.icd"
+	vmkdir etc/OpenCL/vendors
+	ln -s ../../OpenCL/rocm-vendors/amdocl64.icd \
+		${DESTDIR}/etc/OpenCL/vendors/rocm-amdocl64.icd
+}
+
+ROCm-OpenCL-Runtime-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/lib/libOpenCL-ROCm.so
+		vmove usr/include
+	}
+}
+
+ROCm-OpenCL-Runtime-clinfo_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - clinfo"
+	pkg_install() {
+		vmove usr/bin/rocm-clinfo
+	}
+}
diff --git a/srcpkgs/ROCm-OpenCL-Runtime/update b/srcpkgs/ROCm-OpenCL-Runtime/update
new file mode 100644
index 00000000000..8385f4d1215
--- /dev/null
+++ b/srcpkgs/ROCm-OpenCL-Runtime/update
@@ -0,0 +1 @@
+pattern='roc-\K[\d.]+'

From 40fd881e665651d848b6489c3a0d11ea05865569 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Thu, 30 Apr 2020 13:11:12 -0400
Subject: [PATCH 09/10] New package: ROCR-Runtime-hsa-ext-3.3.0

---
 common/shlibs                         |  2 ++
 srcpkgs/ROCR-Runtime-hsa-ext-devel    |  1 +
 srcpkgs/ROCR-Runtime-hsa-ext/template | 43 +++++++++++++++++++++++++++
 srcpkgs/ROCR-Runtime-hsa-ext/update   |  2 ++
 4 files changed, 48 insertions(+)
 create mode 120000 srcpkgs/ROCR-Runtime-hsa-ext-devel
 create mode 100644 srcpkgs/ROCR-Runtime-hsa-ext/template
 create mode 100644 srcpkgs/ROCR-Runtime-hsa-ext/update

diff --git a/common/shlibs b/common/shlibs
index 0885a3759c5..a01e031c03b 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3881,3 +3881,5 @@ libhsa-runtime64.so.1 ROCR-Runtime-3.3.0_1
 libamd_comgr.so.1 ROCm-CompilerSupport-3.3.0_1
 libOpenCL-ROCm.so.1 ROCm-OpenCL-Runtime-3.3.0_1
 libamdocl64.so ROCm-OpenCL-Runtime-3.3.0_1
+libhsa-ext-image64.so.1 ROCR-Runtime-hsa-ext-3.3.0_1
+libhsa-runtime-tools64.so.1 ROCR-Runtime-hsa-ext-3.3.0_1
diff --git a/srcpkgs/ROCR-Runtime-hsa-ext-devel b/srcpkgs/ROCR-Runtime-hsa-ext-devel
new file mode 120000
index 00000000000..6ee1b14911b
--- /dev/null
+++ b/srcpkgs/ROCR-Runtime-hsa-ext-devel
@@ -0,0 +1 @@
+ROCR-Runtime-hsa-ext
\ No newline at end of file
diff --git a/srcpkgs/ROCR-Runtime-hsa-ext/template b/srcpkgs/ROCR-Runtime-hsa-ext/template
new file mode 100644
index 00000000000..235ae92146b
--- /dev/null
+++ b/srcpkgs/ROCR-Runtime-hsa-ext/template
@@ -0,0 +1,43 @@
+# Template file for 'ROCR-Runtime-hsa-ext'
+pkgname=ROCR-Runtime-hsa-ext
+version=3.3.0
+revision=1
+archs="x86_64"
+hostmakedepends="tar"
+short_desc="Radeon Open Compute HSA runtime extensions"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute"
+_hsa_deb="hsa-ext-rocr-dev_1.1.30300.0-rocm-rel-3.3-19-23fc088b_amd64.deb"
+distfiles="https://repo.radeon.com/rocm/apt/debian/pool/main/h/hsa-ext-rocr-dev/$_hsa_deb"
+checksum=6b44e286b395d946b865ec1f3cc546356396785ac1fde591d07af02d0aa7c25d
+repository=nonfree
+restricted=yes
+
+do_extract() {
+	ar x "${XBPS_SRCDISTDIR}/${pkgname}-${version}/${_hsa_deb}"
+	tar xvf data.tar.gz
+}
+
+do_install() {
+	_rocm_includes="opt/rocm-${version}/hsa/include"
+
+	vmkdir usr
+	vcopy opt/rocm-${version}/hsa/lib usr
+	vcopy "$_rocm_includes" usr
+
+	# Extract license from one of the header files
+	awk 'BEGIN{HEADER=0} /\/\//{HEADER=1; print $0;} /^[^/]/{if(HEADER==1) exit;}' \
+		< "${_rocm_includes}/hsa/amd_hsa_tools_interfaces.h" \
+		| sed 's@^///*\( \|$\)@@' > LICENSE
+	vlicense LICENSE
+}
+
+ROCR-Runtime-hsa-ext-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove "usr/lib/*.so"
+	}
+}
diff --git a/srcpkgs/ROCR-Runtime-hsa-ext/update b/srcpkgs/ROCR-Runtime-hsa-ext/update
new file mode 100644
index 00000000000..84252d2e3b8
--- /dev/null
+++ b/srcpkgs/ROCR-Runtime-hsa-ext/update
@@ -0,0 +1,2 @@
+site='https://repo.radeon.com/rocm/apt/debian/pool/main/h/'
+pattern='hsa-ext-rocr-dev\K[\d.]+'

From 70c828c4de28d76d456bbeb3f2d35d11fb1d0245 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Tue, 28 Apr 2020 13:33:46 -0400
Subject: [PATCH 10/10] hashcat: fix incompatibility with ROCm-OpenCL-Runtime
 [ci skip]

---
 srcpkgs/hashcat/patches/tmpdir.patch | 30 ++++++++++++++++++++++++++++
 srcpkgs/hashcat/template             |  5 +++--
 2 files changed, 33 insertions(+), 2 deletions(-)
 create mode 100644 srcpkgs/hashcat/patches/tmpdir.patch

diff --git a/srcpkgs/hashcat/patches/tmpdir.patch b/srcpkgs/hashcat/patches/tmpdir.patch
new file mode 100644
index 00000000000..c6aab72db16
--- /dev/null
+++ b/srcpkgs/hashcat/patches/tmpdir.patch
@@ -0,0 +1,30 @@
+diff --git src/folder.c src/folder.c
+index 0c313f31..e54910b1 100644
+--- src/folder.c
++++ src/folder.c
+@@ -462,9 +462,24 @@ int folder_config_init (hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const char *ins
+   {
+     char *tmp;
+ 
+-    hc_asprintf (&tmp, "TMP=%s", cpath_real);
++    #if defined (_POSIX)
++    // Setting TMP may break POSIX temporary directory semantics
++    // Fix it by setting the POSIX-ly correct TMPDIR if it is not already set
++    if (getenv ("TMPDIR") == NULL) {
++      if (getenv("TMP") != NULL) {
++        // TMP was specified in the environment, promote it to TMPDIR
++        hc_asprintf (&tmp, "TMPDIR=%s", getenv("TMP"));
++        putenv (tmp);
++        hcfree (tmp);
++      } else {
++        putenv ("TMPDIR=/tmp");
++      }
++    }
++    #endif
+ 
++    hc_asprintf (&tmp, "TMP=%s", cpath_real);
+     putenv (tmp);
++    hcfree (tmp);
+   }
+ 
+   #if defined (_WIN)
diff --git a/srcpkgs/hashcat/template b/srcpkgs/hashcat/template
index e982f99cebf..27e20fca294 100644
--- a/srcpkgs/hashcat/template
+++ b/srcpkgs/hashcat/template
@@ -1,7 +1,7 @@
 # Template file for 'hashcat'
 pkgname=hashcat
 version=5.1.0
-revision=2
+revision=3
 build_style=gnu-makefile
 make_build_args="PREFIX=/usr
  USE_SYSTEM_OPENCL=1 USE_SYSTEM_XXHASH=1
@@ -9,7 +9,7 @@ make_build_args="PREFIX=/usr
  DEPS_XXHASH_PATH=${XBPS_CROSS_BASE}/usr/include"
 make_use_env=yes
 make_install_args="$make_build_args"
-makedepends="gmp-devel opencl2-headers xxHash-devel"
+makedepends="gmp-devel xxHash-devel opencl2-headers"
 checkdepends="perl"
 short_desc="Advanced CPU-based password recovery utility"
 maintainer="Duncaen <duncaen@voidlinux.org>"
@@ -26,6 +26,7 @@ fi
 post_extract() {
 	sed '/^CC/d' -i src/Makefile
 }
+
 post_install() {
 	rm -f ${DESTDIR}/usr/share/docs/hashcat/license.txt
 	vlicense docs/license.txt

^ permalink raw reply	[flat|nested] 61+ messages in thread

* Re: New packages: ROCm core and OpenCL
  2020-04-19 13:34 [PR PATCH] New packages: ROCm core and OpenCL ahesford
                   ` (34 preceding siblings ...)
  2020-05-11 20:03 ` ahesford
@ 2020-05-14 18:04 ` FiCacador
  2020-05-14 18:04 ` FiCacador
                   ` (23 subsequent siblings)
  59 siblings, 0 replies; 61+ messages in thread
From: FiCacador @ 2020-05-14 18:04 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 906 bytes --]

New comment by FiCacador on void-packages repository

https://github.com/void-linux/void-packages/pull/21153#issuecomment-628798600

Comment:
@ericonr  @ahesford I hope some day ROCm OpenCL can actually supersede the OpenCL components of the amdgpu-pro proprietary driver, and kudos for this implementation, but right now and in the foreseeable future, as I can understand it, ROCm OpenCL has:
- Poor performance
- No support for navi10 GPUs (that released almost 1 year ago)
- No support for Vega integrated graphics on AMD's APUs
- Dependencies on outdated software
- Requires additional packages that aren't useful outside the ROCm ecosystem

So I don't think #13568 is irrelevant, although it is outdated, current version is 20.10. It's the solution I use on Manjaro from the AUR.

In the meantime I will keep dreaming about AMD open sourcing it's OpenCL driver and contributing it to mesa...

^ permalink raw reply	[flat|nested] 61+ messages in thread

* Re: New packages: ROCm core and OpenCL
  2020-04-19 13:34 [PR PATCH] New packages: ROCm core and OpenCL ahesford
                   ` (35 preceding siblings ...)
  2020-05-14 18:04 ` FiCacador
@ 2020-05-14 18:04 ` FiCacador
  2020-05-14 19:13 ` ahesford
                   ` (22 subsequent siblings)
  59 siblings, 0 replies; 61+ messages in thread
From: FiCacador @ 2020-05-14 18:04 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 907 bytes --]

New comment by FiCacador on void-packages repository

https://github.com/void-linux/void-packages/pull/21153#issuecomment-628798600

Comment:
@ericonr  @ahesford I hope some day ROCm OpenCL can actually supersede the OpenCL components of the amdgpu-pro proprietary driver, and kudos for this implementation, but right now and for the foreseeable future, as I can understand it, ROCm OpenCL has:
- Poor performance
- No support for navi10 GPUs (that released almost 1 year ago)
- No support for Vega integrated graphics on AMD's APUs
- Dependencies on outdated software
- Requires additional packages that aren't useful outside the ROCm ecosystem

So I don't think #13568 is irrelevant, although it is outdated, current version is 20.10. It's the solution I use on Manjaro from the AUR.

In the meantime I will keep dreaming about AMD open sourcing it's OpenCL driver and contributing it to mesa...

^ permalink raw reply	[flat|nested] 61+ messages in thread

* Re: New packages: ROCm core and OpenCL
  2020-04-19 13:34 [PR PATCH] New packages: ROCm core and OpenCL ahesford
                   ` (36 preceding siblings ...)
  2020-05-14 18:04 ` FiCacador
@ 2020-05-14 19:13 ` ahesford
  2020-05-14 19:14 ` ahesford
                   ` (21 subsequent siblings)
  59 siblings, 0 replies; 61+ messages in thread
From: ahesford @ 2020-05-14 19:13 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 531 bytes --]

New comment by ahesford on void-packages repository

https://github.com/void-linux/void-packages/pull/21153#issuecomment-628835201

Comment:
ROCm is far from perfect, but repurposing the closed-source libraries from amdgpu-pro is an uglier solution that is almost certain never to be permitted in the Void repo. This is really the only packagable solution for OpenCL on AMD hardware.

If you are going to use the amdgpu-pro OpenCL runtime, I think the cleaner approach is to follow what Gentoo does rather than the AUR approach.

^ permalink raw reply	[flat|nested] 61+ messages in thread

* Re: New packages: ROCm core and OpenCL
  2020-04-19 13:34 [PR PATCH] New packages: ROCm core and OpenCL ahesford
                   ` (37 preceding siblings ...)
  2020-05-14 19:13 ` ahesford
@ 2020-05-14 19:14 ` ahesford
  2020-05-14 22:51 ` FiCacador
                   ` (20 subsequent siblings)
  59 siblings, 0 replies; 61+ messages in thread
From: ahesford @ 2020-05-14 19:14 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 529 bytes --]

New comment by ahesford on void-packages repository

https://github.com/void-linux/void-packages/pull/21153#issuecomment-628835201

Comment:
ROCm is far from perfect, but repurposing the closed-source libraries from amdgpu-pro is an uglier solution that is almost certain never to be permitted in the Void repo. This is really the only packagable solution for OpenCL on AMD hardware.

If you are going to use the amdgpu-pro OpenCL runtime, I think the cleaner approach is to follow what Gentoo does rather than the AUR method.

^ permalink raw reply	[flat|nested] 61+ messages in thread

* Re: New packages: ROCm core and OpenCL
  2020-04-19 13:34 [PR PATCH] New packages: ROCm core and OpenCL ahesford
                   ` (38 preceding siblings ...)
  2020-05-14 19:14 ` ahesford
@ 2020-05-14 22:51 ` FiCacador
  2020-05-15  0:07 ` ahesford
                   ` (19 subsequent siblings)
  59 siblings, 0 replies; 61+ messages in thread
From: FiCacador @ 2020-05-14 22:51 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1376 bytes --]

New comment by FiCacador on void-packages repository

https://github.com/void-linux/void-packages/pull/21153#issuecomment-628926306

Comment:
It's not repurposing, it's installing only part of the components. The same can be done on Debian based distros, just install the necessary .debs for OpenCL to work. Or better yet, [the installer has options to install only the OpenCL components](https://math.dartmouth.edu/~sarunas/amdgpu.html).

Is it wrong to add a package that corresponds to one possible installation?
What if those necessary components are added individually, with dependencies (like AUR's [opencl-amdgpu-pro-pal](https://aur.archlinux.org/packages/opencl-amdgpu-pro-pal))?

Both approaches are in the AUR, and both work.
I just checked the [Gentoo wiki](https://wiki.gentoo.org/wiki/OpenCL#AMD), it mentions [dev-libs/amdgpu-pro-opencl](https://gitweb.gentoo.org/repo/gentoo.git/tree/dev-libs/amdgpu-pro-opencl/amdgpu-pro-opencl-19.30.838629.ebuild), doesn't look too different to me from AUR's [opencl-amd](https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=opencl-amd).

All I'm trying to defend is that there is no reason for ROCm-OpenCL-Runtime and opencl-amdgpu-pro to supersede one another. One can keep a system open source, the other has better hardware support and performance. On an APU with iGPU or a navi GPU ROCm isn't even an option.

^ permalink raw reply	[flat|nested] 61+ messages in thread

* Re: New packages: ROCm core and OpenCL
  2020-04-19 13:34 [PR PATCH] New packages: ROCm core and OpenCL ahesford
                   ` (39 preceding siblings ...)
  2020-05-14 22:51 ` FiCacador
@ 2020-05-15  0:07 ` ahesford
  2020-05-15  1:30 ` fosslinux
                   ` (18 subsequent siblings)
  59 siblings, 0 replies; 61+ messages in thread
From: ahesford @ 2020-05-15  0:07 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1512 bytes --]

New comment by ahesford on void-packages repository

https://github.com/void-linux/void-packages/pull/21153#issuecomment-628949696

Comment:
The AUR uses `sed` to patch the binary AMD ICD to look for a renamed version of the proprietary backend driver, a fragile hack that could be prone to breakage if the string being replaced has other interpretations in the library. We don't know because we can't see the source. Gentoo uses `patchelf` to adjust the RPATH of the OpenCL ICD to prefer the backend driver as originally named by AMD, placed in a location that won't conflict with system libraries. This is a much more reliable method because the ELF format and method for specifying RPATH are well defined.

Void has standards for packaging that prohibit inclusion of amdgpu-pro as either Gentoo or the AUR do. Both methods of altering amdgpu-pro expressly violate the [AMD EULA](https://www.amd.com/en/support/gpu-pro-eula) and, as such, are almost certain never to be allowed in the repos, even as a restricted, non-free package.

I won't say you shouldn't adapt the AMD software as you see fit to make it work with your hardware and operating environment. I won't even dispute that the amdgpu-pro runtime offers some advantages over ROCm. However, in the context of Void packaging, I have high confidence that an OpenCL implementation based on amdgpu-pro will never be allowed in the repo. ROCm is not subject to the same restrictions and, as such, supersedes amdgpu-pro as the only packageable option.

^ permalink raw reply	[flat|nested] 61+ messages in thread

* Re: New packages: ROCm core and OpenCL
  2020-04-19 13:34 [PR PATCH] New packages: ROCm core and OpenCL ahesford
                   ` (40 preceding siblings ...)
  2020-05-15  0:07 ` ahesford
@ 2020-05-15  1:30 ` fosslinux
  2020-05-15  3:31 ` FiCacador
                   ` (17 subsequent siblings)
  59 siblings, 0 replies; 61+ messages in thread
From: fosslinux @ 2020-05-15  1:30 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 407 bytes --]

New comment by fosslinux on void-packages repository

https://github.com/void-linux/void-packages/pull/21153#issuecomment-628972536

Comment:
Of course, there is also nothing stopping you from packaging it for XBPS, distributing it in a void-packages fork, bearing any issues that may occur. That way you can locally install it on your system even though it doesn't adhere to void's packaging requirements.

^ permalink raw reply	[flat|nested] 61+ messages in thread

* Re: New packages: ROCm core and OpenCL
  2020-04-19 13:34 [PR PATCH] New packages: ROCm core and OpenCL ahesford
                   ` (41 preceding siblings ...)
  2020-05-15  1:30 ` fosslinux
@ 2020-05-15  3:31 ` FiCacador
  2020-05-15  3:32 ` FiCacador
                   ` (16 subsequent siblings)
  59 siblings, 0 replies; 61+ messages in thread
From: FiCacador @ 2020-05-15  3:31 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 702 bytes --]

New comment by FiCacador on void-packages repository

https://github.com/void-linux/void-packages/pull/21153#issuecomment-629006070

Comment:
@ahesford thank you for the explanation. I'm not sure if there is a violation (by the repo) if no binary is distributed and the package is built at the user's end, but either way, Void packaging has rules and I understand that. I won't keep expecting the possibility of an opencl-amd package on Void anymore and keep an eye on this. Again, thank you.

@fosslinux there is also nothing pushing me to replace Manjaro on my main system that works well for me and keep using Void only on my 10 year old laptop. Which is ok, that's the beauty of Linux after all.

^ permalink raw reply	[flat|nested] 61+ messages in thread

* Re: New packages: ROCm core and OpenCL
  2020-04-19 13:34 [PR PATCH] New packages: ROCm core and OpenCL ahesford
                   ` (42 preceding siblings ...)
  2020-05-15  3:31 ` FiCacador
@ 2020-05-15  3:32 ` FiCacador
  2020-05-15  6:54 ` fosslinux
                   ` (15 subsequent siblings)
  59 siblings, 0 replies; 61+ messages in thread
From: FiCacador @ 2020-05-15  3:32 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 709 bytes --]

New comment by FiCacador on void-packages repository

https://github.com/void-linux/void-packages/pull/21153#issuecomment-629006070

Comment:
@ahesford thank you for the explanation. I'm not sure if there is a violation (by the repo) if no binary is distributed and the package is built at the user's end, but either way, Void packaging has rules and I understand that. I won't keep expecting the possibility of an opencl-amd package on Void anymore and I will keep an eye on this. Again, thank you.

@fosslinux there is also nothing pushing me to replace Manjaro on my main system that works well for me and keep using Void only on my 10 year old laptop. Which is ok, that's the beauty of Linux after all.

^ permalink raw reply	[flat|nested] 61+ messages in thread

* Re: New packages: ROCm core and OpenCL
  2020-04-19 13:34 [PR PATCH] New packages: ROCm core and OpenCL ahesford
                   ` (43 preceding siblings ...)
  2020-05-15  3:32 ` FiCacador
@ 2020-05-15  6:54 ` fosslinux
  2020-08-04 17:13 ` [PR PATCH] [Updated] " ahesford
                   ` (14 subsequent siblings)
  59 siblings, 0 replies; 61+ messages in thread
From: fosslinux @ 2020-05-15  6:54 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 271 bytes --]

New comment by fosslinux on void-packages repository

https://github.com/void-linux/void-packages/pull/21153#issuecomment-629064535

Comment:
@FiCacador Nope, there isn't, and I don't see how that is relevant to my point. I don't have any problem with you using Manjaro!

^ permalink raw reply	[flat|nested] 61+ messages in thread

* Re: [PR PATCH] [Updated] New packages: ROCm core and OpenCL
  2020-04-19 13:34 [PR PATCH] New packages: ROCm core and OpenCL ahesford
                   ` (44 preceding siblings ...)
  2020-05-15  6:54 ` fosslinux
@ 2020-08-04 17:13 ` ahesford
  2020-08-04 17:13 ` ahesford
                   ` (13 subsequent siblings)
  59 siblings, 0 replies; 61+ messages in thread
From: ahesford @ 2020-08-04 17:13 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 3893 bytes --]

There is an updated pull request by ahesford against master on the void-packages repository

https://github.com/ahesford/void-packages rocm
https://github.com/void-linux/void-packages/pull/21153

New packages: ROCm core and OpenCL
This PR includes several packages designed to bring the OpenCL portion of the AMD ROCm ecosystem to Void. It addresses Issue #19507. There are many other packages that AMD provides for GPGPU computing, but these can be added piecemeal as users demand.

The packages are currently only for `x86_64*`. While at least some of the packages will compile on other 64-bit architectures, I have no hardware to test. They are certainly not suitable for 32-bit architectures; some internal data structures rely on `uint64_t` values that are cast to pointers. At a
minimum, a thorough audit would be necessary to ensure that these casts are safe (e.g., that the values stored were only ever upcast from 32-bit pointers). More extensive work may be necessary to support 32-bit architectures, probably without significant benefit.

The packages successfully identify a Radeon RX 580 on an `x86_64` installation using both `clinfo` and `rocminfo` as provided. Furthermore, a version of `pyopencl` linked against these ROCm packages successfully runs a simple program that validates arithmetic on GPU-bound arrays.

There are caveats with this set of packages, almost all of which revolve around the incompatibilities between the Void-provided `ocl-icd` and the [Khronos OpenCL ICD loader](https://github.com/KhronosGroup/OpenCL-ID-Loader) required by (and built into) `rocm-opencl-runtime`.
1. All packages install into `/opt/rocm`. This keeps the environment closer to that officially sanctioned by AMD and helps avoid conflicts between other packages and those provided here. (For example, `clinfo` and the ICD loader itself.) Eventually, we may be able to move the files into `/usr`.
2. The Khronos OpenCL ICD loader built into `rocm-opencl-runtime` is an outdated, pre-release commit. If AMD can update its sources to use the release version of that loader (which has a backward-incompatible API change), we may be able to make ROCm compatible with `ocl-icd` or replace `ocl-icd` with the official Khronos loader.
3. In the meantime, to avoid `shlibs` conflicts, the OpenCL ICD loader is installed as `/opt/rocm/lib/libOpenCL-ROCm.so` (and an appropriately versioned shared library), which means that programs wishing to use the ROCm OpenCL must explicitly link against this library instead of the generic `libOpenCL.so`.
4. I do **not** recommend making any Void packages link against this specific library, because it will make those packages ROCm-only. For the time being, ROCm is intended for end-users to specifically link against. Linking Void packages against ROCm would requires the ICD loader used by ROCm be compatible with `ocl-icd`, or `ocl-icd` be replaced by the Khronos loader. However, because the Khronos loader changed its API for the release version, such a change is not yet appropriate.

Hopefully, if AMD updates its dependence on the Khronos ICD loader, we can resolve some of these caveats in the future and make ROCm a more natural Void component. For now, these packages are useful for those who need an AMD OpenCL solution and would rather custom-link software against the AMD ICD loader than hack the `amdgpu-pro` driver into an ICD compatible with `ocl-icd`.

Some patches were made to relocate some files in `/opt/rocm` and make everyting build on x86_64-musl`. Where appropriate, these patches will be pushed upstream to clean up the distribution and packaging.

Update: I pushed some new commits to update license information that triggerd an `xlint` failure. I've also disabled CI builds because they will time out on `rocm-llvm`.

A patch file from https://github.com/void-linux/void-packages/pull/21153.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-rocm-21153.patch --]
[-- Type: text/x-diff, Size: 35429 bytes --]

From 5cbdcb738fa646996cbf8e119465300742bca327 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Mon, 13 Apr 2020 13:08:09 -0400
Subject: [PATCH 1/9] New package: ROCT-Thunk-Interface-3.3.0

---
 common/shlibs                                 |  1 +
 srcpkgs/ROCT-Thunk-Interface-devel            |  1 +
 .../patches/cmake-dev-libdir.patch            | 10 ++++++
 .../ROCT-Thunk-Interface/patches/musl.patch   | 29 ++++++++++++++++
 srcpkgs/ROCT-Thunk-Interface/template         | 33 +++++++++++++++++++
 srcpkgs/ROCT-Thunk-Interface/update           |  1 +
 6 files changed, 75 insertions(+)
 create mode 120000 srcpkgs/ROCT-Thunk-Interface-devel
 create mode 100644 srcpkgs/ROCT-Thunk-Interface/patches/cmake-dev-libdir.patch
 create mode 100644 srcpkgs/ROCT-Thunk-Interface/patches/musl.patch
 create mode 100644 srcpkgs/ROCT-Thunk-Interface/template
 create mode 100644 srcpkgs/ROCT-Thunk-Interface/update

diff --git a/common/shlibs b/common/shlibs
index dcb1d8e54b6..4f93db41216 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3981,3 +3981,4 @@ libcglm.so.0 cglm-0.7.6_1
 libfcft.so.3 fcft-2.2.2_1
 libaml.so.0 aml-0.1.0_1
 libneatvnc.so.0 neatvnc-0.2.0_1
+libhsakmt.so.1 ROCT-Thunk-Interface-3.3.0_1
diff --git a/srcpkgs/ROCT-Thunk-Interface-devel b/srcpkgs/ROCT-Thunk-Interface-devel
new file mode 120000
index 00000000000..7e43c209e3d
--- /dev/null
+++ b/srcpkgs/ROCT-Thunk-Interface-devel
@@ -0,0 +1 @@
+ROCT-Thunk-Interface
\ No newline at end of file
diff --git a/srcpkgs/ROCT-Thunk-Interface/patches/cmake-dev-libdir.patch b/srcpkgs/ROCT-Thunk-Interface/patches/cmake-dev-libdir.patch
new file mode 100644
index 00000000000..98c7f1e459c
--- /dev/null
+++ b/srcpkgs/ROCT-Thunk-Interface/patches/cmake-dev-libdir.patch
@@ -0,0 +1,10 @@
+--- CMakeLists.txt.old	2020-04-18 19:45:17.306081135 -0400
++++ CMakeLists.txt	2020-04-18 19:46:51.300753636 -0400
+@@ -146,6 +146,7 @@
+     COMMAND ${CMAKE_COMMAND}
+         -DSOURCE_DIR="${SOURCE_DIR}"
+         -DCMAKE_INSTALL_PREFIX="${CMAKE_INSTALL_PREFIX}"
++        -DCMAKE_INSTALL_LIBDIR="${CMAKE_INSTALL_LIBDIR}"
+         -DCPACK_RPM_PACKAGE_REQUIRES="hsakmt-roct"
+         -DCPACK_PACKAGING_INSTALL_PREFIX="${CPACK_PACKAGING_INSTALL_PREFIX}"
+         -DVERSION="${BUILD_VERSION_STRING}"
diff --git a/srcpkgs/ROCT-Thunk-Interface/patches/musl.patch b/srcpkgs/ROCT-Thunk-Interface/patches/musl.patch
new file mode 100644
index 00000000000..aeea9832411
--- /dev/null
+++ b/srcpkgs/ROCT-Thunk-Interface/patches/musl.patch
@@ -0,0 +1,29 @@
+diff -r -u old/src/libhsakmt.h new/src/libhsakmt.h
+--- src/libhsakmt.h	2020-03-04 15:00:47.000000000 -0500
++++ src/libhsakmt.h	2020-04-13 12:58:30.444865992 -0400
+@@ -54,6 +54,10 @@
+ #define CHECK_KFD_OPEN() \
+ 	do { if (kfd_open_count == 0 || hsakmt_forked) return HSAKMT_STATUS_KERNEL_IO_CHANNEL_NOT_OPENED; } while (0)
+ 
++/*On some platforms, a PAGE_SIZE macro eclipses the extern variable*/
++#ifdef PAGE_SIZE
++#undef PAGE_SIZE
++#endif
+ extern int PAGE_SIZE;
+ extern int PAGE_SHIFT;
+ 
+diff -r -u old/src/topology.c new/src/topology.c
+--- src/topology.c	2020-03-04 15:00:47.000000000 -0500
++++ src/topology.c	2020-04-13 13:01:31.209870701 -0400
+@@ -38,6 +38,11 @@
+ #include "libhsakmt.h"
+ #include "fmm.h"
+ 
++/*Needed on MUSL*/
++#ifndef MAXNAMLEN
++#define MAXNAMLEN PATH_MAX
++#endif
++
+ /* Number of memory banks added by thunk on top of topology
+  * This only includes static heaps like LDS, scratch and SVM,
+  * not for MMIO_REMAP heap. MMIO_REMAP memory bank is reported
diff --git a/srcpkgs/ROCT-Thunk-Interface/template b/srcpkgs/ROCT-Thunk-Interface/template
new file mode 100644
index 00000000000..8c680b2af29
--- /dev/null
+++ b/srcpkgs/ROCT-Thunk-Interface/template
@@ -0,0 +1,33 @@
+# Template file for 'ROCT-Thunk-Interface'
+pkgname=ROCT-Thunk-Interface
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="${pkgname}-roc-${version}"
+build_style=cmake
+make_build_target="all build-dev"
+make_install_target="install install-dev"
+hostmakedepends="cmake pkg-config"
+makedepends="pciutils-devel libnuma-devel"
+short_desc="Radeon Open Compute thunk interface"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="MIT"
+homepage="https://github.com/RadeonOpenCompute/ROCT-Thunk-Interface"
+distfiles="${homepage}/archive/roc-${version}.tar.gz"
+checksum=2cabe9d2cfa72031c05d11290837c476182e72d8dec2049298f691143fdd212b
+nocross=yes
+
+post_install() {
+	vlicense LICENSE.md
+}
+
+ROCT-Thunk-Interface-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove "usr/lib/*.so"
+		vmove usr/share/pkgconfig
+		vmove usr/lib/cmake
+	}
+}
diff --git a/srcpkgs/ROCT-Thunk-Interface/update b/srcpkgs/ROCT-Thunk-Interface/update
new file mode 100644
index 00000000000..8385f4d1215
--- /dev/null
+++ b/srcpkgs/ROCT-Thunk-Interface/update
@@ -0,0 +1 @@
+pattern='roc-\K[\d.]+'

From 8738399f72c96ba594d928abc2c165da2cc0772b Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Mon, 13 Apr 2020 15:27:27 -0400
Subject: [PATCH 2/9] New package: ROCR-Runtime-3.3.0

---
 common/shlibs                            |  1 +
 srcpkgs/ROCR-Runtime-devel               |  1 +
 srcpkgs/ROCR-Runtime/patches/cmake.patch | 27 +++++++++++++++++++++
 srcpkgs/ROCR-Runtime/template            | 30 ++++++++++++++++++++++++
 srcpkgs/ROCR-Runtime/update              |  1 +
 5 files changed, 60 insertions(+)
 create mode 120000 srcpkgs/ROCR-Runtime-devel
 create mode 100644 srcpkgs/ROCR-Runtime/patches/cmake.patch
 create mode 100644 srcpkgs/ROCR-Runtime/template
 create mode 100644 srcpkgs/ROCR-Runtime/update

diff --git a/common/shlibs b/common/shlibs
index 4f93db41216..944ab37c190 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3982,3 +3982,4 @@ libfcft.so.3 fcft-2.2.2_1
 libaml.so.0 aml-0.1.0_1
 libneatvnc.so.0 neatvnc-0.2.0_1
 libhsakmt.so.1 ROCT-Thunk-Interface-3.3.0_1
+libhsa-runtime64.so.1 ROCR-Runtime-3.3.0_1
diff --git a/srcpkgs/ROCR-Runtime-devel b/srcpkgs/ROCR-Runtime-devel
new file mode 120000
index 00000000000..a733fb9fbab
--- /dev/null
+++ b/srcpkgs/ROCR-Runtime-devel
@@ -0,0 +1 @@
+ROCR-Runtime
\ No newline at end of file
diff --git a/srcpkgs/ROCR-Runtime/patches/cmake.patch b/srcpkgs/ROCR-Runtime/patches/cmake.patch
new file mode 100644
index 00000000000..93b74cd2297
--- /dev/null
+++ b/srcpkgs/ROCR-Runtime/patches/cmake.patch
@@ -0,0 +1,27 @@
+--- src/CMakeLists.txt.old	2020-04-18 20:01:48.549636995 -0400
++++ src/CMakeLists.txt	2020-04-18 20:04:00.177179781 -0400
+@@ -108,8 +108,8 @@
+ ## ROCr build internal versioning
+ add_definitions ( -DROCR_BUILD_ID=${PACKAGE_VERSION_STRING} )
+ 
+-## Set RUNPATH - ../../lib covers use of the legacy symlink in /hsa/lib/
+-set(CMAKE_INSTALL_RPATH "$ORIGIN;$ORIGIN/../../lib;$ORIGIN/../../lib64;$ORIGIN/../lib64")
++## Set RUNPATH
++set(CMAKE_INSTALL_RPATH "$ORIGIN;$ORIGIN/../lib")
+ 
+ ## ------------------------- Linux Compiler and Linker options -------------------------
+ set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -fexceptions -fno-rtti -fvisibility=hidden -Wno-error=sign-compare -Wno-sign-compare -Wno-write-strings -Wno-conversion-null -fno-math-errno -fno-threadsafe-statics -fmerge-all-constants -fms-extensions -Wno-error=comment -Wno-comment -Wno-error=pointer-arith -Wno-pointer-arith -Wno-error=unused-variable -Wno-error=unused-function" )
+@@ -185,11 +185,8 @@
+ add_custom_target ( hsa_lib_link2 ALL WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMAND ${CMAKE_COMMAND} -E create_symlink ../hsa/lib/${CORE_RUNTIME_LIBRARY}.so.${SO_MAJOR} ${CORE_RUNTIME_LIBRARY}-link.so.${SO_MAJOR} )
+ 
+ ## Set install information
+-install ( TARGETS ${CORE_RUNTIME_TARGET} LIBRARY DESTINATION hsa/lib )
+-install ( DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/inc/ DESTINATION hsa/include/hsa )
+-install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/hsa_include_link DESTINATION include PERMISSIONS OWNER_WRITE OWNER_READ RENAME hsa )
+-install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/${CORE_RUNTIME_LIBRARY}-link.so DESTINATION lib PERMISSIONS OWNER_WRITE OWNER_READ RENAME ${CORE_RUNTIME_LIBRARY}.so )
+-install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/${CORE_RUNTIME_LIBRARY}-link.so.${SO_MAJOR} DESTINATION lib PERMISSIONS OWNER_WRITE OWNER_READ RENAME ${CORE_RUNTIME_LIBRARY}.so.${SO_MAJOR} )
++install ( TARGETS ${CORE_RUNTIME_TARGET} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} )
++install ( DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/inc/ DESTINATION include/hsa )
+ 
+ ## Packaging directives
+ set ( CPACK_GENERATOR "DEB;RPM" CACHE STRING "Package types to build")
diff --git a/srcpkgs/ROCR-Runtime/template b/srcpkgs/ROCR-Runtime/template
new file mode 100644
index 00000000000..95b7e701afb
--- /dev/null
+++ b/srcpkgs/ROCR-Runtime/template
@@ -0,0 +1,30 @@
+# Template file for 'ROCR-Runtime'
+pkgname=ROCR-Runtime
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="${pkgname}-rocm-${version}"
+build_wrksrc="src"
+build_style=cmake
+hostmakedepends="cmake pkg-config"
+makedepends="ROCT-Thunk-Interface-devel elfutils-devel"
+short_desc="Radeon Open Compute HSA runtime"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute/ROCR-Runtime"
+distfiles="${homepage}/archive/rocm-${version}.tar.gz"
+checksum=fa2d2d1f8a61d8a6952d377cf288d78c61776c3c2a666f163cafc3aa19ab0b61
+nocross=yes
+
+post_install() {
+	vlicense ../LICENSE.txt
+}
+
+ROCR-Runtime-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove "usr/lib/*.so"
+	}
+}
diff --git a/srcpkgs/ROCR-Runtime/update b/srcpkgs/ROCR-Runtime/update
new file mode 100644
index 00000000000..86197bc3eea
--- /dev/null
+++ b/srcpkgs/ROCR-Runtime/update
@@ -0,0 +1 @@
+pattern='rocm-\K[\d.]+'

From 0ee0f3f609c9c3743099173482d2c4a26a045b1f Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Mon, 13 Apr 2020 18:07:34 -0400
Subject: [PATCH 3/9] New package: ROCm-llvm-3.3.0

---
 srcpkgs/ROCm-llvm/template | 26 ++++++++++++++++++++++++++
 srcpkgs/ROCm-llvm/update   |  1 +
 2 files changed, 27 insertions(+)
 create mode 100644 srcpkgs/ROCm-llvm/template
 create mode 100644 srcpkgs/ROCm-llvm/update

diff --git a/srcpkgs/ROCm-llvm/template b/srcpkgs/ROCm-llvm/template
new file mode 100644
index 00000000000..4c3095b21f4
--- /dev/null
+++ b/srcpkgs/ROCm-llvm/template
@@ -0,0 +1,26 @@
+# Template file for 'ROCm-llvm'
+pkgname=ROCm-llvm
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="llvm-project-rocm-ocl-${version}"
+build_wrksrc=llvm
+build_style=cmake
+configure_args="-DCMAKE_INSTALL_PREFIX:PATH=/usr/lib/rocm-llvm
+	-DLLVM_ENABLE_PROJECTS='llvm;clang;lld' -DLLVM_TARGETS_TO_BUILD='AMDGPU'
+	-DLLVM_BUILD_DOCS=NO -DLLVM_ENABLE_OCAMLDOC=OFF
+	-DLLVM_ENABLE_SPHINX=NO -DLLVM_ENABLE_DOXYGEN=OFF
+	-DLLVM_INSTALL_UTILS=ON -DLLVM_VERSION_SUFFIX=roc -DOCAMLFIND=NO"
+hostmakedepends="cmake pkg-config python3"
+short_desc="Radeon Open Compute LLVM toolchain"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="Apache-2.0, NCSA, custom:LLVM-Exceptions"
+homepage="https://github.com/RadeonOpenCompute/llvm-project"
+distfiles="${homepage}/archive/rocm-ocl-${version}.tar.gz"
+checksum=a2bef7042e8e2f2cd8548cb246b88322e1c77188839983dcac8312d56f544dc8
+python_version=3
+nocross=yes
+
+post_install() {
+	vlicense LICENSE.TXT
+}
diff --git a/srcpkgs/ROCm-llvm/update b/srcpkgs/ROCm-llvm/update
new file mode 100644
index 00000000000..6a73667d3c1
--- /dev/null
+++ b/srcpkgs/ROCm-llvm/update
@@ -0,0 +1 @@
+pattern='rocm-ocl-\K[\d.]+'

From 7d6f1904eed5b3c2a8eff961859916d886c4eefb Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Tue, 14 Apr 2020 10:25:31 -0400
Subject: [PATCH 4/9] New package: ROCm-Device-Libs-3.3.0

---
 srcpkgs/ROCm-Device-Libs/template | 37 +++++++++++++++++++++++++++++++
 srcpkgs/ROCm-Device-Libs/update   |  1 +
 2 files changed, 38 insertions(+)
 create mode 100644 srcpkgs/ROCm-Device-Libs/template
 create mode 100644 srcpkgs/ROCm-Device-Libs/update

diff --git a/srcpkgs/ROCm-Device-Libs/template b/srcpkgs/ROCm-Device-Libs/template
new file mode 100644
index 00000000000..8086cd86450
--- /dev/null
+++ b/srcpkgs/ROCm-Device-Libs/template
@@ -0,0 +1,37 @@
+# Template file for 'ROCm-Device-Libs'
+pkgname=ROCm-Device-Libs
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="${pkgname}-rocm-ocl-${version}"
+build_style=cmake
+configure_args="-DLLVM_DIR:PATH=/usr/lib/rocm-llvm
+	-DCMAKE_INSTALL_LIBDIR:PATH=lib/rocm-device-libs"
+hostmakedepends="cmake ROCm-llvm"
+short_desc="Radeon Open Compute device libraries"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute/ROCm-Device-Libs"
+distfiles="${homepage}/archive/rocm-ocl-${version}.tar.gz"
+checksum=706b08230790e08ca6a7a2fb7687d6131fd39a562148340e00fa37a6c06769c5
+nocross=yes
+
+pre_configure() {
+	# Put bytecodes in a lib/ subdirectory
+	vsed -i Packages.cmake -e 's@/lib/@/${CMAKE_INSTALL_LIBDIR}/@'
+	vsed -i OCL.cmake -e 's@DESTINATION lib$@DESTINATION ${CMAKE_INSTALL_LIBDIR}@'
+
+	# Build the prepare-builtins executable with native compiler
+	mkdir -p utils/build
+	cd utils/build
+	_prepare_builtins="$PWD/prepare-builtins/prepare-builtins"
+	cmake ${configure_args} ..
+	make ${makejobs}
+
+	# Add path to prepare-builtins for cmake
+	configure_args+=" -DPREPARE_BUILTINS='${_prepare_builtins}'"
+}
+
+post_install() {
+	vlicense LICENSE
+}
diff --git a/srcpkgs/ROCm-Device-Libs/update b/srcpkgs/ROCm-Device-Libs/update
new file mode 100644
index 00000000000..6a73667d3c1
--- /dev/null
+++ b/srcpkgs/ROCm-Device-Libs/update
@@ -0,0 +1 @@
+pattern='rocm-ocl-\K[\d.]+'

From bfdd38fd81a2c6a06c9a65c129cf11d937616f2e Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Mon, 13 Apr 2020 18:30:00 -0400
Subject: [PATCH 5/9] New package: ROCm-CompilerSupport-3.3.0

---
 common/shlibs                         |  1 +
 srcpkgs/ROCm-CompilerSupport-devel    |  1 +
 srcpkgs/ROCm-CompilerSupport/template | 32 +++++++++++++++++++++++++++
 srcpkgs/ROCm-CompilerSupport/update   |  1 +
 4 files changed, 35 insertions(+)
 create mode 120000 srcpkgs/ROCm-CompilerSupport-devel
 create mode 100644 srcpkgs/ROCm-CompilerSupport/template
 create mode 100644 srcpkgs/ROCm-CompilerSupport/update

diff --git a/common/shlibs b/common/shlibs
index 944ab37c190..393e464f683 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3983,3 +3983,4 @@ libaml.so.0 aml-0.1.0_1
 libneatvnc.so.0 neatvnc-0.2.0_1
 libhsakmt.so.1 ROCT-Thunk-Interface-3.3.0_1
 libhsa-runtime64.so.1 ROCR-Runtime-3.3.0_1
+libamd_comgr.so.1 ROCm-CompilerSupport-3.3.0_1
diff --git a/srcpkgs/ROCm-CompilerSupport-devel b/srcpkgs/ROCm-CompilerSupport-devel
new file mode 120000
index 00000000000..877aeafeeae
--- /dev/null
+++ b/srcpkgs/ROCm-CompilerSupport-devel
@@ -0,0 +1 @@
+ROCm-CompilerSupport
\ No newline at end of file
diff --git a/srcpkgs/ROCm-CompilerSupport/template b/srcpkgs/ROCm-CompilerSupport/template
new file mode 100644
index 00000000000..df56f7a3837
--- /dev/null
+++ b/srcpkgs/ROCm-CompilerSupport/template
@@ -0,0 +1,32 @@
+# Template file for 'ROCm-CompilerSupport'
+pkgname=ROCm-CompilerSupport
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="${pkgname}-rocm-${version}"
+build_wrksrc="lib/comgr"
+build_style=cmake
+configure_args="-DClang_DIR:PATH=/usr/lib/rocm-llvm/lib/cmake/clang"
+hostmakedepends="cmake pkg-config ROCm-llvm"
+makedepends="ROCm-Device-Libs"
+short_desc="Radeon Open Compute compiler support"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="BSD-3-Clause"
+homepage="https://github.com/RadeonOpenCompute/ROCm-CompilerSupport"
+distfiles="${homepage}/archive/rocm-${version}.tar.gz"
+checksum=01e2524e0f28ecd6f46c9720f279207de935d826b0172158792aa3ec86af9ca7
+nocross=yes
+
+post_install() {
+	vlicense LICENSE.txt
+}
+
+ROCm-CompilerSupport-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove "usr/lib/*.so"
+		vmove usr/lib/cmake
+	}
+}
diff --git a/srcpkgs/ROCm-CompilerSupport/update b/srcpkgs/ROCm-CompilerSupport/update
new file mode 100644
index 00000000000..86197bc3eea
--- /dev/null
+++ b/srcpkgs/ROCm-CompilerSupport/update
@@ -0,0 +1 @@
+pattern='rocm-\K[\d.]+'

From 0d1c2fc7c9a0e8962f7d7dae390cb6c0f7a44fc5 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Fri, 17 Apr 2020 12:11:25 -0400
Subject: [PATCH 6/9] New package: rocminfo-3.3.0

---
 srcpkgs/rocminfo/template | 22 ++++++++++++++++++++++
 srcpkgs/rocminfo/update   |  1 +
 2 files changed, 23 insertions(+)
 create mode 100644 srcpkgs/rocminfo/template
 create mode 100644 srcpkgs/rocminfo/update

diff --git a/srcpkgs/rocminfo/template b/srcpkgs/rocminfo/template
new file mode 100644
index 00000000000..7a075c7f7ac
--- /dev/null
+++ b/srcpkgs/rocminfo/template
@@ -0,0 +1,22 @@
+# Template file for 'rocminfo'
+pkgname=rocminfo
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="${pkgname}-rocm-${version}"
+build_style=cmake
+configure_args="-DROCM_DIR=/usr"
+hostmakedepends="cmake pkg-config"
+makedepends="ROCR-Runtime-devel"
+short_desc="Radeon Open Compute system information reporter"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute/rocminfo"
+distfiles="${homepage}/archive/rocm-${version}.tar.gz"
+checksum=e666f662c9e465aaabbbd0b109d87e017243cdf1a0898fabf5a90947bb3dbcd7
+nocross=yes
+python_version=3
+
+post_install() {
+	vlicense License.txt
+}
diff --git a/srcpkgs/rocminfo/update b/srcpkgs/rocminfo/update
new file mode 100644
index 00000000000..86197bc3eea
--- /dev/null
+++ b/srcpkgs/rocminfo/update
@@ -0,0 +1 @@
+pattern='rocm-\K[\d.]+'

From dd624a7ed799d5688b2caaddcef83bd3505d6097 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Sun, 19 Apr 2020 15:01:40 -0400
Subject: [PATCH 7/9] New package: rocm_bandwidth_test-3.3.0

---
 srcpkgs/rocm_bandwidth_test/template | 20 ++++++++++++++++++++
 srcpkgs/rocm_bandwidth_test/update   |  1 +
 2 files changed, 21 insertions(+)
 create mode 100644 srcpkgs/rocm_bandwidth_test/template
 create mode 100644 srcpkgs/rocm_bandwidth_test/update

diff --git a/srcpkgs/rocm_bandwidth_test/template b/srcpkgs/rocm_bandwidth_test/template
new file mode 100644
index 00000000000..6de7f2d6614
--- /dev/null
+++ b/srcpkgs/rocm_bandwidth_test/template
@@ -0,0 +1,20 @@
+# Template file for 'rocm_bandwidth_test'
+pkgname=rocm_bandwidth_test
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="${pkgname}-rocm-${version}"
+build_style=cmake
+hostmakedepends="cmake"
+makedepends="ROCR-Runtime-devel ROCT-Thunk-Interface-devel"
+short_desc="Radeon Open Compute bandwidth test"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute/rocm_bandwidth_test"
+distfiles="${homepage}/archive/rocm-${version}.tar.gz"
+checksum=f5f914073018619dc91662d5bf630903dfa4db9136d603591917fdfb3c9164ce
+nocross=yes
+
+post_install() {
+	vlicense LICENSE.txt
+}
diff --git a/srcpkgs/rocm_bandwidth_test/update b/srcpkgs/rocm_bandwidth_test/update
new file mode 100644
index 00000000000..86197bc3eea
--- /dev/null
+++ b/srcpkgs/rocm_bandwidth_test/update
@@ -0,0 +1 @@
+pattern='rocm-\K[\d.]+'

From c18eb5f651c6749d6fff87791f9f8511011c2ceb Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Tue, 14 Apr 2020 10:25:54 -0400
Subject: [PATCH 8/9] New package: ROCm-OpenCL-Runtime-3.3.0

---
 common/shlibs                                 |   2 +
 srcpkgs/ROCm-OpenCL-Runtime-clinfo            |   1 +
 srcpkgs/ROCm-OpenCL-Runtime-devel             |   1 +
 .../files/libelf-musl.patch                   |  21 +++
 .../files/runtime-musl.patch                  |  11 ++
 .../ROCm-OpenCL-Runtime/patches/cmake.patch   | 126 ++++++++++++++++++
 srcpkgs/ROCm-OpenCL-Runtime/template          |  84 ++++++++++++
 srcpkgs/ROCm-OpenCL-Runtime/update            |   1 +
 8 files changed, 247 insertions(+)
 create mode 120000 srcpkgs/ROCm-OpenCL-Runtime-clinfo
 create mode 120000 srcpkgs/ROCm-OpenCL-Runtime-devel
 create mode 100644 srcpkgs/ROCm-OpenCL-Runtime/files/libelf-musl.patch
 create mode 100644 srcpkgs/ROCm-OpenCL-Runtime/files/runtime-musl.patch
 create mode 100644 srcpkgs/ROCm-OpenCL-Runtime/patches/cmake.patch
 create mode 100644 srcpkgs/ROCm-OpenCL-Runtime/template
 create mode 100644 srcpkgs/ROCm-OpenCL-Runtime/update

diff --git a/common/shlibs b/common/shlibs
index 393e464f683..28250aa3a3f 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3984,3 +3984,5 @@ libneatvnc.so.0 neatvnc-0.2.0_1
 libhsakmt.so.1 ROCT-Thunk-Interface-3.3.0_1
 libhsa-runtime64.so.1 ROCR-Runtime-3.3.0_1
 libamd_comgr.so.1 ROCm-CompilerSupport-3.3.0_1
+libOpenCL-ROCm.so.1 ROCm-OpenCL-Runtime-3.3.0_1
+libamdocl64.so ROCm-OpenCL-Runtime-3.3.0_1
diff --git a/srcpkgs/ROCm-OpenCL-Runtime-clinfo b/srcpkgs/ROCm-OpenCL-Runtime-clinfo
new file mode 120000
index 00000000000..21f2041b8fb
--- /dev/null
+++ b/srcpkgs/ROCm-OpenCL-Runtime-clinfo
@@ -0,0 +1 @@
+ROCm-OpenCL-Runtime
\ No newline at end of file
diff --git a/srcpkgs/ROCm-OpenCL-Runtime-devel b/srcpkgs/ROCm-OpenCL-Runtime-devel
new file mode 120000
index 00000000000..21f2041b8fb
--- /dev/null
+++ b/srcpkgs/ROCm-OpenCL-Runtime-devel
@@ -0,0 +1 @@
+ROCm-OpenCL-Runtime
\ No newline at end of file
diff --git a/srcpkgs/ROCm-OpenCL-Runtime/files/libelf-musl.patch b/srcpkgs/ROCm-OpenCL-Runtime/files/libelf-musl.patch
new file mode 100644
index 00000000000..29469a9a351
--- /dev/null
+++ b/srcpkgs/ROCm-OpenCL-Runtime/files/libelf-musl.patch
@@ -0,0 +1,21 @@
+--- compiler/lib/loaders/elf/utils/libelf/_libelf.h	2020-04-28 15:50:53.243438174 -0400
++++ compiler/lib/loaders/elf/utils/libelf/_libelf.h	2020-04-28 15:51:54.293435415 -0400
+@@ -35,6 +35,7 @@
+ #include "_libelf_config.h"
+ 
+ #include "_elftc.h"
++#include <sys/cdefs.h>
+ 
+ /*
+  * Library-private data structures.
+--- compiler/lib/loaders/elf/utils/libelf/libelf.h	2020-04-28 15:50:53.244438174 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf.h	2020-04-28 15:52:12.375434593 -0400
+@@ -36,6 +36,8 @@
+ #define EM_HSAIL 0xAF5A
+ #endif
+ 
++#include <sys/cdefs.h>
++
+ /* Library private data structures */
+ typedef struct _Elf Elf;
+ typedef struct _Elf_Scn Elf_Scn;
diff --git a/srcpkgs/ROCm-OpenCL-Runtime/files/runtime-musl.patch b/srcpkgs/ROCm-OpenCL-Runtime/files/runtime-musl.patch
new file mode 100644
index 00000000000..ea18e90e09c
--- /dev/null
+++ b/srcpkgs/ROCm-OpenCL-Runtime/files/runtime-musl.patch
@@ -0,0 +1,11 @@
+--- runtime/os/os_posix.cpp.orig	2020-04-19 09:13:51.701982901 -0400
++++ runtime/os/os_posix.cpp	2020-04-19 09:14:04.156947422 -0400
+@@ -44,6 +44,8 @@
+ #include <algorithm>
+ #include <mutex>
+ 
++#include <libgen.h> // for basename
++
+ 
+ namespace amd {
+ 
diff --git a/srcpkgs/ROCm-OpenCL-Runtime/patches/cmake.patch b/srcpkgs/ROCm-OpenCL-Runtime/patches/cmake.patch
new file mode 100644
index 00000000000..2c96b99d45a
--- /dev/null
+++ b/srcpkgs/ROCm-OpenCL-Runtime/patches/cmake.patch
@@ -0,0 +1,126 @@
+--- OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/CMakeLists.txt	2019-09-10 11:53:28.000000000 -0400
++++ OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/CMakeLists.txt	2020-04-16 20:16:13.481180757 -0400
+@@ -73,11 +73,11 @@
+ 
+ set (OPENCL_ICD_LOADER_HEADERS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/inc CACHE PATH "Path to OpenCL Headers")
+ 
+-add_library (OpenCL ${OPENCL_ICD_LOADER_SOURCES})
+-set_target_properties (OpenCL PROPERTIES VERSION "1.2" SOVERSION "1")
++add_library (OpenCL-ROCm ${OPENCL_ICD_LOADER_SOURCES})
++set_target_properties (OpenCL-ROCm PROPERTIES VERSION "1.2" SOVERSION "1")
+ 
+ if (WIN32)
+-    target_link_libraries (OpenCL cfgmgr32.lib)
++    target_link_libraries (OpenCL-ROCm cfgmgr32.lib)
+ 
+     option (OPENCL_ICD_LOADER_REQUIRE_WDK "Build with D3DKMT support, which requires the Windows WDK." ON)
+     if (OPENCL_ICD_LOADER_REQUIRE_WDK)
+@@ -92,10 +92,10 @@
+             get_filename_component(WDK_DIRECTORY ${LATEST_D3DKMT_HEADER} DIRECTORY)
+             get_filename_component(WDK_DIRECTORY ${WDK_DIRECTORY} DIRECTORY)
+             message(STATUS "Found the Windows WDK in: ${WDK_DIRECTORY}")
+-            target_compile_definitions(OpenCL PRIVATE OPENCL_ICD_LOADER_REQUIRE_WDK)
+-            target_include_directories(OpenCL PRIVATE ${WDK_DIRECTORY}/um)
+-            target_include_directories(OpenCL PRIVATE ${WDK_DIRECTORY}/km)
+-            target_include_directories(OpenCL PRIVATE ${WDK_DIRECTORY}/shared)
++	    target_compile_definitions(OpenCL-ROCm PRIVATE OPENCL_ICD_LOADER_REQUIRE_WDK)
++	    target_include_directories(OpenCL-ROCm PRIVATE ${WDK_DIRECTORY}/um)
++	    target_include_directories(OpenCL-ROCm PRIVATE ${WDK_DIRECTORY}/km)
++	    target_include_directories(OpenCL-ROCm PRIVATE ${WDK_DIRECTORY}/shared)
+         else()
+             message(FATAL_ERROR "The Windows WDK was not found. Consider disabling OPENCL_ICD_LOADER_REQUIRE_WDK. Aborting.")
+         endif()
+@@ -113,25 +113,25 @@
+     endif()
+ else()
+     if (APPLE)
+-        target_link_libraries (OpenCL ${CMAKE_THREAD_LIBS_INIT})
++        target_link_libraries (OpenCL-ROCm ${CMAKE_THREAD_LIBS_INIT})
+     else ()
+-        set_target_properties (OpenCL PROPERTIES LINK_FLAGS "-Wl,--version-script -Wl,${CMAKE_CURRENT_SOURCE_DIR}/loader/linux/icd_exports.map")
+-        target_link_libraries (OpenCL ${CMAKE_THREAD_LIBS_INIT})
++        set_target_properties (OpenCL-ROCm PROPERTIES LINK_FLAGS "-Wl,--version-script -Wl,${CMAKE_CURRENT_SOURCE_DIR}/loader/linux/icd_exports.map")
++	target_link_libraries (OpenCL-ROCm ${CMAKE_THREAD_LIBS_INIT})
+     endif ()
+ endif ()
+ 
+ include_directories (${OPENCL_ICD_LOADER_HEADERS_DIR})
+ add_definitions (-DCL_TARGET_OPENCL_VERSION=220)
+ 
+-target_include_directories (OpenCL PRIVATE ${CMAKE_CURRENT_BINARY_DIR} loader)
+-target_link_libraries (OpenCL ${CMAKE_DL_LIBS})
++target_include_directories (OpenCL-ROCm PRIVATE ${CMAKE_CURRENT_BINARY_DIR} loader)
++target_link_libraries (OpenCL-ROCm ${CMAKE_DL_LIBS})
+ 
+ include (CTest)
+ if (BUILD_TESTING)
+     add_subdirectory (test)
+ endif()
+ 
+-install (TARGETS OpenCL
++install (TARGETS OpenCL-ROCm
+     RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+     ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
+     LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
+--- OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/test/loader_test/CMakeLists.txt	2019-09-10 11:53:28.000000000 -0400
++++ OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/test/loader_test/CMakeLists.txt	2020-04-16 20:16:56.647026589 -0400
+@@ -12,4 +12,4 @@
+     test_clgl.c
+     test_image_objects.c )
+ 
+-target_link_libraries (icd_loader_test OpenCL IcdLog)
++target_link_libraries (icd_loader_test OpenCL-ROCm IcdLog)
+--- ROCm-OpenCL-Runtime-roc-3.3.0/CMakeLists.txt	2020-04-28 07:29:51.864446603 -0400
++++ ROCm-OpenCL-Runtime-roc-3.3.0/CMakeLists.txt	2020-04-28 07:32:45.245793180 -0400
+@@ -101,30 +101,30 @@
+ rocm_setup_version( VERSION "2.0.0" )
+ 
+ # MAIN package
+-install(PROGRAMS $<TARGET_FILE:clinfo>
+-        DESTINATION bin/x86_64
++install(PROGRAMS $<TARGET_FILE:rocm-clinfo>
++        DESTINATION bin
+         COMPONENT MAIN)
+ install(PROGRAMS $<TARGET_FILE:amdocl64>
+-        DESTINATION lib/x86_64
++        DESTINATION lib
+         COMPONENT MAIN)
+-install(PROGRAMS $<TARGET_FILE:OpenCL>
+-        DESTINATION lib/x86_64
++install(PROGRAMS $<TARGET_FILE:OpenCL-ROCm>
++        DESTINATION lib
+         COMPONENT MAIN)
+-install(PROGRAMS $<TARGET_SONAME_FILE:OpenCL>
+-        DESTINATION lib/x86_64
++install(PROGRAMS $<TARGET_SONAME_FILE:OpenCL-ROCm>
++        DESTINATION lib
+         COMPONENT MAIN)
+ 
+ # DEV package
+ install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/api/opencl/khronos/headers/opencl2.2/CL"
+-        DESTINATION include
++	DESTINATION include/rocm
+         COMPONENT DEV
+         USE_SOURCE_PERMISSIONS
+         PATTERN cl_d3d10.h EXCLUDE
+         PATTERN cl_d3d11.h EXCLUDE
+         PATTERN cl_dx9_media_sharing.h EXCLUDE
+         PATTERN cl_egl.h EXCLUDE)
+-install(PROGRAMS $<TARGET_LINKER_FILE:OpenCL>
+-        DESTINATION lib/x86_64
++install(PROGRAMS $<TARGET_LINKER_FILE:OpenCL-ROCm>
++        DESTINATION lib
+         COMPONENT DEV)
+ 
+ # Generic CPACK variables
+--- ROCm-OpenCL-Runtime-roc-3.3.0/tools/clinfo/CMakeLists.txt	2020-04-28 07:29:51.882446535 -0400
++++ ROCm-OpenCL-Runtime-roc-3.3.0/tools/clinfo/CMakeLists.txt	2020-04-28 07:30:05.627394732 -0400
+@@ -6,6 +6,6 @@
+ 
+ add_definitions(-DHAVE_CL2_HPP)
+ 
+-add_executable(clinfo clinfo.cpp)
++add_executable(rocm-clinfo clinfo.cpp)
+ 
+-target_link_libraries(clinfo OpenCL)
++target_link_libraries(rocm-clinfo OpenCL-ROCm)
diff --git a/srcpkgs/ROCm-OpenCL-Runtime/template b/srcpkgs/ROCm-OpenCL-Runtime/template
new file mode 100644
index 00000000000..f6699a1d4c0
--- /dev/null
+++ b/srcpkgs/ROCm-OpenCL-Runtime/template
@@ -0,0 +1,84 @@
+# Template file for 'ROCm-OpenCL-Runtime'
+pkgname=ROCm-OpenCL-Runtime
+version=3.3.0
+revision=1
+_ocl_icd_name="OpenCL-ICD-Loader"
+_ocl_icd_ver="6c03f8b58fafd9dd693eaac826749a5cfad515f8"
+archs="x86_64*"
+create_wrksrc=yes
+build_wrksrc="${pkgname}-roc-${version}"
+build_style=cmake
+configure_args="-DUSE_COMGR_LIBRARY=yes"
+hostmakedepends="cmake pkg-config"
+makedepends="libglvnd-devel ROCm-CompilerSupport-devel
+	ROCT-Thunk-Interface-devel ROCR-Runtime-devel"
+depends="ROCm-CompilerSupport"
+short_desc="Radeon Open Compute OpenCL runtime"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="MIT"
+homepage="https://github.com/RadeonOpenCompute/ROCm-OpenCL-Runtime"
+_rocroot="https://github.com/RadeonOpenCompute"
+distfiles="${_rocroot}/ROCm-OpenCL-Runtime/archive/roc-${version}.tar.gz
+	${_rocroot}/rocm-cmake/archive/rocm-${version}.tar.gz
+	https://github.com/KhronosGroup/${_ocl_icd_name}/archive/${_ocl_icd_ver}.tar.gz"
+checksum="ac6999f1a491ab066286c2bd6adf50f08f831286f56e267879f9f7eced22f98e
+	76ed3ee8e56cf3246011cf7723c2abda539e1136e7e7f6909bfa45d268b8644f
+	c94d5bb6dc980c4d41d73e2b81663a19aabe494e923e2d0eec72a4c95b318438"
+nocross=yes
+
+if [ "$XBPS_LIBC" = "musl" ]; then
+	makedepends+=" musl-legacy-compat"
+fi
+
+post_patch() {
+	if [ "$XBPS_LIBC" = "musl" ]; then
+		# Remove dependence on glibc
+		patch -Np0 < ${FILESDIR}/libelf-musl.patch
+		patch -Np0 < ${FILESDIR}/runtime-musl.patch
+		vsed -e '/glibc_functions.cpp/d' -i api/opencl/amdocl/CMakeLists.txt
+	fi
+}
+
+pre_configure() {
+	# ROCm requires a very specific Khronos ICD loader version in the tree
+	# Keep the ICD loader config in /etc/OpenCL/rocm-vendors to avoid conflicts
+	_ocl_icd_dir="${_ocl_icd_name}-${_ocl_icd_ver}"
+	ln -sf "${wrksrc}/${_ocl_icd_dir}" api/opencl/khronos/icd
+	vsed -i "${wrksrc}/${_ocl_icd_dir}/loader/icd_platform.h" \
+		-e 's@/etc/OpenCL/vendors/@/etc/OpenCL/rocm-vendors/@g'
+
+	# CMake modules probably not useful anywhere but for this build
+	ln -sf "${wrksrc}/rocm-cmake-rocm-${version}/share/rocm/cmake"/*.cmake cmake
+
+	# Fix the dlopen macro to point to versioned libamd_comgr shared object
+	vsed -i 'runtime/device/comgrctx.cpp' \
+		-e 's/\blibamd_comgr\(32\)\?.so\b/&.1/g'
+}
+
+post_install() {
+	vlicense License
+
+	# Create descriptor to allow the ICD loader to find the driver
+	vmkdir etc/OpenCL/rocm-vendors
+	echo "libamdocl64.so" > "${DESTDIR}/etc/OpenCL/rocm-vendors/amdocl64.icd"
+	vmkdir etc/OpenCL/vendors
+	ln -s ../../OpenCL/rocm-vendors/amdocl64.icd \
+		${DESTDIR}/etc/OpenCL/vendors/rocm-amdocl64.icd
+}
+
+ROCm-OpenCL-Runtime-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/lib/libOpenCL-ROCm.so
+		vmove usr/include
+	}
+}
+
+ROCm-OpenCL-Runtime-clinfo_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - clinfo"
+	pkg_install() {
+		vmove usr/bin/rocm-clinfo
+	}
+}
diff --git a/srcpkgs/ROCm-OpenCL-Runtime/update b/srcpkgs/ROCm-OpenCL-Runtime/update
new file mode 100644
index 00000000000..8385f4d1215
--- /dev/null
+++ b/srcpkgs/ROCm-OpenCL-Runtime/update
@@ -0,0 +1 @@
+pattern='roc-\K[\d.]+'

From fa4303072e381a013a7d98d2691fbc2753cc059a Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Thu, 30 Apr 2020 13:11:12 -0400
Subject: [PATCH 9/9] New package: ROCR-Runtime-hsa-ext-3.3.0

---
 common/shlibs                         |  2 ++
 srcpkgs/ROCR-Runtime-hsa-ext-devel    |  1 +
 srcpkgs/ROCR-Runtime-hsa-ext/template | 43 +++++++++++++++++++++++++++
 srcpkgs/ROCR-Runtime-hsa-ext/update   |  2 ++
 4 files changed, 48 insertions(+)
 create mode 120000 srcpkgs/ROCR-Runtime-hsa-ext-devel
 create mode 100644 srcpkgs/ROCR-Runtime-hsa-ext/template
 create mode 100644 srcpkgs/ROCR-Runtime-hsa-ext/update

diff --git a/common/shlibs b/common/shlibs
index 28250aa3a3f..66392db5c99 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3986,3 +3986,5 @@ libhsa-runtime64.so.1 ROCR-Runtime-3.3.0_1
 libamd_comgr.so.1 ROCm-CompilerSupport-3.3.0_1
 libOpenCL-ROCm.so.1 ROCm-OpenCL-Runtime-3.3.0_1
 libamdocl64.so ROCm-OpenCL-Runtime-3.3.0_1
+libhsa-ext-image64.so.1 ROCR-Runtime-hsa-ext-3.3.0_1
+libhsa-runtime-tools64.so.1 ROCR-Runtime-hsa-ext-3.3.0_1
diff --git a/srcpkgs/ROCR-Runtime-hsa-ext-devel b/srcpkgs/ROCR-Runtime-hsa-ext-devel
new file mode 120000
index 00000000000..6ee1b14911b
--- /dev/null
+++ b/srcpkgs/ROCR-Runtime-hsa-ext-devel
@@ -0,0 +1 @@
+ROCR-Runtime-hsa-ext
\ No newline at end of file
diff --git a/srcpkgs/ROCR-Runtime-hsa-ext/template b/srcpkgs/ROCR-Runtime-hsa-ext/template
new file mode 100644
index 00000000000..235ae92146b
--- /dev/null
+++ b/srcpkgs/ROCR-Runtime-hsa-ext/template
@@ -0,0 +1,43 @@
+# Template file for 'ROCR-Runtime-hsa-ext'
+pkgname=ROCR-Runtime-hsa-ext
+version=3.3.0
+revision=1
+archs="x86_64"
+hostmakedepends="tar"
+short_desc="Radeon Open Compute HSA runtime extensions"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute"
+_hsa_deb="hsa-ext-rocr-dev_1.1.30300.0-rocm-rel-3.3-19-23fc088b_amd64.deb"
+distfiles="https://repo.radeon.com/rocm/apt/debian/pool/main/h/hsa-ext-rocr-dev/$_hsa_deb"
+checksum=6b44e286b395d946b865ec1f3cc546356396785ac1fde591d07af02d0aa7c25d
+repository=nonfree
+restricted=yes
+
+do_extract() {
+	ar x "${XBPS_SRCDISTDIR}/${pkgname}-${version}/${_hsa_deb}"
+	tar xvf data.tar.gz
+}
+
+do_install() {
+	_rocm_includes="opt/rocm-${version}/hsa/include"
+
+	vmkdir usr
+	vcopy opt/rocm-${version}/hsa/lib usr
+	vcopy "$_rocm_includes" usr
+
+	# Extract license from one of the header files
+	awk 'BEGIN{HEADER=0} /\/\//{HEADER=1; print $0;} /^[^/]/{if(HEADER==1) exit;}' \
+		< "${_rocm_includes}/hsa/amd_hsa_tools_interfaces.h" \
+		| sed 's@^///*\( \|$\)@@' > LICENSE
+	vlicense LICENSE
+}
+
+ROCR-Runtime-hsa-ext-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove "usr/lib/*.so"
+	}
+}
diff --git a/srcpkgs/ROCR-Runtime-hsa-ext/update b/srcpkgs/ROCR-Runtime-hsa-ext/update
new file mode 100644
index 00000000000..84252d2e3b8
--- /dev/null
+++ b/srcpkgs/ROCR-Runtime-hsa-ext/update
@@ -0,0 +1,2 @@
+site='https://repo.radeon.com/rocm/apt/debian/pool/main/h/'
+pattern='hsa-ext-rocr-dev\K[\d.]+'

^ permalink raw reply	[flat|nested] 61+ messages in thread

* Re: [PR PATCH] [Updated] New packages: ROCm core and OpenCL
  2020-04-19 13:34 [PR PATCH] New packages: ROCm core and OpenCL ahesford
                   ` (45 preceding siblings ...)
  2020-08-04 17:13 ` [PR PATCH] [Updated] " ahesford
@ 2020-08-04 17:13 ` ahesford
  2020-08-04 17:16 ` [PR PATCH] [Closed]: " ahesford
                   ` (12 subsequent siblings)
  59 siblings, 0 replies; 61+ messages in thread
From: ahesford @ 2020-08-04 17:13 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 3893 bytes --]

There is an updated pull request by ahesford against master on the void-packages repository

https://github.com/ahesford/void-packages rocm
https://github.com/void-linux/void-packages/pull/21153

New packages: ROCm core and OpenCL
This PR includes several packages designed to bring the OpenCL portion of the AMD ROCm ecosystem to Void. It addresses Issue #19507. There are many other packages that AMD provides for GPGPU computing, but these can be added piecemeal as users demand.

The packages are currently only for `x86_64*`. While at least some of the packages will compile on other 64-bit architectures, I have no hardware to test. They are certainly not suitable for 32-bit architectures; some internal data structures rely on `uint64_t` values that are cast to pointers. At a
minimum, a thorough audit would be necessary to ensure that these casts are safe (e.g., that the values stored were only ever upcast from 32-bit pointers). More extensive work may be necessary to support 32-bit architectures, probably without significant benefit.

The packages successfully identify a Radeon RX 580 on an `x86_64` installation using both `clinfo` and `rocminfo` as provided. Furthermore, a version of `pyopencl` linked against these ROCm packages successfully runs a simple program that validates arithmetic on GPU-bound arrays.

There are caveats with this set of packages, almost all of which revolve around the incompatibilities between the Void-provided `ocl-icd` and the [Khronos OpenCL ICD loader](https://github.com/KhronosGroup/OpenCL-ID-Loader) required by (and built into) `rocm-opencl-runtime`.
1. All packages install into `/opt/rocm`. This keeps the environment closer to that officially sanctioned by AMD and helps avoid conflicts between other packages and those provided here. (For example, `clinfo` and the ICD loader itself.) Eventually, we may be able to move the files into `/usr`.
2. The Khronos OpenCL ICD loader built into `rocm-opencl-runtime` is an outdated, pre-release commit. If AMD can update its sources to use the release version of that loader (which has a backward-incompatible API change), we may be able to make ROCm compatible with `ocl-icd` or replace `ocl-icd` with the official Khronos loader.
3. In the meantime, to avoid `shlibs` conflicts, the OpenCL ICD loader is installed as `/opt/rocm/lib/libOpenCL-ROCm.so` (and an appropriately versioned shared library), which means that programs wishing to use the ROCm OpenCL must explicitly link against this library instead of the generic `libOpenCL.so`.
4. I do **not** recommend making any Void packages link against this specific library, because it will make those packages ROCm-only. For the time being, ROCm is intended for end-users to specifically link against. Linking Void packages against ROCm would requires the ICD loader used by ROCm be compatible with `ocl-icd`, or `ocl-icd` be replaced by the Khronos loader. However, because the Khronos loader changed its API for the release version, such a change is not yet appropriate.

Hopefully, if AMD updates its dependence on the Khronos ICD loader, we can resolve some of these caveats in the future and make ROCm a more natural Void component. For now, these packages are useful for those who need an AMD OpenCL solution and would rather custom-link software against the AMD ICD loader than hack the `amdgpu-pro` driver into an ICD compatible with `ocl-icd`.

Some patches were made to relocate some files in `/opt/rocm` and make everyting build on x86_64-musl`. Where appropriate, these patches will be pushed upstream to clean up the distribution and packaging.

Update: I pushed some new commits to update license information that triggerd an `xlint` failure. I've also disabled CI builds because they will time out on `rocm-llvm`.

A patch file from https://github.com/void-linux/void-packages/pull/21153.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-rocm-21153.patch --]
[-- Type: text/x-diff, Size: 35439 bytes --]

From 5cbdcb738fa646996cbf8e119465300742bca327 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Mon, 13 Apr 2020 13:08:09 -0400
Subject: [PATCH 1/9] New package: ROCT-Thunk-Interface-3.3.0

---
 common/shlibs                                 |  1 +
 srcpkgs/ROCT-Thunk-Interface-devel            |  1 +
 .../patches/cmake-dev-libdir.patch            | 10 ++++++
 .../ROCT-Thunk-Interface/patches/musl.patch   | 29 ++++++++++++++++
 srcpkgs/ROCT-Thunk-Interface/template         | 33 +++++++++++++++++++
 srcpkgs/ROCT-Thunk-Interface/update           |  1 +
 6 files changed, 75 insertions(+)
 create mode 120000 srcpkgs/ROCT-Thunk-Interface-devel
 create mode 100644 srcpkgs/ROCT-Thunk-Interface/patches/cmake-dev-libdir.patch
 create mode 100644 srcpkgs/ROCT-Thunk-Interface/patches/musl.patch
 create mode 100644 srcpkgs/ROCT-Thunk-Interface/template
 create mode 100644 srcpkgs/ROCT-Thunk-Interface/update

diff --git a/common/shlibs b/common/shlibs
index dcb1d8e54b6..4f93db41216 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3981,3 +3981,4 @@ libcglm.so.0 cglm-0.7.6_1
 libfcft.so.3 fcft-2.2.2_1
 libaml.so.0 aml-0.1.0_1
 libneatvnc.so.0 neatvnc-0.2.0_1
+libhsakmt.so.1 ROCT-Thunk-Interface-3.3.0_1
diff --git a/srcpkgs/ROCT-Thunk-Interface-devel b/srcpkgs/ROCT-Thunk-Interface-devel
new file mode 120000
index 00000000000..7e43c209e3d
--- /dev/null
+++ b/srcpkgs/ROCT-Thunk-Interface-devel
@@ -0,0 +1 @@
+ROCT-Thunk-Interface
\ No newline at end of file
diff --git a/srcpkgs/ROCT-Thunk-Interface/patches/cmake-dev-libdir.patch b/srcpkgs/ROCT-Thunk-Interface/patches/cmake-dev-libdir.patch
new file mode 100644
index 00000000000..98c7f1e459c
--- /dev/null
+++ b/srcpkgs/ROCT-Thunk-Interface/patches/cmake-dev-libdir.patch
@@ -0,0 +1,10 @@
+--- CMakeLists.txt.old	2020-04-18 19:45:17.306081135 -0400
++++ CMakeLists.txt	2020-04-18 19:46:51.300753636 -0400
+@@ -146,6 +146,7 @@
+     COMMAND ${CMAKE_COMMAND}
+         -DSOURCE_DIR="${SOURCE_DIR}"
+         -DCMAKE_INSTALL_PREFIX="${CMAKE_INSTALL_PREFIX}"
++        -DCMAKE_INSTALL_LIBDIR="${CMAKE_INSTALL_LIBDIR}"
+         -DCPACK_RPM_PACKAGE_REQUIRES="hsakmt-roct"
+         -DCPACK_PACKAGING_INSTALL_PREFIX="${CPACK_PACKAGING_INSTALL_PREFIX}"
+         -DVERSION="${BUILD_VERSION_STRING}"
diff --git a/srcpkgs/ROCT-Thunk-Interface/patches/musl.patch b/srcpkgs/ROCT-Thunk-Interface/patches/musl.patch
new file mode 100644
index 00000000000..aeea9832411
--- /dev/null
+++ b/srcpkgs/ROCT-Thunk-Interface/patches/musl.patch
@@ -0,0 +1,29 @@
+diff -r -u old/src/libhsakmt.h new/src/libhsakmt.h
+--- src/libhsakmt.h	2020-03-04 15:00:47.000000000 -0500
++++ src/libhsakmt.h	2020-04-13 12:58:30.444865992 -0400
+@@ -54,6 +54,10 @@
+ #define CHECK_KFD_OPEN() \
+ 	do { if (kfd_open_count == 0 || hsakmt_forked) return HSAKMT_STATUS_KERNEL_IO_CHANNEL_NOT_OPENED; } while (0)
+ 
++/*On some platforms, a PAGE_SIZE macro eclipses the extern variable*/
++#ifdef PAGE_SIZE
++#undef PAGE_SIZE
++#endif
+ extern int PAGE_SIZE;
+ extern int PAGE_SHIFT;
+ 
+diff -r -u old/src/topology.c new/src/topology.c
+--- src/topology.c	2020-03-04 15:00:47.000000000 -0500
++++ src/topology.c	2020-04-13 13:01:31.209870701 -0400
+@@ -38,6 +38,11 @@
+ #include "libhsakmt.h"
+ #include "fmm.h"
+ 
++/*Needed on MUSL*/
++#ifndef MAXNAMLEN
++#define MAXNAMLEN PATH_MAX
++#endif
++
+ /* Number of memory banks added by thunk on top of topology
+  * This only includes static heaps like LDS, scratch and SVM,
+  * not for MMIO_REMAP heap. MMIO_REMAP memory bank is reported
diff --git a/srcpkgs/ROCT-Thunk-Interface/template b/srcpkgs/ROCT-Thunk-Interface/template
new file mode 100644
index 00000000000..8c680b2af29
--- /dev/null
+++ b/srcpkgs/ROCT-Thunk-Interface/template
@@ -0,0 +1,33 @@
+# Template file for 'ROCT-Thunk-Interface'
+pkgname=ROCT-Thunk-Interface
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="${pkgname}-roc-${version}"
+build_style=cmake
+make_build_target="all build-dev"
+make_install_target="install install-dev"
+hostmakedepends="cmake pkg-config"
+makedepends="pciutils-devel libnuma-devel"
+short_desc="Radeon Open Compute thunk interface"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="MIT"
+homepage="https://github.com/RadeonOpenCompute/ROCT-Thunk-Interface"
+distfiles="${homepage}/archive/roc-${version}.tar.gz"
+checksum=2cabe9d2cfa72031c05d11290837c476182e72d8dec2049298f691143fdd212b
+nocross=yes
+
+post_install() {
+	vlicense LICENSE.md
+}
+
+ROCT-Thunk-Interface-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove "usr/lib/*.so"
+		vmove usr/share/pkgconfig
+		vmove usr/lib/cmake
+	}
+}
diff --git a/srcpkgs/ROCT-Thunk-Interface/update b/srcpkgs/ROCT-Thunk-Interface/update
new file mode 100644
index 00000000000..8385f4d1215
--- /dev/null
+++ b/srcpkgs/ROCT-Thunk-Interface/update
@@ -0,0 +1 @@
+pattern='roc-\K[\d.]+'

From 8738399f72c96ba594d928abc2c165da2cc0772b Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Mon, 13 Apr 2020 15:27:27 -0400
Subject: [PATCH 2/9] New package: ROCR-Runtime-3.3.0

---
 common/shlibs                            |  1 +
 srcpkgs/ROCR-Runtime-devel               |  1 +
 srcpkgs/ROCR-Runtime/patches/cmake.patch | 27 +++++++++++++++++++++
 srcpkgs/ROCR-Runtime/template            | 30 ++++++++++++++++++++++++
 srcpkgs/ROCR-Runtime/update              |  1 +
 5 files changed, 60 insertions(+)
 create mode 120000 srcpkgs/ROCR-Runtime-devel
 create mode 100644 srcpkgs/ROCR-Runtime/patches/cmake.patch
 create mode 100644 srcpkgs/ROCR-Runtime/template
 create mode 100644 srcpkgs/ROCR-Runtime/update

diff --git a/common/shlibs b/common/shlibs
index 4f93db41216..944ab37c190 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3982,3 +3982,4 @@ libfcft.so.3 fcft-2.2.2_1
 libaml.so.0 aml-0.1.0_1
 libneatvnc.so.0 neatvnc-0.2.0_1
 libhsakmt.so.1 ROCT-Thunk-Interface-3.3.0_1
+libhsa-runtime64.so.1 ROCR-Runtime-3.3.0_1
diff --git a/srcpkgs/ROCR-Runtime-devel b/srcpkgs/ROCR-Runtime-devel
new file mode 120000
index 00000000000..a733fb9fbab
--- /dev/null
+++ b/srcpkgs/ROCR-Runtime-devel
@@ -0,0 +1 @@
+ROCR-Runtime
\ No newline at end of file
diff --git a/srcpkgs/ROCR-Runtime/patches/cmake.patch b/srcpkgs/ROCR-Runtime/patches/cmake.patch
new file mode 100644
index 00000000000..93b74cd2297
--- /dev/null
+++ b/srcpkgs/ROCR-Runtime/patches/cmake.patch
@@ -0,0 +1,27 @@
+--- src/CMakeLists.txt.old	2020-04-18 20:01:48.549636995 -0400
++++ src/CMakeLists.txt	2020-04-18 20:04:00.177179781 -0400
+@@ -108,8 +108,8 @@
+ ## ROCr build internal versioning
+ add_definitions ( -DROCR_BUILD_ID=${PACKAGE_VERSION_STRING} )
+ 
+-## Set RUNPATH - ../../lib covers use of the legacy symlink in /hsa/lib/
+-set(CMAKE_INSTALL_RPATH "$ORIGIN;$ORIGIN/../../lib;$ORIGIN/../../lib64;$ORIGIN/../lib64")
++## Set RUNPATH
++set(CMAKE_INSTALL_RPATH "$ORIGIN;$ORIGIN/../lib")
+ 
+ ## ------------------------- Linux Compiler and Linker options -------------------------
+ set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -fexceptions -fno-rtti -fvisibility=hidden -Wno-error=sign-compare -Wno-sign-compare -Wno-write-strings -Wno-conversion-null -fno-math-errno -fno-threadsafe-statics -fmerge-all-constants -fms-extensions -Wno-error=comment -Wno-comment -Wno-error=pointer-arith -Wno-pointer-arith -Wno-error=unused-variable -Wno-error=unused-function" )
+@@ -185,11 +185,8 @@
+ add_custom_target ( hsa_lib_link2 ALL WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMAND ${CMAKE_COMMAND} -E create_symlink ../hsa/lib/${CORE_RUNTIME_LIBRARY}.so.${SO_MAJOR} ${CORE_RUNTIME_LIBRARY}-link.so.${SO_MAJOR} )
+ 
+ ## Set install information
+-install ( TARGETS ${CORE_RUNTIME_TARGET} LIBRARY DESTINATION hsa/lib )
+-install ( DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/inc/ DESTINATION hsa/include/hsa )
+-install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/hsa_include_link DESTINATION include PERMISSIONS OWNER_WRITE OWNER_READ RENAME hsa )
+-install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/${CORE_RUNTIME_LIBRARY}-link.so DESTINATION lib PERMISSIONS OWNER_WRITE OWNER_READ RENAME ${CORE_RUNTIME_LIBRARY}.so )
+-install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/${CORE_RUNTIME_LIBRARY}-link.so.${SO_MAJOR} DESTINATION lib PERMISSIONS OWNER_WRITE OWNER_READ RENAME ${CORE_RUNTIME_LIBRARY}.so.${SO_MAJOR} )
++install ( TARGETS ${CORE_RUNTIME_TARGET} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} )
++install ( DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/inc/ DESTINATION include/hsa )
+ 
+ ## Packaging directives
+ set ( CPACK_GENERATOR "DEB;RPM" CACHE STRING "Package types to build")
diff --git a/srcpkgs/ROCR-Runtime/template b/srcpkgs/ROCR-Runtime/template
new file mode 100644
index 00000000000..95b7e701afb
--- /dev/null
+++ b/srcpkgs/ROCR-Runtime/template
@@ -0,0 +1,30 @@
+# Template file for 'ROCR-Runtime'
+pkgname=ROCR-Runtime
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="${pkgname}-rocm-${version}"
+build_wrksrc="src"
+build_style=cmake
+hostmakedepends="cmake pkg-config"
+makedepends="ROCT-Thunk-Interface-devel elfutils-devel"
+short_desc="Radeon Open Compute HSA runtime"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute/ROCR-Runtime"
+distfiles="${homepage}/archive/rocm-${version}.tar.gz"
+checksum=fa2d2d1f8a61d8a6952d377cf288d78c61776c3c2a666f163cafc3aa19ab0b61
+nocross=yes
+
+post_install() {
+	vlicense ../LICENSE.txt
+}
+
+ROCR-Runtime-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove "usr/lib/*.so"
+	}
+}
diff --git a/srcpkgs/ROCR-Runtime/update b/srcpkgs/ROCR-Runtime/update
new file mode 100644
index 00000000000..86197bc3eea
--- /dev/null
+++ b/srcpkgs/ROCR-Runtime/update
@@ -0,0 +1 @@
+pattern='rocm-\K[\d.]+'

From 0ee0f3f609c9c3743099173482d2c4a26a045b1f Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Mon, 13 Apr 2020 18:07:34 -0400
Subject: [PATCH 3/9] New package: ROCm-llvm-3.3.0

---
 srcpkgs/ROCm-llvm/template | 26 ++++++++++++++++++++++++++
 srcpkgs/ROCm-llvm/update   |  1 +
 2 files changed, 27 insertions(+)
 create mode 100644 srcpkgs/ROCm-llvm/template
 create mode 100644 srcpkgs/ROCm-llvm/update

diff --git a/srcpkgs/ROCm-llvm/template b/srcpkgs/ROCm-llvm/template
new file mode 100644
index 00000000000..4c3095b21f4
--- /dev/null
+++ b/srcpkgs/ROCm-llvm/template
@@ -0,0 +1,26 @@
+# Template file for 'ROCm-llvm'
+pkgname=ROCm-llvm
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="llvm-project-rocm-ocl-${version}"
+build_wrksrc=llvm
+build_style=cmake
+configure_args="-DCMAKE_INSTALL_PREFIX:PATH=/usr/lib/rocm-llvm
+	-DLLVM_ENABLE_PROJECTS='llvm;clang;lld' -DLLVM_TARGETS_TO_BUILD='AMDGPU'
+	-DLLVM_BUILD_DOCS=NO -DLLVM_ENABLE_OCAMLDOC=OFF
+	-DLLVM_ENABLE_SPHINX=NO -DLLVM_ENABLE_DOXYGEN=OFF
+	-DLLVM_INSTALL_UTILS=ON -DLLVM_VERSION_SUFFIX=roc -DOCAMLFIND=NO"
+hostmakedepends="cmake pkg-config python3"
+short_desc="Radeon Open Compute LLVM toolchain"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="Apache-2.0, NCSA, custom:LLVM-Exceptions"
+homepage="https://github.com/RadeonOpenCompute/llvm-project"
+distfiles="${homepage}/archive/rocm-ocl-${version}.tar.gz"
+checksum=a2bef7042e8e2f2cd8548cb246b88322e1c77188839983dcac8312d56f544dc8
+python_version=3
+nocross=yes
+
+post_install() {
+	vlicense LICENSE.TXT
+}
diff --git a/srcpkgs/ROCm-llvm/update b/srcpkgs/ROCm-llvm/update
new file mode 100644
index 00000000000..6a73667d3c1
--- /dev/null
+++ b/srcpkgs/ROCm-llvm/update
@@ -0,0 +1 @@
+pattern='rocm-ocl-\K[\d.]+'

From 7d6f1904eed5b3c2a8eff961859916d886c4eefb Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Tue, 14 Apr 2020 10:25:31 -0400
Subject: [PATCH 4/9] New package: ROCm-Device-Libs-3.3.0

---
 srcpkgs/ROCm-Device-Libs/template | 37 +++++++++++++++++++++++++++++++
 srcpkgs/ROCm-Device-Libs/update   |  1 +
 2 files changed, 38 insertions(+)
 create mode 100644 srcpkgs/ROCm-Device-Libs/template
 create mode 100644 srcpkgs/ROCm-Device-Libs/update

diff --git a/srcpkgs/ROCm-Device-Libs/template b/srcpkgs/ROCm-Device-Libs/template
new file mode 100644
index 00000000000..8086cd86450
--- /dev/null
+++ b/srcpkgs/ROCm-Device-Libs/template
@@ -0,0 +1,37 @@
+# Template file for 'ROCm-Device-Libs'
+pkgname=ROCm-Device-Libs
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="${pkgname}-rocm-ocl-${version}"
+build_style=cmake
+configure_args="-DLLVM_DIR:PATH=/usr/lib/rocm-llvm
+	-DCMAKE_INSTALL_LIBDIR:PATH=lib/rocm-device-libs"
+hostmakedepends="cmake ROCm-llvm"
+short_desc="Radeon Open Compute device libraries"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute/ROCm-Device-Libs"
+distfiles="${homepage}/archive/rocm-ocl-${version}.tar.gz"
+checksum=706b08230790e08ca6a7a2fb7687d6131fd39a562148340e00fa37a6c06769c5
+nocross=yes
+
+pre_configure() {
+	# Put bytecodes in a lib/ subdirectory
+	vsed -i Packages.cmake -e 's@/lib/@/${CMAKE_INSTALL_LIBDIR}/@'
+	vsed -i OCL.cmake -e 's@DESTINATION lib$@DESTINATION ${CMAKE_INSTALL_LIBDIR}@'
+
+	# Build the prepare-builtins executable with native compiler
+	mkdir -p utils/build
+	cd utils/build
+	_prepare_builtins="$PWD/prepare-builtins/prepare-builtins"
+	cmake ${configure_args} ..
+	make ${makejobs}
+
+	# Add path to prepare-builtins for cmake
+	configure_args+=" -DPREPARE_BUILTINS='${_prepare_builtins}'"
+}
+
+post_install() {
+	vlicense LICENSE
+}
diff --git a/srcpkgs/ROCm-Device-Libs/update b/srcpkgs/ROCm-Device-Libs/update
new file mode 100644
index 00000000000..6a73667d3c1
--- /dev/null
+++ b/srcpkgs/ROCm-Device-Libs/update
@@ -0,0 +1 @@
+pattern='rocm-ocl-\K[\d.]+'

From bfdd38fd81a2c6a06c9a65c129cf11d937616f2e Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Mon, 13 Apr 2020 18:30:00 -0400
Subject: [PATCH 5/9] New package: ROCm-CompilerSupport-3.3.0

---
 common/shlibs                         |  1 +
 srcpkgs/ROCm-CompilerSupport-devel    |  1 +
 srcpkgs/ROCm-CompilerSupport/template | 32 +++++++++++++++++++++++++++
 srcpkgs/ROCm-CompilerSupport/update   |  1 +
 4 files changed, 35 insertions(+)
 create mode 120000 srcpkgs/ROCm-CompilerSupport-devel
 create mode 100644 srcpkgs/ROCm-CompilerSupport/template
 create mode 100644 srcpkgs/ROCm-CompilerSupport/update

diff --git a/common/shlibs b/common/shlibs
index 944ab37c190..393e464f683 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3983,3 +3983,4 @@ libaml.so.0 aml-0.1.0_1
 libneatvnc.so.0 neatvnc-0.2.0_1
 libhsakmt.so.1 ROCT-Thunk-Interface-3.3.0_1
 libhsa-runtime64.so.1 ROCR-Runtime-3.3.0_1
+libamd_comgr.so.1 ROCm-CompilerSupport-3.3.0_1
diff --git a/srcpkgs/ROCm-CompilerSupport-devel b/srcpkgs/ROCm-CompilerSupport-devel
new file mode 120000
index 00000000000..877aeafeeae
--- /dev/null
+++ b/srcpkgs/ROCm-CompilerSupport-devel
@@ -0,0 +1 @@
+ROCm-CompilerSupport
\ No newline at end of file
diff --git a/srcpkgs/ROCm-CompilerSupport/template b/srcpkgs/ROCm-CompilerSupport/template
new file mode 100644
index 00000000000..df56f7a3837
--- /dev/null
+++ b/srcpkgs/ROCm-CompilerSupport/template
@@ -0,0 +1,32 @@
+# Template file for 'ROCm-CompilerSupport'
+pkgname=ROCm-CompilerSupport
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="${pkgname}-rocm-${version}"
+build_wrksrc="lib/comgr"
+build_style=cmake
+configure_args="-DClang_DIR:PATH=/usr/lib/rocm-llvm/lib/cmake/clang"
+hostmakedepends="cmake pkg-config ROCm-llvm"
+makedepends="ROCm-Device-Libs"
+short_desc="Radeon Open Compute compiler support"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="BSD-3-Clause"
+homepage="https://github.com/RadeonOpenCompute/ROCm-CompilerSupport"
+distfiles="${homepage}/archive/rocm-${version}.tar.gz"
+checksum=01e2524e0f28ecd6f46c9720f279207de935d826b0172158792aa3ec86af9ca7
+nocross=yes
+
+post_install() {
+	vlicense LICENSE.txt
+}
+
+ROCm-CompilerSupport-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove "usr/lib/*.so"
+		vmove usr/lib/cmake
+	}
+}
diff --git a/srcpkgs/ROCm-CompilerSupport/update b/srcpkgs/ROCm-CompilerSupport/update
new file mode 100644
index 00000000000..86197bc3eea
--- /dev/null
+++ b/srcpkgs/ROCm-CompilerSupport/update
@@ -0,0 +1 @@
+pattern='rocm-\K[\d.]+'

From 0d1c2fc7c9a0e8962f7d7dae390cb6c0f7a44fc5 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Fri, 17 Apr 2020 12:11:25 -0400
Subject: [PATCH 6/9] New package: rocminfo-3.3.0

---
 srcpkgs/rocminfo/template | 22 ++++++++++++++++++++++
 srcpkgs/rocminfo/update   |  1 +
 2 files changed, 23 insertions(+)
 create mode 100644 srcpkgs/rocminfo/template
 create mode 100644 srcpkgs/rocminfo/update

diff --git a/srcpkgs/rocminfo/template b/srcpkgs/rocminfo/template
new file mode 100644
index 00000000000..7a075c7f7ac
--- /dev/null
+++ b/srcpkgs/rocminfo/template
@@ -0,0 +1,22 @@
+# Template file for 'rocminfo'
+pkgname=rocminfo
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="${pkgname}-rocm-${version}"
+build_style=cmake
+configure_args="-DROCM_DIR=/usr"
+hostmakedepends="cmake pkg-config"
+makedepends="ROCR-Runtime-devel"
+short_desc="Radeon Open Compute system information reporter"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute/rocminfo"
+distfiles="${homepage}/archive/rocm-${version}.tar.gz"
+checksum=e666f662c9e465aaabbbd0b109d87e017243cdf1a0898fabf5a90947bb3dbcd7
+nocross=yes
+python_version=3
+
+post_install() {
+	vlicense License.txt
+}
diff --git a/srcpkgs/rocminfo/update b/srcpkgs/rocminfo/update
new file mode 100644
index 00000000000..86197bc3eea
--- /dev/null
+++ b/srcpkgs/rocminfo/update
@@ -0,0 +1 @@
+pattern='rocm-\K[\d.]+'

From dd624a7ed799d5688b2caaddcef83bd3505d6097 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Sun, 19 Apr 2020 15:01:40 -0400
Subject: [PATCH 7/9] New package: rocm_bandwidth_test-3.3.0

---
 srcpkgs/rocm_bandwidth_test/template | 20 ++++++++++++++++++++
 srcpkgs/rocm_bandwidth_test/update   |  1 +
 2 files changed, 21 insertions(+)
 create mode 100644 srcpkgs/rocm_bandwidth_test/template
 create mode 100644 srcpkgs/rocm_bandwidth_test/update

diff --git a/srcpkgs/rocm_bandwidth_test/template b/srcpkgs/rocm_bandwidth_test/template
new file mode 100644
index 00000000000..6de7f2d6614
--- /dev/null
+++ b/srcpkgs/rocm_bandwidth_test/template
@@ -0,0 +1,20 @@
+# Template file for 'rocm_bandwidth_test'
+pkgname=rocm_bandwidth_test
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="${pkgname}-rocm-${version}"
+build_style=cmake
+hostmakedepends="cmake"
+makedepends="ROCR-Runtime-devel ROCT-Thunk-Interface-devel"
+short_desc="Radeon Open Compute bandwidth test"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute/rocm_bandwidth_test"
+distfiles="${homepage}/archive/rocm-${version}.tar.gz"
+checksum=f5f914073018619dc91662d5bf630903dfa4db9136d603591917fdfb3c9164ce
+nocross=yes
+
+post_install() {
+	vlicense LICENSE.txt
+}
diff --git a/srcpkgs/rocm_bandwidth_test/update b/srcpkgs/rocm_bandwidth_test/update
new file mode 100644
index 00000000000..86197bc3eea
--- /dev/null
+++ b/srcpkgs/rocm_bandwidth_test/update
@@ -0,0 +1 @@
+pattern='rocm-\K[\d.]+'

From c18eb5f651c6749d6fff87791f9f8511011c2ceb Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Tue, 14 Apr 2020 10:25:54 -0400
Subject: [PATCH 8/9] New package: ROCm-OpenCL-Runtime-3.3.0

---
 common/shlibs                                 |   2 +
 srcpkgs/ROCm-OpenCL-Runtime-clinfo            |   1 +
 srcpkgs/ROCm-OpenCL-Runtime-devel             |   1 +
 .../files/libelf-musl.patch                   |  21 +++
 .../files/runtime-musl.patch                  |  11 ++
 .../ROCm-OpenCL-Runtime/patches/cmake.patch   | 126 ++++++++++++++++++
 srcpkgs/ROCm-OpenCL-Runtime/template          |  84 ++++++++++++
 srcpkgs/ROCm-OpenCL-Runtime/update            |   1 +
 8 files changed, 247 insertions(+)
 create mode 120000 srcpkgs/ROCm-OpenCL-Runtime-clinfo
 create mode 120000 srcpkgs/ROCm-OpenCL-Runtime-devel
 create mode 100644 srcpkgs/ROCm-OpenCL-Runtime/files/libelf-musl.patch
 create mode 100644 srcpkgs/ROCm-OpenCL-Runtime/files/runtime-musl.patch
 create mode 100644 srcpkgs/ROCm-OpenCL-Runtime/patches/cmake.patch
 create mode 100644 srcpkgs/ROCm-OpenCL-Runtime/template
 create mode 100644 srcpkgs/ROCm-OpenCL-Runtime/update

diff --git a/common/shlibs b/common/shlibs
index 393e464f683..28250aa3a3f 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3984,3 +3984,5 @@ libneatvnc.so.0 neatvnc-0.2.0_1
 libhsakmt.so.1 ROCT-Thunk-Interface-3.3.0_1
 libhsa-runtime64.so.1 ROCR-Runtime-3.3.0_1
 libamd_comgr.so.1 ROCm-CompilerSupport-3.3.0_1
+libOpenCL-ROCm.so.1 ROCm-OpenCL-Runtime-3.3.0_1
+libamdocl64.so ROCm-OpenCL-Runtime-3.3.0_1
diff --git a/srcpkgs/ROCm-OpenCL-Runtime-clinfo b/srcpkgs/ROCm-OpenCL-Runtime-clinfo
new file mode 120000
index 00000000000..21f2041b8fb
--- /dev/null
+++ b/srcpkgs/ROCm-OpenCL-Runtime-clinfo
@@ -0,0 +1 @@
+ROCm-OpenCL-Runtime
\ No newline at end of file
diff --git a/srcpkgs/ROCm-OpenCL-Runtime-devel b/srcpkgs/ROCm-OpenCL-Runtime-devel
new file mode 120000
index 00000000000..21f2041b8fb
--- /dev/null
+++ b/srcpkgs/ROCm-OpenCL-Runtime-devel
@@ -0,0 +1 @@
+ROCm-OpenCL-Runtime
\ No newline at end of file
diff --git a/srcpkgs/ROCm-OpenCL-Runtime/files/libelf-musl.patch b/srcpkgs/ROCm-OpenCL-Runtime/files/libelf-musl.patch
new file mode 100644
index 00000000000..29469a9a351
--- /dev/null
+++ b/srcpkgs/ROCm-OpenCL-Runtime/files/libelf-musl.patch
@@ -0,0 +1,21 @@
+--- compiler/lib/loaders/elf/utils/libelf/_libelf.h	2020-04-28 15:50:53.243438174 -0400
++++ compiler/lib/loaders/elf/utils/libelf/_libelf.h	2020-04-28 15:51:54.293435415 -0400
+@@ -35,6 +35,7 @@
+ #include "_libelf_config.h"
+ 
+ #include "_elftc.h"
++#include <sys/cdefs.h>
+ 
+ /*
+  * Library-private data structures.
+--- compiler/lib/loaders/elf/utils/libelf/libelf.h	2020-04-28 15:50:53.244438174 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf.h	2020-04-28 15:52:12.375434593 -0400
+@@ -36,6 +36,8 @@
+ #define EM_HSAIL 0xAF5A
+ #endif
+ 
++#include <sys/cdefs.h>
++
+ /* Library private data structures */
+ typedef struct _Elf Elf;
+ typedef struct _Elf_Scn Elf_Scn;
diff --git a/srcpkgs/ROCm-OpenCL-Runtime/files/runtime-musl.patch b/srcpkgs/ROCm-OpenCL-Runtime/files/runtime-musl.patch
new file mode 100644
index 00000000000..ea18e90e09c
--- /dev/null
+++ b/srcpkgs/ROCm-OpenCL-Runtime/files/runtime-musl.patch
@@ -0,0 +1,11 @@
+--- runtime/os/os_posix.cpp.orig	2020-04-19 09:13:51.701982901 -0400
++++ runtime/os/os_posix.cpp	2020-04-19 09:14:04.156947422 -0400
+@@ -44,6 +44,8 @@
+ #include <algorithm>
+ #include <mutex>
+ 
++#include <libgen.h> // for basename
++
+ 
+ namespace amd {
+ 
diff --git a/srcpkgs/ROCm-OpenCL-Runtime/patches/cmake.patch b/srcpkgs/ROCm-OpenCL-Runtime/patches/cmake.patch
new file mode 100644
index 00000000000..2c96b99d45a
--- /dev/null
+++ b/srcpkgs/ROCm-OpenCL-Runtime/patches/cmake.patch
@@ -0,0 +1,126 @@
+--- OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/CMakeLists.txt	2019-09-10 11:53:28.000000000 -0400
++++ OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/CMakeLists.txt	2020-04-16 20:16:13.481180757 -0400
+@@ -73,11 +73,11 @@
+ 
+ set (OPENCL_ICD_LOADER_HEADERS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/inc CACHE PATH "Path to OpenCL Headers")
+ 
+-add_library (OpenCL ${OPENCL_ICD_LOADER_SOURCES})
+-set_target_properties (OpenCL PROPERTIES VERSION "1.2" SOVERSION "1")
++add_library (OpenCL-ROCm ${OPENCL_ICD_LOADER_SOURCES})
++set_target_properties (OpenCL-ROCm PROPERTIES VERSION "1.2" SOVERSION "1")
+ 
+ if (WIN32)
+-    target_link_libraries (OpenCL cfgmgr32.lib)
++    target_link_libraries (OpenCL-ROCm cfgmgr32.lib)
+ 
+     option (OPENCL_ICD_LOADER_REQUIRE_WDK "Build with D3DKMT support, which requires the Windows WDK." ON)
+     if (OPENCL_ICD_LOADER_REQUIRE_WDK)
+@@ -92,10 +92,10 @@
+             get_filename_component(WDK_DIRECTORY ${LATEST_D3DKMT_HEADER} DIRECTORY)
+             get_filename_component(WDK_DIRECTORY ${WDK_DIRECTORY} DIRECTORY)
+             message(STATUS "Found the Windows WDK in: ${WDK_DIRECTORY}")
+-            target_compile_definitions(OpenCL PRIVATE OPENCL_ICD_LOADER_REQUIRE_WDK)
+-            target_include_directories(OpenCL PRIVATE ${WDK_DIRECTORY}/um)
+-            target_include_directories(OpenCL PRIVATE ${WDK_DIRECTORY}/km)
+-            target_include_directories(OpenCL PRIVATE ${WDK_DIRECTORY}/shared)
++	    target_compile_definitions(OpenCL-ROCm PRIVATE OPENCL_ICD_LOADER_REQUIRE_WDK)
++	    target_include_directories(OpenCL-ROCm PRIVATE ${WDK_DIRECTORY}/um)
++	    target_include_directories(OpenCL-ROCm PRIVATE ${WDK_DIRECTORY}/km)
++	    target_include_directories(OpenCL-ROCm PRIVATE ${WDK_DIRECTORY}/shared)
+         else()
+             message(FATAL_ERROR "The Windows WDK was not found. Consider disabling OPENCL_ICD_LOADER_REQUIRE_WDK. Aborting.")
+         endif()
+@@ -113,25 +113,25 @@
+     endif()
+ else()
+     if (APPLE)
+-        target_link_libraries (OpenCL ${CMAKE_THREAD_LIBS_INIT})
++        target_link_libraries (OpenCL-ROCm ${CMAKE_THREAD_LIBS_INIT})
+     else ()
+-        set_target_properties (OpenCL PROPERTIES LINK_FLAGS "-Wl,--version-script -Wl,${CMAKE_CURRENT_SOURCE_DIR}/loader/linux/icd_exports.map")
+-        target_link_libraries (OpenCL ${CMAKE_THREAD_LIBS_INIT})
++        set_target_properties (OpenCL-ROCm PROPERTIES LINK_FLAGS "-Wl,--version-script -Wl,${CMAKE_CURRENT_SOURCE_DIR}/loader/linux/icd_exports.map")
++	target_link_libraries (OpenCL-ROCm ${CMAKE_THREAD_LIBS_INIT})
+     endif ()
+ endif ()
+ 
+ include_directories (${OPENCL_ICD_LOADER_HEADERS_DIR})
+ add_definitions (-DCL_TARGET_OPENCL_VERSION=220)
+ 
+-target_include_directories (OpenCL PRIVATE ${CMAKE_CURRENT_BINARY_DIR} loader)
+-target_link_libraries (OpenCL ${CMAKE_DL_LIBS})
++target_include_directories (OpenCL-ROCm PRIVATE ${CMAKE_CURRENT_BINARY_DIR} loader)
++target_link_libraries (OpenCL-ROCm ${CMAKE_DL_LIBS})
+ 
+ include (CTest)
+ if (BUILD_TESTING)
+     add_subdirectory (test)
+ endif()
+ 
+-install (TARGETS OpenCL
++install (TARGETS OpenCL-ROCm
+     RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+     ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
+     LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
+--- OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/test/loader_test/CMakeLists.txt	2019-09-10 11:53:28.000000000 -0400
++++ OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/test/loader_test/CMakeLists.txt	2020-04-16 20:16:56.647026589 -0400
+@@ -12,4 +12,4 @@
+     test_clgl.c
+     test_image_objects.c )
+ 
+-target_link_libraries (icd_loader_test OpenCL IcdLog)
++target_link_libraries (icd_loader_test OpenCL-ROCm IcdLog)
+--- ROCm-OpenCL-Runtime-roc-3.3.0/CMakeLists.txt	2020-04-28 07:29:51.864446603 -0400
++++ ROCm-OpenCL-Runtime-roc-3.3.0/CMakeLists.txt	2020-04-28 07:32:45.245793180 -0400
+@@ -101,30 +101,30 @@
+ rocm_setup_version( VERSION "2.0.0" )
+ 
+ # MAIN package
+-install(PROGRAMS $<TARGET_FILE:clinfo>
+-        DESTINATION bin/x86_64
++install(PROGRAMS $<TARGET_FILE:rocm-clinfo>
++        DESTINATION bin
+         COMPONENT MAIN)
+ install(PROGRAMS $<TARGET_FILE:amdocl64>
+-        DESTINATION lib/x86_64
++        DESTINATION lib
+         COMPONENT MAIN)
+-install(PROGRAMS $<TARGET_FILE:OpenCL>
+-        DESTINATION lib/x86_64
++install(PROGRAMS $<TARGET_FILE:OpenCL-ROCm>
++        DESTINATION lib
+         COMPONENT MAIN)
+-install(PROGRAMS $<TARGET_SONAME_FILE:OpenCL>
+-        DESTINATION lib/x86_64
++install(PROGRAMS $<TARGET_SONAME_FILE:OpenCL-ROCm>
++        DESTINATION lib
+         COMPONENT MAIN)
+ 
+ # DEV package
+ install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/api/opencl/khronos/headers/opencl2.2/CL"
+-        DESTINATION include
++	DESTINATION include/rocm
+         COMPONENT DEV
+         USE_SOURCE_PERMISSIONS
+         PATTERN cl_d3d10.h EXCLUDE
+         PATTERN cl_d3d11.h EXCLUDE
+         PATTERN cl_dx9_media_sharing.h EXCLUDE
+         PATTERN cl_egl.h EXCLUDE)
+-install(PROGRAMS $<TARGET_LINKER_FILE:OpenCL>
+-        DESTINATION lib/x86_64
++install(PROGRAMS $<TARGET_LINKER_FILE:OpenCL-ROCm>
++        DESTINATION lib
+         COMPONENT DEV)
+ 
+ # Generic CPACK variables
+--- ROCm-OpenCL-Runtime-roc-3.3.0/tools/clinfo/CMakeLists.txt	2020-04-28 07:29:51.882446535 -0400
++++ ROCm-OpenCL-Runtime-roc-3.3.0/tools/clinfo/CMakeLists.txt	2020-04-28 07:30:05.627394732 -0400
+@@ -6,6 +6,6 @@
+ 
+ add_definitions(-DHAVE_CL2_HPP)
+ 
+-add_executable(clinfo clinfo.cpp)
++add_executable(rocm-clinfo clinfo.cpp)
+ 
+-target_link_libraries(clinfo OpenCL)
++target_link_libraries(rocm-clinfo OpenCL-ROCm)
diff --git a/srcpkgs/ROCm-OpenCL-Runtime/template b/srcpkgs/ROCm-OpenCL-Runtime/template
new file mode 100644
index 00000000000..f6699a1d4c0
--- /dev/null
+++ b/srcpkgs/ROCm-OpenCL-Runtime/template
@@ -0,0 +1,84 @@
+# Template file for 'ROCm-OpenCL-Runtime'
+pkgname=ROCm-OpenCL-Runtime
+version=3.3.0
+revision=1
+_ocl_icd_name="OpenCL-ICD-Loader"
+_ocl_icd_ver="6c03f8b58fafd9dd693eaac826749a5cfad515f8"
+archs="x86_64*"
+create_wrksrc=yes
+build_wrksrc="${pkgname}-roc-${version}"
+build_style=cmake
+configure_args="-DUSE_COMGR_LIBRARY=yes"
+hostmakedepends="cmake pkg-config"
+makedepends="libglvnd-devel ROCm-CompilerSupport-devel
+	ROCT-Thunk-Interface-devel ROCR-Runtime-devel"
+depends="ROCm-CompilerSupport"
+short_desc="Radeon Open Compute OpenCL runtime"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="MIT"
+homepage="https://github.com/RadeonOpenCompute/ROCm-OpenCL-Runtime"
+_rocroot="https://github.com/RadeonOpenCompute"
+distfiles="${_rocroot}/ROCm-OpenCL-Runtime/archive/roc-${version}.tar.gz
+	${_rocroot}/rocm-cmake/archive/rocm-${version}.tar.gz
+	https://github.com/KhronosGroup/${_ocl_icd_name}/archive/${_ocl_icd_ver}.tar.gz"
+checksum="ac6999f1a491ab066286c2bd6adf50f08f831286f56e267879f9f7eced22f98e
+	76ed3ee8e56cf3246011cf7723c2abda539e1136e7e7f6909bfa45d268b8644f
+	c94d5bb6dc980c4d41d73e2b81663a19aabe494e923e2d0eec72a4c95b318438"
+nocross=yes
+
+if [ "$XBPS_LIBC" = "musl" ]; then
+	makedepends+=" musl-legacy-compat"
+fi
+
+post_patch() {
+	if [ "$XBPS_LIBC" = "musl" ]; then
+		# Remove dependence on glibc
+		patch -Np0 < ${FILESDIR}/libelf-musl.patch
+		patch -Np0 < ${FILESDIR}/runtime-musl.patch
+		vsed -e '/glibc_functions.cpp/d' -i api/opencl/amdocl/CMakeLists.txt
+	fi
+}
+
+pre_configure() {
+	# ROCm requires a very specific Khronos ICD loader version in the tree
+	# Keep the ICD loader config in /etc/OpenCL/rocm-vendors to avoid conflicts
+	_ocl_icd_dir="${_ocl_icd_name}-${_ocl_icd_ver}"
+	ln -sf "${wrksrc}/${_ocl_icd_dir}" api/opencl/khronos/icd
+	vsed -i "${wrksrc}/${_ocl_icd_dir}/loader/icd_platform.h" \
+		-e 's@/etc/OpenCL/vendors/@/etc/OpenCL/rocm-vendors/@g'
+
+	# CMake modules probably not useful anywhere but for this build
+	ln -sf "${wrksrc}/rocm-cmake-rocm-${version}/share/rocm/cmake"/*.cmake cmake
+
+	# Fix the dlopen macro to point to versioned libamd_comgr shared object
+	vsed -i 'runtime/device/comgrctx.cpp' \
+		-e 's/\blibamd_comgr\(32\)\?.so\b/&.1/g'
+}
+
+post_install() {
+	vlicense License
+
+	# Create descriptor to allow the ICD loader to find the driver
+	vmkdir etc/OpenCL/rocm-vendors
+	echo "libamdocl64.so" > "${DESTDIR}/etc/OpenCL/rocm-vendors/amdocl64.icd"
+	vmkdir etc/OpenCL/vendors
+	ln -s ../../OpenCL/rocm-vendors/amdocl64.icd \
+		${DESTDIR}/etc/OpenCL/vendors/rocm-amdocl64.icd
+}
+
+ROCm-OpenCL-Runtime-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/lib/libOpenCL-ROCm.so
+		vmove usr/include
+	}
+}
+
+ROCm-OpenCL-Runtime-clinfo_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - clinfo"
+	pkg_install() {
+		vmove usr/bin/rocm-clinfo
+	}
+}
diff --git a/srcpkgs/ROCm-OpenCL-Runtime/update b/srcpkgs/ROCm-OpenCL-Runtime/update
new file mode 100644
index 00000000000..8385f4d1215
--- /dev/null
+++ b/srcpkgs/ROCm-OpenCL-Runtime/update
@@ -0,0 +1 @@
+pattern='roc-\K[\d.]+'

From 8fb59c86f69c5f43726fc0be4f813444a06fde38 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Thu, 30 Apr 2020 13:11:12 -0400
Subject: [PATCH 9/9] New package: ROCR-Runtime-hsa-ext-3.3.0

[ci skip]
---
 common/shlibs                         |  2 ++
 srcpkgs/ROCR-Runtime-hsa-ext-devel    |  1 +
 srcpkgs/ROCR-Runtime-hsa-ext/template | 43 +++++++++++++++++++++++++++
 srcpkgs/ROCR-Runtime-hsa-ext/update   |  2 ++
 4 files changed, 48 insertions(+)
 create mode 120000 srcpkgs/ROCR-Runtime-hsa-ext-devel
 create mode 100644 srcpkgs/ROCR-Runtime-hsa-ext/template
 create mode 100644 srcpkgs/ROCR-Runtime-hsa-ext/update

diff --git a/common/shlibs b/common/shlibs
index 28250aa3a3f..66392db5c99 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3986,3 +3986,5 @@ libhsa-runtime64.so.1 ROCR-Runtime-3.3.0_1
 libamd_comgr.so.1 ROCm-CompilerSupport-3.3.0_1
 libOpenCL-ROCm.so.1 ROCm-OpenCL-Runtime-3.3.0_1
 libamdocl64.so ROCm-OpenCL-Runtime-3.3.0_1
+libhsa-ext-image64.so.1 ROCR-Runtime-hsa-ext-3.3.0_1
+libhsa-runtime-tools64.so.1 ROCR-Runtime-hsa-ext-3.3.0_1
diff --git a/srcpkgs/ROCR-Runtime-hsa-ext-devel b/srcpkgs/ROCR-Runtime-hsa-ext-devel
new file mode 120000
index 00000000000..6ee1b14911b
--- /dev/null
+++ b/srcpkgs/ROCR-Runtime-hsa-ext-devel
@@ -0,0 +1 @@
+ROCR-Runtime-hsa-ext
\ No newline at end of file
diff --git a/srcpkgs/ROCR-Runtime-hsa-ext/template b/srcpkgs/ROCR-Runtime-hsa-ext/template
new file mode 100644
index 00000000000..235ae92146b
--- /dev/null
+++ b/srcpkgs/ROCR-Runtime-hsa-ext/template
@@ -0,0 +1,43 @@
+# Template file for 'ROCR-Runtime-hsa-ext'
+pkgname=ROCR-Runtime-hsa-ext
+version=3.3.0
+revision=1
+archs="x86_64"
+hostmakedepends="tar"
+short_desc="Radeon Open Compute HSA runtime extensions"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute"
+_hsa_deb="hsa-ext-rocr-dev_1.1.30300.0-rocm-rel-3.3-19-23fc088b_amd64.deb"
+distfiles="https://repo.radeon.com/rocm/apt/debian/pool/main/h/hsa-ext-rocr-dev/$_hsa_deb"
+checksum=6b44e286b395d946b865ec1f3cc546356396785ac1fde591d07af02d0aa7c25d
+repository=nonfree
+restricted=yes
+
+do_extract() {
+	ar x "${XBPS_SRCDISTDIR}/${pkgname}-${version}/${_hsa_deb}"
+	tar xvf data.tar.gz
+}
+
+do_install() {
+	_rocm_includes="opt/rocm-${version}/hsa/include"
+
+	vmkdir usr
+	vcopy opt/rocm-${version}/hsa/lib usr
+	vcopy "$_rocm_includes" usr
+
+	# Extract license from one of the header files
+	awk 'BEGIN{HEADER=0} /\/\//{HEADER=1; print $0;} /^[^/]/{if(HEADER==1) exit;}' \
+		< "${_rocm_includes}/hsa/amd_hsa_tools_interfaces.h" \
+		| sed 's@^///*\( \|$\)@@' > LICENSE
+	vlicense LICENSE
+}
+
+ROCR-Runtime-hsa-ext-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove "usr/lib/*.so"
+	}
+}
diff --git a/srcpkgs/ROCR-Runtime-hsa-ext/update b/srcpkgs/ROCR-Runtime-hsa-ext/update
new file mode 100644
index 00000000000..84252d2e3b8
--- /dev/null
+++ b/srcpkgs/ROCR-Runtime-hsa-ext/update
@@ -0,0 +1,2 @@
+site='https://repo.radeon.com/rocm/apt/debian/pool/main/h/'
+pattern='hsa-ext-rocr-dev\K[\d.]+'

^ permalink raw reply	[flat|nested] 61+ messages in thread

* Re: [PR PATCH] [Closed]: New packages: ROCm core and OpenCL
  2020-04-19 13:34 [PR PATCH] New packages: ROCm core and OpenCL ahesford
                   ` (46 preceding siblings ...)
  2020-08-04 17:13 ` ahesford
@ 2020-08-04 17:16 ` ahesford
  2020-08-04 17:16 ` [PR PATCH] [Updated] " ahesford
                   ` (11 subsequent siblings)
  59 siblings, 0 replies; 61+ messages in thread
From: ahesford @ 2020-08-04 17:16 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 3738 bytes --]

There's a closed pull request on the void-packages repository

New packages: ROCm core and OpenCL
https://github.com/void-linux/void-packages/pull/21153

Description:
This PR includes several packages designed to bring the OpenCL portion of the AMD ROCm ecosystem to Void. It addresses Issue #19507. There are many other packages that AMD provides for GPGPU computing, but these can be added piecemeal as users demand.

The packages are currently only for `x86_64*`. While at least some of the packages will compile on other 64-bit architectures, I have no hardware to test. They are certainly not suitable for 32-bit architectures; some internal data structures rely on `uint64_t` values that are cast to pointers. At a
minimum, a thorough audit would be necessary to ensure that these casts are safe (e.g., that the values stored were only ever upcast from 32-bit pointers). More extensive work may be necessary to support 32-bit architectures, probably without significant benefit.

The packages successfully identify a Radeon RX 580 on an `x86_64` installation using both `clinfo` and `rocminfo` as provided. Furthermore, a version of `pyopencl` linked against these ROCm packages successfully runs a simple program that validates arithmetic on GPU-bound arrays.

There are caveats with this set of packages, almost all of which revolve around the incompatibilities between the Void-provided `ocl-icd` and the [Khronos OpenCL ICD loader](https://github.com/KhronosGroup/OpenCL-ID-Loader) required by (and built into) `rocm-opencl-runtime`.
1. All packages install into `/opt/rocm`. This keeps the environment closer to that officially sanctioned by AMD and helps avoid conflicts between other packages and those provided here. (For example, `clinfo` and the ICD loader itself.) Eventually, we may be able to move the files into `/usr`.
2. The Khronos OpenCL ICD loader built into `rocm-opencl-runtime` is an outdated, pre-release commit. If AMD can update its sources to use the release version of that loader (which has a backward-incompatible API change), we may be able to make ROCm compatible with `ocl-icd` or replace `ocl-icd` with the official Khronos loader.
3. In the meantime, to avoid `shlibs` conflicts, the OpenCL ICD loader is installed as `/opt/rocm/lib/libOpenCL-ROCm.so` (and an appropriately versioned shared library), which means that programs wishing to use the ROCm OpenCL must explicitly link against this library instead of the generic `libOpenCL.so`.
4. I do **not** recommend making any Void packages link against this specific library, because it will make those packages ROCm-only. For the time being, ROCm is intended for end-users to specifically link against. Linking Void packages against ROCm would requires the ICD loader used by ROCm be compatible with `ocl-icd`, or `ocl-icd` be replaced by the Khronos loader. However, because the Khronos loader changed its API for the release version, such a change is not yet appropriate.

Hopefully, if AMD updates its dependence on the Khronos ICD loader, we can resolve some of these caveats in the future and make ROCm a more natural Void component. For now, these packages are useful for those who need an AMD OpenCL solution and would rather custom-link software against the AMD ICD loader than hack the `amdgpu-pro` driver into an ICD compatible with `ocl-icd`.

Some patches were made to relocate some files in `/opt/rocm` and make everyting build on x86_64-musl`. Where appropriate, these patches will be pushed upstream to clean up the distribution and packaging.

Update: I pushed some new commits to update license information that triggerd an `xlint` failure. I've also disabled CI builds because they will time out on `rocm-llvm`.

^ permalink raw reply	[flat|nested] 61+ messages in thread

* Re: [PR PATCH] [Updated] New packages: ROCm core and OpenCL
  2020-04-19 13:34 [PR PATCH] New packages: ROCm core and OpenCL ahesford
                   ` (47 preceding siblings ...)
  2020-08-04 17:16 ` [PR PATCH] [Closed]: " ahesford
@ 2020-08-04 17:16 ` ahesford
  2020-08-04 17:19 ` ahesford
                   ` (10 subsequent siblings)
  59 siblings, 0 replies; 61+ messages in thread
From: ahesford @ 2020-08-04 17:16 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 3893 bytes --]

There is an updated pull request by ahesford against master on the void-packages repository

https://github.com/ahesford/void-packages rocm
https://github.com/void-linux/void-packages/pull/21153

New packages: ROCm core and OpenCL
This PR includes several packages designed to bring the OpenCL portion of the AMD ROCm ecosystem to Void. It addresses Issue #19507. There are many other packages that AMD provides for GPGPU computing, but these can be added piecemeal as users demand.

The packages are currently only for `x86_64*`. While at least some of the packages will compile on other 64-bit architectures, I have no hardware to test. They are certainly not suitable for 32-bit architectures; some internal data structures rely on `uint64_t` values that are cast to pointers. At a
minimum, a thorough audit would be necessary to ensure that these casts are safe (e.g., that the values stored were only ever upcast from 32-bit pointers). More extensive work may be necessary to support 32-bit architectures, probably without significant benefit.

The packages successfully identify a Radeon RX 580 on an `x86_64` installation using both `clinfo` and `rocminfo` as provided. Furthermore, a version of `pyopencl` linked against these ROCm packages successfully runs a simple program that validates arithmetic on GPU-bound arrays.

There are caveats with this set of packages, almost all of which revolve around the incompatibilities between the Void-provided `ocl-icd` and the [Khronos OpenCL ICD loader](https://github.com/KhronosGroup/OpenCL-ID-Loader) required by (and built into) `rocm-opencl-runtime`.
1. All packages install into `/opt/rocm`. This keeps the environment closer to that officially sanctioned by AMD and helps avoid conflicts between other packages and those provided here. (For example, `clinfo` and the ICD loader itself.) Eventually, we may be able to move the files into `/usr`.
2. The Khronos OpenCL ICD loader built into `rocm-opencl-runtime` is an outdated, pre-release commit. If AMD can update its sources to use the release version of that loader (which has a backward-incompatible API change), we may be able to make ROCm compatible with `ocl-icd` or replace `ocl-icd` with the official Khronos loader.
3. In the meantime, to avoid `shlibs` conflicts, the OpenCL ICD loader is installed as `/opt/rocm/lib/libOpenCL-ROCm.so` (and an appropriately versioned shared library), which means that programs wishing to use the ROCm OpenCL must explicitly link against this library instead of the generic `libOpenCL.so`.
4. I do **not** recommend making any Void packages link against this specific library, because it will make those packages ROCm-only. For the time being, ROCm is intended for end-users to specifically link against. Linking Void packages against ROCm would requires the ICD loader used by ROCm be compatible with `ocl-icd`, or `ocl-icd` be replaced by the Khronos loader. However, because the Khronos loader changed its API for the release version, such a change is not yet appropriate.

Hopefully, if AMD updates its dependence on the Khronos ICD loader, we can resolve some of these caveats in the future and make ROCm a more natural Void component. For now, these packages are useful for those who need an AMD OpenCL solution and would rather custom-link software against the AMD ICD loader than hack the `amdgpu-pro` driver into an ICD compatible with `ocl-icd`.

Some patches were made to relocate some files in `/opt/rocm` and make everyting build on x86_64-musl`. Where appropriate, these patches will be pushed upstream to clean up the distribution and packaging.

Update: I pushed some new commits to update license information that triggerd an `xlint` failure. I've also disabled CI builds because they will time out on `rocm-llvm`.

A patch file from https://github.com/void-linux/void-packages/pull/21153.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-rocm-21153.patch --]
[-- Type: text/x-diff, Size: 0 bytes --]



^ permalink raw reply	[flat|nested] 61+ messages in thread

* Re: New packages: ROCm core and OpenCL
  2020-04-19 13:34 [PR PATCH] New packages: ROCm core and OpenCL ahesford
                   ` (48 preceding siblings ...)
  2020-08-04 17:16 ` [PR PATCH] [Updated] " ahesford
@ 2020-08-04 17:19 ` ahesford
  2020-08-04 17:24 ` [PR PATCH] [Updated] " ahesford
                   ` (9 subsequent siblings)
  59 siblings, 0 replies; 61+ messages in thread
From: ahesford @ 2020-08-04 17:19 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 281 bytes --]

New comment by ahesford on void-packages repository

https://github.com/void-linux/void-packages/pull/21153#issuecomment-668722456

Comment:
I'm not sure what changes are in the AMD fork, but they want the code object manager and device libs to be compiled with their own version.

^ permalink raw reply	[flat|nested] 61+ messages in thread

* Re: [PR PATCH] [Updated] New packages: ROCm core and OpenCL
  2020-04-19 13:34 [PR PATCH] New packages: ROCm core and OpenCL ahesford
                   ` (49 preceding siblings ...)
  2020-08-04 17:19 ` ahesford
@ 2020-08-04 17:24 ` ahesford
  2020-08-18 18:36 ` aurieh
                   ` (8 subsequent siblings)
  59 siblings, 0 replies; 61+ messages in thread
From: ahesford @ 2020-08-04 17:24 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 3893 bytes --]

There is an updated pull request by ahesford against master on the void-packages repository

https://github.com/ahesford/void-packages rocm
https://github.com/void-linux/void-packages/pull/21153

New packages: ROCm core and OpenCL
This PR includes several packages designed to bring the OpenCL portion of the AMD ROCm ecosystem to Void. It addresses Issue #19507. There are many other packages that AMD provides for GPGPU computing, but these can be added piecemeal as users demand.

The packages are currently only for `x86_64*`. While at least some of the packages will compile on other 64-bit architectures, I have no hardware to test. They are certainly not suitable for 32-bit architectures; some internal data structures rely on `uint64_t` values that are cast to pointers. At a
minimum, a thorough audit would be necessary to ensure that these casts are safe (e.g., that the values stored were only ever upcast from 32-bit pointers). More extensive work may be necessary to support 32-bit architectures, probably without significant benefit.

The packages successfully identify a Radeon RX 580 on an `x86_64` installation using both `clinfo` and `rocminfo` as provided. Furthermore, a version of `pyopencl` linked against these ROCm packages successfully runs a simple program that validates arithmetic on GPU-bound arrays.

There are caveats with this set of packages, almost all of which revolve around the incompatibilities between the Void-provided `ocl-icd` and the [Khronos OpenCL ICD loader](https://github.com/KhronosGroup/OpenCL-ID-Loader) required by (and built into) `rocm-opencl-runtime`.
1. All packages install into `/opt/rocm`. This keeps the environment closer to that officially sanctioned by AMD and helps avoid conflicts between other packages and those provided here. (For example, `clinfo` and the ICD loader itself.) Eventually, we may be able to move the files into `/usr`.
2. The Khronos OpenCL ICD loader built into `rocm-opencl-runtime` is an outdated, pre-release commit. If AMD can update its sources to use the release version of that loader (which has a backward-incompatible API change), we may be able to make ROCm compatible with `ocl-icd` or replace `ocl-icd` with the official Khronos loader.
3. In the meantime, to avoid `shlibs` conflicts, the OpenCL ICD loader is installed as `/opt/rocm/lib/libOpenCL-ROCm.so` (and an appropriately versioned shared library), which means that programs wishing to use the ROCm OpenCL must explicitly link against this library instead of the generic `libOpenCL.so`.
4. I do **not** recommend making any Void packages link against this specific library, because it will make those packages ROCm-only. For the time being, ROCm is intended for end-users to specifically link against. Linking Void packages against ROCm would requires the ICD loader used by ROCm be compatible with `ocl-icd`, or `ocl-icd` be replaced by the Khronos loader. However, because the Khronos loader changed its API for the release version, such a change is not yet appropriate.

Hopefully, if AMD updates its dependence on the Khronos ICD loader, we can resolve some of these caveats in the future and make ROCm a more natural Void component. For now, these packages are useful for those who need an AMD OpenCL solution and would rather custom-link software against the AMD ICD loader than hack the `amdgpu-pro` driver into an ICD compatible with `ocl-icd`.

Some patches were made to relocate some files in `/opt/rocm` and make everyting build on x86_64-musl`. Where appropriate, these patches will be pushed upstream to clean up the distribution and packaging.

Update: I pushed some new commits to update license information that triggerd an `xlint` failure. I've also disabled CI builds because they will time out on `rocm-llvm`.

A patch file from https://github.com/void-linux/void-packages/pull/21153.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-rocm-21153.patch --]
[-- Type: text/x-diff, Size: 35439 bytes --]

From 5cbdcb738fa646996cbf8e119465300742bca327 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Mon, 13 Apr 2020 13:08:09 -0400
Subject: [PATCH 1/9] New package: ROCT-Thunk-Interface-3.3.0

---
 common/shlibs                                 |  1 +
 srcpkgs/ROCT-Thunk-Interface-devel            |  1 +
 .../patches/cmake-dev-libdir.patch            | 10 ++++++
 .../ROCT-Thunk-Interface/patches/musl.patch   | 29 ++++++++++++++++
 srcpkgs/ROCT-Thunk-Interface/template         | 33 +++++++++++++++++++
 srcpkgs/ROCT-Thunk-Interface/update           |  1 +
 6 files changed, 75 insertions(+)
 create mode 120000 srcpkgs/ROCT-Thunk-Interface-devel
 create mode 100644 srcpkgs/ROCT-Thunk-Interface/patches/cmake-dev-libdir.patch
 create mode 100644 srcpkgs/ROCT-Thunk-Interface/patches/musl.patch
 create mode 100644 srcpkgs/ROCT-Thunk-Interface/template
 create mode 100644 srcpkgs/ROCT-Thunk-Interface/update

diff --git a/common/shlibs b/common/shlibs
index dcb1d8e54b6..4f93db41216 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3981,3 +3981,4 @@ libcglm.so.0 cglm-0.7.6_1
 libfcft.so.3 fcft-2.2.2_1
 libaml.so.0 aml-0.1.0_1
 libneatvnc.so.0 neatvnc-0.2.0_1
+libhsakmt.so.1 ROCT-Thunk-Interface-3.3.0_1
diff --git a/srcpkgs/ROCT-Thunk-Interface-devel b/srcpkgs/ROCT-Thunk-Interface-devel
new file mode 120000
index 00000000000..7e43c209e3d
--- /dev/null
+++ b/srcpkgs/ROCT-Thunk-Interface-devel
@@ -0,0 +1 @@
+ROCT-Thunk-Interface
\ No newline at end of file
diff --git a/srcpkgs/ROCT-Thunk-Interface/patches/cmake-dev-libdir.patch b/srcpkgs/ROCT-Thunk-Interface/patches/cmake-dev-libdir.patch
new file mode 100644
index 00000000000..98c7f1e459c
--- /dev/null
+++ b/srcpkgs/ROCT-Thunk-Interface/patches/cmake-dev-libdir.patch
@@ -0,0 +1,10 @@
+--- CMakeLists.txt.old	2020-04-18 19:45:17.306081135 -0400
++++ CMakeLists.txt	2020-04-18 19:46:51.300753636 -0400
+@@ -146,6 +146,7 @@
+     COMMAND ${CMAKE_COMMAND}
+         -DSOURCE_DIR="${SOURCE_DIR}"
+         -DCMAKE_INSTALL_PREFIX="${CMAKE_INSTALL_PREFIX}"
++        -DCMAKE_INSTALL_LIBDIR="${CMAKE_INSTALL_LIBDIR}"
+         -DCPACK_RPM_PACKAGE_REQUIRES="hsakmt-roct"
+         -DCPACK_PACKAGING_INSTALL_PREFIX="${CPACK_PACKAGING_INSTALL_PREFIX}"
+         -DVERSION="${BUILD_VERSION_STRING}"
diff --git a/srcpkgs/ROCT-Thunk-Interface/patches/musl.patch b/srcpkgs/ROCT-Thunk-Interface/patches/musl.patch
new file mode 100644
index 00000000000..aeea9832411
--- /dev/null
+++ b/srcpkgs/ROCT-Thunk-Interface/patches/musl.patch
@@ -0,0 +1,29 @@
+diff -r -u old/src/libhsakmt.h new/src/libhsakmt.h
+--- src/libhsakmt.h	2020-03-04 15:00:47.000000000 -0500
++++ src/libhsakmt.h	2020-04-13 12:58:30.444865992 -0400
+@@ -54,6 +54,10 @@
+ #define CHECK_KFD_OPEN() \
+ 	do { if (kfd_open_count == 0 || hsakmt_forked) return HSAKMT_STATUS_KERNEL_IO_CHANNEL_NOT_OPENED; } while (0)
+ 
++/*On some platforms, a PAGE_SIZE macro eclipses the extern variable*/
++#ifdef PAGE_SIZE
++#undef PAGE_SIZE
++#endif
+ extern int PAGE_SIZE;
+ extern int PAGE_SHIFT;
+ 
+diff -r -u old/src/topology.c new/src/topology.c
+--- src/topology.c	2020-03-04 15:00:47.000000000 -0500
++++ src/topology.c	2020-04-13 13:01:31.209870701 -0400
+@@ -38,6 +38,11 @@
+ #include "libhsakmt.h"
+ #include "fmm.h"
+ 
++/*Needed on MUSL*/
++#ifndef MAXNAMLEN
++#define MAXNAMLEN PATH_MAX
++#endif
++
+ /* Number of memory banks added by thunk on top of topology
+  * This only includes static heaps like LDS, scratch and SVM,
+  * not for MMIO_REMAP heap. MMIO_REMAP memory bank is reported
diff --git a/srcpkgs/ROCT-Thunk-Interface/template b/srcpkgs/ROCT-Thunk-Interface/template
new file mode 100644
index 00000000000..8c680b2af29
--- /dev/null
+++ b/srcpkgs/ROCT-Thunk-Interface/template
@@ -0,0 +1,33 @@
+# Template file for 'ROCT-Thunk-Interface'
+pkgname=ROCT-Thunk-Interface
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="${pkgname}-roc-${version}"
+build_style=cmake
+make_build_target="all build-dev"
+make_install_target="install install-dev"
+hostmakedepends="cmake pkg-config"
+makedepends="pciutils-devel libnuma-devel"
+short_desc="Radeon Open Compute thunk interface"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="MIT"
+homepage="https://github.com/RadeonOpenCompute/ROCT-Thunk-Interface"
+distfiles="${homepage}/archive/roc-${version}.tar.gz"
+checksum=2cabe9d2cfa72031c05d11290837c476182e72d8dec2049298f691143fdd212b
+nocross=yes
+
+post_install() {
+	vlicense LICENSE.md
+}
+
+ROCT-Thunk-Interface-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove "usr/lib/*.so"
+		vmove usr/share/pkgconfig
+		vmove usr/lib/cmake
+	}
+}
diff --git a/srcpkgs/ROCT-Thunk-Interface/update b/srcpkgs/ROCT-Thunk-Interface/update
new file mode 100644
index 00000000000..8385f4d1215
--- /dev/null
+++ b/srcpkgs/ROCT-Thunk-Interface/update
@@ -0,0 +1 @@
+pattern='roc-\K[\d.]+'

From 8738399f72c96ba594d928abc2c165da2cc0772b Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Mon, 13 Apr 2020 15:27:27 -0400
Subject: [PATCH 2/9] New package: ROCR-Runtime-3.3.0

---
 common/shlibs                            |  1 +
 srcpkgs/ROCR-Runtime-devel               |  1 +
 srcpkgs/ROCR-Runtime/patches/cmake.patch | 27 +++++++++++++++++++++
 srcpkgs/ROCR-Runtime/template            | 30 ++++++++++++++++++++++++
 srcpkgs/ROCR-Runtime/update              |  1 +
 5 files changed, 60 insertions(+)
 create mode 120000 srcpkgs/ROCR-Runtime-devel
 create mode 100644 srcpkgs/ROCR-Runtime/patches/cmake.patch
 create mode 100644 srcpkgs/ROCR-Runtime/template
 create mode 100644 srcpkgs/ROCR-Runtime/update

diff --git a/common/shlibs b/common/shlibs
index 4f93db41216..944ab37c190 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3982,3 +3982,4 @@ libfcft.so.3 fcft-2.2.2_1
 libaml.so.0 aml-0.1.0_1
 libneatvnc.so.0 neatvnc-0.2.0_1
 libhsakmt.so.1 ROCT-Thunk-Interface-3.3.0_1
+libhsa-runtime64.so.1 ROCR-Runtime-3.3.0_1
diff --git a/srcpkgs/ROCR-Runtime-devel b/srcpkgs/ROCR-Runtime-devel
new file mode 120000
index 00000000000..a733fb9fbab
--- /dev/null
+++ b/srcpkgs/ROCR-Runtime-devel
@@ -0,0 +1 @@
+ROCR-Runtime
\ No newline at end of file
diff --git a/srcpkgs/ROCR-Runtime/patches/cmake.patch b/srcpkgs/ROCR-Runtime/patches/cmake.patch
new file mode 100644
index 00000000000..93b74cd2297
--- /dev/null
+++ b/srcpkgs/ROCR-Runtime/patches/cmake.patch
@@ -0,0 +1,27 @@
+--- src/CMakeLists.txt.old	2020-04-18 20:01:48.549636995 -0400
++++ src/CMakeLists.txt	2020-04-18 20:04:00.177179781 -0400
+@@ -108,8 +108,8 @@
+ ## ROCr build internal versioning
+ add_definitions ( -DROCR_BUILD_ID=${PACKAGE_VERSION_STRING} )
+ 
+-## Set RUNPATH - ../../lib covers use of the legacy symlink in /hsa/lib/
+-set(CMAKE_INSTALL_RPATH "$ORIGIN;$ORIGIN/../../lib;$ORIGIN/../../lib64;$ORIGIN/../lib64")
++## Set RUNPATH
++set(CMAKE_INSTALL_RPATH "$ORIGIN;$ORIGIN/../lib")
+ 
+ ## ------------------------- Linux Compiler and Linker options -------------------------
+ set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -fexceptions -fno-rtti -fvisibility=hidden -Wno-error=sign-compare -Wno-sign-compare -Wno-write-strings -Wno-conversion-null -fno-math-errno -fno-threadsafe-statics -fmerge-all-constants -fms-extensions -Wno-error=comment -Wno-comment -Wno-error=pointer-arith -Wno-pointer-arith -Wno-error=unused-variable -Wno-error=unused-function" )
+@@ -185,11 +185,8 @@
+ add_custom_target ( hsa_lib_link2 ALL WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMAND ${CMAKE_COMMAND} -E create_symlink ../hsa/lib/${CORE_RUNTIME_LIBRARY}.so.${SO_MAJOR} ${CORE_RUNTIME_LIBRARY}-link.so.${SO_MAJOR} )
+ 
+ ## Set install information
+-install ( TARGETS ${CORE_RUNTIME_TARGET} LIBRARY DESTINATION hsa/lib )
+-install ( DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/inc/ DESTINATION hsa/include/hsa )
+-install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/hsa_include_link DESTINATION include PERMISSIONS OWNER_WRITE OWNER_READ RENAME hsa )
+-install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/${CORE_RUNTIME_LIBRARY}-link.so DESTINATION lib PERMISSIONS OWNER_WRITE OWNER_READ RENAME ${CORE_RUNTIME_LIBRARY}.so )
+-install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/${CORE_RUNTIME_LIBRARY}-link.so.${SO_MAJOR} DESTINATION lib PERMISSIONS OWNER_WRITE OWNER_READ RENAME ${CORE_RUNTIME_LIBRARY}.so.${SO_MAJOR} )
++install ( TARGETS ${CORE_RUNTIME_TARGET} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} )
++install ( DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/inc/ DESTINATION include/hsa )
+ 
+ ## Packaging directives
+ set ( CPACK_GENERATOR "DEB;RPM" CACHE STRING "Package types to build")
diff --git a/srcpkgs/ROCR-Runtime/template b/srcpkgs/ROCR-Runtime/template
new file mode 100644
index 00000000000..95b7e701afb
--- /dev/null
+++ b/srcpkgs/ROCR-Runtime/template
@@ -0,0 +1,30 @@
+# Template file for 'ROCR-Runtime'
+pkgname=ROCR-Runtime
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="${pkgname}-rocm-${version}"
+build_wrksrc="src"
+build_style=cmake
+hostmakedepends="cmake pkg-config"
+makedepends="ROCT-Thunk-Interface-devel elfutils-devel"
+short_desc="Radeon Open Compute HSA runtime"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute/ROCR-Runtime"
+distfiles="${homepage}/archive/rocm-${version}.tar.gz"
+checksum=fa2d2d1f8a61d8a6952d377cf288d78c61776c3c2a666f163cafc3aa19ab0b61
+nocross=yes
+
+post_install() {
+	vlicense ../LICENSE.txt
+}
+
+ROCR-Runtime-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove "usr/lib/*.so"
+	}
+}
diff --git a/srcpkgs/ROCR-Runtime/update b/srcpkgs/ROCR-Runtime/update
new file mode 100644
index 00000000000..86197bc3eea
--- /dev/null
+++ b/srcpkgs/ROCR-Runtime/update
@@ -0,0 +1 @@
+pattern='rocm-\K[\d.]+'

From 0ee0f3f609c9c3743099173482d2c4a26a045b1f Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Mon, 13 Apr 2020 18:07:34 -0400
Subject: [PATCH 3/9] New package: ROCm-llvm-3.3.0

---
 srcpkgs/ROCm-llvm/template | 26 ++++++++++++++++++++++++++
 srcpkgs/ROCm-llvm/update   |  1 +
 2 files changed, 27 insertions(+)
 create mode 100644 srcpkgs/ROCm-llvm/template
 create mode 100644 srcpkgs/ROCm-llvm/update

diff --git a/srcpkgs/ROCm-llvm/template b/srcpkgs/ROCm-llvm/template
new file mode 100644
index 00000000000..4c3095b21f4
--- /dev/null
+++ b/srcpkgs/ROCm-llvm/template
@@ -0,0 +1,26 @@
+# Template file for 'ROCm-llvm'
+pkgname=ROCm-llvm
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="llvm-project-rocm-ocl-${version}"
+build_wrksrc=llvm
+build_style=cmake
+configure_args="-DCMAKE_INSTALL_PREFIX:PATH=/usr/lib/rocm-llvm
+	-DLLVM_ENABLE_PROJECTS='llvm;clang;lld' -DLLVM_TARGETS_TO_BUILD='AMDGPU'
+	-DLLVM_BUILD_DOCS=NO -DLLVM_ENABLE_OCAMLDOC=OFF
+	-DLLVM_ENABLE_SPHINX=NO -DLLVM_ENABLE_DOXYGEN=OFF
+	-DLLVM_INSTALL_UTILS=ON -DLLVM_VERSION_SUFFIX=roc -DOCAMLFIND=NO"
+hostmakedepends="cmake pkg-config python3"
+short_desc="Radeon Open Compute LLVM toolchain"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="Apache-2.0, NCSA, custom:LLVM-Exceptions"
+homepage="https://github.com/RadeonOpenCompute/llvm-project"
+distfiles="${homepage}/archive/rocm-ocl-${version}.tar.gz"
+checksum=a2bef7042e8e2f2cd8548cb246b88322e1c77188839983dcac8312d56f544dc8
+python_version=3
+nocross=yes
+
+post_install() {
+	vlicense LICENSE.TXT
+}
diff --git a/srcpkgs/ROCm-llvm/update b/srcpkgs/ROCm-llvm/update
new file mode 100644
index 00000000000..6a73667d3c1
--- /dev/null
+++ b/srcpkgs/ROCm-llvm/update
@@ -0,0 +1 @@
+pattern='rocm-ocl-\K[\d.]+'

From 7d6f1904eed5b3c2a8eff961859916d886c4eefb Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Tue, 14 Apr 2020 10:25:31 -0400
Subject: [PATCH 4/9] New package: ROCm-Device-Libs-3.3.0

---
 srcpkgs/ROCm-Device-Libs/template | 37 +++++++++++++++++++++++++++++++
 srcpkgs/ROCm-Device-Libs/update   |  1 +
 2 files changed, 38 insertions(+)
 create mode 100644 srcpkgs/ROCm-Device-Libs/template
 create mode 100644 srcpkgs/ROCm-Device-Libs/update

diff --git a/srcpkgs/ROCm-Device-Libs/template b/srcpkgs/ROCm-Device-Libs/template
new file mode 100644
index 00000000000..8086cd86450
--- /dev/null
+++ b/srcpkgs/ROCm-Device-Libs/template
@@ -0,0 +1,37 @@
+# Template file for 'ROCm-Device-Libs'
+pkgname=ROCm-Device-Libs
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="${pkgname}-rocm-ocl-${version}"
+build_style=cmake
+configure_args="-DLLVM_DIR:PATH=/usr/lib/rocm-llvm
+	-DCMAKE_INSTALL_LIBDIR:PATH=lib/rocm-device-libs"
+hostmakedepends="cmake ROCm-llvm"
+short_desc="Radeon Open Compute device libraries"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute/ROCm-Device-Libs"
+distfiles="${homepage}/archive/rocm-ocl-${version}.tar.gz"
+checksum=706b08230790e08ca6a7a2fb7687d6131fd39a562148340e00fa37a6c06769c5
+nocross=yes
+
+pre_configure() {
+	# Put bytecodes in a lib/ subdirectory
+	vsed -i Packages.cmake -e 's@/lib/@/${CMAKE_INSTALL_LIBDIR}/@'
+	vsed -i OCL.cmake -e 's@DESTINATION lib$@DESTINATION ${CMAKE_INSTALL_LIBDIR}@'
+
+	# Build the prepare-builtins executable with native compiler
+	mkdir -p utils/build
+	cd utils/build
+	_prepare_builtins="$PWD/prepare-builtins/prepare-builtins"
+	cmake ${configure_args} ..
+	make ${makejobs}
+
+	# Add path to prepare-builtins for cmake
+	configure_args+=" -DPREPARE_BUILTINS='${_prepare_builtins}'"
+}
+
+post_install() {
+	vlicense LICENSE
+}
diff --git a/srcpkgs/ROCm-Device-Libs/update b/srcpkgs/ROCm-Device-Libs/update
new file mode 100644
index 00000000000..6a73667d3c1
--- /dev/null
+++ b/srcpkgs/ROCm-Device-Libs/update
@@ -0,0 +1 @@
+pattern='rocm-ocl-\K[\d.]+'

From bfdd38fd81a2c6a06c9a65c129cf11d937616f2e Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Mon, 13 Apr 2020 18:30:00 -0400
Subject: [PATCH 5/9] New package: ROCm-CompilerSupport-3.3.0

---
 common/shlibs                         |  1 +
 srcpkgs/ROCm-CompilerSupport-devel    |  1 +
 srcpkgs/ROCm-CompilerSupport/template | 32 +++++++++++++++++++++++++++
 srcpkgs/ROCm-CompilerSupport/update   |  1 +
 4 files changed, 35 insertions(+)
 create mode 120000 srcpkgs/ROCm-CompilerSupport-devel
 create mode 100644 srcpkgs/ROCm-CompilerSupport/template
 create mode 100644 srcpkgs/ROCm-CompilerSupport/update

diff --git a/common/shlibs b/common/shlibs
index 944ab37c190..393e464f683 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3983,3 +3983,4 @@ libaml.so.0 aml-0.1.0_1
 libneatvnc.so.0 neatvnc-0.2.0_1
 libhsakmt.so.1 ROCT-Thunk-Interface-3.3.0_1
 libhsa-runtime64.so.1 ROCR-Runtime-3.3.0_1
+libamd_comgr.so.1 ROCm-CompilerSupport-3.3.0_1
diff --git a/srcpkgs/ROCm-CompilerSupport-devel b/srcpkgs/ROCm-CompilerSupport-devel
new file mode 120000
index 00000000000..877aeafeeae
--- /dev/null
+++ b/srcpkgs/ROCm-CompilerSupport-devel
@@ -0,0 +1 @@
+ROCm-CompilerSupport
\ No newline at end of file
diff --git a/srcpkgs/ROCm-CompilerSupport/template b/srcpkgs/ROCm-CompilerSupport/template
new file mode 100644
index 00000000000..df56f7a3837
--- /dev/null
+++ b/srcpkgs/ROCm-CompilerSupport/template
@@ -0,0 +1,32 @@
+# Template file for 'ROCm-CompilerSupport'
+pkgname=ROCm-CompilerSupport
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="${pkgname}-rocm-${version}"
+build_wrksrc="lib/comgr"
+build_style=cmake
+configure_args="-DClang_DIR:PATH=/usr/lib/rocm-llvm/lib/cmake/clang"
+hostmakedepends="cmake pkg-config ROCm-llvm"
+makedepends="ROCm-Device-Libs"
+short_desc="Radeon Open Compute compiler support"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="BSD-3-Clause"
+homepage="https://github.com/RadeonOpenCompute/ROCm-CompilerSupport"
+distfiles="${homepage}/archive/rocm-${version}.tar.gz"
+checksum=01e2524e0f28ecd6f46c9720f279207de935d826b0172158792aa3ec86af9ca7
+nocross=yes
+
+post_install() {
+	vlicense LICENSE.txt
+}
+
+ROCm-CompilerSupport-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove "usr/lib/*.so"
+		vmove usr/lib/cmake
+	}
+}
diff --git a/srcpkgs/ROCm-CompilerSupport/update b/srcpkgs/ROCm-CompilerSupport/update
new file mode 100644
index 00000000000..86197bc3eea
--- /dev/null
+++ b/srcpkgs/ROCm-CompilerSupport/update
@@ -0,0 +1 @@
+pattern='rocm-\K[\d.]+'

From 0d1c2fc7c9a0e8962f7d7dae390cb6c0f7a44fc5 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Fri, 17 Apr 2020 12:11:25 -0400
Subject: [PATCH 6/9] New package: rocminfo-3.3.0

---
 srcpkgs/rocminfo/template | 22 ++++++++++++++++++++++
 srcpkgs/rocminfo/update   |  1 +
 2 files changed, 23 insertions(+)
 create mode 100644 srcpkgs/rocminfo/template
 create mode 100644 srcpkgs/rocminfo/update

diff --git a/srcpkgs/rocminfo/template b/srcpkgs/rocminfo/template
new file mode 100644
index 00000000000..7a075c7f7ac
--- /dev/null
+++ b/srcpkgs/rocminfo/template
@@ -0,0 +1,22 @@
+# Template file for 'rocminfo'
+pkgname=rocminfo
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="${pkgname}-rocm-${version}"
+build_style=cmake
+configure_args="-DROCM_DIR=/usr"
+hostmakedepends="cmake pkg-config"
+makedepends="ROCR-Runtime-devel"
+short_desc="Radeon Open Compute system information reporter"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute/rocminfo"
+distfiles="${homepage}/archive/rocm-${version}.tar.gz"
+checksum=e666f662c9e465aaabbbd0b109d87e017243cdf1a0898fabf5a90947bb3dbcd7
+nocross=yes
+python_version=3
+
+post_install() {
+	vlicense License.txt
+}
diff --git a/srcpkgs/rocminfo/update b/srcpkgs/rocminfo/update
new file mode 100644
index 00000000000..86197bc3eea
--- /dev/null
+++ b/srcpkgs/rocminfo/update
@@ -0,0 +1 @@
+pattern='rocm-\K[\d.]+'

From dd624a7ed799d5688b2caaddcef83bd3505d6097 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Sun, 19 Apr 2020 15:01:40 -0400
Subject: [PATCH 7/9] New package: rocm_bandwidth_test-3.3.0

---
 srcpkgs/rocm_bandwidth_test/template | 20 ++++++++++++++++++++
 srcpkgs/rocm_bandwidth_test/update   |  1 +
 2 files changed, 21 insertions(+)
 create mode 100644 srcpkgs/rocm_bandwidth_test/template
 create mode 100644 srcpkgs/rocm_bandwidth_test/update

diff --git a/srcpkgs/rocm_bandwidth_test/template b/srcpkgs/rocm_bandwidth_test/template
new file mode 100644
index 00000000000..6de7f2d6614
--- /dev/null
+++ b/srcpkgs/rocm_bandwidth_test/template
@@ -0,0 +1,20 @@
+# Template file for 'rocm_bandwidth_test'
+pkgname=rocm_bandwidth_test
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="${pkgname}-rocm-${version}"
+build_style=cmake
+hostmakedepends="cmake"
+makedepends="ROCR-Runtime-devel ROCT-Thunk-Interface-devel"
+short_desc="Radeon Open Compute bandwidth test"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute/rocm_bandwidth_test"
+distfiles="${homepage}/archive/rocm-${version}.tar.gz"
+checksum=f5f914073018619dc91662d5bf630903dfa4db9136d603591917fdfb3c9164ce
+nocross=yes
+
+post_install() {
+	vlicense LICENSE.txt
+}
diff --git a/srcpkgs/rocm_bandwidth_test/update b/srcpkgs/rocm_bandwidth_test/update
new file mode 100644
index 00000000000..86197bc3eea
--- /dev/null
+++ b/srcpkgs/rocm_bandwidth_test/update
@@ -0,0 +1 @@
+pattern='rocm-\K[\d.]+'

From c18eb5f651c6749d6fff87791f9f8511011c2ceb Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Tue, 14 Apr 2020 10:25:54 -0400
Subject: [PATCH 8/9] New package: ROCm-OpenCL-Runtime-3.3.0

---
 common/shlibs                                 |   2 +
 srcpkgs/ROCm-OpenCL-Runtime-clinfo            |   1 +
 srcpkgs/ROCm-OpenCL-Runtime-devel             |   1 +
 .../files/libelf-musl.patch                   |  21 +++
 .../files/runtime-musl.patch                  |  11 ++
 .../ROCm-OpenCL-Runtime/patches/cmake.patch   | 126 ++++++++++++++++++
 srcpkgs/ROCm-OpenCL-Runtime/template          |  84 ++++++++++++
 srcpkgs/ROCm-OpenCL-Runtime/update            |   1 +
 8 files changed, 247 insertions(+)
 create mode 120000 srcpkgs/ROCm-OpenCL-Runtime-clinfo
 create mode 120000 srcpkgs/ROCm-OpenCL-Runtime-devel
 create mode 100644 srcpkgs/ROCm-OpenCL-Runtime/files/libelf-musl.patch
 create mode 100644 srcpkgs/ROCm-OpenCL-Runtime/files/runtime-musl.patch
 create mode 100644 srcpkgs/ROCm-OpenCL-Runtime/patches/cmake.patch
 create mode 100644 srcpkgs/ROCm-OpenCL-Runtime/template
 create mode 100644 srcpkgs/ROCm-OpenCL-Runtime/update

diff --git a/common/shlibs b/common/shlibs
index 393e464f683..28250aa3a3f 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3984,3 +3984,5 @@ libneatvnc.so.0 neatvnc-0.2.0_1
 libhsakmt.so.1 ROCT-Thunk-Interface-3.3.0_1
 libhsa-runtime64.so.1 ROCR-Runtime-3.3.0_1
 libamd_comgr.so.1 ROCm-CompilerSupport-3.3.0_1
+libOpenCL-ROCm.so.1 ROCm-OpenCL-Runtime-3.3.0_1
+libamdocl64.so ROCm-OpenCL-Runtime-3.3.0_1
diff --git a/srcpkgs/ROCm-OpenCL-Runtime-clinfo b/srcpkgs/ROCm-OpenCL-Runtime-clinfo
new file mode 120000
index 00000000000..21f2041b8fb
--- /dev/null
+++ b/srcpkgs/ROCm-OpenCL-Runtime-clinfo
@@ -0,0 +1 @@
+ROCm-OpenCL-Runtime
\ No newline at end of file
diff --git a/srcpkgs/ROCm-OpenCL-Runtime-devel b/srcpkgs/ROCm-OpenCL-Runtime-devel
new file mode 120000
index 00000000000..21f2041b8fb
--- /dev/null
+++ b/srcpkgs/ROCm-OpenCL-Runtime-devel
@@ -0,0 +1 @@
+ROCm-OpenCL-Runtime
\ No newline at end of file
diff --git a/srcpkgs/ROCm-OpenCL-Runtime/files/libelf-musl.patch b/srcpkgs/ROCm-OpenCL-Runtime/files/libelf-musl.patch
new file mode 100644
index 00000000000..29469a9a351
--- /dev/null
+++ b/srcpkgs/ROCm-OpenCL-Runtime/files/libelf-musl.patch
@@ -0,0 +1,21 @@
+--- compiler/lib/loaders/elf/utils/libelf/_libelf.h	2020-04-28 15:50:53.243438174 -0400
++++ compiler/lib/loaders/elf/utils/libelf/_libelf.h	2020-04-28 15:51:54.293435415 -0400
+@@ -35,6 +35,7 @@
+ #include "_libelf_config.h"
+ 
+ #include "_elftc.h"
++#include <sys/cdefs.h>
+ 
+ /*
+  * Library-private data structures.
+--- compiler/lib/loaders/elf/utils/libelf/libelf.h	2020-04-28 15:50:53.244438174 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf.h	2020-04-28 15:52:12.375434593 -0400
+@@ -36,6 +36,8 @@
+ #define EM_HSAIL 0xAF5A
+ #endif
+ 
++#include <sys/cdefs.h>
++
+ /* Library private data structures */
+ typedef struct _Elf Elf;
+ typedef struct _Elf_Scn Elf_Scn;
diff --git a/srcpkgs/ROCm-OpenCL-Runtime/files/runtime-musl.patch b/srcpkgs/ROCm-OpenCL-Runtime/files/runtime-musl.patch
new file mode 100644
index 00000000000..ea18e90e09c
--- /dev/null
+++ b/srcpkgs/ROCm-OpenCL-Runtime/files/runtime-musl.patch
@@ -0,0 +1,11 @@
+--- runtime/os/os_posix.cpp.orig	2020-04-19 09:13:51.701982901 -0400
++++ runtime/os/os_posix.cpp	2020-04-19 09:14:04.156947422 -0400
+@@ -44,6 +44,8 @@
+ #include <algorithm>
+ #include <mutex>
+ 
++#include <libgen.h> // for basename
++
+ 
+ namespace amd {
+ 
diff --git a/srcpkgs/ROCm-OpenCL-Runtime/patches/cmake.patch b/srcpkgs/ROCm-OpenCL-Runtime/patches/cmake.patch
new file mode 100644
index 00000000000..2c96b99d45a
--- /dev/null
+++ b/srcpkgs/ROCm-OpenCL-Runtime/patches/cmake.patch
@@ -0,0 +1,126 @@
+--- OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/CMakeLists.txt	2019-09-10 11:53:28.000000000 -0400
++++ OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/CMakeLists.txt	2020-04-16 20:16:13.481180757 -0400
+@@ -73,11 +73,11 @@
+ 
+ set (OPENCL_ICD_LOADER_HEADERS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/inc CACHE PATH "Path to OpenCL Headers")
+ 
+-add_library (OpenCL ${OPENCL_ICD_LOADER_SOURCES})
+-set_target_properties (OpenCL PROPERTIES VERSION "1.2" SOVERSION "1")
++add_library (OpenCL-ROCm ${OPENCL_ICD_LOADER_SOURCES})
++set_target_properties (OpenCL-ROCm PROPERTIES VERSION "1.2" SOVERSION "1")
+ 
+ if (WIN32)
+-    target_link_libraries (OpenCL cfgmgr32.lib)
++    target_link_libraries (OpenCL-ROCm cfgmgr32.lib)
+ 
+     option (OPENCL_ICD_LOADER_REQUIRE_WDK "Build with D3DKMT support, which requires the Windows WDK." ON)
+     if (OPENCL_ICD_LOADER_REQUIRE_WDK)
+@@ -92,10 +92,10 @@
+             get_filename_component(WDK_DIRECTORY ${LATEST_D3DKMT_HEADER} DIRECTORY)
+             get_filename_component(WDK_DIRECTORY ${WDK_DIRECTORY} DIRECTORY)
+             message(STATUS "Found the Windows WDK in: ${WDK_DIRECTORY}")
+-            target_compile_definitions(OpenCL PRIVATE OPENCL_ICD_LOADER_REQUIRE_WDK)
+-            target_include_directories(OpenCL PRIVATE ${WDK_DIRECTORY}/um)
+-            target_include_directories(OpenCL PRIVATE ${WDK_DIRECTORY}/km)
+-            target_include_directories(OpenCL PRIVATE ${WDK_DIRECTORY}/shared)
++	    target_compile_definitions(OpenCL-ROCm PRIVATE OPENCL_ICD_LOADER_REQUIRE_WDK)
++	    target_include_directories(OpenCL-ROCm PRIVATE ${WDK_DIRECTORY}/um)
++	    target_include_directories(OpenCL-ROCm PRIVATE ${WDK_DIRECTORY}/km)
++	    target_include_directories(OpenCL-ROCm PRIVATE ${WDK_DIRECTORY}/shared)
+         else()
+             message(FATAL_ERROR "The Windows WDK was not found. Consider disabling OPENCL_ICD_LOADER_REQUIRE_WDK. Aborting.")
+         endif()
+@@ -113,25 +113,25 @@
+     endif()
+ else()
+     if (APPLE)
+-        target_link_libraries (OpenCL ${CMAKE_THREAD_LIBS_INIT})
++        target_link_libraries (OpenCL-ROCm ${CMAKE_THREAD_LIBS_INIT})
+     else ()
+-        set_target_properties (OpenCL PROPERTIES LINK_FLAGS "-Wl,--version-script -Wl,${CMAKE_CURRENT_SOURCE_DIR}/loader/linux/icd_exports.map")
+-        target_link_libraries (OpenCL ${CMAKE_THREAD_LIBS_INIT})
++        set_target_properties (OpenCL-ROCm PROPERTIES LINK_FLAGS "-Wl,--version-script -Wl,${CMAKE_CURRENT_SOURCE_DIR}/loader/linux/icd_exports.map")
++	target_link_libraries (OpenCL-ROCm ${CMAKE_THREAD_LIBS_INIT})
+     endif ()
+ endif ()
+ 
+ include_directories (${OPENCL_ICD_LOADER_HEADERS_DIR})
+ add_definitions (-DCL_TARGET_OPENCL_VERSION=220)
+ 
+-target_include_directories (OpenCL PRIVATE ${CMAKE_CURRENT_BINARY_DIR} loader)
+-target_link_libraries (OpenCL ${CMAKE_DL_LIBS})
++target_include_directories (OpenCL-ROCm PRIVATE ${CMAKE_CURRENT_BINARY_DIR} loader)
++target_link_libraries (OpenCL-ROCm ${CMAKE_DL_LIBS})
+ 
+ include (CTest)
+ if (BUILD_TESTING)
+     add_subdirectory (test)
+ endif()
+ 
+-install (TARGETS OpenCL
++install (TARGETS OpenCL-ROCm
+     RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+     ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
+     LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
+--- OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/test/loader_test/CMakeLists.txt	2019-09-10 11:53:28.000000000 -0400
++++ OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/test/loader_test/CMakeLists.txt	2020-04-16 20:16:56.647026589 -0400
+@@ -12,4 +12,4 @@
+     test_clgl.c
+     test_image_objects.c )
+ 
+-target_link_libraries (icd_loader_test OpenCL IcdLog)
++target_link_libraries (icd_loader_test OpenCL-ROCm IcdLog)
+--- ROCm-OpenCL-Runtime-roc-3.3.0/CMakeLists.txt	2020-04-28 07:29:51.864446603 -0400
++++ ROCm-OpenCL-Runtime-roc-3.3.0/CMakeLists.txt	2020-04-28 07:32:45.245793180 -0400
+@@ -101,30 +101,30 @@
+ rocm_setup_version( VERSION "2.0.0" )
+ 
+ # MAIN package
+-install(PROGRAMS $<TARGET_FILE:clinfo>
+-        DESTINATION bin/x86_64
++install(PROGRAMS $<TARGET_FILE:rocm-clinfo>
++        DESTINATION bin
+         COMPONENT MAIN)
+ install(PROGRAMS $<TARGET_FILE:amdocl64>
+-        DESTINATION lib/x86_64
++        DESTINATION lib
+         COMPONENT MAIN)
+-install(PROGRAMS $<TARGET_FILE:OpenCL>
+-        DESTINATION lib/x86_64
++install(PROGRAMS $<TARGET_FILE:OpenCL-ROCm>
++        DESTINATION lib
+         COMPONENT MAIN)
+-install(PROGRAMS $<TARGET_SONAME_FILE:OpenCL>
+-        DESTINATION lib/x86_64
++install(PROGRAMS $<TARGET_SONAME_FILE:OpenCL-ROCm>
++        DESTINATION lib
+         COMPONENT MAIN)
+ 
+ # DEV package
+ install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/api/opencl/khronos/headers/opencl2.2/CL"
+-        DESTINATION include
++	DESTINATION include/rocm
+         COMPONENT DEV
+         USE_SOURCE_PERMISSIONS
+         PATTERN cl_d3d10.h EXCLUDE
+         PATTERN cl_d3d11.h EXCLUDE
+         PATTERN cl_dx9_media_sharing.h EXCLUDE
+         PATTERN cl_egl.h EXCLUDE)
+-install(PROGRAMS $<TARGET_LINKER_FILE:OpenCL>
+-        DESTINATION lib/x86_64
++install(PROGRAMS $<TARGET_LINKER_FILE:OpenCL-ROCm>
++        DESTINATION lib
+         COMPONENT DEV)
+ 
+ # Generic CPACK variables
+--- ROCm-OpenCL-Runtime-roc-3.3.0/tools/clinfo/CMakeLists.txt	2020-04-28 07:29:51.882446535 -0400
++++ ROCm-OpenCL-Runtime-roc-3.3.0/tools/clinfo/CMakeLists.txt	2020-04-28 07:30:05.627394732 -0400
+@@ -6,6 +6,6 @@
+ 
+ add_definitions(-DHAVE_CL2_HPP)
+ 
+-add_executable(clinfo clinfo.cpp)
++add_executable(rocm-clinfo clinfo.cpp)
+ 
+-target_link_libraries(clinfo OpenCL)
++target_link_libraries(rocm-clinfo OpenCL-ROCm)
diff --git a/srcpkgs/ROCm-OpenCL-Runtime/template b/srcpkgs/ROCm-OpenCL-Runtime/template
new file mode 100644
index 00000000000..f6699a1d4c0
--- /dev/null
+++ b/srcpkgs/ROCm-OpenCL-Runtime/template
@@ -0,0 +1,84 @@
+# Template file for 'ROCm-OpenCL-Runtime'
+pkgname=ROCm-OpenCL-Runtime
+version=3.3.0
+revision=1
+_ocl_icd_name="OpenCL-ICD-Loader"
+_ocl_icd_ver="6c03f8b58fafd9dd693eaac826749a5cfad515f8"
+archs="x86_64*"
+create_wrksrc=yes
+build_wrksrc="${pkgname}-roc-${version}"
+build_style=cmake
+configure_args="-DUSE_COMGR_LIBRARY=yes"
+hostmakedepends="cmake pkg-config"
+makedepends="libglvnd-devel ROCm-CompilerSupport-devel
+	ROCT-Thunk-Interface-devel ROCR-Runtime-devel"
+depends="ROCm-CompilerSupport"
+short_desc="Radeon Open Compute OpenCL runtime"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="MIT"
+homepage="https://github.com/RadeonOpenCompute/ROCm-OpenCL-Runtime"
+_rocroot="https://github.com/RadeonOpenCompute"
+distfiles="${_rocroot}/ROCm-OpenCL-Runtime/archive/roc-${version}.tar.gz
+	${_rocroot}/rocm-cmake/archive/rocm-${version}.tar.gz
+	https://github.com/KhronosGroup/${_ocl_icd_name}/archive/${_ocl_icd_ver}.tar.gz"
+checksum="ac6999f1a491ab066286c2bd6adf50f08f831286f56e267879f9f7eced22f98e
+	76ed3ee8e56cf3246011cf7723c2abda539e1136e7e7f6909bfa45d268b8644f
+	c94d5bb6dc980c4d41d73e2b81663a19aabe494e923e2d0eec72a4c95b318438"
+nocross=yes
+
+if [ "$XBPS_LIBC" = "musl" ]; then
+	makedepends+=" musl-legacy-compat"
+fi
+
+post_patch() {
+	if [ "$XBPS_LIBC" = "musl" ]; then
+		# Remove dependence on glibc
+		patch -Np0 < ${FILESDIR}/libelf-musl.patch
+		patch -Np0 < ${FILESDIR}/runtime-musl.patch
+		vsed -e '/glibc_functions.cpp/d' -i api/opencl/amdocl/CMakeLists.txt
+	fi
+}
+
+pre_configure() {
+	# ROCm requires a very specific Khronos ICD loader version in the tree
+	# Keep the ICD loader config in /etc/OpenCL/rocm-vendors to avoid conflicts
+	_ocl_icd_dir="${_ocl_icd_name}-${_ocl_icd_ver}"
+	ln -sf "${wrksrc}/${_ocl_icd_dir}" api/opencl/khronos/icd
+	vsed -i "${wrksrc}/${_ocl_icd_dir}/loader/icd_platform.h" \
+		-e 's@/etc/OpenCL/vendors/@/etc/OpenCL/rocm-vendors/@g'
+
+	# CMake modules probably not useful anywhere but for this build
+	ln -sf "${wrksrc}/rocm-cmake-rocm-${version}/share/rocm/cmake"/*.cmake cmake
+
+	# Fix the dlopen macro to point to versioned libamd_comgr shared object
+	vsed -i 'runtime/device/comgrctx.cpp' \
+		-e 's/\blibamd_comgr\(32\)\?.so\b/&.1/g'
+}
+
+post_install() {
+	vlicense License
+
+	# Create descriptor to allow the ICD loader to find the driver
+	vmkdir etc/OpenCL/rocm-vendors
+	echo "libamdocl64.so" > "${DESTDIR}/etc/OpenCL/rocm-vendors/amdocl64.icd"
+	vmkdir etc/OpenCL/vendors
+	ln -s ../../OpenCL/rocm-vendors/amdocl64.icd \
+		${DESTDIR}/etc/OpenCL/vendors/rocm-amdocl64.icd
+}
+
+ROCm-OpenCL-Runtime-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/lib/libOpenCL-ROCm.so
+		vmove usr/include
+	}
+}
+
+ROCm-OpenCL-Runtime-clinfo_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - clinfo"
+	pkg_install() {
+		vmove usr/bin/rocm-clinfo
+	}
+}
diff --git a/srcpkgs/ROCm-OpenCL-Runtime/update b/srcpkgs/ROCm-OpenCL-Runtime/update
new file mode 100644
index 00000000000..8385f4d1215
--- /dev/null
+++ b/srcpkgs/ROCm-OpenCL-Runtime/update
@@ -0,0 +1 @@
+pattern='roc-\K[\d.]+'

From 8fb59c86f69c5f43726fc0be4f813444a06fde38 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Thu, 30 Apr 2020 13:11:12 -0400
Subject: [PATCH 9/9] New package: ROCR-Runtime-hsa-ext-3.3.0

[ci skip]
---
 common/shlibs                         |  2 ++
 srcpkgs/ROCR-Runtime-hsa-ext-devel    |  1 +
 srcpkgs/ROCR-Runtime-hsa-ext/template | 43 +++++++++++++++++++++++++++
 srcpkgs/ROCR-Runtime-hsa-ext/update   |  2 ++
 4 files changed, 48 insertions(+)
 create mode 120000 srcpkgs/ROCR-Runtime-hsa-ext-devel
 create mode 100644 srcpkgs/ROCR-Runtime-hsa-ext/template
 create mode 100644 srcpkgs/ROCR-Runtime-hsa-ext/update

diff --git a/common/shlibs b/common/shlibs
index 28250aa3a3f..66392db5c99 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3986,3 +3986,5 @@ libhsa-runtime64.so.1 ROCR-Runtime-3.3.0_1
 libamd_comgr.so.1 ROCm-CompilerSupport-3.3.0_1
 libOpenCL-ROCm.so.1 ROCm-OpenCL-Runtime-3.3.0_1
 libamdocl64.so ROCm-OpenCL-Runtime-3.3.0_1
+libhsa-ext-image64.so.1 ROCR-Runtime-hsa-ext-3.3.0_1
+libhsa-runtime-tools64.so.1 ROCR-Runtime-hsa-ext-3.3.0_1
diff --git a/srcpkgs/ROCR-Runtime-hsa-ext-devel b/srcpkgs/ROCR-Runtime-hsa-ext-devel
new file mode 120000
index 00000000000..6ee1b14911b
--- /dev/null
+++ b/srcpkgs/ROCR-Runtime-hsa-ext-devel
@@ -0,0 +1 @@
+ROCR-Runtime-hsa-ext
\ No newline at end of file
diff --git a/srcpkgs/ROCR-Runtime-hsa-ext/template b/srcpkgs/ROCR-Runtime-hsa-ext/template
new file mode 100644
index 00000000000..235ae92146b
--- /dev/null
+++ b/srcpkgs/ROCR-Runtime-hsa-ext/template
@@ -0,0 +1,43 @@
+# Template file for 'ROCR-Runtime-hsa-ext'
+pkgname=ROCR-Runtime-hsa-ext
+version=3.3.0
+revision=1
+archs="x86_64"
+hostmakedepends="tar"
+short_desc="Radeon Open Compute HSA runtime extensions"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute"
+_hsa_deb="hsa-ext-rocr-dev_1.1.30300.0-rocm-rel-3.3-19-23fc088b_amd64.deb"
+distfiles="https://repo.radeon.com/rocm/apt/debian/pool/main/h/hsa-ext-rocr-dev/$_hsa_deb"
+checksum=6b44e286b395d946b865ec1f3cc546356396785ac1fde591d07af02d0aa7c25d
+repository=nonfree
+restricted=yes
+
+do_extract() {
+	ar x "${XBPS_SRCDISTDIR}/${pkgname}-${version}/${_hsa_deb}"
+	tar xvf data.tar.gz
+}
+
+do_install() {
+	_rocm_includes="opt/rocm-${version}/hsa/include"
+
+	vmkdir usr
+	vcopy opt/rocm-${version}/hsa/lib usr
+	vcopy "$_rocm_includes" usr
+
+	# Extract license from one of the header files
+	awk 'BEGIN{HEADER=0} /\/\//{HEADER=1; print $0;} /^[^/]/{if(HEADER==1) exit;}' \
+		< "${_rocm_includes}/hsa/amd_hsa_tools_interfaces.h" \
+		| sed 's@^///*\( \|$\)@@' > LICENSE
+	vlicense LICENSE
+}
+
+ROCR-Runtime-hsa-ext-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove "usr/lib/*.so"
+	}
+}
diff --git a/srcpkgs/ROCR-Runtime-hsa-ext/update b/srcpkgs/ROCR-Runtime-hsa-ext/update
new file mode 100644
index 00000000000..84252d2e3b8
--- /dev/null
+++ b/srcpkgs/ROCR-Runtime-hsa-ext/update
@@ -0,0 +1,2 @@
+site='https://repo.radeon.com/rocm/apt/debian/pool/main/h/'
+pattern='hsa-ext-rocr-dev\K[\d.]+'

^ permalink raw reply	[flat|nested] 61+ messages in thread

* Re: New packages: ROCm core and OpenCL
  2020-04-19 13:34 [PR PATCH] New packages: ROCm core and OpenCL ahesford
                   ` (50 preceding siblings ...)
  2020-08-04 17:24 ` [PR PATCH] [Updated] " ahesford
@ 2020-08-18 18:36 ` aurieh
  2020-08-18 18:38 ` aurieh
                   ` (7 subsequent siblings)
  59 siblings, 0 replies; 61+ messages in thread
From: aurieh @ 2020-08-18 18:36 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 459 bytes --]

New comment by aurieh on void-packages repository

https://github.com/void-linux/void-packages/pull/21153#issuecomment-675645727

Comment:
Wouldn't it be better to use the official package names as [provided in the docs](https://rocmdocs.amd.com/en/latest/Installation_Guide/Installation-Guide.html#build-amd-rocm) to maintain consistency with Ubuntu, SLES, CentOS, [Arch](https://github.com/rocm-arch/rocm-arch) and [Gentoo](https://github.com/justxi/rocm)?

^ permalink raw reply	[flat|nested] 61+ messages in thread

* Re: New packages: ROCm core and OpenCL
  2020-04-19 13:34 [PR PATCH] New packages: ROCm core and OpenCL ahesford
                   ` (51 preceding siblings ...)
  2020-08-18 18:36 ` aurieh
@ 2020-08-18 18:38 ` aurieh
  2020-08-18 18:39 ` aurieh
                   ` (6 subsequent siblings)
  59 siblings, 0 replies; 61+ messages in thread
From: aurieh @ 2020-08-18 18:38 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 613 bytes --]

New comment by aurieh on void-packages repository

https://github.com/void-linux/void-packages/pull/21153#issuecomment-675645727

Comment:
Wouldn't it be better to use the official package names as [provided in the docs](https://rocmdocs.amd.com/en/latest/Installation_Guide/Installation-Guide.html#build-amd-rocm) to maintain consistency with Ubuntu, SLES, CentOS, [Arch](https://github.com/rocm-arch/rocm-arch) and [Gentoo](https://github.com/justxi/rocm)? I'm currently working on packaging the rest of the ROCm stack (namely the HIP-*) libs, and would like to know which naming scheme to use for consistency.

^ permalink raw reply	[flat|nested] 61+ messages in thread

* Re: New packages: ROCm core and OpenCL
  2020-04-19 13:34 [PR PATCH] New packages: ROCm core and OpenCL ahesford
                   ` (52 preceding siblings ...)
  2020-08-18 18:38 ` aurieh
@ 2020-08-18 18:39 ` aurieh
  2020-08-18 19:46 ` ahesford
                   ` (5 subsequent siblings)
  59 siblings, 0 replies; 61+ messages in thread
From: aurieh @ 2020-08-18 18:39 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 612 bytes --]

New comment by aurieh on void-packages repository

https://github.com/void-linux/void-packages/pull/21153#issuecomment-675645727

Comment:
Wouldn't it be better to use the official package names as [provided in the docs](https://rocmdocs.amd.com/en/latest/Installation_Guide/Installation-Guide.html#build-amd-rocm) to maintain consistency with Ubuntu, SLES, CentOS, [Arch](https://github.com/rocm-arch/rocm-arch) and [Gentoo](https://github.com/justxi/rocm)? I'm currently working on packaging the rest of the ROCm stack (namely the HIP* libs), and would like to know which naming scheme to use for consistency.

^ permalink raw reply	[flat|nested] 61+ messages in thread

* Re: New packages: ROCm core and OpenCL
  2020-04-19 13:34 [PR PATCH] New packages: ROCm core and OpenCL ahesford
                   ` (53 preceding siblings ...)
  2020-08-18 18:39 ` aurieh
@ 2020-08-18 19:46 ` ahesford
  2020-08-20 18:50 ` [PR PATCH] [Updated] " ahesford
                   ` (4 subsequent siblings)
  59 siblings, 0 replies; 61+ messages in thread
From: ahesford @ 2020-08-18 19:46 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 294 bytes --]

New comment by ahesford on void-packages repository

https://github.com/void-linux/void-packages/pull/21153#issuecomment-675677598

Comment:
Void naming policy is to use the upstream repo names, not invent our own names, even when they would be consistent with packages in other distributions.

^ permalink raw reply	[flat|nested] 61+ messages in thread

* Re: [PR PATCH] [Updated] New packages: ROCm core and OpenCL
  2020-04-19 13:34 [PR PATCH] New packages: ROCm core and OpenCL ahesford
                   ` (54 preceding siblings ...)
  2020-08-18 19:46 ` ahesford
@ 2020-08-20 18:50 ` ahesford
  2020-12-21  7:32 ` fosslinux
                   ` (3 subsequent siblings)
  59 siblings, 0 replies; 61+ messages in thread
From: ahesford @ 2020-08-20 18:50 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 3893 bytes --]

There is an updated pull request by ahesford against master on the void-packages repository

https://github.com/ahesford/void-packages rocm
https://github.com/void-linux/void-packages/pull/21153

New packages: ROCm core and OpenCL
This PR includes several packages designed to bring the OpenCL portion of the AMD ROCm ecosystem to Void. It addresses Issue #19507. There are many other packages that AMD provides for GPGPU computing, but these can be added piecemeal as users demand.

The packages are currently only for `x86_64*`. While at least some of the packages will compile on other 64-bit architectures, I have no hardware to test. They are certainly not suitable for 32-bit architectures; some internal data structures rely on `uint64_t` values that are cast to pointers. At a
minimum, a thorough audit would be necessary to ensure that these casts are safe (e.g., that the values stored were only ever upcast from 32-bit pointers). More extensive work may be necessary to support 32-bit architectures, probably without significant benefit.

The packages successfully identify a Radeon RX 580 on an `x86_64` installation using both `clinfo` and `rocminfo` as provided. Furthermore, a version of `pyopencl` linked against these ROCm packages successfully runs a simple program that validates arithmetic on GPU-bound arrays.

There are caveats with this set of packages, almost all of which revolve around the incompatibilities between the Void-provided `ocl-icd` and the [Khronos OpenCL ICD loader](https://github.com/KhronosGroup/OpenCL-ID-Loader) required by (and built into) `rocm-opencl-runtime`.
1. All packages install into `/opt/rocm`. This keeps the environment closer to that officially sanctioned by AMD and helps avoid conflicts between other packages and those provided here. (For example, `clinfo` and the ICD loader itself.) Eventually, we may be able to move the files into `/usr`.
2. The Khronos OpenCL ICD loader built into `rocm-opencl-runtime` is an outdated, pre-release commit. If AMD can update its sources to use the release version of that loader (which has a backward-incompatible API change), we may be able to make ROCm compatible with `ocl-icd` or replace `ocl-icd` with the official Khronos loader.
3. In the meantime, to avoid `shlibs` conflicts, the OpenCL ICD loader is installed as `/opt/rocm/lib/libOpenCL-ROCm.so` (and an appropriately versioned shared library), which means that programs wishing to use the ROCm OpenCL must explicitly link against this library instead of the generic `libOpenCL.so`.
4. I do **not** recommend making any Void packages link against this specific library, because it will make those packages ROCm-only. For the time being, ROCm is intended for end-users to specifically link against. Linking Void packages against ROCm would requires the ICD loader used by ROCm be compatible with `ocl-icd`, or `ocl-icd` be replaced by the Khronos loader. However, because the Khronos loader changed its API for the release version, such a change is not yet appropriate.

Hopefully, if AMD updates its dependence on the Khronos ICD loader, we can resolve some of these caveats in the future and make ROCm a more natural Void component. For now, these packages are useful for those who need an AMD OpenCL solution and would rather custom-link software against the AMD ICD loader than hack the `amdgpu-pro` driver into an ICD compatible with `ocl-icd`.

Some patches were made to relocate some files in `/opt/rocm` and make everyting build on x86_64-musl`. Where appropriate, these patches will be pushed upstream to clean up the distribution and packaging.

Update: I pushed some new commits to update license information that triggerd an `xlint` failure. I've also disabled CI builds because they will time out on `rocm-llvm`.

A patch file from https://github.com/void-linux/void-packages/pull/21153.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-rocm-21153.patch --]
[-- Type: text/x-diff, Size: 35439 bytes --]

From 5cbdcb738fa646996cbf8e119465300742bca327 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Mon, 13 Apr 2020 13:08:09 -0400
Subject: [PATCH 1/9] New package: ROCT-Thunk-Interface-3.3.0

---
 common/shlibs                                 |  1 +
 srcpkgs/ROCT-Thunk-Interface-devel            |  1 +
 .../patches/cmake-dev-libdir.patch            | 10 ++++++
 .../ROCT-Thunk-Interface/patches/musl.patch   | 29 ++++++++++++++++
 srcpkgs/ROCT-Thunk-Interface/template         | 33 +++++++++++++++++++
 srcpkgs/ROCT-Thunk-Interface/update           |  1 +
 6 files changed, 75 insertions(+)
 create mode 120000 srcpkgs/ROCT-Thunk-Interface-devel
 create mode 100644 srcpkgs/ROCT-Thunk-Interface/patches/cmake-dev-libdir.patch
 create mode 100644 srcpkgs/ROCT-Thunk-Interface/patches/musl.patch
 create mode 100644 srcpkgs/ROCT-Thunk-Interface/template
 create mode 100644 srcpkgs/ROCT-Thunk-Interface/update

diff --git a/common/shlibs b/common/shlibs
index dcb1d8e54b6..4f93db41216 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3981,3 +3981,4 @@ libcglm.so.0 cglm-0.7.6_1
 libfcft.so.3 fcft-2.2.2_1
 libaml.so.0 aml-0.1.0_1
 libneatvnc.so.0 neatvnc-0.2.0_1
+libhsakmt.so.1 ROCT-Thunk-Interface-3.3.0_1
diff --git a/srcpkgs/ROCT-Thunk-Interface-devel b/srcpkgs/ROCT-Thunk-Interface-devel
new file mode 120000
index 00000000000..7e43c209e3d
--- /dev/null
+++ b/srcpkgs/ROCT-Thunk-Interface-devel
@@ -0,0 +1 @@
+ROCT-Thunk-Interface
\ No newline at end of file
diff --git a/srcpkgs/ROCT-Thunk-Interface/patches/cmake-dev-libdir.patch b/srcpkgs/ROCT-Thunk-Interface/patches/cmake-dev-libdir.patch
new file mode 100644
index 00000000000..98c7f1e459c
--- /dev/null
+++ b/srcpkgs/ROCT-Thunk-Interface/patches/cmake-dev-libdir.patch
@@ -0,0 +1,10 @@
+--- CMakeLists.txt.old	2020-04-18 19:45:17.306081135 -0400
++++ CMakeLists.txt	2020-04-18 19:46:51.300753636 -0400
+@@ -146,6 +146,7 @@
+     COMMAND ${CMAKE_COMMAND}
+         -DSOURCE_DIR="${SOURCE_DIR}"
+         -DCMAKE_INSTALL_PREFIX="${CMAKE_INSTALL_PREFIX}"
++        -DCMAKE_INSTALL_LIBDIR="${CMAKE_INSTALL_LIBDIR}"
+         -DCPACK_RPM_PACKAGE_REQUIRES="hsakmt-roct"
+         -DCPACK_PACKAGING_INSTALL_PREFIX="${CPACK_PACKAGING_INSTALL_PREFIX}"
+         -DVERSION="${BUILD_VERSION_STRING}"
diff --git a/srcpkgs/ROCT-Thunk-Interface/patches/musl.patch b/srcpkgs/ROCT-Thunk-Interface/patches/musl.patch
new file mode 100644
index 00000000000..aeea9832411
--- /dev/null
+++ b/srcpkgs/ROCT-Thunk-Interface/patches/musl.patch
@@ -0,0 +1,29 @@
+diff -r -u old/src/libhsakmt.h new/src/libhsakmt.h
+--- src/libhsakmt.h	2020-03-04 15:00:47.000000000 -0500
++++ src/libhsakmt.h	2020-04-13 12:58:30.444865992 -0400
+@@ -54,6 +54,10 @@
+ #define CHECK_KFD_OPEN() \
+ 	do { if (kfd_open_count == 0 || hsakmt_forked) return HSAKMT_STATUS_KERNEL_IO_CHANNEL_NOT_OPENED; } while (0)
+ 
++/*On some platforms, a PAGE_SIZE macro eclipses the extern variable*/
++#ifdef PAGE_SIZE
++#undef PAGE_SIZE
++#endif
+ extern int PAGE_SIZE;
+ extern int PAGE_SHIFT;
+ 
+diff -r -u old/src/topology.c new/src/topology.c
+--- src/topology.c	2020-03-04 15:00:47.000000000 -0500
++++ src/topology.c	2020-04-13 13:01:31.209870701 -0400
+@@ -38,6 +38,11 @@
+ #include "libhsakmt.h"
+ #include "fmm.h"
+ 
++/*Needed on MUSL*/
++#ifndef MAXNAMLEN
++#define MAXNAMLEN PATH_MAX
++#endif
++
+ /* Number of memory banks added by thunk on top of topology
+  * This only includes static heaps like LDS, scratch and SVM,
+  * not for MMIO_REMAP heap. MMIO_REMAP memory bank is reported
diff --git a/srcpkgs/ROCT-Thunk-Interface/template b/srcpkgs/ROCT-Thunk-Interface/template
new file mode 100644
index 00000000000..8c680b2af29
--- /dev/null
+++ b/srcpkgs/ROCT-Thunk-Interface/template
@@ -0,0 +1,33 @@
+# Template file for 'ROCT-Thunk-Interface'
+pkgname=ROCT-Thunk-Interface
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="${pkgname}-roc-${version}"
+build_style=cmake
+make_build_target="all build-dev"
+make_install_target="install install-dev"
+hostmakedepends="cmake pkg-config"
+makedepends="pciutils-devel libnuma-devel"
+short_desc="Radeon Open Compute thunk interface"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="MIT"
+homepage="https://github.com/RadeonOpenCompute/ROCT-Thunk-Interface"
+distfiles="${homepage}/archive/roc-${version}.tar.gz"
+checksum=2cabe9d2cfa72031c05d11290837c476182e72d8dec2049298f691143fdd212b
+nocross=yes
+
+post_install() {
+	vlicense LICENSE.md
+}
+
+ROCT-Thunk-Interface-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove "usr/lib/*.so"
+		vmove usr/share/pkgconfig
+		vmove usr/lib/cmake
+	}
+}
diff --git a/srcpkgs/ROCT-Thunk-Interface/update b/srcpkgs/ROCT-Thunk-Interface/update
new file mode 100644
index 00000000000..8385f4d1215
--- /dev/null
+++ b/srcpkgs/ROCT-Thunk-Interface/update
@@ -0,0 +1 @@
+pattern='roc-\K[\d.]+'

From 8738399f72c96ba594d928abc2c165da2cc0772b Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Mon, 13 Apr 2020 15:27:27 -0400
Subject: [PATCH 2/9] New package: ROCR-Runtime-3.3.0

---
 common/shlibs                            |  1 +
 srcpkgs/ROCR-Runtime-devel               |  1 +
 srcpkgs/ROCR-Runtime/patches/cmake.patch | 27 +++++++++++++++++++++
 srcpkgs/ROCR-Runtime/template            | 30 ++++++++++++++++++++++++
 srcpkgs/ROCR-Runtime/update              |  1 +
 5 files changed, 60 insertions(+)
 create mode 120000 srcpkgs/ROCR-Runtime-devel
 create mode 100644 srcpkgs/ROCR-Runtime/patches/cmake.patch
 create mode 100644 srcpkgs/ROCR-Runtime/template
 create mode 100644 srcpkgs/ROCR-Runtime/update

diff --git a/common/shlibs b/common/shlibs
index 4f93db41216..944ab37c190 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3982,3 +3982,4 @@ libfcft.so.3 fcft-2.2.2_1
 libaml.so.0 aml-0.1.0_1
 libneatvnc.so.0 neatvnc-0.2.0_1
 libhsakmt.so.1 ROCT-Thunk-Interface-3.3.0_1
+libhsa-runtime64.so.1 ROCR-Runtime-3.3.0_1
diff --git a/srcpkgs/ROCR-Runtime-devel b/srcpkgs/ROCR-Runtime-devel
new file mode 120000
index 00000000000..a733fb9fbab
--- /dev/null
+++ b/srcpkgs/ROCR-Runtime-devel
@@ -0,0 +1 @@
+ROCR-Runtime
\ No newline at end of file
diff --git a/srcpkgs/ROCR-Runtime/patches/cmake.patch b/srcpkgs/ROCR-Runtime/patches/cmake.patch
new file mode 100644
index 00000000000..93b74cd2297
--- /dev/null
+++ b/srcpkgs/ROCR-Runtime/patches/cmake.patch
@@ -0,0 +1,27 @@
+--- src/CMakeLists.txt.old	2020-04-18 20:01:48.549636995 -0400
++++ src/CMakeLists.txt	2020-04-18 20:04:00.177179781 -0400
+@@ -108,8 +108,8 @@
+ ## ROCr build internal versioning
+ add_definitions ( -DROCR_BUILD_ID=${PACKAGE_VERSION_STRING} )
+ 
+-## Set RUNPATH - ../../lib covers use of the legacy symlink in /hsa/lib/
+-set(CMAKE_INSTALL_RPATH "$ORIGIN;$ORIGIN/../../lib;$ORIGIN/../../lib64;$ORIGIN/../lib64")
++## Set RUNPATH
++set(CMAKE_INSTALL_RPATH "$ORIGIN;$ORIGIN/../lib")
+ 
+ ## ------------------------- Linux Compiler and Linker options -------------------------
+ set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -fexceptions -fno-rtti -fvisibility=hidden -Wno-error=sign-compare -Wno-sign-compare -Wno-write-strings -Wno-conversion-null -fno-math-errno -fno-threadsafe-statics -fmerge-all-constants -fms-extensions -Wno-error=comment -Wno-comment -Wno-error=pointer-arith -Wno-pointer-arith -Wno-error=unused-variable -Wno-error=unused-function" )
+@@ -185,11 +185,8 @@
+ add_custom_target ( hsa_lib_link2 ALL WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMAND ${CMAKE_COMMAND} -E create_symlink ../hsa/lib/${CORE_RUNTIME_LIBRARY}.so.${SO_MAJOR} ${CORE_RUNTIME_LIBRARY}-link.so.${SO_MAJOR} )
+ 
+ ## Set install information
+-install ( TARGETS ${CORE_RUNTIME_TARGET} LIBRARY DESTINATION hsa/lib )
+-install ( DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/inc/ DESTINATION hsa/include/hsa )
+-install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/hsa_include_link DESTINATION include PERMISSIONS OWNER_WRITE OWNER_READ RENAME hsa )
+-install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/${CORE_RUNTIME_LIBRARY}-link.so DESTINATION lib PERMISSIONS OWNER_WRITE OWNER_READ RENAME ${CORE_RUNTIME_LIBRARY}.so )
+-install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/${CORE_RUNTIME_LIBRARY}-link.so.${SO_MAJOR} DESTINATION lib PERMISSIONS OWNER_WRITE OWNER_READ RENAME ${CORE_RUNTIME_LIBRARY}.so.${SO_MAJOR} )
++install ( TARGETS ${CORE_RUNTIME_TARGET} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} )
++install ( DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/inc/ DESTINATION include/hsa )
+ 
+ ## Packaging directives
+ set ( CPACK_GENERATOR "DEB;RPM" CACHE STRING "Package types to build")
diff --git a/srcpkgs/ROCR-Runtime/template b/srcpkgs/ROCR-Runtime/template
new file mode 100644
index 00000000000..95b7e701afb
--- /dev/null
+++ b/srcpkgs/ROCR-Runtime/template
@@ -0,0 +1,30 @@
+# Template file for 'ROCR-Runtime'
+pkgname=ROCR-Runtime
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="${pkgname}-rocm-${version}"
+build_wrksrc="src"
+build_style=cmake
+hostmakedepends="cmake pkg-config"
+makedepends="ROCT-Thunk-Interface-devel elfutils-devel"
+short_desc="Radeon Open Compute HSA runtime"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute/ROCR-Runtime"
+distfiles="${homepage}/archive/rocm-${version}.tar.gz"
+checksum=fa2d2d1f8a61d8a6952d377cf288d78c61776c3c2a666f163cafc3aa19ab0b61
+nocross=yes
+
+post_install() {
+	vlicense ../LICENSE.txt
+}
+
+ROCR-Runtime-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove "usr/lib/*.so"
+	}
+}
diff --git a/srcpkgs/ROCR-Runtime/update b/srcpkgs/ROCR-Runtime/update
new file mode 100644
index 00000000000..86197bc3eea
--- /dev/null
+++ b/srcpkgs/ROCR-Runtime/update
@@ -0,0 +1 @@
+pattern='rocm-\K[\d.]+'

From 0ee0f3f609c9c3743099173482d2c4a26a045b1f Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Mon, 13 Apr 2020 18:07:34 -0400
Subject: [PATCH 3/9] New package: ROCm-llvm-3.3.0

---
 srcpkgs/ROCm-llvm/template | 26 ++++++++++++++++++++++++++
 srcpkgs/ROCm-llvm/update   |  1 +
 2 files changed, 27 insertions(+)
 create mode 100644 srcpkgs/ROCm-llvm/template
 create mode 100644 srcpkgs/ROCm-llvm/update

diff --git a/srcpkgs/ROCm-llvm/template b/srcpkgs/ROCm-llvm/template
new file mode 100644
index 00000000000..4c3095b21f4
--- /dev/null
+++ b/srcpkgs/ROCm-llvm/template
@@ -0,0 +1,26 @@
+# Template file for 'ROCm-llvm'
+pkgname=ROCm-llvm
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="llvm-project-rocm-ocl-${version}"
+build_wrksrc=llvm
+build_style=cmake
+configure_args="-DCMAKE_INSTALL_PREFIX:PATH=/usr/lib/rocm-llvm
+	-DLLVM_ENABLE_PROJECTS='llvm;clang;lld' -DLLVM_TARGETS_TO_BUILD='AMDGPU'
+	-DLLVM_BUILD_DOCS=NO -DLLVM_ENABLE_OCAMLDOC=OFF
+	-DLLVM_ENABLE_SPHINX=NO -DLLVM_ENABLE_DOXYGEN=OFF
+	-DLLVM_INSTALL_UTILS=ON -DLLVM_VERSION_SUFFIX=roc -DOCAMLFIND=NO"
+hostmakedepends="cmake pkg-config python3"
+short_desc="Radeon Open Compute LLVM toolchain"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="Apache-2.0, NCSA, custom:LLVM-Exceptions"
+homepage="https://github.com/RadeonOpenCompute/llvm-project"
+distfiles="${homepage}/archive/rocm-ocl-${version}.tar.gz"
+checksum=a2bef7042e8e2f2cd8548cb246b88322e1c77188839983dcac8312d56f544dc8
+python_version=3
+nocross=yes
+
+post_install() {
+	vlicense LICENSE.TXT
+}
diff --git a/srcpkgs/ROCm-llvm/update b/srcpkgs/ROCm-llvm/update
new file mode 100644
index 00000000000..6a73667d3c1
--- /dev/null
+++ b/srcpkgs/ROCm-llvm/update
@@ -0,0 +1 @@
+pattern='rocm-ocl-\K[\d.]+'

From 7d6f1904eed5b3c2a8eff961859916d886c4eefb Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Tue, 14 Apr 2020 10:25:31 -0400
Subject: [PATCH 4/9] New package: ROCm-Device-Libs-3.3.0

---
 srcpkgs/ROCm-Device-Libs/template | 37 +++++++++++++++++++++++++++++++
 srcpkgs/ROCm-Device-Libs/update   |  1 +
 2 files changed, 38 insertions(+)
 create mode 100644 srcpkgs/ROCm-Device-Libs/template
 create mode 100644 srcpkgs/ROCm-Device-Libs/update

diff --git a/srcpkgs/ROCm-Device-Libs/template b/srcpkgs/ROCm-Device-Libs/template
new file mode 100644
index 00000000000..8086cd86450
--- /dev/null
+++ b/srcpkgs/ROCm-Device-Libs/template
@@ -0,0 +1,37 @@
+# Template file for 'ROCm-Device-Libs'
+pkgname=ROCm-Device-Libs
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="${pkgname}-rocm-ocl-${version}"
+build_style=cmake
+configure_args="-DLLVM_DIR:PATH=/usr/lib/rocm-llvm
+	-DCMAKE_INSTALL_LIBDIR:PATH=lib/rocm-device-libs"
+hostmakedepends="cmake ROCm-llvm"
+short_desc="Radeon Open Compute device libraries"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute/ROCm-Device-Libs"
+distfiles="${homepage}/archive/rocm-ocl-${version}.tar.gz"
+checksum=706b08230790e08ca6a7a2fb7687d6131fd39a562148340e00fa37a6c06769c5
+nocross=yes
+
+pre_configure() {
+	# Put bytecodes in a lib/ subdirectory
+	vsed -i Packages.cmake -e 's@/lib/@/${CMAKE_INSTALL_LIBDIR}/@'
+	vsed -i OCL.cmake -e 's@DESTINATION lib$@DESTINATION ${CMAKE_INSTALL_LIBDIR}@'
+
+	# Build the prepare-builtins executable with native compiler
+	mkdir -p utils/build
+	cd utils/build
+	_prepare_builtins="$PWD/prepare-builtins/prepare-builtins"
+	cmake ${configure_args} ..
+	make ${makejobs}
+
+	# Add path to prepare-builtins for cmake
+	configure_args+=" -DPREPARE_BUILTINS='${_prepare_builtins}'"
+}
+
+post_install() {
+	vlicense LICENSE
+}
diff --git a/srcpkgs/ROCm-Device-Libs/update b/srcpkgs/ROCm-Device-Libs/update
new file mode 100644
index 00000000000..6a73667d3c1
--- /dev/null
+++ b/srcpkgs/ROCm-Device-Libs/update
@@ -0,0 +1 @@
+pattern='rocm-ocl-\K[\d.]+'

From bfdd38fd81a2c6a06c9a65c129cf11d937616f2e Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Mon, 13 Apr 2020 18:30:00 -0400
Subject: [PATCH 5/9] New package: ROCm-CompilerSupport-3.3.0

---
 common/shlibs                         |  1 +
 srcpkgs/ROCm-CompilerSupport-devel    |  1 +
 srcpkgs/ROCm-CompilerSupport/template | 32 +++++++++++++++++++++++++++
 srcpkgs/ROCm-CompilerSupport/update   |  1 +
 4 files changed, 35 insertions(+)
 create mode 120000 srcpkgs/ROCm-CompilerSupport-devel
 create mode 100644 srcpkgs/ROCm-CompilerSupport/template
 create mode 100644 srcpkgs/ROCm-CompilerSupport/update

diff --git a/common/shlibs b/common/shlibs
index 944ab37c190..393e464f683 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3983,3 +3983,4 @@ libaml.so.0 aml-0.1.0_1
 libneatvnc.so.0 neatvnc-0.2.0_1
 libhsakmt.so.1 ROCT-Thunk-Interface-3.3.0_1
 libhsa-runtime64.so.1 ROCR-Runtime-3.3.0_1
+libamd_comgr.so.1 ROCm-CompilerSupport-3.3.0_1
diff --git a/srcpkgs/ROCm-CompilerSupport-devel b/srcpkgs/ROCm-CompilerSupport-devel
new file mode 120000
index 00000000000..877aeafeeae
--- /dev/null
+++ b/srcpkgs/ROCm-CompilerSupport-devel
@@ -0,0 +1 @@
+ROCm-CompilerSupport
\ No newline at end of file
diff --git a/srcpkgs/ROCm-CompilerSupport/template b/srcpkgs/ROCm-CompilerSupport/template
new file mode 100644
index 00000000000..df56f7a3837
--- /dev/null
+++ b/srcpkgs/ROCm-CompilerSupport/template
@@ -0,0 +1,32 @@
+# Template file for 'ROCm-CompilerSupport'
+pkgname=ROCm-CompilerSupport
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="${pkgname}-rocm-${version}"
+build_wrksrc="lib/comgr"
+build_style=cmake
+configure_args="-DClang_DIR:PATH=/usr/lib/rocm-llvm/lib/cmake/clang"
+hostmakedepends="cmake pkg-config ROCm-llvm"
+makedepends="ROCm-Device-Libs"
+short_desc="Radeon Open Compute compiler support"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="BSD-3-Clause"
+homepage="https://github.com/RadeonOpenCompute/ROCm-CompilerSupport"
+distfiles="${homepage}/archive/rocm-${version}.tar.gz"
+checksum=01e2524e0f28ecd6f46c9720f279207de935d826b0172158792aa3ec86af9ca7
+nocross=yes
+
+post_install() {
+	vlicense LICENSE.txt
+}
+
+ROCm-CompilerSupport-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove "usr/lib/*.so"
+		vmove usr/lib/cmake
+	}
+}
diff --git a/srcpkgs/ROCm-CompilerSupport/update b/srcpkgs/ROCm-CompilerSupport/update
new file mode 100644
index 00000000000..86197bc3eea
--- /dev/null
+++ b/srcpkgs/ROCm-CompilerSupport/update
@@ -0,0 +1 @@
+pattern='rocm-\K[\d.]+'

From 0d1c2fc7c9a0e8962f7d7dae390cb6c0f7a44fc5 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Fri, 17 Apr 2020 12:11:25 -0400
Subject: [PATCH 6/9] New package: rocminfo-3.3.0

---
 srcpkgs/rocminfo/template | 22 ++++++++++++++++++++++
 srcpkgs/rocminfo/update   |  1 +
 2 files changed, 23 insertions(+)
 create mode 100644 srcpkgs/rocminfo/template
 create mode 100644 srcpkgs/rocminfo/update

diff --git a/srcpkgs/rocminfo/template b/srcpkgs/rocminfo/template
new file mode 100644
index 00000000000..7a075c7f7ac
--- /dev/null
+++ b/srcpkgs/rocminfo/template
@@ -0,0 +1,22 @@
+# Template file for 'rocminfo'
+pkgname=rocminfo
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="${pkgname}-rocm-${version}"
+build_style=cmake
+configure_args="-DROCM_DIR=/usr"
+hostmakedepends="cmake pkg-config"
+makedepends="ROCR-Runtime-devel"
+short_desc="Radeon Open Compute system information reporter"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute/rocminfo"
+distfiles="${homepage}/archive/rocm-${version}.tar.gz"
+checksum=e666f662c9e465aaabbbd0b109d87e017243cdf1a0898fabf5a90947bb3dbcd7
+nocross=yes
+python_version=3
+
+post_install() {
+	vlicense License.txt
+}
diff --git a/srcpkgs/rocminfo/update b/srcpkgs/rocminfo/update
new file mode 100644
index 00000000000..86197bc3eea
--- /dev/null
+++ b/srcpkgs/rocminfo/update
@@ -0,0 +1 @@
+pattern='rocm-\K[\d.]+'

From dd624a7ed799d5688b2caaddcef83bd3505d6097 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Sun, 19 Apr 2020 15:01:40 -0400
Subject: [PATCH 7/9] New package: rocm_bandwidth_test-3.3.0

---
 srcpkgs/rocm_bandwidth_test/template | 20 ++++++++++++++++++++
 srcpkgs/rocm_bandwidth_test/update   |  1 +
 2 files changed, 21 insertions(+)
 create mode 100644 srcpkgs/rocm_bandwidth_test/template
 create mode 100644 srcpkgs/rocm_bandwidth_test/update

diff --git a/srcpkgs/rocm_bandwidth_test/template b/srcpkgs/rocm_bandwidth_test/template
new file mode 100644
index 00000000000..6de7f2d6614
--- /dev/null
+++ b/srcpkgs/rocm_bandwidth_test/template
@@ -0,0 +1,20 @@
+# Template file for 'rocm_bandwidth_test'
+pkgname=rocm_bandwidth_test
+version=3.3.0
+revision=1
+archs="x86_64*"
+wrksrc="${pkgname}-rocm-${version}"
+build_style=cmake
+hostmakedepends="cmake"
+makedepends="ROCR-Runtime-devel ROCT-Thunk-Interface-devel"
+short_desc="Radeon Open Compute bandwidth test"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute/rocm_bandwidth_test"
+distfiles="${homepage}/archive/rocm-${version}.tar.gz"
+checksum=f5f914073018619dc91662d5bf630903dfa4db9136d603591917fdfb3c9164ce
+nocross=yes
+
+post_install() {
+	vlicense LICENSE.txt
+}
diff --git a/srcpkgs/rocm_bandwidth_test/update b/srcpkgs/rocm_bandwidth_test/update
new file mode 100644
index 00000000000..86197bc3eea
--- /dev/null
+++ b/srcpkgs/rocm_bandwidth_test/update
@@ -0,0 +1 @@
+pattern='rocm-\K[\d.]+'

From c18eb5f651c6749d6fff87791f9f8511011c2ceb Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Tue, 14 Apr 2020 10:25:54 -0400
Subject: [PATCH 8/9] New package: ROCm-OpenCL-Runtime-3.3.0

---
 common/shlibs                                 |   2 +
 srcpkgs/ROCm-OpenCL-Runtime-clinfo            |   1 +
 srcpkgs/ROCm-OpenCL-Runtime-devel             |   1 +
 .../files/libelf-musl.patch                   |  21 +++
 .../files/runtime-musl.patch                  |  11 ++
 .../ROCm-OpenCL-Runtime/patches/cmake.patch   | 126 ++++++++++++++++++
 srcpkgs/ROCm-OpenCL-Runtime/template          |  84 ++++++++++++
 srcpkgs/ROCm-OpenCL-Runtime/update            |   1 +
 8 files changed, 247 insertions(+)
 create mode 120000 srcpkgs/ROCm-OpenCL-Runtime-clinfo
 create mode 120000 srcpkgs/ROCm-OpenCL-Runtime-devel
 create mode 100644 srcpkgs/ROCm-OpenCL-Runtime/files/libelf-musl.patch
 create mode 100644 srcpkgs/ROCm-OpenCL-Runtime/files/runtime-musl.patch
 create mode 100644 srcpkgs/ROCm-OpenCL-Runtime/patches/cmake.patch
 create mode 100644 srcpkgs/ROCm-OpenCL-Runtime/template
 create mode 100644 srcpkgs/ROCm-OpenCL-Runtime/update

diff --git a/common/shlibs b/common/shlibs
index 393e464f683..28250aa3a3f 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3984,3 +3984,5 @@ libneatvnc.so.0 neatvnc-0.2.0_1
 libhsakmt.so.1 ROCT-Thunk-Interface-3.3.0_1
 libhsa-runtime64.so.1 ROCR-Runtime-3.3.0_1
 libamd_comgr.so.1 ROCm-CompilerSupport-3.3.0_1
+libOpenCL-ROCm.so.1 ROCm-OpenCL-Runtime-3.3.0_1
+libamdocl64.so ROCm-OpenCL-Runtime-3.3.0_1
diff --git a/srcpkgs/ROCm-OpenCL-Runtime-clinfo b/srcpkgs/ROCm-OpenCL-Runtime-clinfo
new file mode 120000
index 00000000000..21f2041b8fb
--- /dev/null
+++ b/srcpkgs/ROCm-OpenCL-Runtime-clinfo
@@ -0,0 +1 @@
+ROCm-OpenCL-Runtime
\ No newline at end of file
diff --git a/srcpkgs/ROCm-OpenCL-Runtime-devel b/srcpkgs/ROCm-OpenCL-Runtime-devel
new file mode 120000
index 00000000000..21f2041b8fb
--- /dev/null
+++ b/srcpkgs/ROCm-OpenCL-Runtime-devel
@@ -0,0 +1 @@
+ROCm-OpenCL-Runtime
\ No newline at end of file
diff --git a/srcpkgs/ROCm-OpenCL-Runtime/files/libelf-musl.patch b/srcpkgs/ROCm-OpenCL-Runtime/files/libelf-musl.patch
new file mode 100644
index 00000000000..29469a9a351
--- /dev/null
+++ b/srcpkgs/ROCm-OpenCL-Runtime/files/libelf-musl.patch
@@ -0,0 +1,21 @@
+--- compiler/lib/loaders/elf/utils/libelf/_libelf.h	2020-04-28 15:50:53.243438174 -0400
++++ compiler/lib/loaders/elf/utils/libelf/_libelf.h	2020-04-28 15:51:54.293435415 -0400
+@@ -35,6 +35,7 @@
+ #include "_libelf_config.h"
+ 
+ #include "_elftc.h"
++#include <sys/cdefs.h>
+ 
+ /*
+  * Library-private data structures.
+--- compiler/lib/loaders/elf/utils/libelf/libelf.h	2020-04-28 15:50:53.244438174 -0400
++++ compiler/lib/loaders/elf/utils/libelf/libelf.h	2020-04-28 15:52:12.375434593 -0400
+@@ -36,6 +36,8 @@
+ #define EM_HSAIL 0xAF5A
+ #endif
+ 
++#include <sys/cdefs.h>
++
+ /* Library private data structures */
+ typedef struct _Elf Elf;
+ typedef struct _Elf_Scn Elf_Scn;
diff --git a/srcpkgs/ROCm-OpenCL-Runtime/files/runtime-musl.patch b/srcpkgs/ROCm-OpenCL-Runtime/files/runtime-musl.patch
new file mode 100644
index 00000000000..ea18e90e09c
--- /dev/null
+++ b/srcpkgs/ROCm-OpenCL-Runtime/files/runtime-musl.patch
@@ -0,0 +1,11 @@
+--- runtime/os/os_posix.cpp.orig	2020-04-19 09:13:51.701982901 -0400
++++ runtime/os/os_posix.cpp	2020-04-19 09:14:04.156947422 -0400
+@@ -44,6 +44,8 @@
+ #include <algorithm>
+ #include <mutex>
+ 
++#include <libgen.h> // for basename
++
+ 
+ namespace amd {
+ 
diff --git a/srcpkgs/ROCm-OpenCL-Runtime/patches/cmake.patch b/srcpkgs/ROCm-OpenCL-Runtime/patches/cmake.patch
new file mode 100644
index 00000000000..2c96b99d45a
--- /dev/null
+++ b/srcpkgs/ROCm-OpenCL-Runtime/patches/cmake.patch
@@ -0,0 +1,126 @@
+--- OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/CMakeLists.txt	2019-09-10 11:53:28.000000000 -0400
++++ OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/CMakeLists.txt	2020-04-16 20:16:13.481180757 -0400
+@@ -73,11 +73,11 @@
+ 
+ set (OPENCL_ICD_LOADER_HEADERS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/inc CACHE PATH "Path to OpenCL Headers")
+ 
+-add_library (OpenCL ${OPENCL_ICD_LOADER_SOURCES})
+-set_target_properties (OpenCL PROPERTIES VERSION "1.2" SOVERSION "1")
++add_library (OpenCL-ROCm ${OPENCL_ICD_LOADER_SOURCES})
++set_target_properties (OpenCL-ROCm PROPERTIES VERSION "1.2" SOVERSION "1")
+ 
+ if (WIN32)
+-    target_link_libraries (OpenCL cfgmgr32.lib)
++    target_link_libraries (OpenCL-ROCm cfgmgr32.lib)
+ 
+     option (OPENCL_ICD_LOADER_REQUIRE_WDK "Build with D3DKMT support, which requires the Windows WDK." ON)
+     if (OPENCL_ICD_LOADER_REQUIRE_WDK)
+@@ -92,10 +92,10 @@
+             get_filename_component(WDK_DIRECTORY ${LATEST_D3DKMT_HEADER} DIRECTORY)
+             get_filename_component(WDK_DIRECTORY ${WDK_DIRECTORY} DIRECTORY)
+             message(STATUS "Found the Windows WDK in: ${WDK_DIRECTORY}")
+-            target_compile_definitions(OpenCL PRIVATE OPENCL_ICD_LOADER_REQUIRE_WDK)
+-            target_include_directories(OpenCL PRIVATE ${WDK_DIRECTORY}/um)
+-            target_include_directories(OpenCL PRIVATE ${WDK_DIRECTORY}/km)
+-            target_include_directories(OpenCL PRIVATE ${WDK_DIRECTORY}/shared)
++	    target_compile_definitions(OpenCL-ROCm PRIVATE OPENCL_ICD_LOADER_REQUIRE_WDK)
++	    target_include_directories(OpenCL-ROCm PRIVATE ${WDK_DIRECTORY}/um)
++	    target_include_directories(OpenCL-ROCm PRIVATE ${WDK_DIRECTORY}/km)
++	    target_include_directories(OpenCL-ROCm PRIVATE ${WDK_DIRECTORY}/shared)
+         else()
+             message(FATAL_ERROR "The Windows WDK was not found. Consider disabling OPENCL_ICD_LOADER_REQUIRE_WDK. Aborting.")
+         endif()
+@@ -113,25 +113,25 @@
+     endif()
+ else()
+     if (APPLE)
+-        target_link_libraries (OpenCL ${CMAKE_THREAD_LIBS_INIT})
++        target_link_libraries (OpenCL-ROCm ${CMAKE_THREAD_LIBS_INIT})
+     else ()
+-        set_target_properties (OpenCL PROPERTIES LINK_FLAGS "-Wl,--version-script -Wl,${CMAKE_CURRENT_SOURCE_DIR}/loader/linux/icd_exports.map")
+-        target_link_libraries (OpenCL ${CMAKE_THREAD_LIBS_INIT})
++        set_target_properties (OpenCL-ROCm PROPERTIES LINK_FLAGS "-Wl,--version-script -Wl,${CMAKE_CURRENT_SOURCE_DIR}/loader/linux/icd_exports.map")
++	target_link_libraries (OpenCL-ROCm ${CMAKE_THREAD_LIBS_INIT})
+     endif ()
+ endif ()
+ 
+ include_directories (${OPENCL_ICD_LOADER_HEADERS_DIR})
+ add_definitions (-DCL_TARGET_OPENCL_VERSION=220)
+ 
+-target_include_directories (OpenCL PRIVATE ${CMAKE_CURRENT_BINARY_DIR} loader)
+-target_link_libraries (OpenCL ${CMAKE_DL_LIBS})
++target_include_directories (OpenCL-ROCm PRIVATE ${CMAKE_CURRENT_BINARY_DIR} loader)
++target_link_libraries (OpenCL-ROCm ${CMAKE_DL_LIBS})
+ 
+ include (CTest)
+ if (BUILD_TESTING)
+     add_subdirectory (test)
+ endif()
+ 
+-install (TARGETS OpenCL
++install (TARGETS OpenCL-ROCm
+     RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+     ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
+     LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
+--- OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/test/loader_test/CMakeLists.txt	2019-09-10 11:53:28.000000000 -0400
++++ OpenCL-ICD-Loader-6c03f8b58fafd9dd693eaac826749a5cfad515f8/test/loader_test/CMakeLists.txt	2020-04-16 20:16:56.647026589 -0400
+@@ -12,4 +12,4 @@
+     test_clgl.c
+     test_image_objects.c )
+ 
+-target_link_libraries (icd_loader_test OpenCL IcdLog)
++target_link_libraries (icd_loader_test OpenCL-ROCm IcdLog)
+--- ROCm-OpenCL-Runtime-roc-3.3.0/CMakeLists.txt	2020-04-28 07:29:51.864446603 -0400
++++ ROCm-OpenCL-Runtime-roc-3.3.0/CMakeLists.txt	2020-04-28 07:32:45.245793180 -0400
+@@ -101,30 +101,30 @@
+ rocm_setup_version( VERSION "2.0.0" )
+ 
+ # MAIN package
+-install(PROGRAMS $<TARGET_FILE:clinfo>
+-        DESTINATION bin/x86_64
++install(PROGRAMS $<TARGET_FILE:rocm-clinfo>
++        DESTINATION bin
+         COMPONENT MAIN)
+ install(PROGRAMS $<TARGET_FILE:amdocl64>
+-        DESTINATION lib/x86_64
++        DESTINATION lib
+         COMPONENT MAIN)
+-install(PROGRAMS $<TARGET_FILE:OpenCL>
+-        DESTINATION lib/x86_64
++install(PROGRAMS $<TARGET_FILE:OpenCL-ROCm>
++        DESTINATION lib
+         COMPONENT MAIN)
+-install(PROGRAMS $<TARGET_SONAME_FILE:OpenCL>
+-        DESTINATION lib/x86_64
++install(PROGRAMS $<TARGET_SONAME_FILE:OpenCL-ROCm>
++        DESTINATION lib
+         COMPONENT MAIN)
+ 
+ # DEV package
+ install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/api/opencl/khronos/headers/opencl2.2/CL"
+-        DESTINATION include
++	DESTINATION include/rocm
+         COMPONENT DEV
+         USE_SOURCE_PERMISSIONS
+         PATTERN cl_d3d10.h EXCLUDE
+         PATTERN cl_d3d11.h EXCLUDE
+         PATTERN cl_dx9_media_sharing.h EXCLUDE
+         PATTERN cl_egl.h EXCLUDE)
+-install(PROGRAMS $<TARGET_LINKER_FILE:OpenCL>
+-        DESTINATION lib/x86_64
++install(PROGRAMS $<TARGET_LINKER_FILE:OpenCL-ROCm>
++        DESTINATION lib
+         COMPONENT DEV)
+ 
+ # Generic CPACK variables
+--- ROCm-OpenCL-Runtime-roc-3.3.0/tools/clinfo/CMakeLists.txt	2020-04-28 07:29:51.882446535 -0400
++++ ROCm-OpenCL-Runtime-roc-3.3.0/tools/clinfo/CMakeLists.txt	2020-04-28 07:30:05.627394732 -0400
+@@ -6,6 +6,6 @@
+ 
+ add_definitions(-DHAVE_CL2_HPP)
+ 
+-add_executable(clinfo clinfo.cpp)
++add_executable(rocm-clinfo clinfo.cpp)
+ 
+-target_link_libraries(clinfo OpenCL)
++target_link_libraries(rocm-clinfo OpenCL-ROCm)
diff --git a/srcpkgs/ROCm-OpenCL-Runtime/template b/srcpkgs/ROCm-OpenCL-Runtime/template
new file mode 100644
index 00000000000..f6699a1d4c0
--- /dev/null
+++ b/srcpkgs/ROCm-OpenCL-Runtime/template
@@ -0,0 +1,84 @@
+# Template file for 'ROCm-OpenCL-Runtime'
+pkgname=ROCm-OpenCL-Runtime
+version=3.3.0
+revision=1
+_ocl_icd_name="OpenCL-ICD-Loader"
+_ocl_icd_ver="6c03f8b58fafd9dd693eaac826749a5cfad515f8"
+archs="x86_64*"
+create_wrksrc=yes
+build_wrksrc="${pkgname}-roc-${version}"
+build_style=cmake
+configure_args="-DUSE_COMGR_LIBRARY=yes"
+hostmakedepends="cmake pkg-config"
+makedepends="libglvnd-devel ROCm-CompilerSupport-devel
+	ROCT-Thunk-Interface-devel ROCR-Runtime-devel"
+depends="ROCm-CompilerSupport"
+short_desc="Radeon Open Compute OpenCL runtime"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="MIT"
+homepage="https://github.com/RadeonOpenCompute/ROCm-OpenCL-Runtime"
+_rocroot="https://github.com/RadeonOpenCompute"
+distfiles="${_rocroot}/ROCm-OpenCL-Runtime/archive/roc-${version}.tar.gz
+	${_rocroot}/rocm-cmake/archive/rocm-${version}.tar.gz
+	https://github.com/KhronosGroup/${_ocl_icd_name}/archive/${_ocl_icd_ver}.tar.gz"
+checksum="ac6999f1a491ab066286c2bd6adf50f08f831286f56e267879f9f7eced22f98e
+	76ed3ee8e56cf3246011cf7723c2abda539e1136e7e7f6909bfa45d268b8644f
+	c94d5bb6dc980c4d41d73e2b81663a19aabe494e923e2d0eec72a4c95b318438"
+nocross=yes
+
+if [ "$XBPS_LIBC" = "musl" ]; then
+	makedepends+=" musl-legacy-compat"
+fi
+
+post_patch() {
+	if [ "$XBPS_LIBC" = "musl" ]; then
+		# Remove dependence on glibc
+		patch -Np0 < ${FILESDIR}/libelf-musl.patch
+		patch -Np0 < ${FILESDIR}/runtime-musl.patch
+		vsed -e '/glibc_functions.cpp/d' -i api/opencl/amdocl/CMakeLists.txt
+	fi
+}
+
+pre_configure() {
+	# ROCm requires a very specific Khronos ICD loader version in the tree
+	# Keep the ICD loader config in /etc/OpenCL/rocm-vendors to avoid conflicts
+	_ocl_icd_dir="${_ocl_icd_name}-${_ocl_icd_ver}"
+	ln -sf "${wrksrc}/${_ocl_icd_dir}" api/opencl/khronos/icd
+	vsed -i "${wrksrc}/${_ocl_icd_dir}/loader/icd_platform.h" \
+		-e 's@/etc/OpenCL/vendors/@/etc/OpenCL/rocm-vendors/@g'
+
+	# CMake modules probably not useful anywhere but for this build
+	ln -sf "${wrksrc}/rocm-cmake-rocm-${version}/share/rocm/cmake"/*.cmake cmake
+
+	# Fix the dlopen macro to point to versioned libamd_comgr shared object
+	vsed -i 'runtime/device/comgrctx.cpp' \
+		-e 's/\blibamd_comgr\(32\)\?.so\b/&.1/g'
+}
+
+post_install() {
+	vlicense License
+
+	# Create descriptor to allow the ICD loader to find the driver
+	vmkdir etc/OpenCL/rocm-vendors
+	echo "libamdocl64.so" > "${DESTDIR}/etc/OpenCL/rocm-vendors/amdocl64.icd"
+	vmkdir etc/OpenCL/vendors
+	ln -s ../../OpenCL/rocm-vendors/amdocl64.icd \
+		${DESTDIR}/etc/OpenCL/vendors/rocm-amdocl64.icd
+}
+
+ROCm-OpenCL-Runtime-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/lib/libOpenCL-ROCm.so
+		vmove usr/include
+	}
+}
+
+ROCm-OpenCL-Runtime-clinfo_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - clinfo"
+	pkg_install() {
+		vmove usr/bin/rocm-clinfo
+	}
+}
diff --git a/srcpkgs/ROCm-OpenCL-Runtime/update b/srcpkgs/ROCm-OpenCL-Runtime/update
new file mode 100644
index 00000000000..8385f4d1215
--- /dev/null
+++ b/srcpkgs/ROCm-OpenCL-Runtime/update
@@ -0,0 +1 @@
+pattern='roc-\K[\d.]+'

From 8fb59c86f69c5f43726fc0be4f813444a06fde38 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Thu, 30 Apr 2020 13:11:12 -0400
Subject: [PATCH 9/9] New package: ROCR-Runtime-hsa-ext-3.3.0

[ci skip]
---
 common/shlibs                         |  2 ++
 srcpkgs/ROCR-Runtime-hsa-ext-devel    |  1 +
 srcpkgs/ROCR-Runtime-hsa-ext/template | 43 +++++++++++++++++++++++++++
 srcpkgs/ROCR-Runtime-hsa-ext/update   |  2 ++
 4 files changed, 48 insertions(+)
 create mode 120000 srcpkgs/ROCR-Runtime-hsa-ext-devel
 create mode 100644 srcpkgs/ROCR-Runtime-hsa-ext/template
 create mode 100644 srcpkgs/ROCR-Runtime-hsa-ext/update

diff --git a/common/shlibs b/common/shlibs
index 28250aa3a3f..66392db5c99 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3986,3 +3986,5 @@ libhsa-runtime64.so.1 ROCR-Runtime-3.3.0_1
 libamd_comgr.so.1 ROCm-CompilerSupport-3.3.0_1
 libOpenCL-ROCm.so.1 ROCm-OpenCL-Runtime-3.3.0_1
 libamdocl64.so ROCm-OpenCL-Runtime-3.3.0_1
+libhsa-ext-image64.so.1 ROCR-Runtime-hsa-ext-3.3.0_1
+libhsa-runtime-tools64.so.1 ROCR-Runtime-hsa-ext-3.3.0_1
diff --git a/srcpkgs/ROCR-Runtime-hsa-ext-devel b/srcpkgs/ROCR-Runtime-hsa-ext-devel
new file mode 120000
index 00000000000..6ee1b14911b
--- /dev/null
+++ b/srcpkgs/ROCR-Runtime-hsa-ext-devel
@@ -0,0 +1 @@
+ROCR-Runtime-hsa-ext
\ No newline at end of file
diff --git a/srcpkgs/ROCR-Runtime-hsa-ext/template b/srcpkgs/ROCR-Runtime-hsa-ext/template
new file mode 100644
index 00000000000..235ae92146b
--- /dev/null
+++ b/srcpkgs/ROCR-Runtime-hsa-ext/template
@@ -0,0 +1,43 @@
+# Template file for 'ROCR-Runtime-hsa-ext'
+pkgname=ROCR-Runtime-hsa-ext
+version=3.3.0
+revision=1
+archs="x86_64"
+hostmakedepends="tar"
+short_desc="Radeon Open Compute HSA runtime extensions"
+maintainer="Andrew J. Hesford <ajh@sideband.org>"
+license="NCSA"
+homepage="https://github.com/RadeonOpenCompute"
+_hsa_deb="hsa-ext-rocr-dev_1.1.30300.0-rocm-rel-3.3-19-23fc088b_amd64.deb"
+distfiles="https://repo.radeon.com/rocm/apt/debian/pool/main/h/hsa-ext-rocr-dev/$_hsa_deb"
+checksum=6b44e286b395d946b865ec1f3cc546356396785ac1fde591d07af02d0aa7c25d
+repository=nonfree
+restricted=yes
+
+do_extract() {
+	ar x "${XBPS_SRCDISTDIR}/${pkgname}-${version}/${_hsa_deb}"
+	tar xvf data.tar.gz
+}
+
+do_install() {
+	_rocm_includes="opt/rocm-${version}/hsa/include"
+
+	vmkdir usr
+	vcopy opt/rocm-${version}/hsa/lib usr
+	vcopy "$_rocm_includes" usr
+
+	# Extract license from one of the header files
+	awk 'BEGIN{HEADER=0} /\/\//{HEADER=1; print $0;} /^[^/]/{if(HEADER==1) exit;}' \
+		< "${_rocm_includes}/hsa/amd_hsa_tools_interfaces.h" \
+		| sed 's@^///*\( \|$\)@@' > LICENSE
+	vlicense LICENSE
+}
+
+ROCR-Runtime-hsa-ext-devel_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove "usr/lib/*.so"
+	}
+}
diff --git a/srcpkgs/ROCR-Runtime-hsa-ext/update b/srcpkgs/ROCR-Runtime-hsa-ext/update
new file mode 100644
index 00000000000..84252d2e3b8
--- /dev/null
+++ b/srcpkgs/ROCR-Runtime-hsa-ext/update
@@ -0,0 +1,2 @@
+site='https://repo.radeon.com/rocm/apt/debian/pool/main/h/'
+pattern='hsa-ext-rocr-dev\K[\d.]+'

^ permalink raw reply	[flat|nested] 61+ messages in thread

* Re: New packages: ROCm core and OpenCL
  2020-04-19 13:34 [PR PATCH] New packages: ROCm core and OpenCL ahesford
                   ` (55 preceding siblings ...)
  2020-08-20 18:50 ` [PR PATCH] [Updated] " ahesford
@ 2020-12-21  7:32 ` fosslinux
  2020-12-21 11:58 ` ahesford
                   ` (2 subsequent siblings)
  59 siblings, 0 replies; 61+ messages in thread
From: fosslinux @ 2020-12-21  7:32 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 436 bytes --]

New comment by fosslinux on void-packages repository

https://github.com/void-linux/void-packages/pull/21153#issuecomment-748816049

Comment:
@ahesford I have a diff for ROCm 3.10.0 and will update for 4.0.0 shortly, would you like me to open a new PR or would oyu like to pull the changes into this one?

Patch attached:

[rocm-3.10.0.patch.txt](https://github.com/void-linux/void-packages/files/5722884/rocm-3.10.0.patch.txt)



^ permalink raw reply	[flat|nested] 61+ messages in thread

* Re: New packages: ROCm core and OpenCL
  2020-04-19 13:34 [PR PATCH] New packages: ROCm core and OpenCL ahesford
                   ` (56 preceding siblings ...)
  2020-12-21  7:32 ` fosslinux
@ 2020-12-21 11:58 ` ahesford
  2021-02-15  5:19 ` ahesford
  2021-02-15  5:19 ` [PR PATCH] [Closed]: " ahesford
  59 siblings, 0 replies; 61+ messages in thread
From: ahesford @ 2020-12-21 11:58 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 194 bytes --]

New comment by ahesford on void-packages repository

https://github.com/void-linux/void-packages/pull/21153#issuecomment-748937264

Comment:
@fosslinux Open a new one; this discussion is stale.

^ permalink raw reply	[flat|nested] 61+ messages in thread

* Re: New packages: ROCm core and OpenCL
  2020-04-19 13:34 [PR PATCH] New packages: ROCm core and OpenCL ahesford
                   ` (57 preceding siblings ...)
  2020-12-21 11:58 ` ahesford
@ 2021-02-15  5:19 ` ahesford
  2021-02-15  5:19 ` [PR PATCH] [Closed]: " ahesford
  59 siblings, 0 replies; 61+ messages in thread
From: ahesford @ 2021-02-15  5:19 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 199 bytes --]

New comment by ahesford on void-packages repository

https://github.com/void-linux/void-packages/pull/21153#issuecomment-778946921

Comment:
This may be revisited some day, but today is not the day.

^ permalink raw reply	[flat|nested] 61+ messages in thread

* Re: [PR PATCH] [Closed]: New packages: ROCm core and OpenCL
  2020-04-19 13:34 [PR PATCH] New packages: ROCm core and OpenCL ahesford
                   ` (58 preceding siblings ...)
  2021-02-15  5:19 ` ahesford
@ 2021-02-15  5:19 ` ahesford
  59 siblings, 0 replies; 61+ messages in thread
From: ahesford @ 2021-02-15  5:19 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 3738 bytes --]

There's a closed pull request on the void-packages repository

New packages: ROCm core and OpenCL
https://github.com/void-linux/void-packages/pull/21153

Description:
This PR includes several packages designed to bring the OpenCL portion of the AMD ROCm ecosystem to Void. It addresses Issue #19507. There are many other packages that AMD provides for GPGPU computing, but these can be added piecemeal as users demand.

The packages are currently only for `x86_64*`. While at least some of the packages will compile on other 64-bit architectures, I have no hardware to test. They are certainly not suitable for 32-bit architectures; some internal data structures rely on `uint64_t` values that are cast to pointers. At a
minimum, a thorough audit would be necessary to ensure that these casts are safe (e.g., that the values stored were only ever upcast from 32-bit pointers). More extensive work may be necessary to support 32-bit architectures, probably without significant benefit.

The packages successfully identify a Radeon RX 580 on an `x86_64` installation using both `clinfo` and `rocminfo` as provided. Furthermore, a version of `pyopencl` linked against these ROCm packages successfully runs a simple program that validates arithmetic on GPU-bound arrays.

There are caveats with this set of packages, almost all of which revolve around the incompatibilities between the Void-provided `ocl-icd` and the [Khronos OpenCL ICD loader](https://github.com/KhronosGroup/OpenCL-ID-Loader) required by (and built into) `rocm-opencl-runtime`.
1. All packages install into `/opt/rocm`. This keeps the environment closer to that officially sanctioned by AMD and helps avoid conflicts between other packages and those provided here. (For example, `clinfo` and the ICD loader itself.) Eventually, we may be able to move the files into `/usr`.
2. The Khronos OpenCL ICD loader built into `rocm-opencl-runtime` is an outdated, pre-release commit. If AMD can update its sources to use the release version of that loader (which has a backward-incompatible API change), we may be able to make ROCm compatible with `ocl-icd` or replace `ocl-icd` with the official Khronos loader.
3. In the meantime, to avoid `shlibs` conflicts, the OpenCL ICD loader is installed as `/opt/rocm/lib/libOpenCL-ROCm.so` (and an appropriately versioned shared library), which means that programs wishing to use the ROCm OpenCL must explicitly link against this library instead of the generic `libOpenCL.so`.
4. I do **not** recommend making any Void packages link against this specific library, because it will make those packages ROCm-only. For the time being, ROCm is intended for end-users to specifically link against. Linking Void packages against ROCm would requires the ICD loader used by ROCm be compatible with `ocl-icd`, or `ocl-icd` be replaced by the Khronos loader. However, because the Khronos loader changed its API for the release version, such a change is not yet appropriate.

Hopefully, if AMD updates its dependence on the Khronos ICD loader, we can resolve some of these caveats in the future and make ROCm a more natural Void component. For now, these packages are useful for those who need an AMD OpenCL solution and would rather custom-link software against the AMD ICD loader than hack the `amdgpu-pro` driver into an ICD compatible with `ocl-icd`.

Some patches were made to relocate some files in `/opt/rocm` and make everyting build on x86_64-musl`. Where appropriate, these patches will be pushed upstream to clean up the distribution and packaging.

Update: I pushed some new commits to update license information that triggerd an `xlint` failure. I've also disabled CI builds because they will time out on `rocm-llvm`.

^ permalink raw reply	[flat|nested] 61+ messages in thread

end of thread, other threads:[~2021-02-15  5:19 UTC | newest]

Thread overview: 61+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-19 13:34 [PR PATCH] New packages: ROCm core and OpenCL ahesford
2020-04-19 15:24 ` [PR PATCH] [Updated] " ahesford
2020-04-19 15:57 ` ahesford
2020-04-19 19:02 ` ahesford
2020-04-20  2:02 ` ahesford
2020-04-28 14:00 ` ahesford
2020-04-28 15:14 ` ahesford
2020-04-28 17:34 ` ahesford
2020-04-28 17:34 ` ahesford
2020-04-28 17:38 ` ahesford
2020-04-28 18:09 ` ahesford
2020-04-28 18:44 ` [PR PATCH] [Updated] " ahesford
2020-04-28 19:59 ` ahesford
2020-04-30 19:05 ` ahesford
2020-04-30 19:12 ` ahesford
2020-04-30 19:22 ` ahesford
2020-04-30 19:32 ` ahesford
2020-04-30 19:35 ` ahesford
2020-04-30 19:38 ` ahesford
2020-05-01  4:57 ` lemmi
2020-05-01  5:10 ` ahesford
2020-05-01  5:12 ` ahesford
2020-05-01 14:04 ` [PR PATCH] [Updated] " ahesford
2020-05-01 19:36 ` ahesford
2020-05-02  1:34 ` ahesford
2020-05-02  3:29 ` ahesford
2020-05-05 14:24 ` ahesford
2020-05-05 14:26 ` ahesford
2020-05-07 14:18 ` ahesford
2020-05-07 16:01 ` ahesford
2020-05-08 14:40 ` ahesford
2020-05-11 18:02 ` ericonr
2020-05-11 18:07 ` ahesford
2020-05-11 18:07 ` ahesford
2020-05-11 18:52 ` [PR PATCH] [Updated] " ahesford
2020-05-11 20:03 ` ahesford
2020-05-14 18:04 ` FiCacador
2020-05-14 18:04 ` FiCacador
2020-05-14 19:13 ` ahesford
2020-05-14 19:14 ` ahesford
2020-05-14 22:51 ` FiCacador
2020-05-15  0:07 ` ahesford
2020-05-15  1:30 ` fosslinux
2020-05-15  3:31 ` FiCacador
2020-05-15  3:32 ` FiCacador
2020-05-15  6:54 ` fosslinux
2020-08-04 17:13 ` [PR PATCH] [Updated] " ahesford
2020-08-04 17:13 ` ahesford
2020-08-04 17:16 ` [PR PATCH] [Closed]: " ahesford
2020-08-04 17:16 ` [PR PATCH] [Updated] " ahesford
2020-08-04 17:19 ` ahesford
2020-08-04 17:24 ` [PR PATCH] [Updated] " ahesford
2020-08-18 18:36 ` aurieh
2020-08-18 18:38 ` aurieh
2020-08-18 18:39 ` aurieh
2020-08-18 19:46 ` ahesford
2020-08-20 18:50 ` [PR PATCH] [Updated] " ahesford
2020-12-21  7:32 ` fosslinux
2020-12-21 11:58 ` ahesford
2021-02-15  5:19 ` ahesford
2021-02-15  5:19 ` [PR PATCH] [Closed]: " ahesford

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).