Skip to content

Error while making LLVM on ubuntu 19.10 #152

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
sabinaya opened this issue Feb 25, 2020 · 5 comments
Open

Error while making LLVM on ubuntu 19.10 #152

sabinaya opened this issue Feb 25, 2020 · 5 comments

Comments

@sabinaya
Copy link

I'm attempting to build and install LLVM and clang on my ubuntu 19.10 machine. I'm facing the below issue.
image
On my further research, I figured out that it's because my system doesn't have enough RAM for building.
Below is a screenshot of my system's RAM availability.
image

Can anybody help me with the minimum system requirements for the LLVM build and install?
Is there any build system for usage?
Any workarounds for this problem?

@badenh
Copy link
Contributor

badenh commented Feb 25, 2020

Hi

I'm not aware of a hard lower limit for building, but most people say OOB that you need 4Gb to build llvm and clang.

Of course, you could install a precompiled binary for Ubuntu. See https://apt.llvm.org/
The repos to add are:

# i386 not available
deb http://apt.llvm.org/eoan/ llvm-toolchain-eoan main
deb-src http://apt.llvm.org/eoan/ llvm-toolchain-eoan main
# 9
deb http://apt.llvm.org/eoan/ llvm-toolchain-eoan-9 main
deb-src http://apt.llvm.org/eoan/ llvm-toolchain-eoan-9 main
# 10

If you need to build then there's still some other options.

If you can't add more RAM, there's a few things you can do to reduce the resources requirements to build clang and llvm.

  1. You can use gold instead of ld as a linker, by passing the parameter
    -DLLVM_USE_LINKER=gold

  2. You can reduce the set of artefacts created from the build.
    https://llvm.org/docs/CMake.html provides a list of things you can turn off by editing your CMakeCache.txt. For example, using CMAKE_BUILD_TYPE:STRING=Release will avoid producing Debug artefacts and using LLVM_TARGETS_TO_BUILD:STRING=ARM (or whatever suits your requirement) will avoid producing targets for other architectures.

Note: As an alternative to 1), you can also change the linker in the same CMakeCache.txt file eg CLANG_DEFAULT_LINKER:STRING=gold

  1. You can reduce the number of parallel jobs that are kicked off by Make, by specifying the number explicitly make -j1 (or some small number)

The combination of these can mean that a build takes a long time (like 8+ hours) but it succeeds on relatively low RAM systems.

Hope this helps

@zmodem
Copy link
Collaborator

zmodem commented Feb 25, 2020

Can anybody help me with the minimum system requirements for the LLVM build and install?
Is there any build system for usage?
Any workarounds for this problem?

Did you make sure to do a release build and not a debug build? Release builds require much less memory for linking (and also build faster):

cmake -DCMAKE_BUILD_TYPE=Release ...

Bigcheese pushed a commit to Bigcheese/llvm-project that referenced this issue Feb 27, 2020
[Sanitizer][Darwin] Add interceptor for malloc_zone_from_ptr
@sabinaya
Copy link
Author

sabinaya commented Feb 28, 2020

@badenh @zmodem Thanks for the comments.
I'm able to build LLVM with
cmake -DLLVM_TARGETS_TO_BUILD="X86" -DLLVM_TARGET_ARCH=X86 -DCMAKE_BUILD_TYPE="Release" -DLLVM_BUILD_EXAMPLES=1 -DCLANG_BUILD_EXAMPLES=1 -DLLVM_USE_LINKER=gold -G "Unix Makefiles" ../source/llvm-project/llvm
make -j 8
But, I also want to build clang along with it. Passing -DLLVM_ENABLE_PROJECTS=clang again results in either a system freeze or error.

@uenoku
Copy link
Member

uenoku commented Feb 28, 2020

Please try to use Ninja as a build system generator and LLD as a linker.
It is known that these are efficient.

@abrachet
Copy link
Member

+1 to not using -j 8 if the build keeps failing with that. Doing this in just one thread may be excruciating but at least you'll get there. You could also increase the amount of swap space you have and the build won't fail it'll just take super long. People also swear by lld but gold is the next best if you don't have it.

I'm guessing because you are building from source and not just installing you want to hack on clang and not just use it? In which case a Release build might not be practical but you could try -DLLVM_USE_SPLIT_DWARF=ON

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants