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