Robert Dailey via llvm-dev
2019-Mar-28 19:31 UTC
[llvm-dev] How to build Clang 8 for Ubuntu 18?
I am running Ubuntu 18.04 in a Docker container and I wanted to use Clang version 8 there, along with libc++. The hard part is I need to build a 32-bit app. Originally, my container used the 32-bit version of Ubuntu 18.04, but clang v8 is not available in the official repositories for that version of ubuntu. When I use the LLVM repositories, I can't install clang-8 there either since it doesn't provide 32-bit versions. So I tried using the 64-bit version of Ubuntu 18.04. I'm able to install clang-8 from the LLVM repository, but it doesn't install 32-bit versions of libc++! So when I compile with `-m32`, it fails during the link phase saying it can't find libc++. Now I'm down to trying to compile llvm toolchain myself using this repository: https://github.com/llvm/llvm-project.git It eventually fails to build clang after cmake generates: ninja: error: '/llvm-project/clang/lib/Basic/.git/logs/HEAD', needed by 'lib/Basic/SVNVersion.inc', missing and no known rule to make it I really don't want to build clang, it feels unnecessary and adds a lot of complexity to my Dockerfile. Can someone help me get to a point where I can compile 32-bit Linux applications using Clang v8 with libc++? Here is what I'm running in my Dockerfile: # Clang RUN true \ && git clone --depth 1 --branch llvmorg-8.0.0 https://github.com/llvm/llvm-project.git \ && cd llvm-project \ && cmake -G Ninja -B build/llvm -S llvm \ -D CMAKE_BUILD_TYPE=Release \ -D LLVM_BUILD_32_BITS:BOOL=ON \ && cmake --build build/llvm -j $NUM_PARALLEL --target install RUN true \ && cd llvm-project \ && cmake -G Ninja -B build/clang -S clang \ -D CMAKE_BUILD_TYPE=Release \ && cmake --build build/clang -j $NUM_PARALLEL --target install RUN true \ && cd llvm-project \ && cmake -G Ninja -B build/libcxx -S libcxx \ -D CMAKE_BUILD_TYPE=Release \ -D LIBCXX_BUILD_32_BITS:BOOL=ON \ && cmake --build build/libcxx --target install RUN true \ && cd llvm-project \ && cmake -G Ninja -B build/libcxxabi -S libcxxabi \ -D CMAKE_BUILD_TYPE=Release \ -D LIBCXX_BUILD_32_BITS:BOOL=ON \ && cmake --build build/libcxxabi --target install Note that the multiple RUN directives exist only for quick testing. I do not want to rebuild previously passed builds, so this helps me shortcut stuff already built to save time.