`clang` cannot locate C++ std headers

I already posted about this as a nixpkgs issue, but after it stagnating for a while I decided to ask on here.

I am trying to build a software called “Redumper” from GitHub - superg/redumper: Low level CD dumper utility
When trying to build the application, it quite quickly fails with the error of /build/source/generate_offsets.cc:1:10: fatal error: 'filesystem' file not found

From talking with the developer at the time, it seems to be that clang isn’t properly locating the C++ std headers as I would expect it to. I have put evaluation and log examples at the bottom of this post.
(Yes, this still happens with llvmPackages_18.libcxxStdenv.mkDerivation as well.)

Example Evaluation using llvmPackages_18 and clang_18
{
  lib,
  fetchFromGitHub,
  cmake,
  ninja,
  build_type ? "Release",
    # Typical values include `Debug`, `Release`, `RelWithDebInfo` and
      # `MinSizeRel`
    # Usually set to "Release" for GitHub Actions use, so that's what it's set
      # to here.

  # clang
  llvmPackages_18,
  clang_18
}:

llvmPackages_18.stdenv.mkDerivation rec {
  pname = "redumper-git";
  version = "403";

  src = fetchFromGitHub {
    owner = "superg";
    repo = "redumper";
    rev = "0212055b2f74a1af907c8fd8f115ad21e493bad0";
    hash = "sha256-Zq7Fyuz0jm/djUlDsKJG879utpHNceSJg1LVo0mLliM=";
  };

  nativeBuildInputs = [
    cmake
    ninja
    clang_18 # Should alias to `llvmPackages_18.clang`
  ];

  cmakeFlags = [
    "-DCMAKE_BUILD_WITH_INSTALL_RPATH=ON"
    "-DREDUMPER_CLANG_LINK_OPTIONS=-static"
    "-DREDUMPER_VERSION_BUILD=${version}"
  ];


  meta = {
    description = "Low level CD dumper utility.";
    homepage = "https://github.com/superg/redumper";
    license = lib.licenses.gpl3Only;
    maintainers = with lib.maintainers; [ ];
    mainProgram = "redumper";
    platforms = lib.platforms.all;
  };
}
Example Log Output
@nix { "action": "setPhase", "phase": "unpackPhase" }
Running phase: unpackPhase
unpacking source archive /nix/store/yx99sq32yscvzm88rcpvi615b7l64r1l-source
source root is source
@nix { "action": "setPhase", "phase": "patchPhase" }
Running phase: patchPhase
@nix { "action": "setPhase", "phase": "updateAutotoolsGnuConfigScriptsPhase" }
Running phase: updateAutotoolsGnuConfigScriptsPhase
@nix { "action": "setPhase", "phase": "configurePhase" }
Running phase: configurePhase
fixing cmake files...
cmake flags: -GNinja -DCMAKE_FIND_USE_SYSTEM_PACKAGE_REGISTRY=OFF -DCMAKE_FIND_USE_PACKAGE_REGISTRY=OFF -DCMAKE_EXPORT_NO_PACKAGE_REGISTRY=ON -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=OFF -DCMAKE_INSTALL_LOCALEDIR=/nix/store/7cnhv1yq10miilrb3vn9cj81k3zga0fk-redumper-git-403/share/locale -DCMAKE_INSTALL_LIBEXECDIR=/nix/store/7cnhv1yq10miilrb3vn9cj81k3zga0fk-redumper-git-403/libexec -DCMAKE_INSTALL_LIBDIR=/nix/store/7cnhv1yq10miilrb3vn9cj81k3zga0fk-redumper-git-403/lib -DCMAKE_INSTALL_DOCDIR=/nix/store/7cnhv1yq10miilrb3vn9cj81k3zga0fk-redumper-git-403/share/doc/redumper-git -DCMAKE_INSTALL_INFODIR=/nix/store/7cnhv1yq10miilrb3vn9cj81k3zga0fk-redumper-git-403/share/info -DCMAKE_INSTALL_MANDIR=/nix/store/7cnhv1yq10miilrb3vn9cj81k3zga0fk-redumper-git-403/share/man -DCMAKE_INSTALL_OLDINCLUDEDIR=/nix/store/7cnhv1yq10miilrb3vn9cj81k3zga0fk-redumper-git-403/include -DCMAKE_INSTALL_INCLUDEDIR=/nix/store/7cnhv1yq10miilrb3vn9cj81k3zga0fk-redumper-git-403/include -DCMAKE_INSTALL_SBINDIR=/nix/store/7cnhv1yq10miilrb3vn9cj81k3zga0fk-redumper-git-403/sbin -DCMAKE_INSTALL_BINDIR=/nix/store/7cnhv1yq10miilrb3vn9cj81k3zga0fk-redumper-git-403/bin -DCMAKE_INSTALL_NAME_DIR=/nix/store/7cnhv1yq10miilrb3vn9cj81k3zga0fk-redumper-git-403/lib -DCMAKE_POLICY_DEFAULT_CMP0025=NEW -DCMAKE_OSX_SYSROOT= -DCMAKE_FIND_FRAMEWORK=LAST -DCMAKE_STRIP=/nix/store/4a7g4s02vr57jccasyawfwmwnw9v0bpv-clang-wrapper-18.1.7/bin/strip -DCMAKE_RANLIB=/nix/store/4a7g4s02vr57jccasyawfwmwnw9v0bpv-clang-wrapper-18.1.7/bin/ranlib -DCMAKE_AR=/nix/store/4a7g4s02vr57jccasyawfwmwnw9v0bpv-clang-wrapper-18.1.7/bin/ar -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_INSTALL_PREFIX=/nix/store/7cnhv1yq10miilrb3vn9cj81k3zga0fk-redumper-git-403 -DCMAKE_BUILD_WITH_INSTALL_RPATH=ON -DREDUMPER_CLANG_LINK_OPTIONS=-static -DREDUMPER_VERSION_BUILD=403 
-- The C compiler identification is Clang 18.1.7
-- The CXX compiler identification is Clang 18.1.7
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /nix/store/4a7g4s02vr57jccasyawfwmwnw9v0bpv-clang-wrapper-18.1.7/bin/clang - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /nix/store/4a7g4s02vr57jccasyawfwmwnw9v0bpv-clang-wrapper-18.1.7/bin/clang++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done (1.5s)
-- Generating done (0.0s)
CMake Warning:
  Manually-specified variables were not used by the project:

    BUILD_TESTING
    CMAKE_EXPORT_NO_PACKAGE_REGISTRY
    CMAKE_FIND_USE_PACKAGE_REGISTRY
    CMAKE_FIND_USE_SYSTEM_PACKAGE_REGISTRY
    CMAKE_INSTALL_BINDIR
    CMAKE_INSTALL_DOCDIR
    CMAKE_INSTALL_INCLUDEDIR
    CMAKE_INSTALL_INFODIR
    CMAKE_INSTALL_LIBDIR
    CMAKE_INSTALL_LIBEXECDIR
    CMAKE_INSTALL_LOCALEDIR
    CMAKE_INSTALL_MANDIR
    CMAKE_INSTALL_OLDINCLUDEDIR
    CMAKE_INSTALL_SBINDIR
    CMAKE_POLICY_DEFAULT_CMP0025


