Loading pkgs/development/compilers/swift/compiler/default.nix +12 −8 Original line number Diff line number Diff line Loading @@ -99,7 +99,6 @@ let # "clang-builtin-headers" "stdlib" "sdk-overlay" "parser-lib" "static-mirror-lib" "editor-integration" # "tools" Loading Loading @@ -257,6 +256,7 @@ in stdenv.mkDerivation { ${copySource "llvm-project"} ${copySource "swift"} ${copySource "swift-experimental-string-processing"} ${copySource "swift-syntax"} ${lib.optionalString (!stdenv.isDarwin) (copySource "swift-corelibs-libdispatch")} Loading @@ -276,9 +276,13 @@ in stdenv.mkDerivation { -e 's|/bin/cp|${coreutils}/bin/cp|g' \ -e 's|/usr/bin/file|${file}/bin/file|g' patch -p1 -d swift -i ${./patches/swift-cmake-3.25-compat.patch} patch -p1 -d swift -i ${./patches/swift-wrap.patch} patch -p1 -d swift -i ${./patches/swift-nix-resource-root.patch} patch -p1 -d swift -i ${./patches/swift-linux-fix-libc-paths.patch} patch -p1 -d swift -i ${./patches/swift-linux-fix-linking.patch} patch -p1 -d swift -i ${./patches/swift-darwin-libcxx-flags.patch} patch -p1 -d swift -i ${./patches/swift-darwin-link-cxxabi.patch} patch -p1 -d swift -i ${substituteAll { src = ./patches/swift-darwin-plistbuddy-workaround.patch; inherit swiftArch; Loading @@ -287,8 +291,6 @@ in stdenv.mkDerivation { src = ./patches/swift-prevent-sdk-dirs-warning.patch; inherit (builtins) storeDir; }} substituteInPlace swift/cmake/modules/SwiftConfigureSDK.cmake \ --replace '/usr/include' "${stdenv.cc.libc_dev}/include" # This patch needs to know the lib output location, so must be substituted # in the same derivation as the compiler. Loading Loading @@ -321,8 +323,8 @@ in stdenv.mkDerivation { ''} # Remove tests for cross compilation, which we don't currently support. rm swift/test/Interop/Cxx/class/constructors-copy-irgen.swift rm swift/test/Interop/Cxx/class/constructors-irgen.swift rm swift/test/Interop/Cxx/class/constructors-copy-irgen-*.swift rm swift/test/Interop/Cxx/class/constructors-irgen-*.swift # TODO: consider fixing and re-adding. This test fails due to a non-standard "install_prefix". rm swift/validation-test/Python/build_swift.swift Loading @@ -342,7 +344,7 @@ in stdenv.mkDerivation { rm swift/test/Serialization/restrict-swiftmodule-to-revision.swift # This test was flaky in ofborg, see #186476 rm swift/test/AutoDiff/compiler_crashers_fixed/sr14290-missing-debug-scopes-in-pullback-trampoline.swift rm swift/test/AutoDiff/compiler_crashers_fixed/issue-56649-missing-debug-scopes-in-pullback-trampoline.swift patchShebangs . Loading Loading @@ -446,7 +448,8 @@ in stdenv.mkDerivation { -DSWIFT_PATH_TO_CMARK_SOURCE=$SWIFT_SOURCE_ROOT/swift-cmark -DSWIFT_PATH_TO_CMARK_BUILD=$SWIFT_BUILD_ROOT/swift-cmark -DSWIFT_PATH_TO_LIBDISPATCH_SOURCE=$SWIFT_SOURCE_ROOT/swift-corelibs-libdispatch -DEXPERIMENTAL_STRING_PROCESSING_SOURCE_DIR=$SWIFT_SOURCE_ROOT/swift-experimental-string-processing -DSWIFT_PATH_TO_SWIFT_SYNTAX_SOURCE=$SWIFT_SOURCE_ROOT/swift-syntax -DSWIFT_PATH_TO_STRING_PROCESSING_SOURCE=$SWIFT_SOURCE_ROOT/swift-experimental-string-processing -DSWIFT_INSTALL_COMPONENTS=${lib.concatStringsSep ";" swiftInstallComponents} -DSWIFT_STDLIB_ENABLE_OBJC_INTEROP=${if stdenv.isDarwin then "ON" else "OFF"} " Loading Loading @@ -501,6 +504,7 @@ in stdenv.mkDerivation { cmakeFlags=" -GNinja -DCMAKE_Swift_COMPILER=$SWIFT_BUILD_ROOT/swift/bin/swiftc -DSWIFT_PATH_TO_SWIFT_SYNTAX_SOURCE=$SWIFT_SOURCE_ROOT/swift-syntax -DTOOLCHAIN_DIR=/var/empty -DSWIFT_NATIVE_LLVM_TOOLS_PATH=${stdenv.cc}/bin Loading Loading @@ -579,7 +583,7 @@ in stdenv.mkDerivation { # Undo the clang and swift wrapping we did for the build. # (This happened via patches to cmake files.) cd $SWIFT_BUILD_ROOT mv llvm/bin/clang-14{-unwrapped,} mv llvm/bin/clang-15{-unwrapped,} mv swift/bin/swift-frontend{-unwrapped,} mkdir $out $lib Loading pkgs/development/compilers/swift/compiler/patches/swift-cmake-3.25-compat.patch 0 → 100644 +1509 −0 File added.Preview size limit exceeded, changes collapsed. Show changes pkgs/development/compilers/swift/compiler/patches/swift-darwin-libcxx-flags.patch 0 → 100644 +63 −0 Original line number Diff line number Diff line On Darwin, the SDK is a directory of stubs, and libc++ lives separately. We need to patch the CMake files in several places to make the build for C++ interop succeed. The required flags can be read from cc-wrapper support files. --- a/SwiftCompilerSources/CMakeLists.txt +++ b/SwiftCompilerSources/CMakeLists.txt @@ -105,18 +105,11 @@ function(add_swift_compiler_modules_library name) get_filename_component(swift_exec_bin_dir ${ALS_SWIFT_EXEC} DIRECTORY) set(sdk_option ${sdk_option} "-resource-dir" "${swift_exec_bin_dir}/../bootstrapping0/lib/swift") endif() - if(NOT EXISTS "${sdk_path}/usr/include/c++") - # Darwin SDKs in Xcode 12 or older do not include libc++, which prevents clang from finding libc++ when invoked - # from ClangImporter. This results in build errors. To workaround this, let's explicitly pass the path to libc++ - # to clang. - message(WARNING "Building with an outdated Darwin SDK: libc++ missing from the ${SWIFT_HOST_VARIANT_SDK} SDK. Will use libc++ from the toolchain.") - get_filename_component(absolute_libcxx_path "${CMAKE_C_COMPILER}/../../include/c++/v1" REALPATH) - if (EXISTS "${absolute_libcxx_path}") - set(sdk_option ${sdk_option} "-Xcc" "-isystem" "-Xcc" "${absolute_libcxx_path}") - else() - message(ERROR "libc++ not found in the toolchain.") - endif() - endif() + file(READ "$ENV{NIX_CC}/nix-support/libcxx-cxxflags" nix_libcxx_cxxflags) + separate_arguments(nix_libcxx_cxxflags) + foreach(nix_libcxx_cxxflag ${nix_libcxx_cxxflags}) + set(sdk_option ${sdk_option} "-Xcc" "${nix_libcxx_cxxflag}") + endforeach() elseif(BOOTSTRAPPING_MODE STREQUAL "CROSSCOMPILE") set(sdk_option "-sdk" "${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_ARCH_${SWIFT_HOST_VARIANT_ARCH}_PATH}") get_filename_component(swift_exec_bin_dir ${ALS_SWIFT_EXEC} DIRECTORY) --- a/cmake/modules/SwiftConfigureSDK.cmake +++ b/cmake/modules/SwiftConfigureSDK.cmake @@ -270,6 +270,18 @@ macro(configure_sdk_darwin # Add this to the list of known SDKs. list(APPEND SWIFT_CONFIGURED_SDKS "${prefix}") + set(cxx_overlay_opt "") + if("${prefix}" STREQUAL "OSX") + file(READ "$ENV{NIX_CC}/nix-support/libcxx-cxxflags" nix_libcxx_cxxflags) + separate_arguments(nix_libcxx_cxxflags) + foreach(nix_libcxx_cxxflag ${nix_libcxx_cxxflags}) + set(cxx_overlay_opt ${cxx_overlay_opt} "-Xcc" "${nix_libcxx_cxxflag}") + endforeach() + endif() + set(SWIFT_SDK_${prefix}_CXX_OVERLAY_SWIFT_COMPILE_FLAGS + ${cxx_overlay_opt} + CACHE STRING "Extra flags for compiling the C++ overlay") + _report_sdk("${prefix}") endmacro() --- a/stdlib/public/Cxx/std/CMakeLists.txt +++ b/stdlib/public/Cxx/std/CMakeLists.txt @@ -145,6 +145,9 @@ add_swift_target_library(swiftstd STATIC NO_LINK_NAME IS_STDLIB SWIFT_COMPILE_FLAGS_LINUX ${SWIFT_SDK_LINUX_CXX_OVERLAY_SWIFT_COMPILE_FLAGS} + SWIFT_COMPILE_FLAGS_OSX + ${SWIFT_SDK_OSX_CXX_OVERLAY_SWIFT_COMPILE_FLAGS} + LINK_FLAGS "${SWIFT_RUNTIME_SWIFT_LINK_FLAGS}" TARGET_SDKS ALL_APPLE_PLATFORMS LINUX INSTALL_IN_COMPONENT compiler pkgs/development/compilers/swift/compiler/patches/swift-darwin-link-cxxabi.patch 0 → 100644 +14 −0 Original line number Diff line number Diff line This patches the stdlib backdeploy static lib to have its users link c++abi. Without this, later steps that try to link this fail looking for global new/delete operators (__Znwm/__ZdlPv). --- a/stdlib/toolchain/Compatibility56/Overrides.cpp +++ b/stdlib/toolchain/Compatibility56/Overrides.cpp @@ -23,6 +23,7 @@ using namespace swift; __asm__ (".linker_option \"-lc++\""); +__asm__ (".linker_option \"-lc++abi\""); #define OVERRIDE(name, ret, attrs, ccAttrs, namespace, typedArgs, namedArgs) \ Override_ ## name name; pkgs/development/compilers/swift/compiler/patches/swift-linux-fix-libc-paths.patch 0 → 100644 +48 −0 Original line number Diff line number Diff line This code injects an LLVM modulemap for glibc and libstdc++ by overriding specific VFS paths. In order to do that, it needs to know the actual locations of glibc and libstdc++, but it only searches `-sysroot` and fails. Here we patch it to also consider `-idirafter` and `-isystem` as added by cc-wrapper. --- a/lib/ClangImporter/ClangIncludePaths.cpp +++ b/lib/ClangImporter/ClangIncludePaths.cpp @@ -120,6 +120,7 @@ static clang::driver::Driver createClangDriver(const ASTContext &ctx) { /// \return a path without dots (`../`, './'). static llvm::Optional<Path> findFirstIncludeDir(const llvm::opt::InputArgList &args, + const llvm::opt::ArgList &DriverArgs, const ArrayRef<const char *> expectedFileNames) { // C++ stdlib paths are added as `-internal-isystem`. std::vector<std::string> includeDirs = @@ -128,6 +129,14 @@ findFirstIncludeDir(const llvm::opt::InputArgList &args, llvm::append_range(includeDirs, args.getAllArgValues( clang::driver::options::OPT_internal_externc_isystem)); + // Nix adds the C stdlib include path using `-idirafter`. + llvm::append_range(includeDirs, + DriverArgs.getAllArgValues( + clang::driver::options::OPT_idirafter)); + // Nix adds the C++ stdlib include path using `-isystem`. + llvm::append_range(includeDirs, + DriverArgs.getAllArgValues( + clang::driver::options::OPT_isystem)); for (const auto &includeDir : includeDirs) { Path dir(includeDir); @@ -193,7 +202,7 @@ getGlibcFileMapping(ASTContext &ctx) { // Ideally we would check that all of the headers referenced from the // modulemap are present. Path glibcDir; - if (auto dir = findFirstIncludeDir(parsedIncludeArgs, + if (auto dir = findFirstIncludeDir(parsedIncludeArgs, clangDriverArgs, {"inttypes.h", "unistd.h", "stdint.h"})) { glibcDir = dir.value(); } else { @@ -251,7 +260,7 @@ getLibStdCxxFileMapping(ASTContext &ctx) { auto parsedStdlibArgs = parseClangDriverArgs(clangDriver, stdlibArgStrings); Path cxxStdlibDir; - if (auto dir = findFirstIncludeDir(parsedStdlibArgs, + if (auto dir = findFirstIncludeDir(parsedStdlibArgs, clangDriverArgs, {"cstdlib", "string", "vector"})) { cxxStdlibDir = dir.value(); } else { Loading
pkgs/development/compilers/swift/compiler/default.nix +12 −8 Original line number Diff line number Diff line Loading @@ -99,7 +99,6 @@ let # "clang-builtin-headers" "stdlib" "sdk-overlay" "parser-lib" "static-mirror-lib" "editor-integration" # "tools" Loading Loading @@ -257,6 +256,7 @@ in stdenv.mkDerivation { ${copySource "llvm-project"} ${copySource "swift"} ${copySource "swift-experimental-string-processing"} ${copySource "swift-syntax"} ${lib.optionalString (!stdenv.isDarwin) (copySource "swift-corelibs-libdispatch")} Loading @@ -276,9 +276,13 @@ in stdenv.mkDerivation { -e 's|/bin/cp|${coreutils}/bin/cp|g' \ -e 's|/usr/bin/file|${file}/bin/file|g' patch -p1 -d swift -i ${./patches/swift-cmake-3.25-compat.patch} patch -p1 -d swift -i ${./patches/swift-wrap.patch} patch -p1 -d swift -i ${./patches/swift-nix-resource-root.patch} patch -p1 -d swift -i ${./patches/swift-linux-fix-libc-paths.patch} patch -p1 -d swift -i ${./patches/swift-linux-fix-linking.patch} patch -p1 -d swift -i ${./patches/swift-darwin-libcxx-flags.patch} patch -p1 -d swift -i ${./patches/swift-darwin-link-cxxabi.patch} patch -p1 -d swift -i ${substituteAll { src = ./patches/swift-darwin-plistbuddy-workaround.patch; inherit swiftArch; Loading @@ -287,8 +291,6 @@ in stdenv.mkDerivation { src = ./patches/swift-prevent-sdk-dirs-warning.patch; inherit (builtins) storeDir; }} substituteInPlace swift/cmake/modules/SwiftConfigureSDK.cmake \ --replace '/usr/include' "${stdenv.cc.libc_dev}/include" # This patch needs to know the lib output location, so must be substituted # in the same derivation as the compiler. Loading Loading @@ -321,8 +323,8 @@ in stdenv.mkDerivation { ''} # Remove tests for cross compilation, which we don't currently support. rm swift/test/Interop/Cxx/class/constructors-copy-irgen.swift rm swift/test/Interop/Cxx/class/constructors-irgen.swift rm swift/test/Interop/Cxx/class/constructors-copy-irgen-*.swift rm swift/test/Interop/Cxx/class/constructors-irgen-*.swift # TODO: consider fixing and re-adding. This test fails due to a non-standard "install_prefix". rm swift/validation-test/Python/build_swift.swift Loading @@ -342,7 +344,7 @@ in stdenv.mkDerivation { rm swift/test/Serialization/restrict-swiftmodule-to-revision.swift # This test was flaky in ofborg, see #186476 rm swift/test/AutoDiff/compiler_crashers_fixed/sr14290-missing-debug-scopes-in-pullback-trampoline.swift rm swift/test/AutoDiff/compiler_crashers_fixed/issue-56649-missing-debug-scopes-in-pullback-trampoline.swift patchShebangs . Loading Loading @@ -446,7 +448,8 @@ in stdenv.mkDerivation { -DSWIFT_PATH_TO_CMARK_SOURCE=$SWIFT_SOURCE_ROOT/swift-cmark -DSWIFT_PATH_TO_CMARK_BUILD=$SWIFT_BUILD_ROOT/swift-cmark -DSWIFT_PATH_TO_LIBDISPATCH_SOURCE=$SWIFT_SOURCE_ROOT/swift-corelibs-libdispatch -DEXPERIMENTAL_STRING_PROCESSING_SOURCE_DIR=$SWIFT_SOURCE_ROOT/swift-experimental-string-processing -DSWIFT_PATH_TO_SWIFT_SYNTAX_SOURCE=$SWIFT_SOURCE_ROOT/swift-syntax -DSWIFT_PATH_TO_STRING_PROCESSING_SOURCE=$SWIFT_SOURCE_ROOT/swift-experimental-string-processing -DSWIFT_INSTALL_COMPONENTS=${lib.concatStringsSep ";" swiftInstallComponents} -DSWIFT_STDLIB_ENABLE_OBJC_INTEROP=${if stdenv.isDarwin then "ON" else "OFF"} " Loading Loading @@ -501,6 +504,7 @@ in stdenv.mkDerivation { cmakeFlags=" -GNinja -DCMAKE_Swift_COMPILER=$SWIFT_BUILD_ROOT/swift/bin/swiftc -DSWIFT_PATH_TO_SWIFT_SYNTAX_SOURCE=$SWIFT_SOURCE_ROOT/swift-syntax -DTOOLCHAIN_DIR=/var/empty -DSWIFT_NATIVE_LLVM_TOOLS_PATH=${stdenv.cc}/bin Loading Loading @@ -579,7 +583,7 @@ in stdenv.mkDerivation { # Undo the clang and swift wrapping we did for the build. # (This happened via patches to cmake files.) cd $SWIFT_BUILD_ROOT mv llvm/bin/clang-14{-unwrapped,} mv llvm/bin/clang-15{-unwrapped,} mv swift/bin/swift-frontend{-unwrapped,} mkdir $out $lib Loading
pkgs/development/compilers/swift/compiler/patches/swift-cmake-3.25-compat.patch 0 → 100644 +1509 −0 File added.Preview size limit exceeded, changes collapsed. Show changes
pkgs/development/compilers/swift/compiler/patches/swift-darwin-libcxx-flags.patch 0 → 100644 +63 −0 Original line number Diff line number Diff line On Darwin, the SDK is a directory of stubs, and libc++ lives separately. We need to patch the CMake files in several places to make the build for C++ interop succeed. The required flags can be read from cc-wrapper support files. --- a/SwiftCompilerSources/CMakeLists.txt +++ b/SwiftCompilerSources/CMakeLists.txt @@ -105,18 +105,11 @@ function(add_swift_compiler_modules_library name) get_filename_component(swift_exec_bin_dir ${ALS_SWIFT_EXEC} DIRECTORY) set(sdk_option ${sdk_option} "-resource-dir" "${swift_exec_bin_dir}/../bootstrapping0/lib/swift") endif() - if(NOT EXISTS "${sdk_path}/usr/include/c++") - # Darwin SDKs in Xcode 12 or older do not include libc++, which prevents clang from finding libc++ when invoked - # from ClangImporter. This results in build errors. To workaround this, let's explicitly pass the path to libc++ - # to clang. - message(WARNING "Building with an outdated Darwin SDK: libc++ missing from the ${SWIFT_HOST_VARIANT_SDK} SDK. Will use libc++ from the toolchain.") - get_filename_component(absolute_libcxx_path "${CMAKE_C_COMPILER}/../../include/c++/v1" REALPATH) - if (EXISTS "${absolute_libcxx_path}") - set(sdk_option ${sdk_option} "-Xcc" "-isystem" "-Xcc" "${absolute_libcxx_path}") - else() - message(ERROR "libc++ not found in the toolchain.") - endif() - endif() + file(READ "$ENV{NIX_CC}/nix-support/libcxx-cxxflags" nix_libcxx_cxxflags) + separate_arguments(nix_libcxx_cxxflags) + foreach(nix_libcxx_cxxflag ${nix_libcxx_cxxflags}) + set(sdk_option ${sdk_option} "-Xcc" "${nix_libcxx_cxxflag}") + endforeach() elseif(BOOTSTRAPPING_MODE STREQUAL "CROSSCOMPILE") set(sdk_option "-sdk" "${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_ARCH_${SWIFT_HOST_VARIANT_ARCH}_PATH}") get_filename_component(swift_exec_bin_dir ${ALS_SWIFT_EXEC} DIRECTORY) --- a/cmake/modules/SwiftConfigureSDK.cmake +++ b/cmake/modules/SwiftConfigureSDK.cmake @@ -270,6 +270,18 @@ macro(configure_sdk_darwin # Add this to the list of known SDKs. list(APPEND SWIFT_CONFIGURED_SDKS "${prefix}") + set(cxx_overlay_opt "") + if("${prefix}" STREQUAL "OSX") + file(READ "$ENV{NIX_CC}/nix-support/libcxx-cxxflags" nix_libcxx_cxxflags) + separate_arguments(nix_libcxx_cxxflags) + foreach(nix_libcxx_cxxflag ${nix_libcxx_cxxflags}) + set(cxx_overlay_opt ${cxx_overlay_opt} "-Xcc" "${nix_libcxx_cxxflag}") + endforeach() + endif() + set(SWIFT_SDK_${prefix}_CXX_OVERLAY_SWIFT_COMPILE_FLAGS + ${cxx_overlay_opt} + CACHE STRING "Extra flags for compiling the C++ overlay") + _report_sdk("${prefix}") endmacro() --- a/stdlib/public/Cxx/std/CMakeLists.txt +++ b/stdlib/public/Cxx/std/CMakeLists.txt @@ -145,6 +145,9 @@ add_swift_target_library(swiftstd STATIC NO_LINK_NAME IS_STDLIB SWIFT_COMPILE_FLAGS_LINUX ${SWIFT_SDK_LINUX_CXX_OVERLAY_SWIFT_COMPILE_FLAGS} + SWIFT_COMPILE_FLAGS_OSX + ${SWIFT_SDK_OSX_CXX_OVERLAY_SWIFT_COMPILE_FLAGS} + LINK_FLAGS "${SWIFT_RUNTIME_SWIFT_LINK_FLAGS}" TARGET_SDKS ALL_APPLE_PLATFORMS LINUX INSTALL_IN_COMPONENT compiler
pkgs/development/compilers/swift/compiler/patches/swift-darwin-link-cxxabi.patch 0 → 100644 +14 −0 Original line number Diff line number Diff line This patches the stdlib backdeploy static lib to have its users link c++abi. Without this, later steps that try to link this fail looking for global new/delete operators (__Znwm/__ZdlPv). --- a/stdlib/toolchain/Compatibility56/Overrides.cpp +++ b/stdlib/toolchain/Compatibility56/Overrides.cpp @@ -23,6 +23,7 @@ using namespace swift; __asm__ (".linker_option \"-lc++\""); +__asm__ (".linker_option \"-lc++abi\""); #define OVERRIDE(name, ret, attrs, ccAttrs, namespace, typedArgs, namedArgs) \ Override_ ## name name;
pkgs/development/compilers/swift/compiler/patches/swift-linux-fix-libc-paths.patch 0 → 100644 +48 −0 Original line number Diff line number Diff line This code injects an LLVM modulemap for glibc and libstdc++ by overriding specific VFS paths. In order to do that, it needs to know the actual locations of glibc and libstdc++, but it only searches `-sysroot` and fails. Here we patch it to also consider `-idirafter` and `-isystem` as added by cc-wrapper. --- a/lib/ClangImporter/ClangIncludePaths.cpp +++ b/lib/ClangImporter/ClangIncludePaths.cpp @@ -120,6 +120,7 @@ static clang::driver::Driver createClangDriver(const ASTContext &ctx) { /// \return a path without dots (`../`, './'). static llvm::Optional<Path> findFirstIncludeDir(const llvm::opt::InputArgList &args, + const llvm::opt::ArgList &DriverArgs, const ArrayRef<const char *> expectedFileNames) { // C++ stdlib paths are added as `-internal-isystem`. std::vector<std::string> includeDirs = @@ -128,6 +129,14 @@ findFirstIncludeDir(const llvm::opt::InputArgList &args, llvm::append_range(includeDirs, args.getAllArgValues( clang::driver::options::OPT_internal_externc_isystem)); + // Nix adds the C stdlib include path using `-idirafter`. + llvm::append_range(includeDirs, + DriverArgs.getAllArgValues( + clang::driver::options::OPT_idirafter)); + // Nix adds the C++ stdlib include path using `-isystem`. + llvm::append_range(includeDirs, + DriverArgs.getAllArgValues( + clang::driver::options::OPT_isystem)); for (const auto &includeDir : includeDirs) { Path dir(includeDir); @@ -193,7 +202,7 @@ getGlibcFileMapping(ASTContext &ctx) { // Ideally we would check that all of the headers referenced from the // modulemap are present. Path glibcDir; - if (auto dir = findFirstIncludeDir(parsedIncludeArgs, + if (auto dir = findFirstIncludeDir(parsedIncludeArgs, clangDriverArgs, {"inttypes.h", "unistd.h", "stdint.h"})) { glibcDir = dir.value(); } else { @@ -251,7 +260,7 @@ getLibStdCxxFileMapping(ASTContext &ctx) { auto parsedStdlibArgs = parseClangDriverArgs(clangDriver, stdlibArgStrings); Path cxxStdlibDir; - if (auto dir = findFirstIncludeDir(parsedStdlibArgs, + if (auto dir = findFirstIncludeDir(parsedStdlibArgs, clangDriverArgs, {"cstdlib", "string", "vector"})) { cxxStdlibDir = dir.value(); } else {