New patches to fix search for hip-lang See merge request cmake-team/cmake!12ci/unstable
commit
176ebc390f
@ -0,0 +1,38 @@
|
||||
From: Brad King <brad.king@kitware.com>
|
||||
Date: Wed, 31 May 2023 16:32:45 -0400
|
||||
Subject: Linux: Provide multiarch library directory regex earlier
|
||||
|
||||
Make `CMAKE_LIBRARY_ARCHITECTURE_REGEX` available while determining
|
||||
compilers before `Platform/Linux` is loaded.
|
||||
|
||||
Bug: https://gitlab.kitware.com/cmake/cmake/-/issues/24562
|
||||
Bug-Debian: https://bugs.debian.org/1031799
|
||||
Applied-Upstream: https://gitlab.kitware.com/cmake/cmake/-/commit/cc737ae8295156812e697a9d2f3f7b79bf7b72c8
|
||||
---
|
||||
Modules/Platform/Linux-Initialize.cmake | 2 ++
|
||||
Modules/Platform/Linux.cmake | 3 ---
|
||||
2 files changed, 2 insertions(+), 3 deletions(-)
|
||||
create mode 100644 Modules/Platform/Linux-Initialize.cmake
|
||||
|
||||
diff --git a/Modules/Platform/Linux-Initialize.cmake b/Modules/Platform/Linux-Initialize.cmake
|
||||
new file mode 100644
|
||||
index 0000000..6d9cbae
|
||||
--- /dev/null
|
||||
+++ b/Modules/Platform/Linux-Initialize.cmake
|
||||
@@ -0,0 +1,2 @@
|
||||
+# Match multiarch library directory names.
|
||||
+set(CMAKE_LIBRARY_ARCHITECTURE_REGEX "[a-z0-9_]+(-[a-z0-9_]+)?-linux-gnu[a-z0-9_]*")
|
||||
diff --git a/Modules/Platform/Linux.cmake b/Modules/Platform/Linux.cmake
|
||||
index 3dc3ca3..1f2d8e6 100644
|
||||
--- a/Modules/Platform/Linux.cmake
|
||||
+++ b/Modules/Platform/Linux.cmake
|
||||
@@ -80,9 +80,6 @@ else()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
-# Match multiarch library directory names.
|
||||
-set(CMAKE_LIBRARY_ARCHITECTURE_REGEX "[a-z0-9_]+(-[a-z0-9_]+)?-linux-gnu[a-z0-9_]*")
|
||||
-
|
||||
include(Platform/UnixPaths)
|
||||
|
||||
# Debian has lib32 and lib64 paths only for compatibility so they should not be
|
@ -0,0 +1,112 @@
|
||||
From: Brad King <brad.king@kitware.com>
|
||||
Date: Wed, 31 May 2023 16:41:49 -0400
|
||||
Subject: HIP: Fix search for hip-lang CMake package on multiarch distros
|
||||
|
||||
We need `CMAKE_LIBRARY_ARCHITECTURE` to find the package before HIP
|
||||
compiler ABI detection. However, if HIP is the first enabled language,
|
||||
the value is not known until `CMAKE_HIP_LIBRARY_ARCHITECTURE` is
|
||||
determined by the ABI detection step. Resolve this by detecting
|
||||
`CMAKE_HIP_LIBRARY_ARCHITECTURE` from the compiler id output.
|
||||
|
||||
Bug: https://gitlab.kitware.com/cmake/cmake/-/issues/24562
|
||||
Bug-Debian: https://bugs.debian.org/1031799
|
||||
Applied-Upstream: https://gitlab.kitware.com/cmake/cmake/-/commit/bae57dc28179022ba0b654368efc451e36db6396
|
||||
---
|
||||
Modules/CMakeDetermineHIPCompiler.cmake | 50 ++++++++++++++++++++++++++++-----
|
||||
Modules/CMakeHIPCompiler.cmake.in | 1 +
|
||||
Modules/CMakeHIPInformation.cmake | 2 +-
|
||||
3 files changed, 45 insertions(+), 8 deletions(-)
|
||||
|
||||
diff --git a/Modules/CMakeDetermineHIPCompiler.cmake b/Modules/CMakeDetermineHIPCompiler.cmake
|
||||
index 6294d04..5e54502 100644
|
||||
--- a/Modules/CMakeDetermineHIPCompiler.cmake
|
||||
+++ b/Modules/CMakeDetermineHIPCompiler.cmake
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
include(${CMAKE_ROOT}/Modules/CMakeDetermineCompiler.cmake)
|
||||
include(${CMAKE_ROOT}/Modules/CMakeParseImplicitLinkInfo.cmake)
|
||||
+include(${CMAKE_ROOT}/Modules/CMakeParseLibraryArchitecture.cmake)
|
||||
|
||||
if( NOT ( ("${CMAKE_GENERATOR}" MATCHES "Make") OR
|
||||
("${CMAKE_GENERATOR}" MATCHES "Ninja") ) )
|
||||
@@ -102,13 +103,48 @@ endif()
|
||||
if(NOT CMAKE_HIP_COMPILER_ROCM_ROOT)
|
||||
message(FATAL_ERROR "Failed to find ROCm root directory.")
|
||||
endif()
|
||||
-if(NOT EXISTS "${CMAKE_HIP_COMPILER_ROCM_ROOT}/lib/cmake/hip-lang/hip-lang-config.cmake")
|
||||
- message(FATAL_ERROR
|
||||
- "The ROCm root directory:\n"
|
||||
- " ${CMAKE_HIP_COMPILER_ROCM_ROOT}\n"
|
||||
- "does not contain the HIP runtime CMake package, expected at:\n"
|
||||
- " ${CMAKE_HIP_COMPILER_ROCM_ROOT}/lib/cmake/hip-lang/hip-lang-config.cmake\n"
|
||||
- )
|
||||
+
|
||||
+# Normally implicit link information is not detected until
|
||||
+cmake_parse_implicit_link_info("${CMAKE_HIP_COMPILER_PRODUCED_OUTPUT}"
|
||||
+ _CMAKE_HIP_COMPILER_ID_IMPLICIT_LIBS
|
||||
+ _CMAKE_HIP_COMPILER_ID_IMPLICIT_DIRS
|
||||
+ _CMAKE_HIP_COMPILER_ID_IMPLICIT_FWKS
|
||||
+ _CMAKE_HIP_COMPILER_ID_IMPLICIT_LOG
|
||||
+ "" LANGUAGE HIP)
|
||||
+message(CONFIGURE_LOG
|
||||
+ "Parsed HIP implicit link information from compiler id output:\n${_CMAKE_HIP_COMPILER_ID_IMPLICIT_LOG}\n\n")
|
||||
+cmake_parse_library_architecture(HIP "${_CMAKE_HIP_COMPILER_ID_IMPLICIT_DIRS}" "" CMAKE_HIP_LIBRARY_ARCHITECTURE)
|
||||
+if(CMAKE_HIP_LIBRARY_ARCHITECTURE)
|
||||
+ message(CONFIGURE_LOG
|
||||
+ "Parsed HIP library architecture from compiler id output: ${CMAKE_HIP_LIBRARY_ARCHITECTURE}\n")
|
||||
+endif()
|
||||
+unset(_CMAKE_HIP_COMPILER_ID_IMPLICIT_LIBS)
|
||||
+unset(_CMAKE_HIP_COMPILER_ID_IMPLICIT_DIRS)
|
||||
+unset(_CMAKE_HIP_COMPILER_ID_IMPLICIT_FWKS)
|
||||
+unset(_CMAKE_HIP_COMPILER_ID_IMPLICIT_LOG)
|
||||
+
|
||||
+if(NOT CMAKE_HIP_COMPILER_ROCM_LIB)
|
||||
+ set(_CMAKE_HIP_COMPILER_ROCM_LIB_DIRS "${CMAKE_HIP_COMPILER_ROCM_ROOT}/lib")
|
||||
+ if(CMAKE_HIP_LIBRARY_ARCHITECTURE)
|
||||
+ list(APPEND _CMAKE_HIP_COMPILER_ROCM_LIB_DIRS "${CMAKE_HIP_COMPILER_ROCM_ROOT}/lib/${CMAKE_HIP_LIBRARY_ARCHITECTURE}")
|
||||
+ endif()
|
||||
+ foreach(dir IN LISTS _CMAKE_HIP_COMPILER_ROCM_LIB_DIRS)
|
||||
+ if(EXISTS "${dir}/cmake/hip-lang/hip-lang-config.cmake")
|
||||
+ set(CMAKE_HIP_COMPILER_ROCM_LIB "${dir}")
|
||||
+ break()
|
||||
+ endif()
|
||||
+ endforeach()
|
||||
+ if(NOT CMAKE_HIP_COMPILER_ROCM_LIB)
|
||||
+ list(TRANSFORM _CMAKE_HIP_COMPILER_ROCM_LIB_DIRS APPEND "/cmake/hip-lang/hip-lang-config.cmake")
|
||||
+ string(REPLACE ";" "\n " _CMAKE_HIP_COMPILER_ROCM_LIB_DIRS "${_CMAKE_HIP_COMPILER_ROCM_LIB_DIRS}")
|
||||
+ message(FATAL_ERROR
|
||||
+ "The ROCm root directory:\n"
|
||||
+ " ${CMAKE_HIP_COMPILER_ROCM_ROOT}\n"
|
||||
+ "does not contain the HIP runtime CMake package, expected at one of:\n"
|
||||
+ " ${_CMAKE_HIP_COMPILER_ROCM_LIB_DIRS}\n"
|
||||
+ )
|
||||
+ endif()
|
||||
+ unset(_CMAKE_HIP_COMPILER_ROCM_LIB_DIRS)
|
||||
endif()
|
||||
|
||||
if (NOT _CMAKE_TOOLCHAIN_LOCATION)
|
||||
diff --git a/Modules/CMakeHIPCompiler.cmake.in b/Modules/CMakeHIPCompiler.cmake.in
|
||||
index ce4e2cf..c106e91 100644
|
||||
--- a/Modules/CMakeHIPCompiler.cmake.in
|
||||
+++ b/Modules/CMakeHIPCompiler.cmake.in
|
||||
@@ -18,6 +18,7 @@ set(CMAKE_HIP_SIMULATE_VERSION "@CMAKE_HIP_SIMULATE_VERSION@")
|
||||
@SET_MSVC_HIP_ARCHITECTURE_ID@
|
||||
@_SET_CMAKE_HIP_COMPILER_SYSROOT@
|
||||
set(CMAKE_HIP_COMPILER_ROCM_ROOT "@CMAKE_HIP_COMPILER_ROCM_ROOT@")
|
||||
+set(CMAKE_HIP_COMPILER_ROCM_LIB "@CMAKE_HIP_COMPILER_ROCM_LIB@")
|
||||
|
||||
set(CMAKE_HIP_COMPILER_ENV_VAR "HIPCXX")
|
||||
|
||||
diff --git a/Modules/CMakeHIPInformation.cmake b/Modules/CMakeHIPInformation.cmake
|
||||
index 33f8697..41a98db 100644
|
||||
--- a/Modules/CMakeHIPInformation.cmake
|
||||
+++ b/Modules/CMakeHIPInformation.cmake
|
||||
@@ -142,7 +142,7 @@ set(CMAKE_HIP_INFORMATION_LOADED 1)
|
||||
|
||||
# Load the file and find the relevant HIP runtime.
|
||||
if(NOT DEFINED _CMAKE_HIP_DEVICE_RUNTIME_TARGET)
|
||||
- set(hip-lang_DIR "${CMAKE_HIP_COMPILER_ROCM_ROOT}/lib/cmake/hip-lang")
|
||||
+ set(hip-lang_DIR "${CMAKE_HIP_COMPILER_ROCM_LIB}/cmake/hip-lang")
|
||||
find_package(hip-lang CONFIG QUIET NO_DEFAULT_PATH REQUIRED)
|
||||
endif()
|
||||
if(DEFINED _CMAKE_HIP_DEVICE_RUNTIME_TARGET)
|
@ -0,0 +1,43 @@
|
||||
From: Cordell Bloor <Cordell.Bloor@amd.com>
|
||||
Date: Wed, 22 Mar 2023 16:48:10 -0600
|
||||
Subject: HIP: Add support for HIP runtime in system paths
|
||||
|
||||
Add /usr/include to implicit include dirs for ABI check
|
||||
|
||||
The CMAKE_<LANG>_IMPLICIT_INCLUDE_DIRECTORIES are computed using
|
||||
try_compile in CMAKE_DETERMINE_COMPILER_ABI, but the implicit include
|
||||
directories aren't known until after try_compile is complete. This can
|
||||
be a problem when the HIP runtime include path is /usr/include, because
|
||||
the runtime include path is always added to the userDirs and the
|
||||
compiler automatically includes standard library headers via
|
||||
__clang_hip_runtime_wrapper.h
|
||||
|
||||
Bug: https://gitlab.kitware.com/cmake/cmake/-/issues/24562
|
||||
Bug-Debian: https://bugs.debian.org/1031799
|
||||
Forwarded: https://gitlab.kitware.com/cmake/cmake/-/merge_requests/8534
|
||||
---
|
||||
Source/cmLocalGenerator.cxx | 11 +++++++++++
|
||||
1 file changed, 11 insertions(+)
|
||||
|
||||
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
|
||||
index 75ec694..68ff7ea 100644
|
||||
--- a/Source/cmLocalGenerator.cxx
|
||||
+++ b/Source/cmLocalGenerator.cxx
|
||||
@@ -1190,6 +1190,17 @@ std::vector<BT<std::string>> cmLocalGenerator::GetIncludeDirectoriesImplicit(
|
||||
cmSystemTools::ConvertToUnixSlashes(impDirVec[i]);
|
||||
}
|
||||
}
|
||||
+
|
||||
+ // The CMAKE_<LANG>_IMPLICIT_INCLUDE_DIRECTORIES are computed using
|
||||
+ // try_compile in CMAKE_DETERMINE_COMPILER_ABI, but the implicit include
|
||||
+ // directories are not known during that try_compile. This can be a
|
||||
+ // problem when the HIP runtime include path is /usr/include because the
|
||||
+ // runtime include path is always added to the userDirs and the compiler
|
||||
+ // includes standard library headers via "__clang_hip_runtime_wrapper.h".
|
||||
+ if (lang == "HIP" && impDirVec.size() == impDirVecOldSize &&
|
||||
+ !cm::contains(impDirVec, "/usr/include")) {
|
||||
+ implicitExclude.emplace("/usr/include");
|
||||
+ }
|
||||
}
|
||||
|
||||
// The Platform/UnixPaths module used to hard-code /usr/include for C, CXX,
|
@ -1 +1,4 @@
|
||||
0001-Prefer-default-Python-version.patch
|
||||
0002-Provide-multiarch-library-directory-regex-earlier.patch
|
||||
0003-Fix-search-for-hip-lang-CMake-package.patch
|
||||
0004-Fix-hip-implicit-include-dirs.patch
|
||||
|
Loading…
Reference in new issue