-- Build files have been written to: /build/source/build
cmake: enabled parallel building
cmake: enabled parallel installing
@nix { "action": "setPhase", "phase": "buildPhase" }
Running phase: buildPhase
build flags: -j8
[1/188] Scanning /build/source/generate_offsets.cc for CXX dependencies
FAILED: CMakeFiles/generate_offsets.dir/generate_offsets.cc.o.ddi 
"/nix/store/2v3f3df7ya4i692dc3f67zigwba5kvbb-clang-18.1.7/bin/clang-scan-deps" -format=p1689 -- /nix/store/4a7g4s02vr57jccasyawfwmwnw9v0bpv-clang-wrapper-18.1.7/bin/clang++ -DREDUMPER_VERSION_BUILD=403 -DREDUMPER_VERSION_MAJOR=1980 -DREDUMPER_VERSION_MINOR=01 -DREDUMPER_VERSION_PATCH=01  -O3 -DNDEBUG -std=gnu++20 -stdlib=libc++ -x c++ /build/source/generate_offsets.cc -c -o CMakeFiles/generate_offsets.dir/generate_offsets.cc.o -resource-dir "/nix/store/4a7g4s02vr57jccasyawfwmwnw9v0bpv-clang-wrapper-18.1.7/resource-root" -MT CMakeFiles/generate_offsets.dir/generate_offsets.cc.o.ddi -MD -MF CMakeFiles/generate_offsets.dir/generate_offsets.cc.o.ddi.d > CMakeFiles/generate_offsets.dir/generate_offsets.cc.o.ddi.tmp && mv CMakeFiles/generate_offsets.dir/generate_offsets.cc.o.ddi.tmp CMakeFiles/generate_offsets.dir/generate_offsets.cc.o.ddi
warning: argument unused during compilation: '-stdlib=libc++'
Error while scanning dependencies for /build/source/generate_offsets.cc:
/build/source/generate_offsets.cc:1:10: fatal error: 'filesystem' file not found
[2/188] Building C object lzma/CMakeFiles/lzma.dir/CpuArch.c.o
[3/188] Building C object lzma/CMakeFiles/lzma.dir/Alloc.c.o
[4/188] Building C object lzma/CMakeFiles/lzma.dir/LzFindOpt.c.o
[5/188] Building C object lzma/CMakeFiles/lzma.dir/LzFindMt.c.o
[6/188] Building C object lzma/CMakeFiles/lzma.dir/LzmaDec.c.o
[7/188] Building C object lzma/CMakeFiles/lzma.dir/LzFind.c.o
[8/188] Building C object lzma/CMakeFiles/lzma.dir/LzmaEnc.c.o
ninja: build stopped: subcommand failed.

Thank you for the time!


I’m using Lix in a WSL environment via github:nix-community/NixOS-WSL, though I don’t believe either of those factors influence this issue.

System information via nix run nixpkgs#nix-info -- -m:

$  nix run nixpkgs#nix-info -- -m
 - system: `"x86_64-linux"`
 - host os: `Linux 5.15.153.1-microsoft-standard-WSL2, NixOS, 24.11 (Vicuna), 24.11.20240821.c374d94`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Lix, like Nix) 2.92.0-dev-pre20240822-87fd6e0
System type: x86_64-linux
Additional system types: i686-linux, x86_64-v1-linux, x86_64-v2-linux, x86_64-v3-linux

Hello, I’m one of the LLVM maintainers. Sorry about the stagnation in the issue, I was recently made aware of it. I tried building the package on aarch64-linux and ran into the same problem. It looks like clang-scan-deps reads certain things from the arguments so we might have to wrap clang-scan-deps to fix the inclusion issue.

Thank you for looking into it!

1 Like