NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
17.15k stars 13.42k forks source link

ccacheStdenv cannot find libcxx on Darwin #34817

Open mnacamura opened 6 years ago

mnacamura commented 6 years ago

Issue description

The title says it all. I ran this on Darwin:

#!/usr/bin/env nix-shell --pure

with import <nixpkgs> {};
let
  myCcacheWrapper = ccacheWrapper.override {
    extraConfig = ''
      export CCACHE_COMPRESS=1
      export CCACHE_DIR=/var/cache/ccache
      export CCACHE_UMASK=007
    '';
  };
  myStdenv = overrideCC stdenv myCcacheWrapper;
in
myStdenv.mkDerivation {
  name = "darwin-ccacheStdenv-test";
  buildInputs = [ libcxx ];
  shellHook = ''
    cat << CODE > test.cc
    #include <string>
    CODE
    $CXX -c test.cc
    exit 0
  '';
}

It succeeded. Then, I removed libcxx from buildInputs and ran it again. I saw

test.cc:1:10: fatal error: 'string' file not found
#include <string>
         ^~~~~~~~
1 error generated.

Technical details

mnacamura commented 6 years ago

Running this

#!/usr/bin/env nix-shell --pure
with import <nixpkgs> {};
stdenv.mkDerivation {
  name = "darwin-stdenv-test";
  shellHook = ''
    cat << CODE > test.cc
    #include <string>
    CODE
    echo NIX_CFLAGS_COMPILE: $NIX_CFLAGS_COMPILE
    echo NIX_LDFLAGS: $NIX_LDFLAGS
    echo NIX_CXXSTDLIB_COMPILE: $NIX_CXXSTDLIB_COMPILE
    echo NIX_CXXSTDLIB_LINK: $NIX_CXXSTDLIB_LINK
    $CXX -c test.cc
    exit 0
  '';
}

returns

NIX_CFLAGS_COMPILE: -isystem /nix/store/yd3bi1p0b7wwd0cgjwy77wh549dm5x3d-libc++-4.0.1/include -F/nix/store/69yzhzc71jhxpjg5gzddj6ifvph3fxp5-CF-osx-10.10.5/Library/Frameworks -isystem /nix/store/yd3bi1p0b7wwd0cgjwy77wh549dm5x3d-libc++-4.0.1/include -F/nix/store/69yzhzc71jhxpjg5gzddj6ifvph3fxp5-CF-osx-10.10.5/Library/Frameworks
NIX_LDFLAGS: -L/nix/store/yd3bi1p0b7wwd0cgjwy77wh549dm5x3d-libc++-4.0.1/lib -L/nix/store/yd3bi1p0b7wwd0cgjwy77wh549dm5x3d-libc++-4.0.1/lib
NIX_CXXSTDLIB_COMPILE: -isystem /nix/store/yd3bi1p0b7wwd0cgjwy77wh549dm5x3d-libc++-4.0.1/include/c++/v1
NIX_CXXSTDLIB_LINK: -stdlib=libc++

and running this

#!/usr/bin/env nix-shell --pure
with import <nixpkgs> {};
let
  myCcacheWrapper = ccacheWrapper.override {
    extraConfig = ''
      export CCACHE_COMPRESS=1
      export CCACHE_DIR=/var/cache/ccache
      export CCACHE_UMASK=007
    '';
  };
  myStdenv = overrideCC stdenv myCcacheWrapper;
in
myStdenv.mkDerivation {
  name = "darwin-ccacheStdenv-test";
  shellHook = ''
    cat << CODE > test.cc
    #include <string>
    CODE
    echo NIX_CFLAGS_COMPILE: $NIX_CFLAGS_COMPILE
    echo NIX_LDFLAGS: $NIX_LDFLAGS
    echo NIX_CXXSTDLIB_COMPILE: $NIX_CXXSTDLIB_COMPILE
    echo NIX_CXXSTDLIB_LINK: $NIX_CXXSTDLIB_LINK
    $CXX -c test.cc
    exit 0
  '';
}

returns

NIX_CFLAGS_COMPILE: -F/nix/store/69yzhzc71jhxpjg5gzddj6ifvph3fxp5-CF-osx-10.10.5/Library/Frameworks -F/nix/store/69yzhzc71jhxpjg5gzddj6ifvph3fxp5-CF-osx-10.10.5/Library/Frameworks
NIX_LDFLAGS:
NIX_CXXSTDLIB_COMPILE:
NIX_CXXSTDLIB_LINK:
test.cc:1:10: fatal error: 'string' file not found
#include <string>
         ^~~~~~~~
1 error generated.
matthewbauer commented 5 years ago

Yes, I think ccacheWrapper is broken right now...

luzpaz commented 5 years ago

can you recreate this on ccache 3.6 ?

veprbl commented 4 years ago

caccheStdenv was not tested on Darwin (nor with clang on Linux), so probably it never worked with them

ccacheStdenv used to work for me on darwin a few years ago.

stale[bot] commented 4 years ago

Hello, I'm a bot and I thank you in the name of the community for opening this issue.

To help our human contributors focus on the most-relevant reports, I check up on old issues to see if they're still relevant. This issue has had no activity for 180 days, and so I marked it as stale, but you can rest assured it will never be closed by a non-human.

The community would appreciate your effort in checking if the issue is still valid. If it isn't, please close it.

If the issue persists, and you'd like to remove the stale label, you simply need to leave a comment. Your comment can be as simple as "still important to me". If you'd like it to get more attention, you can ask for help by searching for maintainers and people that previously touched related code and @ mention them in a comment. You can use Git blame or GitHub's web interface on the relevant files to find them.

Lastly, you can always ask for help at our Discourse Forum or at #nixos' IRC channel.

matthewbauer commented 4 years ago

Still important

stale[bot] commented 3 years ago

I marked this as stale due to inactivity. → More info

nixos-discourse commented 2 years ago

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/tensorflow-on-20-09-mac/11931/5