%general-entities; ]> LLVM &llvm-version;
&llvm-url;
LLVM-&llvm-version; - Pass 2 LLVM tools, pass 2 <para>The LLVM package contains a collection of modular and reusable compiler and toolchain technologies.</para> <segmentedlist> <segtitle>&buildtime;</segtitle> <segtitle>&diskspace;</segtitle> <seglistitem> <seg>&llvm-tmpp2-sbu;</seg> <seg>&llvm-tmpp2-du;</seg> </seglistitem> </segmentedlist> </sect2> <sect2 role="installation"> <title>Installation of LLVM Prepare some CMake modules needed by LLVM building system: tar -xf ../llvm-cmake-&llvm-version;.src.tar.xz mv cmake-&llvm-version;.src ../cmake The LLVM documentation recommends building LLVM in a dedicated build directory: mkdir -v build cd build For cross-compiling LLVM, create a CMake toolchain description file: cat > cross.cmake << EOF # the name of the target operating system set(CMAKE_SYSTEM_NAME Linux) # which compilers to use for C and C++ set(CMAKE_C_COMPILER $LFS_TGT-gcc) set(CMAKE_CXX_COMPILER $LFS_TGT-g++) # where is the target environment located set(CMAKE_FIND_ROOT_PATH $LFS) # adjust the default behavior of the FIND_XXX() commands: # search programs in the host environment set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) # search headers and libraries in the target environment set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) EOF Prepare LLVM for compilation: OPTS="-DLLVM_ENABLE_FFI=OFF;\ -DLLVM_BUILD_LLVM_DYLIB=ON;\ -DLLVM_LINK_LLVM_DYLIB=ON;\ -DLLVM_ENABLE_RTTI=ON;\ -DLLVM_TARGETS_TO_BUILD=host;\ -DLLVM_INCLUDE_BENCHMARKS=OFF" CC=gcc CXX=g++ cmake \ -DCMAKE_INSTALL_PREFIX=$LFS/tools/$LFS_TGT \ -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_TOOLCHAIN_FILE=cross.cmake \ -DLLVM_TABLEGEN=$LFS/tools/bin/llvm-tblgen \ $(echo $OPTS | sed 's/;/ /g') \ -DCROSS_TOOLCHAIN_FLAGS_NATIVE=$OPTS \ -Wno-dev .. unset OPTS The meaning of the configure options: -DLLVM_ENABLE_FFI=OFF Allow building LLVM without libffi installed in $LFS. -DLLVM_TABLEGEN=$LFS/tools/bin/llvm-tblgen Use llvm-tblgen from LLVM pass 1, instead of building it again for the host distro. OPTS=..., $(echo $OPTS | sed 's/;/ '), and -DCROSS_TOOLCHAIN_FLAGS_NATIVE=$OPTS Use the same configuration for cross compiling LLVM to generate llvm-config which is runnable on the host distro. llvm-config will be used building Rustc Pass 2. This option ensures it will correctly output the configuration of the cross compiled LLVM libraries. We save the configuration in an environment variable to avoid typing the same options again. For the meaning of other CMake options, see TODO. Compile LLVM by running: make Install the headers and shared library: DESTDIR=$PWD/dest make install cp -av dest/$LFS/tools/$LFS_TGT/lib/libLLVM*.so \ $LFS/tools/$LFS_TGT/lib cp -av dest/$LFS/tools/$LFS_TGT/include/* \ $LFS/tools/$LFS_TGT/include Install another copy of the shared library into $LFS/usr/lib, so it will be able to be used in the chroot environment: cp -av dest/$LFS/tools/$LFS_TGT/lib/libLLVM*.so $LFS/usr/lib Install llvm-config: install -vm755 NATIVE/bin/llvm-config $LFS/tools/$LFS_TGT/bin Clean up the source directory: rm -rf ../../cmake <para>Details on this package are located in <xref linkend="contents-llvm" role="."/></para> </sect2> </sect1>