pkgs/development/compilers: stdenv.lib -> lib

This commit is contained in:
Ben Siraphob
2021-01-23 08:57:37 +07:00
parent bbaff89ceb
commit acc5f7b18a
320 changed files with 1660 additions and 1657 deletions
@@ -1,4 +1,4 @@
{ stdenv, fetch, cmake, libxml2, llvm, version, clang-tools-extra_src, python3
{ lib, stdenv, fetch, cmake, libxml2, llvm, version, clang-tools-extra_src, python3
, fixDarwinDylibNames
, enableManpages ? false
}:
@@ -19,15 +19,15 @@ let
'';
nativeBuildInputs = [ cmake python3 ]
++ 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++11"
"-DLLVM_ENABLE_RTTI=ON"
] ++ stdenv.lib.optionals enableManpages [
] ++ lib.optionals enableManpages [
"-DCLANG_INCLUDE_DOCS=ON"
"-DLLVM_ENABLE_SPHINX=ON"
"-DSPHINX_OUTPUT_MAN=ON"
@@ -44,7 +44,7 @@ let
# Patch for standalone doc building
sed -i '1s,^,find_package(Sphinx REQUIRED)\n,' docs/CMakeLists.txt
'' + stdenv.lib.optionalString stdenv.hostPlatform.isMusl ''
'' + lib.optionalString stdenv.hostPlatform.isMusl ''
sed -i -e 's/lgcc_s/lgcc_eh/' lib/Driver/ToolChains/*.cpp
'';
@@ -80,10 +80,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 = ''
@@ -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 {
src = fetch "compiler-rt" "0ipd4jdxpczgr2w6lzrabymz6dhzj69ywmyybjjc1q397zgrvziy";
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 {
"-DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON"
"-DCMAKE_C_COMPILER_TARGET=${stdenv.hostPlatform.config}"
"-DCMAKE_ASM_COMPILER_TARGET=${stdenv.hostPlatform.config}"
] ++ 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"
] ++ stdenv.lib.optionals (stdenv.hostPlatform.isDarwin) [
] ++ lib.optionals (stdenv.hostPlatform.isDarwin) [
# The compiler-rt build infrastructure sniffs supported platforms on Darwin
# and finds i386;x86_64;x86_64h. We only build for x86_64, so linking fails
# when it tries to use libc++ and libc++api for i386.
@@ -53,19 +53,19 @@ stdenv.mkDerivation {
patches = [
./compiler-rt-codesign.patch # Revert compiler-rt commit that makes codesign mandatory
../7/compiler-rt-glibc.patch
] ++ stdenv.lib.optional stdenv.hostPlatform.isMusl ./sanitizers-nongnu.patch
++ stdenv.lib.optional (stdenv.hostPlatform.libc == "glibc") ./compiler-rt-sys-ustat.patch
++ stdenv.lib.optional stdenv.hostPlatform.isAarch32 ./compiler-rt-armv7l.patch;
] ++ lib.optional stdenv.hostPlatform.isMusl ./sanitizers-nongnu.patch
++ lib.optional (stdenv.hostPlatform.libc == "glibc") ./compiler-rt-sys-ustat.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
# 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 = stdenv.lib.optionalString stdenv.isDarwin ''
postPatch = lib.optionalString stdenv.isDarwin ''
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 \
@@ -75,9 +75,9 @@ stdenv.mkDerivation {
'';
# 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/linux/crtbegin.o
ln -s $out/lib/*/clang_rt.crtend-*.o $out/lib/linux/crtend.o
ln -s $out/lib/*/clang_rt.crtbegin_shared-*.o $out/lib/linux/crtbeginS.o
@@ -1,4 +1,4 @@
{ lowPrio, newScope, pkgs, stdenv, cmake, gccForLibs
{ lowPrio, newScope, pkgs, lib, stdenv, cmake, gccForLibs
, libxml2, python3, isl, fetchurl, overrideCC, wrapCCWith
, buildPackages
, buildLlvmTools # tools, but from the previous stage, for cross
@@ -17,7 +17,7 @@ let
clang-tools-extra_src = fetch "clang-tools-extra" "018b3fiwah8f8br5i26qmzh6sjvzchpn358sn8v079m49f2jldm3";
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"
@@ -25,7 +25,7 @@ let
ln -s "${cc}/lib/clang/${release_version}/include" "$rsrc"
ln -s "${targetLlvmLibraries.compiler-rt.out}/lib" "$rsrc/lib"
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 {
@@ -75,7 +75,7 @@ let
lldb = callPackage ./lldb.nix {};
});
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 {
@@ -11,7 +11,7 @@ stdenv.mkDerivation {
export LIBCXXABI_INCLUDE_DIR="$PWD/$(ls -d libcxxabi-${version}*)/include"
'';
patches = stdenv.lib.optionals stdenv.hostPlatform.isMusl [
patches = lib.optionals stdenv.hostPlatform.isMusl [
../../libcxx-0001-musl-hacks.patch
];
@@ -26,8 +26,8 @@ stdenv.mkDerivation {
patchShebangs utils/cat_files.py
'';
nativeBuildInputs = [ cmake ]
++ stdenv.lib.optional stdenv.hostPlatform.isMusl python3
++ stdenv.lib.optional stdenv.hostPlatform.isDarwin fixDarwinDylibNames;
++ lib.optional stdenv.hostPlatform.isMusl python3
++ lib.optional stdenv.hostPlatform.isDarwin fixDarwinDylibNames;
buildInputs = [ libcxxabi ];
@@ -35,7 +35,7 @@ stdenv.mkDerivation {
"-DLIBCXX_LIBCXXABI_LIB_PATH=${libcxxabi}/lib"
"-DLIBCXX_LIBCPPABI_VERSION=2"
"-DLIBCXX_CXX_ABI=libcxxabi"
] ++ stdenv.lib.optional stdenv.hostPlatform.isMusl "-DLIBCXX_HAS_MUSL_LIBC=1";
] ++ lib.optional stdenv.hostPlatform.isMusl "-DLIBCXX_HAS_MUSL_LIBC=1";
passthru = {
isLLVM = true;
@@ -44,7 +44,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.unix;
license = with lib.licenses; [ ncsa mit ];
platforms = lib.platforms.unix;
};
}
@@ -1,4 +1,4 @@
{ stdenv, cmake, fetch, libcxx, libunwind, llvm, version }:
{ lib, stdenv, cmake, fetch, libcxx, libunwind, llvm, version }:
stdenv.mkDerivation {
pname = "libc++abi";
@@ -7,15 +7,15 @@ stdenv.mkDerivation {
src = fetch "libcxxabi" "12lp799rskr4fc2xr64qn4jfkjnfd8b1aymvsxyn4k9ar7r9pgqv";
nativeBuildInputs = [ cmake ];
buildInputs = stdenv.lib.optional (!stdenv.isDarwin && !stdenv.isFreeBSD) libunwind;
buildInputs = lib.optional (!stdenv.isDarwin && !stdenv.isFreeBSD) libunwind;
postUnpack = ''
unpackFile ${libcxx.src}
unpackFile ${llvm.src}
export cmakeFlags="-DLLVM_PATH=$PWD/$(ls -d llvm-*) -DLIBCXXABI_LIBCXX_PATH=$PWD/$(ls -d libcxx-*)"
'' + 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 $(ls -d libcxx-*) -i ${../libcxx-0001-musl-hacks.patch}
'';
@@ -44,8 +44,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.unix;
license = with lib.licenses; [ ncsa mit ];
maintainers = with lib.maintainers; [ vlstill ];
platforms = lib.platforms.unix;
};
}
+3 -3
View File
@@ -1,4 +1,4 @@
{ stdenv
{ lib, stdenv
, fetch
, cmake
, llvm
@@ -24,8 +24,8 @@ stdenv.mkDerivation {
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;
badPlatforms = [ "x86_64-darwin" ];
};
}
+3 -3
View File
@@ -1,4 +1,4 @@
{ stdenv
{ lib, stdenv
, fetch
, fetchpatch
, cmake
@@ -42,7 +42,7 @@ stdenv.mkDerivation {
nativeBuildInputs = [ cmake python3 which swig ];
buildInputs = [ ncurses zlib libedit libxml2 llvm ]
++ stdenv.lib.optionals stdenv.isDarwin [ darwin.libobjc darwin.apple_sdk.libs.xpc darwin.apple_sdk.frameworks.Foundation darwin.bootstrap_cmds darwin.apple_sdk.frameworks.Carbon darwin.apple_sdk.frameworks.Cocoa ];
++ lib.optionals stdenv.isDarwin [ darwin.libobjc darwin.apple_sdk.libs.xpc darwin.apple_sdk.frameworks.Foundation darwin.bootstrap_cmds darwin.apple_sdk.frameworks.Carbon darwin.apple_sdk.frameworks.Cocoa ];
CXXFLAGS = "-fno-rtti";
hardeningDisable = [ "format" ];
@@ -56,7 +56,7 @@ stdenv.mkDerivation {
cp ../docs/lldb.1 $out/share/man/man1/
'';
meta = with stdenv.lib; {
meta = with lib; {
description = "A next-generation high-performance debugger";
homepage = "https://llvm.org/";
license = licenses.ncsa;
+19 -19
View File
@@ -1,4 +1,4 @@
{ stdenv
{ lib, stdenv
, fetch
, fetchpatch
, cmake
@@ -17,7 +17,7 @@
let
# Used when creating a versioned symlinks of libLLVM.dylib
versionSuffixes = with stdenv.lib;
versionSuffixes = with lib;
let parts = splitVersion release_version; in
imap (i: _: concatStringsSep "." (take i parts)) parts;
in
@@ -35,10 +35,10 @@ stdenv.mkDerivation ({
'';
outputs = [ "out" "python" ]
++ stdenv.lib.optional enableSharedLibraries "lib";
++ lib.optional enableSharedLibraries "lib";
nativeBuildInputs = [ cmake python3 ]
++ stdenv.lib.optional enableManpages python3.pkgs.sphinx;
++ lib.optional enableManpages python3.pkgs.sphinx;
buildInputs = [ libxml2 libffi ];
@@ -58,13 +58,13 @@ stdenv.mkDerivation ({
# stripLen = 1;
#})
];
postPatch = stdenv.lib.optionalString stdenv.isDarwin ''
postPatch = lib.optionalString stdenv.isDarwin ''
substituteInPlace cmake/modules/AddLLVM.cmake \
--replace 'set(_install_name_dir INSTALL_NAME_DIR "@rpath")' "set(_install_name_dir)" \
--replace 'set(_install_rpath "@loader_path/../lib" ''${extra_libdir})' ""
''
# Patch llvm-config to return correct library path based on --link-{shared,static}.
+ stdenv.lib.optionalString (enableSharedLibraries) ''
+ lib.optionalString (enableSharedLibraries) ''
substitute '${./llvm-outputs.patch}' ./llvm-outputs.patch --subst-var lib
patch -p1 < ./llvm-outputs.patch
'' + ''
@@ -72,9 +72,9 @@ stdenv.mkDerivation ({
substituteInPlace unittests/Support/CMakeLists.txt \
--replace "Path.cpp" ""
rm unittests/Support/Path.cpp
'' + stdenv.lib.optionalString stdenv.isAarch64 ''
'' + lib.optionalString stdenv.isAarch64 ''
patch -p0 < ${../aarch64.patch}
'' + stdenv.lib.optionalString stdenv.hostPlatform.isMusl ''
'' + lib.optionalString stdenv.hostPlatform.isMusl ''
patch -p1 -i ${../TLI-musl.patch}
substituteInPlace unittests/Support/CMakeLists.txt \
--replace "add_subdirectory(DynamicLibrary)" ""
@@ -98,18 +98,18 @@ stdenv.mkDerivation ({
"-DLLVM_DEFAULT_TARGET_TRIPLE=${stdenv.hostPlatform.config}"
"-DTARGET_TRIPLE=${stdenv.hostPlatform.config}"
]
++ stdenv.lib.optional enableSharedLibraries
++ lib.optional enableSharedLibraries
"-DLLVM_LINK_LLVM_DYLIB=ON"
++ stdenv.lib.optionals enableManpages [
++ lib.optionals enableManpages [
"-DLLVM_BUILD_DOCS=ON"
"-DLLVM_ENABLE_SPHINX=ON"
"-DSPHINX_OUTPUT_MAN=ON"
"-DSPHINX_OUTPUT_HTML=OFF"
"-DSPHINX_WARNINGS_AS_ERRORS=OFF"
]
++ stdenv.lib.optional (!isDarwin)
++ lib.optional (!isDarwin)
"-DLLVM_BINUTILS_INCDIR=${libbfd.dev}/include"
++ stdenv.lib.optionals (isDarwin) [
++ lib.optionals (isDarwin) [
"-DLLVM_ENABLE_LIBCXX=ON"
"-DCAN_TARGET_i386=false"
];
@@ -126,18 +126,18 @@ stdenv.mkDerivation ({
mkdir -p $python/share
mv $out/share/opt-viewer $python/share/opt-viewer
''
+ stdenv.lib.optionalString enableSharedLibraries ''
+ lib.optionalString enableSharedLibraries ''
moveToOutput "lib/libLLVM-*" "$lib"
moveToOutput "lib/libLLVM${stdenv.hostPlatform.extensions.sharedLibrary}" "$lib"
moveToOutput "lib/libLTO${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-"
''
+ stdenv.lib.optionalString (stdenv.isDarwin && enableSharedLibraries) ''
+ lib.optionalString (stdenv.isDarwin && enableSharedLibraries) ''
substituteInPlace "$out/lib/cmake/llvm/LLVMExports-${if debugVersion then "debug" else "release"}.cmake" \
--replace "\''${_IMPORT_PREFIX}/lib/libLLVM.dylib" "$lib/lib/libLLVM.dylib" \
--replace "\''${_IMPORT_PREFIX}/lib/libLTO.dylib" "$lib/lib/libLTO.dylib"
${stdenv.lib.concatMapStringsSep "\n" (v: ''
${lib.concatMapStringsSep "\n" (v: ''
ln -s $lib/lib/libLLVM.dylib $lib/lib/libLLVM-${v}.dylib
'') versionSuffixes}
'';
@@ -150,11 +150,11 @@ stdenv.mkDerivation ({
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 ];
platforms = stdenv.lib.platforms.all;
license = lib.licenses.ncsa;
maintainers = with lib.maintainers; [ lovek323 raskin dtzWill ];
platforms = lib.platforms.all;
};
} // stdenv.lib.optionalAttrs enableManpages {
} // lib.optionalAttrs enableManpages {
pname = "llvm-manpages";
buildPhase = ''
+2 -2
View File
@@ -18,7 +18,7 @@ stdenv.mkDerivation {
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;
};
}