Skip to content

CXX-2796 Restore external polyfill library and stdlib support #1086

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 37 commits into from
Feb 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
4f15b2e
Add BSONCXX_USE_POLY_IMPLS to configuration
eramongodb Jan 23, 2024
a69b3e3
Formatting
eramongodb Jan 23, 2024
966a23f
Restore stdlib selection for make_unique.hpp
eramongodb Jan 23, 2024
d8296bc
Restore polyfill selection for string_view.hpp
eramongodb Jan 23, 2024
0f165a8
CXX-641 fix usage of common flags in abidiff-test.sh
eramongodb Jan 23, 2024
57acd57
Disable string_view tests for external library polyfills
eramongodb Jan 23, 2024
ea7309f
Add changelog entry for ENABLE_BSONCXX_USE_POLY_IMPLS
eramongodb Jan 23, 2024
e3d08d5
CXX-2797 Document ENABLE_BSONCXX_POLY_USE_IMPLS and deprecate externa…
eramongodb Jan 23, 2024
f773f30
CXX-2746 Ignore detail namespaces in abi-compliance-check-test.sh
eramongodb Jan 23, 2024
c274948
Add deprecation warnings for external polyfill library configurations
eramongodb Jan 23, 2024
3bac3d6
Tweak wording of deprecation message to state _recommended_ behavior
eramongodb Jan 23, 2024
dd23ba6
Add impls to list of mutually exclusive polyfill options
eramongodb Jan 24, 2024
75ad387
Fix endif comment in make_unique.hpp
eramongodb Jan 24, 2024
b44f70c
Merge remote-tracking branch 'upstream/master' into HEAD
eramongodb Feb 14, 2024
552550b
Formatting
eramongodb Feb 13, 2024
e184c3f
Avoid including external symbols in v_noabi abidiff reports
eramongodb Feb 12, 2024
852ce18
Restore polyfill selection for optional.hpp
eramongodb Feb 12, 2024
27f7054
Ignore warnings for symbols unreferenced by debug info
eramongodb Feb 12, 2024
f9d9076
Fix scoped_bson_t ambiguous overloads for views and values
eramongodb Feb 12, 2024
7a23d4a
Add missing include in catch.hh
eramongodb Feb 12, 2024
5c343f8
Disable optional tests for external library polyfills
eramongodb Feb 12, 2024
d0f910c
Conditionally disable convertible ctor static assertion
eramongodb Feb 12, 2024
8bdf1ed
Fix missing std::in_place equivalent for Boost before 1.63
eramongodb Feb 12, 2024
39979f6
Improve quality of error messages for type trait assertions
eramongodb Feb 12, 2024
2318708
Relax trait equality assertions for stdlib implementations
eramongodb Feb 13, 2024
26257b9
Declare BUILD_TESTING as a CMake option variable
eramongodb Feb 13, 2024
0b44dd8
Fix CCACHE_BASEDIR for Windows distros
eramongodb Feb 13, 2024
2c12fbd
Update documentation comments for consistency
eramongodb Feb 14, 2024
1b39989
Tweak description of ENABLE_BSONCXX_POLY_USE_IMPLS to mention "by def…
eramongodb Feb 14, 2024
d6eafaa
Tweak ordering of polyfills for consistency
eramongodb Feb 14, 2024
26d2436
Add missing macro guards for BSONCXX_POLY_USE_STD
eramongodb Feb 14, 2024
2039aac
Revert reintroduction of documentation for experimental stdlib polyfill
eramongodb Feb 14, 2024
bbf5dd5
Merge remote-tracking branch 'upstream/master' into cxx-2796
eramongodb Feb 14, 2024
8715b73
Move common polyfill selection documentation into separate page
eramongodb Feb 20, 2024
7c06aed
Tweak wording to recommend ENABLE_BSONCXX_POLY_USE_IMPLS=ON by default
eramongodb Feb 20, 2024
2c43b52
Move polyfill-selection file to consistent directory placement
eramongodb Feb 20, 2024
7cff319
Update references to polyfill-selection page
eramongodb Feb 20, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
106 changes: 47 additions & 59 deletions .evergreen/abi-compliance-check-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,13 @@ command -V abi-compliance-checker >/dev/null

mkdir cxx-abi cxx-noabi

cat >cxx-abi/old.xml <<DOC
# Generate XML descriptors with sections used by both old and new tests.
if true; then
cat >old.xml <<DOC
<version>
${old_ver:?}
</version>

<headers>
../install/old/include/bsoncxx/
../install/old/include/mongocxx/
</headers>

<skip_headers>
/v_noabi/
</skip_headers>

