Skip to content

Commit d16cb8d

Browse files
AngryLokinegril
authored andcommitted
dev-util/hip: fix compilation with musl
Upstream pull-requests: * ROCm/clr#83 * ROCm/hip-tests#463 Signed-off-by: Sv. Lockal <[email protected]> Signed-off-by: Paul Zander <[email protected]>
1 parent 1b9e14d commit d16cb8d

File tree

3 files changed

+185
-0
lines changed

3 files changed

+185
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
Fix "basename" and "__cpu_mask" definitions for musl
2+
3+
Upstream PR: https://github.com/ROCm/clr/pull/83
4+
--- a/rocclr/os/os.hpp
5+
+++ b/rocclr/os/os.hpp
6+
@@ -29,6 +29,7 @@
7+
8+
#if defined(__linux__)
9+
#include <sched.h>
10+
+#include <libgen.h>
11+
#endif
12+
13+
#ifdef _WIN32
14+
@@ -377,6 +378,10 @@ ALWAYSINLINE address Os::currentStackPtr() {
15+
16+
#if defined(__linux__)
17+
18+
+#ifndef __GLIBC__
19+
+typedef unsigned long int __cpu_mask;
20+
+#endif
21+
+
22+
inline void Os::ThreadAffinityMask::init() { CPU_ZERO(&mask_); }
23+
24+
inline void Os::ThreadAffinityMask::set(uint cpu) { CPU_SET(cpu, &mask_); }
Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
Fix musl errors:
2+
* reinterpret_cast from 'std::nullptr_t' to 'void **' is not allowed
3+
* error.h is GNU extension
4+
5+
Upstream PR: https://github.com/ROCm/hip-tests/pull/463
6+
--- a/unit/rtc/headers/printf_common.h
7+
+++ b/unit/rtc/headers/printf_common.h
8+
@@ -30,7 +30,6 @@ THE SOFTWARE.
9+
#if defined(_WIN32)
10+
#include <io.h>
11+
#else
12+
-#include <error.h>
13+
#include <unistd.h>
14+
#endif
15+
16+
@@ -110,7 +109,7 @@ struct CaptureStream {
17+
saved_fd = dup(orig_fd);
18+
19+
if ((temp_fd = mkstemp(tempname)) == -1) {
20+
- error(0, errno, "Error");
21+
+ fprintf(stderr, "Error: %s\n", strerror(errno));
22+
assert(false);
23+
}
24+
}
25+
@@ -118,11 +117,11 @@ struct CaptureStream {
26+
void Begin() {
27+
fflush(nullptr);
28+
if (dup2(temp_fd, orig_fd) == -1) {
29+
- error(0, errno, "Error");
30+
+ fprintf(stderr, "Error: %s\n", strerror(errno));
31+
assert(false);
32+
}
33+
if (close(temp_fd) != 0) {
34+
- error(0, errno, "Error");
35+
+ fprintf(stderr, "Error: %s\n", strerror(errno));
36+
assert(false);
37+
}
38+
}
39+
@@ -130,11 +129,11 @@ struct CaptureStream {
40+
void End() {
41+
fflush(nullptr);
42+
if (dup2(saved_fd, orig_fd) == -1) {
43+
- error(0, errno, "Error");
44+
+ fprintf(stderr, "Error: %s\n", strerror(errno));
45+
assert(false);
46+
}
47+
if (close(saved_fd) != 0) {
48+
- error(0, errno, "Error");
49+
+ fprintf(stderr, "Error: %s\n", strerror(errno));
50+
assert(false);
51+
}
52+
}
53+
@@ -148,7 +147,7 @@ struct CaptureStream {
54+
55+
~CaptureStream() {
56+
if (remove(tempname) != 0) {
57+
- error(0, errno, "Error");
58+
+ fprintf(stderr, "Error: %s\n", strerror(errno));
59+
assert(false);
60+
}
61+
}
62+
--- a/unit/memory/hipMemRangeGetAttributes_old.cc
63+
+++ b/unit/memory/hipMemRangeGetAttributes_old.cc
64+
@@ -268,7 +268,7 @@ TEST_CASE("Unit_hipMemRangeGetAttributes_NegativeTst") {
65+
// Passing NULL as first parameter
66+
SECTION("Passing NULL as first parameter") {
67+
if (!CheckError(hipMemRangeGetAttributes(
68+
- reinterpret_cast<void**>(NULL),
69+
+ static_cast<void**>(NULL),
70+
reinterpret_cast<size_t*>(dataSizes),
71+
AttrArr, 4, Hmm, MEM_SIZE),
72+
__LINE__)) {
73+
--- a/unit/occupancy/hipOccupancyMaxActiveBlocksPerMultiprocessor_old.cc
74+
+++ b/unit/occupancy/hipOccupancyMaxActiveBlocksPerMultiprocessor_old.cc
75+
@@ -40,7 +40,7 @@ TEST_CASE("Unit_hipOccupancyMaxActiveBlocksPerMultiprocessor_Negative") {
76+
ret = hipOccupancyMaxActiveBlocksPerMultiprocessor(NULL, f1, blockSize, 0);
77+
REQUIRE(ret != hipSuccess);
78+
79+
- ret = hipOccupancyMaxActiveBlocksPerMultiprocessor(&numBlock, NULL, blockSize, 0);
80+
+ ret = hipOccupancyMaxActiveBlocksPerMultiprocessor(&numBlock, static_cast<void*>(NULL), blockSize, 0);
81+
REQUIRE(ret != hipSuccess);
82+
83+
ret = hipOccupancyMaxActiveBlocksPerMultiprocessor(&numBlock, f1, 0, 0);
84+
--- a/unit/occupancy/hipOccupancyMaxPotentialBlockSize_old.cc
85+
+++ b/unit/occupancy/hipOccupancyMaxPotentialBlockSize_old.cc
86+
@@ -37,7 +37,7 @@ TEST_CASE("Unit_hipOccupancyMaxPotentialBlockSize_Negative") {
87+
88+
#ifndef __HIP_PLATFORM_NVIDIA__
89+
// nvcc doesnt support kernelfunc(NULL) for api
90+
- ret = hipOccupancyMaxPotentialBlockSize(&gridSize, &blockSize, NULL, 0, 0);
91+
+ ret = hipOccupancyMaxPotentialBlockSize(&gridSize, &blockSize, static_cast<void*>(NULL), 0, 0);
92+
REQUIRE(ret != hipSuccess);
93+
#endif
94+
}
95+
--- a/unit/occupancy/hipOccupancyMaxActiveBlocksPerMultiprocessor.cc
96+
+++ b/unit/occupancy/hipOccupancyMaxActiveBlocksPerMultiprocessor.cc
97+
@@ -48,7 +48,7 @@ TEST_CASE("Unit_hipOccupancyMaxActiveBlocksPerMultiprocessor_Negative_Parameters
98+
blockSize);
99+
100+
SECTION("Kernel function is NULL") {
101+
- HIP_CHECK_ERROR(hipOccupancyMaxActiveBlocksPerMultiprocessor(&numBlocks, NULL, blockSize, 0),
102+
+ HIP_CHECK_ERROR(hipOccupancyMaxActiveBlocksPerMultiprocessor(&numBlocks, static_cast<void*>(NULL), blockSize, 0),
103+
hipErrorInvalidDeviceFunction);
104+
}
105+
}
106+
--- a/unit/kernel/printf_common.h
107+
+++ b/unit/kernel/printf_common.h
108+
@@ -24,7 +24,6 @@ THE SOFTWARE.
109+
#define _STRESSTEST_PRINTF_COMMON_H_
110+
111+
#include <errno.h>
112+
-#include <error.h>
113+
#include <stdio.h>
114+
#include <stdlib.h>
115+
#include <unistd.h>
116+
@@ -47,17 +46,17 @@ struct CaptureStream {
117+
saved_fd = dup(orig_fd);
118+
119+
if ((temp_fd = mkstemp(tempname)) == -1) {
120+
- error(0, errno, "Error");
121+
+ fprintf(stderr, "Error: %s\n", strerror(errno));
122+
assert(false);
123+
}
124+
125+
fflush(nullptr);
126+
if (dup2(temp_fd, orig_fd) == -1) {
127+
- error(0, errno, "Error");
128+
+ fprintf(stderr, "Error: %s\n", strerror(errno));
129+
assert(false);
130+
}
131+
if (close(temp_fd) != 0) {
132+
- error(0, errno, "Error");
133+
+ fprintf(stderr, "Error: %s\n", strerror(errno));
134+
assert(false);
135+
}
136+
}
137+
@@ -67,11 +66,11 @@ struct CaptureStream {
138+
return;
139+
fflush(nullptr);
140+
if (dup2(saved_fd, orig_fd) == -1) {
141+
- error(0, errno, "Error");
142+
+ fprintf(stderr, "Error: %s\n", strerror(errno));
143+
assert(false);
144+
}
145+
if (close(saved_fd) != 0) {
146+
- error(0, errno, "Error");
147+
+ fprintf(stderr, "Error: %s\n", strerror(errno));
148+
assert(false);
149+
}
150+
saved_fd = -1;
151+
@@ -90,7 +89,7 @@ struct CaptureStream {
152+
~CaptureStream() {
153+
restoreStream();
154+
if (remove(tempname) != 0) {
155+
- error(0, errno, "Error");
156+
+ fprintf(stderr, "Error: %s\n", strerror(errno));
157+
assert(false);
158+
}
159+
}

dev-util/hip/hip-6.1.1.ebuild

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ PATCHES=(
4949
"${FILESDIR}/${PN}-5.7.1-no_asan_doc.patch"
5050
"${FILESDIR}/${PN}-6.1.0-install.patch"
5151
"${FILESDIR}/${PN}-6.1.0-extend-isa-compatibility-check.patch"
52+
"${FILESDIR}/${PN}-6.1.1-fix-musl.patch"
5253
)
5354

5455
hip_test_wrapper() {
@@ -79,6 +80,7 @@ src_prepare() {
7980
"${FILESDIR}"/hip-test-6.0.2-hipcc-system-install.patch
8081
"${FILESDIR}"/hip-test-5.7.1-remove-incompatible-flag.patch
8182
"${FILESDIR}"/hip-test-6.1.0-disable-hipKerArgOptimization.patch
83+
"${FILESDIR}"/hip-test-6.1.1-fix-musl.patch
8284
)
8385
hip_test_wrapper cmake_src_prepare
8486
}

0 commit comments

Comments
 (0)