mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-01 07:01:54 +00:00
llvmPackages_*: respect cc for target when choosing C++ flavour
llvmPackages_*.clang should check the default compiler for the package set it is targeting (targetPackages.stdenv.cc) instead of the compiler that has been used to build it (stdenv.cc) in order to get some sense of whether to use libc++ or libstdc++. Since we are now inspecting targetPackages in the llvmPackages.clang attribute, we need to avoid using it in the cross stdenv — which just forces us to explicitly request libcxxClang for darwin instead of relying on the clang attribute to pick it for us. We also need to do something similar for targetPackages.stdenv.cc: Here the llvmPackages.clang logic would work as we want (inspect targetPackages.stdenv.cc and if it doesn't exist, make the choice based on stdenv.cc), but it gets locked in a cycle with the previous package. We can easily break this, however: We know that the previous set had clang and the next one doesn't exist, so we'd choose libcxxClang any day of the week.
This commit is contained in:
parent
17c5a15c89
commit
766f5ffb76
@ -89,7 +89,11 @@ let
|
||||
# python3 = pkgs.python3; # don't use python-boot
|
||||
# });
|
||||
|
||||
clang = if stdenv.cc.isGNU then tools.libstdcxxClang else tools.libcxxClang;
|
||||
# pick clang appropriate for package set we are targeting
|
||||
clang =
|
||||
if (pkgs.targetPackages.stdenv or stdenv).cc.isGNU
|
||||
then tools.libstdcxxClang
|
||||
else tools.libcxxClang;
|
||||
|
||||
libstdcxxClang = wrapCCWith rec {
|
||||
cc = tools.clang-unwrapped;
|
||||
|
@ -104,7 +104,11 @@ let
|
||||
# python3 = pkgs.python3; # don't use python-boot
|
||||
# });
|
||||
|
||||
clang = if stdenv.cc.isGNU then tools.libstdcxxClang else tools.libcxxClang;
|
||||
# pick clang appropriate for package set we are targeting
|
||||
clang =
|
||||
if (pkgs.targetPackages.stdenv or stdenv).cc.isGNU
|
||||
then tools.libstdcxxClang
|
||||
else tools.libcxxClang;
|
||||
|
||||
libstdcxxClang = wrapCCWith rec {
|
||||
cc = tools.clang-unwrapped;
|
||||
|
@ -92,7 +92,11 @@ let
|
||||
# python3 = pkgs.python3; # don't use python-boot
|
||||
# });
|
||||
|
||||
clang = if stdenv.cc.isGNU then tools.libstdcxxClang else tools.libcxxClang;
|
||||
# pick clang appropriate for package set we are targeting
|
||||
clang =
|
||||
if (pkgs.targetPackages.stdenv or stdenv).cc.isGNU
|
||||
then tools.libstdcxxClang
|
||||
else tools.libcxxClang;
|
||||
|
||||
libstdcxxClang = wrapCCWith rec {
|
||||
cc = tools.clang-unwrapped;
|
||||
|
@ -93,7 +93,11 @@ let
|
||||
# python3 = pkgs.python3; # don't use python-boot
|
||||
# });
|
||||
|
||||
clang = if stdenv.cc.isGNU then tools.libstdcxxClang else tools.libcxxClang;
|
||||
# pick clang appropriate for package set we are targeting
|
||||
clang =
|
||||
if (pkgs.targetPackages.stdenv or stdenv).cc.isGNU
|
||||
then tools.libstdcxxClang
|
||||
else tools.libcxxClang;
|
||||
|
||||
libstdcxxClang = wrapCCWith rec {
|
||||
cc = tools.clang-unwrapped;
|
||||
|
@ -65,7 +65,11 @@ let
|
||||
python3 = pkgs.python3; # don't use python-boot
|
||||
});
|
||||
|
||||
clang = if stdenv.cc.isGNU then tools.libstdcxxClang else tools.libcxxClang;
|
||||
# pick clang appropriate for package set we are targeting
|
||||
clang =
|
||||
if (pkgs.targetPackages.stdenv or stdenv).cc.isGNU
|
||||
then tools.libstdcxxClang
|
||||
else tools.libcxxClang;
|
||||
|
||||
libstdcxxClang = wrapCCWith rec {
|
||||
cc = tools.clang-unwrapped;
|
||||
|
@ -66,7 +66,11 @@ let
|
||||
python3 = pkgs.python3; # don't use python-boot
|
||||
});
|
||||
|
||||
clang = if stdenv.cc.isGNU then tools.libstdcxxClang else tools.libcxxClang;
|
||||
# pick clang appropriate for package set we are targeting
|
||||
clang =
|
||||
if (pkgs.targetPackages.stdenv or stdenv).cc.isGNU
|
||||
then tools.libstdcxxClang
|
||||
else tools.libcxxClang;
|
||||
|
||||
libstdcxxClang = wrapCCWith rec {
|
||||
cc = tools.clang-unwrapped;
|
||||
|
@ -96,7 +96,11 @@ let
|
||||
python3 = pkgs.python3; # don't use python-boot
|
||||
});
|
||||
|
||||
clang = if stdenv.cc.isGNU then tools.libstdcxxClang else tools.libcxxClang;
|
||||
# pick clang appropriate for package set we are targeting
|
||||
clang =
|
||||
if (pkgs.targetPackages.stdenv or stdenv).cc.isGNU
|
||||
then tools.libstdcxxClang
|
||||
else tools.libcxxClang;
|
||||
|
||||
libstdcxxClang = wrapCCWith rec {
|
||||
cc = tools.clang-unwrapped;
|
||||
|
@ -97,7 +97,11 @@ let
|
||||
python3 = pkgs.python3; # don't use python-boot
|
||||
});
|
||||
|
||||
clang = if stdenv.cc.isGNU then tools.libstdcxxClang else tools.libcxxClang;
|
||||
# pick clang appropriate for package set we are targeting
|
||||
clang =
|
||||
if (pkgs.targetPackages.stdenv or stdenv).cc.isGNU
|
||||
then tools.libstdcxxClang
|
||||
else tools.libcxxClang;
|
||||
|
||||
libstdcxxClang = wrapCCWith rec {
|
||||
cc = tools.clang-unwrapped;
|
||||
|
@ -97,7 +97,11 @@ let
|
||||
python3 = pkgs.python3; # don't use python-boot
|
||||
});
|
||||
|
||||
clang = if stdenv.cc.isGNU then tools.libstdcxxClang else tools.libcxxClang;
|
||||
# pick clang appropriate for package set we are targeting
|
||||
clang =
|
||||
if (pkgs.targetPackages.stdenv or stdenv).cc.isGNU
|
||||
then tools.libstdcxxClang
|
||||
else tools.libcxxClang;
|
||||
|
||||
libstdcxxClang = wrapCCWith rec {
|
||||
cc = tools.clang-unwrapped;
|
||||
|
@ -93,7 +93,11 @@ let
|
||||
# python3 = pkgs.python3; # don't use python-boot
|
||||
# });
|
||||
|
||||
clang = if stdenv.cc.isGNU then tools.libstdcxxClang else tools.libcxxClang;
|
||||
# pick clang appropriate for package set we are targeting
|
||||
clang =
|
||||
if (pkgs.targetPackages.stdenv or stdenv).cc.isGNU
|
||||
then tools.libstdcxxClang
|
||||
else tools.libcxxClang;
|
||||
|
||||
libstdcxxClang = wrapCCWith rec {
|
||||
cc = tools.clang-unwrapped;
|
||||
|
@ -124,7 +124,13 @@ stageFuns: let
|
||||
if buildPackages.stdenv.hasCC
|
||||
then
|
||||
if buildPackages.stdenv.cc.isClang or false
|
||||
then buildPackages.clang
|
||||
# buildPackages.clang checks targetPackages.stdenv.cc (i. e. this
|
||||
# attribute) to get a sense of the its set's default compiler and
|
||||
# chooses between libc++ and libstdc++ based on that. If we hit this
|
||||
# code here, we'll cause an infinite recursion. Since a set with
|
||||
# clang as its default compiler always means libc++, we can infer this
|
||||
# decision statically.
|
||||
then buildPackages.llvmPackages.libcxxClang
|
||||
else buildPackages.gcc
|
||||
else
|
||||
# This will blow up if anything uses it, but that's OK. The `if
|
||||
|
@ -70,7 +70,7 @@ in lib.init bootStages ++ [
|
||||
# when there is a C compiler and everything should be fine.
|
||||
then throw "no C compiler provided for this platform"
|
||||
else if crossSystem.isDarwin
|
||||
then buildPackages.llvmPackages.clang
|
||||
then buildPackages.llvmPackages.libcxxClang
|
||||
else if crossSystem.useLLVM or false
|
||||
then buildPackages.llvmPackages.clangUseLLVM
|
||||
else buildPackages.gcc;
|
||||
|
Loading…
Reference in New Issue
Block a user