<libs>
../install/old/lib
</libs>
Expand All @@ -44,26 +37,13 @@ cat >cxx-abi/old.xml <<DOC
../install/old/include/
</add_include_paths>

<skip_including>
bsoncxx/enums/
/config/
</skip_including>
DOC

cat >cxx-abi/new.xml <<DOC
cat >new.xml <<DOC
<version>
${new_ver:?}
</version>

<headers>
../install/new/include/mongocxx/
../install/new/include/bsoncxx/
</headers>

<skip_headers>
/v_noabi/
</skip_headers>

<libs>
../install/new/lib
</libs>
Expand All @@ -72,59 +52,67 @@ cat >cxx-abi/new.xml <<DOC
../install/new/include/
</add_include_paths>

DOC

{
cat <<DOC
<skip_including>
bsoncxx/enums/
/config/
bsoncxx/v_noabi/bsoncxx/enums/
bsoncxx/v_noabi/bsoncxx/config/
</skip_including>

<skip_namespaces>
bsoncxx::detail
bsoncxx::v_noabi::detail
bsoncxx::v_noabi::stdx::detail
</skip_namespaces>

DOC
} | tee -a old.xml new.xml >/dev/null

cat >cxx-noabi/old.xml <<DOC
<version>
${old_ver:?}
</version>
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 <<DOC
<headers>
../install/old/include/bsoncxx/
../install/old/include/mongocxx/
</headers>

<skip_headers>
/v_noabi/
</skip_headers>
DOC

cat >>cxx-noabi/old.xml <<DOC
<headers>
../install/old/include/bsoncxx/v_noabi
../install/old/include/mongocxx/v_noabi
</headers>
DOC

<libs>
../install/old/lib
</libs>

<add_include_paths>
../install/old/include/
</add_include_paths>
cat >>cxx-abi/new.xml <<DOC
<headers>
../install/new/include/mongocxx/
../install/new/include/bsoncxx/
</headers>

<skip_including>
bsoncxx/enums/
/config/
</skip_including>
<skip_headers>
/v_noabi/
</skip_headers>
DOC

cat >cxx-noabi/new.xml <<DOC
<version>
${new_ver:?}
</version>

cat >>cxx-noabi/new.xml <<DOC
<headers>
../install/new/include/bsoncxx/v_noabi
../install/new/include/mongocxx/v_noabi
</headers>

<libs>
../install/new/lib
</libs>

<add_include_paths>
../install/new/include/
</add_include_paths>

<skip_including>
bsoncxx/enums/
/config/
</skip_including>
DOC
fi

# Allow task to upload the HTML report despite failed status.
echo "Generating stable ABI report..."
Expand Down
38 changes: 22 additions & 16 deletions .evergreen/abidiff-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ 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
--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)
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

Expand All @@ -37,18 +37,24 @@ DOC

cat >cxx-noabi/abignore <<DOC
[suppress_type]
name_regexp = ^(bsoncxx|mongocxx)::v[[:digit:]]+::
name_not_regexp = ^(bsoncxx|mongocxx)::v_noabi::

[suppress_function]
name_regexp = ^(bsoncxx|mongocxx)::v[[:digit:]]+::
name_not_regexp = ^(bsoncxx|mongocxx)::v_noabi::

[suppress_variable]
name_regexp = ^(bsoncxx|mongocxx)::v[[:digit:]]+::
name_not_regexp = ^(bsoncxx|mongocxx)::v_noabi::
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
Expand All @@ -57,23 +63,23 @@ 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
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
13 changes: 6 additions & 7 deletions .evergreen/compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -116,7 +115,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
Expand Down
6 changes: 5 additions & 1 deletion .mci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
11 changes: 8 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -157,6 +155,9 @@ option(BUILD_SHARED_LIBS_WITH_STATIC_MONGOC
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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm iffy on this CMake setting name. It is unclear what it means compared to USE_BOOST, USE_STD, USE_MNMLSTC etc. I'm unfortunately not sure on what a better name might be.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I went back and forth several times on what to name this configuration and settled on "bsoncxx implementations" -> "IMPLS" due to the ABI tag parameter b already being used for Boost. This way i can be used for "(bsoncxx) implementations". The hope is that descriptions and documentation will be enough to make its purpose/meaning clear.


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)
Expand Down Expand Up @@ -475,6 +476,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()
Expand Down
2 changes: 1 addition & 1 deletion cmake/BsoncxxUtil.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ function(bsoncxx_add_library TARGET OUTPUT_NAME LINK_TYPE)
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")
Expand Down
Loading