llvmPackages_rocm: init at 3.5.1
This commit is contained in:
parent
d2d402a695
commit
e492cd92a9
67
pkgs/development/compilers/llvm/rocm/clang.nix
Normal file
67
pkgs/development/compilers/llvm/rocm/clang.nix
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
{ stdenv
|
||||||
|
, fetchFromGitHub
|
||||||
|
, cmake
|
||||||
|
, python
|
||||||
|
, llvm
|
||||||
|
, clang-tools-extra_src ? null
|
||||||
|
, rocm-runtime
|
||||||
|
, lld
|
||||||
|
|
||||||
|
, version
|
||||||
|
, src
|
||||||
|
}:
|
||||||
|
|
||||||
|
stdenv.mkDerivation rec {
|
||||||
|
inherit version src;
|
||||||
|
|
||||||
|
pname = "clang";
|
||||||
|
|
||||||
|
nativeBuildInputs = [ cmake python ];
|
||||||
|
|
||||||
|
buildInputs = [ llvm rocm-runtime ];
|
||||||
|
|
||||||
|
hardeningDisable = [ "all" ];
|
||||||
|
|
||||||
|
cmakeFlags = [
|
||||||
|
"-DLLVM_CMAKE_PATH=${llvm}/lib/cmake/llvm"
|
||||||
|
"-DLLVM_MAIN_SRC_DIR=${llvm.src}"
|
||||||
|
"-DCLANG_SOURCE_DIR=${src}"
|
||||||
|
"-DLLVM_ENABLE_RTTI=ON"
|
||||||
|
];
|
||||||
|
|
||||||
|
VCSVersion = ''
|
||||||
|
#undef LLVM_REVISION
|
||||||
|
#undef LLVM_REPOSITORY
|
||||||
|
#undef CLANG_REVISION
|
||||||
|
#undef CLANG_REPOSITORY
|
||||||
|
'';
|
||||||
|
|
||||||
|
postUnpack = stdenv.lib.optionalString (!(isNull clang-tools-extra_src)) ''
|
||||||
|
ln -s ${clang-tools-extra_src} $sourceRoot/tools/extra
|
||||||
|
'';
|
||||||
|
|
||||||
|
# Rather than let cmake extract version information from LLVM or
|
||||||
|
# clang source control repositories, we generate the wanted
|
||||||
|
# `VCSVersion.inc` file ourselves and remove it from the
|
||||||
|
# depencencies of the `clangBasic` target.
|
||||||
|
preConfigure = ''
|
||||||
|
sed 's/ ''${version_inc}//' -i lib/Basic/CMakeLists.txt
|
||||||
|
sed 's|sys::path::parent_path(BundlerExecutable)|StringRef("${llvm}/bin")|' -i tools/clang-offload-bundler/ClangOffloadBundler.cpp
|
||||||
|
sed 's|\([[:space:]]*std::string Linker = \)getToolChain().GetProgramPath(getShortName())|\1"${lld}/bin/ld.lld"|' -i lib/Driver/ToolChains/AMDGPU.cpp
|
||||||
|
substituteInPlace lib/Driver/ToolChains/AMDGPU.h --replace ld.lld ${lld}/bin/ld.lld
|
||||||
|
sed 's|configure_file(AST/gen_ast_dump_json_test.py ''${LLVM_TOOLS_BINARY_DIR}/gen_ast_dump_json_test.py COPYONLY)||' -i test/CMakeLists.txt
|
||||||
|
'';
|
||||||
|
|
||||||
|
postConfigure = ''
|
||||||
|
mkdir -p lib/Basic
|
||||||
|
echo "$VCSVersion" > lib/Basic/VCSVersion.inc
|
||||||
|
'';
|
||||||
|
|
||||||
|
meta = with stdenv.lib; {
|
||||||
|
description = "ROCm fork of the clang C/C++/Objective-C/Objective-C++ LLVM compiler frontend";
|
||||||
|
homepage = "https://llvm.org/";
|
||||||
|
license = with licenses; [ ncsa ];
|
||||||
|
maintainers = with maintainers; [ danieldk ];
|
||||||
|
platforms = platforms.linux;
|
||||||
|
};
|
||||||
|
}
|
41
pkgs/development/compilers/llvm/rocm/default.nix
Normal file
41
pkgs/development/compilers/llvm/rocm/default.nix
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
{ stdenv, fetchFromGitHub, callPackage, wrapCCWith }:
|
||||||
|
|
||||||
|
let
|
||||||
|
version = "3.5.1";
|
||||||
|
src = fetchFromGitHub {
|
||||||
|
owner = "RadeonOpenCompute";
|
||||||
|
repo = "llvm-project";
|
||||||
|
rev = "rocm-${version}";
|
||||||
|
sha256 = "03k2xp8wf4awf1zcjc2hb3kf9bqp567c3s569gp1q3q1zjg6r2ib";
|
||||||
|
};
|
||||||
|
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"
|
||||||
|
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
|
||||||
|
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";
|
||||||
|
};
|
||||||
|
|
||||||
|
lld = callPackage ./lld.nix {
|
||||||
|
inherit llvm version;
|
||||||
|
src = "${src}/lld";
|
||||||
|
};
|
||||||
|
|
||||||
|
llvm = callPackage ./llvm.nix {
|
||||||
|
inherit version;
|
||||||
|
src = "${src}/llvm";
|
||||||
|
};
|
||||||
|
}
|
33
pkgs/development/compilers/llvm/rocm/lld.nix
Normal file
33
pkgs/development/compilers/llvm/rocm/lld.nix
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
{ stdenv
|
||||||
|
, cmake
|
||||||
|
, libxml2
|
||||||
|
, llvm
|
||||||
|
|
||||||
|
, version
|
||||||
|
, src
|
||||||
|
}:
|
||||||
|
|
||||||
|
stdenv.mkDerivation rec {
|
||||||
|
inherit version src;
|
||||||
|
|
||||||
|
pname = "lld";
|
||||||
|
|
||||||
|
nativeBuildInputs = [ cmake ];
|
||||||
|
|
||||||
|
buildInputs = [ libxml2 llvm ];
|
||||||
|
|
||||||
|
outputs = [ "out" "dev" ];
|
||||||
|
|
||||||
|
postInstall = ''
|
||||||
|
moveToOutput include "$dev"
|
||||||
|
moveToOutput lib "$dev"
|
||||||
|
'';
|
||||||
|
|
||||||
|
meta = with stdenv.lib; {
|
||||||
|
description = "ROCm fork of the LLVM Linker";
|
||||||
|
homepage = "https://github.com/RadeonOpenCompute/llvm-project";
|
||||||
|
license = licenses.ncsa;
|
||||||
|
maintainers = with maintainers; [ danieldk ];
|
||||||
|
platforms = platforms.linux;
|
||||||
|
};
|
||||||
|
}
|
26
pkgs/development/compilers/llvm/rocm/llvm-outputs.patch
Normal file
26
pkgs/development/compilers/llvm/rocm/llvm-outputs.patch
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
diff --git a/tools/llvm-config/llvm-config.cpp b/tools/llvm-config/llvm-config.cpp
|
||||||
|
index 94d426b..37f7794 100644
|
||||||
|
--- a/tools/llvm-config/llvm-config.cpp
|
||||||
|
+++ b/tools/llvm-config/llvm-config.cpp
|
||||||
|
@@ -333,6 +333,21 @@ int main(int argc, char **argv) {
|
||||||
|
ActiveIncludeOption = "-I" + ActiveIncludeDir;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ /// Nix-specific multiple-output handling: override ActiveLibDir if --link-shared
|
||||||
|
+ if (!IsInDevelopmentTree) {
|
||||||
|
+ bool WantShared = true;
|
||||||
|
+ for (int i = 1; i < argc; ++i) {
|
||||||
|
+ StringRef Arg = argv[i];
|
||||||
|
+ if (Arg == "--link-shared")
|
||||||
|
+ WantShared = true;
|
||||||
|
+ else if (Arg == "--link-static")
|
||||||
|
+ WantShared = false; // the last one wins
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ if (WantShared)
|
||||||
|
+ ActiveLibDir = std::string("@lib@") + "/lib" + LLVM_LIBDIR_SUFFIX;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
/// We only use `shared library` mode in cases where the static library form
|
||||||
|
/// of the components provided are not available; note however that this is
|
||||||
|
/// skipped if we're run from within the build dir. However, once installed,
|
97
pkgs/development/compilers/llvm/rocm/llvm.nix
Normal file
97
pkgs/development/compilers/llvm/rocm/llvm.nix
Normal file
@ -0,0 +1,97 @@
|
|||||||
|
{ stdenv
|
||||||
|
, 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" ]
|
||||||
|
++ stdenv.lib.optional enableSharedLibraries "lib";
|
||||||
|
|
||||||
|
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}"
|
||||||
|
]
|
||||||
|
++
|
||||||
|
stdenv.lib.optional
|
||||||
|
enableSharedLibraries
|
||||||
|
"-DLLVM_LINK_LLVM_DYLIB=ON"
|
||||||
|
++ stdenv.lib.optionals enableManpages [
|
||||||
|
"-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"
|
||||||
|
''
|
||||||
|
+ stdenv.lib.optionalString enableSharedLibraries ''
|
||||||
|
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;
|
||||||
|
|
||||||
|
meta = with stdenv.lib; {
|
||||||
|
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;
|
||||||
|
};
|
||||||
|
}
|
@ -9101,6 +9101,8 @@ in
|
|||||||
|
|
||||||
llvmPackages_latest = llvmPackages_10;
|
llvmPackages_latest = llvmPackages_10;
|
||||||
|
|
||||||
|
llvmPackages_rocm = callPackage ../development/compilers/llvm/rocm { };
|
||||||
|
|
||||||
lorri = callPackage ../tools/misc/lorri {
|
lorri = callPackage ../tools/misc/lorri {
|
||||||
inherit (darwin.apple_sdk.frameworks) CoreServices Security;
|
inherit (darwin.apple_sdk.frameworks) CoreServices Security;
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user