rocmPackages: clean up, reduce closure sizes (#444860)

This commit is contained in:
Masum Reza
2025-10-11 09:10:43 +00:00
committed by GitHub
25 changed files with 229 additions and 252 deletions

View File

@@ -203,8 +203,8 @@ stdenv.mkDerivation (finalAttrs: {
# Can't easily apply the PR as a patch because we rely on the tarball with pregenerated
# hipified files ∴ fetchpatch of the PR will apply cleanly but fail to build
(strings.cmakeFeature "ROCM_CORE" "${rocmPackages.clr}")
(strings.cmakeFeature "CMAKE_C_COMPILER" "${rocmPackages.clr}/bin/clang")
(strings.cmakeFeature "CMAKE_CXX_COMPILER" "${rocmPackages.clr}/bin/clang++")
(strings.cmakeFeature "CMAKE_C_COMPILER" "${rocmPackages.clang}/bin/clang")
(strings.cmakeFeature "CMAKE_CXX_COMPILER" "${rocmPackages.clang}/bin/clang++")
];
# Magma doesn't have a test suite we can easily run, just loose executables, all of which require a GPU.

View File

@@ -13,10 +13,12 @@
rocm-device-libs,
rocm-comgr,
rocm-runtime,
rocm-toolchain,
rocm-core,
roctracer,
rocminfo,
rocm-smi,
symlinkJoin,
numactl,
libffi,
zstd,
@@ -25,7 +27,7 @@
libxml2,
libX11,
python3Packages,
rocm-merged-llvm,
llvm,
khronos-ocl-icd-loader,
gcc-unwrapped,
writeShellScriptBin,
@@ -34,7 +36,20 @@
let
inherit (rocm-core) ROCM_LIBPATCH_VERSION;
hipClang = rocm-merged-llvm;
# HIP_CLANG_PATH or ROCM_PATH/llvm
# Note: relying on ROCM_PATH/llvm is bad for cross
hipClang = symlinkJoin {
name = "hipClang";
paths = [
# FIXME: if we don't put this first aotriton build fails with ld.lld: -flavor gnu
# Probably wrapper jank
llvm.bintools.bintools
llvm.rocm-toolchain
];
postBuild = ''
rm -rf $out/{include,lib,share,etc,nix-support,usr}
'';
};
hipClangPath = "${hipClang}/bin";
wrapperArgs = [
"--prefix PATH : $out/bin"
@@ -83,6 +98,7 @@ stdenv.mkDerivation (finalAttrs: {
];
buildInputs = [
llvm.llvm
numactl
libGL
libxml2
@@ -100,6 +116,7 @@ stdenv.mkDerivation (finalAttrs: {
rocm-comgr
rocm-runtime
rocminfo
hipClangPath
];
cmakeBuildType = "RelWithDebInfo";
@@ -162,7 +179,8 @@ stdenv.mkDerivation (finalAttrs: {
--replace-fail "install(PROGRAMS \''${HIPCC_BIN_DIR}/hipconfig.bat DESTINATION bin)" ""
substituteInPlace hipamd/src/hip_embed_pch.sh \
--replace-fail "\''$LLVM_DIR/bin/clang" "${hipClangPath}/clang"
--replace-fail "\''$LLVM_DIR/bin/clang" "${hipClangPath}/clang" \
--replace-fail "\''$LLVM_DIR/bin/llvm-mc" "${lib.getExe' llvm.bintools.bintools "llvm-mc"}"
substituteInPlace opencl/khronos/icd/loader/icd_platform.h \
--replace-fail '#define ICD_VENDOR_PATH "/etc/OpenCL/vendors/";' \
@@ -206,7 +224,6 @@ stdenv.mkDerivation (finalAttrs: {
ln -s ${rocm-core}/.info/ $out/.info
ln -s ${hipClang} $out/llvm
ln -s ${hipClang}/bin/{ld.lld,lld,clang-offload-bundler,llvm-objcopy,clang,clang++} $out/bin/
'';
disallowedRequisites = [

View File

@@ -5,7 +5,7 @@
rocmUpdateScript,
cmake,
rocm-cmake,
rocm-merged-llvm,
llvm,
clr,
rocminfo,
python3,
@@ -85,7 +85,6 @@ stdenv.mkDerivation (finalAttrs: {
strictDeps = true;
enableParallelBuilding = true;
env.ROCM_PATH = clr;
env.HIP_CLANG_PATH = "${rocm-merged-llvm}/bin";
cmakeFlags = [
"-DCMAKE_MODULE_PATH=${clr}/hip/cmake"

View File

@@ -3,9 +3,9 @@
python,
composable_kernel,
lib,
rocm-toolchain,
setuptools,
setuptools-scm,
rocm-merged-llvm,
}:
buildPythonPackage {
pyproject = true;
@@ -25,7 +25,7 @@ buildPythonPackage {
propagatedBuildInputs = [
# At runtime will fail to compile anything with ck4inductor without this
# can't easily use in checks phase because most of the compiler machinery is in torch
rocm-merged-llvm
rocm-toolchain
];
checkPhase = ''
if [ ! -d "$out/${python.sitePackages}/ck4inductor" ]; then

View File

@@ -30,7 +30,6 @@ let
buildTests = false;
buildBenchmarks = false;
rocmPath = self.callPackage ./rocm-path { };
rocmUpdateScript = self.callPackage ./update.nix { };
## ROCm ##
@@ -41,26 +40,19 @@ let
inherit (self) rocm-device-libs;
}
);
inherit (self.llvm) rocm-merged-llvm clang openmp;
inherit (self.llvm) rocm-toolchain clang openmp;
rocm-core = self.callPackage ./rocm-core { stdenv = origStdenv; };
rocm-cmake = self.callPackage ./rocm-cmake { stdenv = origStdenv; };
rocm-device-libs = self.callPackage ./rocm-device-libs {
stdenv = origStdenv;
inherit (llvm) rocm-merged-llvm;
};
rocm-device-libs = self.callPackage ./rocm-device-libs { };
rocm-runtime = self.callPackage ./rocm-runtime {
stdenv = origStdenv;
inherit (llvm) rocm-merged-llvm;
};
rocm-comgr = self.callPackage ./rocm-comgr {
stdenv = origStdenv;
inherit (llvm) rocm-merged-llvm;
};
rocm-comgr = self.callPackage ./rocm-comgr { };
rocminfo = self.callPackage ./rocminfo { stdenv = origStdenv; };
@@ -80,10 +72,7 @@ let
hip-common = self.callPackage ./hip-common { };
hipcc = self.callPackage ./hipcc {
stdenv = origStdenv;
inherit (llvm) rocm-merged-llvm;
};
hipcc = self.callPackage ./hipcc { stdenv = origStdenv; };
# Replaces hip, opencl-runtime, and rocclr
clr = self.callPackage ./clr { };
@@ -92,10 +81,6 @@ let
hipify = self.callPackage ./hipify {
stdenv = origStdenv;
inherit (llvm)
clang
rocm-merged-llvm
;
};
# hsakmt was merged into rocm-runtime
@@ -179,8 +164,7 @@ let
composable_kernel = self.callPackage ./composable_kernel { };
ck4inductor = pyPackages.callPackage ./composable_kernel/ck4inductor.nix {
inherit (self) composable_kernel;
inherit (llvm) rocm-merged-llvm;
inherit (self) composable_kernel rocm-toolchain;
};
half = self.callPackage ./half { };
@@ -443,6 +427,23 @@ let
};
}
// lib.optionalAttrs config.allowAliases {
rocmPath = throw ''
'rocm-path' has been removed. If a ROCM_PATH value is required in nixpkgs please
construct one with the minimal set of required deps.
For convenience use outside of nixpkgs consider one of the entries in
'rocmPackages.meta'.
''; # Added 2025-09-30
rocm-merged-llvm = throw ''
'rocm-merged-llvm' has been removed.
For 'libllvm' or 'libclang' use 'rocmPackages.llvm.libllvm/clang'.
For a ROCm compiler toolchain use 'rocmPackages.rocm-toolchain'.
If a package uses '$<TARGET_FILE:clang>' in CMake from 'libclang'
it may be necessary to convince it to use 'rocm-toolchain' instead.
'rocm-merged-llvm' avoided this at the cost of significantly bloating closure
size.
''; # Added 2025-09-30
hsa-amd-aqlprofile-bin = lib.warn ''
'hsa-amd-aqlprofile-bin' has been replaced by 'aqlprofile'.
'' self.aqlprofile; # Added 2025-08-27

View File

@@ -2,7 +2,6 @@
lib,
stdenv,
fetchFromGitHub,
writableTmpDirAsHomeHook,
cmake,
rocm-cmake,
rocm-smi,
@@ -11,6 +10,7 @@
gfortran,
gtest,
boost,
llvm,
msgpack-cxx,
amd-blis,
libxml2,
@@ -139,6 +139,7 @@ stdenv.mkDerivation (finalAttrs: {
];
buildInputs = [
llvm.llvm
clr
rocm-cmake
hipblas-common

View File

@@ -1,7 +1,7 @@
{
lib,
stdenv,
rocm-merged-llvm,
llvm,
cmake,
lsb-release,
}:
@@ -9,13 +9,19 @@
stdenv.mkDerivation (finalAttrs: {
pname = "hipcc";
# In-tree with ROCm LLVM
inherit (rocm-merged-llvm) version;
src = rocm-merged-llvm.llvm-src;
inherit (llvm.llvm) version;
src = llvm.llvm.monorepoSrc;
sourceRoot = "${finalAttrs.src.name}/amd/hipcc";
strictDeps = true;
nativeBuildInputs = [ cmake ];
nativeBuildInputs = [
llvm.rocm-toolchain
cmake
];
buildInputs = [ rocm-merged-llvm ];
buildInputs = [
llvm.clang-unwrapped
];
patches = [
# https://github.com/ROCm/llvm-project/pull/183

View File

@@ -6,7 +6,6 @@
cmake,
rocm-cmake,
clr,
git,
rocfft,
gtest,
boost,
@@ -47,7 +46,6 @@ stdenv.mkDerivation (finalAttrs: {
nativeBuildInputs = [
clr
git
cmake
rocm-cmake
];

View File

@@ -4,9 +4,7 @@
fetchFromGitHub,
rocmUpdateScript,
cmake,
clang,
libxml2,
rocm-merged-llvm,
llvm,
zlib,
zstd,
perl,
@@ -23,21 +21,27 @@ stdenv.mkDerivation (finalAttrs: {
hash = "sha256-uj25WmGCpwouS1yzW9Oil5Vyrbyj5yRITvWF9WaGozM=";
};
strictDeps = true;
nativeBuildInputs = [
cmake
perl
llvm.rocm-toolchain
];
buildInputs = [
libxml2
rocm-merged-llvm
llvm.llvm
llvm.clang-unwrapped
perl
zlib
zstd
perl
];
env.CXXFLAGS = "-I${lib.getInclude llvm.llvm}/include -I${lib.getInclude llvm.clang-unwrapped}/include";
postPatch = ''
substituteInPlace CMakeLists.txt \
--replace "\''${LLVM_TOOLS_BINARY_DIR}/clang" "${clang}/bin/clang"
--replace-fail "\''${LLVM_TOOLS_BINARY_DIR}/clang" "${llvm.rocm-toolchain}/bin/clang"
chmod +x bin/*
'';

View File

@@ -8,7 +8,6 @@
rocsparse,
clr,
gfortran,
git,
gtest,
openmp,
buildTests ? false,
@@ -48,7 +47,6 @@ stdenv.mkDerivation (finalAttrs: {
buildInputs = [
rocsparse
git
]
++ lib.optionals (buildTests || buildBenchmarks) [
gtest

View File

@@ -4,6 +4,7 @@
# LLVM version closest to ROCm fork to override
llvmPackages_19,
overrideCC,
lndir,
rocm-device-libs,
fetchFromGitHub,
runCommand,
@@ -71,7 +72,7 @@ let
stdenvToBuildRocmLlvm.cc
stdenvToBuildRocmLlvm.cc.cc
];
# A prefix for use as the GCC prefix when building rocmcxx
# A prefix for use as the GCC prefix when building rocm-toolchain
gcc-prefix-headers = symlinkJoin {
name = "gcc-prefix-headers";
paths = [
@@ -112,14 +113,6 @@ let
ln -s $out $out/x86_64-unknown-linux-gnu
'';
};
usefulOutputs =
drv:
builtins.filter (x: x != null) [
drv
(drv.lib or null)
(drv.dev or null)
];
listUsefulOutputs = builtins.concatMap usefulOutputs;
llvmSrc = fetchFromGitHub {
owner = "ROCm";
repo = "llvm-project";
@@ -141,40 +134,62 @@ let
monorepoSrc = llvmSrc;
doCheck = false;
});
refsToRemove = builtins.concatStringsSep " -t " [
stdenvToBuildRocmLlvm
stdenvToBuildRocmLlvm.cc
stdenvToBuildRocmLlvm.cc.cc
stdenv.cc
stdenv.cc.cc
stdenv.cc.bintools
];
sysrootCompiler =
cc: name: paths:
{
cc,
name,
paths,
linkPaths,
}:
let
linked = symlinkJoin { inherit name paths; };
in
runCommand name
{
# If this is erroring, try why-depends --precise on the symlinkJoin of inputs to look for the problem
# nix why-depends --precise .#rocmPackages.llvm.rocmcxx.linked /store/path/its/not/allowed
# nix why-depends --precise .#rocmPackages.llvm.rocm-toolchain.linked /store/path/its/not/allowed
disallowedRequisites = disallowedRefsForToolchain;
passthru.linked = linked;
linkPaths = linkPaths;
passAsFile = [ "linkPaths" ];
# TODO(@LunNova): Try to use --sysroot with clang in its original location instead of
# relying on copying the binary?
# $clang/bin/clang++ --sysroot=$rocm-toolchain is not equivalent
# to a clang copied to $rocm-toolchain/bin here, have not yet figured out why
}
''
set -x
mkdir -p $out/
cp --reflink=auto -rL ${linked}/* $out/
chmod -R +rw $out
mkdir -p $out/usr
ln -s $out/ $out/usr/local
mkdir -p $out/nix-support/
# we don't need mixed 32 bit, the presence of lib64 is used by LLVM to decide it's a multilib sysroot
rm -rf $out/lib64
echo 'export CC=clang' >> $out/nix-support/setup-hook
echo 'export CXX=clang++' >> $out/nix-support/setup-hook
rm -rf $out/lib/cmake $out/lib/lib*.a
mkdir -p $out/lib/clang/${llvmMajorVersion}/lib/linux/
ln -s $out/lib/linux/libclang_rt.* $out/lib/clang/${llvmMajorVersion}/lib/linux/
find $out -type f -exec sed -i "s|${cc.out}|$out|g" {} +
find $out -type f -exec sed -i "s|${cc.dev}|$out|g" {} +
# our /include now has more than clang expects, so this specific dir still needs to point to cc.dev
# FIXME: could copy into a different subdir?
sed -i 's|set(CLANG_INCLUDE_DIRS.*$|set(CLANG_INCLUDE_DIRS "${cc.dev}/include")|g' $out/lib/cmake/clang/ClangConfig.cmake
${lib.getExe rdfind} -makesymlinks true $out/ # create links *within* the sysroot to save space
${lib.getExe rdfind} -makesymlinks true ${
builtins.concatStringsSep " " (map (x: "${x}/lib") paths)
} $out/ # create links *within* the sysroot to save space
for i in $(cat $linkPathsPath); do
${lib.getExe lndir} -silent $i $out
done
echo 'export CC=clang' >> $out/nix-support/setup-hook
echo 'export CXX=clang++' >> $out/nix-support/setup-hook
'';
# Removes patches which either aren't desired, or don't apply against ROCm LLVM
removeInapplicablePatches =
@@ -277,6 +292,11 @@ rec {
zstd
zlib
];
preFixup = ''
moveToOutput "lib/lib*.a" "$dev"
moveToOutput "lib/cmake" "$dev"
sed -Ei "s|$lib/lib/(lib[^/]*)\.a|$dev/lib/\1.a|g" $dev/lib/cmake/llvm/*.cmake
'';
env = (old.env or { }) // {
NIX_CFLAGS_COMPILE = "${(old.env or { }).NIX_CFLAGS_COMPILE or ""} ${llvmExtraCflags}";
};
@@ -285,10 +305,7 @@ rec {
disallowedReferences = (old.disallowedReferences or [ ]) ++ disallowedRefsForToolchain;
postFixup = ''
${old.postFixup or ""}
remove-references-to -t "${stdenv.cc}" "$lib/lib/libLLVMSupport.a"
find $lib -type f -exec remove-references-to -t ${stdenv.cc.cc} {} +
find $lib -type f -exec remove-references-to -t ${stdenvToBuildRocmLlvm.cc} {} +
find $lib -type f -exec remove-references-to -t ${stdenv.cc.bintools} {} +
find $lib -type f -exec remove-references-to -t ${refsToRemove} {} +
'';
meta = old.meta // llvmMeta;
});
@@ -314,16 +331,15 @@ rec {
disallowedReferences = (old.disallowedReferences or [ ]) ++ disallowedRefsForToolchain;
postFixup = ''
${old.postFixup or ""}
find $lib -type f -exec remove-references-to -t ${stdenv.cc.cc} {} +
find $lib -type f -exec remove-references-to -t ${stdenv.cc.bintools} {} +
find $lib -type f -exec remove-references-to -t ${refsToRemove} {} +
'';
meta = old.meta // llvmMeta;
});
clang-unwrapped =
(
(llvmPackagesRocm.clang-unwrapped.override {
libllvm = llvm;
}).overrideAttrs
clang-unwrapped = (
(llvmPackagesRocm.clang-unwrapped.override {
libllvm = llvm;
enableClangToolsExtra = false;
}).overrideAttrs
(
old:
let
@@ -384,75 +400,85 @@ rec {
(builtins.filter tablegenUsage old.cmakeFlags)
++ commonCmakeFlags
++ lib.optionals (!withLibcxx) [
# FIXME: Config file in rocmcxx instead of GCC_INSTALL_PREFIX?
# FIXME: Config file in rocm-toolchain instead of GCC_INSTALL_PREFIX?
# Expected to be fully removed eventually
"-DUSE_DEPRECATED_GCC_INSTALL_PREFIX=ON"
"-DGCC_INSTALL_PREFIX=${gcc-prefix}"
];
postFixup = (old.postFixup or "") + ''
find $lib -type f -exec remove-references-to -t ${stdenvToBuildRocmLlvm} {} +
find $lib -type f -exec remove-references-to -t ${stdenvToBuildRocmLlvm.cc} {} +
find $lib -type f -exec remove-references-to -t ${stdenvToBuildRocmLlvm.cc.cc} {} +
find $lib -type f -exec remove-references-to -t ${stdenv.cc} {} +
find $lib -type f -exec remove-references-to -t ${stdenv.cc.cc} {} +
find $lib -type f -exec remove-references-to -t ${stdenv.cc.bintools} {} +
preFixup = ''
${toString old.preFixup or ""}
moveToOutput "lib/lib*.a" "$dev"
moveToOutput "lib/cmake" "$dev"
mkdir -p $dev/lib/clang/
ln -s $lib/lib/clang/${llvmMajorVersion} $dev/lib/clang/
sed -Ei "s|$lib/lib/(lib[^/]*)\.a|$dev/lib/\1.a|g" $dev/lib/cmake/clang/*.cmake
'';
postFixup = ''
${toString old.postFixup or ""}
find $lib -type f -exec remove-references-to -t ${refsToRemove} {} +
find $dev -type f -exec remove-references-to -t ${refsToRemove} {} +
'';
meta = old.meta // llvmMeta;
}
)
)
// {
libllvm = llvm;
};
);
# A clang that understands standard include searching in a GNU sysroot and will put GPU libs in include path
# in the right order
# and expects its libc to be in the sysroot
rocmcxx =
(sysrootCompiler clang-unwrapped "rocmcxx" (
listUsefulOutputs (
[
clang-unwrapped
bintools
compiler-rt
openmp
]
++ (lib.optionals withLibcxx [
libcxx
])
++ (lib.optionals (!withLibcxx) [
gcc-include
glibc
glibc.dev
])
)
))
rocm-toolchain =
(sysrootCompiler {
cc = clang-unwrapped;
name = "rocm-toolchain";
paths = [
clang-unwrapped.out
clang-unwrapped.lib
bintools.out
compiler-rt.out
openmp.out
openmp.dev
]
++ lib.optionals withLibcxx [
libcxx
]
++ lib.optionals (!withLibcxx) [
glibc
glibc.dev
];
linkPaths = [
bintools.bintools.out
]
++ lib.optionals (!withLibcxx) [
gcc-include.out
];
})
// {
version = llvmMajorVersion;
cc = rocmcxx;
cc = rocm-toolchain;
libllvm = llvm;
isClang = true;
isGNU = false;
};
clang-tools = llvmPackagesRocm.clang-tools.override {
inherit clang-unwrapped clang;
};
compiler-rt-libc = llvmPackagesRocm.compiler-rt-libc.overrideAttrs (old: {
patches = old.patches ++ [
(fetchpatch {
name = "Fix-missing-main-function-in-float16-bfloat16-support-checks.patch";
url = "https://github.com/ROCm/llvm-project/commit/68d8b3846ab1e6550910f2a9a685690eee558af2.patch";
hash = "sha256-Db+L1HFMWVj4CrofsGbn5lnMoCzEcU+7q12KKFb17/g=";
relative = "compiler-rt";
})
(fetchpatch {
# Fixes fortify hardening compile error related to openat usage
hash = "sha256-pgpN1q1vIQrPXHPxNSZ6zfgV2EflHO5Amzl+2BDjXbs=";
url = "https://github.com/llvm/llvm-project/commit/155b7a12820ec45095988b6aa6e057afaf2bc892.patch";
relative = "compiler-rt";
})
];
meta = old.meta // llvmMeta;
});
compiler-rt-libc =
(llvmPackagesRocm.compiler-rt-libc.override {
libllvm = llvm;
}).overrideAttrs
(old: {
patches = old.patches ++ [
(fetchpatch {
name = "Fix-missing-main-function-in-float16-bfloat16-support-checks.patch";
url = "https://github.com/ROCm/llvm-project/commit/68d8b3846ab1e6550910f2a9a685690eee558af2.patch";
hash = "sha256-Db+L1HFMWVj4CrofsGbn5lnMoCzEcU+7q12KKFb17/g=";
relative = "compiler-rt";
})
(fetchpatch {
# Fixes fortify hardening compile error related to openat usage
hash = "sha256-pgpN1q1vIQrPXHPxNSZ6zfgV2EflHO5Amzl+2BDjXbs=";
url = "https://github.com/llvm/llvm-project/commit/155b7a12820ec45095988b6aa6e057afaf2bc892.patch";
relative = "compiler-rt";
})
];
meta = old.meta // llvmMeta;
});
compiler-rt = compiler-rt-libc;
bintools = wrapBintoolsWith {
bintools = llvmPackagesRocm.bintools-unwrapped.override {
@@ -460,45 +486,7 @@ rec {
};
};
clang = rocmcxx;
# Emulate a monolithic ROCm LLVM build to support building ROCm's in-tree LLVM projects
# TODO(@LunNova): destroy this
rocm-merged-llvm = symlinkJoin {
name = "rocm-llvm-merge";
paths = [
llvm
llvm.dev
lld
lld.lib
lld.dev
compiler-rt
compiler-rt.dev
rocmcxx
]
++ lib.optionals withLibcxx [
libcxx
libcxx.out
libcxx.dev
];
postBuild = builtins.unsafeDiscardStringContext ''
found_files=$(find $out -name '*.cmake')
if [ -z "$found_files" ]; then
>&2 echo "Error: No CMake files found in $out"
exit 1
fi
for target in ${clang-unwrapped.out} ${clang-unwrapped.lib} ${clang-unwrapped.dev}; do
if grep "$target" $found_files; then
>&2 echo "Unexpected ref to $target (clang-unwrapped) found"
# exit 1
# # FIXME: enable this to reduce closure size
fi
done
'';
inherit version;
llvm-src = llvmSrc;
};
clang = rocm-toolchain;
rocmClangStdenv = overrideCC (
if withLibcxx then llvmPackagesRocm.libcxxStdenv else llvmPackagesRocm.stdenv

View File

@@ -13,7 +13,6 @@
rocmlir,
rocrand,
rocm-runtime,
rocm-merged-llvm,
hipblas-common,
hipblas,
hipblaslt,
@@ -172,7 +171,6 @@ stdenv.mkDerivation (finalAttrs: {
enableParallelBuilding = true;
env.ROCM_PATH = clr;
env.LD_LIBRARY_PATH = lib.makeLibraryPath [ rocm-runtime ];
env.HIP_CLANG_PATH = "${rocm-merged-llvm}/bin";
nativeBuildInputs = [
pkg-config

View File

@@ -10,7 +10,6 @@
rocprim,
rocrand,
clr,
git,
pkg-config,
openmp,
openmpi,
@@ -49,7 +48,6 @@ stdenv.mkDerivation (finalAttrs: {
cmake
rocm-cmake
clr
git
pkg-config
];

View File

@@ -4,7 +4,6 @@
fetchFromGitHub,
fetchpatch,
rocmUpdateScript,
writableTmpDirAsHomeHook,
cmake,
rocm-cmake,
clr,
@@ -16,7 +15,7 @@
gtest,
gfortran,
openmp,
git,
gitMinimal,
amd-blis,
zstd,
roctracer,
@@ -53,7 +52,7 @@ stdenv.mkDerivation (finalAttrs: {
# no ninja, it buffers console output and nix times out long periods of no output
rocm-cmake
clr
git
gitMinimal
pkg-config
]
++ lib.optionals buildTensile [

View File

@@ -5,7 +5,6 @@
rocmUpdateScript,
cmake,
rocm-cmake,
git,
rocm-comgr,
rocm-runtime,
hwdata,
@@ -82,7 +81,6 @@ stdenv.mkDerivation (finalAttrs: {
nativeBuildInputs = [
cmake
rocm-cmake
git
]
++ lib.optionals buildDocs [
writableTmpDirAsHomeHook

View File

@@ -3,12 +3,11 @@
stdenv,
fetchpatch,
cmake,
llvm,
python3,
rocm-merged-llvm,
rocm-device-libs,
zlib,
zstd,
libxml2,
}:
let
@@ -23,10 +22,10 @@ in
stdenv.mkDerivation (finalAttrs: {
pname = "rocm-comgr";
# In-tree with ROCm LLVM
inherit (rocm-merged-llvm) version;
src = rocm-merged-llvm.llvm-src;
inherit (llvm.llvm) version;
src = llvm.llvm.monorepoSrc;
sourceRoot = "${finalAttrs.src.name}/amd/comgr";
strictDeps = true;
patches = [
# [Comgr] Extend ISA compatibility
@@ -43,22 +42,26 @@ stdenv.mkDerivation (finalAttrs: {
})
];
postPatch = ''
substituteInPlace cmake/opencl_pch.cmake \
--replace-fail "\''${CLANG_CMAKE_DIR}/../../../" "${llvm.clang-unwrapped.lib}"
'';
nativeBuildInputs = [
cmake
python3
];
buildInputs = [
llvm.llvm
llvm.clang-unwrapped
llvm.lld
rocm-device-libs
libxml2
zlib
zstd
rocm-merged-llvm
];
cmakeFlags = [
"-DCMAKE_VERBOSE_MAKEFILE=ON"
"-DCMAKE_BUILD_TYPE=Release"
"-DLLVM_TARGETS_TO_BUILD=AMDGPU;${llvmNativeTarget}"
];

View File

@@ -1,7 +1,7 @@
diff --git a/cmake/Packages.cmake b/cmake/Packages.cmake
index 07c60eb..c736b3e 100644
--- a/amd/device-libs/cmake/Packages.cmake
+++ b/amd/device-libs/cmake/Packages.cmake
--- a/cmake/Packages.cmake
+++ b/cmake/Packages.cmake
@@ -12,24 +12,29 @@ set_target_properties(${target} PROPERTIES
IMPORTED_LOCATION \"${target_path}\")")
endforeach()

View File

@@ -4,11 +4,9 @@
fetchpatch,
cmake,
ninja,
libxml2,
zlib,
zstd,
ncurses,
rocm-merged-llvm,
llvm,
python3,
}:
@@ -21,22 +19,29 @@ let
else
throw "Unsupported ROCm LLVM platform";
in
stdenv.mkDerivation {
stdenv.mkDerivation (finalAttrs: {
pname = "rocm-device-libs";
# In-tree with ROCm LLVM
inherit (rocm-merged-llvm) version;
src = rocm-merged-llvm.llvm-src;
inherit (llvm.llvm) version;
src = llvm.llvm.monorepoSrc;
sourceRoot = "${finalAttrs.src.name}/amd/device-libs";
strictDeps = true;
__structuredAttrs = true;
postPatch = ''
cd amd/device-libs
'';
postPatch =
# Use our sysrooted toolchain instead of direct clang target
''
substituteInPlace cmake/OCL.cmake \
--replace-fail '$<TARGET_FILE:clang>' "${llvm.rocm-toolchain}/bin/clang"
'';
patches = [
./cmake.patch
(fetchpatch {
name = "cmake-4-compat-dont-set-cmp0053.patch";
url = "https://github.com/ROCm/llvm-project/commit/a18cc4c7cb51f94182b6018c7c73acde1b8ebddb.patch";
hash = "sha256-LNT7srxd4gXDAJ6lSsJXKnRQKSepkAbHeRNH+eZYIFk=";
hash = "sha256-kp/Ld0IhjWgRbRR9R/CKdkI9ELvPkQSAMqPsAPFxzhM=";
relative = "amd/device-libs";
})
];
@@ -44,18 +49,17 @@ stdenv.mkDerivation {
cmake
ninja
python3
llvm.rocm-toolchain
];
buildInputs = [
libxml2
llvm.llvm
llvm.clang-unwrapped
zlib
zstd
ncurses
rocm-merged-llvm
];
cmakeFlags = [
"-DCMAKE_RELEASE_TYPE=Release"
"-DLLVM_TARGETS_TO_BUILD=AMDGPU;${llvmNativeTarget}"
];
@@ -67,4 +71,4 @@ stdenv.mkDerivation {
teams = [ teams.rocm ];
platforms = platforms.linux;
};
}
})

View File

@@ -1,27 +0,0 @@
{
symlinkJoin,
linkFarm,
clr,
hipblas,
hipblas-common,
rocblas,
rocsolver,
rocsparse,
rocm-device-libs,
rocm-smi,
llvm,
}:
symlinkJoin {
name = "rocm-path-${clr.version}";
paths = [
clr
hipblas-common
hipblas
rocblas
rocsolver
rocsparse
rocm-device-libs
rocm-smi
(linkFarm "rocm-llvm-subdir" { llvm = llvm.clang; })
];
}

View File

@@ -6,15 +6,12 @@
rocmUpdateScript,
pkg-config,
cmake,
ninja,
xxd,
rocm-device-libs,
elfutils,
libdrm,
numactl,
valgrind,
libxml2,
rocm-merged-llvm,
llvm,
}:
stdenv.mkDerivation (finalAttrs: {
@@ -31,22 +28,21 @@ stdenv.mkDerivation (finalAttrs: {
cmakeBuildType = "RelWithDebInfo";
separateDebugInfo = true;
__structuredAttrs = true;
strictDeps = true;
nativeBuildInputs = [
pkg-config
cmake
ninja
xxd
rocm-merged-llvm
xxd # used by create_hsaco_ascii_file.sh
llvm.rocm-toolchain
];
buildInputs = [
llvm.clang-unwrapped
llvm.llvm
elfutils
libdrm
numactl
# without valgrind, additional work for "kCodeCopyAligned11" is done in the installPhase
valgrind
libxml2
];
cmakeFlags = [
@@ -99,6 +95,9 @@ stdenv.mkDerivation (finalAttrs: {
substituteInPlace CMakeLists.txt \
--replace 'hsa/include/hsa' 'include/hsa'
substituteInPlace runtime/hsa-runtime/image/blit_src/CMakeLists.txt \
--replace-fail 'COMMAND clang' "COMMAND ${llvm.rocm-toolchain}/bin/clang"
export HIP_DEVICE_LIB_PATH="${rocm-device-libs}/amdgcn/bitcode"
'';

View File

@@ -50,7 +50,7 @@ stdenv.mkDerivation (finalAttrs: {
mv $out/libexec/rocm_smi/.rsmiBindings.py-wrapped $out/libexec/rocm_smi/rsmiBindings.py
''
# workaround: propagate libdrm/ manually
# rocmcxx doesn't automatically add buildInputs to isystem include path like
# rocm-toolchain doesn't automatically add buildInputs to isystem include path like
# wrapper based toolchains, cmake files often don't find_package(rocm-smi) so
# can't rely on cmake propagated interface
# upstream have been shipping libdrm copied into /opt/rocm

View File

@@ -6,7 +6,6 @@
cmake,
rocm-cmake,
clr,
git,
libxml2,
libedit,
zstd,
@@ -64,7 +63,6 @@ stdenv.mkDerivation (finalAttrs: {
];
buildInputs = [
git
libxml2
libedit
];

View File

@@ -16,11 +16,10 @@
numactl,
libpciaccess,
libxml2,
llvm,
elfutils,
mpi,
systemd,
gtest,
git,
python3Packages,
gpuTargets ? clr.gpuTargets,
}:
@@ -59,7 +58,6 @@ stdenv.mkDerivation (finalAttrs: {
cmake
clang
clr
git
python3Packages.lxml
python3Packages.cppheaderparser
python3Packages.pyyaml
@@ -68,12 +66,13 @@ stdenv.mkDerivation (finalAttrs: {
];
buildInputs = [
llvm.clang-unwrapped
llvm.llvm
numactl
libpciaccess
libxml2
elfutils
mpi
systemd
gtest
aqlprofile
];

View File

@@ -5,7 +5,6 @@
rocmUpdateScript,
cmake,
clr,
git,
rocdbgapi,
elfutils,
}:
@@ -24,7 +23,6 @@ stdenv.mkDerivation (finalAttrs: {
nativeBuildInputs = [
cmake
clr
git
];
buildInputs = [

View File

@@ -9,7 +9,6 @@
rocprim,
clr,
gfortran,
git,
gtest,
boost,
python3Packages,
@@ -49,7 +48,6 @@ stdenv.mkDerivation (finalAttrs: {
buildInputs = [
rocprim
git
]
++ lib.optionals (buildTests || buildBenchmarks) [
gtest