From f62017f4a5e78b38d9976666e41fb39dcf69c848 Mon Sep 17 00:00:00 2001 From: Sean Keely Date: Sat, 16 Nov 2019 00:18:52 -0600 Subject: [PATCH] Correct clang paths for incremental builds. We should be using bin/clang, not the build/lightining/bin/clang since build/ is the project's internal build directory. This patch corrects this where possible. However, lightning does not install all it's end user files under out/ so some headers can not be found anywhere in out/ in an incremental build. This header (opencl-c.h) if fetched out of the lightning source tree if necessary. Change-Id: I083d8b27bb39dd615fba3bb0711a789318f95e77 --- rocrtst/samples/CMakeLists.txt | 15 +++++++++++++-- rocrtst/suites/test_common/CMakeLists.txt | 13 ++++++++++++- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/rocrtst/samples/CMakeLists.txt b/rocrtst/samples/CMakeLists.txt index 7daf4819b1..73fcb355cc 100755 --- a/rocrtst/samples/CMakeLists.txt +++ b/rocrtst/samples/CMakeLists.txt @@ -89,8 +89,12 @@ endif() if (DEFINED LLVM_DIR) set(CLANG ${LLVM_DIR}/clang) if (NOT EXISTS ${CLANG}) + # SPK temp until Jenkins script input is corrected. + set (CLANG ${OPENCL_DIR}/bin/clang) + if (NOT EXISTS ${CLANG}) message("ERROR: path to clang (${CLANG}) is not valid. Is define LLVM_DIR correct?") return() + endif() endif() else() message("WARNING: LLVM_DIR define is not set. Kernels will not be built.") @@ -110,6 +114,13 @@ else() set(OPENCL_VER "2.0") endif() +if(NOT EXISTS "${OPENCL_INC_DIR}/opencl-c.h") + set(OPENCL_INC_DIR "${OPENCL_DIR}/../../../external/llvm-clang/lib/Headers/") + if(NOT EXISTS "${OPENCL_INC_DIR}/opencl-c.h") + message(WARNING "opencl-c.h not found.") + endif() +endif() + if (NOT DEFINED TARGET_DEVICES) message("WARNING: No targets devices provided on command line") message(" e.g., cmake -DTARGET_DEVICES=\"gfx803;gfx900;gfx...\" ..") @@ -223,7 +234,7 @@ link_directories(${ROCR_LIB_DIR}) # set(ROCR_LIBS ${ROCR_LIBS} hsa-runtime${ONLY64STR}) -include_directories(${ROCR_INC_DIR} ${OPENCL_INC_DIR}) +include_directories(${ROCR_INC_DIR} "${OPENCL_DIR}/include") # Use this function to build any samples that have kernels to be built function(process_sample S_NAME TARG_DEV HAS_KERNEL) @@ -237,7 +248,7 @@ function(process_sample S_NAME TARG_DEV HAS_KERNEL) if (${HAS_KERNEL}) # Build the kernel separate_arguments(CLANG_ARG_LIST UNIX_COMMAND - "-x cl -Xclang -finclude-default-header -target amdgcn-amdh-amdhsa -mcpu=${TARG_DEV} -mno-code-object-v3 ${BITCODE_LIBS} -cl-std=CL${OPENCL_VER} ${CL_FILE_LIST} -o ${KERNEL_DIR}/${SNAME_KERNEL}") + "-x cl -target amdgcn-amd-amdhsa -include ${OPENCL_INC_DIR}opencl-c.h -mcpu=${TARG_DEV} -mno-code-object-v3 ${BITCODE_LIBS} -cl-std=CL${OPENCL_VER} ${CL_FILE_LIST} -o ${KERNEL_DIR}/${SNAME_KERNEL}") add_custom_target("${TARG_NAME}" ${CLANG} ${CLANG_ARG_LIST} COMMAND ${CMAKE_COMMAND} -E create_symlink "../${SNAME_EXE}" "${KERNEL_DIR}/${SNAME_EXE}" diff --git a/rocrtst/suites/test_common/CMakeLists.txt b/rocrtst/suites/test_common/CMakeLists.txt index 2060e33bc4..7b4357ae89 100755 --- a/rocrtst/suites/test_common/CMakeLists.txt +++ b/rocrtst/suites/test_common/CMakeLists.txt @@ -89,8 +89,12 @@ endif() if (DEFINED LLVM_DIR) set(CLANG ${LLVM_DIR}/clang) if (NOT EXISTS ${CLANG}) + # SPK temp until Jenkins script input is corrected. + set (CLANG ${OPENCL_DIR}/bin/clang) + if (NOT EXISTS ${CLANG}) message("ERROR: path to clang (${CLANG}) is not valid. Is define LLVM_DIR correct?") return() + endif() endif() else() message("WARNING: LLVM_DIR define is not set. Kernels will not be built.") @@ -110,6 +114,13 @@ else() set(OPENCL_VER "2.0") endif() +if(NOT EXISTS "${OPENCL_INC_DIR}/opencl-c.h") + set(OPENCL_INC_DIR "${OPENCL_DIR}/../../../external/llvm-clang/lib/Headers/") + if(NOT EXISTS "${OPENCL_INC_DIR}/opencl-c.h") + message(WARNING "opencl-c.h not found.") + endif() +endif() + if (NOT DEFINED TARGET_DEVICES) message("No targets devices provided on command line") message(" e.g., cmake -DTARGET_DEVICES=\"gfx803;gfx900;gfx...\" ..") @@ -266,7 +277,7 @@ function(build_kernel S_NAME TARG_DEV) set(HSACO_TARG_LIST ${HSACO_TARG_LIST} ${TARG_NAME} CACHE INTERNAL HSA_TARG_LIST) separate_arguments(CLANG_ARG_LIST UNIX_COMMAND - "-x cl -Xclang -finclude-default-header -target amdgcn-amdh-amdhsa -mcpu=${TARG_DEV} -mno-code-object-v3 ${BITCODE_LIBS} -cl-std=CL${OPENCL_VER} ${CL_FILE_LIST} -o ${KERNEL_DIR}/${SNAME_KERNEL}") + "-x cl -target amdgcn-amd-amdhsa -include ${OPENCL_INC_DIR}opencl-c.h -mcpu=${TARG_DEV} -mno-code-object-v3 ${BITCODE_LIBS} -cl-std=CL${OPENCL_VER} ${CL_FILE_LIST} -o ${KERNEL_DIR}/${SNAME_KERNEL}") add_custom_target("${TARG_NAME}" ${CLANG} ${CLANG_ARG_LIST} COMMAND ${CMAKE_COMMAND} -E create_symlink "../${ROCRTST}" "${KERNEL_DIR}/${ROCRTST}"