1
0
mirror of https://github.com/ceph/ceph synced 2025-04-01 23:02:17 +00:00

Merge PR into master

* refs/pull/32776/head:
	win32*.sh: fetch WNBD dependency
	win32*.sh: bump win32 boost dependency
	cmake: skip osd, Lua and neorados on Windows
	win32*.sh: improve lib handling
	win32*.sh: update openssl location
	win32*.sh: cleanup dependency build dir when targetting Windows
	win32*.sh: Strip binaries individually
	win32*.sh: Cleanup zip archive creation
	cmake,win32*.sh: Add OS=(ubuntu|suse) flag, for distro settings
	win32*.sh: Use nproc for CPU count when targeting win32
	test: Include compat.h to find uid_t/gid_t/gidlist when cross compiling
	win32*.sh: improve win32 dependency check
	win32*.sh: isolate network operations when building win32 dependencies
	cmake: drop Python dependency when targeting Windows
	win32*.sh: cleanup Windows build script
	win32*.sh: fix patch command
	win32*.sh: update Windows build scripts and readme

Reviewed-by: Jason Dillaman <dillaman@redhat.com>
This commit is contained in:
Jan Fajerski 2021-01-05 12:50:37 +01:00
commit 2fa311a462
10 changed files with 453 additions and 124 deletions

View File

@ -448,6 +448,7 @@ endif (WITH_RADOSGW)
#option for CephFS
option(WITH_CEPHFS "CephFS is enabled" ON)
if(NOT WIN32)
# Please specify 3.[0-7] if you want to build with a certain version of python3.
set(WITH_PYTHON3 "3" CACHE STRING "build with specified python3 version")
if(NOT WITH_PYTHON3 STREQUAL "3")
@ -470,6 +471,7 @@ if(WITH_MGR)
endif()
# Boost dependency check deferred to Boost section
endif(WITH_MGR)
endif(NOT WIN32)
option(WITH_THREAD_SAFE_RES_QUERY "res_query is thread safe" OFF)
if(WITH_THREAD_SAFE_RES_QUERY)

View File

