Skip to content

Commit 1fda393

Browse files
authored
CXX-2796 Restore external polyfill library and stdlib support (#1086)
* Add BSONCXX_USE_POLY_IMPLS to configuration * Restore stdlib selection for make_unique, string_view, and optional * CXX-641 fix usage of common flags in abidiff-test.sh * Disable tests for external library polyfills * Add changelog entry for ENABLE_BSONCXX_USE_POLY_IMPLS * CXX-2797 Document ENABLE_BSONCXX_POLY_USE_IMPLS and deprecate external polyfill libraries * CXX-2746 Ignore detail namespaces in abi-compliance-check-test.sh * Add deprecation warnings for external polyfill library configurations * Avoid including external symbols in v_noabi abidiff reports * Ignore warnings for symbols unreferenced by debug info in abidiff * Fix scoped_bson_t ambiguous overloads for views and values * Add missing include in catch.hh * Fix missing std::in_place equivalent for Boost before 1.63 * Improve quality of error messages for type trait assertions * Relax trait equality assertions for stdlib implementations * Declare BUILD_TESTING as a CMake option variable * Fix CCACHE_BASEDIR for Windows distros * Add missing macro guards for BSONCXX_POLY_USE_STD * Revert reintroduction of documentation for experimental stdlib polyfill * Move common polyfill selection documentation into separate page
1 parent fe02b0d commit 1fda393

File tree

26 files changed

+609
-309
lines changed

26 files changed

+609
-309
lines changed

.evergreen/abi-compliance-check-test.sh

Lines changed: 47 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,13 @@ command -V abi-compliance-checker >/dev/null
2222

2323
mkdir cxx-abi cxx-noabi
2424

25-
cat >cxx-abi/old.xml <<DOC
25+
# Generate XML descriptors with sections used by both old and new tests.
26+
if true; then
27+
cat >old.xml <<DOC
2628
<version>
2729
${old_ver:?}
2830
</version>
2931
30-
<headers>
31-
../install/old/include/bsoncxx/
32-
../install/old/include/mongocxx/
33-
</headers>
34-
35-
<skip_headers>
36-
/v_noabi/
37-
</skip_headers>
38-
3932
<libs>
4033
../install/old/lib
4134
</libs>
@@ -44,26 +37,13 @@ cat >cxx-abi/old.xml <<DOC
4437
../install/old/include/
4538
</add_include_paths>
4639
47-
<skip_including>
48-
bsoncxx/enums/
49-
/config/
50-
</skip_including>
5140
DOC
5241

53-
cat >cxx-abi/new.xml <<DOC
42+
cat >new.xml <<DOC
5443
<version>
5544
${new_ver:?}
5645
</version>
5746
58-
<headers>
59-
../install/new/include/mongocxx/
60-
../install/new/include/bsoncxx/
61-
</headers>
62-
63-
<skip_headers>
64-
/v_noabi/
65-
</skip_headers>
66-
6747
<libs>
6848
../install/new/lib
6949
</libs>
@@ -72,59 +52,67 @@ cat >cxx-abi/new.xml <<DOC
7252
../install/new/include/
7353
</add_include_paths>
7454
55+
DOC
56+
57+
{
58+
cat <<DOC
7559
<skip_including>
76-
bsoncxx/enums/
77-
/config/
60+
bsoncxx/v_noabi/bsoncxx/enums/
61+
bsoncxx/v_noabi/bsoncxx/config/
7862
</skip_including>
63+
64+
<skip_namespaces>
65+
bsoncxx::detail
66+
bsoncxx::v_noabi::detail
67+
bsoncxx::v_noabi::stdx::detail
68+
</skip_namespaces>
69+
7970
DOC
71+
} | tee -a old.xml new.xml >/dev/null
8072

81-
cat >cxx-noabi/old.xml <<DOC
82-
<version>
83-
${old_ver:?}
84-
</version>
73+
cat old.xml | tee cxx-abi/old.xml cxx-noabi/old.xml >/dev/null
74+
cat new.xml | tee cxx-abi/new.xml cxx-noabi/new.xml >/dev/null
75+
rm old.xml new.xml
76+
fi
8577

78+
# Append sections specific to each ABI test.
79+
if true; then
80+
cat >>cxx-abi/old.xml <<DOC
81+
<headers>
82+
../install/old/include/bsoncxx/
83+
../install/old/include/mongocxx/
84+
</headers>
85+
86+
<skip_headers>
87+
/v_noabi/
88+
</skip_headers>
89+
DOC
90+
91+
cat >>cxx-noabi/old.xml <<DOC
8692
<headers>
8793
../install/old/include/bsoncxx/v_noabi
8894
../install/old/include/mongocxx/v_noabi
8995
</headers>
96+
DOC
9097

91-
<libs>
92-
../install/old/lib
93-
</libs>
94-
95-
<add_include_paths>
96-
../install/old/include/
97-
</add_include_paths>
98+
cat >>cxx-abi/new.xml <<DOC
99+
<headers>
100+
../install/new/include/mongocxx/
101+
../install/new/include/bsoncxx/
102+
</headers>
98103
99-
<skip_including>
100-
bsoncxx/enums/
101-
/config/
102-
</skip_including>
104+
<skip_headers>
105+
/v_noabi/
106+
</skip_headers>
103107
DOC
104108

105-
cat >cxx-noabi/new.xml <<DOC
106-
<version>
107-
${new_ver:?}
108-
</version>
109-
109+
cat >>cxx-noabi/new.xml <<DOC
110110
<headers>
111111
../install/new/include/bsoncxx/v_noabi
112112
../install/new/include/mongocxx/v_noabi
113113
</headers>
114-
115-
<libs>
116-
../install/new/lib
117-
</libs>
118-
119-
<add_include_paths>
120-
../install/new/include/
121-
</add_include_paths>
122-
123-
<skip_including>
124-
bsoncxx/enums/
125-
/config/
126-
</skip_including>
127114
DOC
115+
fi
128116

129117
# Allow task to upload the HTML report despite failed status.
130118
echo "Generating stable ABI report..."

.evergreen/abidiff-test.sh

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ export PATH
1010
PATH="${working_dir:?}/install/bin:${PATH:-}"
1111

1212
declare -a common_flags
13-
flags=(
13+
common_flags=(
1414
--headers-dir1 install/old/include
1515
--headers-dir2 install/new/include
16-
--non-reachable-types
17-
--fail-no-debug-info
16+
--fail-no-debug-info # Ensure debug info is present for our libs.
17+
--no-unreferenced-symbols # Not interested in symbols not owned by our libs.
1818
)
1919

20-
declare -a abi_flags=("${common_flags[@]}" --suppressions cxx-abi/abignore)
21-
declare -a noabi_flags=("${common_flags[@]}" --suppressions cxx-noabi/abignore)
20+
declare -a abi_flags=("${common_flags[@]:?}" --suppressions cxx-abi/abignore)
21+
declare -a noabi_flags=("${common_flags[@]:?}" --suppressions cxx-noabi/abignore)
2222

2323
command -V abidiff >/dev/null
2424

@@ -37,18 +37,24 @@ DOC
3737

3838
cat >cxx-noabi/abignore <<DOC
3939
[suppress_type]
40-
name_regexp = ^(bsoncxx|mongocxx)::v[[:digit:]]+::
40+
name_not_regexp = ^(bsoncxx|mongocxx)::v_noabi::
4141
4242
[suppress_function]
43-
name_regexp = ^(bsoncxx|mongocxx)::v[[:digit:]]+::
43+
name_not_regexp = ^(bsoncxx|mongocxx)::v_noabi::
4444
4545
[suppress_variable]
46-
name_regexp = ^(bsoncxx|mongocxx)::v[[:digit:]]+::
46+
name_not_regexp = ^(bsoncxx|mongocxx)::v_noabi::
4747
DOC
4848

49+
# Ensure files have content even when abidiff produces no output.
50+
echo "---" >>cxx-abi/bsoncxx.txt
51+
echo "---" >>cxx-abi/mongocxx.txt
52+
echo "---" >>cxx-noabi/bsoncxx.txt
53+
echo "---" >>cxx-noabi/mongocxx.txt
54+
4955
# Allow task to upload the diff reports despite failed status.
5056
echo "Comparing stable ABI for bsoncxx..."
51-
if ! abidiff "${abi_flags[@]}" install/old/lib/libbsoncxx.so install/new/lib/libbsoncxx.so &>cxx-abi/bsoncxx.txt; then
57+
if ! abidiff "${abi_flags[@]:?}" install/old/lib/libbsoncxx.so install/new/lib/libbsoncxx.so >>cxx-abi/bsoncxx.txt; then
5258
declare status
5359
status='{"status":"failed", "type":"test", "should_continue":true, "desc":"abidiff returned an error for bsoncxx (stable)"}'
5460
curl -sS -d "${status:?}" -H "Content-Type: application/json" -X POST localhost:2285/task_status || true
@@ -57,23 +63,23 @@ echo "Comparing stable ABI for bsoncxx... done."
5763

5864
# Allow task to upload the diff reports despite failed status.
5965
echo "Comparing stable ABI for mongocxx..."
60-
if ! abidiff "${abi_flags[@]}" install/old/lib/libmongocxx.so install/new/lib/libmongocxx.so &>cxx-abi/mongocxx.txt; then
66+
if ! abidiff "${abi_flags[@]:?}" install/old/lib/libmongocxx.so install/new/lib/libmongocxx.so >>cxx-abi/mongocxx.txt; then
6167
declare status
6268
status='{"status":"failed", "type":"test", "should_continue":true, "desc":"abidiff returned an error for mongocxx (stable)"}'
6369
curl -sS -d "${status:?}" -H "Content-Type: application/json" -X POST localhost:2285/task_status || true
6470
fi
6571
echo "Comparing stable ABI for mongocxx... done."
6672

6773
echo "Comparing unstable ABI for bsoncxx..."
68-
abidiff "${noabi_flags[@]}" install/old/lib/libbsoncxx.so install/new/lib/libbsoncxx.so &>cxx-noabi/bsoncxx.txt || true
74+
abidiff "${noabi_flags[@]:?}" install/old/lib/libbsoncxx.so install/new/lib/libbsoncxx.so >>cxx-noabi/bsoncxx.txt || true
6975
echo "Comparing unstable ABI for bsoncxx... done."
7076

7177
echo "Comparing unstable ABI for mongocxx..."
72-
abidiff "${noabi_flags[@]}" install/old/lib/libmongocxx.so install/new/lib/libmongocxx.so &>cxx-noabi/mongocxx.txt || true
78+
abidiff "${noabi_flags[@]:?}" install/old/lib/libmongocxx.so install/new/lib/libmongocxx.so >>cxx-noabi/mongocxx.txt || true
7379
echo "Comparing unstable ABI for mongocxx... done."
7480

7581
# Ensure files have content even when abidiff produces no output.
76-
printf "\n" >>cxx-abi/bsoncxx.txt
77-
printf "\n" >>cxx-abi/mongocxx.txt
78-
printf "\n" >>cxx-noabi/bsoncxx.txt
79-
printf "\n" >>cxx-noabi/mongocxx.txt
82+
echo "---" >>cxx-abi/bsoncxx.txt
83+
echo "---" >>cxx-abi/mongocxx.txt
84+
echo "---" >>cxx-noabi/bsoncxx.txt
85+
echo "---" >>cxx-noabi/mongocxx.txt

.evergreen/compile.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,11 @@ if command -V ccache 2>/dev/null; then
7171

7272
# Allow reuse of ccache compilation results between different build directories.
7373
export CCACHE_BASEDIR CCACHE_NOHASHDIR
74-
CCACHE_BASEDIR="$(pwd)"
75-
CCACHE_NOHASHDIR=1
76-
# Allow reuse of ccache compilation results between different build directories.
77-
export CCACHE_BASEDIR CCACHE_NOHASHDIR
78-
CCACHE_BASEDIR="$(pwd)"
74+
if [[ "${OSTYPE:?}" == "cygwin" ]]; then
75+
CCACHE_BASEDIR="$(cygpath -aw "$(pwd)")"
76+
else
77+
CCACHE_BASEDIR="$(pwd)"
78+
fi
7979
CCACHE_NOHASHDIR=1
8080
fi
8181

.mci.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -952,7 +952,11 @@ tasks:
952952
953953
# Allow reuse of ccache compilation results between different build directories.
954954
export CCACHE_BASEDIR CCACHE_NOHASHDIR
955-
CCACHE_BASEDIR="$(pwd)"
955+
if [[ "${OSTYPE:?}" == "cygwin" ]]; then
956+
CCACHE_BASEDIR="$(cygpath -aw "$(pwd)")"
957+
else
958+
CCACHE_BASEDIR="$(pwd)"
959+
fi
956960
CCACHE_NOHASHDIR=1
957961
fi
958962
command -v "$cmake_binary"

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ Changes prior to 3.9.0 are documented as [release notes on GitHub](https://githu
1414
- Forward headers providing non-defining declarations of bsoncxx and mongocxx class types.
1515
- Note: user-defined forward declarations of any library entity has not been, and is still not, supported.
1616
To obtain the declaration or definition of a library entity, always include the corresponding header.
17+
- 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.
18+
- 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.
1719

1820
### Changed
1921

CMakeLists.txt

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,7 @@ endif()
2020

2121
project(MONGO_CXX_DRIVER LANGUAGES CXX)
2222

23-
if(NOT DEFINED BUILD_TESTING)
24-
set(BUILD_TESTING OFF) # Set this to OFF by default
25-
endif()
23+
option(BUILD_TESTING "Include test targets in the \"all\" target")
2624

2725
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
2826
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "4.8.2")
@@ -157,6 +155,9 @@ option(BUILD_SHARED_LIBS_WITH_STATIC_MONGOC
157155
OFF
158156
)
159157

158+
# Allow the user to opt into using bsoncxx implementations for C++17 polyfills by default.
159+
option(ENABLE_BSONCXX_POLY_USE_IMPLS "Enable using bsoncxx implementations of C++17 polyfills for pre-C++17 configurations by default" OFF)
160+
160161
if(DEFINED CACHE{ENABLE_ABI_TAG_IN_LIBRARY_FILENAMES} AND NOT MSVC)
161162
message(WARNING "ENABLE_ABI_TAG_IN_LIBRARY_FILENAMES is an MSVC-only option and will be ignored by the current configuration")
162163
unset(ENABLE_ABI_TAG_IN_LIBRARY_FILENAMES CACHE)
@@ -475,6 +476,10 @@ if(NOT(TARGET dist OR TARGET distcheck))
475476
list(APPEND polyfill_flags "-DBSONCXX_POLY_USE_BOOST=${BSONCXX_POLY_USE_BOOST}")
476477
endif()
477478

479+
if(NOT "${BSONCXX_POLY_USE_IMPLS}" STREQUAL "")
480+
list(APPEND polyfill_flags "-DBSONCXX_POLY_USE_IMPLS=${BSONCXX_POLY_USE_IMPLS}")
481+
endif()
482+
478483
if(NOT "${BSONCXX_POLY_USE_STD}" STREQUAL "")
479484
list(APPEND polyfill_flags "-DBSONCXX_POLY_USE_STD=${BSONCXX_POLY_USE_STD}")
480485
endif()

cmake/BsoncxxUtil.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ function(bsoncxx_add_library TARGET OUTPUT_NAME LINK_TYPE)
6262
set(polyfill "m")
6363
elseif(BSONCXX_POLY_USE_BOOST)
6464
set(polyfill "b")
65-
elseif(0) # CXX-2796: reserved for bsoncxx implementations as polyfill.
65+
elseif(BSONCXX_POLY_USE_IMPLS)
6666
set(polyfill "i")
6767
elseif(BSONCXX_POLY_USE_STD)
6868
set(polyfill "s")

0 commit comments

Comments
 (0)