forked from mirrors/nixpkgs
C++ Compilers: Systematize handling of standard libraries
This commit is contained in:
parent
e00d4d6021
commit
f3f7612a40
|
@ -177,7 +177,7 @@ stdenv.mkDerivation ({
|
|||
|
||||
BINDGEN_CFLAGS="$(< ${stdenv.cc}/nix-support/libc-cflags) \
|
||||
$(< ${stdenv.cc}/nix-support/cc-cflags) \
|
||||
${stdenv.cc.default_cxx_stdlib_compile} \
|
||||
$(< ${stdenv.cc}/nix-support/libcxx-cxxflags) \
|
||||
${lib.optionalString stdenv.cc.isClang "-idirafter ${stdenv.cc.cc}/lib/clang/${lib.getVersion stdenv.cc.cc}/include"} \
|
||||
${lib.optionalString stdenv.cc.isGNU "-isystem ${stdenv.cc.cc}/include/c++/${lib.getVersion stdenv.cc.cc} -isystem ${stdenv.cc.cc}/include/c++/${lib.getVersion stdenv.cc.cc}/${stdenv.hostPlatform.config}"} \
|
||||
$NIX_CFLAGS_COMPILE"
|
||||
|
|
|
@ -179,7 +179,7 @@ stdenv.mkDerivation rec {
|
|||
|
||||
BINDGEN_CFLAGS="$(< ${stdenv.cc}/nix-support/libc-cflags) \
|
||||
$(< ${stdenv.cc}/nix-support/cc-cflags) \
|
||||
${stdenv.cc.default_cxx_stdlib_compile} \
|
||||
$(< ${stdenv.cc}/nix-support/libcxx-cxxflags) \
|
||||
${
|
||||
lib.optionalString stdenv.cc.isClang
|
||||
"-idirafter ${stdenv.cc.cc}/lib/clang/${
|
||||
|
|
|
@ -37,6 +37,14 @@ if [ -e @out@/nix-support/libc-cflags ]; then
|
|||
NIX_CFLAGS_COMPILE_@suffixSalt@="$(< @out@/nix-support/libc-cflags) $NIX_CFLAGS_COMPILE_@suffixSalt@"
|
||||
fi
|
||||
|
||||
if [ -e @out@/nix-support/libcxx-cxxflags ]; then
|
||||
NIX_CXXSTDLIB_COMPILE_@suffixSalt@+=" $(< @out@/nix-support/libcxx-cxxflags)"
|
||||
fi
|
||||
|
||||
if [ -e @out@/nix-support/libcxx-ldflags ]; then
|
||||
NIX_CXXSTDLIB_LINK_@suffixSalt@+=" $(< @out@/nix-support/libcxx-ldflags)"
|
||||
fi
|
||||
|
||||
if [ -e @out@/nix-support/cc-cflags ]; then
|
||||
NIX_CFLAGS_COMPILE_@suffixSalt@="$(< @out@/nix-support/cc-cflags) $NIX_CFLAGS_COMPILE_@suffixSalt@"
|
||||
fi
|
||||
|
|
|
@ -129,7 +129,7 @@ fi
|
|||
|
||||
if [[ "$isCpp" = 1 ]]; then
|
||||
if [[ "$cppInclude" = 1 ]]; then
|
||||
NIX_CFLAGS_COMPILE_@suffixSalt@+=" ${NIX_CXXSTDLIB_COMPILE_@suffixSalt@:-@default_cxx_stdlib_compile@}"
|
||||
NIX_CFLAGS_COMPILE_@suffixSalt@+=" $NIX_CXXSTDLIB_COMPILE_@suffixSalt@"
|
||||
fi
|
||||
NIX_CFLAGS_LINK_@suffixSalt@+=" $NIX_CXXSTDLIB_LINK_@suffixSalt@"
|
||||
fi
|
||||
|
|
|
@ -48,12 +48,6 @@ let
|
|||
# The wrapper scripts use 'cat' and 'grep', so we may need coreutils.
|
||||
coreutils_bin = if nativeTools then "" else getBin coreutils;
|
||||
|
||||
default_cxx_stdlib_compile = if (targetPlatform.isLinux && !(cc.isGNU or false) && !nativeTools && cc ? gcc) && !(targetPlatform.useLLVM or false) then
|
||||
"-isystem $(echo -n ${cc.gcc}/include/c++/*) -isystem $(echo -n ${cc.gcc}/include/c++/*)/${targetPlatform.config}"
|
||||
else if targetPlatform.isDarwin && (libcxx != null) && (cc.isClang or false) && !(targetPlatform.useLLVM or false) then
|
||||
"-isystem ${libcxx}/include/c++/v1"
|
||||
else "";
|
||||
|
||||
# The "suffix salt" is a arbitrary string added in the end of env vars
|
||||
# defined by cc-wrapper's hooks so that multiple cc-wrappers can be used
|
||||
# without interfering. For the moment, it is defined as the target triple,
|
||||
|
@ -68,7 +62,7 @@ let
|
|||
|
||||
# older compilers (for example bootstrap's GCC 5) fail with -march=too-modern-cpu
|
||||
isGccArchSupported = arch:
|
||||
if cc.isGNU or false then
|
||||
if isGNU then
|
||||
{ skylake = versionAtLeast ccVersion "6.0";
|
||||
skylake-avx512 = versionAtLeast ccVersion "6.0";
|
||||
cannonlake = versionAtLeast ccVersion "8.0";
|
||||
|
@ -76,7 +70,7 @@ let
|
|||
icelake-server = versionAtLeast ccVersion "8.0";
|
||||
knm = versionAtLeast ccVersion "8.0";
|
||||
}.${arch} or true
|
||||
else if cc.isClang or false then
|
||||
else if isClang then
|
||||
{ cannonlake = versionAtLeast ccVersion "5.0";
|
||||
icelake-client = versionAtLeast ccVersion "7.0";
|
||||
icelake-server = versionAtLeast ccVersion "7.0";
|
||||
|
@ -116,7 +110,7 @@ stdenv.mkDerivation {
|
|||
# Binutils, and Apple's "cctools"; "bintools" as an attempt to find an
|
||||
# unused middle-ground name that evokes both.
|
||||
inherit bintools;
|
||||
inherit libc nativeTools nativeLibc nativePrefix isGNU isClang default_cxx_stdlib_compile;
|
||||
inherit libc nativeTools nativeLibc nativePrefix isGNU isClang;
|
||||
|
||||
emacsBufferSetup = pkgs: ''
|
||||
; We should handle propagation here too
|
||||
|
@ -173,8 +167,6 @@ stdenv.mkDerivation {
|
|||
export named_cc=${targetPrefix}cc
|
||||
export named_cxx=${targetPrefix}c++
|
||||
|
||||
export default_cxx_stdlib_compile="${default_cxx_stdlib_compile}"
|
||||
|
||||
if [ -e $ccPath/${targetPrefix}gcc ]; then
|
||||
wrap ${targetPrefix}gcc $wrapper $ccPath/${targetPrefix}gcc
|
||||
ln -s ${targetPrefix}gcc $out/bin/${targetPrefix}cc
|
||||
|
@ -226,7 +218,7 @@ stdenv.mkDerivation {
|
|||
|
||||
strictDeps = true;
|
||||
propagatedBuildInputs = [ bintools ] ++ extraTools ++ optionals cc.langD or false [ zlib ];
|
||||
depsTargetTargetPropagated = extraPackages;
|
||||
depsTargetTargetPropagated = optional (libcxx != null) libcxx ++ extraPackages;
|
||||
|
||||
wrapperName = "CC_WRAPPER";
|
||||
|
||||
|
@ -250,6 +242,24 @@ stdenv.mkDerivation {
|
|||
fi
|
||||
''
|
||||
|
||||
+ optionalString isClang ''
|
||||
##
|
||||
## General Clang support
|
||||
##
|
||||
|
||||
echo "-target ${targetPlatform.config}" >> $out/nix-support/cc-cflags
|
||||
''
|
||||
|
||||
+ optionalString (isClang && libcxx == null && cc ? gcc) ''
|
||||
##
|
||||
## GCC libs for non-GCC support
|
||||
##
|
||||
|
||||
echo "-B${cc.gcc}/lib/gcc/${targetPlatform.config}/${cc.gcc.version}" >> $out/nix-support/cc-cflags
|
||||
echo "-L${cc.gcc}/lib/gcc/${targetPlatform.config}/${cc.gcc.version}" >> $out/nix-support/cc-ldflags
|
||||
echo "-L${cc.gcc.lib}/${targetPlatform.config}/lib" >> $out/nix-support/cc-ldflags
|
||||
''
|
||||
|
||||
+ optionalString (libc != null) (''
|
||||
##
|
||||
## General libc support
|
||||
|
@ -279,6 +289,27 @@ stdenv.mkDerivation {
|
|||
echo "${libc_dev}" > $out/nix-support/orig-libc-dev
|
||||
'')
|
||||
|
||||
+ ''
|
||||
##
|
||||
## General libc++ support
|
||||
##
|
||||
|
||||
''
|
||||
+ optionalString (libcxx == null && cc ? gcc) ''
|
||||
for dir in ${cc.gcc}/include/c++/*; do
|
||||
echo "-isystem $dir" >> $out/nix-support/libcxx-cxxflags
|
||||
done
|
||||
for dir in ${cc.gcc}/include/c++/*/${targetPlatform.config}; do
|
||||
echo "-isystem $dir" >> $out/nix-support/libcxx-cxxflags
|
||||
done
|
||||
''
|
||||
+ optionalString (libcxx.isLLVM or false) (''
|
||||
echo "-isystem ${libcxx}/include/c++/v1" >> $out/nix-support/libcxx-cxxflags
|
||||
echo "-stdlib=libc++" >> $out/nix-support/libcxx-ldflags
|
||||
'' + stdenv.lib.optionalString stdenv.targetPlatform.isLinux ''
|
||||
echo "-lc++abi" >> $out/nix-support/libcxx-ldflags
|
||||
'')
|
||||
|
||||
+ optionalString (!nativeTools) ''
|
||||
##
|
||||
## Initial CFLAGS
|
||||
|
@ -389,9 +420,9 @@ stdenv.mkDerivation {
|
|||
# There are a few tools (to name one libstdcxx5) which do not work
|
||||
# well with multi line flags, so make the flags single line again
|
||||
+ ''
|
||||
if [ -e "$out/nix-support/libc-cflags" ]; then
|
||||
substituteInPlace "$out/nix-support/libc-cflags" --replace $'\n' ' '
|
||||
fi
|
||||
for flags in "$out/nix-support"/*flags; do
|
||||
substituteInPlace "$flags" --replace $'\n' ' '
|
||||
done
|
||||
|
||||
substituteAll ${./add-flags.sh} $out/nix-support/add-flags.sh
|
||||
substituteAll ${./add-hardening.sh} $out/nix-support/add-hardening.sh
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
# See pkgs/build-support/setup-hooks/role.bash
|
||||
getHostRole
|
||||
|
||||
export NIX_CXXSTDLIB_COMPILE${role_post}+=" -isystem $(echo -n @gcc@/include/c++/*) -isystem $(echo -n @gcc@/include/c++/*)/@targetConfig@"
|
|
@ -1,4 +1,4 @@
|
|||
{ lowPrio, newScope, pkgs, stdenv, cmake, gcc, libstdcxxHook
|
||||
{ lowPrio, newScope, pkgs, stdenv, cmake
|
||||
, libxml2, python3, isl, fetchurl, overrideCC, wrapCCWith, wrapBintoolsWith
|
||||
, buildLlvmTools # tools, but from the previous stage, for cross
|
||||
, targetLlvmLibraries # libraries, but from the next stage, for cross
|
||||
|
@ -57,23 +57,17 @@ let
|
|||
|
||||
libstdcxxClang = wrapCCWith rec {
|
||||
cc = tools.clang-unwrapped;
|
||||
libcxx = null; # libstdcxx is smuggled in with clang.gcc
|
||||
extraPackages = [
|
||||
libstdcxxHook
|
||||
targetLlvmLibraries.compiler-rt
|
||||
];
|
||||
extraBuildCommands = ''
|
||||
echo "-target ${targetConfig}" >> $out/nix-support/cc-cflags
|
||||
echo "-B${gcc.cc}/lib/gcc/${targetConfig}/${gcc.version}" >> $out/nix-support/cc-cflags
|
||||
echo "-L${gcc.cc}/lib/gcc/${targetConfig}/${gcc.version}" >> $out/nix-support/cc-ldflags
|
||||
echo "-L${gcc.cc.lib}/${targetConfig}/lib" >> $out/nix-support/cc-ldflags
|
||||
'' + mkExtraBuildCommands cc;
|
||||
extraBuildCommands = mkExtraBuildCommands cc;
|
||||
};
|
||||
|
||||
libcxxClang = wrapCCWith rec {
|
||||
cc = tools.clang-unwrapped;
|
||||
libcxx = targetLlvmLibraries.libcxx;
|
||||
extraPackages = [
|
||||
targetLlvmLibraries.libcxx
|
||||
targetLlvmLibraries.libcxxabi
|
||||
targetLlvmLibraries.compiler-rt
|
||||
];
|
||||
|
@ -100,14 +94,12 @@ let
|
|||
inherit (tools) bintools;
|
||||
};
|
||||
extraPackages = [
|
||||
targetLlvmLibraries.libcxx
|
||||
targetLlvmLibraries.libcxxabi
|
||||
targetLlvmLibraries.compiler-rt
|
||||
] ++ stdenv.lib.optionals (!stdenv.targetPlatform.isWasm) [
|
||||
targetLlvmLibraries.libunwind
|
||||
];
|
||||
extraBuildCommands = ''
|
||||
echo "-target ${stdenv.targetPlatform.config}" >> $out/nix-support/cc-cflags
|
||||
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) ''
|
||||
|
@ -127,7 +119,6 @@ let
|
|||
targetLlvmLibraries.compiler-rt
|
||||
];
|
||||
extraBuildCommands = ''
|
||||
echo "-target ${stdenv.targetPlatform.config}" >> $out/nix-support/cc-cflags
|
||||
echo "-rtlib=compiler-rt" >> $out/nix-support/cc-cflags
|
||||
echo "-B${targetLlvmLibraries.compiler-rt}/lib" >> $out/nix-support/cc-cflags
|
||||
echo "-nostdlib++" >> $out/nix-support/cc-cflags
|
||||
|
@ -145,7 +136,6 @@ let
|
|||
targetLlvmLibraries.compiler-rt
|
||||
];
|
||||
extraBuildCommands = ''
|
||||
echo "-target ${stdenv.targetPlatform.config}" >> $out/nix-support/cc-cflags
|
||||
echo "-rtlib=compiler-rt" >> $out/nix-support/cc-cflags
|
||||
echo "-B${targetLlvmLibraries.compiler-rt}/lib" >> $out/nix-support/cc-cflags
|
||||
'' + mkExtraBuildCommands cc;
|
||||
|
@ -161,7 +151,6 @@ let
|
|||
extraPackages = [ ];
|
||||
extraBuildCommands = ''
|
||||
echo "-nostartfiles" >> $out/nix-support/cc-cflags
|
||||
echo "-target ${stdenv.targetPlatform.config}" >> $out/nix-support/cc-cflags
|
||||
'';
|
||||
};
|
||||
|
||||
|
|
|
@ -39,12 +39,9 @@ stdenv.mkDerivation {
|
|||
|
||||
enableParallelBuilding = true;
|
||||
|
||||
linkCxxAbi = stdenv.isLinux;
|
||||
|
||||
setupHooks = [
|
||||
../../../../../build-support/setup-hooks/role.bash
|
||||
./setup-hook.sh
|
||||
];
|
||||
passthru = {
|
||||
isLLVM = true;
|
||||
};
|
||||
|
||||
meta = {
|
||||
homepage = "https://libcxx.llvm.org/";
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
# See pkgs/build-support/setup-hooks/role.bash
|
||||
getHostRole
|
||||
|
||||
linkCxxAbi="@linkCxxAbi@"
|
||||
export NIX_CXXSTDLIB_COMPILE${role_post}+=" -isystem @out@/include/c++/v1"
|
||||
export NIX_CXXSTDLIB_LINK${role_post}=" -stdlib=libc++${linkCxxAbi:+" -lc++abi"}"
|
|
@ -1,4 +1,4 @@
|
|||
{ lowPrio, newScope, pkgs, stdenv, cmake, gcc, libstdcxxHook
|
||||
{ lowPrio, newScope, pkgs, stdenv, cmake
|
||||
, libxml2, python3, isl, fetchurl, overrideCC, wrapCCWith
|
||||
, buildLlvmTools # tools, but from the previous stage, for cross
|
||||
, targetLlvmLibraries # libraries, but from the next stage, for cross
|
||||
|
@ -51,25 +51,17 @@ let
|
|||
|
||||
libstdcxxClang = wrapCCWith rec {
|
||||
cc = tools.clang-unwrapped;
|
||||
extraTools = [
|
||||
libstdcxxHook
|
||||
];
|
||||
libcxx = null; # libstdcxx is smuggled in with clang.gcc
|
||||
extraPackages = [
|
||||
targetLlvmLibraries.compiler-rt
|
||||
];
|
||||
extraBuildCommands = ''
|
||||
echo "-target ${targetConfig}" >> $out/nix-support/cc-cflags
|
||||
echo "-B${gcc.cc}/lib/gcc/${targetConfig}/${gcc.version}" >> $out/nix-support/cc-cflags
|
||||
echo "-L${gcc.cc}/lib/gcc/${targetConfig}/${gcc.version}" >> $out/nix-support/cc-ldflags
|
||||
echo "-L${gcc.cc.lib}/${targetConfig}/lib" >> $out/nix-support/cc-ldflags
|
||||
'' + mkExtraBuildCommands cc;
|
||||
extraBuildCommands = mkExtraBuildCommands cc;
|
||||
};
|
||||
|
||||
libcxxClang = wrapCCWith rec {
|
||||
cc = tools.clang-unwrapped;
|
||||
libcxx = targetLlvmLibraries.libcxx;
|
||||
extraPackages = [
|
||||
targetLlvmLibraries.libcxx
|
||||
targetLlvmLibraries.libcxxabi
|
||||
targetLlvmLibraries.compiler-rt
|
||||
];
|
||||
|
|
|
@ -37,12 +37,9 @@ stdenv.mkDerivation {
|
|||
|
||||
enableParallelBuilding = true;
|
||||
|
||||
linkCxxAbi = stdenv.isLinux;
|
||||
|
||||
setupHooks = [
|
||||
../../../../../build-support/setup-hooks/role.bash
|
||||
./setup-hook.sh
|
||||
];
|
||||
passthru = {
|
||||
isLLVM = true;
|
||||
};
|
||||
|
||||
meta = {
|
||||
homepage = "https://libcxx.llvm.org/";
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
# See pkgs/build-support/setup-hooks/role.bash
|
||||
getHostRole
|
||||
|
||||
linkCxxAbi="@linkCxxAbi@"
|
||||
export NIX_CXXSTDLIB_COMPILE${role_post}+=" -isystem @out@/include/c++/v1"
|
||||
export NIX_CXXSTDLIB_LINK${role_post}=" -stdlib=libc++${linkCxxAbi:+" -lc++abi"}"
|
|
@ -1,4 +1,4 @@
|
|||
{ lowPrio, newScope, pkgs, stdenv, cmake, gcc, libstdcxxHook
|
||||
{ lowPrio, newScope, pkgs, stdenv, cmake
|
||||
, libxml2, python3, isl, fetchurl, overrideCC, wrapCCWith
|
||||
, buildLlvmTools # tools, but from the previous stage, for cross
|
||||
, targetLlvmLibraries # libraries, but from the next stage, for cross
|
||||
|
@ -51,25 +51,17 @@ let
|
|||
|
||||
libstdcxxClang = wrapCCWith rec {
|
||||
cc = tools.clang-unwrapped;
|
||||
extraTools = [
|
||||
libstdcxxHook
|
||||
];
|
||||
libcxx = null; # libstdcxx is smuggled in with clang.gcc
|
||||
extraPackages = [
|
||||
targetLlvmLibraries.compiler-rt
|
||||
];
|
||||
extraBuildCommands = ''
|
||||
echo "-target ${targetConfig}" >> $out/nix-support/cc-cflags
|
||||
echo "-B${gcc.cc}/lib/gcc/${targetConfig}/${gcc.version}" >> $out/nix-support/cc-cflags
|
||||
echo "-L${gcc.cc}/lib/gcc/${targetConfig}/${gcc.version}" >> $out/nix-support/cc-ldflags
|
||||
echo "-L${gcc.cc.lib}/${targetConfig}/lib" >> $out/nix-support/cc-ldflags
|
||||
'' + mkExtraBuildCommands cc;
|
||||
extraBuildCommands = mkExtraBuildCommands cc;
|
||||
};
|
||||
|
||||
libcxxClang = wrapCCWith rec {
|
||||
cc = tools.clang-unwrapped;
|
||||
libcxx = targetLlvmLibraries.libcxx;
|
||||
extraPackages = [
|
||||
targetLlvmLibraries.libcxx
|
||||
targetLlvmLibraries.libcxxabi
|
||||
targetLlvmLibraries.compiler-rt
|
||||
];
|
||||
|
|
|
@ -37,12 +37,9 @@ stdenv.mkDerivation {
|
|||
|
||||
enableParallelBuilding = true;
|
||||
|
||||
linkCxxAbi = stdenv.isLinux;
|
||||
|
||||
setupHooks = [
|
||||
../../../../../build-support/setup-hooks/role.bash
|
||||
./setup-hook.sh
|
||||
];
|
||||
passthru = {
|
||||
isLLVM = true;
|
||||
};
|
||||
|
||||
meta = {
|
||||
homepage = "https://libcxx.llvm.org/";
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
# See pkgs/build-support/setup-hooks/role.bash
|
||||
getHostRole
|
||||
|
||||
linkCxxAbi="@linkCxxAbi@"
|
||||
export NIX_CXXSTDLIB_COMPILE${role_post}+=" -isystem @out@/include/c++/v1"
|
||||
export NIX_CXXSTDLIB_LINK${role_post}=" -stdlib=libc++${linkCxxAbi:+" -lc++abi"}"
|
|
@ -1,4 +1,4 @@
|
|||
{ lowPrio, newScope, pkgs, stdenv, cmake, gcc, libstdcxxHook
|
||||
{ lowPrio, newScope, pkgs, stdenv, cmake
|
||||
, libxml2, python3, isl, fetchurl, overrideCC, wrapCCWith, wrapBintoolsWith
|
||||
, buildLlvmTools # tools, but from the previous stage, for cross
|
||||
, targetLlvmLibraries # libraries, but from the next stage, for cross
|
||||
|
@ -58,25 +58,17 @@ let
|
|||
|
||||
libstdcxxClang = wrapCCWith rec {
|
||||
cc = tools.clang-unwrapped;
|
||||
extraTools = [
|
||||
libstdcxxHook
|
||||
];
|
||||
libcxx = null; # libstdcxx is smuggled in with clang.gcc
|
||||
extraPackages = [
|
||||
targetLlvmLibraries.compiler-rt
|
||||
];
|
||||
extraBuildCommands = ''
|
||||
echo "-target ${targetConfig}" >> $out/nix-support/cc-cflags
|
||||
echo "-B${gcc.cc}/lib/gcc/${targetConfig}/${gcc.version}" >> $out/nix-support/cc-cflags
|
||||
echo "-L${gcc.cc}/lib/gcc/${targetConfig}/${gcc.version}" >> $out/nix-support/cc-ldflags
|
||||
echo "-L${gcc.cc.lib}/${targetConfig}/lib" >> $out/nix-support/cc-ldflags
|
||||
'' + mkExtraBuildCommands cc;
|
||||
extraBuildCommands = mkExtraBuildCommands cc;
|
||||
};
|
||||
|
||||
libcxxClang = wrapCCWith rec {
|
||||
cc = tools.clang-unwrapped;
|
||||
libcxx = targetLlvmLibraries.libcxx;
|
||||
extraPackages = [
|
||||
targetLlvmLibraries.libcxx
|
||||
targetLlvmLibraries.libcxxabi
|
||||
targetLlvmLibraries.compiler-rt
|
||||
];
|
||||
|
@ -87,48 +79,77 @@ let
|
|||
|
||||
lldb = callPackage ./lldb.nix {};
|
||||
|
||||
# Below, is the LLVM bootstrapping logic. It handles building a
|
||||
# fully LLVM toolchain from scratch. No GCC toolchain should be
|
||||
# pulled in. As a consequence, it is very quick to build different
|
||||
# targets provided by LLVM and we can also build for what GCC
|
||||
# doesn’t support like LLVM. Probably we should move to some other
|
||||
# file.
|
||||
|
||||
bintools = callPackage ./bintools.nix {};
|
||||
|
||||
lldClang = wrapCCWith rec {
|
||||
cc = tools.clang-unwrapped;
|
||||
libcxx = targetLlvmLibraries.libcxx;
|
||||
bintools = wrapBintoolsWith {
|
||||
inherit (tools) bintools;
|
||||
};
|
||||
extraPackages = [
|
||||
# targetLlvmLibraries.libcxx
|
||||
# targetLlvmLibraries.libcxxabi
|
||||
targetLlvmLibraries.libcxxabi
|
||||
targetLlvmLibraries.compiler-rt
|
||||
];
|
||||
extraBuildCommands = ''
|
||||
echo "-target ${stdenv.targetPlatform.config} -rtlib=compiler-rt" >> $out/nix-support/cc-cflags
|
||||
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) ''
|
||||
echo "--unwindlib=libunwind" >> $out/nix-support/cc-cflags
|
||||
'' + stdenv.lib.optionalString stdenv.targetPlatform.isWasm ''
|
||||
echo "-fno-exceptions" >> $out/nix-support/cc-cflags
|
||||
'' + mkExtraBuildCommands cc;
|
||||
};
|
||||
|
||||
lldClangNoLibcxx = wrapCCWith rec {
|
||||
cc = tools.clang-unwrapped;
|
||||
libcxx = null;
|
||||
bintools = wrapBintoolsWith {
|
||||
inherit (tools) bintools;
|
||||
};
|
||||
extraPackages = [
|
||||
targetLlvmLibraries.compiler-rt
|
||||
];
|
||||
extraBuildCommands = ''
|
||||
echo "-rtlib=compiler-rt" >> $out/nix-support/cc-cflags
|
||||
echo "-B${targetLlvmLibraries.compiler-rt}/lib" >> $out/nix-support/cc-cflags
|
||||
echo "-nostdlib++" >> $out/nix-support/cc-cflags
|
||||
'' + mkExtraBuildCommands cc;
|
||||
};
|
||||
|
||||
lldClangNoLibc = wrapCCWith rec {
|
||||
cc = tools.clang-unwrapped;
|
||||
libcxx = null;
|
||||
bintools = wrapBintoolsWith {
|
||||
inherit (tools) bintools;
|
||||
libc = null;
|
||||
};
|
||||
extraPackages = [
|
||||
# targetLlvmLibraries.libcxx
|
||||
# targetLlvmLibraries.libcxxabi
|
||||
targetLlvmLibraries.compiler-rt
|
||||
];
|
||||
extraBuildCommands = ''
|
||||
echo "-target ${stdenv.targetPlatform.config} -rtlib=compiler-rt" >> $out/nix-support/cc-cflags
|
||||
echo "-rtlib=compiler-rt" >> $out/nix-support/cc-cflags
|
||||
echo "-B${targetLlvmLibraries.compiler-rt}/lib" >> $out/nix-support/cc-cflags
|
||||
'' + mkExtraBuildCommands cc;
|
||||
};
|
||||
|
||||
lldClangNoCompilerRt = wrapCCWith {
|
||||
cc = tools.clang-unwrapped;
|
||||
libcxx = null;
|
||||
bintools = wrapBintoolsWith {
|
||||
inherit (tools) bintools;
|
||||
libc = null;
|
||||
};
|
||||
extraPackages = [ ];
|
||||
extraBuildCommands = ''
|
||||
echo "-nostartfiles -target ${stdenv.targetPlatform.config}" >> $out/nix-support/cc-cflags
|
||||
echo "-nostartfiles" >> $out/nix-support/cc-cflags
|
||||
'';
|
||||
};
|
||||
|
||||
|
@ -148,9 +169,16 @@ let
|
|||
|
||||
libcxxStdenv = overrideCC stdenv buildLlvmTools.libcxxClang;
|
||||
|
||||
libcxx = callPackage ./libc++ {};
|
||||
libcxx = callPackage ./libc++ ({} //
|
||||
(stdenv.lib.optionalAttrs (stdenv.hostPlatform.useLLVM or false) {
|
||||
stdenv = overrideCC stdenv buildLlvmTools.lldClangNoLibcxx;
|
||||
}));
|
||||
|
||||
libcxxabi = callPackage ./libc++abi.nix {};
|
||||
libcxxabi = callPackage ./libc++abi.nix ({} //
|
||||
(stdenv.lib.optionalAttrs (stdenv.hostPlatform.useLLVM or false) {
|
||||
stdenv = overrideCC stdenv buildLlvmTools.lldClangNoLibcxx;
|
||||
libunwind = libraries.libunwind;
|
||||
}));
|
||||
|
||||
openmp = callPackage ./openmp.nix {};
|
||||
});
|
||||
|
|
|
@ -37,12 +37,9 @@ stdenv.mkDerivation {
|
|||
|
||||
enableParallelBuilding = true;
|
||||
|
||||
linkCxxAbi = stdenv.isLinux;
|
||||
|
||||
setupHooks = [
|
||||
../../../../../build-support/setup-hooks/role.bash
|
||||
./setup-hook.sh
|
||||
];
|
||||
passthru = {
|
||||
isLLVM = true;
|
||||
};
|
||||
|
||||
meta = {
|
||||
homepage = "https://libcxx.llvm.org/";
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
# See pkgs/build-support/setup-hooks/role.bash
|
||||
getHostRole
|
||||
|
||||
linkCxxAbi="@linkCxxAbi@"
|
||||
export NIX_CXXSTDLIB_COMPILE${role_post}+=" -isystem @out@/include/c++/v1"
|
||||
export NIX_CXXSTDLIB_LINK${role_post}=" -stdlib=libc++${linkCxxAbi:+" -lc++abi"}"
|
|
@ -1,4 +1,4 @@
|
|||
{ lowPrio, newScope, pkgs, stdenv, cmake, gcc, libstdcxxHook
|
||||
{ lowPrio, newScope, pkgs, stdenv, cmake
|
||||
, libxml2, python3, isl, fetchurl, overrideCC, wrapCCWith, wrapBintoolsWith
|
||||
, buildLlvmTools # tools, but from the previous stage, for cross
|
||||
, targetLlvmLibraries # libraries, but from the next stage, for cross
|
||||
|
@ -58,25 +58,17 @@ let
|
|||
|
||||
libstdcxxClang = wrapCCWith rec {
|
||||
cc = tools.clang-unwrapped;
|
||||
extraTools = [
|
||||
libstdcxxHook
|
||||
];
|
||||
libcxx = null; # libstdcxx is smuggled in with clang.gcc
|
||||
extraPackages = [
|
||||
targetLlvmLibraries.compiler-rt
|
||||
];
|
||||
extraBuildCommands = ''
|
||||
echo "-target ${targetConfig}" >> $out/nix-support/cc-cflags
|
||||
echo "-B${gcc.cc}/lib/gcc/${targetConfig}/${gcc.version}" >> $out/nix-support/cc-cflags
|
||||
echo "-L${gcc.cc}/lib/gcc/${targetConfig}/${gcc.version}" >> $out/nix-support/cc-ldflags
|
||||
echo "-L${gcc.cc.lib}/${targetConfig}/lib" >> $out/nix-support/cc-ldflags
|
||||
'' + mkExtraBuildCommands cc;
|
||||
extraBuildCommands = mkExtraBuildCommands cc;
|
||||
};
|
||||
|
||||
libcxxClang = wrapCCWith rec {
|
||||
cc = tools.clang-unwrapped;
|
||||
libcxx = targetLlvmLibraries.libcxx;
|
||||
extraPackages = [
|
||||
targetLlvmLibraries.libcxx
|
||||
targetLlvmLibraries.libcxxabi
|
||||
targetLlvmLibraries.compiler-rt
|
||||
];
|
||||
|
@ -103,14 +95,12 @@ let
|
|||
inherit (tools) bintools;
|
||||
};
|
||||
extraPackages = [
|
||||
targetLlvmLibraries.libcxx
|
||||
targetLlvmLibraries.libcxxabi
|
||||
targetLlvmLibraries.compiler-rt
|
||||
] ++ stdenv.lib.optionals (!stdenv.targetPlatform.isWasm) [
|
||||
targetLlvmLibraries.libunwind
|
||||
];
|
||||
extraBuildCommands = ''
|
||||
echo "-target ${stdenv.targetPlatform.config}" >> $out/nix-support/cc-cflags
|
||||
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) ''
|
||||
|
@ -130,7 +120,6 @@ let
|
|||
targetLlvmLibraries.compiler-rt
|
||||
];
|
||||
extraBuildCommands = ''
|
||||
echo "-target ${stdenv.targetPlatform.config}" >> $out/nix-support/cc-cflags
|
||||
echo "-rtlib=compiler-rt" >> $out/nix-support/cc-cflags
|
||||
echo "-B${targetLlvmLibraries.compiler-rt}/lib" >> $out/nix-support/cc-cflags
|
||||
echo "-nostdlib++" >> $out/nix-support/cc-cflags
|
||||
|
@ -148,7 +137,6 @@ let
|
|||
targetLlvmLibraries.compiler-rt
|
||||
];
|
||||
extraBuildCommands = ''
|
||||
echo "-target ${stdenv.targetPlatform.config}" >> $out/nix-support/cc-cflags
|
||||
echo "-rtlib=compiler-rt" >> $out/nix-support/cc-cflags
|
||||
echo "-B${targetLlvmLibraries.compiler-rt}/lib" >> $out/nix-support/cc-cflags
|
||||
'' + mkExtraBuildCommands cc;
|
||||
|
@ -164,7 +152,6 @@ let
|
|||
extraPackages = [ ];
|
||||
extraBuildCommands = ''
|
||||
echo "-nostartfiles" >> $out/nix-support/cc-cflags
|
||||
echo "-target ${stdenv.targetPlatform.config}" >> $out/nix-support/cc-cflags
|
||||
'';
|
||||
};
|
||||
|
||||
|
|
|
@ -43,12 +43,9 @@ stdenv.mkDerivation {
|
|||
|
||||
enableParallelBuilding = true;
|
||||
|
||||
linkCxxAbi = stdenv.isLinux;
|
||||
|
||||
setupHooks = [
|
||||
../../../../../build-support/setup-hooks/role.bash
|
||||
./setup-hook.sh
|
||||
];
|
||||
passthru = {
|
||||
isLLVM = true;
|
||||
};
|
||||
|
||||
meta = {
|
||||
homepage = "https://libcxx.llvm.org/";
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
# See pkgs/build-support/setup-hooks/role.bash
|
||||
getHostRole
|
||||
|
||||
linkCxxAbi="@linkCxxAbi@"
|
||||
export NIX_CXXSTDLIB_COMPILE${role_post}+=" -isystem @out@/include/c++/v1"
|
||||
export NIX_CXXSTDLIB_LINK${role_post}=" -stdlib=libc++${linkCxxAbi:+" -lc++abi"}"
|
|
@ -1,4 +1,4 @@
|
|||
{ lowPrio, newScope, pkgs, stdenv, cmake, gcc, libstdcxxHook
|
||||
{ lowPrio, newScope, pkgs, stdenv, cmake
|
||||
, libxml2, python3, isl, fetchurl, overrideCC, wrapCCWith, wrapBintoolsWith
|
||||
, buildLlvmTools # tools, but from the previous stage, for cross
|
||||
, targetLlvmLibraries # libraries, but from the next stage, for cross
|
||||
|
@ -58,25 +58,17 @@ let
|
|||
|
||||
libstdcxxClang = wrapCCWith rec {
|
||||
cc = tools.clang-unwrapped;
|
||||
extraTools = [
|
||||
libstdcxxHook
|
||||
];
|
||||
libcxx = null; # libstdcxx is smuggled in with clang.gcc
|
||||
extraPackages = [
|
||||
targetLlvmLibraries.compiler-rt
|
||||
];
|
||||
extraBuildCommands = ''
|
||||
echo "-target ${targetConfig}" >> $out/nix-support/cc-cflags
|
||||
echo "-B${gcc.cc}/lib/gcc/${targetConfig}/${gcc.version}" >> $out/nix-support/cc-cflags
|
||||
echo "-L${gcc.cc}/lib/gcc/${targetConfig}/${gcc.version}" >> $out/nix-support/cc-ldflags
|
||||
echo "-L${gcc.cc.lib}/${targetConfig}/lib" >> $out/nix-support/cc-ldflags
|
||||
'' + mkExtraBuildCommands cc;
|
||||
extraBuildCommands = mkExtraBuildCommands cc;
|
||||
};
|
||||
|
||||
libcxxClang = wrapCCWith rec {
|
||||
cc = tools.clang-unwrapped;
|
||||
libcxx = targetLlvmLibraries.libcxx;
|
||||
extraPackages = [
|
||||
targetLlvmLibraries.libcxx
|
||||
targetLlvmLibraries.libcxxabi
|
||||
targetLlvmLibraries.compiler-rt
|
||||
];
|
||||
|
@ -103,14 +95,12 @@ let
|
|||
inherit (tools) bintools;
|
||||
};
|
||||
extraPackages = [
|
||||
targetLlvmLibraries.libcxx
|
||||
targetLlvmLibraries.libcxxabi
|
||||
targetLlvmLibraries.compiler-rt
|
||||
] ++ stdenv.lib.optionals (!stdenv.targetPlatform.isWasm) [
|
||||
targetLlvmLibraries.libunwind
|
||||
];
|
||||
extraBuildCommands = ''
|
||||
echo "-target ${stdenv.targetPlatform.config}" >> $out/nix-support/cc-cflags
|
||||
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) ''
|
||||
|
@ -130,7 +120,6 @@ let
|
|||
targetLlvmLibraries.compiler-rt
|
||||
];
|
||||
extraBuildCommands = ''
|
||||
echo "-target ${stdenv.targetPlatform.config}" >> $out/nix-support/cc-cflags
|
||||
echo "-rtlib=compiler-rt" >> $out/nix-support/cc-cflags
|
||||
echo "-B${targetLlvmLibraries.compiler-rt}/lib" >> $out/nix-support/cc-cflags
|
||||
echo "-nostdlib++" >> $out/nix-support/cc-cflags
|
||||
|
@ -148,7 +137,6 @@ let
|
|||
targetLlvmLibraries.compiler-rt
|
||||
];
|
||||
extraBuildCommands = ''
|
||||
echo "-target ${stdenv.targetPlatform.config}" >> $out/nix-support/cc-cflags
|
||||
echo "-rtlib=compiler-rt" >> $out/nix-support/cc-cflags
|
||||
echo "-B${targetLlvmLibraries.compiler-rt}/lib" >> $out/nix-support/cc-cflags
|
||||
'' + mkExtraBuildCommands cc;
|
||||
|
@ -164,7 +152,6 @@ let
|
|||
extraPackages = [ ];
|
||||
extraBuildCommands = ''
|
||||
echo "-nostartfiles" >> $out/nix-support/cc-cflags
|
||||
echo "-target ${stdenv.targetPlatform.config}" >> $out/nix-support/cc-cflags
|
||||
'';
|
||||
};
|
||||
|
||||
|
|
|
@ -39,12 +39,9 @@ stdenv.mkDerivation {
|
|||
|
||||
enableParallelBuilding = true;
|
||||
|
||||
linkCxxAbi = stdenv.isLinux;
|
||||
|
||||
setupHooks = [
|
||||
../../../../../build-support/setup-hooks/role.bash
|
||||
./setup-hook.sh
|
||||
];
|
||||
passthru = {
|
||||
isLLVM = true;
|
||||
};
|
||||
|
||||
meta = {
|
||||
homepage = "https://libcxx.llvm.org/";
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
# See pkgs/build-support/setup-hooks/role.bash
|
||||
getHostRole
|
||||
|
||||
linkCxxAbi="@linkCxxAbi@"
|
||||
export NIX_CXXSTDLIB_COMPILE${role_post}+=" -isystem @out@/include/c++/v1"
|
||||
export NIX_CXXSTDLIB_LINK${role_post}=" -stdlib=libc++${linkCxxAbi:+" -lc++abi"}"
|
|
@ -258,7 +258,7 @@ stdenv.mkDerivation {
|
|||
|
||||
buildPhase = ''
|
||||
# gcc-6.4.0/include/c++/6.4.0/cstdlib:75:15: fatal error: 'stdlib.h' file not found
|
||||
export NIX_CFLAGS_COMPILE="$( echo ${clang.default_cxx_stdlib_compile} ) $NIX_CFLAGS_COMPILE"
|
||||
export NIX_CFLAGS_COMPILE="$(< $NIX_CC/nix-support/libcxx-cxxflags) $NIX_CFLAGS_COMPILE"
|
||||
# During the Swift build, a full local LLVM build is performed and the resulting clang is invoked.
|
||||
# This compiler is not using the Nix wrappers, so it needs some help to find things.
|
||||
export NIX_LDFLAGS_BEFORE="-rpath ${clang.cc.gcc.lib}/lib -L${clang.cc.gcc.lib}/lib $NIX_LDFLAGS_BEFORE"
|
||||
|
|
|
@ -98,8 +98,6 @@ self: super: {
|
|||
# These usually implicitly set by cc-wrapper around clang (pkgs/build-support/cc-wrapper).
|
||||
# The linked ruby code shows generates the required '.clang_complete' for cmake based projects
|
||||
# https://gist.github.com/Mic92/135e83803ed29162817fce4098dec144
|
||||
# as an alternative you can execute the following command:
|
||||
# $ eval echo $(nix-instantiate --eval --expr 'with (import <nixpkgs>) {}; clang.default_cxx_stdlib_compile')
|
||||
preFixup = ''
|
||||
substituteInPlace "$out"/share/vim-plugins/clang_complete/plugin/clang_complete.vim \
|
||||
--replace "let g:clang_library_path = '' + "''" + ''" "let g:clang_library_path='${llvmPackages.clang.cc.lib}/lib/libclang.so'"
|
||||
|
|
|
@ -90,11 +90,11 @@ in rec {
|
|||
inherit shell;
|
||||
inherit (last) stdenvNoCC;
|
||||
|
||||
extraPackages = lib.optional (libcxx != null) libcxx;
|
||||
extraPackages = [];
|
||||
|
||||
nativeTools = false;
|
||||
nativeLibc = false;
|
||||
inherit buildPackages coreutils gnugrep bintools;
|
||||
inherit buildPackages coreutils gnugrep bintools libcxx;
|
||||
libc = last.pkgs.darwin.Libsystem;
|
||||
isClang = true;
|
||||
cc = { name = "${name}-clang"; outPath = bootstrapTools; };
|
||||
|
@ -168,8 +168,9 @@ in rec {
|
|||
ln -s ${bootstrapTools}/lib/libc++.dylib $out/lib/libc++.dylib
|
||||
ln -s ${bootstrapTools}/include/c++ $out/include/c++
|
||||
'';
|
||||
linkCxxAbi = false;
|
||||
setupHook = ../../development/compilers/llvm/7/libc++/setup-hook.sh;
|
||||
passthru = {
|
||||
isLLVM = true;
|
||||
};
|
||||
};
|
||||
|
||||
libcxxabi = stdenv.mkDerivation {
|
||||
|
|
|
@ -264,6 +264,7 @@ mapAliases ({
|
|||
libudev = udev; # added 2018-04-25
|
||||
libusb = libusb1; # added 2020-04-28
|
||||
libsexy = throw "libsexy has been removed from nixpkgs, as it's abandoned and no package needed it."; # 2019-12-10
|
||||
libstdcxxHook = throw "libstdcxx hook has been removed because cc-wrapper is now directly aware of the c++ standard library intended to be used."; # 2020-06-22
|
||||
libqmatrixclient = throw "libqmatrixclient was renamed to libquotient"; # added 2020-04-09
|
||||
links = links2; # added 2016-01-31
|
||||
linux_rpi0 = linux_rpi1;
|
||||
|
|
|
@ -8188,7 +8188,6 @@ in
|
|||
computecpp = wrapCCWith rec {
|
||||
cc = computecpp-unwrapped;
|
||||
extraPackages = [
|
||||
libstdcxxHook
|
||||
llvmPackages.compiler-rt
|
||||
];
|
||||
extraBuildCommands = ''
|
||||
|
@ -8330,14 +8329,6 @@ in
|
|||
stripped = false;
|
||||
}));
|
||||
|
||||
libstdcxxHook = makeSetupHook
|
||||
{ substitutions = {
|
||||
gcc = gcc-unwrapped;
|
||||
targetConfig = stdenv.targetPlatform.config;
|
||||
};
|
||||
}
|
||||
../development/compilers/gcc/libstdc++-hook.sh;
|
||||
|
||||
crossLibcStdenv = overrideCC stdenv
|
||||
(if stdenv.hostPlatform.useLLVM or false
|
||||
then buildPackages.llvmPackages_8.lldClangNoLibc
|
||||
|
@ -9394,6 +9385,10 @@ in
|
|||
# provide the default choice, avoiding infinite recursion.
|
||||
bintools ? if stdenv.targetPlatform.isDarwin then darwin.binutils else binutils
|
||||
, libc ? bintools.libc
|
||||
, # libc++ from the default LLVM version is bound at the top level, but we
|
||||
# want the C++ library to be explicitly chosen by the caller, and null by
|
||||
# default.
|
||||
libcxx ? null
|
||||
, extraPackages ? stdenv.lib.optional (cc.isGNU or false && stdenv.targetPlatform.isMinGW) threadsCross
|
||||
, ...
|
||||
} @ extraArgs:
|
||||
|
@ -9406,7 +9401,7 @@ in
|
|||
isGNU = cc.isGNU or false;
|
||||
isClang = cc.isClang or false;
|
||||
|
||||
inherit cc bintools libc extraPackages zlib;
|
||||
inherit cc bintools libc libcxx extraPackages zlib;
|
||||
} // extraArgs; in self);
|
||||
|
||||
wrapCC = cc: wrapCCWith {
|
||||
|
|
Loading…
Reference in a new issue