Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,19 @@ if(WIN32)
# the targeted Windows version. The availability of certain functions and
# structures will depend on it.
set(WIN32_WINNT "0x0A00" CACHE STRING "Targeted Windows version.")
# In order to avoid known winpthread issues, we're using the boost
# shared mutex implementation.
# https://github.com/msys2/MINGW-packages/issues/3319
add_definitions(
-D_WIN32_WINNT=${WIN32_WINNT}
-DFMT_USE_TZSET=0
-DBOOST_THREAD_PROVIDES_GENERIC_SHARED_MUTEX_ON_WIN
-DBOOST_THREAD_V2_SHARED_MUTEX
)
# In order to avoid known winpthread issues, we're using the Boost
# shared mutex implementation. This isn't required with llvm/libc++.
# https://github.com/msys2/MINGW-packages/issues/3319
if(CMAKE_CXX_COMPILER_ID STREQUAL GNU)
add_definitions(
-DBOOST_THREAD_PROVIDES_GENERIC_SHARED_MUTEX_ON_WIN
-DBOOST_THREAD_V2_SHARED_MUTEX
)
endif()
set(Boost_THREADAPI "win32")
endif()

Expand Down
2 changes: 2 additions & 0 deletions README.windows.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ Flag Description Default value
================= =============================== ===============================
OS Host OS distribution, for mingw ubuntu (also valid: suse)
and other OS specific settings.
TOOLCHAIN Mingw toolchain: mingw-llvm or mingw-llvm
mingw-gcc.
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
Expand Down
130 changes: 86 additions & 44 deletions mingw_conf.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env bash

# MINGW Settings:
# Due to inconsistencies between distributions, mingw versions, binaries,
# and directories must be determined (or defined) prior to building.
Expand All @@ -8,6 +10,16 @@
# * 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.
# * USE_MINGW_LLVM - allows using the mingw llvm toolchain
# * MINGW_LLVM_DIR - allows specifying the mingw-llvm toolchain location.
# If unset, we'll use the default path from build.deps.

SCRIPT_DIR="$(dirname "$BASH_SOURCE")"
SCRIPT_DIR="$(realpath "$SCRIPT_DIR")"

if [[ -n $USE_MINGW_LLVM ]]; then
MINGW_LLVM_DIR=${MINGW_LLVM_DIR:-"$SCRIPT_DIR/build.deps/mingw-llvm"}
fi

# -Common mingw settings-
MINGW_PREFIX="x86_64-w64-mingw32-"
Expand All @@ -17,60 +29,82 @@ MINGW_DLLTOOL="${MINGW_BASE}-dlltool"
MINGW_WINDRES="${MINGW_BASE}-windres"
MINGW_STRIP="${MINGW_BASE}-strip"
MINGW_OBJCOPY="${MINGW_BASE}-objcopy"
# -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
;;
rhel)
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
;;
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}"

if [[ -n $USE_MINGW_LLVM ]]; then
# This package isn't currently provided by Linux distributions, we're
# fetching it from Github.
export PATH="$MINGW_LLVM_DIR/bin:$PATH"
Comment thread
idryomov marked this conversation as resolved.
Resolved
mingwPosix=""
mingwVersion="$(${MINGW_CPP}${mingwPosix} -dumpversion)"
mingwX64IncludeDir="$MINGW_LLVM_DIR/x86_64-w64-mingw32/include"
mingwX64BinDir="$MINGW_LLVM_DIR/x86_64-w64-mingw32/bin"
mingwX64LibDir="$MINGW_LLVM_DIR/x86_64-w64-mingw32/lib"
mingwTargetLibDir="$mingwX64BinDir"
mingwLibpthreadDir="$mingwX64BinDir"
PTW32Include="$mingwX64IncludeDir"
PTW32Lib="$mingwX64LibDir"

MINGW_CC="${MINGW_BASE}-clang${mingwPosix}"
MINGW_CXX="${MINGW_BASE}-clang++${mingwPosix}"

