Error building LLVM+Clang "Too many open files" on Windows

Hello,
I am trying to build LLVM and Clang according to the instructions found here: Getting Started with the LLVM System — LLVM 17.0.0git documentation.

My goal is to use clang-format source code in a project I am working on so that I can format code snippets in real time.

I have attempted to generate the build with the following commands:
cmake -S llvm -B build -G “Ninja” -DLLVM_ENABLE_PROJECTS=“clang” -DCMAKE_INSTALL_PREFIX=“/install” -DCMAKE_BUILD_TYPE=“Release” -DLLVM_PARALLEL_LINK_JOBS=1

And then finally ran the build with:
ninja -j 1

Unfortunately I get the following error:

[2970/3426] Linking CXX shared library bin\libLTO.dll
FAILED: bin/libLTO.dll lib/libLTO.dll.a
cmd.exe /C “cd . && C:\Strawberry\c\bin\c++.exe -Wa,-mbig-obj -Werror=date-time -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wno-maybe-uninitialized -Wno-class-memaccess -Wno-noexcept-type -Wdelete-non-virtual-dtor -Wno-comment -Wno-misleading-indentation -ffunction-sections -fdata-sections -O2 -DNDEBUG -Wl,–gc-sections “D:/libraries/llvm-project/build/tools/lto/LTO.def” -shared -o bin\libLTO.dll -Wl,–out-implib,lib\libLTO.dll.a -Wl,–major-image-version,0,–minor-image-version,0 @CMakeFiles\LTO.rsp && cd .”
C:/Strawberry/c/bin/…/lib/gcc/x86_64-w64-mingw32/8.3.0/…/…/…/…/x86_64-w64-mingw32/bin/ld.exe: cannot find lib/libLLVMIRReader.a: Too many open files
C:/Strawberry/c/bin/…/lib/gcc/x86_64-w64-mingw32/8.3.0/…/…/…/…/x86_64-w64-mingw32/bin/ld.exe: cannot find lib/libLLVMBitReader.a: Too many open files
C:/Strawberry/c/bin/…/lib/gcc/x86_64-w64-mingw32/8.3.0/…/…/…/…/x86_64-w64-mingw32/bin/ld.exe: cannot find lib/libLLVMAsmParser.a: Too many open files
C:/Strawberry/c/bin/…/lib/gcc/x86_64-w64-mingw32/8.3.0/…/…/…/…/x86_64-w64-mingw32/bin/ld.exe: cannot find lib/libLLVMCore.a: Too many open files
C:/Strawberry/c/bin/…/lib/gcc/x86_64-w64-mingw32/8.3.0/…/…/…/…/x86_64-w64-mingw32/bin/ld.exe: cannot find lib/libLLVMRemarks.a: Too many open files
C:/Strawberry/c/bin/…/lib/gcc/x86_64-w64-mingw32/8.3.0/…/…/…/…/x86_64-w64-mingw32/bin/ld.exe: cannot find lib/libLLVMBitstreamReader.a: Too many open files
C:/Strawberry/c/bin/…/lib/gcc/x86_64-w64-mingw32/8.3.0/…/…/…/…/x86_64-w64-mingw32/bin/ld.exe: cannot find lib/libLLVMTextAPI.a: Too many open files
C:/Strawberry/c/bin/…/lib/gcc/x86_64-w64-mingw32/8.3.0/…/…/…/…/x86_64-w64-mingw32/bin/ld.exe: cannot find lib/libLLVMBinaryFormat.a: Too many open files
C:/Strawberry/c/bin/…/lib/gcc/x86_64-w64-mingw32/8.3.0/…/…/…/…/x86_64-w64-mingw32/bin/ld.exe: cannot find lib/libLLVMTargetParser.a: Too many open files
C:/Strawberry/c/bin/…/lib/gcc/x86_64-w64-mingw32/8.3.0/…/…/…/…/x86_64-w64-mingw32/bin/ld.exe: cannot find lib/libLLVMSupport.a: Too many open files
C:/Strawberry/c/bin/…/lib/gcc/x86_64-w64-mingw32/8.3.0/…/…/…/…/x86_64-w64-mingw32/bin/ld.exe: cannot find lib/libLLVMDemangle.a: Too many open files
C:/Strawberry/c/bin/…/lib/gcc/x86_64-w64-mingw32/8.3.0/…/…/…/…/x86_64-w64-mingw32/bin/ld.exe: cannot find -lpsapi
C:/Strawberry/c/bin/…/lib/gcc/x86_64-w64-mingw32/8.3.0/…/…/…/…/x86_64-w64-mingw32/bin/ld.exe: cannot find -lshell32C:/Strawberry/c/bin/…/lib/gcc/x86_64-w64-mingw32/8.3.0/…/…/…/…/x86_64-w64-mingw32/bin/ld.exe: cannot find -lole32
C:/Strawberry/c/bin/…/lib/gcc/x86_64-w64-mingw32/8.3.0/…/…/…/…/x86_64-w64-mingw32/bin/ld.exe: cannot find -luuid
C:/Strawberry/c/bin/…/lib/gcc/x86_64-w64-mingw32/8.3.0/…/…/…/…/x86_64-w64-mingw32/bin/ld.exe: cannot find -ladvapi32
C:/Strawberry/c/bin/…/lib/gcc/x86_64-w64-mingw32/8.3.0/…/…/…/…/x86_64-w64-mingw32/bin/ld.exe: cannot find C:/Strawberry/c/lib/libz.a: Too many open files
C:/Strawberry/c/bin/…/lib/gcc/x86_64-w64-mingw32/8.3.0/…/…/…/…/x86_64-w64-mingw32/bin/ld.exe: cannot find -lkernel32
C:/Strawberry/c/bin/…/lib/gcc/x86_64-w64-mingw32/8.3.0/…/…/…/…/x86_64-w64-mingw32/bin/ld.exe: cannot find -luser32
C:/Strawberry/c/bin/…/lib/gcc/x86_64-w64-mingw32/8.3.0/…/…/…/…/x86_64-w64-mingw32/bin/ld.exe: cannot find -lgdi32
C:/Strawberry/c/bin/…/lib/gcc/x86_64-w64-mingw32/8.3.0/…/…/…/…/x86_64-w64-mingw32/bin/ld.exe: cannot find -lwinspool
C:/Strawberry/c/bin/…/lib/gcc/x86_64-w64-mingw32/8.3.0/…/…/…/…/x86_64-w64-mingw32/bin/ld.exe: cannot find -lshell32C:/Strawberry/c/bin/…/lib/gcc/x86_64-w64-mingw32/8.3.0/…/…/…/…/x86_64-w64-mingw32/bin/ld.exe: cannot find -lole32
C:/Strawberry/c/bin/…/lib/gcc/x86_64-w64-mingw32/8.3.0/…/…/…/…/x86_64-w64-mingw32/bin/ld.exe: cannot find -loleaut32
C:/Strawberry/c/bin/…/lib/gcc/x86_64-w64-mingw32/8.3.0/…/…/…/…/x86_64-w64-mingw32/bin/ld.exe: cannot find -luuid
C:/Strawberry/c/bin/…/lib/gcc/x86_64-w64-mingw32/8.3.0/…/…/…/…/x86_64-w64-mingw32/bin/ld.exe: cannot find -lcomdlg32
C:/Strawberry/c/bin/…/lib/gcc/x86_64-w64-mingw32/8.3.0/…/…/…/…/x86_64-w64-mingw32/bin/ld.exe: cannot find -ladvapi32
C:/Strawberry/c/bin/…/lib/gcc/x86_64-w64-mingw32/8.3.0/…/…/…/…/x86_64-w64-mingw32/bin/ld.exe: cannot find -lstdc++
C:/Strawberry/c/bin/…/lib/gcc/x86_64-w64-mingw32/8.3.0/…/…/…/…/x86_64-w64-mingw32/bin/ld.exe: cannot find -lmingw32C:/Strawberry/c/bin/…/lib/gcc/x86_64-w64-mingw32/8.3.0/…/…/…/…/x86_64-w64-mingw32/bin/ld.exe: cannot find -lgcc_s
C:/Strawberry/c/bin/…/lib/gcc/x86_64-w64-mingw32/8.3.0/…/…/…/…/x86_64-w64-mingw32/bin/ld.exe: cannot find -lgcc
C:/Strawberry/c/bin/…/lib/gcc/x86_64-w64-mingw32/8.3.0/…/…/…/…/x86_64-w64-mingw32/bin/ld.exe: cannot find -lmoldname
C:/Strawberry/c/bin/…/lib/gcc/x86_64-w64-mingw32/8.3.0/…/…/…/…/x86_64-w64-mingw32/bin/ld.exe: cannot find -lmingwexC:/Strawberry/c/bin/…/lib/gcc/x86_64-w64-mingw32/8.3.0/…/…/…/…/x86_64-w64-mingw32/bin/ld.exe: cannot find -lmsvcrt
C:/Strawberry/c/bin/…/lib/gcc/x86_64-w64-mingw32/8.3.0/…/…/…/…/x86_64-w64-mingw32/bin/ld.exe: cannot find -lpthreadC:/Strawberry/c/bin/…/lib/gcc/x86_64-w64-mingw32/8.3.0/…/…/…/…/x86_64-w64-mingw32/bin/ld.exe: cannot find -ladvapi32
C:/Strawberry/c/bin/…/lib/gcc/x86_64-w64-mingw32/8.3.0/…/…/…/…/x86_64-w64-mingw32/bin/ld.exe: cannot find -lshell32C:/Strawberry/c/bin/…/lib/gcc/x86_64-w64-mingw32/8.3.0/…/…/…/…/x86_64-w64-mingw32/bin/ld.exe: cannot find -luser32
C:/Strawberry/c/bin/…/lib/gcc/x86_64-w64-mingw32/8.3.0/…/…/…/…/x86_64-w64-mingw32/bin/ld.exe: cannot find -lkernel32
C:/Strawberry/c/bin/…/lib/gcc/x86_64-w64-mingw32/8.3.0/…/…/…/…/x86_64-w64-mingw32/bin/ld.exe: cannot find -liconv
C:/Strawberry/c/bin/…/lib/gcc/x86_64-w64-mingw32/8.3.0/…/…/…/…/x86_64-w64-mingw32/bin/ld.exe: cannot find -lmingw32C:/Strawberry/c/bin/…/lib/gcc/x86_64-w64-mingw32/8.3.0/…/…/…/…/x86_64-w64-mingw32/bin/ld.exe: cannot find -lgcc_s
C:/Strawberry/c/bin/…/lib/gcc/x86_64-w64-mingw32/8.3.0/…/…/…/…/x86_64-w64-mingw32/bin/ld.exe: cannot find -lgcc
C:/Strawberry/c/bin/…/lib/gcc/x86_64-w64-mingw32/8.3.0/…/…/…/…/x86_64-w64-mingw32/bin/ld.exe: cannot find -lmoldname
C:/Strawberry/c/bin/…/lib/gcc/x86_64-w64-mingw32/8.3.0/…/…/…/…/x86_64-w64-mingw32/bin/ld.exe: cannot find -lmingwexC:/Strawberry/c/bin/…/lib/gcc/x86_64-w64-mingw32/8.3.0/…/…/…/…/x86_64-w64-mingw32/bin/ld.exe: cannot find -lmsvcrt
C:/Strawberry/c/bin/…/lib/gcc/x86_64-w64-mingw32/8.3.0/…/…/…/…/x86_64-w64-mingw32/bin/ld.exe: cannot find C:/Strawberry/c/bin/…/lib/gcc/x86_64-w64-mingw32/8.3.0/crtend.o: Too many open files
collect2.exe: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.

I am running Windows 11 on a Microsoft Surface Go 3.

Any help would be greatly appreciated, thank you for your time.

I remember running into an open-file limit on Linux, and using the ulimit utility to increase it. I don’t know how you would get the same effect with mingw but it’s a direction to research.

Are you using the 64 bit version of whatever linker you are using? From the pathing x86_64-w64-mingw32 it might be that you are using a 32 bit version of the linker?

Eye balling the 64 bit mingw32 CRT’s stdio header, there seems to be a limit of 512 files. Perhaps it might be worthwhile to use MSVC to build?

Unrelated, but I’d be surprised if you don’t run into memory issues later on in your build, once you’ve resolved these issues: I regularly see links in my LLVM builds that can take over 8GB of RAM (which is the standard spec of that device as far as I can tell).