I am getting started with writing my own clang tools. These are the steps I have followed so far:
- Checked out llvm 7.0 release build
- Checked out clang 7.0 release build
Built clang and llvm using ninja with following flags (It was hanging up on me constantly without these)
-DLLVM_USE_LINKER=gold -DLLVM_PARALLEL_LINK_JOBS=1 -DLLVM_LINK_LLVM_DYLIB=true -DLLVM_USE_SPLIT_DWARF=ON -DBUILD_SHARED_LIBS=ON
Installed clang
Now I want to set clang as it's own compiler. So I have set these flags in config file using 'ccmake ../llvm'. I'm not sure if that was the right thing to do though? Now that I try to build clang it says linker detected is GNU ld. How can I reset my config file and actually change the linker so it will be faster? I have 8GB RAM.
Secondly, would I have to build clang again and again every time I write a tool? As in would it take 3-4 hours every single time?
Update
As suggested by sandthorn in comments I limited parallel jobs to 1 by using ninja -j 1
. However, the build failed again with following error:
[3840/4138] Linking CXX shared library lib/libLTO.so.7
FAILED: lib/libLTO.so.7
: && /usr/bin/c++ -fPIC -fPIC -fvisibility-inlines-hidden -Werror=date-time -std=c++11 -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wno-maybe-uninitialized -Wdelete-non-virtual-dtor -Wno-comment -fdiagnostics-color -ffunction-sections -fdata-sections -O3 -DNDEBUG -Wl,-z,defs -Wl,-z,nodelete -fuse-ld=gold -Wl,-O3 -Wl,--gc-sections -Wl,--version-script,/home/tehreem/clang-llvm/build/tools/lto/LTO.exports -shared -Wl,-soname,libLTO.so.7 -o lib/libLTO.so.7 tools/lto/CMakeFiles/LTO.dir/LTODisassembler.cpp.o tools/lto/CMakeFiles/LTO.dir/lto.cpp.o -Wl,-rpath,"\$ORIGIN/../lib" lib/libLLVM-7.so && :
And after this there are about a 100 other undefined reference errors.