From e4459e59a2d29c63ec8cb669b47bdfe4ece59b36 Mon Sep 17 00:00:00 2001 From: Bernardo Meurer Date: Wed, 1 Sep 2021 12:47:49 -0700 Subject: [PATCH 01/13] llvmPackages_rocm: add compiler-rt Co-Authored-By: acowley --- .../compiler-rt/compiler-rt-codesign.patch | 33 +++++++++++ .../llvm/rocm/compiler-rt/default.nix | 57 +++++++++++++++++++ .../compilers/llvm/rocm/default.nix | 25 +++++++- .../llvm/rocm/{lld/default.nix => lld.nix} | 0 4 files changed, 113 insertions(+), 2 deletions(-) create mode 100644 pkgs/development/compilers/llvm/rocm/compiler-rt/compiler-rt-codesign.patch create mode 100644 pkgs/development/compilers/llvm/rocm/compiler-rt/default.nix rename pkgs/development/compilers/llvm/rocm/{lld/default.nix => lld.nix} (100%) diff --git a/pkgs/development/compilers/llvm/rocm/compiler-rt/compiler-rt-codesign.patch b/pkgs/development/compilers/llvm/rocm/compiler-rt/compiler-rt-codesign.patch new file mode 100644 index 000000000000..3cc12b94b200 --- /dev/null +++ b/pkgs/development/compilers/llvm/rocm/compiler-rt/compiler-rt-codesign.patch @@ -0,0 +1,33 @@ +From 3dec5f3475a26aeb4678627795c4b67c6b7b4785 Mon Sep 17 00:00:00 2001 +From: Will Dietz +Date: Tue, 19 Sep 2017 13:13:06 -0500 +Subject: [PATCH] remove codesign use on Apple, disable ios sim testing that + needs it + +--- + cmake/Modules/AddCompilerRT.cmake | 8 ------ + test/asan/CMakeLists.txt | 52 --------------------------------------- + test/tsan/CMakeLists.txt | 47 ----------------------------------- + 3 files changed, 107 deletions(-) + +diff --git a/cmake/Modules/AddCompilerRT.cmake b/cmake/Modules/AddCompilerRT.cmake +index bc5fb9ff7..b64eb4246 100644 +--- a/cmake/Modules/AddCompilerRT.cmake ++++ b/cmake/Modules/AddCompilerRT.cmake +@@ -210,14 +210,6 @@ function(add_compiler_rt_runtime name type) + set_target_properties(${libname} PROPERTIES IMPORT_PREFIX "") + set_target_properties(${libname} PROPERTIES IMPORT_SUFFIX ".lib") + endif() +- if(APPLE) +- # Ad-hoc sign the dylibs +- add_custom_command(TARGET ${libname} +- POST_BUILD +- COMMAND codesign --sign - $ +- WORKING_DIRECTORY ${COMPILER_RT_LIBRARY_OUTPUT_DIR} +- ) +- endif() + endif() + install(TARGETS ${libname} + ARCHIVE DESTINATION ${COMPILER_RT_LIBRARY_INSTALL_DIR} +2.14.1 + diff --git a/pkgs/development/compilers/llvm/rocm/compiler-rt/default.nix b/pkgs/development/compilers/llvm/rocm/compiler-rt/default.nix new file mode 100644 index 000000000000..126ceb6aaa72 --- /dev/null +++ b/pkgs/development/compilers/llvm/rocm/compiler-rt/default.nix @@ -0,0 +1,57 @@ +{ stdenv, lib, version, src, cmake, python3, llvm, libcxxabi }: +stdenv.mkDerivation rec { + pname = "compiler-rt"; + inherit version src; + + nativeBuildInputs = [ cmake python3 llvm ]; + + NIX_CFLAGS_COMPILE = [ + "-DSCUDO_DEFAULT_OPTIONS=DeleteSizeMismatch=0:DeallocationTypeMismatch=0" + ]; + + cmakeFlags = [ + "-DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON" + "-DCMAKE_C_COMPILER_TARGET=${stdenv.hostPlatform.config}" + "-DCMAKE_ASM_COMPILER_TARGET=${stdenv.hostPlatform.config}" + "-DCOMPILER_RT_BUILD_SANITIZERS=OFF" + "-DCOMPILER_RT_BUILD_XRAY=OFF" + "-DCOMPILER_RT_BUILD_LIBFUZZER=OFF" + "-DCOMPILER_RT_BUILD_PROFILE=OFF" + "-DCMAKE_C_COMPILER_WORKS=ON" + "-DCMAKE_CXX_COMPILER_WORKS=ON" + "-DCOMPILER_RT_BAREMETAL_BUILD=ON" + "-DCMAKE_SIZEOF_VOID_P=${toString (stdenv.hostPlatform.parsed.cpu.bits / 8)}" + "-DCOMPILER_RT_BUILD_BUILTINS=ON" + "-DCMAKE_C_FLAGS=-nodefaultlibs" + #https://stackoverflow.com/questions/53633705/cmake-the-c-compiler-is-not-able-to-compile-a-simple-test-program + "-DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY" + ]; + + outputs = [ "out" "dev" ]; + + patches = [ + ./compiler-rt-codesign.patch # Revert compiler-rt commit that makes codesign mandatory + ]; + + + # TSAN requires XPC on Darwin, which we have no public/free source files for. We can depend on the Apple frameworks + # to get it, but they're unfree. Since LLVM is rather central to the stdenv, we patch out TSAN support so that Hydra + # can build this. If we didn't do it, basically the entire nixpkgs on Darwin would have an unfree dependency and we'd + # get no binary cache for the entire platform. If you really find yourself wanting the TSAN, make this controllable by + # a flag and turn the flag off during the stdenv build. + postPatch = lib.optionalString (!stdenv.isDarwin) '' + substituteInPlace cmake/builtin-config-ix.cmake \ + --replace 'set(X86 i386)' 'set(X86 i386 i486 i586 i686)' + ''; + + # Hack around weird upsream RPATH bug + postInstall = '' + ln -s "$out/lib"/*/* "$out/lib" + ln -s $out/lib/*/clang_rt.crtbegin-*.o $out/lib/crtbegin.o + ln -s $out/lib/*/clang_rt.crtend-*.o $out/lib/crtend.o + ln -s $out/lib/*/clang_rt.crtbegin_shared-*.o $out/lib/crtbeginS.o + ln -s $out/lib/*/clang_rt.crtend_shared-*.o $out/lib/crtendS.o + ''; + + enableParallelBuilding = true; +} diff --git a/pkgs/development/compilers/llvm/rocm/default.nix b/pkgs/development/compilers/llvm/rocm/default.nix index 581d05746718..980dd0d395da 100644 --- a/pkgs/development/compilers/llvm/rocm/default.nix +++ b/pkgs/development/compilers/llvm/rocm/default.nix @@ -1,4 +1,4 @@ -{ lib, buildPackages, fetchFromGitHub, callPackage, wrapCCWith }: +{ stdenv, lib, buildPackages, fetchFromGitHub, callPackage, wrapCCWith, overrideCC }: let version = "4.1.0"; @@ -23,12 +23,33 @@ in rec { ''; }; + clangNoCompilerRt = wrapCCWith rec { + cc = clang-unwrapped; + extraBuildCommands = '' + clang_version=`${cc}/bin/clang -v 2>&1 | grep "clang version " | grep -E -o "[0-9.-]+"` + rsrc="$out/resource-root" + mkdir "$rsrc" + ln -s "${cc}/lib/clang/$clang_version/include" "$rsrc" + echo "-resource-dir=$rsrc" >> $out/nix-support/cc-cflags + echo "--gcc-toolchain=${stdenv.cc.cc}" >> $out/nix-support/cc-cflags + echo "-Wno-unused-command-line-argument" >> $out/nix-support/cc-cflags + rm $out/nix-support/add-hardening.sh + touch $out/nix-support/add-hardening.sh + ''; + }; + clang-unwrapped = callPackage ./clang.nix { inherit lld llvm version; src = "${src}/clang"; }; - lld = callPackage ./lld { + compiler-rt = callPackage ./compiler-rt { + inherit version llvm; + src = "${src}/compiler-rt"; + stdenv = overrideCC stdenv clangNoCompilerRt; + }; + + lld = callPackage ./lld.nix { inherit llvm version; src = "${src}/lld"; buildLlvmTools = buildPackages.llvmPackages_rocm; diff --git a/pkgs/development/compilers/llvm/rocm/lld/default.nix b/pkgs/development/compilers/llvm/rocm/lld.nix similarity index 100% rename from pkgs/development/compilers/llvm/rocm/lld/default.nix rename to pkgs/development/compilers/llvm/rocm/lld.nix From e3b026fdba25f31bf542148a11966e926809cf59 Mon Sep 17 00:00:00 2001 From: Bernardo Meurer Date: Thu, 2 Sep 2021 12:20:50 -0700 Subject: [PATCH 02/13] llvmPackages_rocm: 4.1.0 -> 4.3.1 --- pkgs/development/compilers/llvm/rocm/clang.nix | 5 +++-- .../compilers/llvm/rocm/compiler-rt/default.nix | 8 ++++++++ .../development/compilers/llvm/rocm/default.nix | 9 +++++---- pkgs/development/compilers/llvm/rocm/lld.nix | 17 ++++++----------- .../compilers/llvm/rocm/llvm/default.nix | 5 +++-- 5 files changed, 25 insertions(+), 19 deletions(-) diff --git a/pkgs/development/compilers/llvm/rocm/clang.nix b/pkgs/development/compilers/llvm/rocm/clang.nix index d6bfd07d444e..c2844633252e 100644 --- a/pkgs/development/compilers/llvm/rocm/clang.nix +++ b/pkgs/development/compilers/llvm/rocm/clang.nix @@ -1,4 +1,5 @@ -{ lib, stdenv +{ stdenv +, lib , fetchFromGitHub , cmake , python3 @@ -65,7 +66,7 @@ stdenv.mkDerivation rec { description = "ROCm fork of the clang C/C++/Objective-C/Objective-C++ LLVM compiler frontend"; homepage = "https://llvm.org/"; license = with licenses; [ ncsa ]; - maintainers = with maintainers; [ ]; + maintainers = with maintainers; [ acowley danieldk lovesegfault ]; platforms = platforms.linux; }; } diff --git a/pkgs/development/compilers/llvm/rocm/compiler-rt/default.nix b/pkgs/development/compilers/llvm/rocm/compiler-rt/default.nix index 126ceb6aaa72..f05ff91055a5 100644 --- a/pkgs/development/compilers/llvm/rocm/compiler-rt/default.nix +++ b/pkgs/development/compilers/llvm/rocm/compiler-rt/default.nix @@ -54,4 +54,12 @@ stdenv.mkDerivation rec { ''; enableParallelBuilding = true; + + meta = with lib; { + description = "ROCm fork of the LLVM Compiler runtime libraries"; + homepage = "https://github.com/RadeonOpenCompute/llvm-project"; + license = licenses.ncsa; + maintainers = with maintainers; [ acowley danieldk lovesegfault ]; + platforms = platforms.linux; + }; } diff --git a/pkgs/development/compilers/llvm/rocm/default.nix b/pkgs/development/compilers/llvm/rocm/default.nix index 980dd0d395da..3497f910d6dc 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 = "4.1.0"; + version = "4.3.1"; src = fetchFromGitHub { owner = "RadeonOpenCompute"; repo = "llvm-project"; rev = "rocm-${version}"; - hash = "sha256-DlId/dF5r0ULl2omYPCyu1Ic3XKlLL7ndiCA0RaF264="; + hash = "sha256-7XVtHcrTpw+NYUvuKQFWWFE0FlOTt8EnfZpvepQqE1c="; }; in rec { clang = wrapCCWith rec { @@ -15,8 +15,10 @@ in rec { clang_version=`${cc}/bin/clang -v 2>&1 | grep "clang version " | grep -E -o "[0-9.-]+"` rsrc="$out/resource-root" mkdir "$rsrc" - ln -s "${lib.getLib cc}/lib/clang/$clang_version/include" "$rsrc" + ln -s "${cc}/lib/clang/$clang_version/include" "$rsrc" + ln -s "${compiler-rt}/lib" "$rsrc/lib" echo "-resource-dir=$rsrc" >> $out/nix-support/cc-cflags + echo "--gcc-toolchain=${stdenv.cc.cc}" >> $out/nix-support/cc-cflags echo "-Wno-unused-command-line-argument" >> $out/nix-support/cc-cflags rm $out/nix-support/add-hardening.sh touch $out/nix-support/add-hardening.sh @@ -52,7 +54,6 @@ in rec { lld = callPackage ./lld.nix { inherit llvm version; src = "${src}/lld"; - buildLlvmTools = buildPackages.llvmPackages_rocm; }; llvm = callPackage ./llvm { diff --git a/pkgs/development/compilers/llvm/rocm/lld.nix b/pkgs/development/compilers/llvm/rocm/lld.nix index c8ca83f76c12..ae153f5e0de0 100644 --- a/pkgs/development/compilers/llvm/rocm/lld.nix +++ b/pkgs/development/compilers/llvm/rocm/lld.nix @@ -1,5 +1,5 @@ -{ lib, stdenv -, buildLlvmTools +{ stdenv +, lib , cmake , libxml2 , llvm @@ -14,18 +14,13 @@ stdenv.mkDerivation rec { pname = "lld"; nativeBuildInputs = [ cmake ]; + buildInputs = [ libxml2 llvm ]; - - cmakeFlags = [ - "-DLLVM_MAIN_SRC_DIR=${llvm.src}" - ] ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [ - "-DLLVM_TABLEGEN_EXE=${buildLlvmTools.llvm}/bin/llvm-tblgen" - "-DLLVM_CONFIG_PATH=${llvm.dev}/bin/llvm-config-native" - ]; - outputs = [ "out" "dev" ]; + cmakeFlags = [ "-DLLVM_MAIN_SRC_DIR=${llvm.src}" ]; + postInstall = '' moveToOutput include "$dev" moveToOutput lib "$dev" @@ -39,7 +34,7 @@ stdenv.mkDerivation rec { description = "ROCm fork of the LLVM Linker"; homepage = "https://github.com/RadeonOpenCompute/llvm-project"; license = licenses.ncsa; - maintainers = with maintainers; [ ]; + maintainers = with maintainers; [ acowley danieldk lovesegfault ]; platforms = platforms.linux; }; } diff --git a/pkgs/development/compilers/llvm/rocm/llvm/default.nix b/pkgs/development/compilers/llvm/rocm/llvm/default.nix index 6d1ff664972d..05b6d9de0869 100644 --- a/pkgs/development/compilers/llvm/rocm/llvm/default.nix +++ b/pkgs/development/compilers/llvm/rocm/llvm/default.nix @@ -1,4 +1,5 @@ -{ lib, stdenv +{ stdenv +, lib , fetchFromGitHub , cmake , python3 @@ -91,7 +92,7 @@ in stdenv.mkDerivation rec { description = "ROCm fork of the LLVM compiler infrastructure"; homepage = "https://github.com/RadeonOpenCompute/llvm-project"; license = with licenses; [ ncsa ]; - maintainers = with maintainers; [ ]; + maintainers = with maintainers; [ acowley danieldk lovesegfault ]; platforms = platforms.linux; }; } From bd698dbd7ee62c11bfc03a9d648c1caa98639fcf Mon Sep 17 00:00:00 2001 From: Bernardo Meurer Date: Thu, 2 Sep 2021 12:27:22 -0700 Subject: [PATCH 03/13] rocm-cmake: 4.1.0 -> 4.3.1 --- pkgs/development/tools/build-managers/rocm-cmake/default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/development/tools/build-managers/rocm-cmake/default.nix b/pkgs/development/tools/build-managers/rocm-cmake/default.nix index 68cd3d449cad..31f4265597fe 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 = "4.1.0"; + version = "4.3.1"; src = fetchFromGitHub { owner = "RadeonOpenCompute"; repo = "rocm-cmake"; rev = "rocm-${version}"; - hash = "sha256-uK060F7d7/pTCNbGqdKCzxgPrPPbGjNwuUOt176z7EM="; + hash = "sha256-BhpYOL7+IlBpkzeFjfy6KLO7ail472KQWFfQX/sXLGo="; }; nativeBuildInputs = [ cmake ]; From 4fa55823c32762275b92efffc6266a5f1c389599 Mon Sep 17 00:00:00 2001 From: Bernardo Meurer Date: Thu, 2 Sep 2021 12:30:10 -0700 Subject: [PATCH 04/13] rocm-comgr: 4.1.0 -> 4.3.1 --- pkgs/development/libraries/rocm-comgr/default.nix | 10 +++++----- pkgs/top-level/all-packages.nix | 1 - 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/pkgs/development/libraries/rocm-comgr/default.nix b/pkgs/development/libraries/rocm-comgr/default.nix index 95fe28ce9fd3..52a3cb6784d6 100644 --- a/pkgs/development/libraries/rocm-comgr/default.nix +++ b/pkgs/development/libraries/rocm-comgr/default.nix @@ -1,21 +1,21 @@ -{ lib, stdenv, fetchFromGitHub, cmake, clang, device-libs, lld, llvm }: +{ lib, stdenv, fetchFromGitHub, cmake, clang, rocm-device-libs, lld, llvm }: stdenv.mkDerivation rec { pname = "rocm-comgr"; - version = "4.1.0"; + version = "4.3.1"; src = fetchFromGitHub { owner = "RadeonOpenCompute"; repo = "ROCm-CompilerSupport"; rev = "rocm-${version}"; - hash = "sha256-LbQqyJxRqb6vpXiYSkRlF1FeqXJJXktPafGmYDDK02U="; + hash = "sha256-wHSAhp1cqR9xOreGt2M2Td/ELCuLEHjpMRRkqE9dUy0="; }; sourceRoot = "source/lib/comgr"; nativeBuildInputs = [ cmake ]; - buildInputs = [ clang device-libs lld llvm ]; + buildInputs = [ clang rocm-device-libs lld llvm ]; cmakeFlags = [ "-DCLANG=${clang}/bin/clang" @@ -40,7 +40,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; [ ]; + maintainers = with maintainers; [ lovesegfault ]; platforms = platforms.linux; }; } diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index baf61f2b9b54..24ae41cccf53 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -12150,7 +12150,6 @@ with pkgs; rocm-comgr = callPackage ../development/libraries/rocm-comgr { inherit (llvmPackages_rocm) clang lld llvm; - device-libs = rocm-device-libs; }; rocm-device-libs = callPackage ../development/libraries/rocm-device-libs { From 416576036e872330a68be44fd9b35016230bf357 Mon Sep 17 00:00:00 2001 From: Bernardo Meurer Date: Thu, 2 Sep 2021 12:31:48 -0700 Subject: [PATCH 05/13] rocm-device-libs: 4.1.0 -> 4.3.1 --- pkgs/development/libraries/rocm-device-libs/default.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkgs/development/libraries/rocm-device-libs/default.nix b/pkgs/development/libraries/rocm-device-libs/default.nix index 383d91bd08c1..77dd4b721f2a 100644 --- a/pkgs/development/libraries/rocm-device-libs/default.nix +++ b/pkgs/development/libraries/rocm-device-libs/default.nix @@ -9,13 +9,13 @@ stdenv.mkDerivation rec { pname = "rocm-device-libs"; - version = "4.1.0"; + version = "4.3.1"; src = fetchFromGitHub { owner = "RadeonOpenCompute"; repo = "ROCm-Device-Libs"; rev = "rocm-${version}"; - hash = "sha256-9p6PIXdHFIgHgNWZzqVz5O9i2Np0z/iyxodG2cLrpGs="; + hash = "sha256-fPD9vevO2UDaFaclSI0CC/lRfM5WemWmxP1K5ajXHbk="; }; nativeBuildInputs = [ cmake ]; @@ -34,7 +34,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; [ ]; + maintainers = with maintainers; [ lovesegfault ]; platforms = platforms.linux; }; } From ff514b0737d549b0ed49e95ef8b04f54181a9c81 Mon Sep 17 00:00:00 2001 From: Bernardo Meurer Date: Thu, 2 Sep 2021 12:54:58 -0700 Subject: [PATCH 06/13] rocm-thunk: 4.1.0 -> 4.3.1 --- 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 770dd16740ca..432688e1bfb5 100644 --- a/pkgs/development/libraries/rocm-thunk/default.nix +++ b/pkgs/development/libraries/rocm-thunk/default.nix @@ -7,13 +7,13 @@ stdenv.mkDerivation rec { pname = "rocm-thunk"; - version = "4.1.0"; + version = "4.3.1"; src = fetchFromGitHub { owner = "RadeonOpenCompute"; repo = "ROCT-Thunk-Interface"; rev = "rocm-${version}"; - hash = "sha256-gdto7BbrSRa3UiRNvTW1KLkHyjrcxdah4+L+1Gdm0wA="; + hash = "sha256-jpwFL4UbEnWkw1AiM4U1s1t7GiqzBeOwa55VpnOG2Dk="; }; preConfigure = '' @@ -32,6 +32,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; [ ]; + maintainers = with maintainers; [ lovesegfault ]; }; } From 9d96c4004821ca5c97399bbfda65108c634d297c Mon Sep 17 00:00:00 2001 From: Bernardo Meurer Date: Thu, 2 Sep 2021 12:57:12 -0700 Subject: [PATCH 07/13] rocm-runtime: 4.1.0 -> 4.3.1 --- pkgs/development/libraries/rocm-runtime/default.nix | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/pkgs/development/libraries/rocm-runtime/default.nix b/pkgs/development/libraries/rocm-runtime/default.nix index eb4ce3c19fb6..fc3c627a5628 100644 --- a/pkgs/development/libraries/rocm-runtime/default.nix +++ b/pkgs/development/libraries/rocm-runtime/default.nix @@ -1,4 +1,5 @@ -{ lib, stdenv +{ stdenv +, lib , fetchFromGitHub , addOpenGLRunpath , clang-unwrapped @@ -6,25 +7,26 @@ , xxd , elfutils , llvm +, numactl , rocm-device-libs , rocm-thunk }: stdenv.mkDerivation rec { pname = "rocm-runtime"; - version = "4.1.0"; + version = "4.3.1"; src = fetchFromGitHub { owner = "RadeonOpenCompute"; repo = "ROCR-Runtime"; rev = "rocm-${version}"; - hash = "sha256-Jxg3n203tV0L+UrmeQEuzX0TKpFu5An2cnuEA/F/SNY="; + hash = "sha256-B67v9B8LXDbWNxYNRxM3dgFFLjFSyJmm0zd3G5Bgvek="; }; sourceRoot = "source/src"; nativeBuildInputs = [ cmake xxd ]; - buildInputs = [ clang-unwrapped elfutils llvm ]; + buildInputs = [ clang-unwrapped elfutils llvm numactl ]; cmakeFlags = [ "-DBITCODE_DIR=${rocm-device-libs}/amdgcn/bitcode" @@ -43,6 +45,6 @@ stdenv.mkDerivation rec { description = "Platform runtime for ROCm"; homepage = "https://github.com/RadeonOpenCompute/ROCR-Runtime"; license = with licenses; [ ncsa ]; - maintainers = with maintainers; [ ]; + maintainers = with maintainers; [ danieldk lovesegfault ]; }; } From fae3bbca9b273097e71aa8615422faff169d4a91 Mon Sep 17 00:00:00 2001 From: Bernardo Meurer Date: Thu, 2 Sep 2021 13:03:18 -0700 Subject: [PATCH 08/13] rocm-smi: 4.1.0 -> 4.3.1 --- pkgs/tools/system/rocm-smi/default.nix | 10 +++++----- pkgs/top-level/all-packages.nix | 3 +-- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/pkgs/tools/system/rocm-smi/default.nix b/pkgs/tools/system/rocm-smi/default.nix index de9afdae2940..bbee315e9c70 100644 --- a/pkgs/tools/system/rocm-smi/default.nix +++ b/pkgs/tools/system/rocm-smi/default.nix @@ -1,17 +1,17 @@ -{ lib, stdenv, fetchFromGitHub, cmake, python3 }: +{ lib, stdenv, fetchFromGitHub, cmake, wrapPython }: stdenv.mkDerivation rec { pname = "rocm-smi"; - version = "4.1.0"; + version = "4.3.1"; src = fetchFromGitHub { owner = "RadeonOpenCompute"; repo = "rocm_smi_lib"; rev = "rocm-${version}"; - hash = "sha256-LEaC1XhmyoVWrpL05MhgN02LVT2rLKdnw9g2QdfM/uE="; + hash = "sha256-Ckno73Otkc9rHEUkSgNoOui+6ZHGUF+B9iAoe0NQH0c="; }; - nativeBuildInputs = [ cmake python3.pkgs.wrapPython ]; + nativeBuildInputs = [ cmake wrapPython ]; postPatch = '' # Upstream ROCm is installed in an /opt directory. For this reason, @@ -46,7 +46,7 @@ stdenv.mkDerivation rec { description = "System management interface for AMD GPUs supported by ROCm"; homepage = "https://github.com/RadeonOpenCompute/ROC-smi"; license = with licenses; [ mit ]; - maintainers = with maintainers; [ ]; + maintainers = with maintainers; [ lovesegfault ]; platforms = [ "x86_64-linux" ]; }; } diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 24ae41cccf53..5ad61129d421 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -12166,8 +12166,7 @@ with pkgs; inherit (llvmPackages_rocm) clang-unwrapped llvm; }; - # Python >= 3.8 still gives a bunch of warnings. - rocm-smi = python37.pkgs.callPackage ../tools/system/rocm-smi { }; + rocm-smi = python3Packages.callPackage ../tools/system/rocm-smi { }; rocm-thunk = callPackage ../development/libraries/rocm-thunk { }; From d212d1bbb4b18892e3c29b8af278f69427ce8e94 Mon Sep 17 00:00:00 2001 From: Bernardo Meurer Date: Thu, 2 Sep 2021 13:07:20 -0700 Subject: [PATCH 09/13] rocclr: 4.1.0 -> 4.3.1 --- 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 cf085d50edb0..c96753f9a4b2 100644 --- a/pkgs/development/libraries/rocclr/default.nix +++ b/pkgs/development/libraries/rocclr/default.nix @@ -15,13 +15,13 @@ stdenv.mkDerivation rec { pname = "rocclr"; - version = "4.1.0"; + version = "4.3.1"; src = fetchFromGitHub { owner = "ROCm-Developer-Tools"; repo = "ROCclr"; rev = "rocm-${version}"; - hash = "sha256-2DI/PL29aiZcxOrGZBzXwAnNgZQpSDjyyGKgl+vDErk="; + hash = "sha256-3lk7Zucoam+11gFBzg/TWQI1L8uAlxTrPz/mDwTwod4="; }; nativeBuildInputs = [ cmake rocm-cmake ]; @@ -55,7 +55,7 @@ stdenv.mkDerivation rec { description = "Radeon Open Compute common language runtime"; homepage = "https://github.com/ROCm-Developer-Tools/ROCclr"; license = licenses.mit; - maintainers = with maintainers; [ ]; + maintainers = with maintainers; [ lovesegfault ]; # rocclr seems to have some AArch64 ifdefs, but does not seem # to be supported yet by the build infrastructure. Recheck in # the future. From 0bfc804da20e1dd77a99568c9ea503fb1352ccf9 Mon Sep 17 00:00:00 2001 From: Bernardo Meurer Date: Thu, 2 Sep 2021 13:07:48 -0700 Subject: [PATCH 10/13] rocm-opencl-runtime: 4.1.0 -> 4.3.1 --- .../libraries/rocm-opencl-runtime/default.nix | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/pkgs/development/libraries/rocm-opencl-runtime/default.nix b/pkgs/development/libraries/rocm-opencl-runtime/default.nix index 40ffcae79246..04fba42525ed 100644 --- a/pkgs/development/libraries/rocm-opencl-runtime/default.nix +++ b/pkgs/development/libraries/rocm-opencl-runtime/default.nix @@ -1,4 +1,5 @@ -{ lib, stdenv +{ stdenv +, lib , fetchFromGitHub , addOpenGLRunpath , cmake @@ -21,13 +22,13 @@ stdenv.mkDerivation rec { pname = "rocm-opencl-runtime"; - version = "4.1.0"; + version = "4.3.1"; src = fetchFromGitHub { owner = "RadeonOpenCompute"; repo = "ROCm-OpenCL-Runtime"; rev = "rocm-${version}"; - hash = "sha256-+6h1E5uWNKjjaeO5ZIi854CWYi0QGQ5mVUHdi9+4vX4="; + hash = "sha256-4+PNxRqvAvU0Nj2igYl3WiS5h5HGV63J+cHbIVW89LE="; }; nativeBuildInputs = [ cmake rocm-cmake ]; @@ -77,7 +78,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; [ ]; + maintainers = with maintainers; [ acowley danieldk lovesegfault ]; platforms = platforms.linux; }; } From 0a8c0cfa8bc9456cc13a483b75ec68a331b8b687 Mon Sep 17 00:00:00 2001 From: Bernardo Meurer Date: Thu, 2 Sep 2021 12:32:34 -0700 Subject: [PATCH 11/13] rocm-opencl-icd: add lovesegfault as maintainer --- pkgs/development/libraries/rocm-opencl-icd/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/development/libraries/rocm-opencl-icd/default.nix b/pkgs/development/libraries/rocm-opencl-icd/default.nix index 0a9d124561e2..9b0f7ab9f81f 100644 --- a/pkgs/development/libraries/rocm-opencl-icd/default.nix +++ b/pkgs/development/libraries/rocm-opencl-icd/default.nix @@ -14,7 +14,7 @@ stdenv.mkDerivation rec { meta = with lib; { description = "OpenCL ICD definition for AMD GPUs using the ROCm stack"; license = licenses.mit; - maintainers = with maintainers; [ ]; + maintainers = with maintainers; [ lovesegfault ]; platforms = platforms.linux; }; } From 715eea832f66b5d81fd711afa307640e91870d27 Mon Sep 17 00:00:00 2001 From: Bernardo Meurer Date: Wed, 1 Sep 2021 12:50:22 -0700 Subject: [PATCH 12/13] rocminfo: init at 4.3.1 Co-Authored-By: acowley --- pkgs/development/tools/rocminfo/default.nix | 38 +++++++++++++++++++++ pkgs/top-level/all-packages.nix | 2 ++ 2 files changed, 40 insertions(+) create mode 100644 pkgs/development/tools/rocminfo/default.nix diff --git a/pkgs/development/tools/rocminfo/default.nix b/pkgs/development/tools/rocminfo/default.nix new file mode 100644 index 000000000000..bf95e15873fa --- /dev/null +++ b/pkgs/development/tools/rocminfo/default.nix @@ -0,0 +1,38 @@ +{ stdenv, lib, fetchFromGitHub, fetchpatch, cmake, rocm-runtime, python3, rocm-cmake, busybox, gnugrep + # rocminfo requires that the calling user have a password and be in + # the video group. If we let rocm_agent_enumerator rely upon + # rocminfo's output, then it, too, has those requirements. Instead, + # we can specify the GPU targets for this system (e.g. "gfx803" for + # Polaris) such that no system call is needed for downstream + # compilers to determine the desired target. +, defaultTargets ? []}: +stdenv.mkDerivation rec { + version = "4.3.1"; + pname = "rocminfo"; + src = fetchFromGitHub { + owner = "RadeonOpenCompute"; + repo = "rocminfo"; + rev = "rocm-${version}"; + sha256 = "sha256-n80tiSVaPTFl4imZvoFENM4KhPLxgDKz5VlOvhEYlV0="; + }; + + enableParallelBuilding = true; + buildInputs = [ cmake rocm-cmake rocm-runtime ]; + cmakeFlags = [ + "-DROCM_DIR=${rocm-runtime}" + "-DROCRTST_BLD_TYPE=Release" + ]; + + prePatch = '' + sed 's,#!/usr/bin/env python3,#!${python3}/bin/python,' -i rocm_agent_enumerator + sed 's,lsmod | grep ,${busybox}/bin/lsmod | ${gnugrep}/bin/grep ,' -i rocminfo.cc + ''; + + installPhase = '' + mkdir -p $out/bin + cp rocminfo $out/bin + cp rocm_agent_enumerator $out/bin + '' + lib.optionalString (defaultTargets != []) '' + echo '${lib.concatStringsSep "\n" defaultTargets}' > $out/bin/target.lst + ''; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 5ad61129d421..344426061747 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -12170,6 +12170,8 @@ with pkgs; rocm-thunk = callPackage ../development/libraries/rocm-thunk { }; + rocminfo = callPackage ../development/tools/rocminfo { }; + rtags = callPackage ../development/tools/rtags { inherit (darwin) apple_sdk; }; From 75125b85d0e7be6a59c374bb830ce05a79bd9df2 Mon Sep 17 00:00:00 2001 From: Bernardo Meurer Date: Wed, 1 Sep 2021 12:51:43 -0700 Subject: [PATCH 13/13] hip: init at 4.3.1 Co-Authored-By: acowley --- pkgs/development/compilers/hip/default.nix | 166 +++++++++++++++++++++ pkgs/top-level/all-packages.nix | 4 + 2 files changed, 170 insertions(+) create mode 100644 pkgs/development/compilers/hip/default.nix diff --git a/pkgs/development/compilers/hip/default.nix b/pkgs/development/compilers/hip/default.nix new file mode 100644 index 000000000000..ff5a34330ede --- /dev/null +++ b/pkgs/development/compilers/hip/default.nix @@ -0,0 +1,166 @@ +{ stdenv +, binutils-unwrapped +, clang +, clang-unwrapped +, cmake +, compiler-rt +, fetchFromGitHub +, fetchpatch +, file +, lib +, lld +, llvm +, makeWrapper +, perl +, python +, rocclr +, rocm-comgr +, rocm-device-libs +, rocm-opencl-runtime +, rocm-runtime +, rocm-thunk +, rocminfo +, writeText +}: + +stdenv.mkDerivation rec { + name = "hip"; + version = "4.3.1"; + src = fetchFromGitHub { + owner = "ROCm-Developer-Tools"; + repo = "HIP"; + rev = "rocm-${version}"; + sha256 = "sha256-dUdP32H0u6kVItS+VUE549vvxkV1mSN84HvyfeK2hEE="; + }; + + # FIXME: https://github.com/ROCm-Developer-Tools/HIP/issues/2317 + postPatch = '' + cp ${rocm-opencl-runtime.src}/amdocl/cl_vk_amd.hpp amdocl/ + ''; + + nativeBuildInputs = [ cmake python makeWrapper ]; + propagatedBuildInputs = [ + clang + compiler-rt + lld + llvm + rocclr + rocm-comgr + rocm-device-libs + rocm-runtime + rocm-thunk + rocminfo + ]; + + preConfigure = '' + export HIP_CLANG_PATH=${clang}/bin + export DEVICE_LIB_PATH=${rocm-device-libs}/lib + ''; + + # The patch version is the last two digits of year + week number + + # day in the week: date -d "2021-07-25" +%y%U%w + workweek = "21300"; + + cmakeFlags = [ + "-DHSA_PATH=${rocm-runtime}" + "-DHIP_COMPILER=clang" + "-DHIP_PLATFORM=amd" + "-DHIP_VERSION_GITDATE=${workweek}" + "-DCMAKE_C_COMPILER=${clang}/bin/clang" + "-DCMAKE_CXX_COMPILER=${clang}/bin/clang++" + "-DLLVM_ENABLE_RTTI=ON" + "-DLIBROCclr_STATIC_DIR=${rocclr}/lib/cmake" + "-DROCclr_DIR=${rocclr}" + "-DHIP_CLANG_ROOT=${clang-unwrapped}" + ]; + + patches = [ + (fetchpatch { + name = "no-git-during-build"; + url = "https://github.com/acowley/HIP/commit/310b7e972cfb23216250c0240ba6134741679aee.patch"; + sha256 = "08ky7v1yvajabn9m5x3afzrnz38gnrgc7vgqlbyr7s801c383ha1"; + }) + (fetchpatch { + name = "use-PATH-when-compiling-pch"; + url = "https://github.com/acowley/HIP/commit/bfb4dd1eafa9714a2c05a98229cc35ffa3429b37.patch"; + sha256 = "1wp0m32df7pf4rhx3k5n750fd7kz10zr60z0wllb0mw6h00w6xpz"; + }) + ]; + + # - fix bash paths + # - fix path to rocm_agent_enumerator + # - fix hcc path + # - fix hcc version parsing + # - add linker flags for libhsa-runtime64 and hc_am since libhip_hcc + # refers to them. + prePatch = '' + for f in $(find bin -type f); do + sed -e 's,#!/usr/bin/perl,#!${perl}/bin/perl,' \ + -e 's,#!/bin/bash,#!${stdenv.shell},' \ + -i "$f" + done + + for f in $(find . -regex '.*\.cpp\|.*\.h\(pp\)?'); do + if grep -q __hcc_workweek__ "$f" ; then + substituteInPlace "$f" --replace '__hcc_workweek__' '${workweek}' + fi + done + + sed 's,#!/usr/bin/python,#!${python}/bin/python,' -i hip_prof_gen.py + + sed -e 's,$ROCM_AGENT_ENUM = "''${ROCM_PATH}/bin/rocm_agent_enumerator";,$ROCM_AGENT_ENUM = "${rocminfo}/bin/rocm_agent_enumerator";,' \ + -e "s,^\($HIP_LIB_PATH=\).*$,\1\"$out/lib\";," \ + -e 's,^\($HIP_CLANG_PATH=\).*$,\1"${clang}/bin";,' \ + -e 's,^\($DEVICE_LIB_PATH=\).*$,\1"${rocm-device-libs}/amdgcn/bitcode";,' \ + -e 's,^\($HIP_COMPILER=\).*$,\1"clang";,' \ + -e 's,^\($HIP_RUNTIME=\).*$,\1"ROCclr";,' \ + -e 's,^\([[:space:]]*$HSA_PATH=\).*$,\1"${rocm-runtime}";,'g \ + -e 's,\([[:space:]]*$HOST_OSNAME=\).*,\1"nixos";,' \ + -e 's,\([[:space:]]*$HOST_OSVER=\).*,\1"${lib.versions.majorMinor lib.version}";,' \ + -e 's,^\([[:space:]]*\)$HIP_CLANG_INCLUDE_PATH = abs_path("$HIP_CLANG_PATH/../lib/clang/$HIP_CLANG_VERSION/include");,\1$HIP_CLANG_INCLUDE_PATH = "${clang-unwrapped}/lib/clang/$HIP_CLANG_VERSION/include";,' \ + -e 's,^\([[:space:]]*$HIPCXXFLAGS .= " -isystem $HIP_CLANG_INCLUDE_PATH\)";,\1 -isystem ${rocm-runtime}/include";,' \ + -e 's,\($HIPCXXFLAGS .= " -isystem \\"$HIP_INCLUDE_PATH\\"\)" ;,\1 --rocm-path=${rocclr}";,' \ + -e "s,\$HIP_PATH/\(bin\|lib\),$out/\1,g" \ + -e "s,^\$HIP_LIB_PATH=\$ENV{'HIP_LIB_PATH'};,\$HIP_LIB_PATH=\"$out/lib\";," \ + -e 's,`file,`${file}/bin/file,g' \ + -e 's,`readelf,`${binutils-unwrapped}/bin/readelf,' \ + -e 's, ar , ${binutils-unwrapped}/bin/ar ,g' \ + -i bin/hipcc + + sed -e 's,^\($HSA_PATH=\).*$,\1"${rocm-runtime}";,' \ + -e 's,^\($HIP_CLANG_PATH=\).*$,\1"${clang}/bin";,' \ + -e 's,^\($HIP_PLATFORM=\).*$,\1"amd";,' \ + -e 's,$HIP_CLANG_PATH/llc,${llvm}/bin/llc,' \ + -e 's, abs_path, Cwd::abs_path,' \ + -i bin/hipconfig + + sed -e 's, abs_path, Cwd::abs_path,' -i bin/hipvars.pm + + sed -e 's|_IMPORT_PREFIX}/../include|_IMPORT_PREFIX}/include|g' \ + -e 's|''${HIP_CLANG_ROOT}/lib/clang/\*/include|${clang-unwrapped}/lib/clang/*/include|' \ + -i hip-config.cmake.in + ''; + + preInstall = '' + mkdir -p $out/lib/cmake + ''; + + # The upstream ROCclr setup wants everything built into the same + # ROCclr output directory. We copy things into the HIP output + # directory, since it is downstream of ROCclr in terms of dependency + # direction. Thus we have device-libs and rocclr pieces in the HIP + # output directory. + postInstall = '' + mkdir -p $out/share + mv $out/lib/cmake $out/share/ + mv $out/cmake/* $out/share/cmake/hip + mkdir -p $out/lib + ln -s ${rocm-device-libs}/lib $out/lib/bitcode + mkdir -p $out/include + ln -s ${clang-unwrapped}/lib/clang/11.0.0/include $out/include/clang + ln -s ${rocclr}/lib/*.* $out/lib + ln -s ${rocclr}/include/* $out/include + wrapProgram $out/bin/hipcc --set HIP_PATH $out --set HSA_PATH ${rocm-runtime} --set HIP_CLANG_PATH ${clang}/bin --prefix PATH : ${lld}/bin --set NIX_CC_WRAPPER_TARGET_HOST_${stdenv.cc.suffixSalt} 1 --prefix NIX_LDFLAGS ' ' -L${compiler-rt}/lib --prefix NIX_LDFLAGS_FOR_TARGET ' ' -L${compiler-rt}/lib + wrapProgram $out/bin/hipconfig --set HIP_PATH $out --set HSA_PATH ${rocm-runtime} --set HIP_CLANG_PATH ${clang}/bin + ''; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 344426061747..096bdad3f847 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -12146,6 +12146,10 @@ with pkgs; inherit (llvmPackages_rocm) clang; }; + hip = callPackage ../development/compilers/hip { + inherit (llvmPackages_rocm) clang clang-unwrapped compiler-rt lld llvm; + }; + rocm-cmake = callPackage ../development/tools/build-managers/rocm-cmake { }; rocm-comgr = callPackage ../development/libraries/rocm-comgr {