
When gcc builds libtorch_cpu.so and hipcc (clang-18) build libtorch_hip.so,
resulting binary fails in runtime due to different mangling.
Related issue in LLVM: https://github.com/llvm/llvm-project/issues/85656
Fixed in pytorch-2.4.0 in https://github.com/pytorch/pytorch/commit/a89f442f0b103fa6f38103784a2dfedbd147f863
--- a/cmake/Dependencies.cmake
+++ b/cmake/Dependencies.cmake
@@ -1314,6 +1314,9 @@ if(USE_ROCM)
        list(APPEND HIP_HIPCC_FLAGS -fdebug-info-for-profiling)
     endif(CMAKE_BUILD_TYPE MATCHES Debug)
 
+    # needed for compat with newer versions of hip-clang that introduced C++20 mangling rules
+    list(APPEND HIP_HIPCC_FLAGS -fclang-abi-compat=17)
+
     set(HIP_CLANG_FLAGS ${HIP_CXX_FLAGS})
     # Ask hcc to generate device code during compilation so we can use
     # host linker to link.
