summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--README.windows.rst18
-rw-r--r--cmake/toolchains/mingw32.cmake24
-rw-r--r--mingw_conf.sh81
-rwxr-xr-xwin32_build.sh39
-rwxr-xr-xwin32_deps_build.sh65
5 files changed, 160 insertions, 67 deletions
diff --git a/README.windows.rst b/README.windows.rst
index c3b2e979d8f..b7e2426500c 100644
--- a/README.windows.rst
+++ b/README.windows.rst
@@ -16,9 +16,9 @@ components for Windows. Support for msvc and clang will be added soon.
It may be called from a Linux environment, including Windows Subsystem for
Linux. MSYS2 and CygWin may also work but those weren't tested.
-This script currently supports Ubuntu 18.04 but it may be easily adapted to
-run on other Linux distributions, taking into account different package
-managers, package names or paths (e.g. mingw paths).
+This script currently supports Ubuntu 18.04 and openSUSE Tumbleweed, but it
+may be easily adapted to run on other Linux distributions, taking into
+account different package managers, package names or paths (e.g. mingw paths).
.. _win32_build.sh: win32_build.sh
@@ -27,6 +27,8 @@ The script accepts the following flags:
============ =============================== ===============================
Flag Description Default value
============ =============================== ===============================
+OS Host OS distribution, for mingw ubuntu (also valid: suse)
+ and other OS specific settings.
CEPH_DIR The Ceph source code directory. The same as the script.
BUILD_DIR The directory where the $CEPH_DIR/build
generated artifacts will be
@@ -63,6 +65,16 @@ Debug binaries can be quite large, the following parameters may be passed to
CFLAGS="-g1" CXXFLAGS="-g1" CMAKE_BUILD_TYPE="Release"
+``win32_build.sh`` will fetch dependencies using ``win32_deps_build.sh``. If
+all dependencies are successfully prepared, this potentially time consuming
+step will be skipped by subsequent builds. Be aware that you may have to do
+a clean build (using the ``CLEAN_BUILD`` flag) when the dependencies change
+(e.g. after switching to a more recent Ceph version by doing a ``git pull``).
+
+Make sure to explicitly pass the "OS" parameter when directly calling
+``win32_deps_build.sh``. Also, be aware of the fact that it will use the distro
+specific package manager, which will require privileged rights.
+
Current status
--------------
diff --git a/cmake/toolchains/mingw32.cmake b/cmake/toolchains/mingw32.cmake
deleted file mode 100644
index e363a6897a2..00000000000
--- a/cmake/toolchains/mingw32.cmake
+++ /dev/null
@@ -1,24 +0,0 @@
-set(CMAKE_SYSTEM_NAME Windows)
-set(TOOLCHAIN_PREFIX x86_64-w64-mingw32)
-set(CMAKE_SYSTEM_PROCESSOR x86_64)
-
-# We'll need to use posix threads in order to use
-# C++11 features, such as std::thread.
-set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}-gcc-posix)
-set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}-g++-posix)
-set(CMAKE_RC_COMPILER ${TOOLCHAIN_PREFIX}-windres)
-
-set(CMAKE_FIND_ROOT_PATH /usr/${TOOLCHAIN_PREFIX} /usr/lib/gcc/${TOOLCHAIN_PREFIX}/7.3-posix)
-set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
-# TODO: consider switching this to "ONLY". The issue with
-# that is that all our libs should then be under
-# CMAKE_FIND_ROOT_PATH and CMAKE_PREFIX_PATH would be ignored.
-set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH)
-set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE BOTH)
-
-# Some functions (e.g. localtime_r) will not be available unless we set
-# the following flag.
-add_definitions(-D_POSIX=1)
-add_definitions(-D_POSIX_C_SOURCE=1)
-add_definitions(-D_POSIX_=1)
-add_definitions(-D_POSIX_THREADS=1)
diff --git a/mingw_conf.sh b/mingw_conf.sh
new file mode 100644
index 00000000000..4d66a075775
--- /dev/null
+++ b/mingw_conf.sh
@@ -0,0 +1,81 @@
+# MINGW Settings:
+# Due to inconsistencies between distributions, mingw versions, binaries,
+# and directories must be determined (or defined) prior to building.
+
+# This script expects the following variables:
+# * OS - currently ubuntu or suse. In the future we may attempt to detect the
+# platform.
+# * MINGW_CMAKE_FILE - if set, a cmake toolchain file will be created
+# * MINGW_POSIX_FLAGS - if set, Mingw Posix compatibility mode will be
+# enabled by defining the according flags.
+
+# -Common mingw settings-
+MINGW_PREFIX="x86_64-w64-mingw32-"
+MINGW_BASE="x86_64-w64-mingw32"
+MINGW_CPP="${MINGW_BASE}-c++"
+MINGW_DLLTOOL="${MINGW_BASE}-dlltool"
+MINGW_WINDRES="${MINGW_BASE}-windres"
+MINGW_STRIP="${MINGW_BASE}-strip"
+# -Distribution specific mingw settings-
+case "$OS" in
+ ubuntu)
+ mingwPosix="-posix"
+ mingwLibDir="/usr/lib/gcc"
+ mingwVersion="$(${MINGW_CPP}${mingwPosix} -dumpversion)"
+ mingwTargetLibDir="${mingwLibDir}/${MINGW_BASE}/${mingwVersion}"
+ mingwLibpthreadDir="/usr/${MINGW_BASE}/lib"
+ PTW32Include=/usr/share/mingw-w64/include
+ PTW32Lib=/usr/x86_64-w64-mingw32/lib
+ ;;
+ suse)
+ mingwPosix=""
+ mingwLibDir="/usr/lib64/gcc"
+ mingwVersion="$(${MINGW_CPP}${mingwPosix} -dumpversion)"
+ mingwTargetLibDir="/usr/${MINGW_BASE}/sys-root/mingw/bin"
+ mingwLibpthreadDir="$mingwTargetLibDir"
+ PTW32Include=/usr/x86_64-w64-mingw32/sys-root/mingw/include
+ PTW32Lib=/usr/x86_64-w64-mingw32/sys-root/mingw/lib
+ ;;
+ *)
+ echo "$ID is unknown, automatic mingw configuration is not possible."
+ exit 1
+ ;;
+esac
+# -Common mingw settings, dependent upon distribution specific settings-
+MINGW_FIND_ROOT_LIB_PATH="${mingwLibDir}/\${TOOLCHAIN_PREFIX}/${mingwVersion}"
+MINGW_CC="${MINGW_BASE}-gcc${mingwPosix}"
+MINGW_CXX="${MINGW_BASE}-g++${mingwPosix}"
+# End MINGW configuration
+
+
+if [[ -n $MINGW_CMAKE_FILE ]]; then
+ cat > $MINGW_CMAKE_FILE <<EOL
+set(CMAKE_SYSTEM_NAME Windows)
+set(TOOLCHAIN_PREFIX ${MINGW_BASE})
+set(CMAKE_SYSTEM_PROCESSOR x86_64)
+
+# We'll need to use posix threads in order to use
+# C++11 features, such as std::thread.
+set(CMAKE_C_COMPILER \${TOOLCHAIN_PREFIX}-gcc${mingwPosix})
+set(CMAKE_CXX_COMPILER \${TOOLCHAIN_PREFIX}-g++${mingwPosix})
+set(CMAKE_RC_COMPILER \${TOOLCHAIN_PREFIX}-windres)
+
+set(CMAKE_FIND_ROOT_PATH /usr/\${TOOLCHAIN_PREFIX} ${MINGW_FIND_ROOT_LIB_PATH})
+set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
+# TODO: consider switching this to "ONLY". The issue with
+# that is that all our libs should then be under
+# CMAKE_FIND_ROOT_PATH and CMAKE_PREFIX_PATH would be ignored.
+set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH)
+set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE BOTH)
+EOL
+ if [[ -n $MINGW_POSIX_FLAGS ]]; then
+ cat >> $MINGW_CMAKE_FILE <<EOL
+# Some functions (e.g. localtime_r) will not be available unless we set
+# the following flag.
+add_definitions(-D_POSIX=1)
+add_definitions(-D_POSIX_C_SOURCE=1)
+add_definitions(-D_POSIX_=1)
+add_definitions(-D_POSIX_THREADS=1)
+EOL
+ fi
+fi \ No newline at end of file
diff --git a/win32_build.sh b/win32_build.sh
index 81e7f99cf8e..d03ab831715 100755
--- a/win32_build.sh
+++ b/win32_build.sh
@@ -28,6 +28,24 @@ BUILD_ZIP=${BUILD_ZIP:-}
# Unfortunately we cannot use pdb symbols when cross compiling. cv2pdb
# well as llvm rely on mspdb*.dll in order to support this proprietary format.
STRIP_ZIPPED=${STRIP_ZIPPED:-}
+# Allow for OS specific customizations through the OS flag.
+# Valid options are currently "ubuntu" and "suse".
+
+OS=${OS}
+if [[ -z $OS ]]; then
+ if [[ -f /etc/os-release ]] && \
+ $(grep -q "^NAME=\".*SUSE.*\"" /etc/os-release); then
+ OS="suse"
+ elif [[ -f /etc/lsb-release ]] && \
+ $(grep -q "^DISTRIB_ID=Ubuntu" /etc/lsb-release); then
+ OS="ubuntu"
+ else
+ echo "Unsupported Linux distro, only SUSE and Ubuntu are currently \
+supported. Set the OS variable to override"
+ exit 1
+ fi
+fi
+export OS="$OS"
# We'll have to be explicit here since auto-detecting doesn't work
# properly when cross compiling.
@@ -70,13 +88,19 @@ fi
if [[ ! -f ${depsToolsetDir}/completed ]]; then
echo "Preparing dependencies: $DEPS_DIR"
- NUM_WORKERS=$NUM_WORKERS DEPS_DIR=$DEPS_DIR \
+ NUM_WORKERS=$NUM_WORKERS DEPS_DIR=$DEPS_DIR OS="$OS"\
"$SCRIPT_DIR/win32_deps_build.sh"
fi
mkdir -p $BUILD_DIR
cd $BUILD_DIR
+# Due to distribution specific mingw settings, the mingw.cmake file
+# must be built prior to running cmake.
+MINGW_CMAKE_FILE="$BUILD_DIR/mingw32.cmake"
+MINGW_POSIX_FLAGS=1
+source "$SCRIPT_DIR/mingw_conf.sh"
+
if [[ -z $SKIP_CMAKE ]]; then
# We'll need to cross compile Boost.Python before enabling
# "WITH_MGR".
@@ -98,7 +122,7 @@ fi
# symbols. Until we fix the dependencies (which are either unspecified
# or circular), we'll have to stick to static linking.
cmake -D CMAKE_PREFIX_PATH=$depsDirs \
- -D CMAKE_TOOLCHAIN_FILE="$CEPH_DIR/cmake/toolchains/mingw32.cmake" \
+ -D CMAKE_TOOLCHAIN_FILE="$MINGW_CMAKE_FILE" \
-D WITH_RDMA=OFF -D WITH_OPENLDAP=OFF \
-D WITH_GSSAPI=OFF -D WITH_FUSE=OFF -D WITH_XFS=OFF \
-D WITH_BLUESTORE=OFF -D WITH_LEVELDB=OFF \
@@ -139,10 +163,7 @@ if [[ -z $SKIP_BUILD ]]; then
fi
if [[ -z $SKIP_DLL_COPY ]]; then
- # Hopefully this path will be the same across distros.
- # This depends on the thread library, we're currently using posix.
- mingwVersion=`x86_64-w64-mingw32-c++-posix -dumpversion`
- mingwTargetLibDir="/usr/lib/gcc/x86_64-w64-mingw32/$mingwVersion"
+ # To adjust mingw paths, see 'mingw_conf.sh'.
required_dlls=(
$zlibDir/zlib1.dll
$lz4Dir/lib/dll/liblz4-1.dll
@@ -150,7 +171,7 @@ if [[ -z $SKIP_DLL_COPY ]]; then
$sslDir/bin/libssl-1_1-x64.dll
$mingwTargetLibDir/libstdc++-6.dll
$mingwTargetLibDir/libgcc_s_seh-1.dll
- /usr/x86_64-w64-mingw32/lib/libwinpthread-1.dll)
+ $mingwLibpthreadDir/libwinpthread-1.dll)
echo "Copying required dlls to $binDir."
cp ${required_dlls[@]} $binDir
fi
@@ -160,8 +181,8 @@ if [[ -n $BUILD_ZIP ]]; then
rm -rf $strippedBinDir
cp -r $binDir $strippedBinDir
echo "Stripping debug symbols from $strippedBinDir binaries."
- x86_64-w64-mingw32-strip $strippedBinDir/*.exe \
- $strippedBinDir/*.dll
+ $MINGW_STRIP $strippedBinDir/*.exe \
+ $strippedBinDir/*.dll
fi
echo "Building zip archive $ZIP_DEST."
zip -r $ZIP_DEST $strippedBinDir
diff --git a/win32_deps_build.sh b/win32_deps_build.sh
index 81c02d2e5ef..5b53891ce54 100755
--- a/win32_deps_build.sh
+++ b/win32_deps_build.sh
@@ -42,6 +42,11 @@ wnbdTag="master"
wnbdSrcDir="${depsSrcDir}/wnbd"
wnbdLibDir="${depsToolsetDir}/wnbd/lib"
+# Allow for OS specific customizations through the OS flag (normally
+# passed through from win32_build).
+# Valid options are currently "ubuntu" and "suse".
+OS=${OS:-"ubuntu"}
+
function _make() {
make -j $NUM_WORKERS $@
}
@@ -50,26 +55,24 @@ mkdir -p $DEPS_DIR
mkdir -p $depsToolsetDir
mkdir -p $depsSrcDir
-MINGW_CMAKE_FILE="$DEPS_DIR/mingw.cmake"
-cat > $MINGW_CMAKE_FILE <<EOL
-set(CMAKE_SYSTEM_NAME Windows)
-set(TOOLCHAIN_PREFIX x86_64-w64-mingw32)
-
-# We'll need to use posix threads in order to use
-# C++11 features, such as std::thread.
-set(CMAKE_C_COMPILER \${TOOLCHAIN_PREFIX}-gcc-posix)
-set(CMAKE_CXX_COMPILER \${TOOLCHAIN_PREFIX}-g++-posix)
-set(CMAKE_RC_COMPILER \${TOOLCHAIN_PREFIX}-windres)
-
-set(CMAKE_FIND_ROOT_PATH /usr/\${TOOLCHAIN_PREFIX} /usr/lib/gcc/\${TOOLCHAIN_PREFIX}/7.3-posix)
-set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
-set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH)
-set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE BOTH)
-EOL
-
-sudo apt-get -y install mingw-w64 cmake pkg-config python3-dev python3-pip \
+case "$OS" in
+ ubuntu)
+ sudo apt-get update
+ sudo apt-get -y install mingw-w64 cmake pkg-config python3-dev python3-pip \
autoconf libtool ninja-build zip
-sudo python3 -m pip install cython
+ sudo python3 -m pip install cython
+ ;;
+ suse)
+ for PKG in mingw64-cross-gcc-c++ mingw64-libgcc_s_seh1 mingw64-libstdc++6 \
+ cmake pkgconf python3-devel autoconf libtool ninja zip \
+ python3-Cython gcc patch wget git; do
+ rpm -q $PKG >/dev/null || zypper -n install $PKG
+ done
+ ;;
+esac
+
+MINGW_CMAKE_FILE="$DEPS_DIR/mingw.cmake"
+source "$SCRIPT_DIR/mingw_conf.sh"
cd $depsSrcDir
if [[ ! -d $zlibSrcDir ]]; then
@@ -77,7 +80,7 @@ if [[ ! -d $zlibSrcDir ]]; then
fi
cd $zlibSrcDir
# Apparently the configure script is broken...
-sed -e s/"PREFIX = *$"/"PREFIX = x86_64-w64-mingw32-"/ -i win32/Makefile.gcc
+sed -e s/"PREFIX = *$"/"PREFIX = ${MINGW_PREFIX}"/ -i win32/Makefile.gcc
_make -f win32/Makefile.gcc
_make BINARY_PATH=$zlibDir \
INCLUDE_PATH=$zlibDir/include \
@@ -91,9 +94,9 @@ if [[ ! -d $lz4Dir ]]; then
cd $lz4Dir; git checkout $lz4Tag
fi
cd $lz4Dir
-_make BUILD_STATIC=no CC=x86_64-w64-mingw32-gcc \
- DLLTOOL=x86_64-w64-mingw32-dlltool \
- WINDRES=x86_64-w64-mingw32-windres \
+_make BUILD_STATIC=no CC=${MINGW_CC%-posix*} \
+ DLLTOOL=${MINGW_DLLTOOL} \
+ WINDRES=${MINGW_WINDRES} \
TARGET_OS=Windows_NT
cd $depsSrcDir
@@ -102,7 +105,7 @@ if [[ ! -d $sslSrcDir ]]; then
fi
cd $sslSrcDir
mkdir -p $sslDir
-CROSS_COMPILE="x86_64-w64-mingw32-" ./Configure \
+CROSS_COMPILE="${MINGW_PREFIX}" ./Configure \
mingw64 shared --prefix=$sslDir
_make depend
_make
@@ -116,7 +119,7 @@ fi
cd $curlSrcDir
./buildconf
./configure --prefix=$curlDir --with-ssl=$sslDir --with-zlib=$zlibDir \
- --host=x86_64-w64-mingw32
+ --host=${MINGW_BASE}
_make
_make install
@@ -127,7 +130,7 @@ if [[ ! -d $boostSrcDir ]]; then
fi
cd $boostSrcDir
-echo "using gcc : mingw32 : x86_64-w64-mingw32-g++-posix ;" > user-config.jam
+echo "using gcc : mingw32 : ${MINGW_CXX} ;" > user-config.jam
# Workaround for https://github.com/boostorg/thread/issues/156
# Older versions of mingw provided a different pthread lib.
@@ -138,8 +141,8 @@ 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
+export PTW32_INCLUDE=${PTW32Include}
+export PTW32_LIB=${PTW32Lib}
# Fix getting Windows page size
# TODO: send this upstream and maybe use a fork until it merges.
@@ -266,7 +269,7 @@ fi
mkdir -p $backtraceSrcDir/build
cd $backtraceSrcDir/build
../configure --prefix=$backtraceDir --exec-prefix=$backtraceDir \
- --host x86_64-w64-mingw32 --enable-host-shared
+ --host ${MINGW_BASE} --enable-host-shared
_make LDFLAGS="-no-undefined"
_make install
cp $backtraceDir/lib/libbacktrace.a $backtraceDir/lib/libbacktrace.dll.a
@@ -329,7 +332,7 @@ rexec@24rresvport@4
s_perror@8sethostname@8
EOF
-x86_64-w64-mingw32-dlltool -d $winLibDir/mswsock.def \
- -l $winLibDir/libmswsock.a
+$MINGW_DLLTOOL -d $winLibDir/mswsock.def \
+ -l $winLibDir/libmswsock.a
touch $depsToolsetDir/completed