2021-01-22 12:25:31 +01:00
|
|
|
{ lib, stdenv
|
2020-07-10 19:28:08 +02:00
|
|
|
, fetchFromGitHub
|
|
|
|
, cmake
|
|
|
|
, python3
|
|
|
|
, libxml2
|
|
|
|
, libffi
|
|
|
|
, libbfd
|
|
|
|
, ncurses
|
|
|
|
, zlib
|
|
|
|
, debugVersion ? false
|
|
|
|
, enableManpages ? false
|
|
|
|
, enableSharedLibraries ? true
|
|
|
|
|
|
|
|
, version
|
|
|
|
, src
|
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
|
|
|
llvmNativeTarget =
|
|
|
|
if stdenv.isx86_64 then "X86"
|
|
|
|
else if stdenv.isAarch64 then "AArch64"
|
|
|
|
else throw "Unsupported ROCm LLVM platform";
|
|
|
|
in stdenv.mkDerivation rec {
|
|
|
|
inherit src version;
|
|
|
|
|
|
|
|
pname = "rocm-llvm";
|
|
|
|
|
|
|
|
outputs = [ "out" "python" ]
|
2021-01-22 12:25:31 +01:00
|
|
|
++ lib.optional enableSharedLibraries "lib";
|
2020-07-10 19:28:08 +02:00
|
|
|
|
|
|
|
nativeBuildInputs = [ cmake python3 ];
|
|
|
|
|
|
|
|
buildInputs = [ libxml2 libffi ];
|
|
|
|
|
|
|
|
propagatedBuildInputs = [ ncurses zlib ];
|
|
|
|
|
|
|
|
cmakeFlags = with stdenv; [
|
|
|
|
"-DCMAKE_BUILD_TYPE=${if debugVersion then "Debug" else "Release"}"
|
|
|
|
"-DLLVM_INSTALL_UTILS=ON" # Needed by rustc
|
|
|
|
"-DLLVM_BUILD_TESTS=OFF"
|
|
|
|
"-DLLVM_ENABLE_FFI=ON"
|
|
|
|
"-DLLVM_ENABLE_RTTI=ON"
|
|
|
|
"-DLLVM_ENABLE_DUMP=ON"
|
|
|
|
"-DLLVM_TARGETS_TO_BUILD=AMDGPU;${llvmNativeTarget}"
|
|
|
|
]
|
|
|
|
++
|
2021-01-22 12:25:31 +01:00
|
|
|
lib.optional
|
2020-07-10 19:28:08 +02:00
|
|
|
enableSharedLibraries
|
|
|
|
"-DLLVM_LINK_LLVM_DYLIB=ON"
|
2021-01-22 12:25:31 +01:00
|
|
|
++ lib.optionals enableManpages [
|
2020-07-10 19:28:08 +02: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"
|
|
|
|
];
|
|
|
|
|
|
|
|
postPatch = ''
|
|
|
|
substitute '${./llvm-outputs.patch}' ./llvm-outputs.patch --subst-var lib
|
|
|
|
patch -p1 < ./llvm-outputs.patch
|
|
|
|
'';
|
|
|
|
|
|
|
|
# hacky fix: created binaries need to be run before installation
|
|
|
|
preBuild = ''
|
|
|
|
mkdir -p $out/
|
|
|
|
ln -sv $PWD/lib $out
|
|
|
|
'';
|
|
|
|
|
|
|
|
postBuild = ''
|
|
|
|
rm -fR $out
|
|
|
|
'';
|
|
|
|
|
|
|
|
preCheck = ''
|
|
|
|
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$PWD/lib
|
|
|
|
'';
|
|
|
|
|
|
|
|
postInstall = ''
|
|
|
|
moveToOutput share/opt-viewer "$python"
|
|
|
|
''
|
2021-01-22 12:25:31 +01:00
|
|
|
+ lib.optionalString enableSharedLibraries ''
|
2020-07-10 19:28:08 +02:00
|
|
|
moveToOutput "lib/libLLVM-*" "$lib"
|
|
|
|
moveToOutput "lib/libLLVM${stdenv.hostPlatform.extensions.sharedLibrary}" "$lib"
|
|
|
|
substituteInPlace "$out/lib/cmake/llvm/LLVMExports-${if debugVersion then "debug" else "release"}.cmake" \
|
|
|
|
--replace "\''${_IMPORT_PREFIX}/lib/libLLVM-" "$lib/lib/libLLVM-"
|
|
|
|
'';
|
|
|
|
|
|
|
|
passthru.src = src;
|
|
|
|
|
2021-01-22 12:25:31 +01:00
|
|
|
meta = with lib; {
|
2020-07-10 19:28:08 +02:00
|
|
|
description = "ROCm fork of the LLVM compiler infrastructure";
|
|
|
|
homepage = "https://github.com/RadeonOpenCompute/llvm-project";
|
|
|
|
license = with licenses; [ ncsa ];
|
|
|
|
maintainers = with maintainers; [ danieldk ];
|
|
|
|
platforms = platforms.linux;
|
|
|
|
};
|
|
|
|
}
|