Skip to content

Commit

Permalink
MB-38476: tlm: Use different spdlogConfig.cmake for TSAN variant
Browse files Browse the repository at this point in the history
Patch "MB-38476: Add TSan variant of spdlog" (b538b0e) built a second
instance of libspdlog.a with TSan enabled, however there was no way
for find_package() to locate it, given there was just a single
spdlogConfig.cmake which only knew about the non-TSan
library. Therefore we ended up incorrectly using the non-TSan library
for TSan builds.

To address this, fully install the TSan variant of spdlog into a
separare directory tree (under 'tsan_root'), which will have it's own
CMake config file which points to the TSan variant.

Change-Id: I1aec5110376baa9f0b82e074bea2c7aa17baa4a6
Reviewed-on: http://review.couchbase.org/c/tlm/+/161376
Tested-by: Build Bot <build@couchbase.com>
Reviewed-by: Ben Huddleston <ben.huddleston@couchbase.com>
  • Loading branch information
BenHuddleston authored and daverigby committed Sep 14, 2021
1 parent eaa16e4 commit 23abbd2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
2 changes: 1 addition & 1 deletion deps/packages/CMakeLists.txt
Expand Up @@ -206,4 +206,4 @@ _ADD_DEP_PACKAGE(pcre 8.43 v8.43 2)
_ADD_DEP_PACKAGE(opentracing-cpp v1.5.1 v1.5.1 4)
_ADD_DEP_PACKAGE(prometheus-cpp v0.10.0-couchbase v0.10.0-couchbase 2)
_ADD_DEP_PACKAGE(cbpy 7.1.0 ignored 1)
_ADD_DEP_PACKAGE(spdlog v1.8.5 v1.8.5 2)
_ADD_DEP_PACKAGE(spdlog v1.8.5 v1.8.5 3)
18 changes: 8 additions & 10 deletions deps/packages/spdlog/CMakeLists.txt
Expand Up @@ -7,7 +7,6 @@ DECLARE_DEP (fmt VERSION 7.1.3-cb2 PLATFORMS amzn2 centos7 centos8 debian8 debia
# Given we build spdlog twice on Windows, define the common cmake
# arguments once.
list(APPEND cache_args -DCMAKE_CXX_VISIBILITY_PRESET:STRING=hidden)
list(APPEND cache_args -DCMAKE_INSTALL_PREFIX:STRING=${CMAKE_CURRENT_BINARY_DIR}/install)
list(APPEND cache_args -DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON)
list(APPEND cache_args -DSPDLOG_BUILD_EXAMPLE:BOOL=OFF)

Expand Down Expand Up @@ -45,14 +44,14 @@ list(APPEND cache_args -DCMAKE_PREFIX_PATH:STRING=${CMAKE_CURRENT_BINARY_DIR}/fm
ExternalProject_Add(spdlog
GIT_REPOSITORY ${_git_repo}
GIT_TAG ${_git_rev}
INSTALL_DIR ${CMAKE_CURRENT_BINARY_DIR}/install

PATCH_COMMAND git apply ${CMAKE_CURRENT_SOURCE_DIR}/custom_level_names.patch
COMMAND git apply ${CMAKE_CURRENT_SOURCE_DIR}/relocatable_export_package.patch
CMAKE_CACHE_ARGS ${cache_args}
CMAKE_ARGS -D CMAKE_BUILD_TYPE=RelWithDebInfo

BUILD_COMMAND ${CMAKE_COMMAND} --build . --parallel ${_parallelism}
CMAKE_ARGS -D CMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>

INSTALL_DIR ${CMAKE_CURRENT_BINARY_DIR}/install)
BUILD_COMMAND ${CMAKE_COMMAND} --build . --parallel ${_parallelism})

# We generally only run TSan on Ubuntu dockers, but on occasion a local build is
# required. Only build the TSan package on ubuntu and macos platforms to save
Expand All @@ -63,18 +62,17 @@ if (${PLATFORM} STREQUAL "ubuntu18.04" OR ${PLATFORM} MATCHES "macos")
ExternalProject_Add(spdlog_tsan
GIT_REPOSITORY ${_git_repo}
GIT_TAG ${_git_rev}
INSTALL_DIR ${CMAKE_CURRENT_BINARY_DIR}/install/tsan_root

PATCH_COMMAND git apply ${CMAKE_CURRENT_SOURCE_DIR}/custom_level_names.patch
COMMAND git apply ${CMAKE_CURRENT_SOURCE_DIR}/relocatable_export_package.patch
CMAKE_CACHE_ARGS ${cache_args}
"-DCMAKE_C_COMPILER:STRING=clang"
"-DCMAKE_CXX_COMPILER:STRING=clang++"
"-DCMAKE_CXX_FLAGS:STRING=-fsanitize=thread"
CMAKE_ARGS -D CMAKE_BUILD_TYPE=RelWithDebInfo

BUILD_COMMAND ${CMAKE_COMMAND} --build . --parallel ${_parallelism}
CMAKE_ARGS -D CMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>

INSTALL_COMMAND mkdir -p ${CMAKE_CURRENT_BINARY_DIR}/install/tsan_root/lib &&
cp libspdlog.a ${CMAKE_CURRENT_BINARY_DIR}/install/tsan_root/lib)
BUILD_COMMAND ${CMAKE_COMMAND} --build . --parallel ${_parallelism})

ExternalProject_Add_StepDependencies(spdlog download spdlog_tsan)
endif()
Expand Down

0 comments on commit 23abbd2

Please sign in to comment.