cmake: fix mingw-llvm shared linking

mingw-llvm can't handle the '--exclude-libs' linker flag, so
we'll have to skip it.

At the same time, cmake can't locate the boost shared libs as the
import libs are not generated when using mingw-llvm due to boost's
clang-linux.jam file. For now, we'll patch the cmake files, using
the dlls as import libs (which is allowed by mingw).

While at it, we'll avoid linking the static AND dynamic boost libs,
speeding the build.

Signed-off-by: Lucian Petrut <lpetrut@cloudbasesolutions.com>
This commit is contained in:
Lucian Petrut 2023-08-23 14:21:12 +00:00
parent 4b43afd509
commit ec4a2778f6
3 changed files with 27 additions and 4 deletions

View File

@ -814,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))
foreach(name ceph-common client osdc)
set_property(TARGET cephfs APPEND_STRING PROPERTY
LINK_FLAGS " -Wl,--exclude-libs,lib${name}.a")

View File

@ -231,8 +231,12 @@ if [[ -z $SKIP_DLL_COPY ]]; then
$lz4Dir/lib/dll/liblz4-1.dll
$sslDir/bin/libcrypto-1_1-x64.dll
$sslDir/bin/libssl-1_1-x64.dll
$mingwLibpthreadDir/libwinpthread-1.dll
$boostDir/lib/*.dll)
$mingwLibpthreadDir/libwinpthread-1.dll)
if [[ $ENABLE_SHARED == "ON" ]]; then
required_dlls+=(
$boostDir/lib/*.dll
)
fi
if [[ -n $USE_MINGW_LLVM ]]; then
required_dlls+=(
$mingwTargetLibDir/libc++.dll

View File

@ -6,6 +6,7 @@ SCRIPT_DIR="$(dirname "$BASH_SOURCE")"
SCRIPT_DIR="$(realpath "$SCRIPT_DIR")"
USE_MINGW_LLVM=${USE_MINGW_LLVM:-}
ENABLE_SHARED=${ENABLE_SHARED:-OFF}
num_vcpus=$(nproc)
NUM_WORKERS=${NUM_WORKERS:-$num_vcpus}
@ -236,15 +237,32 @@ EOL
./bootstrap.sh
if [[ $ENABLE_SHARED == "ON" ]]; then
b2_link="shared"
else
b2_link="static"
fi
./b2 install --user-config=user-config.jam toolset=$b2toolset \
target-os=windows release \
link=static,shared \
link=$b2_link \
threadapi=win32 --prefix=$boostDir \
address-model=64 architecture=x86 \
binary-format=pe abi=ms -j $NUM_WORKERS \
-sZLIB_INCLUDE=$zlibDir/include -sZLIB_LIBRARY_PATH=$zlibDir/lib \
--without-python --without-mpi --without-log --without-wave
if [[ -n $USE_MINGW_LLVM && $ENABLE_SHARED == "ON" ]]; then
# b2 doesn't generate import libs when using mingw-llvm. We'll tell cmake
# to use the dlls instead of import libs, which mingw is capable of.
#
# TODO: consider dropping this if we get to fix Boost's clang-linux.jam
# file. Worth mentioning that Boost might drop the import libs altogether:
# https://github.com/bfgroup/b2/issues/278
find $boostDir/lib/cmake -name "*.cmake" \
-exec sed -i 's/IMPORTED_LOCATION_RELEASE/IMPORTED_IMPLIB_RELEASE/g' {} \;
fi
echo "Building libbacktrace."
cd $depsSrcDir
if [[ ! -d $backtraceSrcDir ]]; then