MINGW_FIND_ROOT_PATH="$MINGW_LLVM_DIR/x86_64-w64-mingw32"
else
# -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
;;
rhel)
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
;;
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
MINGW_CC="${MINGW_BASE}-gcc${mingwPosix}"
MINGW_CXX="${MINGW_BASE}-g++${mingwPosix}"

# -Common mingw settings, dependent upon distribution specific settings-
MINGW_FIND_ROOT_LIB_PATH="${mingwLibDir}/${MINGW_BASE}/${mingwVersion}"
MINGW_FIND_ROOT_PATH="/usr/${MINGW_BASE} ${MINGW_FIND_ROOT_LIB_PATH}"
fi
# 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_C_COMPILER ${MINGW_CC})
Comment thread
petrutlucian94 marked this conversation as resolved.
Resolved
set(CMAKE_CXX_COMPILER ${MINGW_CXX})
set(CMAKE_RC_COMPILER ${MINGW_WINDRES})

set(CMAKE_FIND_ROOT_PATH /usr/\${TOOLCHAIN_PREFIX} ${MINGW_FIND_ROOT_LIB_PATH})
set(CMAKE_FIND_ROOT_PATH ${MINGW_FIND_ROOT_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
Expand All @@ -88,4 +122,12 @@ add_definitions(-D_POSIX_=1)
add_definitions(-D_POSIX_THREADS=1)
EOL
fi
fi

if [[ -n $USE_MINGW_LLVM ]]; then
cat >> $MINGW_CMAKE_FILE <<EOL
add_definitions(-I$mingwX64IncludeDir)
add_definitions(-march=native)
add_definitions(-Wno-unknown-attributes)
EOL
fi
fi
8 changes: 6 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,9 @@ else()
set(old_BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS})
set(BUILD_SHARED_LIBS FALSE)
add_subdirectory(fmt)
if (WITH_FMT_HEADER_ONLY)
add_library(fmt::fmt ALIAS fmt-header-only)
Comment thread
petrutlucian94 marked this conversation as resolved.
Resolved
endif()
set(BUILD_SHARED_LIBS ${old_BUILD_SHARED_LIBS})
unset(old_BUILD_SHARED_LIBS)
include_directories(SYSTEM "${CMAKE_SOURCE_DIR}/src/fmt/include")
Expand Down Expand Up @@ -567,7 +570,7 @@ endif()
set_target_properties(ceph-common PROPERTIES
SOVERSION 2
SKIP_RPATH TRUE)
if(NOT APPLE AND NOT FREEBSD)
if(NOT APPLE AND NOT FREEBSD AND NOT WIN32)
# Apple uses Mach-O, not ELF. so this option does not apply to APPLE.
#
# prefer the local symbol definitions when binding references to global
Expand Down Expand Up @@ -811,7 +814,8 @@ if(WITH_LIBCEPHFS)
OUTPUT_NAME cephfs
VERSION 2.0.0
SOVERSION 2)
if(NOT APPLE)
if(NOT APPLE AND NOT
(WIN32 AND CMAKE_CXX_COMPILER_ID STREQUAL Clang))
Comment thread
petrutlucian94 marked this conversation as resolved.
Resolved
foreach(name ceph-common client osdc)
set_property(TARGET cephfs APPEND_STRING PROPERTY
LINK_FLAGS " -Wl,--exclude-libs,lib${name}.a")
Expand Down
2 changes: 1 addition & 1 deletion src/SimpleRADOSStriper.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ class [[gnu::visibility("default")]] SimpleRADOSStriper
std::thread lock_keeper;
std::condition_variable lock_keeper_cvar;
std::mutex lock_keeper_mutex;
time last_renewal = time::min();
time last_renewal = clock::zero();
std::chrono::milliseconds lock_keeper_interval{2000};
std::chrono::milliseconds lock_keeper_timeout{30000};
std::atomic<bool> blocklisted = false;
Expand Down
2 changes: 1 addition & 1 deletion src/arch/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ elseif(HAVE_PPC64LE OR HAVE_PPC64 OR HAVE_PPC)
list(APPEND arch_srcs ppc.c)
endif()

