Re: [llvm-dev] Improving llvm-projects build

39 views
Skip to first unread message

Manas via llvm-dev

unread,
Feb 14, 2021, 8:15:49 AM2/14/21
to llvm...@lists.llvm.org
Hi everyone,

I fairly regularly build LLVM (a forked up-to-date repo containing some
custom LLVM passes). But when the build is large, it takes up almost all of
my remaining RAM (~4 to 5 gigs). I usually run those builds at nights for it
to complete.

Though I would like the build to not clog up entire RAM and just use some
portion of it, so that I can also work alongside (and my system won't
freeze). My current CMAKE command is:

```
cmake -G Ninja -DLLVM_TARGETS_TO_BUILD="X86;AMDGPU" \
-DLLVM_ENABLE_ASSERTIONS=ON \
-DCMAKE_C_COMPILER=/usr/bin/clang \
-DCMAKE_CXX_COMPILER=/usr/bin/clang++ \
-DCMAKE_BUILD_TYPE=Debug \
-DLLVM_CCACHE_BUILD=ON \
-DLLVM_USE_LINKER=gold \
-DCMAKE_EXPORT_COMPILE_COMMANDS=1 \
../llvm/
```

I found a SO answer claiming `gold` can improve upon memory usage, but I
found almost no improvement.

Are there ways to restrict memory limit during build? Also, I should
mention that I would like to build a Debug version as it is helpful.

Thank you
--
Manas
CSAM Undergraduate | 2022
IIIT-Delhi, India
_______________________________________________
LLVM Developers mailing list
llvm...@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev

Florian Hahn via llvm-dev

unread,
Feb 14, 2021, 8:22:28 AM2/14/21
to Manas, llvm...@lists.llvm.org
Hi,


On Feb 14, 2021, at 13:15, Manas via llvm-dev <llvm...@lists.llvm.org> wrote:

Hi everyone,

I fairly regularly build LLVM (a forked up-to-date repo containing some
custom LLVM passes). But when the build is large, it takes up almost all of
my remaining RAM (~4 to 5 gigs). I usually run those builds at nights for it
to complete.

Though I would like the build to not clog up entire RAM and just use some
portion of it, so that I can also work alongside (and my system won't
freeze). My current CMAKE command is:

```
cmake -G Ninja -DLLVM_TARGETS_TO_BUILD="X86;AMDGPU" \
   -DLLVM_ENABLE_ASSERTIONS=ON \
   -DCMAKE_C_COMPILER=/usr/bin/clang \
   -DCMAKE_CXX_COMPILER=/usr/bin/clang++ \
   -DCMAKE_BUILD_TYPE=Debug \
   -DLLVM_CCACHE_BUILD=ON \
   -DLLVM_USE_LINKER=gold \
   -DCMAKE_EXPORT_COMPILE_COMMANDS=1 \
   ../llvm/
```

Building llvm with debug info requires a large amount of RAM. See https://llvm.org/docs/GettingStarted.html#common-problems for some pointers.

Cheers,
Florian

Dimitry Andric via llvm-dev

unread,
Feb 14, 2021, 8:35:19 AM2/14/21
to Manas, llvm...@lists.llvm.org
On 14 Feb 2021, at 14:15, Manas via llvm-dev <llvm...@lists.llvm.org> wrote:
>
> I fairly regularly build LLVM (a forked up-to-date repo containing some
> custom LLVM passes). But when the build is large, it takes up almost all of
> my remaining RAM (~4 to 5 gigs). I usually run those builds at nights for it
> to complete.
>
> Though I would like the build to not clog up entire RAM and just use some
> portion of it, so that I can also work alongside (and my system won't
> freeze). My current CMAKE command is:
>
> ```
> cmake -G Ninja -DLLVM_TARGETS_TO_BUILD="X86;AMDGPU" \
> -DLLVM_ENABLE_ASSERTIONS=ON \
> -DCMAKE_C_COMPILER=/usr/bin/clang \
> -DCMAKE_CXX_COMPILER=/usr/bin/clang++ \
> -DCMAKE_BUILD_TYPE=Debug \
> -DLLVM_CCACHE_BUILD=ON \
> -DLLVM_USE_LINKER=gold \
> -DCMAKE_EXPORT_COMPILE_COMMANDS=1 \
> ../llvm/
> ```
>
> I found a SO answer claiming `gold` can improve upon memory usage, but I
> found almost no improvement.
>
> Are there ways to restrict memory limit during build? Also, I should
> mention that I would like to build a Debug version as it is helpful.

Try adding:

-D LLVM_PARALLEL_LINK_JOBS=1

to your CMake invocation. This lowers the number of parallel link jobs, which (at last in my experience) tend to be the largest RAM consumers during a build.

-Dimitry

signature.asc

Manas via llvm-dev

unread,
Feb 14, 2021, 10:10:34 AM2/14/21
to Florian Hahn, llvm...@lists.llvm.org
On Sun, Feb 14, 2021 at 01:22:14PM +0000, Florian Hahn wrote:
> Hi,
>
> Building llvm with debug info requires a large amount of RAM. See https://llvm.org/docs/GettingStarted.html#common-problems <https://llvm.org/docs/GettingStarted.html#common-problems> for some pointers.
>
Thanks for the link, Florian.

Manas via llvm-dev

unread,
Feb 14, 2021, 10:12:39 AM2/14/21
to Dimitry Andric, llvm...@lists.llvm.org
On Sun, Feb 14, 2021 at 02:34:57PM +0100, Dimitry Andric wrote:
> Try adding:
>
> -D LLVM_PARALLEL_LINK_JOBS=1
>
> to your CMake invocation. This lowers the number of parallel link jobs, which (at last in my experience) tend to be the largest RAM consumers during a build.
>
Thanks a lot, Dimitry. I added this option and it was extremely helpful.
It limited usage of RAM to ~1.5 gigs.
Reply all
Reply to author
Forward
0 new messages