Out of memory error when building llvm on windows

I’m trying to compile clang on windows using ninja alongside visual studio following this tutorial Clang - Getting Started. I am getting this error with following stack trace. I am not even sure if this even a bug or something on my computer can anyone elaborate?

[3241/3754] Building RISCVGenDAGISel.inc…
FAILED: lib/Target/RISCV/RISCVGenDAGISel.inc D:/llvm-project/build_ninja_vs/lib/Target/RISCV/RISCVGenDAGISel.inc
cmd.exe /C “cd /D D:\llvm-project\build_ninja_vs && D:\llvm-project\build_ninja_vs\bin\llvm-tblgen.exe -gen-dag-isel -I D:/llvm-project/llvm/lib/Target/RISCV -ID:/llvm-project/build_ninja_vs/include -ID:/llvm-project/llvm/include -I D:/llvm-project/llvm/lib/Target --long-string-literals=0 D:/llvm-project/llvm/lib/Target/RISCV/RISCV.td --write-if-changed -o lib/Target/RISCV/RISCVGenDAGISel.inc -d lib/Target/RISCV/RISCVGenDAGISel.inc.d”
LLVM ERROR: out of memory
Allocation failed
PLEASE submit a bug report to Issues · llvm/llvm-project · GitHub and include the crash backtrace.
Stack dump:
0. Program arguments: D:\llvm-project\build_ninja_vs\bin\llvm-tblgen.exe -gen-dag-isel -I D:/llvm-project/llvm/lib/Target/RISCV -ID:/llvm-project/build_ninja_vs/include -ID:/llvm-project/llvm/include -I D:/llvm-project/llvm/lib/Target --long-string-literals=0 D:/llvm-project/llvm/lib/Target/RISCV/RISCV.td --write-if-changed -o lib/Target/RISCV/RISCVGenDAGISel.inc -d lib/Target/RISCV/RISCVGenDAGISel.inc.d
Exception Code: 0x80000003
0x00785159, D:\llvm-project\build_ninja_vs\bin\llvm-tblgen.exe(0x0000000000110000) + 0x675159 byte(s), HandleAbort() + 0x9 byte(s), D:\llvm-project\llvm\lib\Support\Windows\Signals.inc, line 415 + 0x0 byte(s)
0x783AD56B, C:\Windows\SYSTEM32\ucrtbased.dll(0x0000000078310000) + 0x9D56B byte(s), raise() + 0x36B byte(s)
0x783AEA72, C:\Windows\SYSTEM32\ucrtbased.dll(0x0000000078310000) + 0x9EA72 byte(s), abort() + 0x32 byte(s)
0x006EEDBF, D:\llvm-project\build_ninja_vs\bin\llvm-tblgen.exe(0x0000000000110000) + 0x5DEDBF byte(s), llvm::report_bad_alloc_error() + 0x16F byte(s), D:\llvm-project\llvm\lib\Support\ErrorHandling.cpp, line 175 + 0x8 byte(s)
0x006EF6BF, D:\llvm-project\build_ninja_vs\bin\llvm-tblgen.exe(0x0000000000110000) + 0x5DF6BF byte(s), out_of_memory_new_handler() + 0xF byte(s), D:\llvm-project\llvm\lib\Support\ErrorHandling.cpp, line 189 + 0x0 byte(s)
0x7C1E6878, C:\Windows\SYSTEM32\MSVCP140D.dll(0x000000007C1C0000) + 0x26878 byte(s), ?_MP_Rem@std@@YAXQA_K_K@Z() + 0x698 byte(s)
0x7839CA46, C:\Windows\SYSTEM32\ucrtbased.dll(0x0000000078310000) + 0x8CA46 byte(s), _callnewh() + 0x36 byte(s)
0x00912627, D:\llvm-project\build_ninja_vs\bin\llvm-tblgen.exe(0x0000000000110000) + 0x802627 byte(s), operator new() + 0x27 byte(s), D:\a_work\1\s\src\vctools\crt\vcstartup\src\heap\new_scalar.cpp, line 40 + 0x9 byte(s)
0x001E10CC, D:\llvm-project\build_ninja_vs\bin\llvm-tblgen.exe(0x0000000000110000) + 0xD10CC byte(s), std::_Default_allocate_traits::_Allocate() + 0xC byte(s), C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\xmemory, line 79 + 0x9 byte(s)
0x001B325B, D:\llvm-project\build_ninja_vs\bin\llvm-tblgen.exe(0x0000000000110000) + 0xA325B byte(s), std::_Allocate_manually_vector_alignedstd::_Default_allocate_traits() + 0x3B byte(s), C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\xmemory, line 134 + 0x9 byte(s)
0x001B31E5, D:\llvm-project\build_ninja_vs\bin\llvm-tblgen.exe(0x0000000000110000) + 0xA31E5 byte(s), std::_Allocate<8,std::_Default_allocate_traits,0>() + 0x15 byte(s), C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\xmemory, line 229 + 0x9 byte(s)
0x001E9E10, D:\llvm-project\build_ninja_vs\bin\llvm-tblgen.exe(0x0000000000110000) + 0xD9E10 byte(s), std::allocator::allocate() + 0x20 byte(s), C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\xmemory, line 801 + 0x12 byte(s)
0x001C22CA, D:\llvm-project\build_ninja_vs\bin\llvm-tblgen.exe(0x0000000000110000) + 0xB22CA byte(s), std::basic_string<char,std::char_traits,std::allocator >::_Reallocate_grow_by<<lambda_ab246b20b9526e2ef7792587e4298a77>,char const *,unsigned int>() + 0x7A byte(s), C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\xstring, line 4517 + 0xF byte(s)
0x001EA52C, D:\llvm-project\build_ninja_vs\bin\llvm-tblgen.exe(0x0000000000110000) + 0xDA52C byte(s), std::basic_string<char,std::char_traits,std::allocator >::append() + 0x9C byte(s), C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\xstring, line 3138 + 0x0 byte(s)
0x006FAD50, D:\llvm-project\build_ninja_vs\bin\llvm-tblgen.exe(0x0000000000110000) + 0x5EAD50 byte(s), llvm::raw_string_ostream::write_impl() + 0x30 byte(s), D:\llvm-project\llvm\lib\Support\raw_ostream.cpp, line 939 + 0x0 byte(s)
0x006F9D67, D:\llvm-project\build_ninja_vs\bin\llvm-tblgen.exe(0x0000000000110000) + 0x5E9D67 byte(s), llvm::raw_ostream::flush_tied_then_write() + 0x47 byte(s), D:\llvm-project\llvm\lib\Support\raw_ostream.cpp, line 303 + 0x1B byte(s)
0x006F8D62, D:\llvm-project\build_ninja_vs\bin\llvm-tblgen.exe(0x0000000000110000) + 0x5E8D62 byte(s), llvm::raw_ostream::write() + 0x52 byte(s), D:\llvm-project\llvm\lib\Support\raw_ostream.cpp, line 244 + 0x0 byte(s)
0x006FB2B7, D:\llvm-project\build_ninja_vs\bin\llvm-tblgen.exe(0x0000000000110000) + 0x5EB2B7 byte(s), write_padding<32>() + 0x37 byte(s), D:\llvm-project\llvm\lib\Support\raw_ostream.cpp, line 483 + 0x11 byte(s)
0x006F976B, D:\llvm-project\build_ninja_vs\bin\llvm-tblgen.exe(0x0000000000110000) + 0x5E976B byte(s), llvm::raw_ostream::indent() + 0x1B byte(s), D:\llvm-project\llvm\lib\Support\raw_ostream.cpp, line 495 + 0xD byte(s)
0x003E88CB, D:\llvm-project\build_ninja_vs\bin\llvm-tblgen.exe(0x0000000000110000) + 0x2D88CB byte(s), anonymous namespace'::MatcherTableEmitter::EmitMatcher() + 0x223B byte(s), D:\llvm-project\llvm\utils\TableGen\DAGISelMatcherEmitter.cpp, line 786 + 0x0 byte(s) 0x003E53B9, D:\llvm-project\build_ninja_vs\bin\llvm-tblgen.exe(0x0000000000110000) + 0x2D53B9 byte(s), anonymous namespace’::MatcherTableEmitter::EmitMatcherList() + 0x99 byte(s), D:\llvm-project\llvm\utils\TableGen\DAGISelMatcherEmitter.cpp, line 873 + 0x18 byte(s)
0x003E68FB, D:\llvm-project\build_ninja_vs\bin\llvm-tblgen.exe(0x0000000000110000) + 0x2D68FB byte(s), anonymous namespace'::MatcherTableEmitter::EmitMatcher() + 0x26B byte(s), D:\llvm-project\llvm\utils\TableGen\DAGISelMatcherEmitter.cpp, line 401 + 0x27 byte(s) 0x003E53B9, D:\llvm-project\build_ninja_vs\bin\llvm-tblgen.exe(0x0000000000110000) + 0x2D53B9 byte(s), anonymous namespace’::MatcherTableEmitter::EmitMatcherList() + 0x99 byte(s), D:\llvm-project\llvm\utils\TableGen\DAGISelMatcherEmitter.cpp, line 873 + 0x18 byte(s)
0x003E68FB, D:\llvm-project\build_ninja_vs\bin\llvm-tblgen.exe(0x0000000000110000) + 0x2D68FB byte(s), anonymous namespace'::MatcherTableEmitter::EmitMatcher() + 0x26B byte(s), D:\llvm-project\llvm\utils\TableGen\DAGISelMatcherEmitter.cpp, line 401 + 0x27 byte(s) 0x003E53B9, D:\llvm-project\build_ninja_vs\bin\llvm-tblgen.exe(0x0000000000110000) + 0x2D53B9 byte(s), anonymous namespace’::MatcherTableEmitter::EmitMatcherList() + 0x99 byte(s), D:\llvm-project\llvm\utils\TableGen\DAGISelMatcherEmitter.cpp, line 873 + 0x18 byte(s)
0x003E68FB, D:\llvm-project\build_ninja_vs\bin\llvm-tblgen.exe(0x0000000000110000) + 0x2D68FB byte(s), anonymous namespace'::MatcherTableEmitter::EmitMatcher() + 0x26B byte(s), D:\llvm-project\llvm\utils\TableGen\DAGISelMatcherEmitter.cpp, line 401 + 0x27 byte(s) 0x003E53B9, D:\llvm-project\build_ninja_vs\bin\llvm-tblgen.exe(0x0000000000110000) + 0x2D53B9 byte(s), anonymous namespace’::MatcherTableEmitter::EmitMatcherList() + 0x99 byte(s), D:\llvm-project\llvm\utils\TableGen\DAGISelMatcherEmitter.cpp, line 873 + 0x18 byte(s)
0x003E740A, D:\llvm-project\build_ninja_vs\bin\llvm-tblgen.exe(0x0000000000110000) + 0x2D740A byte(s), anonymous namespace'::MatcherTableEmitter::EmitMatcher() + 0xD7A byte(s), D:\llvm-project\llvm\utils\TableGen\DAGISelMatcherEmitter.cpp, line 554 + 0x1B byte(s) 0x003E53B9, D:\llvm-project\build_ninja_vs\bin\llvm-tblgen.exe(0x0000000000110000) + 0x2D53B9 byte(s), anonymous namespace’::MatcherTableEmitter::EmitMatcherList() + 0x99 byte(s), D:\llvm-project\llvm\utils\TableGen\DAGISelMatcherEmitter.cpp, line 873 + 0x18 byte(s)
0x003E4E97, D:\llvm-project\build_ninja_vs\bin\llvm-tblgen.exe(0x0000000000110000) + 0x2D4E97 byte(s), llvm::EmitMatcherTable() + 0x237 byte(s), D:\llvm-project\llvm\utils\TableGen\DAGISelMatcherEmitter.cpp, line 1141 + 0x17 byte(s)
0x003DCAF4, D:\llvm-project\build_ninja_vs\bin\llvm-tblgen.exe(0x0000000000110000) + 0x2CCAF4 byte(s), anonymous namespace'::DAGISelEmitter::run() + 0x4E4 byte(s), D:\llvm-project\llvm\utils\TableGen\DAGISelEmitter.cpp, line 185 + 0x1C byte(s) 0x003DD0F1, D:\llvm-project\build_ninja_vs\bin\llvm-tblgen.exe(0x0000000000110000) + 0x2CD0F1 byte(s), llvm::EmitDAGISel() + 0x61 byte(s), D:\llvm-project\llvm\utils\TableGen\DAGISelEmitter.cpp, line 192 + 0x24 byte(s) 0x006AF20D, D:\llvm-project\build_ninja_vs\bin\llvm-tblgen.exe(0x0000000000110000) + 0x59F20D byte(s), anonymous namespace’::LLVMTableGenMain() + 0x17D byte(s), D:\llvm-project\llvm\utils\TableGen\TableGen.cpp, line 197 + 0xD byte(s)
0x00894833, D:\llvm-project\build_ninja_vs\bin\llvm-tblgen.exe(0x0000000000110000) + 0x784833 byte(s), llvm::TableGenMain() + 0x343 byte(s), D:\llvm-project\llvm\lib\TableGen\Main.cpp, line 122 + 0x1C byte(s)
0x006AF7DC, D:\llvm-project\build_ninja_vs\bin\llvm-tblgen.exe(0x0000000000110000) + 0x59F7DC byte(s), main() + 0x7C byte(s), D:\llvm-project\llvm\utils\TableGen\TableGen.cpp, line 296 + 0x19 byte(s)
0x00913D63, D:\llvm-project\build_ninja_vs\bin\llvm-tblgen.exe(0x0000000000110000) + 0x803D63 byte(s), invoke_main() + 0x33 byte(s), D:\a_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl, line 78 + 0x2D byte(s)
0x00913BE7, D:\llvm-project\build_ninja_vs\bin\llvm-tblgen.exe(0x0000000000110000) + 0x803BE7 byte(s), __scrt_common_main_seh() + 0x157 byte(s), D:\a_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl, line 288 + 0x5 byte(s)
0x00913A7D, D:\llvm-project\build_ninja_vs\bin\llvm-tblgen.exe(0x0000000000110000) + 0x803A7D byte(s), __scrt_common_main() + 0xD byte(s), D:\a_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl, line 331 + 0x0 byte(s)
0x00913DE8, D:\llvm-project\build_ninja_vs\bin\llvm-tblgen.exe(0x0000000000110000) + 0x803DE8 byte(s), mainCRTStartup() + 0x8 byte(s), D:\a_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_main.cpp, line 17 + 0x0 byte(s)
0x773A00F9, C:\Windows\System32\KERNEL32.DLL(0x0000000077380000) + 0x200F9 byte(s), BaseThreadInitThunk() + 0x19 byte(s)
0x774E7BBE, C:\Windows\SYSTEM32\ntdll.dll(0x0000000077480000) + 0x67BBE byte(s), RtlGetAppContainerNamedObjectPath() + 0x11E byte(s)
0x774E7B8E, C:\Windows\SYSTEM32\ntdll.dll(0x0000000077480000) + 0x67B8E byte(s), RtlGetAppContainerNamedObjectPath() + 0xEE byte(s)
[3254/3754] Building CXX object tools\clang\lib\CodeGen\CMakeFiles\obj.clangCodeGen.dir\TargetInfo.cpp.obj
ninja: build stopped: subcommand failed.

Are you seeing this even if you drastically limit the number of jobs (ninja -j1) ?

The cases where I’ve seen oom issues are usually when there are more linker jobs running, its not usually tblgen jobs that have problems.

1 Like

I’m seeing the same error when i compile using ninja -j1

How much main memory do you have?

My system has 16 gigs of ram