From 4f15b2e27bb95107eb978b90d7e74668ca4afcd8 Mon Sep 17 00:00:00 2001 From: Ezra Chung Date: Tue, 23 Jan 2024 09:48:59 -0600 Subject: [PATCH 01/35] Add BSONCXX_USE_POLY_IMPLS to configuration --- CMakeLists.txt | 7 +++++++ cmake/BsoncxxUtil.cmake | 10 +++++----- cmake/make_dist/MakeDistCheck.cmake | 3 +++ src/bsoncxx/CMakeLists.txt | 5 +++++ .../bsoncxx/v_noabi/bsoncxx/config/postlude.hpp | 2 ++ .../include/bsoncxx/v_noabi/bsoncxx/config/prelude.hpp | 2 ++ .../lib/bsoncxx/v_noabi/bsoncxx/config/config.hpp.in | 1 + src/bsoncxx/test/CMakeLists.txt | 1 + 8 files changed, 26 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c2cbbdedf6..939df54179 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -157,6 +157,9 @@ option(BUILD_SHARED_LIBS_WITH_STATIC_MONGOC OFF ) +# Allow the user to opt into using bsoncxx implementations for C++17 polyfills. +option(ENABLE_BSONCXX_POLY_USE_IMPLS "Enable using bsoncxx implementations of C++17 polyfills for pre-C++17 configurations" OFF) + if(DEFINED CACHE{ENABLE_ABI_TAG_IN_LIBRARY_FILENAMES} AND NOT MSVC) message(WARNING "ENABLE_ABI_TAG_IN_LIBRARY_FILENAMES is an MSVC-only option and will be ignored by the current configuration") unset(ENABLE_ABI_TAG_IN_LIBRARY_FILENAMES CACHE) @@ -456,6 +459,10 @@ if(NOT(TARGET dist OR TARGET distcheck)) list(APPEND polyfill_flags "-DBOOST_ROOT=${BOOST_ROOT}") endif() + if(NOT "${BSONCXX_POLY_USE_IMPLS}" STREQUAL "") + list(APPEND polyfill_flags "-DBSONCXX_POLY_USE_IMPLS=${BSONCXX_POLY_USE_IMPLS}") + endif() + if(NOT "${BSONCXX_POLY_USE_MNMLSTC}" STREQUAL "") list(APPEND polyfill_flags "-DBSONCXX_POLY_USE_MNMLSTC=${BSONCXX_POLY_USE_MNMLSTC}") endif() diff --git a/cmake/BsoncxxUtil.cmake b/cmake/BsoncxxUtil.cmake index 42bbc54b36..3a5f7cb591 100644 --- a/cmake/BsoncxxUtil.cmake +++ b/cmake/BsoncxxUtil.cmake @@ -53,24 +53,24 @@ function(bsoncxx_add_library TARGET OUTPUT_NAME LINK_TYPE) endif() # Library used for C++17 polyfills: + # - 'i' for bsoncxx implementations. # - 'm' for mnmlstc/core. # - 'b' for Boost. # - 'x' for experimental standard library. - # - 'i' for bsoncxx implementations. # - 's' for standard library (no polyfill). if(1) - if(BSONCXX_POLY_USE_MNMLSTC) + if(BSONCXX_POLY_USE_IMPLS) + set(polyfill "i") + elseif(BSONCXX_POLY_USE_MNMLSTC) set(polyfill "m") elseif(BSONCXX_POLY_USE_BOOST) set(polyfill "b") elseif(BSONCXX_POLY_USE_STD_EXPERIMENTAL) set(polyfill "x") - elseif(0) # CXX-2796: reserved for bsoncxx implementations as polyfill. - set(polyfill "i") elseif(BSONCXX_POLY_USE_STD) set(polyfill "s") else() - message(FATAL_ERROR "could not determine polyfill library: must be one of [mbxis]") + message(FATAL_ERROR "could not determine polyfill library: must be one of [imbxs]") endif() set_target_properties(${TARGET} PROPERTIES INTERFACE_BSONCXX_ABI_TAG_POLYFILL_LIBRARY ${polyfill}) diff --git a/cmake/make_dist/MakeDistCheck.cmake b/cmake/make_dist/MakeDistCheck.cmake index d6576fe3a8..bf6ee4ef72 100644 --- a/cmake/make_dist/MakeDistCheck.cmake +++ b/cmake/make_dist/MakeDistCheck.cmake @@ -36,6 +36,9 @@ function (RUN_DIST_CHECK PACKAGE_PREFIX EXT) if (NOT "${BOOST_ROOT}" STREQUAL "") list(APPEND polyfill_flags "-DBOOST_ROOT=${BOOST_ROOT}") endif () + if (NOT "${BSONCXX_POLY_USE_IMPLS}" STREQUAL "") + list(APPEND polyfill_flags "-DBSONCXX_POLY_USE_IMPLS=${BSONCXX_POLY_USE_IMPLS}") + endif() if (NOT "${BSONCXX_POLY_USE_MNMLSTC}" STREQUAL "") list(APPEND polyfill_flags "-DBSONCXX_POLY_USE_MNMLSTC=${BSONCXX_POLY_USE_MNMLSTC}") endif() diff --git a/src/bsoncxx/CMakeLists.txt b/src/bsoncxx/CMakeLists.txt index 1e241f55f6..e6f491f4ea 100644 --- a/src/bsoncxx/CMakeLists.txt +++ b/src/bsoncxx/CMakeLists.txt @@ -20,6 +20,7 @@ set(BSONCXX_VERSION_NO_EXTRA ${BSONCXX_VERSION_MAJOR}.${BSONCXX_VERSION_MINOR}.$ set(BSONCXX_VERSION ${BSONCXX_VERSION_NO_EXTRA}${BSONCXX_VERSION_EXTRA}) message(STATUS "bsoncxx version: ${BSONCXX_VERSION}") +option(BSONCXX_POLY_USE_IMPLS "Use bsoncxx implementations for stdx polyfills" OFF) option(BSONCXX_POLY_USE_MNMLSTC "Use MNMLSTC/core for stdx polyfills" OFF) option(BSONCXX_POLY_USE_STD_EXPERIMENTAL "Use std::experimental for stdx polyfills" OFF) option(BSONCXX_POLY_USE_SYSTEM_MNMLSTC "Obtain mnmlstc/core from system" OFF) @@ -46,6 +47,10 @@ elseif(BSONCXX_POLY_OPTIONS_SET EQUAL 0) # If we are in C++17 mode, use the C++17 versions set(BSONCXX_POLY_USE_STD ON) message(STATUS "Auto-configuring bsoncxx to use C++17 std library polyfills since C++17 is active and user didn't specify otherwise") + elseif(ENABLE_BSONCXX_POLY_USE_IMPLS) + # If enabled, use bsoncxx implementations instead of external libraries. + set(BSONCXX_POLY_USE_IMPLS ON) + message(STATUS "Auto-configuring bsoncxx to use its own polyfill implementations since C++17 is inactive") elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") # Otherwise, since MSVC can't handle MNMLSTC, default to boost set(BSONCXX_POLY_USE_BOOST ON) diff --git a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/config/postlude.hpp b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/config/postlude.hpp index 22f1355dd8..387c2b2cef 100644 --- a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/config/postlude.hpp +++ b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/config/postlude.hpp @@ -24,6 +24,8 @@ BSONCXX_POP_WARNINGS(); #pragma pop_macro("BSONCXX_INLINE_NAMESPACE_BEGIN") #undef BSONCXX_INLINE_NAMESPACE_END #pragma pop_macro("BSONCXX_INLINE_NAMESPACE_END") +#undef BSONCXX_POLY_USE_IMPLS +#pragma pop_macro("BSONCXX_POLY_USE_IMPLS") #undef BSONCXX_POLY_USE_MNMLSTC #pragma pop_macro("BSONCXX_POLY_USE_MNMLSTC") #undef BSONCXX_POLY_USE_STD_EXPERIMENTAL diff --git a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/config/prelude.hpp b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/config/prelude.hpp index 7cfa56c1e8..4e1716cac1 100644 --- a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/config/prelude.hpp +++ b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/config/prelude.hpp @@ -65,6 +65,8 @@ #undef BSONCXX_INLINE_NAMESPACE_BEGIN #pragma push_macro("BSONCXX_INLINE_NAMESPACE_END") #undef BSONCXX_INLINE_NAMESPACE_END +#pragma push_macro("BSONCXX_POLY_USE_IMPLS") +#undef BSONCXX_POLY_USE_MNMLSTC #pragma push_macro("BSONCXX_POLY_USE_MNMLSTC") #undef BSONCXX_POLY_USE_MNMLSTC #pragma push_macro("BSONCXX_POLY_USE_STD_EXPERIMENTAL") diff --git a/src/bsoncxx/lib/bsoncxx/v_noabi/bsoncxx/config/config.hpp.in b/src/bsoncxx/lib/bsoncxx/v_noabi/bsoncxx/config/config.hpp.in index e4a2a6704c..ed01dfc1ee 100644 --- a/src/bsoncxx/lib/bsoncxx/v_noabi/bsoncxx/config/config.hpp.in +++ b/src/bsoncxx/lib/bsoncxx/v_noabi/bsoncxx/config/config.hpp.in @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +#cmakedefine BSONCXX_POLY_USE_IMPLS #cmakedefine BSONCXX_POLY_USE_STD_EXPERIMENTAL #cmakedefine BSONCXX_POLY_USE_MNMLSTC #cmakedefine BSONCXX_POLY_USE_SYSTEM_MNMLSTC diff --git a/src/bsoncxx/test/CMakeLists.txt b/src/bsoncxx/test/CMakeLists.txt index 1c483b37d2..ee93cbf63c 100644 --- a/src/bsoncxx/test/CMakeLists.txt +++ b/src/bsoncxx/test/CMakeLists.txt @@ -77,6 +77,7 @@ if(ENABLE_MACRO_GUARD_TESTS) BSONCXX_CALL BSONCXX_INLINE_NAMESPACE_BEGIN # config.hpp (generated by CMake) BSONCXX_INLINE_NAMESPACE_END + BSONCXX_POLY_USE_IMPLS BSONCXX_POLY_USE_MNMLSTC BSONCXX_POLY_USE_STD_EXPERIMENTAL BSONCXX_POLY_USE_SYSTEM_MNMLSTC From a69b3e37a528be45037460e8ed15e66bad8cda68 Mon Sep 17 00:00:00 2001 From: Ezra Chung Date: Tue, 23 Jan 2024 09:49:00 -0600 Subject: [PATCH 02/35] Formatting --- cmake/make_dist/MakeDistCheck.cmake | 80 ++++++++++++++++------------- 1 file changed, 44 insertions(+), 36 deletions(-) diff --git a/cmake/make_dist/MakeDistCheck.cmake b/cmake/make_dist/MakeDistCheck.cmake index bf6ee4ef72..f409b06a31 100644 --- a/cmake/make_dist/MakeDistCheck.cmake +++ b/cmake/make_dist/MakeDistCheck.cmake @@ -1,67 +1,76 @@ -include (MakeDistFiles) +include(MakeDistFiles) -function (RUN_DIST_CHECK PACKAGE_PREFIX EXT) +function(RUN_DIST_CHECK PACKAGE_PREFIX EXT) + set(tarball ${PACKAGE_PREFIX}.tar${EXT}) - set (tarball ${PACKAGE_PREFIX}.tar${EXT}) - if (NOT EXISTS ${tarball}) - message (FATAL_ERROR "Can't find dist tarball '${tarball}'") - endif () + if(NOT EXISTS ${tarball}) + message(FATAL_ERROR "Can't find dist tarball '${tarball}'") + endif() # Remove the directory to which we're about to extract - file (REMOVE_RECURSE ${PACKAGE_PREFIX}) + file(REMOVE_RECURSE ${PACKAGE_PREFIX}) # Untar the distribution we want to check - set (TAR_OPTION "zxf") - if (${EXT} STREQUAL ".bz2") - set (TAR_OPTION "jxf") - endif () + set(TAR_OPTION "zxf") + + if(${EXT} STREQUAL ".bz2") + set(TAR_OPTION "jxf") + endif() - execute_process_and_check_result ( + execute_process_and_check_result( COMMAND ${CMAKE_COMMAND} -E tar ${TAR_OPTION} ${tarball} WORKING_DIRECTORY . ERROR_MSG "Command to untar ${tarball} failed." ) - set (BUILD_DIR "_cmake_build") - set (INSTALL_DIR "_cmake_install") - file (REMOVE_RECURSE ${BUILD_DIR} ${INSTALL_DIR}) + set(BUILD_DIR "_cmake_build") + set(INSTALL_DIR "_cmake_install") + file(REMOVE_RECURSE ${BUILD_DIR} ${INSTALL_DIR}) - file (MAKE_DIRECTORY ${BUILD_DIR} ${INSTALL_DIR}) + file(MAKE_DIRECTORY ${BUILD_DIR} ${INSTALL_DIR}) # Ensure distcheck inherits polyfill library selection. set(polyfill_flags "") - if (NOT "${CMAKE_CXX_STANDARD}" STREQUAL "") + + if(NOT "${CMAKE_CXX_STANDARD}" STREQUAL "") list(APPEND polyfill_flags "-DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD}") - endif () - if (NOT "${BOOST_ROOT}" STREQUAL "") + endif() + + if(NOT "${BOOST_ROOT}" STREQUAL "") list(APPEND polyfill_flags "-DBOOST_ROOT=${BOOST_ROOT}") - endif () - if (NOT "${BSONCXX_POLY_USE_IMPLS}" STREQUAL "") + endif() + + if(NOT "${BSONCXX_POLY_USE_IMPLS}" STREQUAL "") list(APPEND polyfill_flags "-DBSONCXX_POLY_USE_IMPLS=${BSONCXX_POLY_USE_IMPLS}") endif() - if (NOT "${BSONCXX_POLY_USE_MNMLSTC}" STREQUAL "") + + if(NOT "${BSONCXX_POLY_USE_MNMLSTC}" STREQUAL "") list(APPEND polyfill_flags "-DBSONCXX_POLY_USE_MNMLSTC=${BSONCXX_POLY_USE_MNMLSTC}") endif() - if (NOT "${BSONCXX_POLY_USE_STD_EXPERIMENTAL}" STREQUAL "") + + if(NOT "${BSONCXX_POLY_USE_STD_EXPERIMENTAL}" STREQUAL "") list(APPEND polyfill_flags "-DBSONCXX_POLY_USE_STD_EXPERIMENTAL=${BSONCXX_POLY_USE_STD_EXPERIMENTAL}") endif() - if (NOT "${BSONCXX_POLY_USE_SYSTEM_MNMLSTC}" STREQUAL "") + + if(NOT "${BSONCXX_POLY_USE_SYSTEM_MNMLSTC}" STREQUAL "") list(APPEND polyfill_flags "-DBSONCXX_POLY_USE_SYSTEM_MNMLSTC=${BSONCXX_POLY_USE_SYSTEM_MNMLSTC}") endif() - if (NOT "${BSONCXX_POLY_USE_BOOST}" STREQUAL "") + + if(NOT "${BSONCXX_POLY_USE_BOOST}" STREQUAL "") list(APPEND polyfill_flags "-DBSONCXX_POLY_USE_BOOST=${BSONCXX_POLY_USE_BOOST}") endif() - if (NOT "${BSONCXX_POLY_USE_STD}" STREQUAL "") + + if(NOT "${BSONCXX_POLY_USE_STD}" STREQUAL "") list(APPEND polyfill_flags "-DBSONCXX_POLY_USE_STD=${BSONCXX_POLY_USE_STD}") endif() - execute_process_and_check_result ( + execute_process_and_check_result( COMMAND ${CMAKE_COMMAND} -E echo "Configuring distcheck with CMake flags: ${polyfill_flags}" WORKING_DIRECTORY . ERROR_MSG "Failed to echo polyfill flags" ) - execute_process_and_check_result ( + execute_process_and_check_result( COMMAND ${CMAKE_COMMAND} -S ../${PACKAGE_PREFIX} -B . @@ -76,29 +85,28 @@ function (RUN_DIST_CHECK PACKAGE_PREFIX EXT) ) # Run make in the build directory - separate_arguments (build_opts) - execute_process_and_check_result ( + separate_arguments(build_opts) + execute_process_and_check_result( COMMAND ${CMAKE_COMMAND} --build . WORKING_DIRECTORY ${BUILD_DIR} ERROR_MSG "Make build failed." ) # Run make install - execute_process_and_check_result ( + execute_process_and_check_result( COMMAND ${CMAKE_COMMAND} --build . --target install WORKING_DIRECTORY ${BUILD_DIR} ERROR_MSG "Make install failed." ) # Run make dist - execute_process_and_check_result ( + execute_process_and_check_result( COMMAND ${CMAKE_COMMAND} --build . --target dist WORKING_DIRECTORY ${BUILD_DIR} ERROR_MSG "Make dist failed." ) - message ("distcheck complete.") - -endfunction () + message("distcheck complete.") +endfunction() -run_dist_check (${PACKAGE_PREFIX} .gz) +run_dist_check(${PACKAGE_PREFIX} .gz) From 966a23f2c7cc7d9f4960f431c19600601695e475 Mon Sep 17 00:00:00 2001 From: Ezra Chung Date: Tue, 23 Jan 2024 09:49:01 -0600 Subject: [PATCH 03/35] Restore stdlib selection for make_unique.hpp --- .../v_noabi/bsoncxx/config/prelude.hpp | 2 +- .../v_noabi/bsoncxx/stdx/make_unique.hpp | 46 +++++++++++++++++-- 2 files changed, 43 insertions(+), 5 deletions(-) diff --git a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/config/prelude.hpp b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/config/prelude.hpp index 4e1716cac1..a9b5d68c23 100644 --- a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/config/prelude.hpp +++ b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/config/prelude.hpp @@ -66,7 +66,7 @@ #pragma push_macro("BSONCXX_INLINE_NAMESPACE_END") #undef BSONCXX_INLINE_NAMESPACE_END #pragma push_macro("BSONCXX_POLY_USE_IMPLS") -#undef BSONCXX_POLY_USE_MNMLSTC +#undef BSONCXX_POLY_USE_IMPLS #pragma push_macro("BSONCXX_POLY_USE_MNMLSTC") #undef BSONCXX_POLY_USE_MNMLSTC #pragma push_macro("BSONCXX_POLY_USE_STD_EXPERIMENTAL") diff --git a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/stdx/make_unique.hpp b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/stdx/make_unique.hpp index 770fd69196..f36d0aa7d8 100644 --- a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/stdx/make_unique.hpp +++ b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/stdx/make_unique.hpp @@ -14,19 +14,30 @@ #pragma once -#include #include + +#include + +#pragma push_macro("BSONCXX_DETAIL_USE_STD_MAKE_UNIQUE") +#undef BSONCXX_DETAIL_USE_STD_MAKE_UNIQUE + +#if (defined(__cplusplus) && __cplusplus >= 201402L) || \ + (defined(_MSVC_LANG) && _MSVC_LANG >= 201402L) +#define BSONCXX_DETAIL_USE_STD_MAKE_UNIQUE +#endif + +// Only define bsoncxx implementation details when necessary. +#if !defined(BSONCXX_DETAIL_USE_STD_MAKE_UNIQUE) || !defined(__cpp_lib_smart_ptr_for_overwrite) + +#include #include #include #include -#include - namespace bsoncxx { namespace v_noabi { namespace stdx { - namespace detail { // Switch backend of make_unique by the type we are creating. @@ -84,6 +95,21 @@ template struct make_unique_impl {}; } // namespace detail +} // namespace stdx +} // namespace v_noabi +} // namespace bsoncxx + +#endif // defined(BSONCXX_DETAIL_USE_IMPLS_MAKE_UNIQUE) + +namespace bsoncxx { +namespace v_noabi { +namespace stdx { + +// Unlike other C++17 polyfill features, this is a C++14 feature. +// Use feature testing rather than polyfill library selection macros. +#if defined(BSONCXX_DETAIL_USE_STD_MAKE_UNIQUE) +using ::std::make_unique; +#else /// Equivalent to `std::make_unique(args...)` where `T` is a non-array type. template make_unique(std::size_t count) { return Impl::make(std::true_type{}, count); } +#endif + +// Unlike other C++17 polyfill features, this is a C++20 feature. +// Use feature testing rather than polyfill library selection macros. +#if defined(__cpp_lib_smart_ptr_for_overwrite) +using ::std::make_unique_for_overwrite; +#else + /// Equivalent to `std::make_unique_for_overwrite()` where `T` is a non-array type. template , @@ -127,10 +161,14 @@ std::unique_ptr make_unique_for_overwrite(std::size_t count) { return Impl::make(std::false_type{}, count); } +#endif + } // namespace stdx } // namespace v_noabi } // namespace bsoncxx +#pragma pop_macro("BSONCXX_DETAIL_USE_STD_MAKE_UNIQUE") + #include namespace bsoncxx { From d8296bccf1e7420688e8b00326050dc77a974f70 Mon Sep 17 00:00:00 2001 From: Ezra Chung Date: Tue, 23 Jan 2024 09:49:01 -0600 Subject: [PATCH 04/35] Restore polyfill selection for string_view.hpp --- .../v_noabi/bsoncxx/stdx/string_view.hpp | 126 ++++++++++++++---- 1 file changed, 102 insertions(+), 24 deletions(-) diff --git a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/stdx/string_view.hpp b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/stdx/string_view.hpp index 785e873d77..74bba0d239 100644 --- a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/stdx/string_view.hpp +++ b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/stdx/string_view.hpp @@ -14,6 +14,92 @@ #pragma once +#include + +#if defined(BSONCXX_POLY_USE_MNMLSTC) + +#include + +namespace bsoncxx { +namespace v_noabi { +namespace stdx { + +using ::core::basic_string_view; +using ::core::string_view; + +} // namespace stdx +} // namespace v_noabi +} // namespace bsoncxx + +#elif defined(BSONCXX_POLY_USE_BOOST) + +#include + +#if BOOST_VERSION >= 106100 + +#include + +namespace bsoncxx { +namespace v_noabi { +namespace stdx { + +using ::boost::basic_string_view; +using ::boost::string_view; + +} // namespace stdx +} // namespace v_noabi +} // namespace bsoncxx + +#else + +#include + +namespace bsoncxx { +namespace v_noabi { +namespace stdx { + +template > +using basic_string_view = ::boost::basic_string_ref; +using string_view = ::boost::string_ref; + +} // namespace stdx +} // namespace v_noabi +} // namespace bsoncxx + +#endif + +#elif defined(BSONCXX_POLY_USE_STD_EXPERIMENTAL) + +#include + +namespace bsoncxx { +namespace v_noabi { +namespace stdx { + +using ::std::experimental::basic_string_view; +using ::std::experimental::string_view; + +} // namespace stdx +} // namespace v_noabi +} // namespace bsoncxx + +#elif defined(BSONCXX_POLY_USE_STD) + +#include + +namespace bsoncxx { +namespace v_noabi { +namespace stdx { + +using ::std::basic_string_view; +using ::std::string_view; + +} // namespace stdx +} // namespace v_noabi +} // namespace bsoncxx + +#elif defined(BSONCXX_POLY_USE_IMPLS) + #include #include #include @@ -25,18 +111,6 @@ #include #include -#include - -#ifdef __has_include -#if __has_include() -#include -#endif -#endif - -#ifdef __cpp_lib_string_view -#include -#endif - namespace bsoncxx { namespace v_noabi { namespace stdx { @@ -502,17 +576,6 @@ using string_view = basic_string_view; } // namespace v_noabi } // namespace bsoncxx -namespace bsoncxx { -namespace stdx { - -using ::bsoncxx::v_noabi::stdx::basic_string_view; -using ::bsoncxx::v_noabi::stdx::string_view; - -} // namespace stdx -} // namespace bsoncxx - -#include - namespace std { template @@ -525,4 +588,19 @@ struct hash> } }; -} // namespace std \ No newline at end of file +} // namespace std + +#else +#error "Cannot find a valid polyfill for string_view" +#endif + +#include + +namespace bsoncxx { +namespace stdx { + +using ::bsoncxx::v_noabi::stdx::basic_string_view; +using ::bsoncxx::v_noabi::stdx::string_view; + +} // namespace stdx +} // namespace bsoncxx From 0f165a8ff4c32610f733d75944d6ea197c7e1d51 Mon Sep 17 00:00:00 2001 From: Ezra Chung Date: Tue, 23 Jan 2024 09:49:02 -0600 Subject: [PATCH 05/35] CXX-641 fix usage of common flags in abidiff-test.sh --- .evergreen/abidiff-test.sh | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/.evergreen/abidiff-test.sh b/.evergreen/abidiff-test.sh index bac301f3c2..31e2919bf5 100755 --- a/.evergreen/abidiff-test.sh +++ b/.evergreen/abidiff-test.sh @@ -10,15 +10,14 @@ export PATH PATH="${working_dir:?}/install/bin:${PATH:-}" declare -a common_flags -flags=( +common_flags=( --headers-dir1 install/old/include --headers-dir2 install/new/include - --non-reachable-types --fail-no-debug-info ) -declare -a abi_flags=("${common_flags[@]}" --suppressions cxx-abi/abignore) -declare -a noabi_flags=("${common_flags[@]}" --suppressions cxx-noabi/abignore) +declare -a abi_flags=("${common_flags[@]:?}" --suppressions cxx-abi/abignore) +declare -a noabi_flags=("${common_flags[@]:?}" --suppressions cxx-noabi/abignore) command -V abidiff >/dev/null @@ -46,9 +45,15 @@ name_regexp = ^(bsoncxx|mongocxx)::v[[:digit:]]+:: name_regexp = ^(bsoncxx|mongocxx)::v[[:digit:]]+:: DOC +# Ensure files have content even when abidiff produces no output. +echo "---" >>cxx-abi/bsoncxx.txt +echo "---" >>cxx-abi/mongocxx.txt +echo "---" >>cxx-noabi/bsoncxx.txt +echo "---" >>cxx-noabi/mongocxx.txt + # Allow task to upload the diff reports despite failed status. echo "Comparing stable ABI for bsoncxx..." -if ! abidiff "${abi_flags[@]}" install/old/lib/libbsoncxx.so install/new/lib/libbsoncxx.so &>cxx-abi/bsoncxx.txt; then +if ! abidiff "${abi_flags[@]:?}" install/old/lib/libbsoncxx.so install/new/lib/libbsoncxx.so >>cxx-abi/bsoncxx.txt; then declare status status='{"status":"failed", "type":"test", "should_continue":true, "desc":"abidiff returned an error for bsoncxx (stable)"}' curl -sS -d "${status:?}" -H "Content-Type: application/json" -X POST localhost:2285/task_status || true @@ -57,7 +62,7 @@ echo "Comparing stable ABI for bsoncxx... done." # Allow task to upload the diff reports despite failed status. echo "Comparing stable ABI for mongocxx..." -if ! abidiff "${abi_flags[@]}" install/old/lib/libmongocxx.so install/new/lib/libmongocxx.so &>cxx-abi/mongocxx.txt; then +if ! abidiff "${abi_flags[@]:?}" install/old/lib/libmongocxx.so install/new/lib/libmongocxx.so >>cxx-abi/mongocxx.txt; then declare status status='{"status":"failed", "type":"test", "should_continue":true, "desc":"abidiff returned an error for mongocxx (stable)"}' curl -sS -d "${status:?}" -H "Content-Type: application/json" -X POST localhost:2285/task_status || true @@ -65,15 +70,15 @@ fi echo "Comparing stable ABI for mongocxx... done." echo "Comparing unstable ABI for bsoncxx..." -abidiff "${noabi_flags[@]}" install/old/lib/libbsoncxx.so install/new/lib/libbsoncxx.so &>cxx-noabi/bsoncxx.txt || true +abidiff "${noabi_flags[@]:?}" install/old/lib/libbsoncxx.so install/new/lib/libbsoncxx.so >>cxx-noabi/bsoncxx.txt || true echo "Comparing unstable ABI for bsoncxx... done." echo "Comparing unstable ABI for mongocxx..." -abidiff "${noabi_flags[@]}" install/old/lib/libmongocxx.so install/new/lib/libmongocxx.so &>cxx-noabi/mongocxx.txt || true +abidiff "${noabi_flags[@]:?}" install/old/lib/libmongocxx.so install/new/lib/libmongocxx.so >>cxx-noabi/mongocxx.txt || true echo "Comparing unstable ABI for mongocxx... done." # Ensure files have content even when abidiff produces no output. -printf "\n" >>cxx-abi/bsoncxx.txt -printf "\n" >>cxx-abi/mongocxx.txt -printf "\n" >>cxx-noabi/bsoncxx.txt -printf "\n" >>cxx-noabi/mongocxx.txt +echo "---" >>cxx-abi/bsoncxx.txt +echo "---" >>cxx-abi/mongocxx.txt +echo "---" >>cxx-noabi/bsoncxx.txt +echo "---" >>cxx-noabi/mongocxx.txt From 57acd57a30bd5dd88c782af8316336e608025bcf Mon Sep 17 00:00:00 2001 From: Ezra Chung Date: Tue, 23 Jan 2024 09:49:03 -0600 Subject: [PATCH 06/35] Disable string_view tests for external library polyfills --- src/bsoncxx/test/string_view.test.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/bsoncxx/test/string_view.test.cpp b/src/bsoncxx/test/string_view.test.cpp index 9c14d773c4..c9600208de 100644 --- a/src/bsoncxx/test/string_view.test.cpp +++ b/src/bsoncxx/test/string_view.test.cpp @@ -19,6 +19,8 @@ #include #include +#include + namespace stdx = bsoncxx::stdx; using stdx::string_view; @@ -28,6 +30,10 @@ static_assert(std::is_constructible::value, "fail"); static_assert(std::is_convertible::value, "fail"); static_assert(std::is_constructible::value, "fail"); +// Each polyfill library has some set of features that are not conformant with the standard +// specification (inconsistent, missing, etc.). Limit testing to bsoncxx implementation and stdlib. +#if defined(BSONCXX_POLY_USE_IMPLS) || defined(BSONCXX_POLY_USE_STD) + TEST_CASE("string_view: Default constructor") { (void)string_view(); string_view s; @@ -214,4 +220,6 @@ TEST_CASE("Convert to/from std::string_view") { bson_sv = std_sv; CHECK(bson_sv == std_sv); } -#endif \ No newline at end of file +#endif + +#endif // defined(BSONCXX_POLY_USE_IMPLS) || defined(BSONCXX_POLY_USE_STD) From ea7309fdfdb487cda7aa263aee46e4eac4e7cf14 Mon Sep 17 00:00:00 2001 From: Ezra Chung Date: Tue, 23 Jan 2024 12:42:59 -0600 Subject: [PATCH 07/35] Add changelog entry for ENABLE_BSONCXX_USE_POLY_IMPLS --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a585262d49..e4ce7599f9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,8 @@ Changes prior to 3.9.0 are documented as [release notes on GitHub](https://githu - Forward headers providing non-defining declarations of bsoncxx and mongocxx class types. - Note: user-defined forward declarations of any library entity has not been, and is still not, supported. To obtain the declaration or definition of a library entity, always include the corresponding header. +- The CMake option `ENABLE_BSONCXX_USE_POLY_IMPLS` (OFF by default) allows selecting bsoncxx implementations of C++17 polyfills by default when no polyfill library is requested. +- The CMake option `BSONCXX_POLY_USE_IMPLS` (OFF by default) allows selecting bsoncxx implementations of C++17 polyfills instead of external libraries or the C++ standard library. ### Changed From e3d08d53722c6d96351a8a49ea70e957c7ee7c67 Mon Sep 17 00:00:00 2001 From: Ezra Chung Date: Tue, 23 Jan 2024 13:23:13 -0600 Subject: [PATCH 08/35] CXX-2797 Document ENABLE_BSONCXX_POLY_USE_IMPLS and deprecate external polyfill libraries --- .../content/mongocxx-v3/api-abi-versioning.md | 11 ++- .../content/mongocxx-v3/installation/linux.md | 92 ++++++++++++------- .../content/mongocxx-v3/installation/macos.md | 92 ++++++++++++------- .../mongocxx-v3/installation/windows.md | 92 ++++++++++++------- 4 files changed, 183 insertions(+), 104 deletions(-) diff --git a/docs/content/mongocxx-v3/api-abi-versioning.md b/docs/content/mongocxx-v3/api-abi-versioning.md index c67f871a8f..9206193516 100644 --- a/docs/content/mongocxx-v3/api-abi-versioning.md +++ b/docs/content/mongocxx-v3/api-abi-versioning.md @@ -49,11 +49,12 @@ followed by a suffix describing the toolset and runtime library used to build th Some examples of common DSO filenames expected to be generated include: -* mongocxx-v_noabi-rhs-x64-v142-md.dll (release build configuration) -* mongocxx-v_noabi-dhs-x64-v142-mdd.dll (debug build configuration) -* mongocxx-v_noabi-rts-x64-v142-md.dll (link with mongoc statically) -* mongocxx-v_noabi-rhm-x64-v142-md.dll (mnmlstc/core polyfill library) -* mongocxx-v_noabi-rhb-x64-v142-md.dll (Boost polyfill library) +* `mongocxx-v_noabi-rhs-x64-v142-md.dll` (release build configuration) +* `mongocxx-v_noabi-dhs-x64-v142-mdd.dll` (debug build configuration) +* `mongocxx-v_noabi-rts-x64-v142-md.dll` (link with mongoc statically) +* `mongocxx-v_noabi-rhi-x64-v142-md.dll` (bsoncxx polyfill library) +* `mongocxx-v_noabi-rhm-x64-v142-md.dll` (mnmlstc/core polyfill library) +* `mongocxx-v_noabi-rhb-x64-v142-md.dll` (Boost polyfill library) This allows libraries built with different build configurations (and different runtime library requirements) to be built and installed without conflicting with each other. diff --git a/docs/content/mongocxx-v3/installation/linux.md b/docs/content/mongocxx-v3/installation/linux.md index 8386931947..d31b1b61af 100644 --- a/docs/content/mongocxx-v3/installation/linux.md +++ b/docs/content/mongocxx-v3/installation/linux.md @@ -9,39 +9,65 @@ title = "Linux" ### Step 1: Choose a C++17 polyfill -The mongocxx driver uses the C++17 features `std::optional` and -`std::string_view`. To compile the mongocxx driver for pre-C++17, you -must choose one of the following implementations for these features: - - MNMLSTC/core (*default for non-Windows platforms*) - Select with `-DBSONCXX_POLY_USE_MNMLSTC=1`. **NOTE**: This option - vendors a header-only installation of MNMLSTC/core into the bsoncxx - library installation and will therefore download MLNMLSTC from GitHub - during the build process. If you already have an available version of - MNMLSTC on your system, you can avoid the download step by using - `-DBSONCXX_POLY_USE_SYSTEM_MNMLSTC`. - - Boost (*default for Windows platforms*) - Select with `-DBSONCXX_POLY_USE_BOOST=1`. This is currently the - only option if you are using a version of MSVC that does not support - C++17. - - `std::experimental` - Select with `-DBSONCXX_POLY_USE_STD_EXPERIMENTAL=1`. If your - toolchain's standard library provides `optional` and - `string_view` in the namespace `std::experimental`, you can use - this option. Be aware that your standard library's - `std::experimental` implementation may change over time, - breaking binary compatibility in unexpected ways. Note that this - polyfill is *not* recommended and is unsupported. - -Most users should be fine sticking with the default. However, if you -have an existing application which makes heavy use of one of the -available libraries, you may prefer to build the mongocxx driver -against the same library. - -**DO NOT** change your project's polyfill if you need to create a -stable binary interface. +The mongocxx driver uses C++17 features `std::optional` and `std::string_view`. +To use the C++17 standard library implementations for these features, set +the CMake configuration variable `CMAKE_CXX_STANDARD` to 17 or higher. +Otherwise, to compile the mongocxx driver for pre-C++17 configurations, a +polyfill library implementation must be selected from the following options +(note: "default" refers to **pre-C++17** configurations when no polyfill library +is explicitly selected): + +* bsoncxx (*default only when `-DENABLE_BSONCXX_POLY_USE_IMPLS=ON`*) + + Select with `-DBSONCXX_POLY_USE_IMPLS=ON`. This option is most recommended, as + it does not require additional external library dependencies. To enable + selecting this option by default for pre-C++17 configurations when no other + options are specified, set `ENABLE_BSONCXX_POLY_USE_IMPLS=ON` (this option + will be set to ON by default in an upcoming major release). + +* MNMLSTC/core (*default for non-Windows platforms*) + + **This option is deprecated and will be removed in an upcoming major release.** + Select with `-DBSONCXX_POLY_USE_MNMLSTC=1`. **NOTE**: This option vendors a + header-only installation of MNMLSTC/core into the bsoncxx library installation + and will therefore download MLNMLSTC from GitHub during the configuration + process. If you already have an available version of MNMLSTC on your system, + you can avoid the download step by using `-DBSONCXX_POLY_USE_SYSTEM_MNMLSTC`. + +* Boost (*default for Windows platforms*) + + **This option is deprecated and will be removed in an upcoming major release.** + Select with `-DBSONCXX_POLY_USE_BOOST=1`. This is currently the only + non-bsoncxx option if you are using a version of MSVC that does not support + C++17. + +* `std::experimental` + + **This option is deprecated and will be removed in an upcoming major release.** + Select with `-DBSONCXX_POLY_USE_STD_EXPERIMENTAL=1`. If your toolchain's + standard library provides `optional` and `string_view` in the namespace + `std::experimental`, you can use this option. Be aware that your standard + library's `std::experimental` implementation may change over time, breaking + binary compatibility in unexpected ways. Note that this polyfill is *not* + recommended and is unsupported. + +Most users should use the default polyfill selection behavior. However, if you +have a preference for one of the external polyfill libraries (e.g. already a +dependency being used by your application), you may prefer to explicitly select +that external polyfill library rather than rely on default selection behavior. + +**NOTE**: C++ standard conformance and supported behavior of polyfill features +may vary depending on the selected polyfill library. The purpose of these +polyfills is to support pre-C++17 configurations by providing stand-ins for +their C++17 equivalents. Therefore we recommend using the C++17 standard +library whenever possible by setting `-DCMAKE_CXX_STANDARD=17` or newer. + +**WARNING**: the choice of polyfill library has a direct impact on the public +API and ABI for the mongocxx library. Changing the polyfill can lead to both +source-breaking changes (during compilation) and binary-breaking changes (during +linking or execution). To limit reliance on polyfill-specific configuration or +behavior, avoid using `stdx::string_view` and `stdx::optional` with +non-mongocxx library interfaces. ### Step 2: Download the latest version of the mongocxx driver. diff --git a/docs/content/mongocxx-v3/installation/macos.md b/docs/content/mongocxx-v3/installation/macos.md index ff615eeae1..ab6c6a77cc 100644 --- a/docs/content/mongocxx-v3/installation/macos.md +++ b/docs/content/mongocxx-v3/installation/macos.md @@ -9,39 +9,65 @@ title = "macOS" ### Step 1: Choose a C++17 polyfill -The mongocxx driver uses the C++17 features `std::optional` and -`std::string_view`. To compile the mongocxx driver for pre-C++17, you -must choose one of the following implementations for these features: - - MNMLSTC/core (*default for non-Windows platforms*) - Select with `-DBSONCXX_POLY_USE_MNMLSTC=1`. **NOTE**: This option - vendors a header-only installation of MNMLSTC/core into the bsoncxx - library installation and will therefore download MLNMLSTC from GitHub - during the build process. If you already have an available version of - MNMLSTC on your system, you can avoid the download step by using - `-DBSONCXX_POLY_USE_SYSTEM_MNMLSTC`. - - Boost (*default for Windows platforms*) - Select with `-DBSONCXX_POLY_USE_BOOST=1`. This is currently the - only option if you are using a version of MSVC that does not support - C++17. - - `std::experimental` - Select with `-DBSONCXX_POLY_USE_STD_EXPERIMENTAL=1`. If your - toolchain's standard library provides `optional` and - `string_view` in the namespace `std::experimental`, you can use - this option. Be aware that your standard library's - `std::experimental` implementation may change over time, - breaking binary compatibility in unexpected ways. Note that this - polyfill is *not* recommended and is unsupported. - -Most users should be fine sticking with the default. However, if you -have an existing application which makes heavy use of one of the -available libraries, you may prefer to build the mongocxx driver -against the same library. - -**DO NOT** change your project's polyfill if you need to create a -stable binary interface. +The mongocxx driver uses C++17 features `std::optional` and `std::string_view`. +To use the C++17 standard library implementations for these features, set +the CMake configuration variable `CMAKE_CXX_STANDARD` to 17 or higher. +Otherwise, to compile the mongocxx driver for pre-C++17 configurations, a +polyfill library implementation must be selected from the following options +(note: "default" refers to **pre-C++17** configurations when no polyfill library +is explicitly selected): + +* bsoncxx (*default only when `-DENABLE_BSONCXX_POLY_USE_IMPLS=ON`*) + + Select with `-DBSONCXX_POLY_USE_IMPLS=ON`. This option is most recommended, as + it does not require additional external library dependencies. To enable + selecting this option by default for pre-C++17 configurations when no other + options are specified, set `ENABLE_BSONCXX_POLY_USE_IMPLS=ON` (this option + will be set to ON by default in an upcoming major release). + +* MNMLSTC/core (*default for non-Windows platforms*) + + **This option is deprecated and will be removed in an upcoming major release.** + Select with `-DBSONCXX_POLY_USE_MNMLSTC=1`. **NOTE**: This option vendors a + header-only installation of MNMLSTC/core into the bsoncxx library installation + and will therefore download MLNMLSTC from GitHub during the configuration + process. If you already have an available version of MNMLSTC on your system, + you can avoid the download step by using `-DBSONCXX_POLY_USE_SYSTEM_MNMLSTC`. + +* Boost (*default for Windows platforms*) + + **This option is deprecated and will be removed in an upcoming major release.** + Select with `-DBSONCXX_POLY_USE_BOOST=1`. This is currently the only + non-bsoncxx option if you are using a version of MSVC that does not support + C++17. + +* `std::experimental` + + **This option is deprecated and will be removed in an upcoming major release.** + Select with `-DBSONCXX_POLY_USE_STD_EXPERIMENTAL=1`. If your toolchain's + standard library provides `optional` and `string_view` in the namespace + `std::experimental`, you can use this option. Be aware that your standard + library's `std::experimental` implementation may change over time, breaking + binary compatibility in unexpected ways. Note that this polyfill is *not* + recommended and is unsupported. + +Most users should use the default polyfill selection behavior. However, if you +have a preference for one of the external polyfill libraries (e.g. already a +dependency being used by your application), you may prefer to explicitly select +that external polyfill library rather than rely on default selection behavior. + +**NOTE**: C++ standard conformance and supported behavior of polyfill features +may vary depending on the selected polyfill library. The purpose of these +polyfills is to support pre-C++17 configurations by providing stand-ins for +their C++17 equivalents. Therefore we recommend using the C++17 standard +library whenever possible by setting `-DCMAKE_CXX_STANDARD=17` or newer. + +**WARNING**: the choice of polyfill library has a direct impact on the public +API and ABI for the mongocxx library. Changing the polyfill can lead to both +source-breaking changes (during compilation) and binary-breaking changes (during +linking or execution). To limit reliance on polyfill-specific configuration or +behavior, avoid using `stdx::string_view` and `stdx::optional` with +non-mongocxx library interfaces. ### Step 2: Download the latest version of the mongocxx driver. diff --git a/docs/content/mongocxx-v3/installation/windows.md b/docs/content/mongocxx-v3/installation/windows.md index 6c4589d023..a7f5dbb379 100644 --- a/docs/content/mongocxx-v3/installation/windows.md +++ b/docs/content/mongocxx-v3/installation/windows.md @@ -9,39 +9,65 @@ title = "Windows" ### Step 1: Choose a C++17 polyfill -The mongocxx driver uses the C++17 features `std::optional` and -`std::string_view`. To compile the mongocxx driver for pre-C++17, you -must choose one of the following implementations for these features: - - MNMLSTC/core (*default for non-Windows platforms*) - Select with `-DBSONCXX_POLY_USE_MNMLSTC=1`. **NOTE**: This option - vendors a header-only installation of MNMLSTC/core into the bsoncxx - library installation and will therefore download MLNMLSTC from GitHub - during the build process. If you already have an available version of - MNMLSTC on your system, you can avoid the download step by using - `-DBSONCXX_POLY_USE_SYSTEM_MNMLSTC`. - - Boost (*default for Windows platforms*) - Select with `-DBSONCXX_POLY_USE_BOOST=1`. This is currently the - only option if you are using a version of MSVC that does not support - C++17. - - `std::experimental` - Select with `-DBSONCXX_POLY_USE_STD_EXPERIMENTAL=1`. If your - toolchain's standard library provides `optional` and - `string_view` in the namespace `std::experimental`, you can use - this option. Be aware that your standard library's - `std::experimental` implementation may change over time, - breaking binary compatibility in unexpected ways. Note that this - polyfill is *not* recommended and is unsupported. - -Most users should be fine sticking with the default. However, if you -have an existing application which makes heavy use of one of the -available libraries, you may prefer to build the mongocxx driver -against the same library. - -**DO NOT** change your project's polyfill if you need to create a -stable binary interface. +The mongocxx driver uses C++17 features `std::optional` and `std::string_view`. +To use the C++17 standard library implementations for these features, set +the CMake configuration variable `CMAKE_CXX_STANDARD` to 17 or higher. +Otherwise, to compile the mongocxx driver for pre-C++17 configurations, a +polyfill library implementation must be selected from the following options +(note: "default" refers to **pre-C++17** configurations when no polyfill library +is explicitly selected): + +* bsoncxx (*default only when `-DENABLE_BSONCXX_POLY_USE_IMPLS=ON`*) + + Select with `-DBSONCXX_POLY_USE_IMPLS=ON`. This option is most recommended, as + it does not require additional external library dependencies. To enable + selecting this option by default for pre-C++17 configurations when no other + options are specified, set `ENABLE_BSONCXX_POLY_USE_IMPLS=ON` (this option + will be set to ON by default in an upcoming major release). + +* MNMLSTC/core (*default for non-Windows platforms*) + + **This option is deprecated and will be removed in an upcoming major release.** + Select with `-DBSONCXX_POLY_USE_MNMLSTC=1`. **NOTE**: This option vendors a + header-only installation of MNMLSTC/core into the bsoncxx library installation + and will therefore download MLNMLSTC from GitHub during the configuration + process. If you already have an available version of MNMLSTC on your system, + you can avoid the download step by using `-DBSONCXX_POLY_USE_SYSTEM_MNMLSTC`. + +* Boost (*default for Windows platforms*) + + **This option is deprecated and will be removed in an upcoming major release.** + Select with `-DBSONCXX_POLY_USE_BOOST=1`. This is currently the only + non-bsoncxx option if you are using a version of MSVC that does not support + C++17. + +* `std::experimental` + + **This option is deprecated and will be removed in an upcoming major release.** + Select with `-DBSONCXX_POLY_USE_STD_EXPERIMENTAL=1`. If your toolchain's + standard library provides `optional` and `string_view` in the namespace + `std::experimental`, you can use this option. Be aware that your standard + library's `std::experimental` implementation may change over time, breaking + binary compatibility in unexpected ways. Note that this polyfill is *not* + recommended and is unsupported. + +Most users should use the default polyfill selection behavior. However, if you +have a preference for one of the external polyfill libraries (e.g. already a +dependency being used by your application), you may prefer to explicitly select +that external polyfill library rather than rely on default selection behavior. + +**NOTE**: C++ standard conformance and supported behavior of polyfill features +may vary depending on the selected polyfill library. The purpose of these +polyfills is to support pre-C++17 configurations by providing stand-ins for +their C++17 equivalents. Therefore we recommend using the C++17 standard +library whenever possible by setting `-DCMAKE_CXX_STANDARD=17` or newer. + +**WARNING**: the choice of polyfill library has a direct impact on the public +API and ABI for the mongocxx library. Changing the polyfill can lead to both +source-breaking changes (during compilation) and binary-breaking changes (during +linking or execution). To limit reliance on polyfill-specific configuration or +behavior, avoid using `stdx::string_view` and `stdx::optional` with +non-mongocxx library interfaces. ### Step 2: Download the latest version of the mongocxx driver. From f773f3064c0872b2bd0c03a6ddf1530957b61094 Mon Sep 17 00:00:00 2001 From: Ezra Chung Date: Tue, 23 Jan 2024 14:31:16 -0600 Subject: [PATCH 09/35] CXX-2746 Ignore detail namespaces in abi-compliance-check-test.sh --- .evergreen/abi-compliance-check-test.sh | 106 +++++++++++------------- 1 file changed, 47 insertions(+), 59 deletions(-) diff --git a/.evergreen/abi-compliance-check-test.sh b/.evergreen/abi-compliance-check-test.sh index d359840b89..8837e5cf00 100755 --- a/.evergreen/abi-compliance-check-test.sh +++ b/.evergreen/abi-compliance-check-test.sh @@ -22,20 +22,13 @@ command -V abi-compliance-checker >/dev/null mkdir cxx-abi cxx-noabi -cat >cxx-abi/old.xml <old.xml < ${old_ver:?} - - ../install/old/include/bsoncxx/ - ../install/old/include/mongocxx/ - - - - /v_noabi/ - - ../install/old/lib @@ -44,26 +37,13 @@ cat >cxx-abi/old.xml < - - bsoncxx/enums/ - /config/ - DOC -cat >cxx-abi/new.xml <new.xml < ${new_ver:?} - - ../install/new/include/mongocxx/ - ../install/new/include/bsoncxx/ - - - - /v_noabi/ - - ../install/new/lib @@ -72,59 +52,67 @@ cat >cxx-abi/new.xml < +DOC + + { + cat < - bsoncxx/enums/ - /config/ + bsoncxx/v_noabi/bsoncxx/enums/ + bsoncxx/v_noabi/bsoncxx/config/ + + + bsoncxx::detail + bsoncxx::v_noabi::detail + bsoncxx::v_noabi::stdx::detail + + DOC + } | tee -a old.xml new.xml >/dev/null -cat >cxx-noabi/old.xml < - ${old_ver:?} - + cat old.xml | tee cxx-abi/old.xml cxx-noabi/old.xml >/dev/null + cat new.xml | tee cxx-abi/new.xml cxx-noabi/new.xml >/dev/null + rm old.xml new.xml +fi +# Append sections specific to each ABI test. +if true; then + cat >>cxx-abi/old.xml < + ../install/old/include/bsoncxx/ + ../install/old/include/mongocxx/ + + + + /v_noabi/ + +DOC + + cat >>cxx-noabi/old.xml < ../install/old/include/bsoncxx/v_noabi ../install/old/include/mongocxx/v_noabi +DOC - - ../install/old/lib - - - - ../install/old/include/ - + cat >>cxx-abi/new.xml < + ../install/new/include/mongocxx/ + ../install/new/include/bsoncxx/ + - - bsoncxx/enums/ - /config/ - + + /v_noabi/ + DOC -cat >cxx-noabi/new.xml < - ${new_ver:?} - - + cat >>cxx-noabi/new.xml < ../install/new/include/bsoncxx/v_noabi ../install/new/include/mongocxx/v_noabi - - - ../install/new/lib - - - - ../install/new/include/ - - - - bsoncxx/enums/ - /config/ - DOC +fi # Allow task to upload the HTML report despite failed status. echo "Generating stable ABI report..." From c274948fe09d0ae83ad71ab96ecb1510cb416dfb Mon Sep 17 00:00:00 2001 From: Ezra Chung Date: Tue, 23 Jan 2024 15:30:18 -0600 Subject: [PATCH 10/35] Add deprecation warnings for external polyfill library configurations --- src/bsoncxx/CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/bsoncxx/CMakeLists.txt b/src/bsoncxx/CMakeLists.txt index e6f491f4ea..2efb4e6129 100644 --- a/src/bsoncxx/CMakeLists.txt +++ b/src/bsoncxx/CMakeLists.txt @@ -55,11 +55,15 @@ elseif(BSONCXX_POLY_OPTIONS_SET EQUAL 0) # Otherwise, since MSVC can't handle MNMLSTC, default to boost set(BSONCXX_POLY_USE_BOOST ON) message(STATUS "Auto-configuring bsoncxx to use boost std library polyfills since C++17 is inactive and compiler is MSVC") + message(DEPRECATION "Default selection of external polyfill libraries is deprecated and will be removed in an upcoming major release. Set ENABLE_BSONCXX_POLY_USE_IMPLS=ON to enable recommended behavior.") else() # Otherwise, we are on a platform that can handle MNMLSTC set(BSONCXX_POLY_USE_MNMLSTC ON) message(STATUS "Auto-configuring bsoncxx to use MNMLSTC for polyfills since C++17 is inactive") + message(DEPRECATION "Default selection of external polyfill libraries is deprecated and will be removed in an upcoming major release. Set ENABLE_BSONCXX_POLY_USE_IMPLS=ON to enable recommended behavior.") endif() +elseif(BSONCXX_POLY_USE_MNMLSTC OR BSONCXX_POLY_USE_BOOST) + message(DEPRECATION "Support for external polyfill libraries is deprecated and will be removed in an upcoming major release. Set BSONCXX_POLY_USE_IMPLS=ON (pre-C++17) or CMAKE_CXX_STANDARD=17 (or newer) instead.") endif() # It doesn't make sense to say we aren't using MNMLSTC but then From 3bac3d69e58037e9632654022b364914366d3db2 Mon Sep 17 00:00:00 2001 From: Ezra Chung Date: Tue, 23 Jan 2024 15:36:40 -0600 Subject: [PATCH 11/35] Tweak wording of deprecation message to state _recommended_ behavior --- src/bsoncxx/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bsoncxx/CMakeLists.txt b/src/bsoncxx/CMakeLists.txt index 2efb4e6129..9a508c0847 100644 --- a/src/bsoncxx/CMakeLists.txt +++ b/src/bsoncxx/CMakeLists.txt @@ -63,7 +63,7 @@ elseif(BSONCXX_POLY_OPTIONS_SET EQUAL 0) message(DEPRECATION "Default selection of external polyfill libraries is deprecated and will be removed in an upcoming major release. Set ENABLE_BSONCXX_POLY_USE_IMPLS=ON to enable recommended behavior.") endif() elseif(BSONCXX_POLY_USE_MNMLSTC OR BSONCXX_POLY_USE_BOOST) - message(DEPRECATION "Support for external polyfill libraries is deprecated and will be removed in an upcoming major release. Set BSONCXX_POLY_USE_IMPLS=ON (pre-C++17) or CMAKE_CXX_STANDARD=17 (or newer) instead.") + message(DEPRECATION "Support for external polyfill libraries is deprecated and will be removed in an upcoming major release. Set BSONCXX_POLY_USE_IMPLS=ON (pre-C++17) or set CMAKE_CXX_STANDARD=17 (or newer) to select recommended behavior.") endif() # It doesn't make sense to say we aren't using MNMLSTC but then From dd23ba6bc71b5200df4d41725c9065107b9d16c8 Mon Sep 17 00:00:00 2001 From: Ezra Chung Date: Wed, 24 Jan 2024 13:02:08 -0600 Subject: [PATCH 12/35] Add impls to list of mutually exclusive polyfill options --- src/bsoncxx/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bsoncxx/CMakeLists.txt b/src/bsoncxx/CMakeLists.txt index 9a508c0847..b1906e5bf7 100644 --- a/src/bsoncxx/CMakeLists.txt +++ b/src/bsoncxx/CMakeLists.txt @@ -32,7 +32,7 @@ set(BSONCXX_OUTPUT_BASENAME "bsoncxx" CACHE STRING "Output bsoncxx library base # Count how many polyfill options are true-ish set(BSONCXX_POLY_OPTIONS_SET 0) -foreach(BSONCXX_POLY_OPTION ${BSONCXX_POLY_USE_MNMLSTC} ${BSONCXX_POLY_USE_STD_EXPERIMENTAL} ${BSONCXX_POLY_USE_BOOST} ${BSONCXX_POLY_USE_STD}) +foreach(BSONCXX_POLY_OPTION ${BSONCXX_POLY_USE_IMPLS} ${BSONCXX_POLY_USE_MNMLSTC} ${BSONCXX_POLY_USE_STD_EXPERIMENTAL} ${BSONCXX_POLY_USE_BOOST} ${BSONCXX_POLY_USE_STD}) if(${BSONCXX_POLY_OPTION}) MATH(EXPR BSONCXX_POLY_OPTIONS_SET "${BSONCXX_POLY_OPTIONS_SET}+1") endif() From 75ad387ff98b51d540a7ec0a572f750fd0a3673f Mon Sep 17 00:00:00 2001 From: Ezra Chung Date: Wed, 24 Jan 2024 13:03:24 -0600 Subject: [PATCH 13/35] Fix endif comment in make_unique.hpp --- .../include/bsoncxx/v_noabi/bsoncxx/stdx/make_unique.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/stdx/make_unique.hpp b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/stdx/make_unique.hpp index f36d0aa7d8..c05f21a590 100644 --- a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/stdx/make_unique.hpp +++ b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/stdx/make_unique.hpp @@ -99,7 +99,8 @@ struct make_unique_impl {}; } // namespace v_noabi } // namespace bsoncxx -#endif // defined(BSONCXX_DETAIL_USE_IMPLS_MAKE_UNIQUE) +#endif // !defined(BSONCXX_DETAIL_USE_STD_MAKE_UNIQUE) || + // !defined(__cpp_lib_smart_ptr_for_overwrite) namespace bsoncxx { namespace v_noabi { From 552550b54dd6e5e7224bd3df9a639264d318ab9a Mon Sep 17 00:00:00 2001 From: Ezra Chung Date: Tue, 13 Feb 2024 12:42:13 -0600 Subject: [PATCH 14/35] Formatting --- .evergreen/compile.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.evergreen/compile.sh b/.evergreen/compile.sh index 3bd977289c..8b2760539f 100755 --- a/.evergreen/compile.sh +++ b/.evergreen/compile.sh @@ -114,7 +114,7 @@ case "${OSTYPE:?}" in cygwin) case "${generator:-}" in *2015*) cmake_flags+=("-DBOOST_ROOT=C:/local/boost_1_60_0") ;; - *2017*|*2019*) cmake_flags+=("-DCMAKE_CXX_STANDARD=17") ;; + *2017* | *2019*) cmake_flags+=("-DCMAKE_CXX_STANDARD=17") ;; *) echo "missing explicit CMake Generator on Windows distro" 1>&2 exit 1 From e184c3f88076caf194e31e8bfb39a3b41032a189 Mon Sep 17 00:00:00 2001 From: Ezra Chung Date: Mon, 12 Feb 2024 13:20:21 -0600 Subject: [PATCH 15/35] Avoid including external symbols in v_noabi abidiff reports --- .evergreen/abidiff-test.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.evergreen/abidiff-test.sh b/.evergreen/abidiff-test.sh index 31e2919bf5..cac8a223c7 100755 --- a/.evergreen/abidiff-test.sh +++ b/.evergreen/abidiff-test.sh @@ -36,13 +36,13 @@ DOC cat >cxx-noabi/abignore < Date: Mon, 12 Feb 2024 13:35:11 -0600 Subject: [PATCH 16/35] Restore polyfill selection for optional.hpp --- .../bsoncxx/v_noabi/bsoncxx/stdx/optional.hpp | 75 ++++++++++++++++++- 1 file changed, 71 insertions(+), 4 deletions(-) diff --git a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/stdx/optional.hpp b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/stdx/optional.hpp index eb9db49474..0040a97ebe 100644 --- a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/stdx/optional.hpp +++ b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/stdx/optional.hpp @@ -14,6 +14,71 @@ #pragma once +#include + +#if defined(BSONCXX_POLY_USE_MNMLSTC) + +#include + +namespace bsoncxx { +namespace v_noabi { +namespace stdx { + +using ::core::in_place; +using ::core::in_place_t; +using ::core::make_optional; +using ::core::nullopt; +using ::core::nullopt_t; +using ::core::optional; + +} // namespace stdx +} // namespace v_noabi +} // namespace bsoncxx + +#elif defined(BSONCXX_POLY_USE_BOOST) + +#include +#include +#include + +namespace bsoncxx { +namespace v_noabi { +namespace stdx { + +using in_place_t = ::boost::in_place_init_t; +const in_place_t in_place{::boost::in_place_init}; + +using ::boost::optional; +using nullopt_t = ::boost::none_t; + +const nullopt_t nullopt{::boost::none}; +using ::boost::make_optional; + +} // namespace stdx +} // namespace v_noabi +} // namespace bsoncxx + +#elif defined(BSONCXX_POLY_USE_STD) + +#include + +namespace bsoncxx { +namespace v_noabi { +namespace stdx { + +using ::std::in_place; +using ::std::in_place_t; +using ::std::make_optional; +using ::std::nullopt; +using ::std::nullopt_t; +using ::std::optional; + +} // namespace stdx +} // namespace v_noabi +} // namespace bsoncxx + +#elif defined(BSONCXX_POLY_USE_IMPLS) + #include #include #include @@ -23,10 +88,8 @@ #include #include -#include "./operators.hpp" -#include "./type_traits.hpp" - -#include +#include +#include namespace bsoncxx { @@ -771,6 +834,10 @@ struct hash> } // namespace std +#else +#error "Cannot find a valid polyfill for optional" +#endif + #include namespace bsoncxx { From 27f70547cb0bd6d389c7c31ed3644eede7bc4b5e Mon Sep 17 00:00:00 2001 From: Ezra Chung Date: Mon, 12 Feb 2024 13:40:16 -0600 Subject: [PATCH 17/35] Ignore warnings for symbols unreferenced by debug info --- .evergreen/abidiff-test.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.evergreen/abidiff-test.sh b/.evergreen/abidiff-test.sh index cac8a223c7..cc4ea1de2b 100755 --- a/.evergreen/abidiff-test.sh +++ b/.evergreen/abidiff-test.sh @@ -13,7 +13,8 @@ declare -a common_flags common_flags=( --headers-dir1 install/old/include --headers-dir2 install/new/include - --fail-no-debug-info + --fail-no-debug-info # Ensure debug info is present for our libs. + --no-unreferenced-symbols # Not interested in symbols not owned by our libs. ) declare -a abi_flags=("${common_flags[@]:?}" --suppressions cxx-abi/abignore) From f9d9076ef6b30e7d06516cbbd28eb507ef187b59 Mon Sep 17 00:00:00 2001 From: Ezra Chung Date: Mon, 12 Feb 2024 13:44:06 -0600 Subject: [PATCH 18/35] Fix scoped_bson_t ambiguous overloads for views and values --- .../v_noabi/mongocxx/private/libbson.cpp | 35 ++++++++++++--- .../v_noabi/mongocxx/private/libbson.hh | 44 ++++++++++++++++++- 2 files changed, 71 insertions(+), 8 deletions(-) diff --git a/src/mongocxx/lib/mongocxx/v_noabi/mongocxx/private/libbson.cpp b/src/mongocxx/lib/mongocxx/v_noabi/mongocxx/private/libbson.cpp index 46e2175b0c..0052242690 100644 --- a/src/mongocxx/lib/mongocxx/v_noabi/mongocxx/private/libbson.cpp +++ b/src/mongocxx/lib/mongocxx/v_noabi/mongocxx/private/libbson.cpp @@ -31,20 +31,41 @@ void doc_to_bson_t(const bsoncxx::v_noabi::document::view& doc, bson_t* bson) { } // namespace -scoped_bson_t::scoped_bson_t(bsoncxx::stdx::optional doc) - : _is_initialized{doc} { +scoped_bson_t::scoped_bson_t(bsoncxx::document::view_or_value doc) + : _is_initialized{true}, _doc{std::move(doc)} { + doc_to_bson_t(*_doc, &_bson); +} + +void scoped_bson_t::init_from_static(bsoncxx::document::view_or_value doc) { + _is_initialized = true; + _doc = std::move(doc); + doc_to_bson_t(*_doc, &_bson); +} + +scoped_bson_t::scoped_bson_t(bsoncxx::document::view doc) + : scoped_bson_t(bsoncxx::document::view_or_value(doc)) {} + +void scoped_bson_t::init_from_static(bsoncxx::document::view doc) { + this->init_from_static(bsoncxx::document::view_or_value(doc)); +} + +scoped_bson_t::scoped_bson_t(bsoncxx::document::value doc) + : scoped_bson_t(bsoncxx::document::view_or_value(std::move(doc))) {} + +void scoped_bson_t::init_from_static(bsoncxx::document::value doc) { + this->init_from_static(bsoncxx::document::view_or_value(std::move(doc))); +} + +scoped_bson_t::scoped_bson_t(bsoncxx::stdx::optional doc) { if (doc) { - _doc = std::move(doc); - doc_to_bson_t(*_doc, &_bson); + this->init_from_static(std::move(*doc)); } } void scoped_bson_t::init_from_static( bsoncxx::v_noabi::stdx::optional doc) { if (doc) { - _is_initialized = true; - _doc = std::move(doc); - doc_to_bson_t(*_doc, &_bson); + this->init_from_static(std::move(*doc)); } } diff --git a/src/mongocxx/lib/mongocxx/v_noabi/mongocxx/private/libbson.hh b/src/mongocxx/lib/mongocxx/v_noabi/mongocxx/private/libbson.hh index 288c1e0d8e..75955e5946 100644 --- a/src/mongocxx/lib/mongocxx/v_noabi/mongocxx/private/libbson.hh +++ b/src/mongocxx/lib/mongocxx/v_noabi/mongocxx/private/libbson.hh @@ -52,6 +52,48 @@ class MONGOCXX_TEST_API scoped_bson_t { // scoped_bson_t(); + // + // Constructs a new scoped_bson_t from a document view_or_value. + // + // The internal bson_t is considered initialized. + // + explicit scoped_bson_t(bsoncxx::document::view_or_value doc); + + // + // Initializes a bson_t from the provided document. + // + // The internal bson_t is considered initialized. + // + void init_from_static(bsoncxx::document::view_or_value doc); + + // + // Constructs a new scoped_bson_t from a document view_or_value. + // + // The internal bson_t is considered initialized. + // + explicit scoped_bson_t(bsoncxx::document::view doc); + + // + // Initializes a bson_t from the provided document. + // + // The internal bson_t is considered initialized. + // + void init_from_static(bsoncxx::document::view doc); + + // + // Constructs a new scoped_bson_t from a document. + // + // The internal bson_t is considered initialized. + // + explicit scoped_bson_t(bsoncxx::document::value doc); + + // + // Initializes a bson_t from the provided document. + // + // The internal bson_t is considered initialized. + // + void init_from_static(bsoncxx::document::value doc); + // // Constructs a new scoped_bson_t from an optional document view_or_value. // @@ -111,7 +153,7 @@ class MONGOCXX_TEST_API scoped_bson_t { private: bson_t _bson; - bool _is_initialized; + bool _is_initialized = false; // If we are passed a value created on-the-fly, we'll need to own this. bsoncxx::v_noabi::stdx::optional _doc; From 7a23d4afcdc52e83d846754c4e54d80a0d1627a8 Mon Sep 17 00:00:00 2001 From: Ezra Chung Date: Mon, 12 Feb 2024 13:51:01 -0600 Subject: [PATCH 19/35] Add missing include in catch.hh --- src/bsoncxx/test/catch.hh | 1 + 1 file changed, 1 insertion(+) diff --git a/src/bsoncxx/test/catch.hh b/src/bsoncxx/test/catch.hh index 8f5e3421cf..4fb9916880 100644 --- a/src/bsoncxx/test/catch.hh +++ b/src/bsoncxx/test/catch.hh @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include From 5c343f80838d4c29ce690875c1301ae929293d45 Mon Sep 17 00:00:00 2001 From: Ezra Chung Date: Mon, 12 Feb 2024 14:14:20 -0600 Subject: [PATCH 20/35] Disable optional tests for external library polyfills --- src/bsoncxx/test/optional.test.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/bsoncxx/test/optional.test.cpp b/src/bsoncxx/test/optional.test.cpp index bfa0c83cfa..0f190233de 100644 --- a/src/bsoncxx/test/optional.test.cpp +++ b/src/bsoncxx/test/optional.test.cpp @@ -12,6 +12,12 @@ #include #include +#include + +// Each polyfill library has some set of features that are not conformant with the standard +// specification (inconsistent, missing, etc.). Limit testing to bsoncxx implementation and stdlib. +#if defined(BSONCXX_POLY_USE_IMPLS) || defined(BSONCXX_POLY_USE_STD) + using bsoncxx::stdx::in_place; using bsoncxx::stdx::nullopt; using bsoncxx::stdx::optional; @@ -619,3 +625,5 @@ TEST_CASE("optional conversions") { CHECK(string == c_str); CHECK(string2 == c_str); } + +#endif // defined(BSONCXX_POLY_USE_IMPLS) || defined(BSONCXX_POLY_USE_STD) From d0f910c88cb3c59421809552363e5e867866157b Mon Sep 17 00:00:00 2001 From: Ezra Chung Date: Mon, 12 Feb 2024 14:15:48 -0600 Subject: [PATCH 21/35] Conditionally disable convertible ctor static assertion --- src/bsoncxx/test/optional.test.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/bsoncxx/test/optional.test.cpp b/src/bsoncxx/test/optional.test.cpp index 0f190233de..5f8e20cf34 100644 --- a/src/bsoncxx/test/optional.test.cpp +++ b/src/bsoncxx/test/optional.test.cpp @@ -610,7 +610,10 @@ struct in_place_convertible { }; TEST_CASE("optional conversions") { + // Some stdlib implementations do not forbid this ctor correctly. +#if defined(BSONCXX_POLY_USE_IMPLS) static_assert(!std::is_constructible, optional>{}, "fail"); +#endif // defined(BSONCXX_POLY_USE_IMPLS) optional s1(bsoncxx::stdx::in_place); CHECK(s1 == ""); From 8bdf1ed35ce86e3a2457db3490f216a5790f28ac Mon Sep 17 00:00:00 2001 From: Ezra Chung Date: Mon, 12 Feb 2024 14:32:03 -0600 Subject: [PATCH 22/35] Fix missing std::in_place equivalent for Boost before 1.63 --- .../include/bsoncxx/v_noabi/bsoncxx/stdx/optional.hpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/stdx/optional.hpp b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/stdx/optional.hpp index 0040a97ebe..f6c9608b57 100644 --- a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/stdx/optional.hpp +++ b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/stdx/optional.hpp @@ -45,8 +45,10 @@ namespace bsoncxx { namespace v_noabi { namespace stdx { +#if BOOST_VERSION >= 106300 using in_place_t = ::boost::in_place_init_t; const in_place_t in_place{::boost::in_place_init}; +#endif using ::boost::optional; using nullopt_t = ::boost::none_t; @@ -843,8 +845,12 @@ struct hash> namespace bsoncxx { namespace stdx { +// Only Boost prior to 1.63 does not provide an `std::in_place` equivalent. +#if !defined(BOOST_VERSION) || BOOST_VERSION >= 106300 using ::bsoncxx::v_noabi::stdx::in_place; using ::bsoncxx::v_noabi::stdx::in_place_t; +#endif + using ::bsoncxx::v_noabi::stdx::make_optional; using ::bsoncxx::v_noabi::stdx::nullopt; using ::bsoncxx::v_noabi::stdx::nullopt_t; From 39979f6f645475f3f8cd595285cef44dc48a67f6 Mon Sep 17 00:00:00 2001 From: Ezra Chung Date: Mon, 12 Feb 2024 17:08:30 -0600 Subject: [PATCH 23/35] Improve quality of error messages for type trait assertions --- src/bsoncxx/test/optional.test.cpp | 111 ++++++++++++++--------------- 1 file changed, 52 insertions(+), 59 deletions(-) diff --git a/src/bsoncxx/test/optional.test.cpp b/src/bsoncxx/test/optional.test.cpp index 5f8e20cf34..9b3f2dae05 100644 --- a/src/bsoncxx/test/optional.test.cpp +++ b/src/bsoncxx/test/optional.test.cpp @@ -76,49 +76,44 @@ struct not_copyable { not_copyable& operator=(not_copyable&&) = default; }; +// Improve quality of error messages on failure (in particular for MSVC). +#define STATIC_ASSERT_EXPR(expr) static_assert((expr), "expected: " #expr) +#define STATIC_ASSERT_EXPR_EQUAL(a, b) static_assert((a) == (b), "expected: " #a " == " #b) +#define STATIC_ASSERT_EXPR_IMPLIES(a, b) static_assert((!(a) || (b)), "expected: " #a " -> " #b) + template bool assert_sameness() { - static_assert(Trait::value == Trait>::value, "Fail"); + STATIC_ASSERT_EXPR_EQUAL(Trait::value, Trait>::value); return true; } template bool check_convert_alike() { - static_assert(std::is_convertible::value // - == std::is_convertible::value, - "fail"); - static_assert(std::is_convertible::value // - == std::is_convertible::value, - "fail"); - static_assert(std::is_convertible::value // - == std::is_convertible::value, - "fail"); - static_assert(std::is_convertible::value // - == std::is_convertible::value, - "fail"); - static_assert(std::is_convertible::value // - == std::is_convertible::value, - "fail"); + STATIC_ASSERT_EXPR_EQUAL((std::is_convertible::value), + (std::is_convertible::value)); + STATIC_ASSERT_EXPR_EQUAL((std::is_convertible::value), + (std::is_convertible::value)); + STATIC_ASSERT_EXPR_EQUAL((std::is_convertible::value), + (std::is_convertible::value)); + STATIC_ASSERT_EXPR_EQUAL((std::is_convertible::value), + (std::is_convertible::value)); + STATIC_ASSERT_EXPR_EQUAL((std::is_convertible::value), + (std::is_convertible::value)); return true; } template bool check_construct_alike() { - static_assert(std::is_constructible::value // - == std::is_constructible::value, - "fail"); - static_assert(std::is_constructible::value // - == std::is_constructible::value, - "fail"); - static_assert(std::is_constructible::value // - == std::is_constructible::value, - "fail"); - static_assert(std::is_constructible::value // - == std::is_constructible::value, - "fail"); - static_assert(std::is_constructible::value // - == std::is_constructible::value, - "fail"); + STATIC_ASSERT_EXPR_EQUAL((std::is_constructible::value), + (std::is_constructible::value)); + STATIC_ASSERT_EXPR_EQUAL((std::is_constructible::value), + (std::is_constructible::value)); + STATIC_ASSERT_EXPR_EQUAL((std::is_constructible::value), + (std::is_constructible::value)); + STATIC_ASSERT_EXPR_EQUAL((std::is_constructible::value), + (std::is_constructible::value)); + STATIC_ASSERT_EXPR_EQUAL((std::is_constructible::value), + (std::is_constructible::value)); return true; } @@ -140,47 +135,45 @@ bool static_checks() { assert_sameness(); assert_sameness(); assert_sameness(); - static_assert(bsoncxx::detail::is_equality_comparable>::value == - bsoncxx::detail::is_equality_comparable::value, - "fail"); - static_assert(bsoncxx::detail::is_totally_ordered_with>::value == - bsoncxx::detail::is_totally_ordered>::value, - "fail"); - static_assert( - std::is_constructible, T>::value == std::is_constructible::value, "fail"); - static_assert(std::is_constructible, bsoncxx::stdx::nullopt_t>{}, "fail"); + STATIC_ASSERT_EXPR_EQUAL((bsoncxx::detail::is_equality_comparable>::value), + (bsoncxx::detail::is_equality_comparable::value)); + STATIC_ASSERT_EXPR_EQUAL((bsoncxx::detail::is_totally_ordered_with>::value), + (bsoncxx::detail::is_totally_ordered>::value)); + STATIC_ASSERT_EXPR_EQUAL((std::is_constructible, T>::value), + (std::is_constructible::value)); + STATIC_ASSERT_EXPR((std::is_constructible, bsoncxx::stdx::nullopt_t>::value)); // Assert we return proper reference types - static_assert(std::is_same>, T&&>{}, "fail"); - static_assert(std::is_same const>, const T&&>{}, "fail"); - static_assert(std::is_same const&>, const T&>{}, "fail"); - static_assert(std::is_same&>, T&>{}, "fail"); + STATIC_ASSERT_EXPR((std::is_same>, T&&>::value)); + STATIC_ASSERT_EXPR((std::is_same const>, const T&&>::value)); + STATIC_ASSERT_EXPR((std::is_same const&>, const T&>::value)); + STATIC_ASSERT_EXPR((std::is_same&>, T&>::value)); // .value() - static_assert(std::is_same>, T&&>{}, "fail"); - static_assert(std::is_same const>, const T&&>{}, "fail"); - static_assert(std::is_same const&>, const T&>{}, "fail"); - static_assert(std::is_same&>, T&>{}, "fail"); + STATIC_ASSERT_EXPR((std::is_same>, T&&>::value)); + STATIC_ASSERT_EXPR((std::is_same const>, const T&&>::value)); + STATIC_ASSERT_EXPR((std::is_same const&>, const T&>::value)); + STATIC_ASSERT_EXPR((std::is_same&>, T&>::value)); // operator-> - static_assert(std::is_same>, T*>{}, "fail"); - static_assert(std::is_same const>, const T*>{}, "fail"); - static_assert(std::is_same const&>, const T*>{}, "fail"); - static_assert(std::is_same&>, T*>{}, "fail"); + STATIC_ASSERT_EXPR((std::is_same>, T*>::value)); + STATIC_ASSERT_EXPR((std::is_same const>, const T*>::value)); + STATIC_ASSERT_EXPR((std::is_same const&>, const T*>::value)); + STATIC_ASSERT_EXPR((std::is_same&>, T*>::value)); return check_conversions(); } } // namespace -static_assert(bsoncxx::detail::is_totally_ordered{}, "fail"); -static_assert(bsoncxx::detail::is_totally_ordered{}, "fail"); -static_assert(!bsoncxx::detail::is_totally_ordered{}, "fail"); +STATIC_ASSERT_EXPR(bsoncxx::detail::is_totally_ordered::value); +STATIC_ASSERT_EXPR(bsoncxx::detail::is_totally_ordered::value); +STATIC_ASSERT_EXPR(!bsoncxx::detail::is_totally_ordered::value); #ifndef NO_LWG_2543 -static_assert(is_hashable>::value, "fail"); -static_assert(!is_hashable>::value, "fail"); +STATIC_ASSERT_EXPR(is_hashable>::value); +STATIC_ASSERT_EXPR(!is_hashable>::value); #endif // Having this static_assert appear prior to static_checks prevents a later static assert error // that occurs only on MSVC 19.29 (VS2019). Obviously. -static_assert(bsoncxx::detail::is_totally_ordered>{}, "fail"); +STATIC_ASSERT_EXPR(bsoncxx::detail::is_totally_ordered>::value); // It's a useful check on its own, but now you are cursed with this knowledge just as I have been. // pain. @@ -612,7 +605,7 @@ struct in_place_convertible { TEST_CASE("optional conversions") { // Some stdlib implementations do not forbid this ctor correctly. #if defined(BSONCXX_POLY_USE_IMPLS) - static_assert(!std::is_constructible, optional>{}, "fail"); + STATIC_ASSERT_EXPR((!std::is_constructible, optional>::value)); #endif // defined(BSONCXX_POLY_USE_IMPLS) optional s1(bsoncxx::stdx::in_place); From 2318708e5457392c297f3637d0310a5986ead970 Mon Sep 17 00:00:00 2001 From: Ezra Chung Date: Tue, 13 Feb 2024 14:20:51 -0600 Subject: [PATCH 24/35] Relax trait equality assertions for stdlib implementations --- src/bsoncxx/test/optional.test.cpp | 60 +++++++++++++++++------------- 1 file changed, 34 insertions(+), 26 deletions(-) diff --git a/src/bsoncxx/test/optional.test.cpp b/src/bsoncxx/test/optional.test.cpp index 9b3f2dae05..c83912f3d5 100644 --- a/src/bsoncxx/test/optional.test.cpp +++ b/src/bsoncxx/test/optional.test.cpp @@ -81,38 +81,46 @@ struct not_copyable { #define STATIC_ASSERT_EXPR_EQUAL(a, b) static_assert((a) == (b), "expected: " #a " == " #b) #define STATIC_ASSERT_EXPR_IMPLIES(a, b) static_assert((!(a) || (b)), "expected: " #a " -> " #b) +#if defined(BSONCXX_POLY_USE_STD) +// Deliberately weaken assertions for stdlib implementations to accomodate for differences in +// behavior. +#define STATIC_ASSERT_EXPR_ALIKE(a, b) STATIC_ASSERT_EXPR_IMPLIES(a, b) +#else +#define STATIC_ASSERT_EXPR_ALIKE(a, b) STATIC_ASSERT_EXPR_EQUAL(a, b) +#endif + template -bool assert_sameness() { - STATIC_ASSERT_EXPR_EQUAL(Trait::value, Trait>::value); +bool assert_alikeness() { + STATIC_ASSERT_EXPR_ALIKE(Trait::value, Trait>::value); return true; } template bool check_convert_alike() { - STATIC_ASSERT_EXPR_EQUAL((std::is_convertible::value), + STATIC_ASSERT_EXPR_ALIKE((std::is_convertible::value), (std::is_convertible::value)); - STATIC_ASSERT_EXPR_EQUAL((std::is_convertible::value), + STATIC_ASSERT_EXPR_ALIKE((std::is_convertible::value), (std::is_convertible::value)); - STATIC_ASSERT_EXPR_EQUAL((std::is_convertible::value), + STATIC_ASSERT_EXPR_ALIKE((std::is_convertible::value), (std::is_convertible::value)); - STATIC_ASSERT_EXPR_EQUAL((std::is_convertible::value), + STATIC_ASSERT_EXPR_ALIKE((std::is_convertible::value), (std::is_convertible::value)); - STATIC_ASSERT_EXPR_EQUAL((std::is_convertible::value), + STATIC_ASSERT_EXPR_ALIKE((std::is_convertible::value), (std::is_convertible::value)); return true; } template bool check_construct_alike() { - STATIC_ASSERT_EXPR_EQUAL((std::is_constructible::value), + STATIC_ASSERT_EXPR_ALIKE((std::is_constructible::value), (std::is_constructible::value)); - STATIC_ASSERT_EXPR_EQUAL((std::is_constructible::value), + STATIC_ASSERT_EXPR_ALIKE((std::is_constructible::value), (std::is_constructible::value)); - STATIC_ASSERT_EXPR_EQUAL((std::is_constructible::value), + STATIC_ASSERT_EXPR_ALIKE((std::is_constructible::value), (std::is_constructible::value)); - STATIC_ASSERT_EXPR_EQUAL((std::is_constructible::value), + STATIC_ASSERT_EXPR_ALIKE((std::is_constructible::value), (std::is_constructible::value)); - STATIC_ASSERT_EXPR_EQUAL((std::is_constructible::value), + STATIC_ASSERT_EXPR_ALIKE((std::is_constructible::value), (std::is_constructible::value)); return true; } @@ -127,20 +135,20 @@ bool check_conversions() { template bool static_checks() { - assert_sameness(); - assert_sameness(); - assert_sameness(); - assert_sameness(); - assert_sameness(); - assert_sameness(); - assert_sameness(); - assert_sameness(); - STATIC_ASSERT_EXPR_EQUAL((bsoncxx::detail::is_equality_comparable>::value), - (bsoncxx::detail::is_equality_comparable::value)); - STATIC_ASSERT_EXPR_EQUAL((bsoncxx::detail::is_totally_ordered_with>::value), - (bsoncxx::detail::is_totally_ordered>::value)); - STATIC_ASSERT_EXPR_EQUAL((std::is_constructible, T>::value), - (std::is_constructible::value)); + assert_alikeness(); + assert_alikeness(); + assert_alikeness(); + assert_alikeness(); + assert_alikeness(); + assert_alikeness(); + assert_alikeness(); + assert_alikeness(); + STATIC_ASSERT_EXPR_ALIKE((bsoncxx::detail::is_equality_comparable::value), + (bsoncxx::detail::is_equality_comparable>::value)); + STATIC_ASSERT_EXPR_ALIKE((bsoncxx::detail::is_totally_ordered::value), + (bsoncxx::detail::is_totally_ordered_with>::value)); + STATIC_ASSERT_EXPR_ALIKE((std::is_constructible::value), + (std::is_constructible, T>::value)); STATIC_ASSERT_EXPR((std::is_constructible, bsoncxx::stdx::nullopt_t>::value)); // Assert we return proper reference types STATIC_ASSERT_EXPR((std::is_same>, T&&>::value)); From 26257b9a44560a457338ee72ff848763b4298518 Mon Sep 17 00:00:00 2001 From: Ezra Chung Date: Tue, 13 Feb 2024 11:27:02 -0600 Subject: [PATCH 25/35] Declare BUILD_TESTING as a CMake option variable --- CMakeLists.txt | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ce89909354..b5b6aea736 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,9 +20,7 @@ endif() project(MONGO_CXX_DRIVER LANGUAGES CXX) -if(NOT DEFINED BUILD_TESTING) - set(BUILD_TESTING OFF) # Set this to OFF by default -endif() +option(BUILD_TESTING "Include test targets in the \"all\" target") if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "4.8.2") From 0b44dd8cf6bdc520a7613c0b8489bc9559b1c17c Mon Sep 17 00:00:00 2001 From: Ezra Chung Date: Tue, 13 Feb 2024 12:41:06 -0600 Subject: [PATCH 26/35] Fix CCACHE_BASEDIR for Windows distros --- .evergreen/compile.sh | 11 +++++------ .mci.yml | 6 +++++- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/.evergreen/compile.sh b/.evergreen/compile.sh index 8b2760539f..fbfc8a81f2 100755 --- a/.evergreen/compile.sh +++ b/.evergreen/compile.sh @@ -69,14 +69,13 @@ export CMAKE_BUILD_PARALLEL_LEVEL if command -V ccache 2>/dev/null; then export CMAKE_CXX_COMPILER_LAUNCHER=ccache - - # Allow reuse of ccache compilation results between different build directories. - export CCACHE_BASEDIR CCACHE_NOHASHDIR - CCACHE_BASEDIR="$(pwd)" - CCACHE_NOHASHDIR=1 # Allow reuse of ccache compilation results between different build directories. export CCACHE_BASEDIR CCACHE_NOHASHDIR - CCACHE_BASEDIR="$(pwd)" + if [[ "${OSTYPE:?}" == "cygwin" ]]; then + CCACHE_BASEDIR="$(cygpath -aw "$(pwd)")" + else + CCACHE_BASEDIR="$(pwd)" + fi CCACHE_NOHASHDIR=1 fi diff --git a/.mci.yml b/.mci.yml index 45b05adb5e..1c0eb58057 100644 --- a/.mci.yml +++ b/.mci.yml @@ -952,7 +952,11 @@ tasks: # Allow reuse of ccache compilation results between different build directories. export CCACHE_BASEDIR CCACHE_NOHASHDIR - CCACHE_BASEDIR="$(pwd)" + if [[ "${OSTYPE:?}" == "cygwin" ]]; then + CCACHE_BASEDIR="$(cygpath -aw "$(pwd)")" + else + CCACHE_BASEDIR="$(pwd)" + fi CCACHE_NOHASHDIR=1 fi command -v "$cmake_binary" From 2c12fbdbb63cd58851ce4f8901e142a5faa90a3b Mon Sep 17 00:00:00 2001 From: Ezra Chung Date: Wed, 14 Feb 2024 12:00:28 -0600 Subject: [PATCH 27/35] Update documentation comments for consistency --- .../lib/mongocxx/v_noabi/mongocxx/private/libbson.hh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/mongocxx/lib/mongocxx/v_noabi/mongocxx/private/libbson.hh b/src/mongocxx/lib/mongocxx/v_noabi/mongocxx/private/libbson.hh index 75955e5946..ae1bce3606 100644 --- a/src/mongocxx/lib/mongocxx/v_noabi/mongocxx/private/libbson.hh +++ b/src/mongocxx/lib/mongocxx/v_noabi/mongocxx/private/libbson.hh @@ -53,7 +53,7 @@ class MONGOCXX_TEST_API scoped_bson_t { scoped_bson_t(); // - // Constructs a new scoped_bson_t from a document view_or_value. + // Constructs a new scoped_bson_t from the provided document. // // The internal bson_t is considered initialized. // @@ -67,7 +67,7 @@ class MONGOCXX_TEST_API scoped_bson_t { void init_from_static(bsoncxx::document::view_or_value doc); // - // Constructs a new scoped_bson_t from a document view_or_value. + // Constructs a new scoped_bson_t from the provided document. // // The internal bson_t is considered initialized. // @@ -81,7 +81,7 @@ class MONGOCXX_TEST_API scoped_bson_t { void init_from_static(bsoncxx::document::view doc); // - // Constructs a new scoped_bson_t from a document. + // Constructs a new scoped_bson_t from the provided document. // // The internal bson_t is considered initialized. // @@ -95,9 +95,9 @@ class MONGOCXX_TEST_API scoped_bson_t { void init_from_static(bsoncxx::document::value doc); // - // Constructs a new scoped_bson_t from an optional document view_or_value. + // Constructs a new scoped_bson_t from the provided optional document. // - // The internal bson_t is initialized if the optional is populated. + // The internal bson_t is initialized if the optional contains a document. // explicit scoped_bson_t( bsoncxx::v_noabi::stdx::optional doc); @@ -105,7 +105,7 @@ class MONGOCXX_TEST_API scoped_bson_t { // // Initializes a bson_t from the provided optional document. // - // The internal bson_t is initialized if the optional is populated. + // The internal bson_t is initialized if the optional contains a document. // void init_from_static( bsoncxx::v_noabi::stdx::optional doc); From 1b39989f119b1a069a2cca8018d32752d58e1166 Mon Sep 17 00:00:00 2001 From: Ezra Chung Date: Wed, 14 Feb 2024 12:06:43 -0600 Subject: [PATCH 28/35] Tweak description of ENABLE_BSONCXX_POLY_USE_IMPLS to mention "by default" --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b5b6aea736..94171cd01e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -155,8 +155,8 @@ option(BUILD_SHARED_LIBS_WITH_STATIC_MONGOC OFF ) -# Allow the user to opt into using bsoncxx implementations for C++17 polyfills. -option(ENABLE_BSONCXX_POLY_USE_IMPLS "Enable using bsoncxx implementations of C++17 polyfills for pre-C++17 configurations" OFF) +# Allow the user to opt into using bsoncxx implementations for C++17 polyfills by default. +option(ENABLE_BSONCXX_POLY_USE_IMPLS "Enable using bsoncxx implementations of C++17 polyfills for pre-C++17 configurations by default" OFF) if(DEFINED CACHE{ENABLE_ABI_TAG_IN_LIBRARY_FILENAMES} AND NOT MSVC) message(WARNING "ENABLE_ABI_TAG_IN_LIBRARY_FILENAMES is an MSVC-only option and will be ignored by the current configuration") From d6eafaa0a121aef8f4aa04e17d6c6f9be53a1e27 Mon Sep 17 00:00:00 2001 From: Ezra Chung Date: Wed, 14 Feb 2024 12:13:32 -0600 Subject: [PATCH 29/35] Tweak ordering of polyfills for consistency --- CMakeLists.txt | 8 ++++---- cmake/BsoncxxUtil.cmake | 6 ++---- cmake/make_dist/MakeDistCheck.cmake | 8 ++++---- .../include/bsoncxx/v_noabi/bsoncxx/config/postlude.hpp | 4 ++-- .../include/bsoncxx/v_noabi/bsoncxx/config/prelude.hpp | 4 ++-- .../lib/bsoncxx/v_noabi/bsoncxx/config/config.hpp.in | 2 +- src/bsoncxx/test/CMakeLists.txt | 2 +- 7 files changed, 16 insertions(+), 18 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 94171cd01e..05a34b1d41 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -457,10 +457,6 @@ if(NOT(TARGET dist OR TARGET distcheck)) list(APPEND polyfill_flags "-DBOOST_ROOT=${BOOST_ROOT}") endif() - if(NOT "${BSONCXX_POLY_USE_IMPLS}" STREQUAL "") - list(APPEND polyfill_flags "-DBSONCXX_POLY_USE_IMPLS=${BSONCXX_POLY_USE_IMPLS}") - endif() - if(NOT "${BSONCXX_POLY_USE_MNMLSTC}" STREQUAL "") list(APPEND polyfill_flags "-DBSONCXX_POLY_USE_MNMLSTC=${BSONCXX_POLY_USE_MNMLSTC}") endif() @@ -473,6 +469,10 @@ if(NOT(TARGET dist OR TARGET distcheck)) list(APPEND polyfill_flags "-DBSONCXX_POLY_USE_BOOST=${BSONCXX_POLY_USE_BOOST}") endif() + if(NOT "${BSONCXX_POLY_USE_IMPLS}" STREQUAL "") + list(APPEND polyfill_flags "-DBSONCXX_POLY_USE_IMPLS=${BSONCXX_POLY_USE_IMPLS}") + endif() + if(NOT "${BSONCXX_POLY_USE_STD}" STREQUAL "") list(APPEND polyfill_flags "-DBSONCXX_POLY_USE_STD=${BSONCXX_POLY_USE_STD}") endif() diff --git a/cmake/BsoncxxUtil.cmake b/cmake/BsoncxxUtil.cmake index ab50b57ef4..a1d9ab6b5f 100644 --- a/cmake/BsoncxxUtil.cmake +++ b/cmake/BsoncxxUtil.cmake @@ -58,13 +58,11 @@ function(bsoncxx_add_library TARGET OUTPUT_NAME LINK_TYPE) # - 'i' for bsoncxx implementations. # - 's' for standard library (no polyfill). if(1) - if(BSONCXX_POLY_USE_IMPLS) - set(polyfill "i") - elseif(BSONCXX_POLY_USE_MNMLSTC) + if(BSONCXX_POLY_USE_MNMLSTC) set(polyfill "m") elseif(BSONCXX_POLY_USE_BOOST) set(polyfill "b") - elseif(0) # CXX-2796: reserved for bsoncxx implementations as polyfill. + elseif(BSONCXX_POLY_USE_IMPLS) set(polyfill "i") elseif(BSONCXX_POLY_USE_STD) set(polyfill "s") diff --git a/cmake/make_dist/MakeDistCheck.cmake b/cmake/make_dist/MakeDistCheck.cmake index e6f54ac9c8..8190510270 100644 --- a/cmake/make_dist/MakeDistCheck.cmake +++ b/cmake/make_dist/MakeDistCheck.cmake @@ -40,10 +40,6 @@ function(RUN_DIST_CHECK PACKAGE_PREFIX EXT) list(APPEND polyfill_flags "-DBOOST_ROOT=${BOOST_ROOT}") endif() - if(NOT "${BSONCXX_POLY_USE_IMPLS}" STREQUAL "") - list(APPEND polyfill_flags "-DBSONCXX_POLY_USE_IMPLS=${BSONCXX_POLY_USE_IMPLS}") - endif() - if(NOT "${BSONCXX_POLY_USE_MNMLSTC}" STREQUAL "") list(APPEND polyfill_flags "-DBSONCXX_POLY_USE_MNMLSTC=${BSONCXX_POLY_USE_MNMLSTC}") endif() @@ -56,6 +52,10 @@ function(RUN_DIST_CHECK PACKAGE_PREFIX EXT) list(APPEND polyfill_flags "-DBSONCXX_POLY_USE_BOOST=${BSONCXX_POLY_USE_BOOST}") endif() + if(NOT "${BSONCXX_POLY_USE_IMPLS}" STREQUAL "") + list(APPEND polyfill_flags "-DBSONCXX_POLY_USE_IMPLS=${BSONCXX_POLY_USE_IMPLS}") + endif() + if(NOT "${BSONCXX_POLY_USE_STD}" STREQUAL "") list(APPEND polyfill_flags "-DBSONCXX_POLY_USE_STD=${BSONCXX_POLY_USE_STD}") endif() diff --git a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/config/postlude.hpp b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/config/postlude.hpp index 54479d02ef..e55f4c8eea 100644 --- a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/config/postlude.hpp +++ b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/config/postlude.hpp @@ -24,14 +24,14 @@ BSONCXX_POP_WARNINGS(); #pragma pop_macro("BSONCXX_INLINE_NAMESPACE_BEGIN") #undef BSONCXX_INLINE_NAMESPACE_END #pragma pop_macro("BSONCXX_INLINE_NAMESPACE_END") -#undef BSONCXX_POLY_USE_IMPLS -#pragma pop_macro("BSONCXX_POLY_USE_IMPLS") #undef BSONCXX_POLY_USE_MNMLSTC #pragma pop_macro("BSONCXX_POLY_USE_MNMLSTC") #undef BSONCXX_POLY_USE_SYSTEM_MNMLSTC #pragma pop_macro("BSONCXX_POLY_USE_SYSTEM_MNMLSTC") #undef BSONCXX_POLY_USE_BOOST #pragma pop_macro("BSONCXX_POLY_USE_BOOST") +#undef BSONCXX_POLY_USE_IMPLS +#pragma pop_macro("BSONCXX_POLY_USE_IMPLS") // version.hpp (generated by CMake) #undef BSONCXX_VERSION_EXTRA diff --git a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/config/prelude.hpp b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/config/prelude.hpp index 5879bbdd11..2794715dcb 100644 --- a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/config/prelude.hpp +++ b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/config/prelude.hpp @@ -67,14 +67,14 @@ #undef BSONCXX_INLINE_NAMESPACE_BEGIN #pragma push_macro("BSONCXX_INLINE_NAMESPACE_END") #undef BSONCXX_INLINE_NAMESPACE_END -#pragma push_macro("BSONCXX_POLY_USE_IMPLS") -#undef BSONCXX_POLY_USE_IMPLS #pragma push_macro("BSONCXX_POLY_USE_MNMLSTC") #undef BSONCXX_POLY_USE_MNMLSTC #pragma push_macro("BSONCXX_POLY_USE_SYSTEM_MNMLSTC") #undef BSONCXX_POLY_USE_SYSTEM_MNMLSTC #pragma push_macro("BSONCXX_POLY_USE_BOOST") #undef BSONCXX_POLY_USE_BOOST +#pragma push_macro("BSONCXX_POLY_USE_IMPLS") +#undef BSONCXX_POLY_USE_IMPLS // version.hpp (generated by CMake) #pragma push_macro("BSONCXX_VERSION_EXTRA") diff --git a/src/bsoncxx/lib/bsoncxx/v_noabi/bsoncxx/config/config.hpp.in b/src/bsoncxx/lib/bsoncxx/v_noabi/bsoncxx/config/config.hpp.in index 2addd97528..a80c180a19 100644 --- a/src/bsoncxx/lib/bsoncxx/v_noabi/bsoncxx/config/config.hpp.in +++ b/src/bsoncxx/lib/bsoncxx/v_noabi/bsoncxx/config/config.hpp.in @@ -12,10 +12,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -#cmakedefine BSONCXX_POLY_USE_IMPLS #cmakedefine BSONCXX_POLY_USE_MNMLSTC #cmakedefine BSONCXX_POLY_USE_SYSTEM_MNMLSTC #cmakedefine BSONCXX_POLY_USE_BOOST +#cmakedefine BSONCXX_POLY_USE_IMPLS #cmakedefine BSONCXX_POLY_USE_STD #define BSONCXX_INLINE_NAMESPACE_BEGIN inline namespace v_noabi { diff --git a/src/bsoncxx/test/CMakeLists.txt b/src/bsoncxx/test/CMakeLists.txt index c76605f79c..5e55314b3b 100644 --- a/src/bsoncxx/test/CMakeLists.txt +++ b/src/bsoncxx/test/CMakeLists.txt @@ -78,10 +78,10 @@ if(ENABLE_MACRO_GUARD_TESTS) BSONCXX_CALL BSONCXX_INLINE_NAMESPACE_BEGIN # config.hpp (generated by CMake) BSONCXX_INLINE_NAMESPACE_END - BSONCXX_POLY_USE_IMPLS BSONCXX_POLY_USE_MNMLSTC BSONCXX_POLY_USE_SYSTEM_MNMLSTC BSONCXX_POLY_USE_BOOST + BSONCXX_POLY_USE_IMPLS BSONCXX_VERSION_EXTRA # version.hpp (generated by CMake) BSONCXX_VERSION_MAJOR BSONCXX_VERSION_MINOR From 26d24360455f6d170a2fdc9f9ebd7abfa6939202 Mon Sep 17 00:00:00 2001 From: Ezra Chung Date: Wed, 14 Feb 2024 12:13:42 -0600 Subject: [PATCH 30/35] Add missing macro guards for BSONCXX_POLY_USE_STD --- src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/config/postlude.hpp | 2 ++ src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/config/prelude.hpp | 2 ++ src/bsoncxx/test/CMakeLists.txt | 1 + 3 files changed, 5 insertions(+) diff --git a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/config/postlude.hpp b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/config/postlude.hpp index e55f4c8eea..81524a1e87 100644 --- a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/config/postlude.hpp +++ b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/config/postlude.hpp @@ -32,6 +32,8 @@ BSONCXX_POP_WARNINGS(); #pragma pop_macro("BSONCXX_POLY_USE_BOOST") #undef BSONCXX_POLY_USE_IMPLS #pragma pop_macro("BSONCXX_POLY_USE_IMPLS") +#undef BSONCXX_POLY_USE_STD +#pragma pop_macro("BSONCXX_POLY_USE_STD") // version.hpp (generated by CMake) #undef BSONCXX_VERSION_EXTRA diff --git a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/config/prelude.hpp b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/config/prelude.hpp index 2794715dcb..edfb84d38c 100644 --- a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/config/prelude.hpp +++ b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/config/prelude.hpp @@ -75,6 +75,8 @@ #undef BSONCXX_POLY_USE_BOOST #pragma push_macro("BSONCXX_POLY_USE_IMPLS") #undef BSONCXX_POLY_USE_IMPLS +#pragma push_macro("BSONCXX_POLY_USE_STD") +#undef BSONCXX_POLY_USE_STD // version.hpp (generated by CMake) #pragma push_macro("BSONCXX_VERSION_EXTRA") diff --git a/src/bsoncxx/test/CMakeLists.txt b/src/bsoncxx/test/CMakeLists.txt index 5e55314b3b..56abda1e1c 100644 --- a/src/bsoncxx/test/CMakeLists.txt +++ b/src/bsoncxx/test/CMakeLists.txt @@ -82,6 +82,7 @@ if(ENABLE_MACRO_GUARD_TESTS) BSONCXX_POLY_USE_SYSTEM_MNMLSTC BSONCXX_POLY_USE_BOOST BSONCXX_POLY_USE_IMPLS + BSONCXX_POLY_USE_STD BSONCXX_VERSION_EXTRA # version.hpp (generated by CMake) BSONCXX_VERSION_MAJOR BSONCXX_VERSION_MINOR From 2039aacbe90643e440ecbae44e457ced8f3b3c85 Mon Sep 17 00:00:00 2001 From: Ezra Chung Date: Wed, 14 Feb 2024 12:19:16 -0600 Subject: [PATCH 31/35] Revert reintroduction of documentation for experimental stdlib polyfill --- docs/content/mongocxx-v3/installation/linux.md | 10 ---------- docs/content/mongocxx-v3/installation/macos.md | 10 ---------- docs/content/mongocxx-v3/installation/windows.md | 10 ---------- 3 files changed, 30 deletions(-) diff --git a/docs/content/mongocxx-v3/installation/linux.md b/docs/content/mongocxx-v3/installation/linux.md index d31b1b61af..91d8676f42 100644 --- a/docs/content/mongocxx-v3/installation/linux.md +++ b/docs/content/mongocxx-v3/installation/linux.md @@ -41,16 +41,6 @@ is explicitly selected): non-bsoncxx option if you are using a version of MSVC that does not support C++17. -* `std::experimental` - - **This option is deprecated and will be removed in an upcoming major release.** - Select with `-DBSONCXX_POLY_USE_STD_EXPERIMENTAL=1`. If your toolchain's - standard library provides `optional` and `string_view` in the namespace - `std::experimental`, you can use this option. Be aware that your standard - library's `std::experimental` implementation may change over time, breaking - binary compatibility in unexpected ways. Note that this polyfill is *not* - recommended and is unsupported. - Most users should use the default polyfill selection behavior. However, if you have a preference for one of the external polyfill libraries (e.g. already a dependency being used by your application), you may prefer to explicitly select diff --git a/docs/content/mongocxx-v3/installation/macos.md b/docs/content/mongocxx-v3/installation/macos.md index ab6c6a77cc..8b05f0806c 100644 --- a/docs/content/mongocxx-v3/installation/macos.md +++ b/docs/content/mongocxx-v3/installation/macos.md @@ -41,16 +41,6 @@ is explicitly selected): non-bsoncxx option if you are using a version of MSVC that does not support C++17. -* `std::experimental` - - **This option is deprecated and will be removed in an upcoming major release.** - Select with `-DBSONCXX_POLY_USE_STD_EXPERIMENTAL=1`. If your toolchain's - standard library provides `optional` and `string_view` in the namespace - `std::experimental`, you can use this option. Be aware that your standard - library's `std::experimental` implementation may change over time, breaking - binary compatibility in unexpected ways. Note that this polyfill is *not* - recommended and is unsupported. - Most users should use the default polyfill selection behavior. However, if you have a preference for one of the external polyfill libraries (e.g. already a dependency being used by your application), you may prefer to explicitly select diff --git a/docs/content/mongocxx-v3/installation/windows.md b/docs/content/mongocxx-v3/installation/windows.md index a7f5dbb379..a224334b89 100644 --- a/docs/content/mongocxx-v3/installation/windows.md +++ b/docs/content/mongocxx-v3/installation/windows.md @@ -41,16 +41,6 @@ is explicitly selected): non-bsoncxx option if you are using a version of MSVC that does not support C++17. -* `std::experimental` - - **This option is deprecated and will be removed in an upcoming major release.** - Select with `-DBSONCXX_POLY_USE_STD_EXPERIMENTAL=1`. If your toolchain's - standard library provides `optional` and `string_view` in the namespace - `std::experimental`, you can use this option. Be aware that your standard - library's `std::experimental` implementation may change over time, breaking - binary compatibility in unexpected ways. Note that this polyfill is *not* - recommended and is unsupported. - Most users should use the default polyfill selection behavior. However, if you have a preference for one of the external polyfill libraries (e.g. already a dependency being used by your application), you may prefer to explicitly select From 8715b731f48c3fa2f3ee2c2d6b0c59a89a0ab507 Mon Sep 17 00:00:00 2001 From: Ezra Chung Date: Tue, 20 Feb 2024 13:05:53 -0600 Subject: [PATCH 32/35] Move common polyfill selection documentation into separate page --- .../content/mongocxx-v3/installation/linux.md | 50 +--------------- .../content/mongocxx-v3/installation/macos.md | 50 +--------------- .../installation/polyfill-selection.md | 58 +++++++++++++++++++ .../mongocxx-v3/installation/windows.md | 50 +--------------- 4 files changed, 61 insertions(+), 147 deletions(-) create mode 100644 docs/content/mongocxx-v3/installation/polyfill-selection.md diff --git a/docs/content/mongocxx-v3/installation/linux.md b/docs/content/mongocxx-v3/installation/linux.md index 91d8676f42..8ca9cd1dbb 100644 --- a/docs/content/mongocxx-v3/installation/linux.md +++ b/docs/content/mongocxx-v3/installation/linux.md @@ -9,55 +9,7 @@ title = "Linux" ### Step 1: Choose a C++17 polyfill -The mongocxx driver uses C++17 features `std::optional` and `std::string_view`. -To use the C++17 standard library implementations for these features, set -the CMake configuration variable `CMAKE_CXX_STANDARD` to 17 or higher. -Otherwise, to compile the mongocxx driver for pre-C++17 configurations, a -polyfill library implementation must be selected from the following options -(note: "default" refers to **pre-C++17** configurations when no polyfill library -is explicitly selected): - -* bsoncxx (*default only when `-DENABLE_BSONCXX_POLY_USE_IMPLS=ON`*) - - Select with `-DBSONCXX_POLY_USE_IMPLS=ON`. This option is most recommended, as - it does not require additional external library dependencies. To enable - selecting this option by default for pre-C++17 configurations when no other - options are specified, set `ENABLE_BSONCXX_POLY_USE_IMPLS=ON` (this option - will be set to ON by default in an upcoming major release). - -* MNMLSTC/core (*default for non-Windows platforms*) - - **This option is deprecated and will be removed in an upcoming major release.** - Select with `-DBSONCXX_POLY_USE_MNMLSTC=1`. **NOTE**: This option vendors a - header-only installation of MNMLSTC/core into the bsoncxx library installation - and will therefore download MLNMLSTC from GitHub during the configuration - process. If you already have an available version of MNMLSTC on your system, - you can avoid the download step by using `-DBSONCXX_POLY_USE_SYSTEM_MNMLSTC`. - -* Boost (*default for Windows platforms*) - - **This option is deprecated and will be removed in an upcoming major release.** - Select with `-DBSONCXX_POLY_USE_BOOST=1`. This is currently the only - non-bsoncxx option if you are using a version of MSVC that does not support - C++17. - -Most users should use the default polyfill selection behavior. However, if you -have a preference for one of the external polyfill libraries (e.g. already a -dependency being used by your application), you may prefer to explicitly select -that external polyfill library rather than rely on default selection behavior. - -**NOTE**: C++ standard conformance and supported behavior of polyfill features -may vary depending on the selected polyfill library. The purpose of these -polyfills is to support pre-C++17 configurations by providing stand-ins for -their C++17 equivalents. Therefore we recommend using the C++17 standard -library whenever possible by setting `-DCMAKE_CXX_STANDARD=17` or newer. - -**WARNING**: the choice of polyfill library has a direct impact on the public -API and ABI for the mongocxx library. Changing the polyfill can lead to both -source-breaking changes (during compilation) and binary-breaking changes (during -linking or execution). To limit reliance on polyfill-specific configuration or -behavior, avoid using `stdx::string_view` and `stdx::optional` with -non-mongocxx library interfaces. +First, [choose a C++17 polyfill library]({{< ref "/mongocxx-v3/installation/polyfill-selection" >}}). ### Step 2: Download the latest version of the mongocxx driver. diff --git a/docs/content/mongocxx-v3/installation/macos.md b/docs/content/mongocxx-v3/installation/macos.md index 8b05f0806c..509bcbbb5e 100644 --- a/docs/content/mongocxx-v3/installation/macos.md +++ b/docs/content/mongocxx-v3/installation/macos.md @@ -9,55 +9,7 @@ title = "macOS" ### Step 1: Choose a C++17 polyfill -The mongocxx driver uses C++17 features `std::optional` and `std::string_view`. -To use the C++17 standard library implementations for these features, set -the CMake configuration variable `CMAKE_CXX_STANDARD` to 17 or higher. -Otherwise, to compile the mongocxx driver for pre-C++17 configurations, a -polyfill library implementation must be selected from the following options -(note: "default" refers to **pre-C++17** configurations when no polyfill library -is explicitly selected): - -* bsoncxx (*default only when `-DENABLE_BSONCXX_POLY_USE_IMPLS=ON`*) - - Select with `-DBSONCXX_POLY_USE_IMPLS=ON`. This option is most recommended, as - it does not require additional external library dependencies. To enable - selecting this option by default for pre-C++17 configurations when no other - options are specified, set `ENABLE_BSONCXX_POLY_USE_IMPLS=ON` (this option - will be set to ON by default in an upcoming major release). - -* MNMLSTC/core (*default for non-Windows platforms*) - - **This option is deprecated and will be removed in an upcoming major release.** - Select with `-DBSONCXX_POLY_USE_MNMLSTC=1`. **NOTE**: This option vendors a - header-only installation of MNMLSTC/core into the bsoncxx library installation - and will therefore download MLNMLSTC from GitHub during the configuration - process. If you already have an available version of MNMLSTC on your system, - you can avoid the download step by using `-DBSONCXX_POLY_USE_SYSTEM_MNMLSTC`. - -* Boost (*default for Windows platforms*) - - **This option is deprecated and will be removed in an upcoming major release.** - Select with `-DBSONCXX_POLY_USE_BOOST=1`. This is currently the only - non-bsoncxx option if you are using a version of MSVC that does not support - C++17. - -Most users should use the default polyfill selection behavior. However, if you -have a preference for one of the external polyfill libraries (e.g. already a -dependency being used by your application), you may prefer to explicitly select -that external polyfill library rather than rely on default selection behavior. - -**NOTE**: C++ standard conformance and supported behavior of polyfill features -may vary depending on the selected polyfill library. The purpose of these -polyfills is to support pre-C++17 configurations by providing stand-ins for -their C++17 equivalents. Therefore we recommend using the C++17 standard -library whenever possible by setting `-DCMAKE_CXX_STANDARD=17` or newer. - -**WARNING**: the choice of polyfill library has a direct impact on the public -API and ABI for the mongocxx library. Changing the polyfill can lead to both -source-breaking changes (during compilation) and binary-breaking changes (during -linking or execution). To limit reliance on polyfill-specific configuration or -behavior, avoid using `stdx::string_view` and `stdx::optional` with -non-mongocxx library interfaces. +First, [choose a C++17 polyfill library]({{< ref "/mongocxx-v3/installation/polyfill-selection" >}}). ### Step 2: Download the latest version of the mongocxx driver. diff --git a/docs/content/mongocxx-v3/installation/polyfill-selection.md b/docs/content/mongocxx-v3/installation/polyfill-selection.md new file mode 100644 index 0000000000..19d98406c4 --- /dev/null +++ b/docs/content/mongocxx-v3/installation/polyfill-selection.md @@ -0,0 +1,58 @@ ++++ +date = "2024-02-20T00:00:00-00:00" +title = "Choosing a C++17 Polyfill" +[menu.main] + identifier = "mongocxx3-polyfill-selection" + parent = "mongocxx3" + weight = 8 ++++ + +The mongocxx driver uses C++17 features `std::optional` and `std::string_view`. +To use the C++17 standard library implementations for these features, set +the CMake configuration variable `CMAKE_CXX_STANDARD` to 17 or higher. +Otherwise, to compile the mongocxx driver for pre-C++17 configurations, a +polyfill library implementation must be selected from the following options +(note: "default" refers to **pre-C++17** configurations when no polyfill library +is explicitly selected): + +* bsoncxx (*default only when `-DENABLE_BSONCXX_POLY_USE_IMPLS=ON`*) + + Select with `-DBSONCXX_POLY_USE_IMPLS=ON`. This option is most recommended, as + it does not require additional external library dependencies. To enable + selecting this option by default for pre-C++17 configurations when no other + options are specified, set `ENABLE_BSONCXX_POLY_USE_IMPLS=ON` (this option + will be set to ON by default in an upcoming major release). + +* MNMLSTC/core (*default for non-Windows platforms*) + + **This option is deprecated and will be removed in an upcoming major release.** + Select with `-DBSONCXX_POLY_USE_MNMLSTC=1`. **NOTE**: This option vendors a + header-only installation of MNMLSTC/core into the bsoncxx library installation + and will therefore download MLNMLSTC from GitHub during the configuration + process. If you already have an available version of MNMLSTC on your system, + you can avoid the download step by using `-DBSONCXX_POLY_USE_SYSTEM_MNMLSTC`. + +* Boost (*default for Windows platforms*) + + **This option is deprecated and will be removed in an upcoming major release.** + Select with `-DBSONCXX_POLY_USE_BOOST=1`. This is currently the only + non-bsoncxx option if you are using a version of MSVC that does not support + C++17. + +Most users should use the default polyfill selection behavior. However, if you +have a preference for one of the external polyfill libraries (e.g. already a +dependency being used by your application), you may prefer to explicitly select +that external polyfill library rather than rely on default selection behavior. + +**NOTE**: C++ standard conformance and supported behavior of polyfill features +may vary depending on the selected polyfill library. The purpose of these +polyfills is to support pre-C++17 configurations by providing stand-ins for +their C++17 equivalents. Therefore we recommend using the C++17 standard +library whenever possible by setting `-DCMAKE_CXX_STANDARD=17` or newer. + +**WARNING**: the choice of polyfill library has a direct impact on the public +API and ABI for the mongocxx library. Changing the polyfill can lead to both +source-breaking changes (during compilation) and binary-breaking changes (during +linking or execution). To limit reliance on polyfill-specific configuration or +behavior, avoid using `stdx::string_view` and `stdx::optional` with +non-mongocxx library interfaces. diff --git a/docs/content/mongocxx-v3/installation/windows.md b/docs/content/mongocxx-v3/installation/windows.md index a224334b89..25801b0ae0 100644 --- a/docs/content/mongocxx-v3/installation/windows.md +++ b/docs/content/mongocxx-v3/installation/windows.md @@ -9,55 +9,7 @@ title = "Windows" ### Step 1: Choose a C++17 polyfill -The mongocxx driver uses C++17 features `std::optional` and `std::string_view`. -To use the C++17 standard library implementations for these features, set -the CMake configuration variable `CMAKE_CXX_STANDARD` to 17 or higher. -Otherwise, to compile the mongocxx driver for pre-C++17 configurations, a -polyfill library implementation must be selected from the following options -(note: "default" refers to **pre-C++17** configurations when no polyfill library -is explicitly selected): - -* bsoncxx (*default only when `-DENABLE_BSONCXX_POLY_USE_IMPLS=ON`*) - - Select with `-DBSONCXX_POLY_USE_IMPLS=ON`. This option is most recommended, as - it does not require additional external library dependencies. To enable - selecting this option by default for pre-C++17 configurations when no other - options are specified, set `ENABLE_BSONCXX_POLY_USE_IMPLS=ON` (this option - will be set to ON by default in an upcoming major release). - -* MNMLSTC/core (*default for non-Windows platforms*) - - **This option is deprecated and will be removed in an upcoming major release.** - Select with `-DBSONCXX_POLY_USE_MNMLSTC=1`. **NOTE**: This option vendors a - header-only installation of MNMLSTC/core into the bsoncxx library installation - and will therefore download MLNMLSTC from GitHub during the configuration - process. If you already have an available version of MNMLSTC on your system, - you can avoid the download step by using `-DBSONCXX_POLY_USE_SYSTEM_MNMLSTC`. - -* Boost (*default for Windows platforms*) - - **This option is deprecated and will be removed in an upcoming major release.** - Select with `-DBSONCXX_POLY_USE_BOOST=1`. This is currently the only - non-bsoncxx option if you are using a version of MSVC that does not support - C++17. - -Most users should use the default polyfill selection behavior. However, if you -have a preference for one of the external polyfill libraries (e.g. already a -dependency being used by your application), you may prefer to explicitly select -that external polyfill library rather than rely on default selection behavior. - -**NOTE**: C++ standard conformance and supported behavior of polyfill features -may vary depending on the selected polyfill library. The purpose of these -polyfills is to support pre-C++17 configurations by providing stand-ins for -their C++17 equivalents. Therefore we recommend using the C++17 standard -library whenever possible by setting `-DCMAKE_CXX_STANDARD=17` or newer. - -**WARNING**: the choice of polyfill library has a direct impact on the public -API and ABI for the mongocxx library. Changing the polyfill can lead to both -source-breaking changes (during compilation) and binary-breaking changes (during -linking or execution). To limit reliance on polyfill-specific configuration or -behavior, avoid using `stdx::string_view` and `stdx::optional` with -non-mongocxx library interfaces. +First, [choose a C++17 polyfill library]({{< ref "/mongocxx-v3/installation/polyfill-selection" >}}). ### Step 2: Download the latest version of the mongocxx driver. From 7c06aedae9e064d5f8623e6d98a130f3f5725a10 Mon Sep 17 00:00:00 2001 From: Ezra Chung Date: Tue, 20 Feb 2024 13:09:54 -0600 Subject: [PATCH 33/35] Tweak wording to recommend ENABLE_BSONCXX_POLY_USE_IMPLS=ON by default --- .../mongocxx-v3/installation/polyfill-selection.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/docs/content/mongocxx-v3/installation/polyfill-selection.md b/docs/content/mongocxx-v3/installation/polyfill-selection.md index 19d98406c4..1dba2b8d02 100644 --- a/docs/content/mongocxx-v3/installation/polyfill-selection.md +++ b/docs/content/mongocxx-v3/installation/polyfill-selection.md @@ -39,10 +39,11 @@ is explicitly selected): non-bsoncxx option if you are using a version of MSVC that does not support C++17. -Most users should use the default polyfill selection behavior. However, if you -have a preference for one of the external polyfill libraries (e.g. already a -dependency being used by your application), you may prefer to explicitly select -that external polyfill library rather than rely on default selection behavior. +Most users should use default behavior with `-DENABLE_BSONCXX_POLY_USE_IMPLS=ON`. +However, if you have a preference for one of the external polyfill libraries +(e.g. already a dependency being used by your application), you may prefer to +explicitly select that external polyfill library rather than rely on default +selection behavior. **NOTE**: C++ standard conformance and supported behavior of polyfill features may vary depending on the selected polyfill library. The purpose of these From 2c43b52eaf530375fbfa12e99c6330cb478d22e5 Mon Sep 17 00:00:00 2001 From: Ezra Chung Date: Tue, 20 Feb 2024 13:23:44 -0600 Subject: [PATCH 34/35] Move polyfill-selection file to consistent directory placement --- docs/content/mongocxx-v3/{installation => }/polyfill-selection.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename docs/content/mongocxx-v3/{installation => }/polyfill-selection.md (100%) diff --git a/docs/content/mongocxx-v3/installation/polyfill-selection.md b/docs/content/mongocxx-v3/polyfill-selection.md similarity index 100% rename from docs/content/mongocxx-v3/installation/polyfill-selection.md rename to docs/content/mongocxx-v3/polyfill-selection.md From 7cff319da0f6d06af7a4271b8e0231bfd506818d Mon Sep 17 00:00:00 2001 From: Ezra Chung Date: Tue, 20 Feb 2024 13:24:42 -0600 Subject: [PATCH 35/35] Update references to polyfill-selection page --- docs/content/mongocxx-v3/installation/linux.md | 2 +- docs/content/mongocxx-v3/installation/macos.md | 2 +- docs/content/mongocxx-v3/installation/windows.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/content/mongocxx-v3/installation/linux.md b/docs/content/mongocxx-v3/installation/linux.md index 8ca9cd1dbb..5d234cec2c 100644 --- a/docs/content/mongocxx-v3/installation/linux.md +++ b/docs/content/mongocxx-v3/installation/linux.md @@ -9,7 +9,7 @@ title = "Linux" ### Step 1: Choose a C++17 polyfill -First, [choose a C++17 polyfill library]({{< ref "/mongocxx-v3/installation/polyfill-selection" >}}). +First, [choose a C++17 polyfill library]({{< ref "/mongocxx-v3/polyfill-selection" >}}). ### Step 2: Download the latest version of the mongocxx driver. diff --git a/docs/content/mongocxx-v3/installation/macos.md b/docs/content/mongocxx-v3/installation/macos.md index 509bcbbb5e..906e24f025 100644 --- a/docs/content/mongocxx-v3/installation/macos.md +++ b/docs/content/mongocxx-v3/installation/macos.md @@ -9,7 +9,7 @@ title = "macOS" ### Step 1: Choose a C++17 polyfill -First, [choose a C++17 polyfill library]({{< ref "/mongocxx-v3/installation/polyfill-selection" >}}). +First, [choose a C++17 polyfill library]({{< ref "/mongocxx-v3/polyfill-selection" >}}). ### Step 2: Download the latest version of the mongocxx driver. diff --git a/docs/content/mongocxx-v3/installation/windows.md b/docs/content/mongocxx-v3/installation/windows.md index 25801b0ae0..59923c5dec 100644 --- a/docs/content/mongocxx-v3/installation/windows.md +++ b/docs/content/mongocxx-v3/installation/windows.md @@ -9,7 +9,7 @@ title = "Windows" ### Step 1: Choose a C++17 polyfill -First, [choose a C++17 polyfill library]({{< ref "/mongocxx-v3/installation/polyfill-selection" >}}). +First, [choose a C++17 polyfill library]({{< ref "/mongocxx-v3/polyfill-selection" >}}). ### Step 2: Download the latest version of the mongocxx driver.