add_library(arch STATIC ${arch_srcs})
add_library(arch OBJECT ${arch_srcs})
3 changes: 1 addition & 2 deletions src/client/Client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6963,10 +6963,9 @@ void Client::tick()
void Client::start_tick_thread()
{
upkeeper = std::thread([this]() {
using time = ceph::coarse_mono_time;
using sec = std::chrono::seconds;

auto last_tick = time::min();
auto last_tick = clock::zero();

std::unique_lock cl(client_lock);
while (!tick_thread_stopped) {
Expand Down
3 changes: 2 additions & 1 deletion src/common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,8 @@ elseif(HAVE_ARMV8_CRC)
crc32c_aarch64.c)
endif(HAVE_INTEL)

add_library(crc32 STATIC ${crc32_srcs})
add_library(crc32 OBJECT ${crc32_srcs})

if(HAVE_ARMV8_CRC)
set_target_properties(crc32 PROPERTIES
COMPILE_FLAGS "${CMAKE_C_FLAGS} ${ARMV8_CRC_COMPILE_FLAGS}")
Expand Down
2 changes: 1 addition & 1 deletion src/common/Thread.cc
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ std::string get_thread_name(const std::thread& t) {

void kill(std::thread& t, int signal)
{
auto r = pthread_kill(t.native_handle(), signal);
auto r = ceph_pthread_kill(t.native_handle(), signal);
if (r != 0) {
throw std::system_error(r, std::generic_category());
}
Expand Down
16 changes: 14 additions & 2 deletions src/common/Timer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,20 @@ void CommonSafeTimer<Mutex>::timer_thread()
auto p = schedule.begin();

// is the future now?
if (p->first > now)
break;
#if defined(_WIN32)
if (p->first - now > std::chrono::milliseconds(1)) {
// std::condition_variable::wait_for uses SleepConditionVariableSRW
// on Windows, which has millisecond precision. Deltas <1ms will
// lead to busy loops, which should be avoided. This situation is
// quite common since "wait_for" often returns ~1ms earlier than
// requested.
break;
}
#else // !_WIN32
if (p->first > now) {
break;
}
#endif

Context *callback = p->second;
events.erase(callback);
Expand Down
4 changes: 2 additions & 2 deletions src/common/async/waiter.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,12 @@ class rvalue_reference_wrapper {
}

template<typename... Args>
std::result_of_t<T&(Args&&...)> operator ()(Args&&... args ) const {
auto operator()(Args&&... args) const {
return (*p)(std::forward<Args>(args)...);
}

template<typename... Args>
std::result_of_t<T&&(Args&&...)> operator ()(Args&&... args ) {
auto operator()(Args&&... args) {
return std::move(*p)(std::forward<Args>(args)...);
}

Expand Down
4 changes: 2 additions & 2 deletions src/common/ceph_mutex.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ namespace ceph {
// The winpthreads shared mutex implementation is broken.
// We'll use boost::shared_mutex instead.
// https://github.com/msys2/MINGW-packages/issues/3319
#if __MINGW32__
#if defined(__MINGW32__) && !defined(__clang__)
#include <boost/thread/shared_mutex.hpp>
#else
#include <shared_mutex>
Expand All @@ -163,7 +163,7 @@ namespace ceph {
typedef std::recursive_mutex recursive_mutex;
typedef std::condition_variable condition_variable;

#if __MINGW32__
#if defined(__MINGW32__) && !defined(__clang__)
typedef boost::shared_mutex shared_mutex;
#else
typedef std::shared_mutex shared_mutex;
Expand Down
Loading