query
On this page

overrideLibcxx

pkgs.overrideLibcxx

Docs pulled from | This Revision | about 1 hour ago


because older compilers may not be able to parse the headers from the default stdenv’s libc++.


Noogle detected

Implementation

The following is the current implementation of this function.

overrideLibcxx = stdenv:
    assert stdenv.cc.libcxx != null;
    assert pkgs.stdenv.cc.libcxx != null;
    # only unified libcxx / libcxxabi stdenv's are supported
    assert lib.versionAtLeast pkgs.stdenv.cc.libcxx.version "12";
    assert lib.versionAtLeast stdenv.cc.libcxx.version "12";
    let
      llvmLibcxxVersion = lib.getVersion llvmLibcxx;

      stdenvLibcxx = pkgs.stdenv.cc.libcxx;
      llvmLibcxx = stdenv.cc.libcxx;

      libcxx = pkgs.runCommand "${stdenvLibcxx.name}-${llvmLibcxxVersion}" {
        outputs = [ "out" "dev" ];
        isLLVM = true;
      } ''
        mkdir -p "$dev/nix-support"
        ln -s '${stdenvLibcxx}' "$out"
        echo '${stdenvLibcxx}' > "$dev/nix-support/propagated-build-inputs"
        ln -s '${lib.getDev llvmLibcxx}/include' "$dev/include"
      '';
    in
    overrideCC stdenv (stdenv.cc.override {
      inherit libcxx;
      extraPackages = [
        pkgs.buildPackages.targetPackages."llvmPackages_${lib.versions.major llvmLibcxxVersion}".compiler-rt
      ];
    });