#!/usr/bin/env bash set -e SCRIPT_DIR="$(dirname "$BASH_SOURCE")" SCRIPT_DIR="$(realpath "$SCRIPT_DIR")" num_vcpus=$(( $(lscpu -p | tail -1 | cut -d "," -f 1) + 1 )) NUM_WORKERS=${NUM_WORKERS:-$num_vcpus} DEPS_DIR="${DEPS_DIR:-$SCRIPT_DIR/build.deps}" depsSrcDir="$DEPS_DIR/src" depsToolsetDir="$DEPS_DIR/mingw" lz4SrcDir="${depsSrcDir}/lz4" lz4Dir="${depsToolsetDir}/lz4" lz4Tag="v1.9.2" sslVersion="1.1.1c" sslDir="${depsToolsetDir}/openssl" sslSrcDir="${depsSrcDir}/openssl-${sslVersion}" curlTag="curl-7_66_0" curlSrcDir="${depsSrcDir}/curl" curlDir="${depsToolsetDir}/curl" # For now, we'll keep the version number within the file path when not using git. boostUrl="https://dl.bintray.com/boostorg/release/1.70.0/source/boost_1_70_0.tar.gz" boostSrcDir="${depsSrcDir}/boost_1_70_0" boostDir="${depsToolsetDir}/boost" zlibDir="${depsToolsetDir}/zlib" zlibSrcDir="${depsSrcDir}/zlib" backtraceDir="${depsToolsetDir}/backtrace" backtraceSrcDir="${depsSrcDir}/backtrace" snappySrcDir="${depsSrcDir}/snappy" snappyDir="${depsToolsetDir}/snappy" snappyTag="1.1.7" # Additional Windows libraries, which aren't provided by Mingw winLibDir="${depsToolsetDir}/windows/lib" MINGW_PREFIX="x86_64-w64-mingw32-" function _make() { make -j $NUM_WORKERS $@ } mkdir -p $DEPS_DIR mkdir -p $depsToolsetDir mkdir -p $depsSrcDir MINGW_CMAKE_FILE="$DEPS_DIR/mingw.cmake" cat > $MINGW_CMAKE_FILE < user-config.jam # Workaround for https://github.com/boostorg/thread/issues/156 # Older versions of mingw provided a different pthread lib. sed -i 's/lib$(libname)GC2.a/lib$(libname).a/g' ./libs/thread/build/Jamfile.v2 sed -i 's/mthreads/pthreads/g' ./tools/build/src/tools/gcc.py sed -i 's/mthreads/pthreads/g' ./tools/build/src/tools/gcc.jam sed -i 's/pthreads/mthreads/g' ./tools/build/src/tools/gcc.py sed -i 's/pthreads/mthreads/g' ./tools/build/src/tools/gcc.jam export PTW32_INCLUDE=/usr/share/mingw-w64/include export PTW32_LIB=/usr/x86_64-w64-mingw32/lib # Fix getting Windows page size # TODO: send this upstream and maybe use a fork until it merges. # Meanwhile, we might consider moving those to ceph/cmake/modules/BuildBoost.cmake. # This cmake module will first have to be updated to support Mingw though. cat | patch -N boost/thread/pthread/thread_data.hpp < +#endif + #include #include @@ -54,6 +58,10 @@ if (size==0) return; #ifdef BOOST_THREAD_USES_GETPAGESIZE std::size_t page_size = getpagesize(); +#elif _WIN32 + SYSTEM_INFO system_info; + ::GetSystemInfo (&system_info); + std::size_t page_size = system_info.dwPageSize; #else std::size_t page_size = ::sysconf( _SC_PAGESIZE); #endif EOL # Use pthread if requested cat | patch -N boost/asio/detail/thread.hpp < +#elif defined(BOOST_ASIO_HAS_PTHREADS) +# include #elif defined(BOOST_ASIO_WINDOWS) # if defined(UNDER_CE) # include @@ -27,8 +29,6 @@ # else # include # endif -#elif defined(BOOST_ASIO_HAS_PTHREADS) -# include #elif defined(BOOST_ASIO_HAS_STD_THREAD) # include #else @@ -41,6 +41,8 @@ #if !defined(BOOST_ASIO_HAS_THREADS) typedef null_thread thread; +#elif defined(BOOST_ASIO_HAS_PTHREADS) +typedef posix_thread thread; #elif defined(BOOST_ASIO_WINDOWS) # if defined(UNDER_CE) typedef wince_thread thread; @@ -49,8 +51,6 @@ # else typedef win_thread thread; # endif -#elif defined(BOOST_ASIO_HAS_PTHREADS) -typedef posix_thread thread; #elif defined(BOOST_ASIO_HAS_STD_THREAD) typedef std_thread thread; #endif EOL # Unix socket support for Windows is currently disabled by Boost. # https://github.com/huangqinjin/asio/commit/d27a8ad1870 cat | patch -N boost/asio/detail/socket_types.hpp < $winLibDir/mswsock.def <