summaryrefslogtreecommitdiff
path: root/dev-libs/rocm-opencl-runtime/files/rocm-opencl-runtime-2.8.0-change-opencl.patch
blob: cd6695e2d4f6ccb1d59ce3a1fab8dbf55766c587 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
diff --git a/runtime/CMakeLists.txt b/runtime/CMakeLists.txt
index 2c9dfd6..863b4bf 100644
--- a/runtime/CMakeLists.txt
+++ b/runtime/CMakeLists.txt
@@ -23,7 +23,6 @@ if (${USE_COMGR_LIBRARY} STREQUAL "no")
   include_directories(${CMAKE_SOURCE_DIR}/compiler/llvm/include)
 endif() # if (${USE_COMGR_LIBRARY} STREQUAL "no")
 
-include_directories(${CMAKE_SOURCE_DIR}/compiler/driver/src)
 include_directories(${CMAKE_SOURCE_DIR}/compiler/lib)
 include_directories(${CMAKE_SOURCE_DIR}/compiler/lib/include)
 include_directories(${CMAKE_SOURCE_DIR}/compiler/lib/backends/common)
@@ -79,6 +78,8 @@ add_library(oclruntime OBJECT
   ${COMGR_CPP}
 )
 set_target_properties(oclruntime PROPERTIES POSITION_INDEPENDENT_CODE ON)
+#add_dependencies(oclruntime opencl1.2-c.amdgcn.inc_target)
+#add_dependencies(oclruntime opencl2.0-c.amdgcn.inc_target)
 
 set(AMDGCN_DEP_LIST)
 if(AMDGCN_TARGETS_LIB_DEPS)
diff --git a/runtime/device/rocm/CMakeLists.txt b/runtime/device/rocm/CMakeLists.txt
index 5870b65..39166f3 100644
--- a/runtime/device/rocm/CMakeLists.txt
+++ b/runtime/device/rocm/CMakeLists.txt
@@ -1,3 +1,21 @@
+find_package(Clang REQUIRED CONFIG)
+
+# FIXME: CLANG_CMAKE_DIR seems like the most stable way to find this, but
+# really there is no way to reliably discover this header.
+#
+# We effectively back up to the Clang output directory (for the case of a build
+# tree) or install prefix (for the case of an installed copy), and then search
+# for a file named opencl-c.h anywhere below that. We take the first result in
+# the case where there are multiple (e.g. if there is an installed copy nested
+# in a build directory). This is a bit imprecise, but it covers cases like MSVC
+# adding some additional configuration-specific subdirectories to the build
+# tree but not to an installed copy.
+file(GLOB_RECURSE OPENCL_C_H_LIST "${CLANG_CMAKE_DIR}/../../../*/opencl-c.h")
+list(GET OPENCL_C_H_LIST 0 OPENCL_C_H)
+if (NOT EXISTS "${OPENCL_C_H}" OR IS_DIRECTORY "${OPENCL_C_H}")
+  message(FATAL_ERROR "Unable to locate opencl-c.h from the supplied Clang. The path '${CLANG_CMAKE_DIR}/../../../*' was searched.")
+endif()
+
 include(bc2h)
 
 set(INC_SUFFIX "amdgcn.inc")
@@ -82,8 +100,8 @@ if (${USE_COMGR_LIBRARY} STREQUAL "no")
 
   # generating opencl*.inc files
   add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/opencl1.2-c.amdgcn.pch
-    COMMAND clang -cc1 -x cl-header -triple amdgcn-amd-amdhsa -Werror -O3 -DNDEBUG -cl-std=CL1.2 -emit-pch -o ${CMAKE_CURRENT_BINARY_DIR}/opencl1.2-c.amdgcn.pch < ${CMAKE_SOURCE_DIR}/compiler/llvm/tools/clang/lib/Headers/opencl-c.h
-    DEPENDS clang ${CMAKE_SOURCE_DIR}/compiler/llvm/tools/clang/lib/Headers/opencl-c.h
+    COMMAND clang -cc1 -x cl-header -triple amdgcn-amd-amdhsa -Werror -O3 -DNDEBUG -cl-std=CL1.2 -emit-pch -o ${CMAKE_CURRENT_BINARY_DIR}/opencl1.2-c.amdgcn.pch < ${OPENCL_C_H}
+    DEPENDS clang ${OPENCL_C_H}
     COMMENT "Generating opencl1.2-c.amdgcn.pch"
   )
   add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/opencl1.2-c.amdgcn.inc
@@ -96,8 +114,8 @@ if (${USE_COMGR_LIBRARY} STREQUAL "no")
   add_dependencies(oclrocm opencl1.2-c.amdgcn.inc_target)
 
   add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/opencl2.0-c.amdgcn.pch
-    COMMAND clang -cc1 -x cl-header -triple amdgcn-amd-amdhsa -Werror -O3 -DNDEBUG -cl-std=CL2.0 -emit-pch -o ${CMAKE_CURRENT_BINARY_DIR}/opencl2.0-c.amdgcn.pch < ${CMAKE_SOURCE_DIR}/compiler/llvm/tools/clang/lib/Headers/opencl-c.h
-    DEPENDS clang ${CMAKE_SOURCE_DIR}/compiler/llvm/tools/clang/lib/Headers/opencl-c.h
+    COMMAND clang -cc1 -x cl-header -triple amdgcn-amd-amdhsa -Werror -O3 -DNDEBUG -cl-std=CL2.0 -emit-pch -o ${CMAKE_CURRENT_BINARY_DIR}/opencl2.0-c.amdgcn.pch < ${OPENCL_C_H}
+    DEPENDS clang ${OPENCL_C_H}
     COMMENT "Generating opencl2.0-c.amdgcn.pch"
   )
   add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/opencl2.0-c.amdgcn.inc