2023-01-20 10:41:00 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
2024-01-13 08:15:51 +00:00
|
|
|
, gcc12Stdenv
|
2020-07-18 16:06:22 +00:00
|
|
|
, fetchFromGitHub
|
2023-01-20 10:41:00 +00:00
|
|
|
, rocmUpdateScript
|
|
|
|
, pkg-config
|
2020-07-18 16:06:22 +00:00
|
|
|
, cmake
|
2021-12-24 04:21:11 +00:00
|
|
|
, ninja
|
2023-01-20 10:41:00 +00:00
|
|
|
, git
|
|
|
|
, doxygen
|
|
|
|
, sphinx
|
|
|
|
, lit
|
2020-07-18 16:06:22 +00:00
|
|
|
, libxml2
|
2022-10-30 15:09:59 +00:00
|
|
|
, libxcrypt
|
2023-01-20 10:41:00 +00:00
|
|
|
, libedit
|
|
|
|
, libffi
|
|
|
|
, mpfr
|
2020-07-18 16:06:22 +00:00
|
|
|
, zlib
|
2023-01-20 10:41:00 +00:00
|
|
|
, ncurses
|
|
|
|
, python3Packages
|
|
|
|
, buildDocs ? true
|
|
|
|
, buildMan ? true
|
|
|
|
, buildTests ? true
|
|
|
|
, targetName ? "llvm"
|
|
|
|
, targetDir ? "llvm"
|
|
|
|
, targetProjects ? [ ]
|
|
|
|
, targetRuntimes ? [ ]
|
2023-10-19 13:55:26 +00:00
|
|
|
, llvmTargetsToBuild ? [ "NATIVE" ] # "NATIVE" resolves into x86 or aarch64 depending on stdenv
|
2023-01-20 10:41:00 +00:00
|
|
|
, extraPatches ? [ ]
|
|
|
|
, extraNativeBuildInputs ? [ ]
|
|
|
|
, extraBuildInputs ? [ ]
|
|
|
|
, extraCMakeFlags ? [ ]
|
|
|
|
, extraPostPatch ? ""
|
|
|
|
, checkTargets ? [(
|
|
|
|
lib.optionalString buildTests (
|
|
|
|
if targetDir == "runtimes"
|
|
|
|
then "check-runtimes"
|
|
|
|
else "check-all"
|
|
|
|
)
|
|
|
|
)]
|
|
|
|
, extraPostInstall ? ""
|
2023-10-19 13:55:26 +00:00
|
|
|
, hardeningDisable ? [ ]
|
2023-05-24 13:37:59 +00:00
|
|
|
, requiredSystemFeatures ? [ ]
|
2023-01-20 10:41:00 +00:00
|
|
|
, extraLicenses ? [ ]
|
|
|
|
, isBroken ? false
|
2020-07-18 16:06:22 +00:00
|
|
|
}:
|
|
|
|
|
2024-01-13 08:15:51 +00:00
|
|
|
let stdenv' = stdenv; in
|
|
|
|
let stdenv =
|
|
|
|
if stdenv'.cc.cc.isGNU or false && lib.versionAtLeast stdenv'.cc.cc.version "13.0"
|
|
|
|
then gcc12Stdenv
|
|
|
|
else stdenv';
|
|
|
|
in
|
|
|
|
|
2020-07-18 16:06:22 +00:00
|
|
|
let
|
|
|
|
llvmNativeTarget =
|
|
|
|
if stdenv.isx86_64 then "X86"
|
|
|
|
else if stdenv.isAarch64 then "AArch64"
|
|
|
|
else throw "Unsupported ROCm LLVM platform";
|
2023-04-12 12:48:02 +00:00
|
|
|
inferNativeTarget = t: if t == "NATIVE" then llvmNativeTarget else t;
|
|
|
|
llvmTargetsToBuild' = [ "AMDGPU" ] ++ builtins.map inferNativeTarget llvmTargetsToBuild;
|
2022-11-27 09:42:12 +00:00
|
|
|
in stdenv.mkDerivation (finalAttrs: {
|
2023-01-20 10:41:00 +00:00
|
|
|
pname = "rocm-llvm-${targetName}";
|
2023-11-16 04:20:00 +00:00
|
|
|
version = "5.7.1";
|
2023-01-20 10:41:00 +00:00
|
|
|
|
|
|
|
outputs = [
|
|
|
|
"out"
|
|
|
|
] ++ lib.optionals buildDocs [
|
|
|
|
"doc"
|
|
|
|
] ++ lib.optionals buildMan [
|
|
|
|
"man"
|
|
|
|
"info" # Avoid `attribute 'info' missing` when using with wrapCC
|
|
|
|
];
|
2020-07-18 16:06:22 +00:00
|
|
|
|
2023-01-20 10:41:00 +00:00
|
|
|
patches = extraPatches;
|
2022-05-18 14:49:53 +00:00
|
|
|
|
2023-01-20 10:41:00 +00:00
|
|
|
src = fetchFromGitHub {
|
2024-01-02 11:29:13 +00:00
|
|
|
owner = "ROCm";
|
2023-01-20 10:41:00 +00:00
|
|
|
repo = "llvm-project";
|
|
|
|
rev = "rocm-${finalAttrs.version}";
|
2023-11-16 04:20:00 +00:00
|
|
|
hash = "sha256-0+lJnDiMntxCYbZBCSWvHOcKXexFfEzRfb49QbfOmK8=";
|
2023-01-20 10:41:00 +00:00
|
|
|
};
|
2020-07-18 16:06:22 +00:00
|
|
|
|
2023-01-20 10:41:00 +00:00
|
|
|
nativeBuildInputs = [
|
|
|
|
pkg-config
|
|
|
|
cmake
|
|
|
|
ninja
|
|
|
|
git
|
2024-07-27 06:49:29 +00:00
|
|
|
(python3Packages.python.withPackages (p: [ p.setuptools ]))
|
2023-01-20 10:41:00 +00:00
|
|
|
] ++ lib.optionals (buildDocs || buildMan) [
|
|
|
|
doxygen
|
|
|
|
sphinx
|
|
|
|
python3Packages.recommonmark
|
|
|
|
] ++ lib.optionals (buildTests && !finalAttrs.passthru.isLLVM) [
|
|
|
|
lit
|
|
|
|
] ++ extraNativeBuildInputs;
|
|
|
|
|
|
|
|
buildInputs = [
|
|
|
|
libxml2
|
|
|
|
libxcrypt
|
|
|
|
libedit
|
|
|
|
libffi
|
|
|
|
mpfr
|
|
|
|
] ++ extraBuildInputs;
|
|
|
|
|
|
|
|
propagatedBuildInputs = lib.optionals finalAttrs.passthru.isLLVM [
|
|
|
|
zlib
|
|
|
|
ncurses
|
|
|
|
];
|
2020-07-18 16:06:22 +00:00
|
|
|
|
2023-01-20 10:41:00 +00:00
|
|
|
sourceRoot = "${finalAttrs.src.name}/${targetDir}";
|
2020-07-18 16:06:22 +00:00
|
|
|
|
2023-01-20 10:41:00 +00:00
|
|
|
cmakeFlags = [
|
2023-04-12 12:48:02 +00:00
|
|
|
"-DLLVM_TARGETS_TO_BUILD=${builtins.concatStringsSep ";" llvmTargetsToBuild'}"
|
2023-01-20 10:41:00 +00:00
|
|
|
] ++ lib.optionals (finalAttrs.passthru.isLLVM && targetProjects != [ ]) [
|
|
|
|
"-DLLVM_ENABLE_PROJECTS=${lib.concatStringsSep ";" targetProjects}"
|
|
|
|
] ++ lib.optionals ((finalAttrs.passthru.isLLVM || targetDir == "runtimes") && targetRuntimes != [ ]) [
|
|
|
|
"-DLLVM_ENABLE_RUNTIMES=${lib.concatStringsSep ";" targetRuntimes}"
|
2023-10-19 13:55:26 +00:00
|
|
|
] ++ lib.optionals finalAttrs.passthru.isLLVM [
|
|
|
|
"-DLLVM_INSTALL_UTILS=ON"
|
|
|
|
"-DLLVM_INSTALL_GTEST=ON"
|
2023-01-20 10:41:00 +00:00
|
|
|
] ++ lib.optionals (buildDocs || buildMan) [
|
|
|
|
"-DLLVM_INCLUDE_DOCS=ON"
|
2020-07-18 16:06:22 +00:00
|
|
|
"-DLLVM_BUILD_DOCS=ON"
|
2023-01-20 10:41:00 +00:00
|
|
|
# "-DLLVM_ENABLE_DOXYGEN=ON" Way too slow, only uses one core
|
2020-07-18 16:06:22 +00:00
|
|
|
"-DLLVM_ENABLE_SPHINX=ON"
|
2023-01-20 10:41:00 +00:00
|
|
|
"-DSPHINX_OUTPUT_HTML=ON"
|
2020-07-18 16:06:22 +00:00
|
|
|
"-DSPHINX_OUTPUT_MAN=ON"
|
|
|
|
"-DSPHINX_WARNINGS_AS_ERRORS=OFF"
|
2023-01-20 10:41:00 +00:00
|
|
|
] ++ lib.optionals buildTests [
|
|
|
|
"-DLLVM_INCLUDE_TESTS=ON"
|
|
|
|
"-DLLVM_BUILD_TESTS=ON"
|
|
|
|
"-DLLVM_EXTERNAL_LIT=${lit}/bin/.lit-wrapped"
|
|
|
|
] ++ extraCMakeFlags;
|
|
|
|
|
|
|
|
postPatch = lib.optionalString finalAttrs.passthru.isLLVM ''
|
2022-03-30 09:31:56 +00:00
|
|
|
patchShebangs lib/OffloadArch/make_generated_offload_arch_h.sh
|
2023-01-20 10:41:00 +00:00
|
|
|
'' + lib.optionalString (buildTests && finalAttrs.passthru.isLLVM) ''
|
|
|
|
# FileSystem permissions tests fail with various special bits
|
|
|
|
rm test/tools/llvm-objcopy/ELF/mirror-permissions-unix.test
|
|
|
|
rm unittests/Support/Path.cpp
|
|
|
|
|
|
|
|
substituteInPlace unittests/Support/CMakeLists.txt \
|
|
|
|
--replace "Path.cpp" ""
|
|
|
|
'' + extraPostPatch;
|
|
|
|
|
|
|
|
doCheck = buildTests;
|
|
|
|
checkTarget = lib.concatStringsSep " " checkTargets;
|
|
|
|
|
2023-10-19 13:55:26 +00:00
|
|
|
postInstall = lib.optionalString buildMan ''
|
2023-01-20 10:41:00 +00:00
|
|
|
mkdir -p $info
|
|
|
|
'' + extraPostInstall;
|
2020-07-18 16:06:22 +00:00
|
|
|
|
2022-12-17 10:02:37 +00:00
|
|
|
passthru = {
|
2023-01-20 10:41:00 +00:00
|
|
|
isLLVM = targetDir == "llvm";
|
|
|
|
isClang = targetDir == "clang" || builtins.elem "clang" targetProjects;
|
|
|
|
|
|
|
|
updateScript = rocmUpdateScript {
|
|
|
|
name = finalAttrs.pname;
|
|
|
|
owner = finalAttrs.src.owner;
|
|
|
|
repo = finalAttrs.src.repo;
|
2022-12-17 10:02:37 +00:00
|
|
|
};
|
2023-01-20 10:41:00 +00:00
|
|
|
};
|
2022-08-21 13:32:41 +00:00
|
|
|
|
2023-10-19 13:55:26 +00:00
|
|
|
inherit hardeningDisable requiredSystemFeatures;
|
2023-05-24 13:37:59 +00:00
|
|
|
|
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";
|
2024-01-02 11:29:13 +00:00
|
|
|
homepage = "https://github.com/ROCm/llvm-project";
|
2023-01-20 10:41:00 +00:00
|
|
|
license = with licenses; [ ncsa ] ++ extraLicenses;
|
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;
|
2024-01-02 11:29:13 +00:00
|
|
|
broken = isBroken || versionAtLeast finalAttrs.version "6.0.0";
|
2020-07-18 16:06:22 +00:00
|
|
|
};
|
2022-11-27 09:42:12 +00:00
|
|
|
})
|