2021-09-18 10:52:07 +00:00
|
|
|
{ stdenv
|
|
|
|
, lib
|
2022-08-21 13:32:41 +00:00
|
|
|
, fetchgit
|
2020-07-18 16:06:22 +00:00
|
|
|
, fetchFromGitHub
|
2021-09-18 10:52:07 +00:00
|
|
|
, writeScript
|
2020-07-18 16:06:22 +00:00
|
|
|
, cmake
|
2021-12-24 04:21:11 +00:00
|
|
|
, ninja
|
2020-07-18 16:06:22 +00:00
|
|
|
, python3
|
|
|
|
, libxml2
|
|
|
|
, libffi
|
|
|
|
, libbfd
|
2022-10-30 15:09:59 +00:00
|
|
|
, libxcrypt
|
2020-07-18 16:06:22 +00:00
|
|
|
, ncurses
|
|
|
|
, zlib
|
|
|
|
, debugVersion ? false
|
|
|
|
, enableManpages ? false
|
|
|
|
|
|
|
|
, version
|
|
|
|
, src
|
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
|
|
|
llvmNativeTarget =
|
|
|
|
if stdenv.isx86_64 then "X86"
|
|
|
|
else if stdenv.isAarch64 then "AArch64"
|
|
|
|
else throw "Unsupported ROCm LLVM platform";
|
2022-11-27 09:42:12 +00:00
|
|
|
in stdenv.mkDerivation (finalAttrs: {
|
2020-07-18 16:06:22 +00:00
|
|
|
inherit src version;
|
|
|
|
|
|
|
|
pname = "rocm-llvm";
|
|
|
|
|
2022-05-18 14:49:53 +00:00
|
|
|
sourceRoot = "${src.name}/llvm";
|
|
|
|
|
2021-12-24 04:21:11 +00:00
|
|
|
nativeBuildInputs = [ cmake ninja python3 ];
|
2020-07-18 16:06:22 +00:00
|
|
|
|
2022-10-30 15:09:59 +00:00
|
|
|
buildInputs = [ libxml2 libxcrypt ];
|
2020-07-18 16:06:22 +00:00
|
|
|
|
|
|
|
propagatedBuildInputs = [ ncurses zlib ];
|
|
|
|
|
|
|
|
cmakeFlags = with stdenv; [
|
|
|
|
"-DCMAKE_BUILD_TYPE=${if debugVersion then "Debug" else "Release"}"
|
|
|
|
"-DLLVM_INSTALL_UTILS=ON" # Needed by rustc
|
|
|
|
"-DLLVM_TARGETS_TO_BUILD=AMDGPU;${llvmNativeTarget}"
|
2022-12-02 08:20:57 +00:00
|
|
|
"-DLLVM_ENABLE_PROJECTS=clang;lld;compiler-rt;clang-tools-extra"
|
2020-07-18 16:06:22 +00:00
|
|
|
]
|
2021-02-05 17:12:51 +00:00
|
|
|
++ lib.optionals enableManpages [
|
2020-07-18 16:06:22 +00:00
|
|
|
"-DLLVM_BINUTILS_INCDIR=${libbfd.dev}/include"
|
|
|
|
"-DLLVM_BUILD_DOCS=ON"
|
|
|
|
"-DLLVM_ENABLE_SPHINX=ON"
|
|
|
|
"-DSPHINX_OUTPUT_MAN=ON"
|
|
|
|
"-DSPHINX_OUTPUT_HTML=OFF"
|
|
|
|
"-DSPHINX_WARNINGS_AS_ERRORS=OFF"
|
|
|
|
];
|
|
|
|
|
2022-08-21 13:32:41 +00:00
|
|
|
patches = [
|
|
|
|
./install-symlinks.patch
|
|
|
|
];
|
|
|
|
|
2020-07-18 16:06:22 +00:00
|
|
|
postPatch = ''
|
2022-03-30 09:31:56 +00:00
|
|
|
patchShebangs lib/OffloadArch/make_generated_offload_arch_h.sh
|
2022-08-21 13:32:41 +00:00
|
|
|
substituteInPlace ../clang/cmake/modules/CMakeLists.txt \
|
|
|
|
--replace 'FILES_MATCHING' 'NO_SOURCE_PERMISSIONS FILES_MATCHING'
|
2020-07-18 16:06:22 +00:00
|
|
|
'';
|
|
|
|
|
2021-09-18 10:52:07 +00:00
|
|
|
updateScript = writeScript "update.sh" ''
|
|
|
|
#!/usr/bin/env nix-shell
|
|
|
|
#!nix-shell -i bash -p curl jq common-updater-scripts nix-prefetch-github
|
|
|
|
|
2022-12-02 08:20:57 +00:00
|
|
|
version="$(curl ''${GITHUB_TOKEN:+"-u \":$GITHUB_TOKEN\""} -sL "https://api.github.com/repos/RadeonOpenCompute/llvm-project/releases?per_page=1" | jq '.[0].tag_name | split("-") | .[1]' --raw-output)"
|
2021-09-18 10:52:07 +00:00
|
|
|
current_version="$(grep "version =" pkgs/development/compilers/llvm/rocm/default.nix | cut -d'"' -f2)"
|
|
|
|
if [[ "$version" != "$current_version" ]]; then
|
|
|
|
tarball_meta="$(nix-prefetch-github RadeonOpenCompute llvm-project --rev "rocm-$version")"
|
|
|
|
tarball_hash="$(nix to-base64 sha256-$(jq -r '.sha256' <<< "$tarball_meta"))"
|
|
|
|
sed -i "pkgs/development/compilers/llvm/rocm/default.nix" \
|
|
|
|
-e 's,version = "\(.*\)",version = "'"$version"'",' \
|
|
|
|
-e 's,hash = "\(.*\)",hash = "sha256-'"$tarball_hash"'",'
|
|
|
|
else
|
|
|
|
echo rocm-llvm already up-to-date
|
|
|
|
fi
|
|
|
|
'';
|
|
|
|
|
2022-08-21 13:32:41 +00:00
|
|
|
passthru.isClang = true;
|
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
meta = with lib; {
|
2020-07-18 16:06:22 +00:00
|
|
|
description = "ROCm fork of the LLVM compiler infrastructure";
|
|
|
|
homepage = "https://github.com/RadeonOpenCompute/llvm-project";
|
|
|
|
license = with licenses; [ ncsa ];
|
2022-11-27 09:42:12 +00:00
|
|
|
maintainers = with maintainers; [ acowley lovesegfault ] ++ teams.rocm.members;
|
2020-07-18 16:06:22 +00:00
|
|
|
platforms = platforms.linux;
|
|
|
|
};
|
2022-11-27 09:42:12 +00:00
|
|
|
})
|