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.

1 Like

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)

2 Likes

@ivanradanov @tamas

is there any way to compile llvm in flask drive connected to linux system

I am doing that i am still facing compilation issues (following official compilation docs)

I want to contribute to llvm but i have not been able to compile the llvm yet

maybe some of the info given in docs are out dated,

for example : when getting build failure , i followed the section to set the versions of some framework to specific value by running

gcc_version=7.4.0
wget https://ftp.gnu.org/gnu/gcc/gcc-${gcc_version}/gcc-${gcc_version}.tar.bz2
wget https://ftp.gnu.org/gnu/gcc/gcc-${gcc_version}/gcc-${gcc_version}.tar.bz2.sig
wget https://ftp.gnu.org/gnu/gnu-keyring.gpg
signature_invalid=`gpg --verify --no-default-keyring --keyring ./gnu-keyring.gpg gcc-${gcc_version}.tar.bz2.sig`
if [ $signature_invalid ]; then echo "Invalid signature" ; exit 1 ; fi
tar -xvjf gcc-${gcc_version}.tar.bz2
cd gcc-${gcc_version}
./contrib/download_prerequisites
cd ..
mkdir gcc-${gcc_version}-build
cd gcc-${gcc_version}-build
$PWD/../gcc-${gcc_version}/configure --prefix=$HOME/toolchains --enable-languages=c,c++
make -j$(nproc)
make install

but the 1st 3 links are not available in gnu server

https://llvm.org/docs/GettingStarted.html#getting-a-modern-host-c-toolchain

The first step is to get a recent GCC toolchain installed. The most common
distribution on which users have struggled with the version requirements is
Ubuntu Precise, 12.04 LTS.

Ouch, indeed that already seems pretty old and outdated.

I’m not sure why we’re trying to document how to build gcc from source though: this seems like it’ll necessary always be quickly out-of-date.

Ooof that’s though, we should probably just refer to gcc documentation on this.

I tried the documentation you provided ,

But they are out of date

I followed and modified the link with those links which are available in gnu’s server , but not much positive result