Replace deprecated stdenv.lib

This commit is contained in:
Ehmry - 2021-03-03 00:04:31 +01:00
parent 73c8b62645
commit 707ec1828c
10 changed files with 75 additions and 73 deletions

View File

@ -1,4 +1,4 @@
{ stdenv, fetch, cmake, libxml2, llvm, version, clang-tools-extra_src, python3, lld
{ lib, stdenv, fetch, cmake, libxml2, llvm, version, clang-tools-extra_src, python3, lld
, fixDarwinDylibNames
, enableManpages ? false
}:
@ -20,15 +20,15 @@ let
'';
nativeBuildInputs = [ cmake python3 lld ]
++ stdenv.lib.optional enableManpages python3.pkgs.sphinx
++ stdenv.lib.optional stdenv.hostPlatform.isDarwin fixDarwinDylibNames;
++ lib.optional enableManpages python3.pkgs.sphinx
++ lib.optional stdenv.hostPlatform.isDarwin fixDarwinDylibNames;
buildInputs = [ libxml2 llvm ];
cmakeFlags = [
"-DCMAKE_CXX_FLAGS=-std=c++14"
"-DCLANGD_BUILD_XPC=OFF"
] ++ stdenv.lib.optionals enableManpages [
] ++ lib.optionals enableManpages [
"-DCLANG_INCLUDE_DOCS=ON"
"-DLLVM_ENABLE_SPHINX=ON"
"-DSPHINX_OUTPUT_MAN=ON"
@ -49,9 +49,9 @@ let
# Patch for standalone doc building
sed -i '1s,^,find_package(Sphinx REQUIRED)\n,' docs/CMakeLists.txt
'' + stdenv.lib.optionalString (stdenv.hostPlatform.isMusl || stdenv.targetPlatform.isGenode) ''
'' + lib.optionalString (stdenv.hostPlatform.isMusl || stdenv.targetPlatform.isGenode) ''
sed -i -e 's/lgcc_s/lgcc_eh/' lib/Driver/ToolChains/*.cpp
'' + stdenv.lib.optionalString stdenv.hostPlatform.isDarwin ''
'' + lib.optionalString stdenv.hostPlatform.isDarwin ''
substituteInPlace tools/extra/clangd/CMakeLists.txt \
--replace "NOT HAVE_CXX_ATOMICS64_WITHOUT_LIB" FALSE
'';
@ -92,10 +92,10 @@ let
meta = {
description = "A c, c++, objective-c, and objective-c++ frontend for the llvm compiler";
homepage = "https://llvm.org/";
license = stdenv.lib.licenses.ncsa;
platforms = stdenv.lib.platforms.all;
license = lib.licenses.ncsa;
platforms = lib.platforms.all;
};
} // stdenv.lib.optionalAttrs enableManpages {
} // lib.optionalAttrs enableManpages {
pname = "clang-manpages";
buildPhase = ''

View File

@ -1,4 +1,4 @@
{ stdenv, version, fetch, cmake, python3, llvm, libcxxabi }:
{ lib, stdenv, version, fetch, cmake, python3, llvm, libcxxabi }:
let
@ -14,7 +14,7 @@ stdenv.mkDerivation rec {
src = fetch pname "0d5j5l8phwqjjscmk8rmqn0i2i0abl537gdbkagl8fjpzy1gyjip";
nativeBuildInputs = [ cmake python3 llvm ];
buildInputs = stdenv.lib.optional stdenv.hostPlatform.isDarwin libcxxabi;
buildInputs = lib.optional stdenv.hostPlatform.isDarwin libcxxabi;
NIX_CFLAGS_COMPILE = [
"-DSCUDO_DEFAULT_OPTIONS=DeleteSizeMismatch=0:DeallocationTypeMismatch=0"
@ -24,24 +24,24 @@ stdenv.mkDerivation rec {
"-DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON"
"-DCMAKE_C_COMPILER_TARGET=${stdenv.hostPlatform.config}"
"-DCMAKE_ASM_COMPILER_TARGET=${stdenv.hostPlatform.config}"
] ++ stdenv.lib.optionals (stdenv.isDarwin) [
] ++ lib.optionals (stdenv.isDarwin) [
"-DDARWIN_macosx_OVERRIDE_SDK_VERSION=ON"
] ++ stdenv.lib.optionals (useLLVM || bareMetal || isMusl) [
] ++ lib.optionals (useLLVM || bareMetal || isMusl) [
"-DCOMPILER_RT_BUILD_SANITIZERS=OFF"
"-DCOMPILER_RT_BUILD_XRAY=OFF"
"-DCOMPILER_RT_BUILD_LIBFUZZER=OFF"
"-DCOMPILER_RT_BUILD_PROFILE=OFF"
] ++ stdenv.lib.optionals (useLLVM || bareMetal) [
] ++ lib.optionals (useLLVM || bareMetal) [
"-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)}"
] ++ stdenv.lib.optionals (useLLVM) [
] ++ lib.optionals (useLLVM) [
"-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"
] ++ stdenv.lib.optionals (bareMetal) [
] ++ lib.optionals (bareMetal) [
"-DCOMPILER_RT_OS_DIR=baremetal"
];
@ -50,8 +50,8 @@ stdenv.mkDerivation rec {
patches = [
./compiler-rt-codesign.patch # Revert compiler-rt commit that makes codesign mandatory
./compiler-rt-X86-support-extension.patch # Add support for i486 i586 i686 by reusing i386 config
]# ++ stdenv.lib.optional stdenv.hostPlatform.isMusl ./sanitizers-nongnu.patch
++ stdenv.lib.optional stdenv.hostPlatform.isAarch32 ./compiler-rt-armv7l.patch;
]# ++ lib.optional stdenv.hostPlatform.isMusl ./sanitizers-nongnu.patch
++ lib.optional stdenv.hostPlatform.isAarch32 ./compiler-rt-armv7l.patch;
# TSAN requires XPC on Darwin, which we have no public/free source files for. We can depend on the Apple frameworks
@ -59,15 +59,15 @@ stdenv.mkDerivation rec {
# 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 = stdenv.lib.optionalString (!stdenv.isDarwin) ''
postPatch = lib.optionalString (!stdenv.isDarwin) ''
substituteInPlace cmake/builtin-config-ix.cmake \
--replace 'set(X86 i386)' 'set(X86 i386 i486 i586 i686)'
'' + stdenv.lib.optionalString stdenv.isDarwin ''
'' + lib.optionalString stdenv.isDarwin ''
substituteInPlace cmake/builtin-config-ix.cmake \
--replace 'set(ARM64 arm64 arm64e)' 'set(ARM64)'
substituteInPlace cmake/config-ix.cmake \
--replace 'set(COMPILER_RT_HAS_TSAN TRUE)' 'set(COMPILER_RT_HAS_TSAN FALSE)'
'' + stdenv.lib.optionalString (useLLVM) ''
'' + lib.optionalString (useLLVM) ''
substituteInPlace lib/builtins/int_util.c \
--replace "#include <stdlib.h>" ""
substituteInPlace lib/builtins/clear_cache.c \
@ -77,9 +77,9 @@ stdenv.mkDerivation rec {
'';
# Hack around weird upsream RPATH bug
postInstall = stdenv.lib.optionalString (stdenv.hostPlatform.isDarwin || stdenv.hostPlatform.isWasm) ''
postInstall = lib.optionalString (stdenv.hostPlatform.isDarwin || stdenv.hostPlatform.isWasm) ''
ln -s "$out/lib"/*/* "$out/lib"
'' + stdenv.lib.optionalString (useLLVM) ''
'' + lib.optionalString (useLLVM) ''
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

View File

@ -1,4 +1,4 @@
{ lowPrio, newScope, pkgs, stdenv, cmake, gccForLibs
{ lib, lowPrio, newScope, pkgs, stdenv, cmake, gccForLibs
, libxml2, python3, isl, fetchurl, overrideCC, wrapCCWith, wrapBintoolsWith
, buildPackages
, buildLlvmTools # tools, but from the previous stage, for cross
@ -18,7 +18,7 @@ let
clang-tools-extra_src = fetch "clang-tools-extra" "02bcwwn54661madhq4nxc069s7p7pj5gpqi8ww50w3anbpviilzy";
tools = stdenv.lib.makeExtensible (tools: let
tools = lib.makeExtensible (tools: let
callPackage = newScope (tools // { inherit stdenv cmake libxml2 python3 isl release_version version fetch; });
mkExtraBuildCommands = cc: ''
rsrc="$out/resource-root"
@ -27,7 +27,7 @@ let
ln -s "${targetLlvmLibraries.compiler-rt.out}/lib" "$rsrc/lib"
ln -s "${targetLlvmLibraries.compiler-rt.out}/share" "$rsrc/share"
echo "-resource-dir=$rsrc" >> $out/nix-support/cc-cflags
'' + stdenv.lib.optionalString (stdenv.targetPlatform.isLinux && !(stdenv.targetPlatform.useLLVM or false)) ''
'' + lib.optionalString (stdenv.targetPlatform.isLinux && !(stdenv.targetPlatform.useLLVM or false)) ''
echo "--gcc-toolchain=${gccForLibs}" >> $out/nix-support/cc-cflags
'';
in {
@ -124,14 +124,14 @@ let
bintools = wrapBintoolsWith { inherit (tools) bintools; };
extraPackages =
[ targetLlvmLibraries.libcxxabi targetLlvmLibraries.compiler-rt ]
++ stdenv.lib.optionals (!stdenv.targetPlatform.isWasm)
++ lib.optionals (!stdenv.targetPlatform.isWasm)
[ targetLlvmLibraries.libunwind ];
extraBuildCommands = ''
echo "-rtlib=compiler-rt -Wno-unused-command-line-argument" >> $out/nix-support/cc-cflags
echo "-B${targetLlvmLibraries.compiler-rt}/lib" >> $out/nix-support/cc-cflags
'' + stdenv.lib.optionalString (!stdenv.targetPlatform.isWasm) ''
'' + lib.optionalString (!stdenv.targetPlatform.isWasm) ''
echo "--unwindlib=libunwind" >> $out/nix-support/cc-cflags
'' + stdenv.lib.optionalString stdenv.targetPlatform.isWasm ''
'' + lib.optionalString stdenv.targetPlatform.isWasm ''
echo "-fno-exceptions" >> $out/nix-support/cc-cflags
'' + mkExtraBuildCommands cc;
};
@ -183,12 +183,12 @@ let
});
libraries = stdenv.lib.makeExtensible (libraries: let
libraries = lib.makeExtensible (libraries: let
callPackage = newScope (libraries // buildLlvmTools // { inherit stdenv cmake libxml2 python3 isl release_version version fetch; });
in {
compiler-rt = callPackage ./compiler-rt.nix ({} //
(stdenv.lib.optionalAttrs (stdenv.hostPlatform.useLLVM or false) {
(lib.optionalAttrs (stdenv.hostPlatform.useLLVM or false) {
stdenv = overrideCC stdenv buildLlvmTools.lldClangNoCompilerRt;
}));
@ -197,12 +197,12 @@ let
libcxxStdenv = overrideCC stdenv buildLlvmTools.libcxxClang;
libcxx = callPackage ./libc++ ({} //
(stdenv.lib.optionalAttrs (stdenv.hostPlatform.useLLVM or false) {
(lib.optionalAttrs (stdenv.hostPlatform.useLLVM or false) {
stdenv = overrideCC stdenv buildLlvmTools.lldClangNoLibcxx;
}));
libcxxabi = callPackage ./libc++abi.nix ({} //
(stdenv.lib.optionalAttrs (stdenv.hostPlatform.useLLVM or false) {
(lib.optionalAttrs (stdenv.hostPlatform.useLLVM or false) {
stdenv = overrideCC stdenv buildLlvmTools.lldClangNoLibcxx;
libunwind = libraries.libunwind;
}));
@ -210,7 +210,7 @@ let
openmp = callPackage ./openmp.nix {};
libunwind = callPackage ./libunwind.nix ({} //
(stdenv.lib.optionalAttrs (stdenv.hostPlatform.useLLVM or false) {
(lib.optionalAttrs (stdenv.hostPlatform.useLLVM or false) {
stdenv = overrideCC stdenv buildLlvmTools.lldClangNoLibcxx;
}));

View File

@ -25,13 +25,13 @@ stdenv.mkDerivation {
cmakeFlags = [
"-DLIBCXX_CXX_ABI=libcxxabi"
] ++ stdenv.lib.optional (stdenv.hostPlatform.isMusl || stdenv.hostPlatform.isWasi) "-DLIBCXX_HAS_MUSL_LIBC=1"
++ stdenv.lib.optional (stdenv.hostPlatform.useLLVM or false) "-DLIBCXX_USE_COMPILER_RT=ON"
++ stdenv.lib.optional stdenv.hostPlatform.isWasm [
] ++ lib.optional (stdenv.hostPlatform.isMusl || stdenv.hostPlatform.isWasi) "-DLIBCXX_HAS_MUSL_LIBC=1"
++ lib.optional (stdenv.hostPlatform.useLLVM or false) "-DLIBCXX_USE_COMPILER_RT=ON"
++ lib.optional stdenv.hostPlatform.isWasm [
"-DLIBCXX_ENABLE_THREADS=OFF"
"-DLIBCXX_ENABLE_FILESYSTEM=OFF"
"-DLIBCXX_ENABLE_EXCEPTIONS=OFF"
] ++ stdenv.lib.optional (!enableShared) "-DLIBCXX_ENABLE_SHARED=OFF";
] ++ lib.optional (!enableShared) "-DLIBCXX_ENABLE_SHARED=OFF";
enableParallelBuilding = true;
@ -42,7 +42,7 @@ stdenv.mkDerivation {
meta = {
homepage = "https://libcxx.llvm.org/";
description = "A new implementation of the C++ standard library, targeting C++11";
license = with stdenv.lib.licenses; [ ncsa mit ];
platforms = stdenv.lib.platforms.all;
license = with lib.licenses; [ ncsa mit ];
platforms = lib.platforms.all;
};
}

View File

@ -1,4 +1,4 @@
{ stdenv, cmake, fetch, libcxx, libunwind, llvm, version
{ lib, stdenv, cmake, fetch, libcxx, libunwind, llvm, version
, enableShared ? true }:
stdenv.mkDerivation {
@ -8,15 +8,15 @@ stdenv.mkDerivation {
src = fetch "libcxxabi" "05ac7rkjbla03bc0lf92f901dfjgxdvp8cr9fpn59a5p4x27ssaq";
nativeBuildInputs = [ cmake ];
buildInputs = stdenv.lib.optional (!stdenv.isDarwin && !stdenv.isFreeBSD && !stdenv.hostPlatform.isWasm) libunwind;
buildInputs = lib.optional (!stdenv.isDarwin && !stdenv.isFreeBSD && !stdenv.hostPlatform.isWasm) libunwind;
cmakeFlags = stdenv.lib.optionals (stdenv.hostPlatform.useLLVM or false) [
cmakeFlags = lib.optionals (stdenv.hostPlatform.useLLVM or false) [
"-DLLVM_ENABLE_LIBCXX=ON"
"-DLIBCXXABI_USE_LLVM_UNWINDER=ON"
] ++ stdenv.lib.optionals stdenv.hostPlatform.isWasm [
] ++ lib.optionals stdenv.hostPlatform.isWasm [
"-DLIBCXXABI_ENABLE_THREADS=OFF"
"-DLIBCXXABI_ENABLE_EXCEPTIONS=OFF"
] ++ stdenv.lib.optionals (!enableShared) [
] ++ lib.optionals (!enableShared) [
"-DLIBCXXABI_ENABLE_SHARED=OFF"
];
@ -27,11 +27,11 @@ stdenv.mkDerivation {
mv libcxx-* libcxx
unpackFile ${llvm.src}
mv llvm-* llvm
'' + stdenv.lib.optionalString stdenv.isDarwin ''
'' + lib.optionalString stdenv.isDarwin ''
export TRIPLE=x86_64-apple-darwin
'' + stdenv.lib.optionalString stdenv.hostPlatform.isMusl ''
'' + lib.optionalString stdenv.hostPlatform.isMusl ''
patch -p1 -d libcxx -i ${../libcxx-0001-musl-hacks.patch}
'' + stdenv.lib.optionalString stdenv.hostPlatform.isWasm ''
'' + lib.optionalString stdenv.hostPlatform.isWasm ''
patch -p1 -d llvm -i ${./libcxxabi-wasm.patch}
'';
@ -52,7 +52,7 @@ stdenv.mkDerivation {
install -d -m 755 $out/include $out/lib
install -m 644 lib/libc++abi.a $out/lib
install -m 644 ../include/cxxabi.h $out/include
'' + stdenv.lib.optionalString enableShared ''
'' + lib.optionalString enableShared ''
install -m 644 lib/libc++abi.so.1.0 $out/lib
ln -s libc++abi.so.1.0 $out/lib/libc++abi.so
ln -s libc++abi.so.1.0 $out/lib/libc++abi.so.1
@ -61,8 +61,8 @@ stdenv.mkDerivation {
meta = {
homepage = "https://libcxxabi.llvm.org/";
description = "A new implementation of low level support for a standard C++ library";
license = with stdenv.lib.licenses; [ ncsa mit ];
maintainers = with stdenv.lib.maintainers; [ vlstill ];
platforms = stdenv.lib.platforms.all;
license = with lib.licenses; [ ncsa mit ];
maintainers = with lib.maintainers; [ vlstill ];
platforms = lib.platforms.all;
};
}

View File

@ -1,4 +1,4 @@
{ stdenv, version, fetch, cmake, fetchpatch, enableShared ? true }:
{ lib, stdenv, version, fetch, cmake, fetchpatch, enableShared ? true }:
stdenv.mkDerivation rec {
pname = "libunwind";
@ -10,5 +10,5 @@ stdenv.mkDerivation rec {
enableParallelBuilding = true;
cmakeFlags = stdenv.lib.optional (!enableShared) "-DLIBUNWIND_ENABLE_SHARED=OFF";
cmakeFlags = lib.optional (!enableShared) "-DLIBUNWIND_ENABLE_SHARED=OFF";
}

View File

@ -1,4 +1,5 @@
{ stdenv
{ lib
, stdenv
, fetch
, cmake
, libxml2
@ -29,7 +30,7 @@ stdenv.mkDerivation rec {
meta = {
description = "The LLVM Linker";
homepage = "https://lld.llvm.org/";
license = stdenv.lib.licenses.ncsa;
platforms = stdenv.lib.platforms.all;
license = lib.licenses.ncsa;
platforms = lib.platforms.all;
};
}

View File

@ -25,7 +25,7 @@ stdenv.mkDerivation (rec {
patches = [ ./lldb-procfs.patch ];
nativeBuildInputs = [ cmake python3 which swig lit ]
++ stdenv.lib.optionals enableManpages [ python3.pkgs.sphinx python3.pkgs.recommonmark ];
++ lib.optionals enableManpages [ python3.pkgs.sphinx python3.pkgs.recommonmark ];
buildInputs = [
ncurses
@ -34,7 +34,7 @@ stdenv.mkDerivation (rec {
libxml2
llvm
]
++ stdenv.lib.optionals stdenv.isDarwin [
++ lib.optionals stdenv.isDarwin [
darwin.libobjc
darwin.apple_sdk.libs.xpc
darwin.apple_sdk.frameworks.Foundation
@ -49,11 +49,11 @@ stdenv.mkDerivation (rec {
"-DLLVM_ENABLE_RTTI=OFF"
"-DClang_DIR=${clang-unwrapped}/lib/cmake"
"-DLLVM_EXTERNAL_LIT=${lit}/bin/lit"
] ++ stdenv.lib.optionals stdenv.isDarwin [
] ++ lib.optionals stdenv.isDarwin [
"-DLLDB_USE_SYSTEM_DEBUGSERVER=ON"
] ++ stdenv.lib.optionals (!stdenv.isDarwin) [
] ++ lib.optionals (!stdenv.isDarwin) [
"-DLLDB_CODESIGN_IDENTITY=" # codesigning makes nondeterministic
] ++ stdenv.lib.optionals enableManpages [
] ++ lib.optionals enableManpages [
"-DLLVM_ENABLE_SPHINX=ON"
"-DSPHINX_OUTPUT_MAN=ON"
"-DSPHINX_OUTPUT_HTML=OFF"
@ -69,13 +69,13 @@ stdenv.mkDerivation (rec {
ln -s $out/bin/lldb-vscode $out/share/vscode/extensions/llvm-org.lldb-vscode-0.1.0/bin
'';
meta = with stdenv.lib; {
meta = with lib; {
description = "A next-generation high-performance debugger";
homepage = "https://lldb.llvm.org";
license = licenses.ncsa;
platforms = platforms.all;
};
} // stdenv.lib.optionalAttrs enableManpages {
} // lib.optionalAttrs enableManpages {
pname = "lldb-manpages";
buildPhase = ''

View File

@ -1,4 +1,5 @@
{ stdenv
{ lib
, stdenv
, fetch
, cmake
, python3
@ -22,10 +23,10 @@
}:
let
inherit (stdenv.lib) optional optionals optionalString;
inherit (lib) optional optionals optionalString;
# Used when creating a version-suffixed symlink of libLLVM.dylib
shortVersion = with stdenv.lib;
shortVersion = with lib;
concatStringsSep "." (take 1 (splitString "." release_version));
in stdenv.mkDerivation (rec {
@ -164,11 +165,11 @@ in stdenv.mkDerivation (rec {
meta = {
description = "Collection of modular and reusable compiler and toolchain technologies";
homepage = "https://llvm.org/";
license = stdenv.lib.licenses.ncsa;
maintainers = with stdenv.lib.maintainers; [ lovek323 raskin dtzWill primeos ];
platforms = stdenv.lib.platforms.all;
license = lib.licenses.ncsa;
maintainers = with lib.maintainers; [ lovek323 raskin dtzWill primeos ];
platforms = lib.platforms.all;
};
} // stdenv.lib.optionalAttrs enableManpages {
} // lib.optionalAttrs enableManpages {
pname = "llvm-manpages";
buildPhase = ''

View File

@ -20,7 +20,7 @@ stdenv.mkDerivation rec {
meta = {
description = "Components required to build an executable OpenMP program";
homepage = "https://openmp.llvm.org/";
license = stdenv.lib.licenses.mit;
platforms = stdenv.lib.platforms.all;
license = lib.licenses.mit;
platforms = lib.platforms.all;
};
}