Unverified Commit 501a9e1b authored by Rahul Butani's avatar Rahul Butani
Browse files

llvmPackages_15.libcxxabi: fix cycles that arise when `stdenv` is the LLVM stdenv

parent ca59a201
Loading
Loading
Loading
Loading
+14 −1
Original line number Diff line number Diff line
{ 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;
      };

+7 −1
Original line number Diff line number Diff line
@@ -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";