sys-devel/clang-common-18.1.8 with USE=hardened adds the following line to /etc/clang/gentoo-hardened.cfg: -D_GLIBCXX_ASSERTIONS To reproduce: cat test.cpp --------------------------------------------- #include <array> #include <hip/hip_runtime.h> __global__ void test() { std::array<int, 10> x{}; x[20] = 0; } int main() { test<<<dim3(512), dim3(256), 0, 0>>>(); std::array<int, 10> x{}; x[20] = 0; } --------------------------------------------- hipcc test.cpp -o test && ./test --------------------------------------------- Expected result: compiles, fails in runtime on host (as GPU has no such thing as glibc assertions). Actual result: build fails with: /usr/lib/gcc/x86_64-pc-linux-gnu/14/include/g++-v14/array:208:2: error: reference to __host__ function '__glibcxx_assert_fail' in __host__ __device__ function note: called by 'test' 7 | x[20] = 0; --------------------------------------------- Solution: should set `-Xarch_host -D_GLIBCXX_ASSERTIONS` in /etc/clang/gentoo-hardened.cfg
Affected line: https://gitweb.gentoo.org/repo/gentoo.git/tree/sys-devel/clang-common/clang-common-18.1.8.ebuild#n252 Note that next line `-D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_EXTENSIVE` is kind of not affected, because hipcc fails with libc++ (probably was never tested).
I suppose we should -Xarch_host both of them to be safe. Thanks for the report.
Sounds good, I'll create PR tomorrow
The bug has been closed via the following commit(s): https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=de01d97d992ee06fa23ed0938cfd32cc0ea34493 commit de01d97d992ee06fa23ed0938cfd32cc0ea34493 Author: Sv. Lockal <lockalsash@gmail.com> AuthorDate: 2024-07-04 03:44:33 +0000 Commit: Sam James <sam@gentoo.org> CommitDate: 2024-07-04 19:07:10 +0000 sys-devel/clang-common: add -Xarch_host for hardening flags to fix HIP compilation Fixes USE=hardened errors like: `error: reference to __host__ function '__glibcxx_assert_fail' in __host__ __device__ function` Closes: https://bugs.gentoo.org/935314 Signed-off-by: Sv. Lockal <lockalsash@gmail.com> Closes: https://github.com/gentoo/gentoo/pull/37420 Signed-off-by: Sam James <sam@gentoo.org> .../clang-common/clang-common-17.0.6-r6.ebuild | 303 +++++++++++++++++++++ ...18.1.8.ebuild => clang-common-18.1.8-r1.ebuild} | 4 +- .../clang-common/clang-common-19.0.0.9999.ebuild | 4 +- .../clang-common-19.0.0_pre20240630.ebuild | 4 +- 4 files changed, 309 insertions(+), 6 deletions(-)