diff --git a/pkgs/development/compilers/llvm/15/default.nix b/pkgs/development/compilers/llvm/15/default.nix index d9b117ee2343b..8825f860c6161 100644 --- a/pkgs/development/compilers/llvm/15/default.nix +++ b/pkgs/development/compilers/llvm/15/default.nix @@ -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 @@ -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; }; diff --git a/pkgs/development/compilers/llvm/15/libcxx/default.nix b/pkgs/development/compilers/llvm/15/libcxx/default.nix index 1e3222da6b601..b4d973f0b073f 100644 --- a/pkgs/development/compilers/llvm/15/libcxx/default.nix +++ b/pkgs/development/compilers/llvm/15/libcxx/default.nix @@ -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";