From dee4fee1c7beeeaea4a27a3c88bf5cf0eed761ff Mon Sep 17 00:00:00 2001 From: Sebastian Neubauer Date: Wed, 5 Oct 2022 10:36:21 +0000 Subject: [PATCH 01/11] =?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" ]; }; } From 3bdbc120f80f25bdf5b808efc9c13c02eac0c97a Mon Sep 17 00:00:00 2001 From: Sebastian Neubauer Date: Wed, 5 Oct 2022 10:36:30 +0000 Subject: [PATCH 02/11] =?UTF-8?q?rocm-cmake:=205.2.0=20=E2=86=92=205.3.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../development/tools/build-managers/rocm-cmake/default.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkgs/development/tools/build-managers/rocm-cmake/default.nix b/pkgs/development/tools/build-managers/rocm-cmake/default.nix index 2526957ccbce..efd2e3a05e53 100644 --- a/pkgs/development/tools/build-managers/rocm-cmake/default.nix +++ b/pkgs/development/tools/build-managers/rocm-cmake/default.nix @@ -2,13 +2,13 @@ stdenv.mkDerivation rec { pname = "rocm-cmake"; - version = "5.2.0"; + version = "5.3.0"; src = fetchFromGitHub { owner = "RadeonOpenCompute"; repo = "rocm-cmake"; rev = "rocm-${version}"; - hash = "sha256-2YALk3G5BhrsXZZHjGSSuk8tCi5sNGuB2VB4uvozyZo="; + hash = "sha256-AOn3SLprHdeo2FwojQdhRAttUHuaWkO6WlymK8Q8lbc="; }; nativeBuildInputs = [ cmake ]; @@ -24,7 +24,7 @@ stdenv.mkDerivation rec { description = "CMake modules for common build tasks for the ROCm stack"; homepage = "https://github.com/RadeonOpenCompute/rocm-cmake"; license = licenses.mit; - maintainers = with maintainers; [ ]; + maintainers = with maintainers; [ Flakebi ]; platforms = platforms.unix; }; } From 421b8086f0cc09778fb11d5d873eb17b5aedd240 Mon Sep 17 00:00:00 2001 From: Sebastian Neubauer Date: Wed, 5 Oct 2022 10:36:39 +0000 Subject: [PATCH 03/11] =?UTF-8?q?rocm-thunk:=205.2.1=20=E2=86=92=205.3.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkgs/development/libraries/rocm-thunk/default.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkgs/development/libraries/rocm-thunk/default.nix b/pkgs/development/libraries/rocm-thunk/default.nix index c2a67a6f1462..d7add50386e7 100644 --- a/pkgs/development/libraries/rocm-thunk/default.nix +++ b/pkgs/development/libraries/rocm-thunk/default.nix @@ -9,13 +9,13 @@ stdenv.mkDerivation rec { pname = "rocm-thunk"; - version = "5.2.1"; + version = "5.3.0"; src = fetchFromGitHub { owner = "RadeonOpenCompute"; repo = "ROCT-Thunk-Interface"; rev = "rocm-${version}"; - hash = "sha256-iXhlEofPAQNxeZzDgdF1DdflIKfSI7rHGTqOybHnnHM="; + hash = "sha256-cM78Bx6uYsxhvdqSVNgmqOUYQnUJVCA7mNpRNNSFv6k="; }; preConfigure = '' @@ -48,6 +48,6 @@ stdenv.mkDerivation rec { description = "Radeon open compute thunk interface"; homepage = "https://github.com/RadeonOpenCompute/ROCT-Thunk-Interface"; license = with licenses; [ bsd2 mit ]; - maintainers = with maintainers; [ lovesegfault ]; + maintainers = with maintainers; [ lovesegfault Flakebi ]; }; } From 79ef038e49d4dfe806bd3f20395cbe42dc48ccba Mon Sep 17 00:00:00 2001 From: Sebastian Neubauer Date: Wed, 5 Oct 2022 10:36:50 +0000 Subject: [PATCH 04/11] =?UTF-8?q?rocm-runtime:=205.2.0=20=E2=86=92=205.3.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../libraries/rocm-runtime/default.nix | 25 ++++++++++++------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/pkgs/development/libraries/rocm-runtime/default.nix b/pkgs/development/libraries/rocm-runtime/default.nix index 36d178ea0433..563632b9d7f5 100644 --- a/pkgs/development/libraries/rocm-runtime/default.nix +++ b/pkgs/development/libraries/rocm-runtime/default.nix @@ -4,8 +4,10 @@ , writeScript , addOpenGLRunpath , cmake +, pkg-config , xxd , elfutils +, libdrm , llvm , numactl , rocm-device-libs @@ -13,28 +15,33 @@ stdenv.mkDerivation rec { pname = "rocm-runtime"; - version = "5.2.0"; + version = "5.3.0"; src = fetchFromGitHub { owner = "RadeonOpenCompute"; repo = "ROCR-Runtime"; rev = "rocm-${version}"; - hash = "sha256-TY0YPgNzxBLXAj7fncLQ01cSJyydveOLHrimCmLS32o="; + hash = "sha256-26E7vA2JlC50zmpaQfDrFMlgjAqmfTdp9/A8g5caDqI="; }; sourceRoot = "source/src"; - nativeBuildInputs = [ cmake xxd ]; + nativeBuildInputs = [ cmake pkg-config xxd ]; - buildInputs = [ elfutils llvm numactl ]; + buildInputs = [ elfutils libdrm llvm numactl ]; - cmakeFlags = [ - "-DBITCODE_DIR=${rocm-device-libs}/amdgcn/bitcode" - "-DCMAKE_PREFIX_PATH=${rocm-thunk}" - ]; + cmakeFlags = [ "-DCMAKE_PREFIX_PATH=${rocm-thunk}" ]; postPatch = '' patchShebangs image/blit_src/create_hsaco_ascii_file.sh + patchShebangs core/runtime/trap_handler/create_trap_handler_header.sh + + substituteInPlace CMakeLists.txt \ + --replace 'hsa/include/hsa' 'include/hsa' + + # We compile clang before rocm-device-libs, so patch it in afterwards + substituteInPlace image/blit_src/CMakeLists.txt \ + --replace '-cl-denorms-are-zero' '-cl-denorms-are-zero --rocm-device-lib-path=${rocm-device-libs}/amdgcn/bitcode' ''; fixupPhase = '' @@ -52,6 +59,6 @@ stdenv.mkDerivation rec { description = "Platform runtime for ROCm"; homepage = "https://github.com/RadeonOpenCompute/ROCR-Runtime"; license = with licenses; [ ncsa ]; - maintainers = with maintainers; [ lovesegfault ]; + maintainers = with maintainers; [ lovesegfault Flakebi ]; }; } From 8ec49a85c560892f324da9265b7459da0636f772 Mon Sep 17 00:00:00 2001 From: Sebastian Neubauer Date: Wed, 5 Oct 2022 10:36:59 +0000 Subject: [PATCH 05/11] =?UTF-8?q?rocm-opencl-runtime:=205.2.1=20=E2=86=92?= =?UTF-8?q?=205.3.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkgs/development/libraries/rocm-opencl-runtime/default.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkgs/development/libraries/rocm-opencl-runtime/default.nix b/pkgs/development/libraries/rocm-opencl-runtime/default.nix index 699f00449cc7..fc5f8fba5250 100644 --- a/pkgs/development/libraries/rocm-opencl-runtime/default.nix +++ b/pkgs/development/libraries/rocm-opencl-runtime/default.nix @@ -22,13 +22,13 @@ stdenv.mkDerivation rec { pname = "rocm-opencl-runtime"; - version = "5.2.1"; + version = "5.3.0"; src = fetchFromGitHub { owner = "RadeonOpenCompute"; repo = "ROCm-OpenCL-Runtime"; rev = "rocm-${version}"; - hash = "sha256-Mk7Wssz34Uxtb9PRIEGrTn/tXtqxLMrq0damA/p/DsY="; + hash = "sha256-QvAF25Zfq9d1M/KIsr2S+Ggxzqw/MQ2OVcm9ZNfjTa8="; }; nativeBuildInputs = [ cmake rocm-cmake ]; @@ -79,7 +79,7 @@ stdenv.mkDerivation rec { description = "OpenCL runtime for AMD GPUs, part of the ROCm stack"; homepage = "https://github.com/RadeonOpenCompute/ROCm-OpenCL-Runtime"; license = with licenses; [ asl20 mit ]; - maintainers = with maintainers; [ acowley lovesegfault ]; + maintainers = with maintainers; [ acowley lovesegfault Flakebi ]; platforms = platforms.linux; }; } From 1d6f9948cb24ee92fdc43798179be21454179874 Mon Sep 17 00:00:00 2001 From: Sebastian Neubauer Date: Wed, 5 Oct 2022 10:37:09 +0000 Subject: [PATCH 06/11] =?UTF-8?q?rocm-device-libs:=205.2.0=20=E2=86=92=205?= =?UTF-8?q?.3.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../libraries/rocm-device-libs/cmake.patch | 43 +++++++++++++++++++ .../libraries/rocm-device-libs/default.nix | 8 ++-- 2 files changed, 48 insertions(+), 3 deletions(-) create mode 100644 pkgs/development/libraries/rocm-device-libs/cmake.patch diff --git a/pkgs/development/libraries/rocm-device-libs/cmake.patch b/pkgs/development/libraries/rocm-device-libs/cmake.patch new file mode 100644 index 000000000000..500ff37a9905 --- /dev/null +++ b/pkgs/development/libraries/rocm-device-libs/cmake.patch @@ -0,0 +1,43 @@ +diff --git a/cmake/Packages.cmake b/cmake/Packages.cmake +index 07c60eb..c736b3e 100644 +--- a/cmake/Packages.cmake ++++ b/cmake/Packages.cmake +@@ -12,24 +12,29 @@ set_target_properties(${target} PROPERTIES + IMPORTED_LOCATION \"${target_path}\")") + endforeach() + configure_file(AMDDeviceLibsConfig.cmake.in +- ${PACKAGE_PREFIX}/AMDDeviceLibsConfig.cmake ++ lib/cmake/AMDDeviceLibs/AMDDeviceLibsConfig.cmake + @ONLY) + + + set(install_path_suffix "amdgcn/bitcode") + + # Generate the install-tree package. +-# We do not know the absolute path to the intall tree until we are installed, +-# so we calculate it dynamically in AMD_DEVICE_LIBS_PREFIX_CODE and use +-# relative paths in the target imports in AMD_DEVICE_LIBS_TARGET_CODE. +-set(AMD_DEVICE_LIBS_PREFIX_CODE " ++if(IS_ABSOLUTE "${CMAKE_INSTALL_PREFIX}") ++ set(AMD_DEVICE_LIBS_PREFIX_CODE "set(AMD_DEVICE_LIBS_PREFIX \"${CMAKE_INSTALL_PREFIX}\")") ++else() ++ # We do not know the absolute path to the install tree until we are installed, ++ # so we calculate it dynamically in AMD_DEVICE_LIBS_PREFIX_CODE and use ++ # relative paths in the target imports in AMD_DEVICE_LIBS_TARGET_CODE. ++ set(AMD_DEVICE_LIBS_PREFIX_CODE " + # Derive absolute install prefix from config file path. + get_filename_component(AMD_DEVICE_LIBS_PREFIX \"\${CMAKE_CURRENT_LIST_FILE}\" PATH)") +-string(REGEX REPLACE "/" ";" count "${PACKAGE_PREFIX}") +-foreach(p ${count}) +- set(AMD_DEVICE_LIBS_PREFIX_CODE "${AMD_DEVICE_LIBS_PREFIX_CODE} ++ string(REGEX REPLACE "/" ";" count "${PACKAGE_PREFIX}") ++ foreach(p ${count}) ++ set(AMD_DEVICE_LIBS_PREFIX_CODE "${AMD_DEVICE_LIBS_PREFIX_CODE} + get_filename_component(AMD_DEVICE_LIBS_PREFIX \"\${AMD_DEVICE_LIBS_PREFIX}\" PATH)") +-endforeach() ++ endforeach() ++endif() ++ + set(AMD_DEVICE_LIBS_TARGET_CODE) + foreach(target ${AMDGCN_LIB_LIST}) + get_target_property(target_name ${target} ARCHIVE_OUTPUT_NAME) diff --git a/pkgs/development/libraries/rocm-device-libs/default.nix b/pkgs/development/libraries/rocm-device-libs/default.nix index 08690f3fa450..c94e1f2753e0 100644 --- a/pkgs/development/libraries/rocm-device-libs/default.nix +++ b/pkgs/development/libraries/rocm-device-libs/default.nix @@ -8,13 +8,13 @@ stdenv.mkDerivation rec { pname = "rocm-device-libs"; - version = "5.2.0"; + version = "5.3.0"; src = fetchFromGitHub { owner = "RadeonOpenCompute"; repo = "ROCm-Device-Libs"; rev = "rocm-${version}"; - hash = "sha256-TBCSznHyiaiOcBR9irybCnOgfqPiNNn4679PCQwrLhA="; + hash = "sha256-rKMe0B/pkDek/ZU37trnJNa8aqvlwxobPb1+VTx/bJU="; }; nativeBuildInputs = [ cmake ]; @@ -27,6 +27,8 @@ stdenv.mkDerivation rec { "-DCLANG=${clang}/bin/clang" ]; + patches = [ ./cmake.patch ]; + passthru.updateScript = writeScript "update.sh" '' #!/usr/bin/env nix-shell #!nix-shell -i bash -p curl jq common-updater-scripts @@ -38,7 +40,7 @@ stdenv.mkDerivation rec { description = "Set of AMD-specific device-side language runtime libraries"; homepage = "https://github.com/RadeonOpenCompute/ROCm-Device-Libs"; license = licenses.ncsa; - maintainers = with maintainers; [ lovesegfault ]; + maintainers = with maintainers; [ lovesegfault Flakebi ]; platforms = platforms.linux; }; } From 6bd359374957bae5df7ba8c4da83995b1fcfa3d4 Mon Sep 17 00:00:00 2001 From: Sebastian Neubauer Date: Wed, 5 Oct 2022 10:37:19 +0000 Subject: [PATCH 07/11] =?UTF-8?q?rocm-comgr:=205.2.0=20=E2=86=92=205.3.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../libraries/rocm-comgr/cmake.patch | 343 ++++++++++++------ .../libraries/rocm-comgr/default.nix | 7 +- 2 files changed, 245 insertions(+), 105 deletions(-) diff --git a/pkgs/development/libraries/rocm-comgr/cmake.patch b/pkgs/development/libraries/rocm-comgr/cmake.patch index 0c599e2403c5..ae966745171c 100644 --- a/pkgs/development/libraries/rocm-comgr/cmake.patch +++ b/pkgs/development/libraries/rocm-comgr/cmake.patch @@ -1,19 +1,8 @@ diff --git a/CMakeLists.txt b/CMakeLists.txt -index eac270a..27610ec 100644 +index 62b857b..d21c7f4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt -@@ -53,10 +53,6 @@ set(SOURCES - - if(COMGR_BUILD_SHARED_LIBS) - add_library(amd_comgr SHARED ${SOURCES}) -- # Windows doesn't have a strip utility, so CMAKE_STRIP won't be set. -- if((CMAKE_BUILD_TYPE STREQUAL "Release") AND NOT ("${CMAKE_STRIP}" STREQUAL "")) -- add_custom_command(TARGET amd_comgr POST_BUILD COMMAND ${CMAKE_STRIP} $) -- endif() - else() - add_library(amd_comgr STATIC ${SOURCES}) - endif() -@@ -141,8 +137,8 @@ if (UNIX) +@@ -147,8 +147,8 @@ if (UNIX) list(APPEND AMD_COMGR_PUBLIC_LINKER_OPTIONS -pthread) if (NOT APPLE AND COMGR_BUILD_SHARED_LIBS) configure_file( @@ -24,17 +13,7 @@ index eac270a..27610ec 100644 list(APPEND AMD_COMGR_PRIVATE_LINKER_OPTIONS "-Wl,--version-script=${CMAKE_CURRENT_BINARY_DIR}/src/exportmap") # When building a shared library with -fsanitize=address we can't be -@@ -154,6 +150,9 @@ if (UNIX) - -Wl,--no-undefined) - endif() - endif() -+ -+ # Strip in release build -+ set_target_properties(amd_comgr PROPERTIES LINK_FLAGS_RELEASE -s) - elseif (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") - list(APPEND AMD_COMGR_PRIVATE_COMPILE_OPTIONS - "/wd4244" #[[Suppress 'argument' : conversion from 'type1' to 'type2', possible loss of data]] -@@ -169,10 +168,6 @@ endif() +@@ -175,10 +175,6 @@ endif() # the shared header. list(APPEND AMD_COMGR_PRIVATE_COMPILE_DEFINITIONS AMD_COMGR_EXPORT) @@ -45,100 +24,209 @@ index eac270a..27610ec 100644 include(bc2h) include(opencl_pch) include(DeviceLibs) -@@ -203,8 +198,11 @@ target_compile_definitions(amd_comgr - PRIVATE "${AMD_COMGR_PRIVATE_COMPILE_DEFINITIONS}") - target_include_directories(amd_comgr - PUBLIC -- $ -- $) -+ $) -+ +@@ -212,10 +208,14 @@ target_include_directories(amd_comgr + $ + $) + +configure_file( + include/amd_comgr.h.in + include/amd_comgr.h @ONLY) - ++ set(AMD_COMGR_CONFIG_NAME amd_comgr-config.cmake) set(AMD_COMGR_TARGETS_NAME amd_comgr-targets.cmake) -@@ -220,29 +218,30 @@ if (NOT COMGR_BUILD_SHARED_LIBS) + set(AMD_COMGR_VERSION_NAME amd_comgr-config-version.cmake) +-set(AMD_COMGR_PACKAGE_PREFIX ${CMAKE_INSTALL_LIBDIR}/cmake/amd_comgr) ++set(AMD_COMGR_PACKAGE_PREFIX cmake/amd_comgr) + + # Generate the build-tree package. + set(AMD_COMGR_PREFIX_CODE) +@@ -226,13 +226,13 @@ if (NOT COMGR_BUILD_SHARED_LIBS) endif() set(AMD_COMGR_TARGETS_PATH - "${CMAKE_CURRENT_BINARY_DIR}/${AMD_COMGR_PACKAGE_PREFIX}/${AMD_COMGR_TARGETS_NAME}") --set(AMD_COMGR_VERSION_PATH ++ "${CMAKE_CURRENT_BINARY_DIR}/lib/${AMD_COMGR_PACKAGE_PREFIX}/${AMD_COMGR_TARGETS_NAME}") + set(AMD_COMGR_VERSION_PATH - "${CMAKE_CURRENT_BINARY_DIR}/${AMD_COMGR_PACKAGE_PREFIX}/${AMD_COMGR_VERSION_NAME}") --export(TARGETS amd_comgr ++ "${CMAKE_CURRENT_BINARY_DIR}/lib/${AMD_COMGR_PACKAGE_PREFIX}/${AMD_COMGR_VERSION_NAME}") + export(TARGETS amd_comgr - FILE "${AMD_COMGR_PACKAGE_PREFIX}/${AMD_COMGR_TARGETS_NAME}") -+ "${AMD_COMGR_PACKAGE_PREFIX}/${AMD_COMGR_TARGETS_NAME}") ++ FILE "lib/${AMD_COMGR_PACKAGE_PREFIX}/${AMD_COMGR_TARGETS_NAME}") configure_file("cmake/${AMD_COMGR_CONFIG_NAME}.in" - "${AMD_COMGR_PACKAGE_PREFIX}/${AMD_COMGR_CONFIG_NAME}" -+ ${AMD_COMGR_CONFIG_NAME} ++ "lib/${AMD_COMGR_PACKAGE_PREFIX}/${AMD_COMGR_CONFIG_NAME}" @ONLY) --write_basic_package_version_file("${AMD_COMGR_VERSION_PATH}" -+write_basic_package_version_file("${CMAKE_CURRENT_BINARY_DIR}/${AMD_COMGR_VERSION_NAME}" + write_basic_package_version_file("${AMD_COMGR_VERSION_PATH}" VERSION "${amd_comgr_VERSION}" - COMPATIBILITY SameMajorVersion) - - install(TARGETS amd_comgr - EXPORT amd_comgr_export -- COMPONENT amd-comgr -- RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} -- LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} -- ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) -+ COMPONENT amd-comgr) -+install(EXPORT amd_comgr_export -+ DESTINATION "${AMD_COMGR_PACKAGE_PREFIX}" -+ FILE "${AMD_COMGR_TARGETS_NAME}") - - install(FILES - "${CMAKE_CURRENT_BINARY_DIR}/include/amd_comgr.h" - COMPONENT amd-comgr - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) -+install(FILES -+ "${CMAKE_CURRENT_BINARY_DIR}/${AMD_COMGR_CONFIG_NAME}" -+ "${CMAKE_CURRENT_BINARY_DIR}/${AMD_COMGR_VERSION_NAME}" -+ COMPONENT amd-comgr -+ DESTINATION ${AMD_COMGR_PACKAGE_PREFIX}) - - install(FILES - "README.md" -@@ -251,37 +250,6 @@ install(FILES - COMPONENT amd-comgr - DESTINATION ${CMAKE_INSTALL_DATADIR}/amd_comgr) - --# Generate the install-tree package. --set(AMD_COMGR_PREFIX_CODE " --# Derive absolute install prefix from config file path. --get_filename_component(AMD_COMGR_PREFIX \"\${CMAKE_CURRENT_LIST_FILE}\" PATH)") +@@ -266,7 +266,7 @@ install(FILES + set(AMD_COMGR_PREFIX_CODE " + # Derive absolute install prefix from config file path. + get_filename_component(AMD_COMGR_PREFIX \"\${CMAKE_CURRENT_LIST_FILE}\" PATH)") -string(REGEX REPLACE "/" ";" count "${AMD_COMGR_PACKAGE_PREFIX}") --foreach(p ${count}) -- set(AMD_COMGR_PREFIX_CODE "${AMD_COMGR_PREFIX_CODE} --get_filename_component(AMD_COMGR_PREFIX \"\${AMD_COMGR_PREFIX}\" PATH)") --endforeach() -- --if (NOT COMGR_BUILD_SHARED_LIBS) -- string(APPEND AMD_COMGR_PREFIX_CODE "\ninclude(CMakeFindDependencyMacro)\n") -- string(APPEND AMD_COMGR_PREFIX_CODE "find_dependency(Clang REQUIRED)\n") -- string(APPEND AMD_COMGR_PREFIX_CODE "find_dependency(LLD REQUIRED)\n") --endif() -- --set(AMD_COMGR_TARGETS_PATH "\${AMD_COMGR_PREFIX}/${AMD_COMGR_PACKAGE_PREFIX}/${AMD_COMGR_TARGETS_NAME}") --configure_file("cmake/${AMD_COMGR_CONFIG_NAME}.in" -- "${CMAKE_CURRENT_BINARY_DIR}/${AMD_COMGR_CONFIG_NAME}.install" -- @ONLY) --install(FILES -- "${CMAKE_CURRENT_BINARY_DIR}/${AMD_COMGR_CONFIG_NAME}.install" -- DESTINATION "${AMD_COMGR_PACKAGE_PREFIX}" -- RENAME "${AMD_COMGR_CONFIG_NAME}") --install(EXPORT amd_comgr_export -- DESTINATION "${AMD_COMGR_PACKAGE_PREFIX}" -- FILE "${AMD_COMGR_TARGETS_NAME}") --install(FILES -- "${AMD_COMGR_VERSION_PATH}" -- DESTINATION "${AMD_COMGR_PACKAGE_PREFIX}") -- - set(CLANG_LIBS - clangFrontendTool) ++string(REGEX REPLACE "/" ";" count "${CMAKE_INSTALL_LIBDIR}/${AMD_COMGR_PACKAGE_PREFIX}") + foreach(p ${count}) + set(AMD_COMGR_PREFIX_CODE "${AMD_COMGR_PREFIX_CODE} + get_filename_component(AMD_COMGR_PREFIX \"\${AMD_COMGR_PREFIX}\" PATH)") +@@ -278,20 +278,20 @@ if (NOT COMGR_BUILD_SHARED_LIBS) + string(APPEND AMD_COMGR_PREFIX_CODE "find_dependency(LLD REQUIRED)\n") + endif() +-set(AMD_COMGR_TARGETS_PATH "\${AMD_COMGR_PREFIX}/${AMD_COMGR_PACKAGE_PREFIX}/${AMD_COMGR_TARGETS_NAME}") ++set(AMD_COMGR_TARGETS_PATH "\${AMD_COMGR_PREFIX}/${CMAKE_INSTALL_LIBDIR}/${AMD_COMGR_PACKAGE_PREFIX}/${AMD_COMGR_TARGETS_NAME}") + configure_file("cmake/${AMD_COMGR_CONFIG_NAME}.in" +- "${CMAKE_CURRENT_BINARY_DIR}/${AMD_COMGR_CONFIG_NAME}.install" ++ "${AMD_COMGR_CONFIG_NAME}.install" + @ONLY) + install(FILES + "${CMAKE_CURRENT_BINARY_DIR}/${AMD_COMGR_CONFIG_NAME}.install" +- DESTINATION "${AMD_COMGR_PACKAGE_PREFIX}" ++ DESTINATION "${CMAKE_INSTALL_LIBDIR}/${AMD_COMGR_PACKAGE_PREFIX}" + RENAME "${AMD_COMGR_CONFIG_NAME}") + install(EXPORT amd_comgr_export +- DESTINATION "${AMD_COMGR_PACKAGE_PREFIX}" ++ DESTINATION "${CMAKE_INSTALL_LIBDIR}/${AMD_COMGR_PACKAGE_PREFIX}" + FILE "${AMD_COMGR_TARGETS_NAME}") + install(FILES + "${AMD_COMGR_VERSION_PATH}" +- DESTINATION "${AMD_COMGR_PACKAGE_PREFIX}") ++ DESTINATION "${CMAKE_INSTALL_LIBDIR}/${AMD_COMGR_PACKAGE_PREFIX}") + + if(TARGET clangFrontendTool) + set(CLANG_LIBS +diff --git a/cmake/DeviceLibs.cmake b/cmake/DeviceLibs.cmake +index 27e9546..dfe1b57 100644 +--- a/cmake/DeviceLibs.cmake ++++ b/cmake/DeviceLibs.cmake +@@ -1,8 +1,7 @@ + set(INC_DIR ${CMAKE_CURRENT_BINARY_DIR}/include) + + set(GEN_LIBRARY_INC_FILE ${INC_DIR}/libraries.inc) +- +-file(WRITE ${GEN_LIBRARY_INC_FILE} "// Automatically generated file; DO NOT EDIT.\n") ++set(GEN_LIBRARY_DEFS_INC_FILE ${INC_DIR}/libraries_defs.inc) + + # cmake does not provide a way to query targets produced by a project, + # so we have to make one up. Ordinarily, individual library target +@@ -23,6 +22,7 @@ if(NOT AMD_DEVICE_LIBS_TARGETS) + message(FATAL_ERROR "Could not find list of device libraries") + endif() + ++set(TARGETS_INCLUDES "") + foreach(AMDGCN_LIB_TARGET ${AMD_DEVICE_LIBS_TARGETS}) + set(header ${AMDGCN_LIB_TARGET}.inc) + +@@ -54,75 +54,52 @@ foreach(AMDGCN_LIB_TARGET ${AMD_DEVICE_LIBS_TARGETS}) + add_custom_target(${AMDGCN_LIB_TARGET}_header DEPENDS ${INC_DIR}/${header}) + add_dependencies(amd_comgr ${AMDGCN_LIB_TARGET}_header) + +- file(APPEND ${GEN_LIBRARY_INC_FILE} "#include \"${header}\"\n") ++ list(APPEND TARGETS_INCLUDES "#include \"${header}\"") ++endforeach() ++ ++list(JOIN TARGETS_INCLUDES "\n" TARGETS_INCLUDES) ++file(GENERATE OUTPUT ${GEN_LIBRARY_INC_FILE} CONTENT "${TARGETS_INCLUDES}") ++ ++foreach(OPENCL_VERSION 1.2 2.0) ++ string(REPLACE . _ OPENCL_UNDERSCORE_VERSION ${OPENCL_VERSION}) ++ add_custom_command(OUTPUT ${INC_DIR}/opencl${OPENCL_VERSION}-c.inc ++ COMMAND bc2h ${CMAKE_CURRENT_BINARY_DIR}/opencl${OPENCL_VERSION}-c.pch ++ ${INC_DIR}/opencl${OPENCL_VERSION}-c.inc ++ opencl${OPENCL_UNDERSCORE_VERSION}_c ++ DEPENDS bc2h ${CMAKE_CURRENT_BINARY_DIR}/opencl${OPENCL_VERSION}-c.pch ++ COMMENT "Generating opencl${OPENCL_VERSION}-c.inc" ++ ) ++ set_property(DIRECTORY APPEND PROPERTY ++ ADDITIONAL_MAKE_CLEAN_FILES ${INC_DIR}/opencl${OPENCL_VERSION}-c.inc) ++ add_custom_target(opencl${OPENCL_VERSION}-c.inc_target DEPENDS ${INC_DIR}/opencl${OPENCL_VERSION}-c.inc) ++ add_dependencies(amd_comgr opencl${OPENCL_VERSION}-c.inc_target) + endforeach() + +-add_custom_command(OUTPUT ${INC_DIR}/opencl1.2-c.inc +- COMMAND bc2h ${CMAKE_CURRENT_BINARY_DIR}/opencl1.2-c.pch +- ${INC_DIR}/opencl1.2-c.inc +- opencl1_2_c +- DEPENDS bc2h ${CMAKE_CURRENT_BINARY_DIR}/opencl1.2-c.pch +- COMMENT "Generating opencl1.2-c.inc" +-) +-set_property(DIRECTORY APPEND PROPERTY +- ADDITIONAL_MAKE_CLEAN_FILES ${INC_DIR}/opencl1.2-c.inc) +-add_custom_target(opencl1.2-c.inc_target DEPENDS ${INC_DIR}/opencl1.2-c.inc) +-add_dependencies(amd_comgr opencl1.2-c.inc_target) +-file(APPEND ${GEN_LIBRARY_INC_FILE} "#include \"opencl1.2-c.inc\"\n") +- +-add_custom_command(OUTPUT ${INC_DIR}/opencl2.0-c.inc +- COMMAND bc2h ${CMAKE_CURRENT_BINARY_DIR}/opencl2.0-c.pch +- ${INC_DIR}/opencl2.0-c.inc +- opencl2_0_c +- DEPENDS bc2h ${CMAKE_CURRENT_BINARY_DIR}/opencl2.0-c.pch +- COMMENT "Generating opencl2.0-c.inc" +-) +-set_property(DIRECTORY APPEND PROPERTY +- ADDITIONAL_MAKE_CLEAN_FILES ${INC_DIR}/opencl2.0-c.inc) +-add_custom_target(opencl2.0-c.inc_target DEPENDS ${INC_DIR}/opencl2.0-c.inc) +-add_dependencies(amd_comgr opencl2.0-c.inc_target) +-file(APPEND ${GEN_LIBRARY_INC_FILE} "#include \"opencl2.0-c.inc\"\n") +- +-# Generate function to select libraries for a given GFXIP number. +-file(APPEND ${GEN_LIBRARY_INC_FILE} "#include \"llvm/ADT/StringRef.h\"\n") +-file(APPEND ${GEN_LIBRARY_INC_FILE} +- "static std::tuple get_oclc_isa_version(llvm::StringRef gfxip) {") ++set(TARGETS_DEFS "") ++list(APPEND TARGETS_DEFS "#ifndef AMD_DEVICE_LIBS_TARGET\n#define AMD_DEVICE_LIBS_TARGET(t)\n#endif") ++list(APPEND TARGETS_DEFS "#ifndef AMD_DEVICE_LIBS_GFXIP\n#define AMD_DEVICE_LIBS_GFXIP(t, g)\n#endif") ++list(APPEND TARGETS_DEFS "#ifndef AMD_DEVICE_LIBS_FUNCTION\n#define AMD_DEVICE_LIBS_FUNCTION(t, f)\n#endif") ++list(APPEND TARGETS_DEFS "") + foreach(AMDGCN_LIB_TARGET ${AMD_DEVICE_LIBS_TARGETS}) ++ list(APPEND TARGETS_DEFS "AMD_DEVICE_LIBS_TARGET(${AMDGCN_LIB_TARGET})") ++ # Generate function to select libraries for a given GFXIP number. + if (${AMDGCN_LIB_TARGET} MATCHES "^oclc_isa_version_.+$") + string(REGEX REPLACE "^oclc_isa_version_(.+)$" "\\1" gfxip ${AMDGCN_LIB_TARGET}) +- file(APPEND ${GEN_LIBRARY_INC_FILE} +- "if (gfxip == \"${gfxip}\") return std::make_tuple(\"${AMDGCN_LIB_TARGET}.bc\", ${AMDGCN_LIB_TARGET}_lib, ${AMDGCN_LIB_TARGET}_lib_size);") ++ list(APPEND TARGETS_DEFS "AMD_DEVICE_LIBS_GFXIP(${AMDGCN_LIB_TARGET}, \"${gfxip}\")") + endif() +-endforeach() +-file(APPEND ${GEN_LIBRARY_INC_FILE} +- "return std::make_tuple(nullptr, nullptr, 0); }") +- +-# Generate function to select libraries for given feature. +-foreach(AMDGCN_LIB_TARGET ${AMD_DEVICE_LIBS_TARGETS}) ++ # Generate function to select libraries for given feature. + if (${AMDGCN_LIB_TARGET} MATCHES "^oclc_.*_on$") + string(REGEX REPLACE "^oclc_(.*)_on" "\\1" function ${AMDGCN_LIB_TARGET}) +- file(APPEND ${GEN_LIBRARY_INC_FILE} +- "static std::tuple get_oclc_${function}(bool on) { \ +- return std::make_tuple( \ +- on ? \"oclc_${function}_on_lib.bc\" : \"oclc_${function}_off_lib.bc\", \ +- on ? oclc_${function}_on_lib : oclc_${function}_off_lib, \ +- on ? oclc_${function}_on_lib_size : oclc_${function}_off_lib_size \ +- ); }") ++ list(APPEND TARGETS_DEFS "AMD_DEVICE_LIBS_FUNCTION(${AMDGCN_LIB_TARGET}, ${function})") + endif() + endforeach() + +-# Generate function yield all libraries. +-file(APPEND ${GEN_LIBRARY_INC_FILE} "\n#include \"llvm/ADT/ArrayRef.h\"\n") +-file(APPEND ${GEN_LIBRARY_INC_FILE} +- "llvm::ArrayRef> COMGR::getDeviceLibraries() { \ +- static std::tuple DeviceLibs[] = {") +-foreach(AMDGCN_LIB_TARGET ${AMD_DEVICE_LIBS_TARGETS}) +- file(APPEND ${GEN_LIBRARY_INC_FILE} +- "{\"${AMDGCN_LIB_TARGET}.bc\", llvm::StringRef(reinterpret_cast(${AMDGCN_LIB_TARGET}_lib), ${AMDGCN_LIB_TARGET}_lib_size)},") +-endforeach() +-file(APPEND ${GEN_LIBRARY_INC_FILE} +- "}; \ +- return DeviceLibs; \ +- }") ++list(APPEND TARGETS_DEFS "") ++list(APPEND TARGETS_DEFS "#undef AMD_DEVICE_LIBS_TARGET") ++list(APPEND TARGETS_DEFS "#undef AMD_DEVICE_LIBS_GFXIP") ++list(APPEND TARGETS_DEFS "#undef AMD_DEVICE_LIBS_FUNCTION") ++ ++list(JOIN TARGETS_DEFS "\n" TARGETS_DEFS) ++file(GENERATE OUTPUT ${GEN_LIBRARY_DEFS_INC_FILE} CONTENT "${TARGETS_DEFS}") + + include_directories(${INC_DIR}) diff --git a/cmake/bc2h.cmake b/cmake/bc2h.cmake index 146fe2b..9134985 100644 --- a/cmake/bc2h.cmake @@ -222,3 +310,56 @@ index 146fe2b..9134985 100644 add_executable(bc2h ${CMAKE_CURRENT_BINARY_DIR}/bc2h.c) if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") +diff --git a/src/comgr-device-libs.cpp b/src/comgr-device-libs.cpp +index 4d2b914..80786d1 100644 +--- a/src/comgr-device-libs.cpp ++++ b/src/comgr-device-libs.cpp +@@ -35,7 +35,7 @@ + + #include "comgr-device-libs.h" + #include "comgr.h" +-#include "libraries.inc" ++#include "comgr-libraries.h" + #include "llvm/ADT/StringSwitch.h" + #include + +diff --git a/src/comgr-libraries.h b/src/comgr-libraries.h +new file mode 100644 +index 0000000..3caa0a0 +--- /dev/null ++++ b/src/comgr-libraries.h +@@ -0,0 +1,34 @@ ++#include "libraries.inc" ++#include "opencl1.2-c.inc" ++#include "opencl2.0-c.inc" ++#include "llvm/ADT/StringRef.h" ++#include "llvm/ADT/ArrayRef.h" ++ ++static std::tuple get_oclc_isa_version(llvm::StringRef gfxip) { ++#define AMD_DEVICE_LIBS_GFXIP(target, target_gfxip) \ ++ if (gfxip == target_gfxip) return std::make_tuple(#target ".bc", target##_lib, target##_lib_size); ++#include "libraries_defs.inc" ++ ++ return std::make_tuple(nullptr, nullptr, 0); ++} ++ ++#define AMD_DEVICE_LIBS_FUNCTION(target, function) \ ++ static std::tuple get_oclc_##function(bool on) { \ ++ return std::make_tuple( \ ++ on ? "oclc_" #function "_on_lib.bc" : "oclc_" #function "_off_lib.bc", \ ++ on ? oclc_##function##_on_lib : oclc_##function##_off_lib, \ ++ on ? oclc_##function##_on_lib_size : oclc_##function##_off_lib_size \ ++ ); \ ++ } ++#include "libraries_defs.inc" ++ ++llvm::ArrayRef> COMGR::getDeviceLibraries() { ++ static std::tuple DeviceLibs[] = { ++#define AMD_DEVICE_LIBS_TARGET(target) \ ++ {#target ".bc", llvm::StringRef(reinterpret_cast(target##_lib), target##_lib_size)}, ++#include "libraries_defs.inc" ++ }; ++ return DeviceLibs; ++} ++ ++ diff --git a/pkgs/development/libraries/rocm-comgr/default.nix b/pkgs/development/libraries/rocm-comgr/default.nix index db9e012e4eec..e7f07380758b 100644 --- a/pkgs/development/libraries/rocm-comgr/default.nix +++ b/pkgs/development/libraries/rocm-comgr/default.nix @@ -2,13 +2,13 @@ stdenv.mkDerivation rec { pname = "rocm-comgr"; - version = "5.2.0"; + version = "5.3.0"; src = fetchFromGitHub { owner = "RadeonOpenCompute"; repo = "ROCm-CompilerSupport"; rev = "rocm-${version}"; - hash = "sha256-5C5bRdrt3xZAlRgtiIRTMAuwsFvVM4Win96P5+Pf5ZM="; + hash = "sha256-LQyMhqcWm8zqt6138fnT7EOq/F8bG3Iuf04PTemVQmg="; }; sourceRoot = "source/lib/comgr"; @@ -18,7 +18,6 @@ stdenv.mkDerivation rec { buildInputs = [ clang rocm-device-libs llvm ]; cmakeFlags = [ - "-DCMAKE_BUILD_TYPE=Release" "-DCMAKE_C_COMPILER=${clang}/bin/clang" "-DCMAKE_CXX_COMPILER=${clang}/bin/clang++" "-DCMAKE_PREFIX_PATH=${llvm}/lib/cmake/llvm" @@ -39,7 +38,7 @@ stdenv.mkDerivation rec { description = "APIs for compiling and inspecting AMDGPU code objects"; homepage = "https://github.com/RadeonOpenCompute/ROCm-CompilerSupport/tree/amd-stg-open/lib/comgr"; license = licenses.ncsa; - maintainers = with maintainers; [ lovesegfault ]; + maintainers = with maintainers; [ lovesegfault Flakebi ]; platforms = platforms.linux; }; } From 692bc4c5496219bf96ec275d5fb71f731661f213 Mon Sep 17 00:00:00 2001 From: Sebastian Neubauer Date: Wed, 5 Oct 2022 10:37:29 +0000 Subject: [PATCH 08/11] =?UTF-8?q?rocclr:=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/development/libraries/rocclr/default.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkgs/development/libraries/rocclr/default.nix b/pkgs/development/libraries/rocclr/default.nix index 4de1f3909e26..a9e254d9d349 100644 --- a/pkgs/development/libraries/rocclr/default.nix +++ b/pkgs/development/libraries/rocclr/default.nix @@ -7,13 +7,13 @@ stdenv.mkDerivation rec { pname = "rocclr"; - version = "5.2.3"; + version = "5.3.0"; src = fetchFromGitHub { owner = "ROCm-Developer-Tools"; repo = "ROCclr"; rev = "rocm-${version}"; - hash = "sha256-DER6PBYXmZRgwFNVU5rpn87HrXMR+HnQf8cwHioUals="; + hash = "sha256-l14+l8FkiFmGuRZ9dyD/PEYH9nHVRRg1vMXMnVhg3K4="; }; patches = [ @@ -53,7 +53,7 @@ stdenv.mkDerivation rec { description = "Source package of the Radeon Open Compute common language runtime"; homepage = "https://github.com/ROCm-Developer-Tools/ROCclr"; license = licenses.mit; - maintainers = with maintainers; [ lovesegfault ]; + maintainers = with maintainers; [ lovesegfault Flakebi ]; # rocclr seems to have some AArch64 ifdefs, but does not seem # to be supported yet by the build infrastructure. Recheck in # the future. From 4ee2665a6d9d7a04004054562abdfe4604aa8d17 Mon Sep 17 00:00:00 2001 From: Sebastian Neubauer Date: Wed, 5 Oct 2022 10:37:38 +0000 Subject: [PATCH 09/11] =?UTF-8?q?rocminfo:=205.1.1=20=E2=86=92=205.3.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkgs/development/tools/rocminfo/default.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkgs/development/tools/rocminfo/default.nix b/pkgs/development/tools/rocminfo/default.nix index a7f895f8917f..1761227045b7 100644 --- a/pkgs/development/tools/rocminfo/default.nix +++ b/pkgs/development/tools/rocminfo/default.nix @@ -7,13 +7,13 @@ # compilers to determine the desired target. , defaultTargets ? []}: stdenv.mkDerivation rec { - version = "5.1.1"; + version = "5.3.0"; pname = "rocminfo"; src = fetchFromGitHub { owner = "RadeonOpenCompute"; repo = "rocminfo"; rev = "rocm-${version}"; - sha256 = "sha256-x+QJJtUvgtNS4116tJFWdJOUS8yV4o10mbTAUuxerkE="; + sha256 = "sha256-4wZTm5AZgG8xEd6uYqxWq4bWZgcSYZ2WYA1z4RAPF8U="; }; enableParallelBuilding = true; @@ -48,7 +48,7 @@ stdenv.mkDerivation rec { description = "ROCm Application for Reporting System Info"; homepage = "https://github.com/RadeonOpenCompute/rocminfo"; license = licenses.ncsa; - maintainers = with maintainers; [ lovesegfault ]; + maintainers = with maintainers; [ lovesegfault Flakebi ]; platforms = platforms.linux; }; } From 72aaaa782ab3e1950b4c9e80afb7c0f9e9f19b73 Mon Sep 17 00:00:00 2001 From: Sebastian Neubauer Date: Wed, 5 Oct 2022 10:38:58 +0000 Subject: [PATCH 10/11] =?UTF-8?q?llvmPackages=5Frocm.llvm:=205.2.3=20?= =?UTF-8?q?=E2=86=92=205.3.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkgs/development/compilers/llvm/rocm/default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/development/compilers/llvm/rocm/default.nix b/pkgs/development/compilers/llvm/rocm/default.nix index a3e50ab4761d..a952615a6c24 100644 --- a/pkgs/development/compilers/llvm/rocm/default.nix +++ b/pkgs/development/compilers/llvm/rocm/default.nix @@ -1,12 +1,12 @@ { stdenv, lib, buildPackages, fetchFromGitHub, callPackage, wrapCCWith, overrideCC }: let - version = "5.2.3"; + version = "5.3.0"; src = fetchFromGitHub { owner = "RadeonOpenCompute"; repo = "llvm-project"; rev = "rocm-${version}"; - hash = "sha256-sudH8hnjReyuCFm2CBEPd8W88SjAARgCd1MTIJaDjTI="; + hash = "sha256-MN7W4Gl6+a1nCozdn9gMzIXOiBPquoOP87x26boeSCA="; }; in rec { clang = wrapCCWith rec { From 01819daec129639a040e86804af87842bdf734ca Mon Sep 17 00:00:00 2001 From: Sebastian Neubauer Date: Wed, 5 Oct 2022 11:52:20 +0000 Subject: [PATCH 11/11] =?UTF-8?q?hip:=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/development/compilers/hip/default.nix | 19 ++++++++----- .../compilers/hip/hip-config-paths.patch | 9 +++--- .../compilers/hip/hipamd-config-paths.patch | 28 ++++++++++++++++++- 3 files changed, 43 insertions(+), 13 deletions(-) diff --git a/pkgs/development/compilers/hip/default.nix b/pkgs/development/compilers/hip/default.nix index 329d523ddc23..fff2886246ff 100644 --- a/pkgs/development/compilers/hip/default.nix +++ b/pkgs/development/compilers/hip/default.nix @@ -29,13 +29,13 @@ let hip = stdenv.mkDerivation rec { pname = "hip"; - version = "5.2.3"; + version = "5.3.0"; src = fetchFromGitHub { owner = "ROCm-Developer-Tools"; repo = "HIP"; rev = "rocm-${version}"; - hash = "sha256-QaN666Rku2Tkio2Gm5/3RD8D5JgmCZLe0Yun1fGxa8U="; + hash = "sha256-UAodlVUiTU4n/EyvTIuQekTGh4izmBjKCRXOHXVKY4M="; }; patches = [ @@ -102,20 +102,20 @@ let description = "C++ Heterogeneous-Compute Interface for Portability"; homepage = "https://github.com/ROCm-Developer-Tools/HIP"; license = licenses.mit; - maintainers = with maintainers; [ lovesegfault ]; + maintainers = with maintainers; [ lovesegfault Flakebi ]; platforms = platforms.linux; }; }; in stdenv.mkDerivation rec { pname = "hip"; - version = "5.2.3"; + version = "5.3.0"; src = fetchFromGitHub { owner = "ROCm-Developer-Tools"; repo = "hipamd"; rev = "rocm-${version}"; - hash = "sha256-9YZBFn1jpOiX0X9rcpsFDNhas9vfxNkNnbsWSi7unPU="; + hash = "sha256-gZGZiDP/HbdmzLQkG9Jq9lyMP9hoD6UzTMiX9cUmQNA="; }; nativeBuildInputs = [ cmake python3 makeWrapper perl ]; @@ -133,11 +133,16 @@ stdenv.mkDerivation rec { patches = [ (substituteAll { src = ./hipamd-config-paths.patch; - inherit llvm hip; + inherit clang llvm hip; rocm_runtime = rocm-runtime; }) ]; + prePatch = '' + sed -e 's,#!/bin/bash,#!${stdenv.shell},' \ + -i src/hip_embed_pch.sh + ''; + preConfigure = '' export HIP_CLANG_PATH=${clang}/bin export DEVICE_LIB_PATH=${rocm-device-libs}/lib @@ -189,7 +194,7 @@ stdenv.mkDerivation rec { description = "C++ Heterogeneous-Compute Interface for Portability"; homepage = "https://github.com/ROCm-Developer-Tools/hipamd"; license = licenses.mit; - maintainers = with maintainers; [ lovesegfault ]; + maintainers = with maintainers; [ lovesegfault Flakebi ]; platforms = platforms.linux; }; } diff --git a/pkgs/development/compilers/hip/hip-config-paths.patch b/pkgs/development/compilers/hip/hip-config-paths.patch index 71e804c74482..25fa3b8da95a 100644 --- a/pkgs/development/compilers/hip/hip-config-paths.patch +++ b/pkgs/development/compilers/hip/hip-config-paths.patch @@ -2,7 +2,7 @@ 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) +@@ -71,8 +71,8 @@ get_filename_component(_IMPORT_PREFIX "${_DIR}/../../../" REALPATH) #need _IMPORT_PREFIX to be set #FILE_REORG_BACKWARD_COMPATIBILITY @@ -13,19 +13,18 @@ index 1a72643a..7f35031f 100644 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() +@@ -87,9 +87,7 @@ endif() #if HSA is not under ROCm then provide CMAKE_PREFIX_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) + if (NOT HSA_HEADER) +@@ -97,7 +94,7 @@ if (HSA_HEADER-NOTFOUND) endif() get_filename_component(HIP_COMPILER_INSTALL_PATH ${CMAKE_HIP_COMPILER} DIRECTORY) diff --git a/pkgs/development/compilers/hip/hipamd-config-paths.patch b/pkgs/development/compilers/hip/hipamd-config-paths.patch index 605b73f75c7a..78838836e9aa 100644 --- a/pkgs/development/compilers/hip/hipamd-config-paths.patch +++ b/pkgs/development/compilers/hip/hipamd-config-paths.patch @@ -7,7 +7,7 @@ index 89d1224e..120b68c6 100755 endif() else() - set(HIP_CLANG_ROOT "${ROCM_PATH}/llvm") -+ set(HIP_CLANG_ROOT "@llvm@") ++ set(HIP_CLANG_ROOT "@clang@") endif() if(NOT HIP_CXX_COMPILER) set(HIP_CXX_COMPILER ${CMAKE_CXX_COMPILER}) @@ -45,3 +45,29 @@ index 89d1224e..120b68c6 100755 ) endif() endif() +diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt +index 83866d83..4125d3aa 100644 +--- a/src/CMakeLists.txt ++++ b/src/CMakeLists.txt +@@ -178,7 +178,7 @@ if(__HIP_ENABLE_PCH) + ${ROCM_PATH}/llvm) + # find_package(LLVM) returns the lib/cmake/llvm location. We require the root. + if(NOT DEFINED HIP_LLVM_ROOT) +- set(HIP_LLVM_ROOT "${LLVM_DIR}/../../..") ++ set(HIP_LLVM_ROOT "@clang@") + endif() + + execute_process(COMMAND sh -c "${CMAKE_CURRENT_SOURCE_DIR}/hip_embed_pch.sh ${HIP_COMMON_INCLUDE_DIR} ${PROJECT_BINARY_DIR}/include ${PROJECT_SOURCE_DIR}/include ${HIP_LLVM_ROOT}" COMMAND_ECHO STDERR RESULT_VARIABLE EMBED_PCH_RC) +diff --git a/src/hip_embed_pch.sh b/src/hip_embed_pch.sh +index 0a1572b2..aa855d63 100755 +--- a/src/hip_embed_pch.sh ++++ b/src/hip_embed_pch.sh +@@ -149,7 +149,7 @@ EOF + + $LLVM_DIR/bin/clang -cc1 -O3 -emit-pch -triple amdgcn-amd-amdhsa -aux-triple x86_64-unknown-linux-gnu -fcuda-is-device -std=c++17 -fgnuc-version=4.2.1 -o $tmp/hip_wave64.pch -x hip-cpp-output - <$tmp/pch_wave64.cui && + +- $LLVM_DIR/bin/llvm-mc -o hip_pch.o $tmp/hip_pch.mcin --filetype=obj && ++ @llvm@/bin/llvm-mc -o hip_pch.o $tmp/hip_pch.mcin --filetype=obj && + + rm -rf $tmp + }