uboot: (firmwareOdroidC2/C4) don't invoke patch tool, use patches = [] instead
https://github.com/NixOS/nixpkgs/blob/master/pkgs/stdenv/generic/setup.sh#L948 this can do it nicely. Signed-off-by: Anton Arapov <anton@deadbeef.mx>
This commit is contained in:
commit
56de2bcd43
30691 changed files with 3076956 additions and 0 deletions
72
pkgs/development/compilers/llvm/rocm/clang.nix
Normal file
72
pkgs/development/compilers/llvm/rocm/clang.nix
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
{ stdenv
|
||||
, lib
|
||||
, fetchFromGitHub
|
||||
, cmake
|
||||
, python3
|
||||
, llvm
|
||||
, clang-tools-extra_src ? null
|
||||
, lld
|
||||
|
||||
, version
|
||||
, src
|
||||
}:
|
||||
|
||||
stdenv.mkDerivation rec {
|
||||
inherit version src;
|
||||
|
||||
pname = "clang";
|
||||
|
||||
nativeBuildInputs = [ cmake python3 ];
|
||||
|
||||
buildInputs = [ llvm ];
|
||||
|
||||
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 = 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
|
||||
'';
|
||||
|
||||
passthru = {
|
||||
isClang = true;
|
||||
inherit llvm;
|
||||
};
|
||||
|
||||
meta = with 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; [ acowley lovesegfault ];
|
||||
platforms = platforms.linux;
|
||||
};
|
||||
}
|
||||
64
pkgs/development/compilers/llvm/rocm/compiler-rt/default.nix
Normal file
64
pkgs/development/compilers/llvm/rocm/compiler-rt/default.nix
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
{ stdenv, lib, version, src, cmake, python3, llvm, libcxxabi, fetchpatch }:
|
||||
stdenv.mkDerivation rec {
|
||||
pname = "compiler-rt";
|
||||
inherit version src;
|
||||
|
||||
nativeBuildInputs = [ cmake python3 llvm ];
|
||||
|
||||
NIX_CFLAGS_COMPILE = [
|
||||
"-DSCUDO_DEFAULT_OPTIONS=DeleteSizeMismatch=0:DeallocationTypeMismatch=0"
|
||||
];
|
||||
|
||||
cmakeFlags = [
|
||||
"-DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON"
|
||||
"-DCMAKE_C_COMPILER_TARGET=${stdenv.hostPlatform.config}"
|
||||
"-DCMAKE_ASM_COMPILER_TARGET=${stdenv.hostPlatform.config}"
|
||||
"-DCOMPILER_RT_BUILD_SANITIZERS=OFF"
|
||||
"-DCOMPILER_RT_BUILD_XRAY=OFF"
|
||||
"-DCOMPILER_RT_BUILD_LIBFUZZER=OFF"
|
||||
"-DCOMPILER_RT_BUILD_PROFILE=OFF"
|
||||
"-DCMAKE_C_COMPILER_WORKS=ON"
|
||||
"-DCMAKE_CXX_COMPILER_WORKS=ON"
|
||||
"-DCOMPILER_RT_BAREMETAL_BUILD=ON"
|
||||
"-DCMAKE_SIZEOF_VOID_P=${toString (stdenv.hostPlatform.parsed.cpu.bits / 8)}"
|
||||
"-DCOMPILER_RT_BUILD_BUILTINS=ON"
|
||||
"-DCMAKE_C_FLAGS=-nodefaultlibs"
|
||||
#https://stackoverflow.com/questions/53633705/cmake-the-c-compiler-is-not-able-to-compile-a-simple-test-program
|
||||
"-DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY"
|
||||
];
|
||||
|
||||
outputs = [ "out" "dev" ];
|
||||
|
||||
prePatch = ''
|
||||
cd compiler-rt
|
||||
'';
|
||||
|
||||
# TSAN requires XPC on Darwin, which we have no public/free source files for. We can depend on the Apple frameworks
|
||||
# to get it, but they're unfree. Since LLVM is rather central to the stdenv, we patch out TSAN support so that Hydra
|
||||
# can build this. If we didn't do it, basically the entire nixpkgs on Darwin would have an unfree dependency and we'd
|
||||
# get no binary cache for the entire platform. If you really find yourself wanting the TSAN, make this controllable by
|
||||
# a flag and turn the flag off during the stdenv build.
|
||||
postPatch = lib.optionalString (!stdenv.isDarwin) ''
|
||||
substituteInPlace cmake/builtin-config-ix.cmake \
|
||||
--replace 'set(X86 i386)' 'set(X86 i386 i486 i586 i686)'
|
||||
'';
|
||||
|
||||
# Hack around weird upsream RPATH bug
|
||||
postInstall = ''
|
||||
ln -s "$out/lib"/*/* "$out/lib"
|
||||
ln -s $out/lib/*/clang_rt.crtbegin-*.o $out/lib/crtbegin.o
|
||||
ln -s $out/lib/*/clang_rt.crtend-*.o $out/lib/crtend.o
|
||||
ln -s $out/lib/*/clang_rt.crtbegin_shared-*.o $out/lib/crtbeginS.o
|
||||
ln -s $out/lib/*/clang_rt.crtend_shared-*.o $out/lib/crtendS.o
|
||||
'';
|
||||
|
||||
enableParallelBuilding = true;
|
||||
|
||||
meta = with lib; {
|
||||
description = "ROCm fork of the LLVM Compiler runtime libraries";
|
||||
homepage = "https://github.com/RadeonOpenCompute/llvm-project";
|
||||
license = licenses.ncsa;
|
||||
maintainers = with maintainers; [ acowley lovesegfault ];
|
||||
platforms = platforms.linux;
|
||||
};
|
||||
}
|
||||
61
pkgs/development/compilers/llvm/rocm/default.nix
Normal file
61
pkgs/development/compilers/llvm/rocm/default.nix
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
{ stdenv, lib, buildPackages, fetchFromGitHub, callPackage, wrapCCWith, overrideCC }:
|
||||
|
||||
let
|
||||
version = "5.1.1";
|
||||
src = fetchFromGitHub {
|
||||
owner = "RadeonOpenCompute";
|
||||
repo = "llvm-project";
|
||||
rev = "rocm-${version}";
|
||||
hash = "sha256-5SGIWiyfHvfwIUc4bhdWrlhBfK5ssA7tm5r3zKdr3kg=";
|
||||
};
|
||||
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"
|
||||
ln -s "${compiler-rt}/lib" "$rsrc/lib"
|
||||
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
|
||||
'';
|
||||
};
|
||||
|
||||
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
|
||||
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";
|
||||
};
|
||||
|
||||
compiler-rt = callPackage ./compiler-rt {
|
||||
inherit version llvm;
|
||||
inherit src;
|
||||
stdenv = overrideCC stdenv clangNoCompilerRt;
|
||||
};
|
||||
|
||||
lld = callPackage ./lld.nix {
|
||||
inherit llvm src version;
|
||||
};
|
||||
|
||||
llvm = callPackage ./llvm {
|
||||
inherit src version;
|
||||
};
|
||||
}
|
||||
43
pkgs/development/compilers/llvm/rocm/lld.nix
Normal file
43
pkgs/development/compilers/llvm/rocm/lld.nix
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
{ stdenv
|
||||
, lib
|
||||
, cmake
|
||||
, libxml2
|
||||
, llvm
|
||||
, ninja
|
||||
|
||||
, version
|
||||
, src
|
||||
}:
|
||||
|
||||
stdenv.mkDerivation rec {
|
||||
inherit version src;
|
||||
|
||||
sourceRoot = "${src.name}/lld";
|
||||
|
||||
pname = "lld";
|
||||
|
||||
nativeBuildInputs = [ cmake ninja ];
|
||||
|
||||
buildInputs = [ libxml2 llvm ];
|
||||
|
||||
outputs = [ "out" "dev" ];
|
||||
|
||||
cmakeFlags = [ "-DLLVM_MAIN_SRC_DIR=${src}/llvm" ];
|
||||
|
||||
postInstall = ''
|
||||
moveToOutput include "$dev"
|
||||
moveToOutput lib "$dev"
|
||||
|
||||
# Fix lld binary path for CMake.
|
||||
substituteInPlace "$dev/lib/cmake/lld/LLDTargets-release.cmake" \
|
||||
--replace "\''${_IMPORT_PREFIX}/bin/lld" "$out/bin/lld"
|
||||
'';
|
||||
|
||||
meta = with lib; {
|
||||
description = "ROCm fork of the LLVM Linker";
|
||||
homepage = "https://github.com/RadeonOpenCompute/llvm-project";
|
||||
license = licenses.ncsa;
|
||||
maintainers = with maintainers; [ acowley lovesegfault ];
|
||||
platforms = platforms.linux;
|
||||
};
|
||||
}
|
||||
121
pkgs/development/compilers/llvm/rocm/llvm/default.nix
Normal file
121
pkgs/development/compilers/llvm/rocm/llvm/default.nix
Normal file
|
|
@ -0,0 +1,121 @@
|
|||
{ stdenv
|
||||
, lib
|
||||
, fetchFromGitHub
|
||||
, writeScript
|
||||
, cmake
|
||||
, ninja
|
||||
, python3
|
||||
, libxml2
|
||||
, libffi
|
||||
, libbfd
|
||||
, ncurses
|
||||
, zlib
|
||||
, debugVersion ? false
|
||||
, enableManpages ? false
|
||||
, enableSharedLibraries ? false
|
||||
|
||||
, 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";
|
||||
|
||||
sourceRoot = "${src.name}/llvm";
|
||||
|
||||
outputs = [ "out" "python" ]
|
||||
++ lib.optional enableSharedLibraries "lib";
|
||||
|
||||
nativeBuildInputs = [ cmake ninja 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}"
|
||||
]
|
||||
++
|
||||
lib.optional
|
||||
enableSharedLibraries
|
||||
"-DLLVM_LINK_LLVM_DYLIB=ON"
|
||||
++ 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 = ''
|
||||
patchShebangs lib/OffloadArch/make_generated_offload_arch_h.sh
|
||||
'' + lib.optionalString enableSharedLibraries ''
|
||||
substitute '${./outputs.patch}' ./outputs.patch --subst-var lib
|
||||
patch -p1 < ./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''${LD_LIBRARY_PATH:+:}$PWD/lib
|
||||
'';
|
||||
|
||||
postInstall = ''
|
||||
moveToOutput share/opt-viewer "$python"
|
||||
''
|
||||
+ 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;
|
||||
|
||||
updateScript = writeScript "update.sh" ''
|
||||
#!/usr/bin/env nix-shell
|
||||
#!nix-shell -i bash -p curl jq common-updater-scripts nix-prefetch-github
|
||||
|
||||
version="$(curl -sL "https://api.github.com/repos/RadeonOpenCompute/llvm-project/releases?per_page=1" | jq '.[0].tag_name | split("-") | .[1]' --raw-output)"
|
||||
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
|
||||
'';
|
||||
|
||||
meta = with lib; {
|
||||
description = "ROCm fork of the LLVM compiler infrastructure";
|
||||
homepage = "https://github.com/RadeonOpenCompute/llvm-project";
|
||||
license = with licenses; [ ncsa ];
|
||||
maintainers = with maintainers; [ acowley lovesegfault ];
|
||||
platforms = platforms.linux;
|
||||
};
|
||||
}
|
||||
16
pkgs/development/compilers/llvm/rocm/llvm/outputs.patch
Normal file
16
pkgs/development/compilers/llvm/rocm/llvm/outputs.patch
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
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,11 @@ int main(int argc, char **argv) {
|
||||
ActiveIncludeOption = "-I" + ActiveIncludeDir;
|
||||
}
|
||||
|
||||
+ /// Nix-specific multiple-output handling: override ActiveLibDir
|
||||
+ if (!IsInDevelopmentTree) {
|
||||
+ 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,
|
||||
Loading…
Add table
Add a link
Reference in a new issue