Std::execution::par not found

Hi everyone. I’m trying to compile tangerine using Nix, and am stuck in the compiling phase. It seems the parallel execution strategies in std::execution are missing from libc++ in my build.

What I tried

I first tried a very simple nix file:

{
  cmake,
  SDL2,
  stdenv,
}:
stdenv.mkDerivation {
  name = "tangerine";
  src = ./.;

  nativeBuildInputs = [cmake];

  buildInputs = [SDL2];
}

Which resulted in the following error:

/tmp/nix-build-tangerine.drv-0/tangerine/third_party/naive-surface-nets/src/surface_nets.cpp:1175:14: error: no member named 'execution' in namespace 'std'; did you mean 'exception'?
        std::execution::par,
        ~~~~~^~~~~~~~~
             exception

(full log)

Since the build instructions specify using llvm 17, I tried with that:

{
  cmake,
  SDL2,
  llvmPackages_17,
  stdenv,
}:
stdenv.mkDerivation {
  name = "tangerine";
  src = ./.;

  nativeBuildInputs = [cmake llvmPackages_17.clang];

  buildInputs = [SDL2];
}

Which slightly changed the error:

/tmp/nix-build-tangerine.drv-0/tangerine/third_party/naive-surface-nets/src/surface_nets.cpp:1175:25: error: no member named 'par' in namespace 'std::execution'
 1175 |         std::execution::par,
      |         ~~~~~~~~~~~~~~~~^

(full log)

Newer versions of clang do not seem to change the behavior.

Possible Cause

I haven’t found much online about this problem, but this issue seems to imply that libc++ needs to be compiled using LIBCXX_ENABLE_PARALLEL_ALGORITHMS.

On the other hand, I am not even sure I am using the correct libc++ in the first place. Does Nix automatically set --libstd=?

There’s a pr for tangerine made 2 days ago tangerine: init at 2024-04-05 by viraptor · Pull Request #301672 · NixOS/nixpkgs · GitHub

The package is marked broken on darwin(uses clang by default) which I assume you’re on because using clang(llvmPackages_17.stdenv) on linux works

To use a specific version of clang as the compiler with the proper setup and stuff use llvmPackages_17.stdenv