hip: fix hip cmake config
Update paths in cmake config files provided by HIP and hipamd to the proper location in the Nix store. Previously these files were trying to find headers in a way that assumes the typical ROCm installation (where everything is in /opt/rocm). This resulted in a bunch of errors when trying to compile HIP projects that are configured with cmake, like include paths that were set incorrectly or header paths that were not found.
This commit is contained in:
parent
6c1c144e40
commit
e3d748a92b
@ -21,6 +21,7 @@
|
||||
, rocm-runtime
|
||||
, rocm-thunk
|
||||
, rocminfo
|
||||
, substituteAll
|
||||
, writeScript
|
||||
, writeText
|
||||
}:
|
||||
@ -37,6 +38,14 @@ let
|
||||
hash = "sha256-QaN666Rku2Tkio2Gm5/3RD8D5JgmCZLe0Yun1fGxa8U=";
|
||||
};
|
||||
|
||||
patches = [
|
||||
(substituteAll {
|
||||
src = ./hip-config-paths.patch;
|
||||
inherit llvm;
|
||||
rocm_runtime = rocm-runtime;
|
||||
})
|
||||
];
|
||||
|
||||
# - fix bash paths
|
||||
# - fix path to rocm_agent_enumerator
|
||||
# - fix hcc path
|
||||
@ -121,6 +130,14 @@ stdenv.mkDerivation rec {
|
||||
rocminfo
|
||||
];
|
||||
|
||||
patches = [
|
||||
(substituteAll {
|
||||
src = ./hipamd-config-paths.patch;
|
||||
inherit llvm hip;
|
||||
rocm_runtime = rocm-runtime;
|
||||
})
|
||||
];
|
||||
|
||||
preConfigure = ''
|
||||
export HIP_CLANG_PATH=${clang}/bin
|
||||
export DEVICE_LIB_PATH=${rocm-device-libs}/lib
|
||||
|
36
pkgs/development/compilers/hip/hip-config-paths.patch
Normal file
36
pkgs/development/compilers/hip/hip-config-paths.patch
Normal file
@ -0,0 +1,36 @@
|
||||
diff --git a/hip-lang-config.cmake.in b/hip-lang-config.cmake.in
|
||||
index 1a72643a..7f35031f 100644
|
||||
--- a/hip-lang-config.cmake.in
|
||||
+++ b/hip-lang-config.cmake.in
|
||||
@@ -72,8 +72,8 @@ get_filename_component(_IMPORT_PREFIX "${_DIR}/../../../" REALPATH)
|
||||
|
||||
|
||||
#need _IMPORT_PREFIX to be set #FILE_REORG_BACKWARD_COMPATIBILITY
|
||||
-file(GLOB HIP_CLANG_INCLUDE_SEARCH_PATHS "${_IMPORT_PREFIX}/../llvm/lib/clang/*/include")
|
||||
-file(GLOB HIP_CLANG_INCLUDE_SEARCH_PATHS_REORG "${_IMPORT_PREFIX}/llvm/lib/clang/*/include")
|
||||
+file(GLOB HIP_CLANG_INCLUDE_SEARCH_PATHS "@llvm@/lib/clang/*/include")
|
||||
+file(GLOB HIP_CLANG_INCLUDE_SEARCH_PATHS_REORG "@llvm@/lib/clang/*/include")
|
||||
find_path(HIP_CLANG_INCLUDE_PATH __clang_cuda_math.h
|
||||
HINTS ${HIP_CLANG_INCLUDE_SEARCH_PATHS}
|
||||
${HIP_CLANG_INCLUDE_SEARCH_PATHS_REORG}
|
||||
@@ -88,10 +88,7 @@ endif()
|
||||
#if HSA is not under ROCm then provide CMAKE_PREFIX_PATH=<HSA_PATH>
|
||||
find_path(HSA_HEADER hsa/hsa.h
|
||||
PATHS
|
||||
- "${_IMPORT_PREFIX}/../include" #FILE_REORG_BACKWARD_COMPATIBILITY
|
||||
- "${_IMPORT_PREFIX}/include"
|
||||
- "${ROCM_PATH}/include"
|
||||
- /opt/rocm/include
|
||||
+ "@rocm_runtime@/include"
|
||||
)
|
||||
|
||||
if (HSA_HEADER-NOTFOUND)
|
||||
@@ -99,7 +96,7 @@ if (HSA_HEADER-NOTFOUND)
|
||||
endif()
|
||||
|
||||
get_filename_component(HIP_COMPILER_INSTALL_PATH ${CMAKE_HIP_COMPILER} DIRECTORY)
|
||||
-file(GLOB HIP_CLANGRT_LIB_SEARCH_PATHS "${HIP_COMPILER_INSTALL_PATH}/../lib/clang/*/lib/*")
|
||||
+file(GLOB HIP_CLANGRT_LIB_SEARCH_PATHS "@llvm@/lib/clang/*/lib/*")
|
||||
find_library(CLANGRT_BUILTINS
|
||||
NAMES
|
||||
clang_rt.builtins
|
47
pkgs/development/compilers/hip/hipamd-config-paths.patch
Normal file
47
pkgs/development/compilers/hip/hipamd-config-paths.patch
Normal file
@ -0,0 +1,47 @@
|
||||
diff --git a/hip-config.cmake.in b/hip-config.cmake.in
|
||||
index 89d1224e..120b68c6 100755
|
||||
--- a/hip-config.cmake.in
|
||||
+++ b/hip-config.cmake.in
|
||||
@@ -142,7 +142,7 @@ if(HIP_COMPILER STREQUAL "clang")
|
||||
file(TO_CMAKE_PATH "${HIP_PATH}/../lc" HIP_CLANG_ROOT)
|
||||
endif()
|
||||
else()
|
||||
- set(HIP_CLANG_ROOT "${ROCM_PATH}/llvm")
|
||||
+ set(HIP_CLANG_ROOT "@llvm@")
|
||||
endif()
|
||||
if(NOT HIP_CXX_COMPILER)
|
||||
set(HIP_CXX_COMPILER ${CMAKE_CXX_COMPILER})
|
||||
@@ -206,10 +206,7 @@ if(NOT WIN32)
|
||||
#if HSA is not under ROCm then provide CMAKE_PREFIX_PATH=<HSA_PATH>
|
||||
find_path(HSA_HEADER hsa/hsa.h
|
||||
PATHS
|
||||
- "${_IMPORT_PREFIX}/include"
|
||||
- #FILE_REORG_BACKWARD_COMPATIBILITY ${_IMPORT_PREFIX}/../include is for Backward compatibility
|
||||
- "${_IMPORT_PREFIX}/../include"
|
||||
- ${ROCM_PATH}/include
|
||||
+ "@rocm_runtime@/include"
|
||||
)
|
||||
|
||||
if (NOT HSA_HEADER)
|
||||
@@ -224,8 +221,8 @@ set_target_properties(hip::host PROPERTIES
|
||||
|
||||
if(HIP_RUNTIME MATCHES "rocclr")
|
||||
set_target_properties(hip::amdhip64 PROPERTIES
|
||||
- INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include;${HSA_HEADER}"
|
||||
- INTERFACE_SYSTEM_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include;${HSA_HEADER}"
|
||||
+ INTERFACE_INCLUDE_DIRECTORIES "@hip@/include;${HSA_HEADER}"
|
||||
+ INTERFACE_SYSTEM_INCLUDE_DIRECTORIES "@hip@/include;${HSA_HEADER}"
|
||||
)
|
||||
|
||||
get_target_property(amdhip64_type hip::amdhip64 TYPE)
|
||||
@@ -233,8 +230,8 @@ if(HIP_RUNTIME MATCHES "rocclr")
|
||||
|
||||
if(NOT WIN32)
|
||||
set_target_properties(hip::device PROPERTIES
|
||||
- INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include"
|
||||
- INTERFACE_SYSTEM_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include"
|
||||
+ INTERFACE_INCLUDE_DIRECTORIES "@hip@/include"
|
||||
+ INTERFACE_SYSTEM_INCLUDE_DIRECTORIES "@hip@/include"
|
||||
)
|
||||
endif()
|
||||
endif()
|
Loading…
Reference in New Issue
Block a user