[amdgpu-arch] Guard hsa.h with __has_include
authorPushpinder Singh <Pushpinder.Singh@amd.com>
Fri, 7 May 2021 11:56:46 +0000 (11:56 +0000)
committerPushpinder Singh <Pushpinder.Singh@amd.com>
Mon, 10 May 2021 07:33:30 +0000 (07:33 +0000)
This patch is suppose to fix the issue of hsa.h not found.
Issue was reported in D99949

Reviewed By: JonChesterfield

Differential Revision: https://reviews.llvm.org/D102067

clang/tools/amdgpu-arch/AMDGPUArch.cpp

index 29f9c8b..4fae78b 100644 (file)
 //
 //===----------------------------------------------------------------------===//
 
-#include <hsa.h>
+#if defined(__has_include)
+#if __has_include("hsa.h")
+#define HSA_HEADER_FOUND 1
+#include "hsa.h"
+#elif __has_include("hsa/hsa.h")
+#define HSA_HEADER_FOUND 1
+#include "hsa/hsa.h"
+#else
+#define HSA_HEADER_FOUND 0
+#endif
+#else
+#define HSA_HEADER_FOUND 0
+#endif
+
+#if !HSA_HEADER_FOUND
+int main() { return 1; }
+#else
+
 #include <string>
 #include <vector>
 
@@ -57,3 +74,5 @@ int main() {
   hsa_shut_down();
   return 0;
 }
+
+#endif