-
Notifications
You must be signed in to change notification settings - Fork 115
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix build issues for musl libc (#267) #268
base: amd-staging
Are you sure you want to change the base?
Conversation
This fixes few issues, which allow to build and pass kfdtest on musl-based systems: 1) result of ROCm@daad183#diff-681b7d40f71f20573413d5072e1c381fde6c02aed03a56307afcbe82cf3f5e5eR36-R37f - `extern int hsakmt_page_shift` is under `ifndef`, while it should not ``` /var/tmp/portage/dev-libs/roct-thunk-interface-6.3.0/work/ROCR-Runtime-rocm-6.3.0/libhsakmt/src/openclose.c: In function 'init_page_size': /var/tmp/portage/dev-libs/roct-thunk-interface-6.3.0/work/ROCR-Runtime-rocm-6.3.0/libhsakmt/src/openclose.c:117:9: error: 'hsakmt_page_size' undeclared (first use in this function); did you mean 'hsakmt_page_shift'? 117 | hsakmt_page_size = sysconf(_SC_PAGESIZE); | ^~~~~~~~~~~~~~~~ | hsakmt_page_shift ``` 2) warning of `PAGE_SIZE` macro redefinition (defined previously in `limits.h`) 3) no operator to compare 0 with std::nullptr_t (null is defined as nullptr_t, following https://eel.is/c++draft/support.types.nullptr) ``` In file included from /var/tmp/portage/dev-libs/roct-thunk-interface-6.3.0/work/ROCR-Runtime-rocm-6.3.0/libhsakmt/tests/kfdtest/src/KFDTestUtil.hpp:27, from /var/tmp/portage/dev-libs/roct-thunk-interface-6.3.0/work/ROCR-Runtime-rocm-6.3.0/libhsakmt/tests/kfdtest/src/BaseQueue.hpp:28, from /var/tmp/portage/dev-libs/roct-thunk-interface-6.3.0/work/ROCR-Runtime-rocm-6.3.0/libhsakmt/tests/kfdtest/src/SDMAQueue.hpp:27, from /var/tmp/portage/dev-libs/roct-thunk-interface-6.3.0/work/ROCR-Runtime-rocm-6.3.0/libhsakmt/tests/kfdtest/src/KFDTestUtilQueue.cpp:28: /var/tmp/portage/dev-libs/roct-thunk-interface-6.3.0/work/ROCR-Runtime-rocm-6.3.0/libhsakmt/tests/kfdtest/gtest-1.6.0/gtest/gtest.h: In instantiation of 'testing::AssertionResult testing::internal::CmpHelperNE(const char*, const char*, const T1&, const T2&) [with T1 = long unsigned int; T2 = std::nullptr_t]': /var/tmp/portage/dev-libs/roct-thunk-interface-6.3.0/work/ROCR-Runtime-rocm-6.3.0/libhsakmt/tests/kfdtest/src/KFDTestUtilQueue.cpp:60:29: required from here 19072 | GTEST_ASSERT_(pred_format(#v1, #v2, v1, v2),\ | ^ /var/tmp/portage/dev-libs/roct-thunk-interface-6.3.0/work/ROCR-Runtime-rocm-6.3.0/libhsakmt/tests/kfdtest/gtest-1.6.0/gtest/gtest.h:18573:28: error: invalid operands of types 'const long unsigned int' and 'std::nullptr_t' to binary 'operator!=' 18573 | GTEST_IMPL_CMP_HELPER_(NE, !=); | ^ /var/tmp/portage/dev-libs/roct-thunk-interface-6.3.0/work/ROCR-Runtime-rocm-6.3.0/libhsakmt/tests/kfdtest/gtest-1.6.0/gtest/gtest.h:18558:12: note: in definition of macro 'GTEST_IMPL_CMP_HELPER_' 18558 | if (val1 op val2) {\ | ^~ ``` Closes: ROCm#267 Signed-off-by: Sv. Lockal <[email protected]>
This commit applies a similar change, that was reverted in 1cee865, with major issues fixed. 1) reverted commit checked if `pthread_attr_setaffinity_np` symbol exists, but this check did not work (and effectively disabled better path), because this symbol requires `#define _GNU_SOURCE` (see https://man7.org/linux/man-pages/man3/pthread_attr_setaffinity_np.3.html) 2) non-reverted part implied that `pthread_rwlockattr_setkind` function replaces `pthread_rwlockattr_setkind_np`, which is incorrect. This function is non-portable, serves as a hint and has no alternatives. Signed-off-by: Sv. Lockal <[email protected]>
The macro NULL sometimes is defined as 0, sometimes as nullptr_t-typed value (following [support.types.nullptr]), so to compare with pointers without warnings nullptr should be used
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This portion should be covered by 09d789c , right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This block was intentional. If we have to pick one or the other, we want them to align. If PAGE_SIZE isn't defined, but PAGE_SHIFT=5000 , then setting just PAGE_SIZE=1<<12 won't really work.
!verify full |
!verify |
!verify |
This fixes few issues, which allow to build and pass kfdtest on musl-based systems:
Issues with libhsakmt:
extern int hsakmt_page_shift
is underifndef
, while it should not.warning of
PAGE_SIZE
macro redefinition (defined previously inlimits.h
)no operator to compare 0 with std::nullptr_t (NULL is defined as nullptr_t-typed value, following support.types.nullptr)
Issues with hsa-runtime:
Attempt to fix issues with missing symbols
pthread_attr_setaffinity_np
andpthread_rwlockattr_setkind
was done earlier, but suggested patch was reworked and partially reverted in 1cee865.reverted commit checked if
pthread_attr_setaffinity_np
symbol exists, but this check did not work (and effectively disabled better path), because this function requires#define _GNU_SOURCE
(see https://man7.org/linux/man-pages/man3/pthread_attr_setaffinity_np.3.html)non-reverted part implied that
pthread_rwlockattr_setkind
function replacespthread_rwlockattr_setkind_np
, which is incorrect. This function is non-portable,PTHREAD_RWLOCK_PREFER_WRITER_NP
serves as a hint and has no alternatives.Closes: #267