Using a Dockerfile, I'm attempting to build Clang version v8 along with its dependencies on Ubuntu 18.04. The reason I'm going through all this trouble is because I can't find a 32-bit version of the LLVM libraries. Even the LLVM packages themselves have only 64-bit variants of everything. Because of this, I'm not able to build my 32-bit applications using the LLVM toolchain at version 8. Using version 8 of LLVM is mandatory for reasons I won't go into here.
So far, here is what I have:
FROM ubuntu:18.04 AS build ARG NUM_PARALLEL=8 RUN true \ && dpkg --add-architecture i386 \ && apt-get -qq update \ && apt-get -qq install \ software-properties-common \ build-essential \ gcc-multilib \ g++-multilib \ git \ wget \ autoconf \ pkg-config \ m4 \ python-dev:i386 \ libcurl4-gnutls-dev:i386 \ libncurses-dev:i386 \ uuid-dev:i386 \ libx11-dev:i386 \ libxext-dev:i386 \ libtinfo-dev:i386 \ libedit-dev:i386 \ swig \ libedit-dev python-dev ENV CMAKE_BUILD_PARALLEL_LEVEL=$NUM_PARALLEL # Ninja RUN true \ && git clone --depth 1 --branch v1.8.2 https://github.com/ninja-build/ninja.git \ && cd ninja \ && ./configure.py --bootstrap \ && cp ninja /usr/local/bin # CMake RUN true \ && git clone --depth 1 --branch v3.13.4 https://gitlab.kitware.com/cmake/cmake.git \ && cd cmake \ && ./bootstrap --parallel=$NUM_PARALLEL \ && make -j$NUM_PARALLEL install # Clang (See: https://clang.llvm.org/get_started.html) 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 -S llvm \ -D CMAKE_BUILD_TYPE=Release \ -D LLVM_BUILD_32_BITS:BOOL=ON \ -D LLVM_ENABLE_PROJECTS=all \ -D LLVM_BUILD_TESTS:BOOL=OFF \ -D LLVM_BUILD_EXAMPLES:BOOL=OFF \ -D LLVM_INCLUDE_EXAMPLES:BOOL=OFF \ -D LLVM_INCLUDE_TESTS:BOOL=OFF \ -D LLVM_INCLUDE_BENCHMARKS:BOOL=OFF \ && cmake --build build -j $NUM_PARALLEL --target install I get through compiling a little over 5200 translation units, which takes over an hour, only for it to fail:
[5232/6435] Linking CXX shared library lib/readline.so FAILED: lib/readline.so : && /usr/bin/c++ -fPIC -fPIC -fvisibility-inlines-hidden -m32 -Werror=date-time -std=c++11 -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wno-maybe-uninitialized -Wno-noexcept-type -Wdelete-non-virtual-dtor -Wno-comment -fdiagnostics-color -ffunction-sections -fdata-sections -Wno-deprecated-declarations -Wno-unknown-pragmas -Wno-strict-aliasing -Wno-deprecated-register -Wno-vla-extension -Wno-macro-redefined -O3 -DNDEBUG -Wl,-z,defs -Wl,-z,nodelete -m32 -shared -Wl,-soname,readline.so -o lib/readline.so tools/lldb/scripts/Python/modules/readline/CMakeFiles/readline.dir/readline.cpp.o /usr/lib/x86_64-linux-gnu/libpython2.7.so /usr/lib/x86_64-linux-gnu/libedit.so && : /usr/lib/x86_64-linux-gnu/libpython2.7.so: error adding symbols: File in wrong format collect2: error: ld returned 1 exit status I followed the getting started page to understand how to build LLVM so far, but I must be missing something. They don't exactly go into 32-bit compilation in their examples. Can someone help me get this building? Or at least (and probably better), point me to a version of Clang v8 that has 32-bit LLVM libraries bundled with it?
-m32causes linker failures due tolibc++missing (since it's not available for the i386 architecture).dpkg --add-architecture i386and thenapt-get install libc++1:i386? (see Debian multiarchitecture)