Skip to content

Commit

Permalink
llvmPackages_15.libcxxabi: fix cycles that arise when stdenv is the…
Browse files Browse the repository at this point in the history
… LLVM stdenv
  • Loading branch information
rrbutani committed Jan 27, 2023
1 parent ca59a20 commit 501a9e1
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
15 changes: 14 additions & 1 deletion pkgs/development/compilers/llvm/15/default.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ lowPrio, newScope, pkgs, lib, stdenv, cmake
{ lowPrio, newScope, pkgs, lib, stdenv, stdenvNoCC, cmake
, gccForLibs, preLibcCrossHeaders
, libxml2, python3, isl, fetchFromGitHub, overrideCC, wrapCCWith, wrapBintoolsWith
, buildLlvmTools # tools, but from the previous stage, for cross
Expand Down Expand Up @@ -253,6 +253,19 @@ let
# what stdenv we use here, as long as CMake is happy.
cxx-headers = callPackage ./libcxx {
inherit llvm_meta;
# Note that if we use the regular stdenv here we'll get cycle errors
# when attempting to use this compiler in the stdenv.
#
# The final stdenv pulls `cxx-headers` from the package set where
# hostPlatform *is* the target platform which means that `stdenv` at
# that point attempts to use this toolchain.
#
# So, we use `stdenv_` (the stdenv containing `clang` from this package
# set, defined below) to sidestep this issue.
#
# Because we only use `cxx-headers` in `libcxxabi` (which depends on the
# clang stdenv _anyways_), this is okay.
stdenv = stdenv_;
headersOnly = true;
};

Expand Down
8 changes: 7 additions & 1 deletion pkgs/development/compilers/llvm/15/libcxx/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,13 @@ stdenv.mkDerivation rec {
"-DLIBCXX_ENABLE_THREADS=OFF"
"-DLIBCXX_ENABLE_FILESYSTEM=OFF"
"-DLIBCXX_ENABLE_EXCEPTIONS=OFF"
] ++ lib.optional (!enableShared) "-DLIBCXX_ENABLE_SHARED=OFF";
] ++ lib.optional (!enableShared) "-DLIBCXX_ENABLE_SHARED=OFF"
# If we're only building the headers we don't actually *need* a functioning
# C/C++ compiler:
++ lib.optionals (headersOnly) [
"-DCMAKE_C_COMPILER_WORKS=ON"
"-DCMAKE_CXX_COMPILER_WORKS=ON"
];

buildFlags = lib.optional headersOnly "generate-cxx-headers";
installTargets = lib.optional headersOnly "install-cxx-headers";
Expand Down

0 comments on commit 501a9e1

Please sign in to comment.