@ -5,6 +5,7 @@ Ceph Windows support is currently a work in progress. For now, the main focus
is the client side, allowing Windows hosts to consume rados, rbd and cephfs
resources.
.. _building:
Building
--------
@ -15,6 +16,10 @@ 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 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
The script accepts the following flags:
@ -22,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
@ -33,14 +40,44 @@ NUM_WORKERS The number of workers to use The number of vcpus
CLEAN_BUILD Clean the build directory.
SKIP_BUILD Run cmake without actually
performing the build.
SKIP_TESTS Skip building Ceph tests.
BUILD_ZIP Build a zip archive containing
the generated binaries.
ZIP_DEST Where to put a zip containing $BUILD_DIR/ceph.zip
the generated binaries.
STRIP_ZIPPED If set, the zip will contain
stripped binaries.
============ =============================== ===============================
In order to build debug binaries as well as an archive containing stripped
binaries that may be easily moved around, one may use the following:
.. code:: bash
BUILD_ZIP=1 STRIP_ZIPPED=1 SKIP_TESTS=1 ./win32_build.sh
In order to disable a flag, such as ``CLEAN_BUILD``, leave it undefined.
Debug binaries can be quite large, the following parameters may be passed to
``win32_build.sh`` to reduce the amount of debug information:
.. code:: bash
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
--------------
The rados and rbd binaries and libs compile successfully and can be used on
Windows, successfully connecting to the cluster and consuming pools.
Ceph filesystems can be mounted using the ``ceph-dokan`` command, which
requires the Dokany package to be installed. Note that dokany is a well
maintained fork of the Dokan project, allowing filesystems to be implemented
@ -85,7 +122,10 @@ Cinder to be attached to Hyper-V VMs managed by OpenStack Nova.
Installing
----------
Soon we're going to provide an MSI installed for Ceph. For now, unzip the
The following project allows building an MSI installer that bundles ``ceph`` and
the ``WNBD`` driver: https://github.com/cloudbase/ceph-windows-installer
In order to manually install ``ceph``, start by unzipping the
binaries that you may have obtained by following the building_ step.
You may want to update the environment PATH variable, including the Ceph
@ -139,8 +179,7 @@ also copy your keyring file to the specified location and make sure
that the configured directories exist (e.g. ``C:\ProgramData\ceph\out``).
Please use slashes ``/`` instead of backslashes ``\`` as path separators
within ``ceph.conf`` for the time being. Also, don't forget to include a
newline at the end of the file, Ceph will complain otherwise.
within ``ceph.conf`` for the time being.
.. _windows_service:
Windows service
@ -260,10 +299,10 @@ The following sample imports an RBD image and boots a Hyper-V VM using it.
# Let's give it a hefty 100MB size.
rbd resize cirros-0.5.1-x86_64-disk.raw --size=100MB
rbd-wnbd map cirros-0.5.1-x86_64-disk.raw
rbd device map cirros-0.5.1-x86_64-disk.raw
# Let's have a look at the mappings.
rbd-wnbd list
rbd device list
Get-Disk
$mappingJson = rbd-wnbd show cirros-0.5.1-x86_64-disk.raw --format=json
@ -286,7 +325,7 @@ initializes a partition.
.. code:: PowerShell
rbd create blank_image --size=1G
rbd-wnbd map blank_image
rbd device map blank_image
$mappingJson = rbd-wnbd show blank_image --format=json
$mappingJson = $mappingJson | ConvertFrom-Json
@ -301,3 +340,73 @@ initializes a partition.
Initialize-Disk -PassThru | `
New-Partition -AssignDriveLetter -UseMaximumSize | `
Format-Volume -Force -Confirm:$false
Troubleshooting
...............
Wnbd
~~~~
For ``WNBD`` troubleshooting, please check this page: https://github.com/cloudbase/wnbd#troubleshooting
Privileges
~~~~~~~~~~
Most ``rbd-wnbd`` and ``rbd device`` commands require privileged rights. Make
sure to use an elevated PowerShell or CMD command prompt.
Crash dumps
~~~~~~~~~~~
Userspace crash dumps can be placed at a configurable location and enabled for all
applications or just predefined ones, as outlined here:
https://docs.microsoft.com/en-us/windows/win32/wer/collecting-user-mode-dumps.
Whenever a Windows application crashes, an event will be submitted to the ``Application``
Windows Event Log, having Event ID 1000. The entry will also include the process id,
the faulting module name and path as well as the exception code.
Please note that in order to analyze crash dumps, the debug symbols are required.
We're currently buidling Ceph using ``MinGW``, so by default ``DWARF`` symbols will
be embedded in the binaries. ``windbg`` does not support such symbols but ``gdb``
can be used.
``gdb`` can debug running Windows processes but it cannot open Windows minidumps.
The following ``gdb`` fork may be used until this functionality is merged upstream:
https://github.com/ssbssa/gdb/releases. As an alternative, ``DWARF`` symbols
can be converted using ``cv2pdb`` but be aware that this tool has limitted C++
support.
ceph tool
~~~~~~~~~
The ``ceph`` Python tool can't be used on Windows natively yet. With minor
changes it may run, but the main issue is that Python doesn't currently allow
using ``AF_UNIX`` on Windows: https://bugs.python.org/issue33408
As an alternative, the ``ceph`` tool can be used through Windows Subsystem
for Linux (WSL). For example, running Windows RBD daemons may be contacted by
using:
.. code:: bash
ceph daemon /mnt/c/ProgramData/ceph/out/ceph-client.admin.61436.1209215304.asok help
IO counters
~~~~~~~~~~~
Along with the standard RBD perf counters, the ``libwnbd`` IO counters may be
retrieved using:
.. code:: PowerShell
rbd-wnbd stats $imageName
At the same time, WNBD driver counters can be fetched using:
.. code:: PowerShell
wnbd-client stats $mappingId
Note that the ``wnbd-client`` mapping identifier will be the full RBD image spec
(the ``device`` column of the ``rbd device list`` output).

View File

@ -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)

81
mingw_conf.sh Normal file
View File

@ -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

View File

