Unable to configure and build LLVM

i am inside llvm-project directory

inside that i am running

cmake -S llvm -B build -G Ninja -DCMAKE_BUILD_TYPE=Debug

and getting some errors:

CMake Error: CMake was unable to find a build program corresponding to “Ninja”. CMAKE_MAKE_PROGRAM is not set. You probably need to select a different build tool.
CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage
CMake Error: CMAKE_ASM_COMPILER not set, after EnableLanguage
– Configuring incomplete, errors occurred!
See also “/home/chitransh/gsoc/llvm-project/build/CMakeFiles/CMakeOutput.log”.

CMake Error: CMake was unable to find a build program corresponding to “Ninja”. 

This means that ninja is not (properly) installed on your system. The way to install it depends on your system, so if you can share some information about that, I can give you some hints.

The rest of the errors are red herrings, I’m pretty sure. They will go away once the first one is fixed.

Actually i am using WSL for contributing to open source project

If you are running Ubuntu in WSL (which is the default), you need to run sudo apt-get install ninja-build. Also, remove CMakeCache.txt before attempting the configuration after installing ninja.

THANKS TAMAS , NINJA INSTALLED SUCCESSFULLY AND LLVM WAS ALSO CONFIGURED

BUT THERE ARE NEW ERRORS MENTIONED BELOW, WHEN BUILDING LLVM

cmake --build build
[4/3238] Building CXX object utils/TableGen/CMakeFiles/llvm-tblgen.dir/AsmMatcherEmitter.cpp.o
FAILED: utils/TableGen/CMakeFiles/llvm-tblgen.dir/AsmMatcherEmitter.cpp.o
/usr/bin/c++ -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/home/chitransh/gsoc/llvm-project/build/utils/TableGen -I/home/chitransh/gsoc/llvm-project/llvm/utils/TableGen -I/home/chitransh/gsoc/llvm-project/build/include -I/home/chitransh/gsoc/llvm-project/llvm/include -I/home/chitransh/gsoc/llvm-project/llvm/utils/TableGen/GlobalISel/… -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-maybe-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 -g -fno-exceptions -funwind-tables -fno-rtti -std=c++17 -MD -MT utils/TableGen/CMakeFiles/llvm-tblgen.dir/AsmMatcherEmitter.cpp.o -MF utils/TableGen/CMakeFiles/llvm-tblgen.dir/AsmMatcherEmitter.cpp.o.d -o utils/TableGen/CMakeFiles/llvm-tblgen.dir/AsmMatcherEmitter.cpp.o -c /home/chitransh/gsoc/llvm-project/llvm/utils/TableGen/AsmMatcherEmitter.cpp
c++: fatal error: Killed signal terminated program cc1plus
compilation terminated.
[17/3238] Building CXX object utils/TableGen/CMakeFiles/llvm-tblgen.dir/GlobalISelCombinerEmitter.cpp.o
ninja: build stopped: subcommand failed.

This could be your system going out of memory - debug builds need a lot of memory. What are your machine specs?

You could try ninja -j 4 in the build directory, the 4 specifies the number of parallel jobs, lower that more if needed.

(also see the parallel job variables in Building LLVM with CMake — LLVM 18.0.0git documentation)

1 Like