summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLuke Chen <luke.chen@mongodb.com>2021-11-08 16:11:44 +1100
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-11-08 05:38:01 +0000
commite7129c86c2440fee4658bc75d4de3c62c2cc331e (patch)
tree769d5f4ab69fc2503fb35e499b81257f2fd459ec /src
parent8daba4f4a662ca57d39081bb068f23c243f74176 (diff)
downloadmongo-e7129c86c2440fee4658bc75d4de3c62c2cc331e.tar.gz
Import wiredtiger: 729765c279dbe5c00939ee1e741e6af91b2615f5 from branch mongodb-master
ref: 58546f3e48..729765c279 for: 5.2.0 WT-8335 Support compiling both a static and shared WiredTiger library in CMake
Diffstat (limited to 'src')
-rw-r--r--src/third_party/wiredtiger/cmake/configs/base.cmake15
-rw-r--r--src/third_party/wiredtiger/cmake/configs/x86/windows/config.cmake2
-rw-r--r--src/third_party/wiredtiger/cmake/define_libwiredtiger.cmake103
-rw-r--r--src/third_party/wiredtiger/cmake/install/install.cmake26
-rw-r--r--src/third_party/wiredtiger/import.data2
-rwxr-xr-xsrc/third_party/wiredtiger/lang/python/setup_pip.py9
-rw-r--r--src/third_party/wiredtiger/test/ctest_helpers.cmake2
7 files changed, 138 insertions, 21 deletions
diff --git a/src/third_party/wiredtiger/cmake/configs/base.cmake b/src/third_party/wiredtiger/cmake/configs/base.cmake
index 098859f2734..1ee24fea4e0 100644
--- a/src/third_party/wiredtiger/cmake/configs/base.cmake
+++ b/src/third_party/wiredtiger/cmake/configs/base.cmake
@@ -38,7 +38,7 @@ config_bool(
config_string(
WT_BUFFER_ALIGNMENT_DEFAULT
- "WiredTiger buffer boundary aligment"
+ "WiredTiger buffer boundary alignment"
DEFAULT 0
)
@@ -61,6 +61,19 @@ config_bool(
)
config_bool(
+ ENABLE_SHARED
+ "Compile as a shared library"
+ DEFAULT ON
+)
+
+config_bool(
+ WITH_PIC
+ "Generate position-independent code. Note PIC will always \
+ be used on shared targets, irrespective of the value of this configuration."
+ DEFAULT OFF
+)
+
+config_bool(
ENABLE_STRICT
"Compile with strict compiler warnings enabled"
DEFAULT OFF
diff --git a/src/third_party/wiredtiger/cmake/configs/x86/windows/config.cmake b/src/third_party/wiredtiger/cmake/configs/x86/windows/config.cmake
index 842708a1f9d..0cce82d1b8e 100644
--- a/src/third_party/wiredtiger/cmake/configs/x86/windows/config.cmake
+++ b/src/third_party/wiredtiger/cmake/configs/x86/windows/config.cmake
@@ -13,6 +13,8 @@ set(SPINLOCK_TYPE "msvc" CACHE STRING "" FORCE)
# We force a static compilation to generate a ".lib" file. We can then
# additionally generate a dll file using a *DEF file.
set(ENABLE_STATIC ON CACHE BOOL "" FORCE)
+set(ENABLE_SHARED OFF CACHE BOOL "" FORCE)
+set(WITH_PIC ON CACHE BOOL "" FORCE)
# Compile as C code .
add_compile_options(/TC)
diff --git a/src/third_party/wiredtiger/cmake/define_libwiredtiger.cmake b/src/third_party/wiredtiger/cmake/define_libwiredtiger.cmake
new file mode 100644
index 00000000000..d477aaa0820
--- /dev/null
+++ b/src/third_party/wiredtiger/cmake/define_libwiredtiger.cmake
@@ -0,0 +1,103 @@
+#
+# Public Domain 2014-present MongoDB, Inc.
+# Public Domain 2008-2014 WiredTiger, Inc.
+# All rights reserved.
+#
+# See the file LICENSE for redistribution information
+#
+
+# define_wiredtiger_library(target type)
+# A helper that defines a wiredtiger library target. This defining a set of common targets and properties we
+# want to be associated to any given 'libwiredtiger' target. Having this as a macro allows us to de-duplicate common
+# definitions when creating multiple versions of libwiredtiger i.e. static and shared builds. Note: this
+# macro assumes you only call it once per libwiredtiger flavour (e.g. only one 'static' definition), use carefully.
+# target - Name of the libwiredtiger target.
+# type - Library type of wiredtiger target e.g. STATIC, SHARED or MODULE.
+# SOURCES - Sources to be compiled under the wiredtiger library. Requires that at least one source file/object is defined.
+# PUBLIC_INCLUDES - Public interface includes of the wiredtiger library.
+# PRIVATE_INCLUDES - Private interface includes of the wiredtiger library.
+macro(define_wiredtiger_library target type)
+ cmake_parse_arguments(
+ "DEFINE_WT"
+ ""
+ ""
+ "SOURCES;PUBLIC_INCLUDES;PRIVATE_INCLUDES"
+ ${ARGN}
+ )
+ if (NOT "${DEFINE_WT_UNPARSED_ARGUMENTS}" STREQUAL "")
+ message(FATAL_ERROR "Unknown arguments to define_wiredtiger_library: ${DEFINE_WT_UNPARSED_ARGUMENTS}")
+ endif()
+ if ("${DEFINE_WT_SOURCES}" STREQUAL "")
+ message(FATAL_ERROR "No sources given to define_wiredtiger_library")
+ endif()
+
+ # Define the wiredtiger library target.
+ add_library(${target} ${type} ${DEFINE_WT_SOURCES})
+ # Append any include directories to the library target.
+ if(DEFINE_WT_PUBLIC_INCLUDES)
+ target_include_directories(${target} PUBLIC ${DEFINE_WT_PUBLIC_INCLUDES})
+ endif()
+ if(DEFINE_WT_PRIVATE_INCLUDES)
+ target_include_directories(${target} PRIVATE ${DEFINE_WT_PRIVATE_INCLUDES})
+ endif()
+ # Append any provided C flags.
+ if(COMPILER_DIAGNOSTIC_C_FLAGS)
+ target_compile_options(${target} PRIVATE ${COMPILER_DIAGNOSTIC_C_FLAGS})
+ endif()
+
+ # We want to set the following target properties:
+ # OUTPUT_NAME - Generate a library with the name "libwiredtiger[.so|.a". Note this assumes each invocation
+ # of this macro is specifying a unique libwiredtiger target type (e.g 'SHARED', 'STATIC'), multiple declarations
+ # of a 'SHARED' wiredtiger library would conflict.
+ # NO_SYSTEM_FROM_IMPORTED - don't treat include interface directories consumed on an imported target as system
+ # directories.
+ set_target_properties(${target} PROPERTIES
+ OUTPUT_NAME "wiredtiger"
+ NO_SYSTEM_FROM_IMPORTED TRUE
+ )
+
+ # Ensure we link any available library dependencies to our wiredtiger target.
+ if(HAVE_LIBPTHREAD)
+ target_link_libraries(${target} PUBLIC ${HAVE_LIBPTHREAD})
+ if(HAVE_LIBPTHREAD_INCLUDES)
+ target_include_directories(${target} PUBLIC ${HAVE_LIBPTHREAD_INCLUDES})
+ endif()
+ endif()
+ if(HAVE_LIBRT)
+ target_link_libraries(${target} PUBLIC ${HAVE_LIBRT})
+ if(HAVE_LIBRT_INCLUDES)
+ target_include_directories(${target} PUBLIC ${HAVE_LIBRT_INCLUDES})
+ endif()
+ endif()
+ if(HAVE_LIBDL)
+ target_link_libraries(${target} PUBLIC ${HAVE_LIBDL})
+ if(HAVE_LIBDL_INCLUDES)
+ target_include_directories(${target} PUBLIC ${HAVE_LIBDL_INCLUDES})
+ endif()
+ endif()
+ if(ENABLE_TCMALLOC)
+ target_link_libraries(${target} PRIVATE wt::tcmalloc)
+ endif()
+
+ # We want to capture any transitive dependencies associated with the builtin library
+ # target and ensure we are explicitly linking the 3rd party libraries.
+ if(HAVE_BUILTIN_EXTENSION_LZ4)
+ target_link_libraries(${target} PRIVATE wt::lz4)
+ endif()
+
+ if(HAVE_BUILTIN_EXTENSION_SNAPPY)
+ target_link_libraries(${target} PRIVATE wt::snappy)
+ endif()
+
+ if(HAVE_BUILTIN_EXTENSION_SODIUM)
+ target_link_libraries(${target} PRIVATE wt::sodium)
+ endif()
+
+ if(HAVE_BUILTIN_EXTENSION_ZLIB)
+ target_link_libraries(${target} PRIVATE wt::zlib)
+ endif()
+
+ if(HAVE_BUILTIN_EXTENSION_ZSTD)
+ target_link_libraries(${target} PRIVATE wt::zstd)
+ endif()
+endmacro()
diff --git a/src/third_party/wiredtiger/cmake/install/install.cmake b/src/third_party/wiredtiger/cmake/install/install.cmake
index ec9b30234d6..e6ac82d2b10 100644
--- a/src/third_party/wiredtiger/cmake/install/install.cmake
+++ b/src/third_party/wiredtiger/cmake/install/install.cmake
@@ -10,21 +10,25 @@ include(GNUInstallDirs)
# Library installs
-# Define the public headers for wiredtiger library to be used when installing the target.
-set_property(
- TARGET wiredtiger
- PROPERTY PUBLIC_HEADER
- ${CMAKE_BINARY_DIR}/include/wiredtiger.h
- ${CMAKE_SOURCE_DIR}/src/include/wiredtiger_ext.h
+# Define the wiredtiger public headers we want to export when running the install target.
+install(
+ FILES ${CMAKE_BINARY_DIR}/include/wiredtiger.h ${CMAKE_SOURCE_DIR}/src/include/wiredtiger_ext.h
+ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)
-# Set the version property of the wiredtiger library so we can export a versioned install.
-set_target_properties(wiredtiger PROPERTIES VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}")
-# Install the wiredtiger library target.
-install(TARGETS wiredtiger
+# Define the wiredtiger library targets we will install.
+set(wt_targets)
+if(ENABLE_SHARED)
+ list(APPEND wt_targets wiredtiger_shared)
+endif()
+if(ENABLE_STATIC)
+ list(APPEND wt_targets wiredtiger_static)
+endif()
+
+# Install the wiredtiger library targets.
+install(TARGETS ${wt_targets}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
- PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)
# Create our wiredtiger pkgconfig (for POSIX builds).
diff --git a/src/third_party/wiredtiger/import.data b/src/third_party/wiredtiger/import.data
index 93f61186637..9fc0ae0b46a 100644
--- a/src/third_party/wiredtiger/import.data
+++ b/src/third_party/wiredtiger/import.data
@@ -2,5 +2,5 @@
"vendor": "wiredtiger",
"github": "wiredtiger/wiredtiger.git",
"branch": "mongodb-master",
- "commit": "58546f3e4809aaf88e6a55fdbf8e10551245f265"
+ "commit": "729765c279dbe5c00939ee1e741e6af91b2615f5"
}
diff --git a/src/third_party/wiredtiger/lang/python/setup_pip.py b/src/third_party/wiredtiger/lang/python/setup_pip.py
index ede4f472548..2a1d63f8d7f 100755
--- a/src/third_party/wiredtiger/lang/python/setup_pip.py
+++ b/src/third_party/wiredtiger/lang/python/setup_pip.py
@@ -217,7 +217,7 @@ builtin_libraries = [b[1] for b in builtins]
# Here's the configure/make operations we perform before the python extension
# is linked.
configure_cmds = [
- 'cmake -B cmake_pip_build -G Ninja -DENABLE_STATIC=1 -DCMAKE_C_FLAGS="${CFLAGS:-}" -DENABLE_PYTHON=1 ' + \
+ 'cmake -B cmake_pip_build -G Ninja -DENABLE_STATIC=1 -DENABLE_SHARED=0 -DWITH_PIC=1 -DCMAKE_C_FLAGS="${CFLAGS:-}" -DENABLE_PYTHON=1 ' + \
' '.join(map(lambda name: '-DHAVE_BUILTIN_EXTENSION_' + name.upper() + '=1', builtin_names)),
]
@@ -280,12 +280,7 @@ wt_ext = Extension('_wiredtiger',
extra_compile_args = cflags + cppflags,
extra_link_args = ldflags,
libraries = builtin_libraries,
- # FIXME-WT-7905: Remove manual linking of static extension libraries.
- # Unfortunately CMake's use of the builtin doesn't currently support linking in the extension
- # objects into a static libwiredtiger archive. As a workaround, we need to manually link
- # the ext/compressor libraries.
- extra_objects = [ os.path.join(build_dir, 'libwiredtiger.a') ] + \
- list(map(lambda name: os.path.join(build_dir, 'ext', 'compressors', name) + '/libwiredtiger_' + name + '.a', builtin_names)),
+ extra_objects = [ os.path.join(build_dir, 'libwiredtiger.a') ],
include_dirs = inc_paths,
library_dirs = lib_paths,
)
diff --git a/src/third_party/wiredtiger/test/ctest_helpers.cmake b/src/third_party/wiredtiger/test/ctest_helpers.cmake
index 23cae0b5a95..ea87b6f4015 100644
--- a/src/third_party/wiredtiger/test/ctest_helpers.cmake
+++ b/src/third_party/wiredtiger/test/ctest_helpers.cmake
@@ -100,7 +100,7 @@ function(create_test_executable target)
endif()
# Link the base set of libraries for a wiredtiger C/CXX test.
- target_link_libraries(${target} wiredtiger test_util)
+ target_link_libraries(${target} wt::wiredtiger test_util)
if(NOT "${CREATE_TEST_LIBS}" STREQUAL "")
target_link_libraries(${target} ${CREATE_TEST_LIBS})
endif()