First things first; the versions of various tools that I am using:
OS: Ubuntu 20.04.1 LTS
ld: 2.34
gold: GNU gold (GNU Binutils for Ubuntu 2.34) 1.16
gcc/g++: 9.4.0
cmake: 3.26.0
ninja: 1.10.0
Some details about hardware configurations:
memory: 16 GiB
CPU: Intel(R) Core(TM) i7-8565U CPU @ 1.80GHz
I have cloned the release/16.x
branch from llvm-project repository. After creating the build directory and moving under it, I am using the following command:
user@system:~/llvm-project/build$ cmake -G "Ninja" -DLLVM_ENABLE_PROJECTS="lld;clang" -DLLVM_TARGETS_TO_BUILD="RISCV" -DCMAKE_BUILD_TYPE="Debug" -DLLVM_ENABLE_ASSERTIONS=On -DLLVM_PARALLEL_COMPILE_JOBS=1 -DLLVM_PARALLEL_LINK_JOBS=1 ../llvm
user@system:~/llvm-project/build$ ninja -j 1
The build of llvm itself proceeds successfully. However, when the linking process for bin/clang-16 begins, the system hangs (apparently uses too much memory), and after sometime I get the following message (snippet re-generated after core llvm build completed):
[0/613] Linking CXX executable bin/clang-16
FAILED: bin/clang-16
: && /usr/bin/c++ -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Wall -Wextra
-Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long
-Wimplicit-fallthrough -Wno-maybe-uninitialized -Wno-class-memaccess -Wno-redundant-move -Wno-pessimizing-move
-Wno-noexcept-type ...
...
...
... lib/libLLVMDemangle.a -lrt -ldl -lpthread -lm && :
collect2: fatal error: ld terminated with signal 9 [killed]
compilation terminated.
ninja: build stopped: subcommand failed.
(I have skipped some lines in between!)
Any help is welcome.
P.S.: Since I will be playing around with the source code of llvm and clang, I DO NOT want a release
build. I think the real problem is static linking, which my computer is not able to handle. I went through the answer to Not able to build LLVM from its source code, but am unable to ascertain where and how to set the flags. Further, the answer to Fatal Error building the llvm source code in Ubuntu also suggests a cmake flag. What should be the correct mixture of flags?