Failed llvm build

I’m trying to build llvm on my computer (Ubuntu 20.04, 8Gb RAM, 90Gb free memory, x86). I followed instruction from After I run this command:


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

Thank you

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

1 Like

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
cd llvm-project
mkdir build
cd build
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 -DLLVM_ENABLE_PROJECTS="llvm;clang"
If you are installing it in a different host,
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.

You missed -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 -j option.
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 -j.
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.

Changing cmake --build . to ninja -j1 works well for me.