Use Clang without GCC's C++ standard library

Hi everyone :slight_smile:
I hope I’m posting in the right category.

I’m trying to build a C++ package on NixOS with clangStdenv (the source code is coming from macOS and it doesn’t seems to compile with GCC). But I’m getting errors because Clang is pulling GCC’s C++ standard library instead of Clang’s one (the project I’m working on is using things like std::powf which are not in GCC’s std).

Any idea? Thanks!

1 Like

I’m not sure if it answers your specific question, but it’s worth checking out @mic92’s recent deep dive into C/C++ infrastructure if you’re going to be playing around with it:

Thanks! In fact I answered my own post, but the reply got flagged as spam, this did the trick for me:

with import <nixpkgs> {};
(clangStdenv.override (x: {
  cc = (_: {
    libcxx = llvmPackages.libcxx;
})).mkDerivation {
  # ...

You might want to look at libcxxStdenv.