I’m trying to build llvm on my computer (Ubuntu 20.04, 8Gb RAM, 90Gb free memory, x86). I followed instruction from https://llvm.org/docs/GettingStarted.html#overview. After I run this command:
cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DLLVM_PARALLEL_LINK_JOBS=1 -DLLVM_TARGETS_TO_BUILD=host …/llvm
I got the error in the picture
I tried rebuilding but still got the same error. I hope someone can recommend a solution for my issue
Depending on you needs, I would add
-DLLVM_ENABLE_PROJECTS="clang" or something similar.
Could you tell something about your compiler gcc or clang and version? The minimal requirements for compilers are on the same page.
I’m trying to build ATMI which requires building llvm. My compiler gcc version is 9.4.0 and my clang version is 10.0.0
I try to add - `DLLVM_ENABLE_PROJECTS=“clang” but it giving me this error when I cmake --build .
“Killed signal” in general means you ran out of memory. You should reduce the parallelism (
-j N with N the number of parallel jobs) or make sure you have enough memory (2GB / process may be a reasonable guess).
I don’t see how this can help with the original issue?
In the original command, I already add variable “-DLLVM_PARALLEL_LINK_JOBS=1” which restrict the parallelism but I think my computer still run out of memory
This flag only restricts the parallelism of the link step, not the overall parallelism (which is controlled in general with
-j N when you build instead of configure)
Sorry, I’m very new to this. Is the correct command to build is “cmake --build -j 1 .”? I’m getting unknown argument error.
I can see you are using ninja for building then why don’t you use ninja to install, it will be faster. Again, in your command you didn’t specify the host architechture. Follow the following steps,
git clone https://github.com/llvm/llvm-project.git
cmake -G Ninja -DLLVM_ENABLE_RTTI=ON -DLLVM_ENABLE_EH=ON -DBUILD_SHARED_LIBS=ON -DCMAKE_BUILD_TYPE=Release -DLLVM_TARGETS_TO_BUILD=X86 -DLLVM_ENABLE_ASSERTIONS=ON -DLLVM_ENABLE_PROJECTS="llvm;clang" ../llvm
sudo ninja install
I have added most common options you might need, you can it according to your need like you need only clang,
-DLLVM_ENABLE_PROJECTS="clang" instead of
If you are installing it in a different host,
-DLLVM_TARGETS_TO_BUILD=host_arch instead of
With other options, you should get some additional functionalities, but it depends on your need. But double check your storage, it will be a problem if you are running out of space.
-j to the ninja invocation, which is the source of their issue here…
I never use
cmake --build, according to the doc: cmake(1) — CMake 3.28.0-rc5 Documentation it should support the
However you can just use
ninja directly in place of
cmake --build, so
ninja -j 1 should work (
-j 2 or
-j 3 may work just fine as well!).
By default, I believe
ninja uses the number of cores you have plus one to compute the number of parallel job,…
I might be wrong but will it be solved after adding
-j N to ninja? Because
ninja -C build -j 20 means, it will run 20 build commands in parallel in the build directory. Ninja by default runs commands in parallel anyway, so typically I don’t see a need to pass
I also didn’t understand how that would solve the memory issue. Because if he only wants to install llvm then 1-3 GB is enough. If he only wants to install clang, then 1.5 GB is enough, I think. It is possible to install clang, clang-tools-extra, lld, libcxx, libcxxabi, compiler-rt and openmp with only 1.2 GB.
In the second screenshot, there were kill signals. It indicates that he ran out of main memory. One solution is to reduce the parallelism and run less compilers in parallel. See the -j discussion.
In the first screenshot, there were real errors. The compiler was complaining.
cmake --build . to
ninja -j1 works well for me.