From dee4fee1c7beeeaea4a27a3c88bf5cf0eed761ff Mon Sep 17 00:00:00 2001 From: Sebastian Neubauer Date: Wed, 5 Oct 2022 10:36:21 +0000 Subject: [PATCH] =?UTF-8?q?rocm-smi:=205.2.3=20=E2=86=92=205.3.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkgs/tools/system/rocm-smi/cmake.patch | 89 ++++++++++++++++++++++++++ pkgs/tools/system/rocm-smi/default.nix | 27 ++------ 2 files changed, 93 insertions(+), 23 deletions(-) create mode 100644 pkgs/tools/system/rocm-smi/cmake.patch diff --git a/pkgs/tools/system/rocm-smi/cmake.patch b/pkgs/tools/system/rocm-smi/cmake.patch new file mode 100644 index 000000000000..2634ea46a1f8 --- /dev/null +++ b/pkgs/tools/system/rocm-smi/cmake.patch @@ -0,0 +1,89 @@ +diff --git a/rocm_smi-backward-compat.cmake b/rocm_smi-backward-compat.cmake +index aa8fd9c..59afce5 100644 +--- a/rocm_smi-backward-compat.cmake ++++ b/rocm_smi-backward-compat.cmake +@@ -72,7 +72,12 @@ function(generate_wrapper_header) + set(include_guard "${include_guard}COMGR_WRAPPER_INCLUDE_${INC_GAURD_NAME}_H") + #set #include statement + get_filename_component(file_name ${header_file} NAME) +- set(include_statements "${include_statements}#include \"../../../${CMAKE_INSTALL_INCLUDEDIR}/${ROCM_SMI}/${file_name}\"\n") ++ if(IS_ABSOLUTE ${CMAKE_INSTALL_INCLUDEDIR}) ++ set(include_dir "${CMAKE_INSTALL_INCLUDEDIR}") ++ else() ++ set(include_dir "../../../${CMAKE_INSTALL_INCLUDEDIR}") ++ endif() ++ set(include_statements "${include_statements}#include \"${include_dir}/${ROCM_SMI}/${file_name}\"\n") + configure_file(${RSMI_WRAPPER_DIR}/header.hpp.in ${RSMI_WRAPPER_INC_DIR}/${file_name}) + unset(include_guard) + unset(include_statements) +@@ -90,7 +95,12 @@ function(generate_wrapper_header) + set(include_guard "${include_guard}COMGR_WRAPPER_INCLUDE_${INC_GAURD_NAME}_H") + #set #include statement + get_filename_component(file_name ${header_file} NAME) +- set(include_statements "${include_statements}#include \"../../../${CMAKE_INSTALL_INCLUDEDIR}/${OAM_TARGET_NAME}/${file_name}\"\n") ++ if(IS_ABSOLUTE ${CMAKE_INSTALL_INCLUDEDIR}) ++ set(include_dir "${CMAKE_INSTALL_INCLUDEDIR}") ++ else() ++ set(include_dir "../../../${CMAKE_INSTALL_INCLUDEDIR}") ++ endif() ++ set(include_statements "${include_statements}#include \"${include_dir}/${OAM_TARGET_NAME}/${file_name}\"\n") + configure_file(${RSMI_WRAPPER_DIR}/header.hpp.in ${OAM_WRAPPER_INC_DIR}/${file_name}) + unset(include_guard) + unset(include_statements) +@@ -123,11 +133,16 @@ function(create_library_symlink) + set(library_files "${LIB_RSMI}") + endif() + ++ if(IS_ABSOLUTE ${CMAKE_INSTALL_LIBDIR}) ++ set(install_libdir "${CMAKE_INSTALL_LIBDIR}") ++ else() ++ set(install_libdir "../../${CMAKE_INSTALL_LIBDIR}") ++ endif() + foreach(file_name ${library_files}) + add_custom_target(link_${file_name} ALL + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMAND ${CMAKE_COMMAND} -E create_symlink +- ../../${CMAKE_INSTALL_LIBDIR}/${file_name} ${RSMI_WRAPPER_LIB_DIR}/${file_name}) ++ ${install_libdir}/${file_name} ${RSMI_WRAPPER_LIB_DIR}/${file_name}) + endforeach() + + file(MAKE_DIRECTORY ${OAM_WRAPPER_LIB_DIR}) +@@ -151,11 +166,16 @@ function(create_library_symlink) + set(library_files "${LIB_OAM}") + endif() + ++ if(IS_ABSOLUTE ${CMAKE_INSTALL_LIBDIR}) ++ set(install_libdir "${CMAKE_INSTALL_LIBDIR}") ++ else() ++ set(install_libdir "../../${CMAKE_INSTALL_LIBDIR}") ++ endif() + foreach(file_name ${library_files}) + add_custom_target(link_${file_name} ALL + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMAND ${CMAKE_COMMAND} -E create_symlink +- ../../${CMAKE_INSTALL_LIBDIR}/${file_name} ${OAM_WRAPPER_LIB_DIR}/${file_name}) ++ ${install_libdir}/${file_name} ${OAM_WRAPPER_LIB_DIR}/${file_name}) + endforeach() + + endfunction() +diff --git a/rocm_smi/CMakeLists.txt b/rocm_smi/CMakeLists.txt +index c594eeb..d3ed39d 100755 +--- a/rocm_smi/CMakeLists.txt ++++ b/rocm_smi/CMakeLists.txt +@@ -105,10 +105,15 @@ endif () + #file reorganization changes + #rocm_smi.py moved to libexec/rocm_smi. so creating rocm-smi symlink + file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin) ++if(IS_ABSOLUTE ${CMAKE_INSTALL_LIBEXECDIR}) ++ set(install_libexecdir "${CMAKE_INSTALL_LIBEXECDIR}") ++else() ++ set(install_libexecdir "../${CMAKE_INSTALL_LIBEXECDIR}") ++endif() + add_custom_target(link-rocm-smi ALL + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMAND ${CMAKE_COMMAND} -E create_symlink +- ../${CMAKE_INSTALL_LIBEXECDIR}/${ROCM_SMI}/rocm_smi.py ${CMAKE_CURRENT_BINARY_DIR}/bin/rocm-smi) ++ ${install_libexecdir}/${ROCM_SMI}/rocm_smi.py ${CMAKE_CURRENT_BINARY_DIR}/bin/rocm-smi) + + ## Add the install directives for the runtime library. + install(TARGETS ${ROCM_SMI_TARGET} diff --git a/pkgs/tools/system/rocm-smi/default.nix b/pkgs/tools/system/rocm-smi/default.nix index 8f7859be7dcb..7f3f1ef03531 100644 --- a/pkgs/tools/system/rocm-smi/default.nix +++ b/pkgs/tools/system/rocm-smi/default.nix @@ -2,37 +2,18 @@ stdenv.mkDerivation rec { pname = "rocm-smi"; - version = "5.2.3"; + version = "5.3.0"; src = fetchFromGitHub { owner = "RadeonOpenCompute"; repo = "rocm_smi_lib"; rev = "rocm-${version}"; - hash = "sha256-D3ZH6xJe2C9rUCsJPOf9QlStecU90/iYi4wrXVvPff0="; + hash = "sha256-UbGbkH2vhQ9gv3sSoG+mXap+MdcrP61TN5DcP5F/5nQ="; }; nativeBuildInputs = [ cmake wrapPython ]; - postPatch = '' - # Upstream ROCm is installed in an /opt directory. For this reason, - # it does not completely follow FHS layout, creating top-level - # rocm_smi, oam, and bindings top-level directories. Since rocm-smi - # is a package that is typically installed, we change the paths to - # follow FHS more closely. - - # rocm_smi libraries and headers go into lib and include. Bindings - # go into lib/rocm_smi/bindings. - substituteInPlace rocm_smi/CMakeLists.txt \ - --replace "DESTINATION rocm_smi/" "DESTINATION " \ - --replace "DESTINATION bindings" "DESTINATION lib/rocm_smi/bindings" \ - --replace "../rocm_smi/bindings/rsmiBindings.py" "../lib/rocm_smi/bindings/rsmiBindings.py" \ - --replace 'DESTINATION ''${ROCM_SMI}/' "DESTINATION " - - # oam libraries and headers go into lib and include. - substituteInPlace oam/CMakeLists.txt \ - --replace "DESTINATION oam/" "DESTINATION " \ - --replace 'DESTINATION ''${OAM_NAME}/' "DESTINATION " - ''; + patches = [ ./cmake.patch ]; postInstall = '' wrapPythonProgramsIn $out @@ -49,7 +30,7 @@ stdenv.mkDerivation rec { description = "System management interface for AMD GPUs supported by ROCm"; homepage = "https://github.com/RadeonOpenCompute/rocm_smi_lib"; license = with licenses; [ mit ]; - maintainers = with maintainers; [ lovesegfault ]; + maintainers = with maintainers; [ lovesegfault Flakebi ]; platforms = [ "x86_64-linux" ]; }; }