summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSv. Lockal <lockalsash@gmail.com>2024-03-09 14:49:32 +0000
committerSam James <sam@gentoo.org>2024-03-10 02:16:14 +0000
commit9e7cda93ca888ceabe7c14bf3ddb961c36fdc049 (patch)
tree2b4a052ad366ead13f34ecf1d03164995502dca4
parentdev-libs/roct-thunk-interface: fix compilation with musl for 5.7.1 and 6.0.0 (diff)
downloadgentoo-9e7cda93ca888ceabe7c14bf3ddb961c36fdc049.tar.gz
gentoo-9e7cda93ca888ceabe7c14bf3ddb961c36fdc049.tar.bz2
gentoo-9e7cda93ca888ceabe7c14bf3ddb961c36fdc049.zip
dev-libs/rocr-runtime: fix compilation with musl for 5.7.1 and 6.0.0
Upstream bug: https://github.com/ROCm/ROCR-Runtime/issues/181 Closes: https://bugs.gentoo.org/921322 Signed-off-by: Sv. Lockal <lockalsash@gmail.com> Signed-off-by: Sam James <sam@gentoo.org>
-rw-r--r--dev-libs/rocr-runtime/files/rocr-runtime-5.7.1-musl.patch106
-rw-r--r--dev-libs/rocr-runtime/rocr-runtime-5.7.1-r2.ebuild (renamed from dev-libs/rocr-runtime/rocr-runtime-5.7.1-r1.ebuild)9
-rw-r--r--dev-libs/rocr-runtime/rocr-runtime-6.0.0-r1.ebuild (renamed from dev-libs/rocr-runtime/rocr-runtime-6.0.0.ebuild)7
3 files changed, 115 insertions, 7 deletions
diff --git a/dev-libs/rocr-runtime/files/rocr-runtime-5.7.1-musl.patch b/dev-libs/rocr-runtime/files/rocr-runtime-5.7.1-musl.patch
new file mode 100644
index 000000000000..0e8e53209738
--- /dev/null
+++ b/dev-libs/rocr-runtime/files/rocr-runtime-5.7.1-musl.patch
@@ -0,0 +1,106 @@
+Fix compilation with musl.
+
+Bug: https://github.com/ROCm/ROCR-Runtime/issues/181
+--- a/core/inc/checked.h
++++ b/core/inc/checked.h
+@@ -58,7 +58,7 @@ template <uint64_t code, bool multiProcess = false> class Check final {
+ Check(const Check&) { object_ = uintptr_t(this) ^ uintptr_t(code); }
+ Check(Check&&) { object_ = uintptr_t(this) ^ uintptr_t(code); }
+
+- ~Check() { object_ = NULL; }
++ ~Check() { object_ = uintptr_t(NULL); }
+
+ const Check& operator=(Check&& rhs) { return *this; }
+ const Check& operator=(const Check& rhs) { return *this; }
+--- a/core/runtime/default_signal.cpp
++++ b/core/runtime/default_signal.cpp
+@@ -57,7 +57,7 @@ int BusyWaitSignal::rtti_id_ = 0;
+ BusyWaitSignal::BusyWaitSignal(SharedSignal* abi_block, bool enableIPC)
+ : Signal(abi_block, enableIPC) {
+ signal_.kind = AMD_SIGNAL_KIND_USER;
+- signal_.event_mailbox_ptr = NULL;
++ signal_.event_mailbox_ptr = uint64_t(NULL);
+ }
+
+ hsa_signal_value_t BusyWaitSignal::LoadRelaxed() {
+--- a/core/util/lnx/os_linux.cpp
++++ b/core/util/lnx/os_linux.cpp
+@@ -111,9 +111,12 @@ class os_thread {
+ }
+ }
+
++ int cores = 0;
++ cpu_set_t* cpuset = nullptr;
++
+ if (core::Runtime::runtime_singleton_->flag().override_cpu_affinity()) {
+- int cores = get_nprocs_conf();
+- cpu_set_t* cpuset = CPU_ALLOC(cores);
++ cores = get_nprocs_conf();
++ cpuset = CPU_ALLOC(cores);
+ if (cpuset == nullptr) {
+ fprintf(stderr, "CPU_ALLOC failed: %s\n", strerror(errno));
+ return;
+@@ -122,12 +125,6 @@ class os_thread {
+ for (int i = 0; i < cores; i++) {
+ CPU_SET(i, cpuset);
+ }
+- err = pthread_attr_setaffinity_np(&attrib, CPU_ALLOC_SIZE(cores), cpuset);
+- CPU_FREE(cpuset);
+- if (err != 0) {
+- fprintf(stderr, "pthread_attr_setaffinity_np failed: %s\n", strerror(err));
+- return;
+- }
+ }
+
+ err = pthread_create(&thread, &attrib, ThreadTrampoline, args.get());
+@@ -157,6 +154,14 @@ class os_thread {
+ if (err != 0) {
+ fprintf(stderr, "pthread_attr_destroy failed: %s\n", strerror(err));
+ }
++
++ if (thread && cores && cpuset) {
++ err = pthread_setaffinity_np(thread, CPU_ALLOC_SIZE(cores), cpuset);
++ CPU_FREE(cpuset);
++ if (err != 0) {
++ fprintf(stderr, "pthread_setaffinity_np failed: %s\n", strerror(err));
++ }
++ }
+ }
+
+ os_thread(os_thread&& rhs) {
+@@ -617,11 +622,13 @@ SharedMutex CreateSharedMutex() {
+ fprintf(stderr, "rw lock attribute init failed: %s\n", strerror(err));
+ return nullptr;
+ }
++#if defined(__GLIBC__)
+ err = pthread_rwlockattr_setkind_np(&attrib, PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP);
+ if (err != 0) {
+ fprintf(stderr, "Set rw lock attribute failure: %s\n", strerror(err));
+ return nullptr;
+ }
++#endif
+
+ pthread_rwlock_t* lock = new pthread_rwlock_t;
+ err = pthread_rwlock_init(lock, &attrib);
+--- a/core/util/utils.h
++++ b/core/util/utils.h
+@@ -74,7 +74,7 @@ static __forceinline void* _aligned_malloc(size_t size, size_t alignment) {
+ return aligned_alloc(alignment, size);
+ #else
+ void *mem = NULL;
+- if (NULL != posix_memalign(&mem, alignment, size))
++ if (0 != posix_memalign(&mem, alignment, size))
+ return NULL;
+ return mem;
+ #endif
+--- a/image/util.h
++++ b/image/util.h
+@@ -95,7 +95,7 @@ static __forceinline void* _aligned_malloc(size_t size, size_t alignment) {
+ return aligned_alloc(alignment, size);
+ #else
+ void* mem = NULL;
+- if (NULL != posix_memalign(&mem, alignment, size)) return NULL;
++ if (0 != posix_memalign(&mem, alignment, size)) return NULL;
+ return mem;
+ #endif
+ }
diff --git a/dev-libs/rocr-runtime/rocr-runtime-5.7.1-r1.ebuild b/dev-libs/rocr-runtime/rocr-runtime-5.7.1-r2.ebuild
index 564da67950fa..00615488c2d2 100644
--- a/dev-libs/rocr-runtime/rocr-runtime-5.7.1-r1.ebuild
+++ b/dev-libs/rocr-runtime/rocr-runtime-5.7.1-r2.ebuild
@@ -3,10 +3,10 @@
EAPI=8
-inherit cmake flag-o-matic llvm
-
LLVM_MAX_SLOT=17
+inherit cmake flag-o-matic llvm
+
if [[ ${PV} == *9999 ]] ; then
EGIT_REPO_URI="https://github.com/RadeonOpenCompute/ROCR-Runtime/"
inherit git-r3
@@ -22,6 +22,7 @@ HOMEPAGE="https://github.com/RadeonOpenCompute/ROCR-Runtime"
PATCHES=(
"${FILESDIR}/${PN}-4.3.0_no-aqlprofiler.patch"
"${FILESDIR}/${PN}-5.7.1-extend-isa-compatibility-check.patch"
+ "${FILESDIR}/${PN}-5.7.1-musl.patch"
)
LICENSE="MIT"
@@ -33,8 +34,8 @@ COMMON_DEPEND="dev-libs/elfutils
DEPEND="${COMMON_DEPEND}
>=dev-libs/roct-thunk-interface-${PV}
>=dev-libs/rocm-device-libs-${PV}
- sys-devel/clang
- sys-devel/lld"
+ sys-devel/clang:${LLVM_MAX_SLOT}=
+ sys-devel/lld:${LLVM_MAX_SLOT}="
RDEPEND="${DEPEND}"
BDEPEND="app-editors/vim-core"
# vim-core is needed for "xxd"
diff --git a/dev-libs/rocr-runtime/rocr-runtime-6.0.0.ebuild b/dev-libs/rocr-runtime/rocr-runtime-6.0.0-r1.ebuild
index 840a1949b160..cdd27fbbbefd 100644
--- a/dev-libs/rocr-runtime/rocr-runtime-6.0.0.ebuild
+++ b/dev-libs/rocr-runtime/rocr-runtime-6.0.0-r1.ebuild
@@ -1,4 +1,4 @@
-# Copyright 1999-2023 Gentoo Authors
+# Copyright 1999-2024 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=8
@@ -21,6 +21,7 @@ DESCRIPTION="Radeon Open Compute Runtime"
HOMEPAGE="https://github.com/RadeonOpenCompute/ROCR-Runtime"
PATCHES=(
"${FILESDIR}/${PN}-4.3.0_no-aqlprofiler.patch"
+ "${FILESDIR}/${PN}-5.7.1-musl.patch"
)
LICENSE="MIT"
@@ -32,8 +33,8 @@ COMMON_DEPEND="dev-libs/elfutils
DEPEND="${COMMON_DEPEND}
>=dev-libs/roct-thunk-interface-${PV}
>=dev-libs/rocm-device-libs-${PV}
- sys-devel/clang
- sys-devel/lld"
+ sys-devel/clang:${LLVM_MAX_SLOT}=
+ sys-devel/lld:${LLVM_MAX_SLOT}="
RDEPEND="${DEPEND}"
BDEPEND="app-editors/vim-core"
# vim-core is needed for "xxd"