mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-02-04 19:24:20 +00:00
ec590fdd24
This is the supported way rocm is tested. It makes packaging in nix a *lot* easier (see the code size). An important change is the dontLink detection in the clang/clang++ wrapper script: When compiling with --cuda-device-only, the linker must not be set, otherwise e.g. the blender kernels fail to compile.
55 lines
2.3 KiB
Nix
55 lines
2.3 KiB
Nix
{ stdenv, lib, buildPackages, fetchFromGitHub, callPackage, wrapCCWith, overrideCC }:
|
|
|
|
let
|
|
version = "5.2.1";
|
|
src = fetchFromGitHub {
|
|
owner = "RadeonOpenCompute";
|
|
repo = "llvm-project";
|
|
rev = "rocm-${version}";
|
|
hash = "sha256-sudH8hnjReyuCFm2CBEPd8W88SjAARgCd1MTIJaDjTI=";
|
|
};
|
|
in rec {
|
|
clang = wrapCCWith rec {
|
|
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 "${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
|
|
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 = 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"
|
|
echo "-resource-dir=$rsrc" >> $out/nix-support/cc-cflags
|
|
echo "--gcc-toolchain=${stdenv.cc.cc}" >> $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 ;;'
|
|
'';
|
|
};
|
|
|
|
llvm = callPackage ./llvm.nix {
|
|
inherit src version;
|
|
};
|
|
}
|