@ -556,7 +556,9 @@ endif(${WITH_LTTNG})
add_subdirectory(global)
find_package(Lua 5.3 REQUIRED)
if(NOT WIN32)
find_package(Lua 5.3 REQUIRED)
endif()
# rados object classes
add_subdirectory(cls)
@ -594,10 +596,12 @@ if(NOT CEPH_BUILD_VIRTUALENV)
set(CEPH_BUILD_VIRTUALENV ${CMAKE_BINARY_DIR})
endif()
if(NOT WIN32)
add_subdirectory(pybind)
add_subdirectory(ceph-volume)
add_subdirectory(python-common)
add_subdirectory(cephadm)
endif(NOT WIN32)
# Monitor
add_subdirectory(mon)
@ -627,10 +631,9 @@ endif()
add_subdirectory(kv)
add_subdirectory(os)
if(NOT WIN32)
add_subdirectory(blk)
endif()
add_subdirectory(osd)
set(ceph_osd_srcs
@ -654,6 +657,8 @@ set_target_properties(ceph-osd PROPERTIES
INSTALL_RPATH "")
install(TARGETS ceph-osd DESTINATION bin)
endif(NOT WIN32)
if (WITH_CEPHFS)
add_subdirectory(mds)
set(ceph_mds_srcs
@ -875,6 +880,7 @@ configure_file(
${CMAKE_BINARY_DIR}/include/acconfig.h
)
if(NOT WIN32)
# Everything you need to spin up a cluster with vstart.sh
add_custom_target(vstart-base DEPENDS
ceph-osd
@ -911,6 +917,7 @@ endif()
if(WITH_MGR)
add_dependencies(vstart ceph-volume-venv-setup)
endif()
endif(NOT WIN32)
# Everything you need to run CephFS tests
add_custom_target(cephfs_testing DEPENDS

View File

@ -231,21 +231,23 @@ if (WITH_CEPHFS)
endif (WITH_CEPHFS)
# cls_lua
set(cls_lua_srcs
lua/cls_lua.cc
lua/lua_bufferlist.cc)
add_library(cls_lua SHARED ${cls_lua_srcs})
set_target_properties(cls_lua PROPERTIES
VERSION "1.0.0"
SOVERSION "1"
INSTALL_RPATH ""
CXX_VISIBILITY_PRESET hidden)
install(TARGETS cls_lua DESTINATION ${cls_dir})
target_link_libraries(cls_lua
${LUA_LIBRARIES}
json_spirit)
target_include_directories(cls_lua PRIVATE "${LUA_INCLUDE_DIR}")
if (NOT WIN32)
# cls_lua
set(cls_lua_srcs
lua/cls_lua.cc
lua/lua_bufferlist.cc)
add_library(cls_lua SHARED ${cls_lua_srcs})
set_target_properties(cls_lua PROPERTIES
VERSION "1.0.0"
SOVERSION "1"
INSTALL_RPATH ""
CXX_VISIBILITY_PRESET hidden)
install(TARGETS cls_lua DESTINATION ${cls_dir})
target_link_libraries(cls_lua
${LUA_LIBRARIES}
json_spirit)
target_include_directories(cls_lua PRIVATE "${LUA_INCLUDE_DIR}")
endif (NOT WIN32)
set(cls_lua_client_srcs
lua/cls_lua_client.cc)

View File

@ -13,6 +13,7 @@
*/
#include "gtest/gtest.h"
#include "include/compat.h"
#include "include/cephfs/libcephfs.h"
#include <sstream>

View File

@ -17,16 +17,15 @@ endif()
install(TARGETS rados DESTINATION bin)
if(NOT WIN32)
set(neorados_srcs
neorados.cc)
add_executable(neorados ${neorados_srcs})
target_include_directories(neorados PRIVATE
$<TARGET_PROPERTY:spawn,INTERFACE_INCLUDE_DIRECTORIES>)
set(neorados_srcs
neorados.cc)
add_executable(neorados ${neorados_srcs})
target_include_directories(neorados PRIVATE
$<TARGET_PROPERTY:spawn,INTERFACE_INCLUDE_DIRECTORIES>)
target_link_libraries(neorados libneorados spawn ${CMAKE_DL_LIBS})
#install(TARGETS neorados DESTINATION bin)
endif()
target_link_libraries(neorados libneorados spawn ${CMAKE_DL_LIBS})
#install(TARGETS neorados DESTINATION bin)
if(WITH_TESTS)
add_executable(ceph_scratchtool scratchtool.c)
target_link_libraries(ceph_scratchtool librados global)

View File

@ -1,20 +1,52 @@
#!/usr/bin/env bash
set -e
set -o pipefail
SCRIPT_DIR="$(dirname "$BASH_SOURCE")"
SCRIPT_DIR="$(realpath "$SCRIPT_DIR")"
num_vcpus=$(( $(lscpu -p | tail -1 | cut -d "," -f 1) + 1 ))
num_vcpus=$(nproc)
CEPH_DIR="${CEPH_DIR:-$SCRIPT_DIR}"
BUILD_DIR="${BUILD_DIR:-${CEPH_DIR}/build}"
DEPS_DIR="${DEPS_DIR:-$CEPH_DIR/build.deps}"
ZIP_DEST="${ZIP_DEST:-$BUILD_DIR/ceph.zip}"
CLEAN_BUILD=${CLEAN_BUILD:-}
SKIP_BUILD=${SKIP_BUILD:-}
# Usefull when packaging existing binaries.
SKIP_CMAKE=${SKIP_CMAKE:-}
SKIP_DLL_COPY=${SKIP_DLL_COPY:-}
SKIP_TESTS=${SKIP_TESTS:-}
SKIP_BINDIR_CLEAN=${SKIP_BINDIR_CLEAN:-}
NUM_WORKERS=${NUM_WORKERS:-$num_vcpus}
DEV_BUILD=${DEV_BUILD:-}
BUILD_ZIP=${BUILD_ZIP:-}
# By default, we'll build release binaries with debug symbols attached.
# If BUILD_ZIP and STRIP_ZIPPED are enabled, we'll strip the binaries
# that we're going to archive.
# 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.
@ -24,26 +56,27 @@ ALLOCATOR=${ALLOCATOR:-libc}
# -Wa,-mbig-obj does not help.
CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE:-RelWithDebInfo}
binDir="$BUILD_DIR/bin"
strippedBinDir="$BUILD_DIR/bin_stripped"
depsSrcDir="$DEPS_DIR/src"
depsToolsetDir="$DEPS_DIR/mingw"
generatorUsed="Unix Makefiles"
lz4Dir="${depsToolsetDir}/lz4"
sslDir="${depsToolsetDir}/openssl"
curlDir="${depsToolsetDir}/curl"
boostDir="${depsToolsetDir}/boost"
zlibDir="${depsToolsetDir}/zlib"
backtraceDir="${depsToolsetDir}/backtrace"
backtraceDir="${depsToolsetDir}/libbacktrace"
snappyDir="${depsToolsetDir}/snappy"
winLibDir="${depsToolsetDir}/windows/lib"
generatorUsed="Unix Makefiles"
wnbdSrcDir="${depsSrcDir}/wnbd"
wnbdLibDir="${depsToolsetDir}/wnbd/lib"
depsDirs="$lz4Dir;$curlDir;$sslDir;$boostDir;$zlibDir;$backtraceDir;$snappyDir"
depsDirs+=";$winLibDir"
# That's actually a dll, we may want to rename the file.
lz4Lib="${lz4Dir}/lib/liblz4.so.1.9.2"
lz4Lib="${lz4Dir}/lib/dll/liblz4-1.dll"
lz4Include="${lz4Dir}/lib"
curlLib="${curlDir}/lib/libcurl.dll.a"
curlInclude="${curlDir}/include"
@ -51,17 +84,29 @@ curlInclude="${curlDir}/include"
if [[ -n $CLEAN_BUILD ]]; then
echo "Cleaning up build dir: $BUILD_DIR"
rm -rf $BUILD_DIR
rm -rf $DEPS_DIR
fi
if [[ -z $SKIP_BINDIR_CLEAN ]]; then
echo "Cleaning up bin dir: $binDir"
rm -rf $binDir
fi
if [[ ! -d $DEPS_DIR ]]; then
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".
echo "Generating solution. Log: ${BUILD_DIR}/cmake.log"
@ -82,7 +127,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 \
@ -93,16 +138,15 @@ cmake -D CMAKE_PREFIX_PATH=$depsDirs \
-D WITH_CEPHFS=OFF -D WITH_MANPAGE=OFF \
-D WITH_MGR_DASHBOARD_FRONTEND=OFF -D WITH_SYSTEMD=OFF -D WITH_TESTS=OFF \
-D LZ4_INCLUDE_DIR=$lz4Include -D LZ4_LIBRARY=$lz4Lib \
-D Backtrace_Header="$backtraceDir/include/backtrace.h" \
-D Backtrace_INCLUDE_DIR="$backtraceDir/include" \
-D Backtrace_LIBRARY="$backtraceDir/lib/libbacktrace.dll.a" \
-D Boost_THREADAPI="pthread" \
-D Backtrace_LIBRARY="$backtraceDir/lib/libbacktrace.a" \
-D ENABLE_GIT_VERSION=$ENABLE_GIT_VERSION \
-D ALLOCATOR="$ALLOCATOR" -D CMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE \
-D WNBD_INCLUDE_DIRS="$wnbdSrcDir/include" \
-D WNBD_LIBRARIES="$wnbdLibDir/libwnbd.a" \
-G "$generatorUsed" \
$CEPH_DIR 2>&1 | tee "${BUILD_DIR}/cmake.log"
fi # [[ -z $SKIP_CMAKE ]]
if [[ -z $SKIP_BUILD ]]; then
echo "Building using $NUM_WORKERS workers. Log: ${BUILD_DIR}/build.log"
@ -122,3 +166,47 @@ if [[ -z $SKIP_BUILD ]]; then
make -j $NUM_WORKERS -C $target_subdir ${make_targets[$target_subdir]} 2>&1 | tee -a "${BUILD_DIR}/build.log"
done
fi
if [[ -z $SKIP_DLL_COPY ]]; then
# To adjust mingw paths, see 'mingw_conf.sh'.
required_dlls=(
$zlibDir/zlib1.dll
$lz4Dir/lib/dll/liblz4-1.dll
$sslDir/bin/libcrypto-1_1-x64.dll
$sslDir/bin/libssl-1_1-x64.dll
$mingwTargetLibDir/libstdc++-6.dll
$mingwTargetLibDir/libgcc_s_seh-1.dll
$mingwLibpthreadDir/libwinpthread-1.dll)
echo "Copying required dlls to $binDir."
cp ${required_dlls[@]} $binDir
fi
if [[ -n $BUILD_ZIP ]]; then
# Use a temp directory, in order to create a clean zip file
ZIP_TMPDIR=$(mktemp -d win_binaries.XXXXX)
if [[ -n $STRIP_ZIPPED ]]; then
echo "Stripping debug symbols from binaries."
rm -rf $strippedBinDir; mkdir $strippedBinDir
# Strip files individually, to save time and space
for file in $binDir/*.exe $binDir/*.dll; do
$MINGW_STRIP -o $strippedBinDir/$(basename $file) $file
done
# Copy any remaining files to the stripped directory
for file in $binDir/*; do
[[ ! -f $strippedBinDir/$(basename $file) ]] && \
cp $file $strippedBinDir
done
ln -s $strippedBinDir $ZIP_TMPDIR/ceph
else
ln -s $binDir $ZIP_TMPDIR/ceph
fi
echo "Building zip archive $ZIP_DEST."
# Include the README file in the archive
ln -s $CEPH_DIR/README.windows.rst $ZIP_TMPDIR/ceph/README.windows.rst
cd $ZIP_TMPDIR
[[ -f $ZIP_DEST ]] && rm $ZIP_DEST
zip -r $ZIP_DEST ceph
cd -
rm -rf $ZIP_TMPDIR/ceph/README.windows.rst $ZIP_TMPDIR
echo -e '\n WIN32 files zipped to: '$ZIP_DEST'\n'
fi

View File

@ -5,7 +5,7 @@ set -e
SCRIPT_DIR="$(dirname "$BASH_SOURCE")"
SCRIPT_DIR="$(realpath "$SCRIPT_DIR")"
num_vcpus=$(( $(lscpu -p | tail -1 | cut -d "," -f 1) + 1 ))
num_vcpus=$(nproc)
NUM_WORKERS=${NUM_WORKERS:-$num_vcpus}
DEPS_DIR="${DEPS_DIR:-$SCRIPT_DIR/build.deps}"
@ -15,22 +15,22 @@ depsToolsetDir="$DEPS_DIR/mingw"
lz4SrcDir="${depsSrcDir}/lz4"
lz4Dir="${depsToolsetDir}/lz4"
lz4Tag="v1.9.2"
sslVersion="1.1.1c"
sslTag="OpenSSL_1_1_1c"
sslDir="${depsToolsetDir}/openssl"
sslSrcDir="${depsSrcDir}/openssl-${sslVersion}"
sslSrcDir="${depsSrcDir}/openssl"
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"
boostUrl="https://dl.bintray.com/boostorg/release/1.73.0/source/boost_1_73_0.tar.gz"
boostSrcDir="${depsSrcDir}/boost_1_73_0"
boostDir="${depsToolsetDir}/boost"
zlibDir="${depsToolsetDir}/zlib"
zlibSrcDir="${depsSrcDir}/zlib"
backtraceDir="${depsToolsetDir}/backtrace"
backtraceSrcDir="${depsSrcDir}/backtrace"
backtraceDir="${depsToolsetDir}/libbacktrace"
backtraceSrcDir="${depsSrcDir}/libbacktrace"
snappySrcDir="${depsSrcDir}/snappy"
snappyDir="${depsToolsetDir}/snappy"
snappyTag="1.1.7"
@ -42,42 +42,50 @@ 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 $@
}
if [[ -d $DEPS_DIR ]]; then
echo "Cleaning up dependency build dir: $DEPS_DIR"
rm -rf $DEPS_DIR
fi
mkdir -p $DEPS_DIR
mkdir -p $depsToolsetDir
mkdir -p $depsSrcDir
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
;;
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"
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 \
autoconf libtool ninja-build
sudo python3 -m pip install cython
source "$SCRIPT_DIR/mingw_conf.sh"
cd $depsSrcDir
if [[ ! -d $zlibDir ]]; then
if [[ ! -d $zlibSrcDir ]]; then
git clone https://github.com/madler/zlib
fi
cd zlib
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 \
@ -88,20 +96,23 @@ _make BINARY_PATH=$zlibDir \
cd $depsToolsetDir
if [[ ! -d $lz4Dir ]]; then
git clone https://github.com/lz4/lz4
cd $lz4Dir; git checkout $lz4Tag
fi
cd lz4
git checkout $lz4Tag
_make BUILD_STATIC=no CC=x86_64-w64-mingw32-gcc \
DLLTOOL=x86_64-w64-mingw32-dlltool OS=Windows_NT
cd $lz4Dir
_make BUILD_STATIC=no CC=${MINGW_CC%-posix*} \
DLLTOOL=${MINGW_DLLTOOL} \
WINDRES=${MINGW_WINDRES} \
TARGET_OS=Windows_NT
cd $depsSrcDir
if [[ ! -d $sslSrcDir ]]; then
curl "https://www.openssl.org/source/openssl-${sslVersion}.tar.gz" | tar xz
git clone https://github.com/openssl/openssl
cd $sslSrcDir; git checkout $sslTag
fi
cd $sslSrcDir
mkdir -p $sslDir
CROSS_COMPILE="x86_64-w64-mingw32-" ./Configure \
mingw64 shared --prefix=$sslDir
CROSS_COMPILE="${MINGW_PREFIX}" ./Configure \
mingw64 shared --prefix=$sslDir --libdir="$sslDir/lib"
_make depend
_make
_make install
@ -109,12 +120,12 @@ _make install
cd $depsSrcDir
if [[ ! -d $curlSrcDir ]]; then
git clone https://github.com/curl/curl
cd $curlSrcDir && git checkout $curlTag
fi
cd $curlSrcDir
git checkout $curlTag
./buildconf
./configure --prefix=$curlDir --with-ssl=$sslDir --with-zlib=$zlibDir \
--host=x86_64-w64-mingw32
--host=${MINGW_BASE} --libdir="$curlDir/lib"
_make
_make install
@ -125,7 +136,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.
@ -136,14 +147,14 @@ 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.
# 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 <<EOL
patch -N boost/thread/pthread/thread_data.hpp <<EOL
--- boost/thread/pthread/thread_data.hpp 2019-10-11 15:26:15.678703586 +0300
+++ boost/thread/pthread/thread_data.hpp.new 2019-10-11 15:26:07.321463698 +0300
@@ -32,6 +32,10 @@
@ -171,7 +182,7 @@ cat | patch -N boost/thread/pthread/thread_data.hpp <<EOL
EOL
# Use pthread if requested
cat | patch -N boost/asio/detail/thread.hpp <<EOL
patch -N boost/asio/detail/thread.hpp <<EOL
--- boost/asio/detail/thread.hpp 2019-10-11 16:26:11.191094656 +0300
+++ boost/asio/detail/thread.hpp.new 2019-10-11 16:26:03.310542438 +0300
@@ -19,6 +19,8 @@
@ -214,7 +225,7 @@ 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 <<EOL
patch -N boost/asio/detail/socket_types.hpp <<EOL
--- boost/asio/detail/socket_types.hpp 2019-11-29 16:50:58.647125797 +0000
+++ boost/asio/detail/socket_types.hpp.new 2020-01-13 11:45:05.015104678 +0000
@@ -200,6 +200,8 @@
@ -227,7 +238,7 @@ cat | patch -N boost/asio/detail/socket_types.hpp <<EOL
# endif
typedef ::linger linger_type;
EOL
cat | patch -N boost/asio/detail/config.hpp <<EOL
patch -N boost/asio/detail/config.hpp <<EOL
--- boost/asio/detail/config.hpp 2019-11-29 16:50:58.691126211 +0000
+++ boost/asio/detail/config.hpp.new 2020-01-13 13:09:17.966771750 +0000
@@ -1142,13 +1142,9 @@
@ -247,6 +258,45 @@ cat | patch -N boost/asio/detail/config.hpp <<EOL
#endif // !defined(BOOST_ASIO_HAS_LOCAL_SOCKETS)
EOL
# TODO: drop this when switching to Boost>=1.75, it's unreleased as of 1.74.
patch -N boost/process/detail/windows/handle_workaround.hpp <<EOL
--- boost/process/detail/windows/handle_workaround.hpp
+++ boost/process/detail/windows/handle_workaround.hpp.new
@@ -198,20 +198,20 @@ typedef struct _OBJECT_TYPE_INFORMATION_ {
/*
-__kernel_entry NTSTATUS NtQuerySystemInformation(
+NTSTATUS NtQuerySystemInformation(
IN SYSTEM_INFORMATION_CLASS SystemInformationClass,
OUT PVOID SystemInformation,
IN ULONG SystemInformationLength,
OUT PULONG ReturnLength
);
*/
-typedef ::boost::winapi::NTSTATUS_ (__kernel_entry *nt_system_query_information_p )(
+typedef ::boost::winapi::NTSTATUS_ (*nt_system_query_information_p )(
SYSTEM_INFORMATION_CLASS_,
void *,
::boost::winapi::ULONG_,
::boost::winapi::PULONG_);
/*
-__kernel_entry NTSYSCALLAPI NTSTATUS NtQueryObject(
+NTSYSCALLAPI NTSTATUS NtQueryObject(
HANDLE Handle,
OBJECT_INFORMATION_CLASS ObjectInformationClass,
PVOID ObjectInformation,
@@ -220,7 +220,7 @@ __kernel_entry NTSYSCALLAPI NTSTATUS NtQueryObject(
);
*/
-typedef ::boost::winapi::NTSTATUS_ (__kernel_entry *nt_query_object_p )(
+typedef ::boost::winapi::NTSTATUS_ (*nt_query_object_p )(
::boost::winapi::HANDLE_,
OBJECT_INFORMATION_CLASS_,
void *,
EOL
./bootstrap.sh
./b2 install --user-config=user-config.jam toolset=gcc-mingw32 \
@ -261,21 +311,21 @@ cd $depsSrcDir
if [[ ! -d $backtraceSrcDir ]]; then
git clone https://github.com/ianlancetaylor/libbacktrace
fi
mkdir libbacktrace/build
cd libbacktrace/build
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 \
--libdir="$backtraceDir/lib"
_make LDFLAGS="-no-undefined"
_make install
cp $backtraceDir/lib/libbacktrace.a $backtraceDir/lib/libbacktrace.dll.a
cd $depsSrcDir
if [[ ! -d $snappySrcDir ]]; then
git clone https://github.com/google/snappy
cd $snappySrcDir && git checkout $snappyTag
fi
mkdir -p snappy/build
cd snappy && git checkout $snappyTag
cd build
mkdir -p $snappySrcDir/build
cd $snappySrcDir/build
cmake -DCMAKE_INSTALL_PREFIX=$snappyDir \
-DCMAKE_BUILD_TYPE=Release \
@ -327,5 +377,19 @@ 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
cd $depsSrcDir
if [[ ! -d $wnbdSrcDir ]]; then
git clone $wnbdUrl
cd $wnbdSrcDir && git checkout $wnbdTag
fi
cd $wnbdSrcDir
mkdir -p $wnbdLibDir
$MINGW_DLLTOOL -d $wnbdSrcDir/libwnbd/libwnbd.def \
-D libwnbd.dll \
-l $wnbdLibDir/libwnbd.a
touch $depsToolsetDir/completed