From 08d9759ebade199512a7d8dec319cfc098a556b1 Mon Sep 17 00:00:00 2001 From: "Yaxun (Sam) Liu" Date: Wed, 18 Mar 2020 01:50:21 -0400 Subject: [PATCH] Workaround for libc++ include path for HIP-Clang (#1917) HIP-Clang cuda_wrapper headers require clang include path before standard C++ include path. However libc++ include path requires to be before clang include path. To workaround this, we pass -isystem with the parent directory of clang include path instead of the clang include path itself. --- bin/hipcc | 2 +- include/hip/hcc_detail/hip_runtime.h | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/bin/hipcc b/bin/hipcc index 929fe1cd71..80d28a7b8e 100755 --- a/bin/hipcc +++ b/bin/hipcc @@ -207,7 +207,7 @@ if ($HIP_PLATFORM eq "clang") { } else { $HIPCXXFLAGS .= " -std=c++11"; } - $HIPCXXFLAGS .= " -isystem $HIP_CLANG_INCLUDE_PATH"; + $HIPCXXFLAGS .= " -isystem $HIP_CLANG_INCLUDE_PATH/.."; $HIPLDFLAGS .= " -L$HIP_LIB_PATH"; if (not $isWindows) { $HIPLDFLAGS .= " -Wl,--rpath-link=$HIP_LIB_PATH"; diff --git a/include/hip/hcc_detail/hip_runtime.h b/include/hip/hcc_detail/hip_runtime.h index 448331a868..0707cc6899 100644 --- a/include/hip/hcc_detail/hip_runtime.h +++ b/include/hip/hcc_detail/hip_runtime.h @@ -501,9 +501,14 @@ hc_get_workitem_absolute_id(int dim) #define __CUDA__ #include <__clang_cuda_math_forward_declares.h> #include <__clang_cuda_complex_builtins.h> -#include -#include -#include +// Workaround for using libc++ with HIP-Clang. +// The following headers requires clang include path before standard C++ include path. +// However libc++ include path requires to be before clang include path. +// To workaround this, we pass -isystem with the parent directory of clang include +// path instead of the clang include path itself. +#include +#include +#include #undef __CUDA__ #pragma pop_macro("__CUDA__") #endif // !_OPENMP || __HIP_ENABLE_CUDA_WRAPPER_FOR_OPENMP__