5

I am getting started with writing my own clang tools. These are the steps I have followed so far:

  1. Checked out llvm 7.0 release build
  2. Checked out clang 7.0 release build
  3. 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

  4. 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.

Tehreem
  • 939
  • 2
  • 14
  • 31
  • 1
    Also see https://stackoverflow.com/questions/38248216/building-clang-taking-forever I also tried using `gold` instead of `ld` for building clang. (I don't remember if it actually worked for me or just using plain `ld` did). Nevertheless, you can try that, see https://stackoverflow.com/a/41771754/1412255 To answer your second question: no, it doesn't take hours every time. Once you've built it for the first time, the build process only builds the changed files from then on. – Peeyush Kushwaha Dec 12 '18 at 08:23
  • I experienced the same thing. The linking takes very long time with much much memory. I just limited simultaneous linking by `ninja -j 1` (I have only 4GB) and do other stuff while waiting. – sandthorn Dec 13 '18 at 06:36
  • @sandthorn as you suggested I limited parallel linking but the build failed again. Please see my update for the error I am facing now. Can you help me with this one? – Tehreem Dec 14 '18 at 08:46
  • @Tehreem Perhaps you might wanna create another question with more information about the linker errors. I'm sorry that I have no further suggestions. – sandthorn Dec 14 '18 at 16:37
  • @sandthorn ok thankyou for your help – Tehreem Dec 14 '18 at 18:10

0 Answers0