2021-01-21 17:00:13 +00:00
|
|
|
{ lib, stdenv
|
2020-07-10 18:34:25 +00:00
|
|
|
, fetchFromGitHub
|
2021-09-08 17:12:32 +00:00
|
|
|
, writeScript
|
2020-07-10 18:34:25 +00:00
|
|
|
, cmake
|
|
|
|
, rocm-cmake
|
|
|
|
, clang
|
|
|
|
, rocm-comgr
|
|
|
|
, rocm-opencl-runtime
|
|
|
|
, rocm-runtime
|
|
|
|
, rocm-thunk
|
|
|
|
, libelf
|
|
|
|
, libglvnd
|
|
|
|
, libX11
|
2020-08-21 06:38:43 +00:00
|
|
|
, numactl
|
2020-07-10 18:34:25 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "rocclr";
|
2021-09-02 20:07:20 +00:00
|
|
|
version = "4.3.1";
|
2020-07-10 18:34:25 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "ROCm-Developer-Tools";
|
|
|
|
repo = "ROCclr";
|
2020-08-21 06:38:43 +00:00
|
|
|
rev = "rocm-${version}";
|
2021-09-02 20:07:20 +00:00
|
|
|
hash = "sha256-3lk7Zucoam+11gFBzg/TWQI1L8uAlxTrPz/mDwTwod4=";
|
2020-07-10 18:34:25 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
nativeBuildInputs = [ cmake rocm-cmake ];
|
|
|
|
|
2020-08-07 14:49:18 +00:00
|
|
|
buildInputs = [ clang rocm-comgr rocm-runtime rocm-thunk ];
|
2020-07-10 18:34:25 +00:00
|
|
|
|
2020-08-21 06:38:43 +00:00
|
|
|
propagatedBuildInputs = [ libelf libglvnd libX11 numactl ];
|
2020-07-10 18:34:25 +00:00
|
|
|
|
|
|
|
prePatch = ''
|
|
|
|
substituteInPlace CMakeLists.txt \
|
|
|
|
--replace 'set (CMAKE_LIBRARY_OUTPUT_DIRECTORY ''${CMAKE_CURRENT_BINARY_DIR}/lib)' \
|
2021-02-01 11:38:22 +00:00
|
|
|
'set (CMAKE_LIBRARY_OUTPUT_DIRECTORY ''${CMAKE_INSTALL_LIBDIR})'
|
2020-07-10 18:34:25 +00:00
|
|
|
substituteInPlace device/comgrctx.cpp \
|
|
|
|
--replace "libamd_comgr.so" "${rocm-comgr}/lib/libamd_comgr.so"
|
|
|
|
'';
|
|
|
|
|
|
|
|
cmakeFlags = [
|
|
|
|
"-DOPENCL_DIR=${rocm-opencl-runtime.src}"
|
|
|
|
];
|
|
|
|
|
|
|
|
preFixup = ''
|
2020-11-03 07:50:47 +00:00
|
|
|
# Work around broken cmake files
|
2020-07-10 18:34:25 +00:00
|
|
|
ln -s $out/include/compiler/lib/include/* $out/include
|
2020-11-03 07:50:47 +00:00
|
|
|
ln -s $out/include/elf/elfio $out/include/elfio
|
|
|
|
|
2020-08-21 06:38:43 +00:00
|
|
|
substituteInPlace $out/lib/cmake/rocclr/ROCclrConfig.cmake \
|
|
|
|
--replace "/build/source/build" "$out"
|
2020-07-10 18:34:25 +00:00
|
|
|
'';
|
|
|
|
|
2021-09-08 17:12:32 +00:00
|
|
|
passthru.updateScript = writeScript "update.sh" ''
|
|
|
|
#!/usr/bin/env nix-shell
|
|
|
|
#!nix-shell -i bash -p curl jq common-updater-scripts
|
|
|
|
version="$(curl -sL "https://api.github.com/repos/ROCm-Developer-Tools/ROCclr/tags" | jq '.[].name | split("-") | .[1] | select( . != null )' --raw-output | sort -n | tail -1)"
|
|
|
|
update-source-version rocclr "$version"
|
|
|
|
'';
|
|
|
|
|
2021-01-21 17:00:13 +00:00
|
|
|
meta = with lib; {
|
2020-07-10 18:34:25 +00:00
|
|
|
description = "Radeon Open Compute common language runtime";
|
|
|
|
homepage = "https://github.com/ROCm-Developer-Tools/ROCclr";
|
|
|
|
license = licenses.mit;
|
2021-09-02 20:07:20 +00:00
|
|
|
maintainers = with maintainers; [ lovesegfault ];
|
2020-07-10 18:34:25 +00:00
|
|
|
# rocclr seems to have some AArch64 ifdefs, but does not seem
|
|
|
|
# to be supported yet by the build infrastructure. Recheck in
|
|
|
|
# the future.
|
|
|
|
platforms = [ "x86_64-linux" ];
|
|
|
|
};
|
|
|
|
}
|