Merge pull request #187005 from Flakebi/rocm

rocm: 5.1.0 → 5.2.1
This commit is contained in:
Bernardo Meurer 2022-08-17 10:45:06 -07:00 committed by GitHub
commit 67c247cb5e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 335 additions and 309 deletions

View file

@ -1,9 +1,7 @@
{ stdenv
, binutils-unwrapped
, clang
, clang-unwrapped
, cmake
, compiler-rt
, fetchFromGitHub
, fetchpatch
, file
@ -11,7 +9,6 @@
, libglvnd
, libX11
, libxml2
, lld
, llvm
, makeWrapper
, numactl
@ -31,13 +28,13 @@
let
hip = stdenv.mkDerivation rec {
pname = "hip";
version = "5.1.1";
version = "5.2.1";
src = fetchFromGitHub {
owner = "ROCm-Developer-Tools";
repo = "HIP";
rev = "rocm-${version}";
hash = "sha256-/kIZrbzq1u1pIs1jlmRYZNUGteqVQTI4TlXsHsVIUKE=";
hash = "sha256-aXI55bdhAuPUEdQZukKAdtLWA+8UIxjPJ4LTamR/ENk=";
};
# - fix bash paths
@ -63,8 +60,9 @@ let
-e 's,^\($HIP_COMPILER=\).*$,\1"clang";,' \
-e 's,^\($HIP_RUNTIME=\).*$,\1"ROCclr";,' \
-e 's,^\([[:space:]]*$HSA_PATH=\).*$,\1"${rocm-runtime}";,'g \
-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:]]*\)$HIP_CLANG_INCLUDE_PATH = abs_path("$HIP_CLANG_PATH/../lib/clang/$HIP_CLANG_VERSION/include");,\1$HIP_CLANG_INCLUDE_PATH = "${llvm}/lib/clang/$HIP_CLANG_VERSION/include";,' \
-e 's,^\([[:space:]]*$HIPCXXFLAGS .= " -isystem \\"$HIP_CLANG_INCLUDE_PATH/..\\"\)";,\1 -isystem ${rocm-runtime}/include";,' \
-e 's,$HIP_CLANG_PATH/../lib/clang/$HIP_CLANG_VERSION,$HIP_CLANG_PATH/../resource-root,g' \
-e 's,`file,`${file}/bin/file,g' \
-e 's,`readelf,`${binutils-unwrapped}/bin/readelf,' \
-e 's, ar , ${binutils-unwrapped}/bin/ar ,g' \
@ -102,21 +100,19 @@ let
in
stdenv.mkDerivation rec {
pname = "hip";
version = "5.1.1";
version = "5.2.1";
src = fetchFromGitHub {
owner = "ROCm-Developer-Tools";
repo = "hipamd";
rev = "rocm-${version}";
hash = "sha256-TuCMRJb6G/bhD8hG6Ot7MIkgBoShjVboeXrlGh9eYpQ=";
hash = "sha256-YsvM+HjoBiukXAMCdE/dpQNMnpP6XRXDuxV1487rok0=";
};
nativeBuildInputs = [ cmake python3 makeWrapper perl ];
buildInputs = [ libxml2 numactl libglvnd libX11 ];
propagatedBuildInputs = [
clang
compiler-rt
lld
llvm
rocm-comgr
rocm-device-libs
@ -139,15 +135,37 @@ stdenv.mkDerivation rec {
];
postInstall = ''
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 --add-flags "-nogpuinc"
patchShebangs $out/bin
wrapProgram $out/bin/hipcc --set HIP_PATH $out --set HSA_PATH ${rocm-runtime} --set HIP_CLANG_PATH ${clang}/bin --prefix PATH : ${llvm}/bin --set ROCM_PATH $out
wrapProgram $out/bin/hipconfig --set HIP_PATH $out --set HSA_PATH ${rocm-runtime} --set HIP_CLANG_PATH ${clang}/bin
'';
passthru.updateScript = writeScript "update.sh" ''
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p curl jq common-updater-scripts
#!nix-shell -i bash -p curl jq common-updater-scripts nix-prefetch-github
version="$(curl -sL "https://api.github.com/repos/ROCm-Developer-Tools/HIP/tags" | jq '.[].name | split("-") | .[1] | select( . != null )' --raw-output | sort -n | tail -1)"
current_version="$(grep "version =" pkgs/development/compilers/hip/default.nix | head -n1 | cut -d'"' -f2)"
if [[ "$version" != "$current_version" ]]; then
tarball_meta="$(nix-prefetch-github ROCm-Developer-Tools HIP --rev "rocm-$version")"
tarball_hash="$(nix to-base64 sha256-$(jq -r '.sha256' <<< "$tarball_meta"))"
sed -i -z "pkgs/development/compilers/hip/default.nix" \
-e 's,version = "[^'"'"'"]*",version = "'"$version"'",1' \
-e 's,hash = "[^'"'"'"]*",hash = "sha256-'"$tarball_hash"'",1'
else
echo hip already up-to-date
fi
version="$(curl -sL "https://api.github.com/repos/ROCm-Developer-Tools/hipamd/tags" | jq '.[].name | split("-") | .[1] | select( . != null )' --raw-output | sort -n | tail -1)"
update-source-version hip "$version"
current_version="$(grep "version =" pkgs/development/compilers/hip/default.nix | tail -n1 | cut -d'"' -f2)"
if [[ "$version" != "$current_version" ]]; then
tarball_meta="$(nix-prefetch-github ROCm-Developer-Tools hipamd --rev "rocm-$version")"
tarball_hash="$(nix to-base64 sha256-$(jq -r '.sha256' <<< "$tarball_meta"))"
sed -i -z "pkgs/development/compilers/hip/default.nix" \
-e 's,version = "[^'"'"'"]*",version = "'"$version"'",2' \
-e 's,hash = "[^'"'"'"]*",hash = "sha256-'"$tarball_hash"'",2'
else
echo hipamd already up-to-date
fi
'';
meta = with lib; {

View file

@ -1,72 +0,0 @@
{ stdenv
, lib
, fetchFromGitHub
, cmake
, python3
, llvm
, clang-tools-extra_src ? null
, lld
, version
, src
}:
stdenv.mkDerivation rec {
inherit version src;
pname = "clang";
nativeBuildInputs = [ cmake python3 ];
buildInputs = [ llvm ];
hardeningDisable = [ "all" ];
cmakeFlags = [
"-DLLVM_CMAKE_PATH=${llvm}/lib/cmake/llvm"
"-DLLVM_MAIN_SRC_DIR=${llvm.src}"
"-DCLANG_SOURCE_DIR=${src}"
"-DLLVM_ENABLE_RTTI=ON"
];
VCSVersion = ''
#undef LLVM_REVISION
#undef LLVM_REPOSITORY
#undef CLANG_REVISION
#undef CLANG_REPOSITORY
'';
postUnpack = lib.optionalString (!(isNull clang-tools-extra_src)) ''
ln -s ${clang-tools-extra_src} $sourceRoot/tools/extra
'';
# Rather than let cmake extract version information from LLVM or
# clang source control repositories, we generate the wanted
# `VCSVersion.inc` file ourselves and remove it from the
# depencencies of the `clangBasic` target.
preConfigure = ''
sed 's/ ''${version_inc}//' -i lib/Basic/CMakeLists.txt
sed 's|sys::path::parent_path(BundlerExecutable)|StringRef("${llvm}/bin")|' -i tools/clang-offload-bundler/ClangOffloadBundler.cpp
sed 's|\([[:space:]]*std::string Linker = \)getToolChain().GetProgramPath(getShortName())|\1"${lld}/bin/ld.lld"|' -i lib/Driver/ToolChains/AMDGPU.cpp
substituteInPlace lib/Driver/ToolChains/AMDGPU.h --replace ld.lld ${lld}/bin/ld.lld
sed 's|configure_file(AST/gen_ast_dump_json_test.py ''${LLVM_TOOLS_BINARY_DIR}/gen_ast_dump_json_test.py COPYONLY)||' -i test/CMakeLists.txt
'';
postConfigure = ''
mkdir -p lib/Basic
echo "$VCSVersion" > lib/Basic/VCSVersion.inc
'';
passthru = {
isClang = true;
inherit llvm;
};
meta = with lib; {
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; [ acowley lovesegfault ];
platforms = platforms.linux;
};
}

View file

@ -1,64 +0,0 @@
{ stdenv, lib, version, src, cmake, python3, llvm, libcxxabi, fetchpatch }:
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" ];
prePatch = ''
cd compiler-rt
'';
# 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;
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 lovesegfault ];
platforms = platforms.linux;
};
}

View file

@ -1,32 +1,36 @@
{ stdenv, lib, buildPackages, fetchFromGitHub, callPackage, wrapCCWith, overrideCC }:
let
version = "5.1.1";
version = "5.2.1";
src = fetchFromGitHub {
owner = "RadeonOpenCompute";
repo = "llvm-project";
rev = "rocm-${version}";
hash = "sha256-5SGIWiyfHvfwIUc4bhdWrlhBfK5ssA7tm5r3zKdr3kg=";
hash = "sha256-sudH8hnjReyuCFm2CBEPd8W88SjAARgCd1MTIJaDjTI=";
};
in rec {
clang = wrapCCWith rec {
cc = clang-unwrapped;
cc = llvm;
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"
ln -s "${compiler-rt}/lib" "$rsrc/lib"
ln -s "${cc}/lib/clang/$clang_version/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
# GPU compilation uses builtin lld
substituteInPlace $out/bin/clang \
--replace '-MM) dontLink=1 ;;' $'-MM | --cuda-device-only) dontLink=1 ;;\n--cuda-host-only | --cuda-compile-host-device) dontLink=0 ;;'
substituteInPlace $out/bin/clang++ \
--replace '-MM) dontLink=1 ;;' $'-MM | --cuda-device-only) dontLink=1 ;;\n--cuda-host-only | --cuda-compile-host-device) dontLink=0 ;;'
'';
};
clangNoCompilerRt = wrapCCWith rec {
cc = clang-unwrapped;
cc = llvm;
extraBuildCommands = ''
clang_version=`${cc}/bin/clang -v 2>&1 | grep "clang version " | grep -E -o "[0-9.-]+"`
rsrc="$out/resource-root"
@ -34,28 +38,17 @@ in rec {
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
# GPU compilation uses builtin lld
substituteInPlace $out/bin/clang \
--replace '-MM) dontLink=1 ;;' $'-MM | --cuda-device-only) dontLink=1 ;;\n--cuda-host-only | --cuda-compile-host-device) dontLink=0 ;;'
substituteInPlace $out/bin/clang++ \
--replace '-MM) dontLink=1 ;;' $'-MM | --cuda-device-only) dontLink=1 ;;\n--cuda-host-only | --cuda-compile-host-device) dontLink=0 ;;'
'';
};
clang-unwrapped = callPackage ./clang.nix {
inherit lld llvm version;
src = "${src}/clang";
};
compiler-rt = callPackage ./compiler-rt {
inherit version llvm;
inherit src;
stdenv = overrideCC stdenv clangNoCompilerRt;
};
lld = callPackage ./lld.nix {
inherit llvm src version;
};
llvm = callPackage ./llvm {
llvm = callPackage ./llvm.nix {
inherit src version;
};
}

View file

@ -0,0 +1,23 @@
diff --git a/llvm/cmake/modules/LLVMInstallSymlink.cmake b/llvm/cmake/modules/LLVMInstallSymlink.cmake
index b5c35f706cb7..ac25e40b1436 100644
--- a/cmake/modules/LLVMInstallSymlink.cmake
+++ b/cmake/modules/LLVMInstallSymlink.cmake
@@ -4,11 +4,16 @@
include(GNUInstallDirs)
+set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/../../../cmake/Modules" ${CMAKE_MODULE_PATH})
+include(ExtendPath)
+
function(install_symlink name target outdir)
set(DESTDIR $ENV{DESTDIR})
- set(bindir "${DESTDIR}${CMAKE_INSTALL_PREFIX}/${outdir}")
+ message(STATUS "Creating ${name} at ${bindir} (${CMAKE_MODULE_PATH})")
+ extend_path(prefixed_outdir "${CMAKE_INSTALL_PREFIX}" "${outdir}")
+ set(bindir "${DESTDIR}${prefixed_outdir}")
- message(STATUS "Creating ${name}")
+ message(STATUS "Creating ${name} at ${bindir}")
execute_process(
COMMAND "${CMAKE_COMMAND}" -E create_symlink "${target}" "${name}"

View file

@ -1,43 +0,0 @@
{ stdenv
, lib
, cmake
, libxml2
, llvm
, ninja
, version
, src
}:
stdenv.mkDerivation rec {
inherit version src;
sourceRoot = "${src.name}/lld";
pname = "lld";
nativeBuildInputs = [ cmake ninja ];
buildInputs = [ libxml2 llvm ];
outputs = [ "out" "dev" ];
cmakeFlags = [ "-DLLVM_MAIN_SRC_DIR=${src}/llvm" ];
postInstall = ''
moveToOutput include "$dev"
moveToOutput lib "$dev"
# Fix lld binary path for CMake.
substituteInPlace "$dev/lib/cmake/lld/LLDTargets-release.cmake" \
--replace "\''${_IMPORT_PREFIX}/bin/lld" "$out/bin/lld"
'';
meta = with lib; {
description = "ROCm fork of the LLVM Linker";
homepage = "https://github.com/RadeonOpenCompute/llvm-project";
license = licenses.ncsa;
maintainers = with maintainers; [ acowley lovesegfault ];
platforms = platforms.linux;
};
}

View file

@ -1,5 +1,6 @@
{ stdenv
, lib
, fetchgit
, fetchFromGitHub
, writeScript
, cmake
@ -12,7 +13,6 @@
, zlib
, debugVersion ? false
, enableManpages ? false
, enableSharedLibraries ? false
, version
, src
@ -30,28 +30,18 @@ in stdenv.mkDerivation rec {
sourceRoot = "${src.name}/llvm";
outputs = [ "out" "python" ]
++ lib.optional enableSharedLibraries "lib";
nativeBuildInputs = [ cmake ninja python3 ];
buildInputs = [ libxml2 libffi ];
buildInputs = [ libxml2 ];
propagatedBuildInputs = [ ncurses zlib ];
cmakeFlags = with stdenv; [
"-DCMAKE_BUILD_TYPE=${if debugVersion then "Debug" else "Release"}"
"-DLLVM_INSTALL_UTILS=ON" # Needed by rustc
"-DLLVM_BUILD_TESTS=OFF"
"-DLLVM_ENABLE_FFI=ON"
"-DLLVM_ENABLE_RTTI=ON"
"-DLLVM_ENABLE_DUMP=ON"
"-DLLVM_TARGETS_TO_BUILD=AMDGPU;${llvmNativeTarget}"
"-DLLVM_ENABLE_PROJECTS=clang;lld;compiler-rt"
]
++
lib.optional
enableSharedLibraries
"-DLLVM_LINK_LLVM_DYLIB=ON"
++ lib.optionals enableManpages [
"-DLLVM_BINUTILS_INCDIR=${libbfd.dev}/include"
"-DLLVM_BUILD_DOCS=ON"
@ -61,39 +51,16 @@ in stdenv.mkDerivation rec {
"-DSPHINX_WARNINGS_AS_ERRORS=OFF"
];
patches = [
./install-symlinks.patch
];
postPatch = ''
patchShebangs lib/OffloadArch/make_generated_offload_arch_h.sh
'' + lib.optionalString enableSharedLibraries ''
substitute '${./outputs.patch}' ./outputs.patch --subst-var lib
patch -p1 < ./outputs.patch
substituteInPlace ../clang/cmake/modules/CMakeLists.txt \
--replace 'FILES_MATCHING' 'NO_SOURCE_PERMISSIONS FILES_MATCHING'
'';
# hacky fix: created binaries need to be run before installation
preBuild = ''
mkdir -p $out/
ln -sv $PWD/lib $out
'';
postBuild = ''
rm -fR $out
'';
preCheck = ''
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH''${LD_LIBRARY_PATH:+:}$PWD/lib
'';
postInstall = ''
moveToOutput share/opt-viewer "$python"
''
+ lib.optionalString enableSharedLibraries ''
moveToOutput "lib/libLLVM-*" "$lib"
moveToOutput "lib/libLLVM${stdenv.hostPlatform.extensions.sharedLibrary}" "$lib"
substituteInPlace "$out/lib/cmake/llvm/LLVMExports-${if debugVersion then "debug" else "release"}.cmake" \
--replace "\''${_IMPORT_PREFIX}/lib/libLLVM-" "$lib/lib/libLLVM-"
'';
passthru.src = src;
updateScript = writeScript "update.sh" ''
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p curl jq common-updater-scripts nix-prefetch-github
@ -111,11 +78,13 @@ in stdenv.mkDerivation rec {
fi
'';
passthru.isClang = true;
meta = with lib; {
description = "ROCm fork of the LLVM compiler infrastructure";
homepage = "https://github.com/RadeonOpenCompute/llvm-project";
license = with licenses; [ ncsa ];
maintainers = with maintainers; [ acowley lovesegfault ];
maintainers = with maintainers; [ acowley lovesegfault Flakebi ];
platforms = platforms.linux;
};
}

View file

@ -1,16 +0,0 @@
diff --git a/tools/llvm-config/llvm-config.cpp b/tools/llvm-config/llvm-config.cpp
index 94d426b..37f7794 100644
--- a/tools/llvm-config/llvm-config.cpp
+++ b/tools/llvm-config/llvm-config.cpp
@@ -333,6 +333,11 @@ int main(int argc, char **argv) {
ActiveIncludeOption = "-I" + ActiveIncludeDir;
}
+ /// Nix-specific multiple-output handling: override ActiveLibDir
+ if (!IsInDevelopmentTree) {
+ ActiveLibDir = std::string("@lib@") + "/lib" + LLVM_LIBDIR_SUFFIX;
+ }
+
/// We only use `shared library` mode in cases where the static library form
/// of the components provided are not available; note however that this is
/// skipped if we're run from within the build dir. However, once installed,

View file

@ -7,13 +7,13 @@
stdenv.mkDerivation rec {
pname = "rocclr";
version = "5.1.0";
version = "5.2.1";
src = fetchFromGitHub {
owner = "ROCm-Developer-Tools";
repo = "ROCclr";
rev = "rocm-${version}";
hash = "sha256-SFWEGKffhuiTE7ICbkElVV5cldXu4Xbwvjb6LiNmijA=";
hash = "sha256-bNIc1JF8f88xC18BheKZCZYjWb4gUZOMWlt/5198iGE=";
};
patches = [

View file

@ -0,0 +1,224 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index eac270a..27610ec 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} $<TARGET_FILE:amd_comgr>)
- endif()
else()
add_library(amd_comgr STATIC ${SOURCES})
endif()
@@ -141,8 +137,8 @@ if (UNIX)
list(APPEND AMD_COMGR_PUBLIC_LINKER_OPTIONS -pthread)
if (NOT APPLE AND COMGR_BUILD_SHARED_LIBS)
configure_file(
- ${CMAKE_CURRENT_SOURCE_DIR}/src/exportmap.in
- ${CMAKE_CURRENT_BINARY_DIR}/src/exportmap @ONLY)
+ src/exportmap.in
+ src/exportmap @ONLY)
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()
# the shared header.
list(APPEND AMD_COMGR_PRIVATE_COMPILE_DEFINITIONS AMD_COMGR_EXPORT)
-configure_file(
- ${CMAKE_CURRENT_SOURCE_DIR}/include/amd_comgr.h.in
- ${CMAKE_CURRENT_BINARY_DIR}/include/amd_comgr.h @ONLY)
-
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
- $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>
- $<INSTALL_INTERFACE:include>)
+ $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>)
+
+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)
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}/${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}")
configure_file("cmake/${AMD_COMGR_CONFIG_NAME}.in"
- "${AMD_COMGR_PACKAGE_PREFIX}/${AMD_COMGR_CONFIG_NAME}"
+ ${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}"
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)")
-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)
diff --git a/cmake/bc2h.cmake b/cmake/bc2h.cmake
index 146fe2b..9134985 100644
--- a/cmake/bc2h.cmake
+++ b/cmake/bc2h.cmake
@@ -1,40 +1,41 @@
-file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/bc2h.c
-"#include <stdio.h>\n"
-"int main(int argc, char **argv){\n"
-" FILE *ifp, *ofp;\n"
-" int c, i, l;\n"
-" if (argc != 4) return 1;\n"
-" ifp = fopen(argv[1], \"rb\");\n"
-" if (!ifp) return 1;\n"
-" i = fseek(ifp, 0, SEEK_END);\n"
-" if (i < 0) return 1;\n"
-" l = ftell(ifp);\n"
-" if (l < 0) return 1;\n"
-" i = fseek(ifp, 0, SEEK_SET);\n"
-" if (i < 0) return 1;\n"
-" ofp = fopen(argv[2], \"wb+\");\n"
-" if (!ofp) return 1;\n"
-" fprintf(ofp, \"#define %s_size %d\\n\\n\"\n"
-" \"#if defined __GNUC__\\n\"\n"
-" \"__attribute__((aligned (4096)))\\n\"\n"
-" \"#elif defined _MSC_VER\\n\"\n"
-" \"__declspec(align(4096))\\n\"\n"
-" \"#endif\\n\"\n"
-" \"static const unsigned char %s[%s_size+1] = {\",\n"
-" argv[3], l,\n"
-" argv[3], argv[3]);\n"
-" i = 0;\n"
-" while ((c = getc(ifp)) != EOF) {\n"
-" if (0 == (i&7)) fprintf(ofp, \"\\n \");\n"
-" fprintf(ofp, \" 0x%02x,\", c);\n"
-" ++i;\n"
-" }\n"
-" fprintf(ofp, \" 0x00\\n};\\n\\n\");\n"
-" fclose(ifp);\n"
-" fclose(ofp);\n"
-" return 0;\n"
-"}\n"
-)
+file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/bc2h.c
+ CONTENT
+"#include <stdio.h>
+int main(int argc, char **argv){
+ FILE *ifp, *ofp;
+ int c, i, l;
+ if (argc != 4) return 1;
+ ifp = fopen(argv[1], \"rb\");
+ if (!ifp) return 1;
+ i = fseek(ifp, 0, SEEK_END);
+ if (i < 0) return 1;
+ l = ftell(ifp);
+ if (l < 0) return 1;
+ i = fseek(ifp, 0, SEEK_SET);
+ if (i < 0) return 1;
+ ofp = fopen(argv[2], \"wb+\");
+ if (!ofp) return 1;
+ fprintf(ofp, \"#define %s_size %d\\n\\n\"
+ \"#if defined __GNUC__\\n\"
+ \"__attribute__((aligned (4096)))\\n\"
+ \"#elif defined _MSC_VER\\n\"
+ \"__declspec(align(4096))\\n\"
+ \"#endif\\n\"
+ \"static const unsigned char %s[%s_size+1] = {\",
+ argv[3], l,
+ argv[3], argv[3]);
+ i = 0;
+ while ((c = getc(ifp)) != EOF) {
+ if (0 == (i&7)) fprintf(ofp, \"\\n \");
+ fprintf(ofp, \" 0x%02x,\", c);
+ ++i;
+ }
+ fprintf(ofp, \" 0x00\\n};\\n\\n\");
+ fclose(ifp);
+ fclose(ofp);
+ return 0;
+}
+")
add_executable(bc2h ${CMAKE_CURRENT_BINARY_DIR}/bc2h.c)
if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")

View file

@ -1,32 +1,33 @@
{ lib, stdenv, fetchFromGitHub, writeScript, cmake, clang, rocm-device-libs, lld, llvm }:
{ lib, stdenv, fetchFromGitHub, writeScript, cmake, clang, rocm-device-libs, llvm }:
stdenv.mkDerivation rec {
pname = "rocm-comgr";
version = "5.1.0";
version = "5.2.0";
src = fetchFromGitHub {
owner = "RadeonOpenCompute";
repo = "ROCm-CompilerSupport";
rev = "rocm-${version}";
hash = "sha256-zlCM3Zue7MEhL1c0gUPwRNgdjzyyF9BEP3UxE8RYkKk=";
hash = "sha256-5C5bRdrt3xZAlRgtiIRTMAuwsFvVM4Win96P5+Pf5ZM=";
};
sourceRoot = "source/lib/comgr";
nativeBuildInputs = [ cmake ];
buildInputs = [ clang rocm-device-libs lld llvm ];
buildInputs = [ clang rocm-device-libs llvm ];
cmakeFlags = [
"-DCLANG=${clang}/bin/clang"
"-DCMAKE_BUILD_TYPE=Release"
"-DCMAKE_C_COMPILER=${clang}/bin/clang"
"-DCMAKE_CXX_COMPILER=${clang}/bin/clang++"
"-DCMAKE_PREFIX_PATH=${llvm}/lib/cmake/llvm"
"-DLLD_INCLUDE_DIRS=${lld.src}/include"
"-DLLD_INCLUDE_DIRS=${llvm}/include"
"-DLLVM_TARGETS_TO_BUILD=\"AMDGPU;X86\""
];
patches = [ ./cmake.patch ];
passthru.updateScript = writeScript "update.sh" ''
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p curl jq common-updater-scripts

View file

@ -3,28 +3,26 @@
, writeScript
, cmake
, clang
, clang-unwrapped
, lld
, llvm
}:
stdenv.mkDerivation rec {
pname = "rocm-device-libs";
version = "5.1.0";
version = "5.2.0";
src = fetchFromGitHub {
owner = "RadeonOpenCompute";
repo = "ROCm-Device-Libs";
rev = "rocm-${version}";
hash = "sha256-kmCk+BpM1QCJzEAkru2LK3CGwVXNUEZBFicmwnrPcx8=";
hash = "sha256-TBCSznHyiaiOcBR9irybCnOgfqPiNNn4679PCQwrLhA=";
};
nativeBuildInputs = [ cmake ];
buildInputs = [ clang lld llvm ];
buildInputs = [ clang llvm ];
cmakeFlags = [
"-DCMAKE_PREFIX_PATH=${llvm}/lib/cmake/llvm;${clang-unwrapped}/lib/cmake/clang"
"-DCMAKE_PREFIX_PATH=${llvm}/lib/cmake/llvm;${llvm}/lib/cmake/clang"
"-DLLVM_TARGETS_TO_BUILD='AMDGPU;X86'"
"-DCLANG=${clang}/bin/clang"
];

View file

@ -6,11 +6,9 @@
, cmake
, rocm-cmake
, clang
, clang-unwrapped
, glew
, libglvnd
, libX11
, lld
, llvm
, mesa
, numactl
@ -24,24 +22,22 @@
stdenv.mkDerivation rec {
pname = "rocm-opencl-runtime";
version = "5.1.1";
version = "5.2.1";
src = fetchFromGitHub {
owner = "RadeonOpenCompute";
repo = "ROCm-OpenCL-Runtime";
rev = "rocm-${version}";
hash = "sha256-O7q3uTjspO/rZ2+8+g7pRfBXsCRaEr4DZxEqABHbOeY=";
hash = "sha256-Mk7Wssz34Uxtb9PRIEGrTn/tXtqxLMrq0damA/p/DsY=";
};
nativeBuildInputs = [ cmake rocm-cmake ];
buildInputs = [
clang
clang-unwrapped
glew
libglvnd
libX11
lld
llvm
mesa
numactl

View file

@ -3,7 +3,6 @@
, fetchFromGitHub
, writeScript
, addOpenGLRunpath
, clang-unwrapped
, cmake
, xxd
, elfutils
@ -14,20 +13,20 @@
stdenv.mkDerivation rec {
pname = "rocm-runtime";
version = "5.1.1";
version = "5.2.0";
src = fetchFromGitHub {
owner = "RadeonOpenCompute";
repo = "ROCR-Runtime";
rev = "rocm-${version}";
hash = "sha256-IP5ylfUXOFkw9+Frfh+tNaZ83ozAbOK9kO2AzFVzzWk=";
hash = "sha256-TY0YPgNzxBLXAj7fncLQ01cSJyydveOLHrimCmLS32o=";
};
sourceRoot = "source/src";
nativeBuildInputs = [ cmake xxd ];
buildInputs = [ clang-unwrapped elfutils llvm numactl ];
buildInputs = [ elfutils llvm numactl ];
cmakeFlags = [
"-DBITCODE_DIR=${rocm-device-libs}/amdgcn/bitcode"

View file

@ -9,13 +9,13 @@
stdenv.mkDerivation rec {
pname = "rocm-thunk";
version = "5.1.0";
version = "5.2.1";
src = fetchFromGitHub {
owner = "RadeonOpenCompute";
repo = "ROCT-Thunk-Interface";
rev = "rocm-${version}";
hash = "sha256-Qvbvfe1fhoLTkDnzG0WzfAxbyDoEJwkzVvlBGTBkq0w=";
hash = "sha256-iXhlEofPAQNxeZzDgdF1DdflIKfSI7rHGTqOybHnnHM=";
};
preConfigure = ''

View file

@ -2,13 +2,13 @@
stdenv.mkDerivation rec {
pname = "rocm-cmake";
version = "5.1.0";
version = "5.2.0";
src = fetchFromGitHub {
owner = "RadeonOpenCompute";
repo = "rocm-cmake";
rev = "rocm-${version}";
hash = "sha256-7jLn0FIjsww1lu1J9MB0s/Ksnw66BL1U0jQwiwmgw64=";
hash = "sha256-2YALk3G5BhrsXZZHjGSSuk8tCi5sNGuB2VB4uvozyZo=";
};
nativeBuildInputs = [ cmake ];

View file

@ -2,13 +2,13 @@
stdenv.mkDerivation rec {
pname = "rocm-smi";
version = "5.1.0";
version = "5.2.0";
src = fetchFromGitHub {
owner = "RadeonOpenCompute";
repo = "rocm_smi_lib";
rev = "rocm-${version}";
hash = "sha256-11o4xUyeQ3W/RPY62r8ahwcljKh/rkVSyTk5ruTU66U=";
hash = "sha256-7e8nCCyFhecfC4TJrpqMI5buVZstynYgDWaa+LF85GA=";
};
nativeBuildInputs = [ cmake wrapPython ];

View file

@ -14172,27 +14172,27 @@ with pkgs;
rocclr = callPackage ../development/libraries/rocclr { };
hip = callPackage ../development/compilers/hip {
inherit (llvmPackages_rocm) clang clang-unwrapped compiler-rt lld llvm;
inherit (llvmPackages_rocm) clang llvm;
};
rocm-cmake = callPackage ../development/tools/build-managers/rocm-cmake { };
rocm-comgr = callPackage ../development/libraries/rocm-comgr {
inherit (llvmPackages_rocm) clang lld llvm;
inherit (llvmPackages_rocm) clang llvm;
};
rocm-device-libs = callPackage ../development/libraries/rocm-device-libs {
inherit (llvmPackages_rocm) clang clang-unwrapped lld llvm;
inherit (llvmPackages_rocm) clang llvm;
};
rocm-opencl-icd = callPackage ../development/libraries/rocm-opencl-icd { };
rocm-opencl-runtime = callPackage ../development/libraries/rocm-opencl-runtime {
inherit (llvmPackages_rocm) clang clang-unwrapped lld llvm;
inherit (llvmPackages_rocm) clang llvm;
};
rocm-runtime = callPackage ../development/libraries/rocm-runtime {
inherit (llvmPackages_rocm) clang-unwrapped llvm;
inherit (llvmPackages_rocm) llvm;
};
rocm-smi = python3Packages.callPackage ../tools/system/rocm-smi { };