I am building LLVM 6 on Ubuntu 16.04. I want lld
too. But no matter what I do, lld
doesn't build/install.
Followed the following instruction from here. Still sifting through first and second :)
Read the documentation.
Read the documentation.
Remember that you were warned twice about reading the documentation.
In particular, the relative paths specified are important.
Checkout LLVM:
cd where-you-want-llvm-to-live svn co http://llvm.org/svn/llvm-project/llvm/trunk llvm
Checkout Clang:
cd where-you-want-llvm-to-live cd llvm/tools svn co http://llvm.org/svn/llvm-project/cfe/trunk clang
Checkout Extra Clang Tools [Optional]:
cd where-you-want-llvm-to-live cd llvm/tools/clang/tools svn co http://llvm.org/svn/llvm-project/clang-tools-extra/trunk extra
Checkout LLD linker [Optional]:
cd where-you-want-llvm-to-live cd llvm/tools svn co http://llvm.org/svn/llvm-project/lld/trunk lld
Didn't download the other optional packages. Since svn
download was not working properly (svn: E000104: Error running context: Connection reset by peer
), I downloaded respective zip
for LLVM, Clang, clang-extra and lld from their github mirrors. Since, I didn't use svn
some renaming of the folders had to be done (for e.g. clang-tools-extra-master
to just extra
).
Then execute the following, after cd
ing into the parent folder of the llvm
source folder,
$ mkdir build; cd build
$ cmake ../llvm
$ make
After waiting for +8 hours, I get all the programs (clang
, lli
, llc
etc.) except lld
. I am expecting it to appear in the folder build/bin
.
I have also tried the option cmake -DLLVM_ENABLE_PROJECTS=llvm/tools/lld ../llvm
. (The form -DLLVM_ENABLE_PROJECTS=lld
doesn't work and I found this place discussing about the same ENABLE issue.)
I have already tried things with some tweaking three times. Since it takes so much time to compile, I decided to take your help.
A separate issue: While building, linking phase takes 12 GB RAM + 8.8 GB swap space on my laptop!! Does LLVM building really require >20 GB of ram ? (I had closed all other foreground apps, especially firefox
)
Please let me know if any more information is needed.
First of all, I think that the
LLVM_ENABLE_PROJECTS
option is useful if you use a "flat" source directory layout. In your case, if you performed the checkouts as you wrote, then it's not of much use.Moreover, what @PaulR wrote about using
ninja
is a very good suggestion. It's faster and very useful when restarting builds and it spawns as many separate compilation jobs concurrently as it can depending on thenproc
without having to specify it explicitly.For faster build and shorter link times, I'd also suggest enabling a shared libs enabled build using the
BUILD_SHARED_LIBS
option.Some general good advice can be found here, which can be summarized as:
clang
to buildclang
(a bootstrapped or second-stage build).gold
linker insteadld
for faster linking times.You can skip point 1 for now (although you could install an initial
llvm/clang
from the system package manager)Lastly, you could limit the compilation for the specific target backend you currently require using the
LLVM_TARGETS_TO_BUILD
option.I've built
trunk
recently (includinglld
) with thiscmake
configuration:You can add the following flags if you need to build
libcxx
:For a bootstrapped build using another
llvm/clang
andlibc++
you can augment the above command as (having thatclang
in your$PATH
environment variable):Moreover, another relevant SO question of interest can be found here.
As you wrote, reading the documentation, experimenting and reading the documentation again is the way to go.