diff options
author | sternenseemann <sternenseemann@systemli.org> | 2022-01-07 02:30:01 +0100 |
---|---|---|
committer | sternenseemann <sternenseemann@systemli.org> | 2022-01-07 14:42:41 +0100 |
commit | 766f5ffb761bc916ea0f270f472d04ab30664d52 (patch) | |
tree | d67895941f0a0760acdae057ce0b51450b84268d /pkgs/stdenv/booter.nix | |
parent | 17c5a15c89f2523b2543f946daa4d018e04d731a (diff) | |
download | nixlib-766f5ffb761bc916ea0f270f472d04ab30664d52.tar nixlib-766f5ffb761bc916ea0f270f472d04ab30664d52.tar.gz nixlib-766f5ffb761bc916ea0f270f472d04ab30664d52.tar.bz2 nixlib-766f5ffb761bc916ea0f270f472d04ab30664d52.tar.lz nixlib-766f5ffb761bc916ea0f270f472d04ab30664d52.tar.xz nixlib-766f5ffb761bc916ea0f270f472d04ab30664d52.tar.zst nixlib-766f5ffb761bc916ea0f270f472d04ab30664d52.zip |
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.
Diffstat (limited to 'pkgs/stdenv/booter.nix')
-rw-r--r-- | pkgs/stdenv/booter.nix | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/pkgs/stdenv/booter.nix b/pkgs/stdenv/booter.nix index 51d617354e86..f1d07e6461a9 100644 --- a/pkgs/stdenv/booter.nix +++ b/pkgs/stdenv/booter.nix @@ -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 |