gentoo/dev-util/hip/files/hip-6.4.1-no-glibcxx-assert.patch
Sv. Lockal dacbed530e
dev-util/hip: do not include stdlibc++ file in HIPRTC header
When any hip header included with -D__HIPCC_RTC__, it means that
compiler was launched with -E -P to produce a preprocessed header.
In this case not a single libstdc++ header can be used, otherwise it
causes function redefinition on next attempt to include the same header
elsewhere.

Closes: https://bugs.gentoo.org/966188
Signed-off-by: Sv. Lockal <lockalsash@gmail.com>
Part-of: https://github.com/gentoo/gentoo/pull/44725
Signed-off-by: Sam James <sam@gentoo.org>
2025-11-28 02:52:59 +00:00

27 lines
1.1 KiB
Diff

stdlibc++ of GCC-15 adds __glibcxx_assert in std::clamp, std::array, etc,
which breaks HIP code. However, `clang -x hip` autoloads few files,
one of them is <hip/hip_version.h> (the only one from dev-util/hip),
where we can undefine __glibcxx_assert until it is fixed in stdlibc++.
Upstream bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115740
Bug: https://bugs.gentoo.org/955623
--- a/hipamd/CMakeLists.txt
+++ b/hipamd/CMakeLists.txt
@@ -314,6 +314,16 @@ set(_versionInfoHeader
#define HIP_VERSION_BUILD_NAME \"${HIP_VERSION_BUILD_NAME}\"
#define HIP_VERSION (HIP_VERSION_MAJOR * 10000000 + HIP_VERSION_MINOR * 100000 + HIP_VERSION_PATCH)\n
#define __HIP_HAS_GET_PCH ${_pchStatus}\n
+
+// Workaround for https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115740
+#if defined(__has_include) && defined(__cplusplus) && defined(__HIP__) && !defined(__HIPCC_RTC__)
+ #if __has_include(\"bits/c++config.h\")
+ #include <bits/c++config.h>
+ #undef __glibcxx_assert
+ #define __glibcxx_assert(cond)
+ #endif
+#endif
+
#endif\n
")
file(WRITE "${PROJECT_BINARY_DIR}/include/hip/hip_version.h" ${_versionInfoHeader})