G++: fatal error: Killed signal terminated program cc1plus

I have a checkout of an llvm-project fork, and I’ve followed these steps:

$ cmake -S llvm -B build-release-ninja -G Ninja -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_ASSERTIONS=On -DLLVM_PARALLEL_LINK_JOBS=10
$ ninja -C build-release-ninja check-llvm

I get these errors:

[452/4256] Building CXX object lib/IR/CMakeFiles/LLVMCore.dir/Verifier.cpp.o
FAILED: lib/IR/CMakeFiles/LLVMCore.dir/Verifier.cpp.o
/usr/bin/g++ -DGTEST_HAS_RTTI=0 -D_DEBUG -D_GLIBCXX_ASSERTIONS -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/mnt/c/Projects/llvm-project-rturrado/build-release-ninja/lib/IR -I/mnt/c/Projects/llvm-project-rturrado/llvm/lib/IR -I/mnt/c/Projects/llvm-project-rturrado/build-release-ninja/include -I/mnt/c/Projects/llvm-project-rturrado/llvm/include -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -fno-lifetime-dse -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wno-uninitialized -Wno-nonnull -Wno-class-memaccess -Wno-redundant-move -Wno-pessimizing-move -Wno-noexcept-type -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment -Wno-misleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -O3 -DNDEBUG -std=c++17  -fno-exceptions -funwind-tables -fno-rtti -UNDEBUG -MD -MT lib/IR/CMakeFiles/LLVMCore.dir/Verifier.cpp.o -MF lib/IR/CMakeFiles/LLVMCore.dir/Verifier.cpp.o.d -o lib/IR/CMakeFiles/LLVMCore.dir/Verifier.cpp.o -c /mnt/c/Projects/llvm-project-rturrado/llvm/lib/IR/Verifier.cpp
g++: fatal error: Killed signal terminated program cc1plus
compilation terminated.
[453/4256] Building CXX object lib/CodeGen/CMakeFiles/LLVMCodeGen.dir/AssignmentTrackingAnalysis.cpp.o
FAILED: lib/CodeGen/CMakeFiles/LLVMCodeGen.dir/AssignmentTrackingAnalysis.cpp.o
/usr/bin/g++ -DGTEST_HAS_RTTI=0 -D_DEBUG -D_GLIBCXX_ASSERTIONS -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/mnt/c/Projects/llvm-project-rturrado/build-release-ninja/lib/CodeGen -I/mnt/c/Projects/llvm-project-rturrado/llvm/lib/CodeGen -I/mnt/c/Projects/llvm-project-rturrado/build-release-ninja/include -I/mnt/c/Projects/llvm-project-rturrado/llvm/include -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -fno-lifetime-dse -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wno-uninitialized -Wno-nonnull -Wno-class-memaccess -Wno-redundant-move -Wno-pessimizing-move -Wno-noexcept-type -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment -Wno-misleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -O3 -DNDEBUG -std=c++17  -fno-exceptions -funwind-tables -fno-rtti -UNDEBUG -MD -MT lib/CodeGen/CMakeFiles/LLVMCodeGen.dir/AssignmentTrackingAnalysis.cpp.o -MF lib/CodeGen/CMakeFiles/LLVMCodeGen.dir/AssignmentTrackingAnalysis.cpp.o.d -o lib/CodeGen/CMakeFiles/LLVMCodeGen.dir/AssignmentTrackingAnalysis.cpp.o -c /mnt/c/Projects/llvm-project-rturrado/llvm/lib/CodeGen/AssignmentTrackingAnalysis.cpp
g++: fatal error: Killed signal terminated program cc1plus
compilation terminated.

I’ve also tried with cc before gcc.

Is this maybe also to do with machine resources?

Thanks!

  • Try more light optimizations. -DCMAKE_BUILD_TYPE=MinSizeRel
  • Reduce parallelism with smaller ninja -jN. N is (NumberOfCores+2) by default.
  • Retry problematic compilations manually :slight_smile: ninja lib/IR/CMakeFiles/LLVMCore.dir/Verifier.cpp.o is available. (Or try ninja multiple times)

How is your buildhost? Cores and RAM amount.

1 Like

You can check sudo dmesg to see if g++ is being killed by the OOM killer. cc and c++ are probably just gcc and g++ since you’re on Linux. You should try compiling with Clang instead, if you want to reduce memory usage.

1 Like

Thanks for the help @chapuni.

12th Gen Intel(R) Core™ i7-1265U 1.80 GHz.
cat /proc/cpuinfo shows 12 processors.
And 16 GB RAM.

1 Like

Thanks for the help @overmighty.

I’m trying with this now:

cmake -S llvm -B build-ninja-minsizerel-clang -G Ninja -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_BUILD_TYPE=MinSizeRel -DLLVM_ENABLE_ASSERTIONS=On -DLLVM_PARALLEL_LINK_JOBS=10

ninja -j10 -C build-ninja-minsizerel-clang check-llvm

The last two commands I posted ran fine in my mini PC:

  • 16 AMD Ryzen 7 5700G processors 3.80 GHz.
  • 32 GB RAM.