unfortunately, my build somehow hangs when linking clang binary and my
system is in an unusable state.
My toolchain is clang-3.8, gold-1.11 and LLVMgold.so from binutils
v2.26.1 (both selfmade) and LTO-flag is enabled.
My buildsystem uses cmake-3.6.0 and ninja-1.7.1 (both prebuilt).
I have 52 last steps left in my 3rd build.
My Linux-kernel is v3.13.0-92 from official Ubuntu repositories.
On my Ubuntu/precise AMD64 I have ***4GiB RAM and 256MiB SWAP***.
Is this not enough RAM/SWAP for building/linking?
I built a 1st llvm-toolchain v3.8.1 with GCC v4.9.2 and binutils v2.22.
No speedup settings, no extra-patches applied etc.
[ Selfmade binutils ]
As binutils v2.22 was somehow not able to generate a LLVMgold.so on
Ubuntu/precise AMD64, I have built binutils v2.26.1 manually and use
all its binaries for building/linking (GOLD for linking).
[ 2nd llvm-toolchain LLVMgold.so ]
In a 2nd llvm-toolchain v3.8.1 build a LLVMgold.so was generated.
I placed LLVMgold.so into my selfmade
/opt/binutils-2.26.1/lib/bfd-plugins/ directory.
( I had to create a bfd-plugins subdir manually. )
[ 3rd llvm-toolchain LTO ]
Now, I am able with backported LTO-flag from upstream to build with '-flto'.
This time I just build and installed ld.gold from binutils v2.26.1 and
symlinked system-wide with my ld of my /opt-installation.
The generated LLVMgold.so plugin I copied into /usr/lib/bfd-plugins/
directory (bfd-plugins subdir needed to be created manually).
It is a bit less now: should be closer to 11GB with Full Debug Info.
You may want to try without debug info (or with -gline-tables-only) and it should get under 4GB.
How big is your project?
LTO eats RAM even faster than chrome. For example linking clang with LTO
could take 16GB of ram.
Have you tried using LTO on your project on that machine, or is it your
first time?
Wow hu hu - 16GiB of RAM :-).
It is a bit less now: should be closer to 11GB with Full Debug Info.
You may want to try without debug info (or with -gline-tables-only) and it
should get under 4GB.
Hmm, I have here a built-in small SanDisk-SSD with 16GiB and used that as SWAP.
I was able to build but when starting the install procedure I had 1916
steps again for building/linking.
When I looked while watching TV the max SWAP I have seen was 3,5GiB in
top (linking clang-3.8).
So, build-time increases rapidly here.
What is the benefit of "-gline-tables-only"?
Does it have any correlation/problem with the below cmake-options?
In a next run I wanted to enable Profile-Guided Optimizations (PGO),
optimized-TableGen and split-DWARF.
# CMake LTO (link-time optimizations) settings (WIP)
# NOTE: Not available for LLVM v3.8 (requires a backport of SVN r259766)
LTO_CMAKE_OPTS="-DLLVM_ENABLE_LTO=ON"
"Using Sampling Profilers" [2] is a sub-section of "Profile Guided
Optimization" which says...
#1: Build the code with source line table information. You can use all
the usual build flags that you always build your application with. The
only requirement is that you add -gline-tables-only or -g to the
command line. This is important for the profiler to be able to map
instructions back to source line locations.
$ clang++ -O2 -gline-tables-only code.cc -o code
...currently, I do not have PGO enabled via cmake-options.
How to pass "-gline-tables-only" to the *_FLAGS_* cmake-options?