2021-09-18 10:52:07 +00:00
|
|
|
{ stdenv, lib, buildPackages, fetchFromGitHub, callPackage, wrapCCWith, overrideCC }:
|
2020-07-18 16:06:22 +00:00
|
|
|
|
|
|
|
let
|
2021-09-18 10:52:07 +00:00
|
|
|
version = "4.3.1";
|
2020-07-18 16:06:22 +00:00
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "RadeonOpenCompute";
|
|
|
|
repo = "llvm-project";
|
|
|
|
rev = "rocm-${version}";
|
2021-09-18 10:52:07 +00:00
|
|
|
hash = "sha256-7XVtHcrTpw+NYUvuKQFWWFE0FlOTt8EnfZpvepQqE1c=";
|
2020-07-18 16:06:22 +00:00
|
|
|
};
|
|
|
|
in rec {
|
|
|
|
clang = 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"
|
2021-09-18 10:52:07 +00:00
|
|
|
ln -s "${cc}/lib/clang/$clang_version/include" "$rsrc"
|
|
|
|
ln -s "${compiler-rt}/lib" "$rsrc/lib"
|
2020-07-18 16:06:22 +00:00
|
|
|
echo "-resource-dir=$rsrc" >> $out/nix-support/cc-cflags
|
2021-09-18 10:52:07 +00:00
|
|
|
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
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
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
|
2020-07-18 16:06:22 +00:00
|
|
|
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";
|
|
|
|
};
|
|
|
|
|
2021-09-18 10:52:07 +00:00
|
|
|
compiler-rt = callPackage ./compiler-rt {
|
|
|
|
inherit version llvm;
|
|
|
|
src = "${src}/compiler-rt";
|
|
|
|
stdenv = overrideCC stdenv clangNoCompilerRt;
|
|
|
|
};
|
|
|
|
|
|
|
|
lld = callPackage ./lld.nix {
|
2020-07-18 16:06:22 +00:00
|
|
|
inherit llvm version;
|
|
|
|
src = "${src}/lld";
|
|
|
|
};
|
|
|
|
|
2021-04-12 18:23:04 +00:00
|
|
|
llvm = callPackage ./llvm {
|
2020-07-18 16:06:22 +00:00
|
|
|
inherit version;
|
|
|
|
src = "${src}/llvm";
|
|
|
|
};
|
|
|
|
}
|