From 2e9a9f7c7ae0b316e253a3cceaa396c93d1cbf99 Mon Sep 17 00:00:00 2001 From: Sean Keely Date: Mon, 20 Sep 2021 19:19:34 -0500 Subject: [PATCH] Correct Clang version detection and support for multiple prefix paths. Bumps cmake minimum version to 3.7 for version comparison operator. Previously the Clang cmake project version strings were used. These are not defined if the clang cmake project has not been loaded. We should use CMAKE_CXX_COMPILER_VERSION to check the version when only the compiler binary is redirected and the project files are not available. Also adjust device libs lookup logic to handle multiple paths in CMAKE_PREFIX_PATH. Change-Id: I67b6958d8241685cd6c3a0af68507c9fdc6331ef --- runtime/hsa-runtime/CMakeLists.txt | 4 ++-- runtime/hsa-runtime/README.md | 3 +-- runtime/hsa-runtime/image/blit_src/CMakeLists.txt | 15 ++++++++++----- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/runtime/hsa-runtime/CMakeLists.txt b/runtime/hsa-runtime/CMakeLists.txt index a8b5fe54fb..efc441841c 100644 --- a/runtime/hsa-runtime/CMakeLists.txt +++ b/runtime/hsa-runtime/CMakeLists.txt @@ -40,7 +40,7 @@ ## ################################################################################ -cmake_minimum_required ( VERSION 3.6.3 ) +cmake_minimum_required ( VERSION 3.7 ) ## Clear target dependency data. ## Needed to allow UI transitions between static and dynamic builds. @@ -136,7 +136,7 @@ if ( CMAKE_COMPILER_IS_GNUCXX ) endif () if ( CMAKE_CXX_COMPILER_ID MATCHES "Clang") set ( HSA_CXX_FLAGS ${HSA_CXX_FLAGS} -Wno-error=self-assign) - if( CLANG_VERSION_MAJOR -ge 13) + if( ${CMAKE_CXX_COMPILER_VERSION} VERSION_GREATER_EQUAL 13) set ( HSA_CXX_FLAGS ${HSA_CXX_FLAGS} -Wno-error=unused-but-set-variable) endif() endif() diff --git a/runtime/hsa-runtime/README.md b/runtime/hsa-runtime/README.md index 88a57073c6..2b29eea755 100644 --- a/runtime/hsa-runtime/README.md +++ b/runtime/hsa-runtime/README.md @@ -20,7 +20,7 @@ utils - Utilities required to build the core runtime. #### Build Environment CMake build framework is used to build the ROC runtime. The minimum version is -3.6.3. +3.7. Obtain cmake infrastructure: http://www.cmake.org/download/ @@ -32,7 +32,6 @@ The following support packages are required to successfully build the runtime: * libelf-dev * g++ -* libc6-dev-i386 (for libhsakmt 32bit) #### Building the Runtime diff --git a/runtime/hsa-runtime/image/blit_src/CMakeLists.txt b/runtime/hsa-runtime/image/blit_src/CMakeLists.txt index 3a639662f3..068995282a 100644 --- a/runtime/hsa-runtime/image/blit_src/CMakeLists.txt +++ b/runtime/hsa-runtime/image/blit_src/CMakeLists.txt @@ -40,7 +40,7 @@ ## ################################################################################ -cmake_minimum_required ( VERSION 3.5.0 ) +cmake_minimum_required ( VERSION 3.7 ) # Flag to abort before executing after default initialization of cache variables set (QUIT 0) @@ -49,15 +49,20 @@ set (QUIT 0) find_package(Clang REQUIRED HINTS ${CMAKE_INSTALL_PREFIX}/llvm ${CMAKE_PREFIX_PATH}/llvm PATHS /opt/rocm/llvm ) # Device libs doesn't support find_package yet. -# FIXME: HINTS should not use CMAKE_INSTALL_PREFIX +set(PREFIX_HINTS "") +foreach(hint "/amdgcn/bitcode" "/lib/bitcode" "/lib/x86_64/bitcode") + foreach(path ${CMAKE_PREFIX_PATH}) + string(APPEND path ${hint}) + list(APPEND PREFIX_HINTS ${path}) + endforeach(path) +endforeach(hint) + get_include_path(BITCODE_DIR "Bitcode library path" RESULT FOUND NAMES "opencl.bc" "opencl.amdgcn.bc" HINTS "${CMAKE_INSTALL_PREFIX}/amdgcn/bitcode" "${CMAKE_INSTALL_PREFIX}/lib/bitcode" "${CMAKE_INSTALL_PREFIX}/lib/x86_64/bitcode" - "${CMAKE_PREFIX_PATH}/amdgcn/bitcode" - "${CMAKE_PREFIX_PATH}/lib/bitcode" - "${CMAKE_PREFIX_PATH}/lib/x86_64/bitcode" + "${PREFIX_HINTS}" PATHS "/opt/rocm/amdgcn/bitcode" "/opt/rocm/lib/bitcode"