Building clang

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Building clang

Hubert Tong via cfe-dev
Hi,
I wanted to play with clang, and was trying to build it according to instructions (https://clang.llvm.org/get_started.html), with GCC 5.5 and GNU ld 2.26.1, running my linux 5.6.7.

However, the build regularly fails, running out of memory (my laptop has 12Gb RAM). I tried with both "Unix Makefiles" and "Ninja 1.7.1". I did specify explicitly "DLLVM_ENABLE_PROJECTS=clang".

Is it expected to consume that much memory during build?

Regards,
Denis

_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Building clang

Hubert Tong via cfe-dev
On 15 Aug 2020, at 12:28, denis gantsev via cfe-dev <[hidden email]> wrote:
>
> I wanted to play with clang, and was trying to build it according to instructions (https://clang.llvm.org/get_started.html), with GCC 5.5 and GNU ld 2.26.1, running my linux 5.6.7.
>
> However, the build regularly fails, running out of memory (my laptop has 12Gb RAM). I tried with both "Unix Makefiles" and "Ninja 1.7.1". I did specify explicitly "DLLVM_ENABLE_PROJECTS=clang".
>
> Is it expected to consume that much memory during build?

What usually helps a lot is to add the following to your initial CMake invocation:

-D LLVM_PARALLEL_LINK_JOBS=1

Since linking tends to use lots of memory, and is rather slow, these jobs usually end up clustered together near the end of build stages, and will then fill up all available memory. Limiting the number of parallel link jobs usually helps with this problem.

-Dimitry


_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev

signature.asc (230 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Building clang

Hubert Tong via cfe-dev
In reply to this post by Hubert Tong via cfe-dev
GNU ld probably is a bit of a bottleneck here - try gold or lld if you can.

But also what Dimitry said - about reducing the number of link steps.
Also depends if you build with debug info - that adds a lot. Using
Split DWARF can help ease that a bit.

On Sat, Aug 15, 2020 at 3:28 AM denis gantsev via cfe-dev
<[hidden email]> wrote:

>
> Hi,
> I wanted to play with clang, and was trying to build it according to instructions (https://clang.llvm.org/get_started.html), with GCC 5.5 and GNU ld 2.26.1, running my linux 5.6.7.
>
> However, the build regularly fails, running out of memory (my laptop has 12Gb RAM). I tried with both "Unix Makefiles" and "Ninja 1.7.1". I did specify explicitly "DLLVM_ENABLE_PROJECTS=clang".
>
> Is it expected to consume that much memory during build?
>
> Regards,
> Denis
> _______________________________________________
> cfe-dev mailing list
> [hidden email]
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Building clang

Hubert Tong via cfe-dev
Hi
Thanks to everyone, indeed, using "-DLLVM_PARALLEL_LINK_JOBS=1 -DLLVM_USE_LINKER=gold -DLLVM_TARGETS_TO_BUILD=X86", actually worked!
P.S I had to turn off swap completely, because I prefer process being killed than my laptop being unusable

Thanks again
Regards
Denis

On Sat, 15 Aug 2020 at 19:22, David Blaikie <[hidden email]> wrote:
GNU ld probably is a bit of a bottleneck here - try gold or lld if you can.

But also what Dimitry said - about reducing the number of link steps.
Also depends if you build with debug info - that adds a lot. Using
Split DWARF can help ease that a bit.

On Sat, Aug 15, 2020 at 3:28 AM denis gantsev via cfe-dev
<[hidden email]> wrote:
>
> Hi,
> I wanted to play with clang, and was trying to build it according to instructions (https://clang.llvm.org/get_started.html), with GCC 5.5 and GNU ld 2.26.1, running my linux 5.6.7.
>
> However, the build regularly fails, running out of memory (my laptop has 12Gb RAM). I tried with both "Unix Makefiles" and "Ninja 1.7.1". I did specify explicitly "DLLVM_ENABLE_PROJECTS=clang".
>
> Is it expected to consume that much memory during build?
>
> Regards,
> Denis
> _______________________________________________
> cfe-dev mailing list
> [hidden email]
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev

_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Building clang

Hubert Tong via cfe-dev
In addition, if you can stomach slower load times but faster builds, you can also use -DBUILD_SHARED_LIBS=ON

denis gantsev via cfe-dev <[hidden email]> ezt írta (időpont: 2020. aug. 15., Szo, 22:23):
Hi
Thanks to everyone, indeed, using "-DLLVM_PARALLEL_LINK_JOBS=1 -DLLVM_USE_LINKER=gold -DLLVM_TARGETS_TO_BUILD=X86", actually worked!
P.S I had to turn off swap completely, because I prefer process being killed than my laptop being unusable

Thanks again
Regards
Denis

On Sat, 15 Aug 2020 at 19:22, David Blaikie <[hidden email]> wrote:
GNU ld probably is a bit of a bottleneck here - try gold or lld if you can.

But also what Dimitry said - about reducing the number of link steps.
Also depends if you build with debug info - that adds a lot. Using
Split DWARF can help ease that a bit.

On Sat, Aug 15, 2020 at 3:28 AM denis gantsev via cfe-dev
<[hidden email]> wrote:
>
> Hi,
> I wanted to play with clang, and was trying to build it according to instructions (https://clang.llvm.org/get_started.html), with GCC 5.5 and GNU ld 2.26.1, running my linux 5.6.7.
>
> However, the build regularly fails, running out of memory (my laptop has 12Gb RAM). I tried with both "Unix Makefiles" and "Ninja 1.7.1". I did specify explicitly "DLLVM_ENABLE_PROJECTS=clang".
>
> Is it expected to consume that much memory during build?
>
> Regards,
> Denis
> _______________________________________________
> cfe-dev mailing list
> [hidden email]
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev

_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev