#!/bin/bash -e # helpers pushd () { command pushd "$@" > /dev/null; } popd () { command popd "$@" > /dev/null; } DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" CPUS=$( grep -c processor < /proc/cpuinfo ) cd "$DIR" source "$DIR/../../util.sh" DISTRO="$(operating_system)" function log_tool_name () { echo "" echo "" echo "#### $1 ####" echo "" echo "" } for_arm=false if [[ "$#" -eq 1 ]]; then if [[ "$1" == "--for-arm" ]]; then for_arm=true else echo "Invalid argument received. Use '--for-arm' if you want to build the toolchain for ARM based CPU." exit 1 fi fi TOOLCHAIN_STDCXX="${TOOLCHAIN_STDCXX:-libstdc++}" if [[ "$TOOLCHAIN_STDCXX" != "libstdc++" && "$TOOLCHAIN_STDCXX" != "libc++" ]]; then echo "Only GCC (libstdc++) or LLVM (libc++) C++ standard library implementations are supported." exit 1 fi TOOLCHAIN_VERSION=4 # package versions used GCC_VERSION=11.2.0 BINUTILS_VERSION=2.37 case "$DISTRO" in centos-7) # because GDB >= 9 does NOT compile with readline6. GDB_VERSION=8.3 ;; *) GDB_VERSION=11.2 ;; esac CMAKE_VERSION=3.22.1 CPPCHECK_VERSION=2.6 LLVM_VERSION=13.0.0 SWIG_VERSION=4.0.2 # used only for LLVM compilation # Set the right operating system setup script. ENV_SCRIPT="$DIR/../../os/$DISTRO.sh" if [[ "$for_arm" = true ]]; then ENV_SCRIPT="$DIR/../../os/$DISTRO-arm.sh" fi echo "ALL BUILD PACKAGES: $(${ENV_SCRIPT} list TOOLCHAIN_BUILD_DEPS)" ${ENV_SCRIPT} check TOOLCHAIN_BUILD_DEPS echo "ALL RUN PACKAGES: $(${ENV_SCRIPT} list TOOLCHAIN_RUN_DEPS)" ${ENV_SCRIPT} check TOOLCHAIN_RUN_DEPS # check installation directory NAME=toolchain-v$TOOLCHAIN_VERSION PREFIX=/opt/$NAME mkdir -p $PREFIX >/dev/null 2>/dev/null || true if [ ! -d $PREFIX ] || [ ! -w $PREFIX ]; then echo "Please make sure that the directory '$PREFIX' exists and is writable by the current user!" echo echo "If unsure, execute these commands as root:" echo " mkdir $PREFIX && chown $USER:$USER $PREFIX" echo echo "Press when you have created the directory and granted permissions." # wait for the directory to be created while true; do read if [ ! -d $PREFIX ] || [ ! -w $PREFIX ]; then echo echo "You can't continue before you have created the directory and granted permissions!" echo echo "Press when you have created the directory and granted permissions." else break fi done fi # create archives directory mkdir -p archives # download all archives pushd archives if [ ! -f gcc-$GCC_VERSION.tar.gz ]; then wget https://ftp.gnu.org/gnu/gcc/gcc-$GCC_VERSION/gcc-$GCC_VERSION.tar.gz fi if [ ! -f binutils-$BINUTILS_VERSION.tar.gz ]; then wget https://ftp.gnu.org/gnu/binutils/binutils-$BINUTILS_VERSION.tar.gz fi if [ ! -f gdb-$GDB_VERSION.tar.gz ]; then wget https://ftp.gnu.org/gnu/gdb/gdb-$GDB_VERSION.tar.gz fi if [ ! -f cmake-$CMAKE_VERSION.tar.gz ]; then wget https://github.com/Kitware/CMake/releases/download/v$CMAKE_VERSION/cmake-$CMAKE_VERSION.tar.gz fi if [ ! -f cppcheck-$CPPCHECK_VERSION.tar.gz ]; then wget https://github.com/danmar/cppcheck/archive/$CPPCHECK_VERSION.tar.gz -O cppcheck-$CPPCHECK_VERSION.tar.gz fi if [ ! -f llvm-$LLVM_VERSION.src.tar.xz ]; then wget https://github.com/llvm/llvm-project/releases/download/llvmorg-$LLVM_VERSION/llvm-$LLVM_VERSION.src.tar.xz wget https://github.com/llvm/llvm-project/releases/download/llvmorg-$LLVM_VERSION/clang-$LLVM_VERSION.src.tar.xz wget https://github.com/llvm/llvm-project/releases/download/llvmorg-$LLVM_VERSION/lld-$LLVM_VERSION.src.tar.xz wget https://github.com/llvm/llvm-project/releases/download/llvmorg-$LLVM_VERSION/clang-tools-extra-$LLVM_VERSION.src.tar.xz wget https://github.com/llvm/llvm-project/releases/download/llvmorg-$LLVM_VERSION/compiler-rt-$LLVM_VERSION.src.tar.xz wget https://github.com/llvm/llvm-project/releases/download/llvmorg-$LLVM_VERSION/libunwind-$LLVM_VERSION.src.tar.xz wget https://github.com/llvm/llvm-project/releases/download/llvmorg-$LLVM_VERSION/libcxx-$LLVM_VERSION.src.tar.xz wget https://github.com/llvm/llvm-project/releases/download/llvmorg-$LLVM_VERSION/libcxxabi-$LLVM_VERSION.src.tar.xz fi if [ ! -f pahole-gdb-master.zip ]; then wget https://github.com/PhilArmstrong/pahole-gdb/archive/master.zip -O pahole-gdb-master.zip fi if [ ! -f swig-$SWIG_VERSION.tar.gz ]; then wget https://github.com/swig/swig/archive/rel-$SWIG_VERSION.tar.gz -O swig-$SWIG_VERSION.tar.gz fi # verify all archives # NOTE: Verification can fail if the archive is signed by another developer. I # haven't added commands to download all developer GnuPG keys because the # download is very slow. If the verification fails for you, figure out who has # signed the archive and download their public key instead. GPG="gpg --homedir .gnupg" KEYSERVER="hkp://keyserver.ubuntu.com" mkdir -p .gnupg chmod 700 .gnupg # verify gcc if [ ! -f gcc-$GCC_VERSION.tar.gz.sig ]; then wget https://ftp.gnu.org/gnu/gcc/gcc-$GCC_VERSION/gcc-$GCC_VERSION.tar.gz.sig fi # list of valid gcc gnupg keys: https://gcc.gnu.org/mirrors.html $GPG --keyserver $KEYSERVER --recv-keys FC26A641 $GPG --verify gcc-$GCC_VERSION.tar.gz.sig gcc-$GCC_VERSION.tar.gz # verify binutils if [ ! -f binutils-$BINUTILS_VERSION.tar.gz.sig ]; then wget https://ftp.gnu.org/gnu/binutils/binutils-$BINUTILS_VERSION.tar.gz.sig fi $GPG --keyserver $KEYSERVER --recv-keys 0xDD9E3C4F $GPG --verify binutils-$BINUTILS_VERSION.tar.gz.sig binutils-$BINUTILS_VERSION.tar.gz # verify gdb if [ ! -f gdb-$GDB_VERSION.tar.gz.sig ]; then wget https://ftp.gnu.org/gnu/gdb/gdb-$GDB_VERSION.tar.gz.sig fi $GPG --keyserver $KEYSERVER --recv-keys 0xFF325CF3 $GPG --verify gdb-$GDB_VERSION.tar.gz.sig gdb-$GDB_VERSION.tar.gz # verify cmake if [ ! -f cmake-$CMAKE_VERSION-SHA-256.txt ] || [ ! -f cmake-$CMAKE_VERSION-SHA-256.txt.asc ]; then wget https://github.com/Kitware/CMake/releases/download/v$CMAKE_VERSION/cmake-$CMAKE_VERSION-SHA-256.txt wget https://github.com/Kitware/CMake/releases/download/v$CMAKE_VERSION/cmake-$CMAKE_VERSION-SHA-256.txt.asc # Because CentOS 7 doesn't have the `--ignore-missing` flag for `sha256sum` # we filter out the missing files from the sums here manually. cat cmake-$CMAKE_VERSION-SHA-256.txt | grep "cmake-$CMAKE_VERSION.tar.gz" > cmake-$CMAKE_VERSION-SHA-256-filtered.txt fi $GPG --keyserver $KEYSERVER --recv-keys 0xC6C265324BBEBDC350B513D02D2CEF1034921684 sha256sum -c cmake-$CMAKE_VERSION-SHA-256-filtered.txt $GPG --verify cmake-$CMAKE_VERSION-SHA-256.txt.asc cmake-$CMAKE_VERSION-SHA-256.txt # verify llvm, cfe, lld, clang-tools-extra if [ ! -f llvm-$LLVM_VERSION.src.tar.xz.sig ]; then wget https://github.com/llvm/llvm-project/releases/download/llvmorg-$LLVM_VERSION/llvm-$LLVM_VERSION.src.tar.xz.sig wget https://github.com/llvm/llvm-project/releases/download/llvmorg-$LLVM_VERSION/clang-$LLVM_VERSION.src.tar.xz.sig wget https://github.com/llvm/llvm-project/releases/download/llvmorg-$LLVM_VERSION/lld-$LLVM_VERSION.src.tar.xz.sig wget https://github.com/llvm/llvm-project/releases/download/llvmorg-$LLVM_VERSION/clang-tools-extra-$LLVM_VERSION.src.tar.xz.sig wget https://github.com/llvm/llvm-project/releases/download/llvmorg-$LLVM_VERSION/compiler-rt-$LLVM_VERSION.src.tar.xz.sig wget https://github.com/llvm/llvm-project/releases/download/llvmorg-$LLVM_VERSION/libunwind-$LLVM_VERSION.src.tar.xz.sig wget https://github.com/llvm/llvm-project/releases/download/llvmorg-$LLVM_VERSION/libcxx-$LLVM_VERSION.src.tar.xz.sig wget https://github.com/llvm/llvm-project/releases/download/llvmorg-$LLVM_VERSION/libcxxabi-$LLVM_VERSION.src.tar.xz.sig fi # list of valid llvm gnupg keys: https://releases.llvm.org/download.html $GPG --keyserver $KEYSERVER --recv-keys 0x474E22316ABF4785A88C6E8EA2C794A986419D8A $GPG --verify llvm-$LLVM_VERSION.src.tar.xz.sig llvm-$LLVM_VERSION.src.tar.xz $GPG --verify clang-$LLVM_VERSION.src.tar.xz.sig clang-$LLVM_VERSION.src.tar.xz $GPG --verify lld-$LLVM_VERSION.src.tar.xz.sig lld-$LLVM_VERSION.src.tar.xz $GPG --verify clang-tools-extra-$LLVM_VERSION.src.tar.xz.sig clang-tools-extra-$LLVM_VERSION.src.tar.xz $GPG --verify compiler-rt-$LLVM_VERSION.src.tar.xz.sig compiler-rt-$LLVM_VERSION.src.tar.xz $GPG --verify libunwind-$LLVM_VERSION.src.tar.xz.sig libunwind-$LLVM_VERSION.src.tar.xz $GPG --verify libcxx-$LLVM_VERSION.src.tar.xz.sig libcxx-$LLVM_VERSION.src.tar.xz $GPG --verify libcxxabi-$LLVM_VERSION.src.tar.xz.sig libcxxabi-$LLVM_VERSION.src.tar.xz popd # create build directory mkdir -p build pushd build log_tool_name "GCC $GCC_VERSION" if [ ! -f $PREFIX/bin/gcc ]; then if [ -d gcc-$GCC_VERSION ]; then rm -rf gcc-$GCC_VERSION fi tar -xvf ../archives/gcc-$GCC_VERSION.tar.gz pushd gcc-$GCC_VERSION ./contrib/download_prerequisites mkdir build && pushd build # influenced by: https://buildd.debian.org/status/fetch.php?pkg=gcc-11&arch=arm64&ver=11.2.0-14&stamp=1642052446&raw=0 if [[ "$for_arm" = true ]]; then ../configure -v \ --prefix=$PREFIX \ --disable-multilib \ --with-system-zlib \ --enable-languages=c,c++,fortran \ --enable-gold=yes \ --enable-ld=yes \ --disable-vtable-verify \ --enable-libmpx \ --without-cuda-driver \ --enable-shared \ --enable-linker-build-id \ --without-included-gettext \ --enable-threads=posix \ --enable-nls \ --enable-bootstrap \ --enable-clocale=gnu \ --enable-libstdcxx-debug \ --enable-libstdcxx-time=yes \ --with-default-libstdcxx-abi=new \ --enable-gnu-unique-object \ --disable-libquadmath \ --disable-libquadmath-support \ --enable-plugin \ --enable-default-pie \ --with-system-zlib \ --enable-libphobos-checking=release \ --with-target-system-zlib=auto \ --enable-objc-gc=auto \ --enable-multiarch \ --enable-fix-cortex-a53-843419 \ --disable-werror \ --enable-checking=release \ --build=aarch64-linux-gnu \ --host=aarch64-linux-gnu \ --target=aarch64-linux-gnu \ --with-build-config=bootstrap-lto-lean \ --enable-link-serialization=4 else # influenced by: https://buildd.debian.org/status/fetch.php?pkg=gcc-8&arch=amd64&ver=8.3.0-6&stamp=1554588545 ../configure -v \ --build=x86_64-linux-gnu \ --host=x86_64-linux-gnu \ --target=x86_64-linux-gnu \ --prefix=$PREFIX \ --disable-multilib \ --with-system-zlib \ --enable-checking=release \ --enable-languages=c,c++,fortran \ --enable-gold=yes \ --enable-ld=yes \ --enable-lto \ --enable-bootstrap \ --disable-vtable-verify \ --disable-werror \ --without-included-gettext \ --enable-threads=posix \ --enable-nls \ --enable-clocale=gnu \ --enable-libstdcxx-debug \ --enable-libstdcxx-time=yes \ --enable-gnu-unique-object \ --enable-libmpx \ --enable-plugin \ --enable-default-pie \ --with-target-system-zlib \ --with-tune=generic \ --without-cuda-driver #--program-suffix=$( printf "$GCC_VERSION" | cut -d '.' -f 1,2 ) \ fi make -j$CPUS # make -k check # run test suite make install popd && popd fi # activate toolchain export PATH=$PREFIX/bin:$PATH export LD_LIBRARY_PATH=$PREFIX/lib64 log_tool_name "binutils $BINUTILS_VERSION" if [ ! -f $PREFIX/bin/ld.gold ]; then if [ -d binutils-$BINUTILS_VERSION ]; then rm -rf binutils-$BINUTILS_VERSION fi tar -xvf ../archives/binutils-$BINUTILS_VERSION.tar.gz pushd binutils-$BINUTILS_VERSION mkdir build && pushd build if [[ "$for_arm" = true ]]; then # influenced by: https://buildd.debian.org/status/fetch.php?pkg=binutils&arch=arm64&ver=2.37.90.20220130-2&stamp=1643576183&raw=0 env \ CC=gcc \ CXX=g++ \ CFLAGS="-g -O2" \ CXXFLAGS="-g -O2" \ LDFLAGS="" \ ../configure \ --build=aarch64-linux-gnu \ --host=aarch64-linux-gnu \ --prefix=$PREFIX \ --enable-ld=default \ --enable-gold \ --enable-lto \ --enable-pgo-build=lto \ --enable-plugins \ --enable-shared \ --enable-threads \ --with-system-zlib \ --enable-deterministic-archives \ --disable-compressed-debug-sections \ --disable-x86-used-note \ --enable-obsolete \ --enable-new-dtags \ --disable-werror else # influenced by: https://buildd.debian.org/status/fetch.php?pkg=binutils&arch=amd64&ver=2.32-7&stamp=1553247092 env \ CC=gcc \ CXX=g++ \ CFLAGS="-g -O2" \ CXXFLAGS="-g -O2" \ LDFLAGS="" \ ../configure \ --build=x86_64-linux-gnu \ --host=x86_64-linux-gnu \ --prefix=$PREFIX \ --enable-ld=default \ --enable-gold \ --enable-lto \ --enable-plugins \ --enable-shared \ --enable-threads \ --with-system-zlib \ --enable-deterministic-archives \ --disable-compressed-debug-sections \ --enable-new-dtags \ --disable-werror fi make -j$CPUS # make -k check # run test suite make install popd && popd fi log_tool_name "GDB $GDB_VERSION" if [ ! -f $PREFIX/bin/gdb ]; then if [ -d gdb-$GDB_VERSION ]; then rm -rf gdb-$GDB_VERSION fi tar -xvf ../archives/gdb-$GDB_VERSION.tar.gz pushd gdb-$GDB_VERSION mkdir build && pushd build if [[ "$for_arm" = true ]]; then # https://buildd.debian.org/status/fetch.php?pkg=gdb&arch=arm64&ver=10.1-2&stamp=1614889767&raw=0 env \ CC=gcc \ CXX=g++ \ CFLAGS="-g -O2 -fstack-protector-strong -Wformat -Werror=format-security" \ CXXFLAGS="-g -O2 -fstack-protector-strong -Wformat -Werror=format-security" \ CPPFLAGS="-Wdate-time -D_FORTIFY_SOURCE=2 -fPIC" \ LDFLAGS="-Wl,-z,relro" \ PYTHON="" \ ../configure \ --build=aarch64-linux-gnu \ --host=aarch64-linux-gnu \ --prefix=$PREFIX \ --disable-maintainer-mode \ --disable-dependency-tracking \ --disable-silent-rules \ --disable-gdbtk \ --disable-shared \ --without-guile \ --with-system-gdbinit=$PREFIX/etc/gdb/gdbinit \ --with-system-readline \ --with-expat \ --with-system-zlib \ --with-lzma \ --without-babeltrace \ --enable-tui \ --with-python=python3 elif [[ "${DISTRO}" == fedora* ]]; then # Remove readline, gdb does not compile env \ CC=gcc \ CXX=g++ \ CFLAGS="-g -O2 -fstack-protector-strong -Wformat -Werror=format-security" \ CXXFLAGS="-g -O2 -fstack-protector-strong -Wformat -Werror=format-security" \ CPPFLAGS="-Wdate-time -D_FORTIFY_SOURCE=2 -fPIC" \ LDFLAGS="-Wl,-z,relro" \ PYTHON="" \ ../configure \ --build=x86_64-linux-gnu \ --host=x86_64-linux-gnu \ --prefix=$PREFIX \ --disable-maintainer-mode \ --disable-dependency-tracking \ --disable-silent-rules \ --disable-gdbtk \ --disable-shared \ --without-guile \ --with-system-gdbinit=$PREFIX/etc/gdb/gdbinit \ --with-expat \ --with-system-zlib \ --with-lzma \ --with-babeltrace \ --with-intel-pt \ --enable-tui \ --with-python=python3 elif [[ "${DISTRO}" == "amzn-2" ]]; then # Remove readline, gdb does not compile env \ CC=gcc \ CXX=g++ \ CFLAGS="-g -O2 -fstack-protector-strong -Wformat -Werror=format-security" \ CXXFLAGS="-g -O2 -fstack-protector-strong -Wformat -Werror=format-security" \ CPPFLAGS="-Wdate-time -D_FORTIFY_SOURCE=2 -fPIC" \ LDFLAGS="-Wl,-z,relro" \ PYTHON="" \ ../configure \ --build=x86_64-linux-gnu \ --host=x86_64-linux-gnu \ --prefix=$PREFIX \ --disable-maintainer-mode \ --disable-dependency-tracking \ --disable-silent-rules \ --disable-gdbtk \ --disable-shared \ --without-guile \ --with-system-gdbinit=$PREFIX/etc/gdb/gdbinit \ --with-expat \ --with-system-zlib \ --with-lzma \ --with-babeltrace \ --with-intel-pt \ --enable-tui \ --with-python=python3 else # https://buildd.debian.org/status/fetch.php?pkg=gdb&arch=amd64&ver=8.2.1-2&stamp=1550831554&raw=0 env \ CC=gcc \ CXX=g++ \ CFLAGS="-g -O2 -fstack-protector-strong -Wformat -Werror=format-security" \ CXXFLAGS="-g -O2 -fstack-protector-strong -Wformat -Werror=format-security" \ CPPFLAGS="-Wdate-time -D_FORTIFY_SOURCE=2 -fPIC" \ LDFLAGS="-Wl,-z,relro" \ PYTHON="" \ ../configure \ --build=x86_64-linux-gnu \ --host=x86_64-linux-gnu \ --prefix=$PREFIX \ --disable-maintainer-mode \ --disable-dependency-tracking \ --disable-silent-rules \ --disable-gdbtk \ --disable-shared \ --without-guile \ --with-system-gdbinit=$PREFIX/etc/gdb/gdbinit \ --with-system-readline \ --with-expat \ --with-system-zlib \ --with-lzma \ --with-babeltrace \ --with-intel-pt \ --enable-tui \ --with-python=python3 fi make -j$CPUS make install popd && popd fi log_tool_name "install pahole" if [ ! -d $PREFIX/share/pahole-gdb ]; then unzip ../archives/pahole-gdb-master.zip mv pahole-gdb-master $PREFIX/share/pahole-gdb fi log_tool_name "setup system gdbinit" if [ ! -f $PREFIX/etc/gdb/gdbinit ]; then mkdir -p $PREFIX/etc/gdb cat >$PREFIX/etc/gdb/gdbinit <> build-flags.cmake echo 'set(CMAKE_USE_RELATIVE_PATHS ON CACHE BOOL "Use relative paths" FORCE)' >> build-flags.cmake echo 'set(CMAKE_C_FLAGS "-g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2" CACHE STRING "C flags" FORCE)' >> build-flags.cmake echo 'set(CMAKE_CXX_FLAGS "-g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2" CACHE STRING "C++ flags" FORCE)' >> build-flags.cmake echo 'set(CMAKE_SKIP_BOOTSTRAP_TEST ON CACHE BOOL "Skip BootstrapTest" FORCE)' >> build-flags.cmake echo 'set(BUILD_CursesDialog ON CACHE BOOL "Build curses GUI" FORCE)' >> build-flags.cmake mkdir build && pushd build ../bootstrap \ --prefix=$PREFIX \ --init=../build-flags.cmake \ --parallel=$CPUS \ --system-curl make -j$CPUS # make test # run test suite make install popd && popd fi log_tool_name "cppcheck $CPPCHECK_VERSION" if [ ! -f $PREFIX/bin/cppcheck ]; then if [ -d cppcheck-$CPPCHECK_VERSION ]; then rm -rf cppcheck-$CPPCHECK_VERSION fi tar -xvf ../archives/cppcheck-$CPPCHECK_VERSION.tar.gz pushd cppcheck-$CPPCHECK_VERSION env \ CC=gcc \ CXX=g++ \ PREFIX=$PREFIX \ FILESDIR=$PREFIX/share/cppcheck \ CFGDIR=$PREFIX/share/cppcheck/cfg \ make -j$CPUS env \ CC=gcc \ CXX=g++ \ PREFIX=$PREFIX \ FILESDIR=$PREFIX/share/cppcheck \ CFGDIR=$PREFIX/share/cppcheck/cfg \ make install popd fi log_tool_name "swig $SWIG_VERSION" if [ ! -d swig-$SWIG_VERSION/install ]; then if [ -d swig-$SWIG_VERSION ]; then rm -rf swig-$SWIG_VERSION fi tar -xvf ../archives/swig-$SWIG_VERSION.tar.gz mv swig-rel-$SWIG_VERSION swig-$SWIG_VERSION pushd swig-$SWIG_VERSION ./autogen.sh mkdir build && pushd build ../configure --prefix=$DIR/build/swig-$SWIG_VERSION/install make -j$CPUS make install popd && popd fi log_tool_name "LLVM $LLVM_VERSION" if [ ! -f $PREFIX/bin/clang ]; then if [ -d llvm-$LLVM_VERSION ]; then rm -rf llvm-$LLVM_VERSION fi tar -xvf ../archives/llvm-$LLVM_VERSION.src.tar.xz mv llvm-$LLVM_VERSION.src llvm-$LLVM_VERSION tar -xvf ../archives/clang-$LLVM_VERSION.src.tar.xz mv clang-$LLVM_VERSION.src llvm-$LLVM_VERSION/tools/clang tar -xvf ../archives/lld-$LLVM_VERSION.src.tar.xz mv lld-$LLVM_VERSION.src/ llvm-$LLVM_VERSION/tools/lld tar -xvf ../archives/clang-tools-extra-$LLVM_VERSION.src.tar.xz mv clang-tools-extra-$LLVM_VERSION.src/ llvm-$LLVM_VERSION/tools/clang/tools/extra tar -xvf ../archives/compiler-rt-$LLVM_VERSION.src.tar.xz mv compiler-rt-$LLVM_VERSION.src/ llvm-$LLVM_VERSION/projects/compiler-rt tar -xvf ../archives/libunwind-$LLVM_VERSION.src.tar.xz mv libunwind-$LLVM_VERSION.src/include/mach-o llvm-$LLVM_VERSION/tools/lld/include # The following is required because of libc++ tar -xvf ../archives/libcxx-$LLVM_VERSION.src.tar.xz mv libcxx-$LLVM_VERSION.src llvm-$LLVM_VERSION/projects/libcxx tar -xvf ../archives/libcxxabi-$LLVM_VERSION.src.tar.xz mv libcxxabi-$LLVM_VERSION.src llvm-$LLVM_VERSION/projects/libcxxabi # NOTE: We moved part of the libunwind in one of the previous step. rm -r libunwind-$LLVM_VERSION.src tar -xvf ../archives/libunwind-$LLVM_VERSION.src.tar.xz mv libunwind-$LLVM_VERSION.src llvm-$LLVM_VERSION/projects/libunwind pushd llvm-$LLVM_VERSION mkdir -p build && pushd build # activate swig export PATH=$DIR/build/swig-$SWIG_VERSION/install/bin:$PATH # influenced by: https://buildd.debian.org/status/fetch.php?pkg=llvm-toolchain-7&arch=amd64&ver=1%3A7.0.1%7E%2Brc2-1%7Eexp1&stamp=1541506173&raw=0 cmake .. \ -DCMAKE_C_COMPILER=$PREFIX/bin/gcc \ -DCMAKE_CXX_COMPILER=$PREFIX/bin/g++ \ -DCMAKE_CXX_LINK_FLAGS="-L$PREFIX/lib64 -Wl,-rpath,$PREFIX/lib64" \ -DCMAKE_INSTALL_PREFIX=$PREFIX \ -DCMAKE_BUILD_TYPE=RelWithDebInfo \ -DCMAKE_CXX_FLAGS_RELWITHDEBINFO="-O2 -DNDEBUG" \ -DCMAKE_CXX_FLAGS=' -fuse-ld=gold -fPIC -Wno-unused-command-line-argument -Wno-unknown-warning-option' \ -DCMAKE_C_FLAGS=' -fuse-ld=gold -fPIC -Wno-unused-command-line-argument -Wno-unknown-warning-option' \ -DLLVM_LINK_LLVM_DYLIB=ON \ -DLLVM_INSTALL_UTILS=ON \ -DLLVM_VERSION_SUFFIX= \ -DLLVM_BUILD_LLVM_DYLIB=ON \ -DLLVM_ENABLE_RTTI=ON \ -DLLVM_ENABLE_FFI=ON \ -DLLVM_BINUTILS_INCDIR=$PREFIX/include/ \ -DLLVM_USE_PERF=yes make -j$CPUS if [[ "$for_arm" = false ]]; then make -j$CPUS check-clang # run clang test suite # ldd is not used # make -j$CPUS check-lld # run lld test suite fi make install popd && popd fi popd # create README if [ ! -f $PREFIX/README.md ]; then cat >$PREFIX/README.md <$PREFIX/activate <