On some distributions, like CentOS, the default version of boost is really old. So the best option is to build a newer one from source. Also even on Fedora or Ubuntu it might be useful to point to different version of boost other than what ./scripts/setup.py installs.
This script automates process of downloading the sources of specified version of boost and building it using default or specified toolchain. Please set proper CROSS_PREFIX if you intend to cross-compile the aarch64 version of boost on x86_64 machine like so: CROSS_PREFIX=aarch64-none-linux-gnu- ./scripts/download_and_build_boost.sh 1.70.0 aarch64 The built version of the boost is symlinked into the build/downloaded_packages/<arch>/boost/install/ directory and will automatically be used where cross-compiling aarch64 OSv kernel. In order to use x64 version of boost built using this script we still need to make changes to the main makefile and modules/common.gmk. Signed-off-by: Waldemar Kozaczuk <[email protected]> --- scripts/download_and_build_boost.sh | 56 +++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100755 scripts/download_and_build_boost.sh diff --git a/scripts/download_and_build_boost.sh b/scripts/download_and_build_boost.sh new file mode 100755 index 00000000..bf250e98 --- /dev/null +++ b/scripts/download_and_build_boost.sh @@ -0,0 +1,56 @@ +#!/bin/bash +# +# Copyright (C) 2021 Waldemar Kozaczuk +# +# This work is open source software, licensed under the terms of the +# BSD license as described in the LICENSE file in the top-level directory. +# + +# Usage: +# ./scripts/download_and_build_boost.sh <BOOST_VERSION> <ARCH> +# +set -e + +OSV_ROOT=$(dirname $(readlink -e $0))/.. + +BOOST_VERSION="$1" +if [[ "${BOOST_VERSION}" == "" ]]; then + BOOST_VERSION="1.70.0" +fi +BOOST_VERSION2=${BOOST_VERSION//[.]/_} + +ARCH=$2 +if [[ "${ARCH}" == "" ]]; then + ARCH=$(uname -m) +fi + +TAR_DOWNLOAD_DIR="${OSV_ROOT}"/build/downloaded_packages/"${ARCH}"/boost/upstream/ +mkdir -p "${TAR_DOWNLOAD_DIR}" + +BOOST_URL=https://dl.bintray.com/boostorg/release/"${BOOST_VERSION}"/source/boost_"${BOOST_VERSION2}".tar.gz +wget -c -O "${TAR_DOWNLOAD_DIR}"/boost_"${BOOST_VERSION2}".tar.gz "${BOOST_URL}" + +pushd "${TAR_DOWNLOAD_DIR}" +rm -rf ./boost_"${BOOST_VERSION2}" +tar -xf ./boost_"${BOOST_VERSION2}".tar.gz +cd ./boost_"${BOOST_VERSION2}" +./bootstrap.sh --with-libraries=system,thread,test,chrono,regex,date_time,filesystem,locale,random,atomic,log,program_options + +BOOST_DIR=$(pwd) +if [[ "$CROSS_PREFIX" == aarch64* ]]; then + echo "using gcc : arm : ${CROSS_PREFIX}g++ ;" > user-config.jam +fi + +B2_OPTIONS="threading=multi" +if [[ "${CROSS_PREFIX}" == aarch64* ]]; then + B2_OPTIONS="${B2_OPTIONS} --user-config=${BOOST_DIR}/user-config.jam toolset=gcc-arm architecture=arm address-model=64" +fi +./b2 ${B2_OPTIONS} -j$(nproc) + +# +# Create symlinks to install boost and make it visible to OSv makefile +rm -f ../../install +ln -s upstream/boost_${BOOST_VERSION2}/stage ../../install +mkdir -p stage/usr/include +ln -s ../../../boost stage/usr/include/boost +popd -- 2.29.2 -- You received this message because you are subscribed to the Google Groups "OSv Development" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/osv-dev/20210217052312.65291-1-jwkozaczuk%40gmail.com.
