[CXX-2121] Compilation error with libc++ and C++ 17 Created: 21/Oct/20  Updated: 28/Oct/23  Resolved: 25/Oct/20

Status: Closed
Project: C++ Driver
Component/s: Build
Affects Version/s: 3.6.0
Fix Version/s: 3.6.1

Type: Bug Priority: Major - P3
Reporter: Magnus Håkansson Assignee: Roberto Sanchez
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Using clang 10 on Debian and pass in -DCMAKE_CXX_STANDARD=17 and -DCMAKE_CXX_FLAGS="-stdlib=libc++"


Attachments: Text File cmake-output.txt     Text File make-output.txt    

 Description   

I get this:

In file included from /home/gho/code/pc3-mongo-cxx-driver/src/mongocxx/options/auto_encryption.cpp:15:
In file included from /home/gho/code/pc3-mongo-cxx-driver/src/mongocxx/options/auto_encryption.hpp:17:
In file included from /home/gho/code/pc3-mongo-cxx-driver/src/bsoncxx/document/view_or_value.hpp:17:
In file included from /home/gho/code/pc3-mongo-cxx-driver/src/bsoncxx/document/value.hpp:18:
In file included from /usr/lib/llvm-10/bin/../include/c++/v1/memory:657:
/usr/lib/llvm-10/bin/../include/c++/v1/utility:305:9: error: implicit instantiation of undefined template 'std::_1::basic_string<char, std::1::char_traits<char>, std::_1::allocator<char> >'
_T1 first;
^
/usr/lib/llvm-10/bin/../include/c++/v1/type_traits:3035:38: note: in instantiation of template class 'std::_1::pair<std::1::basic_string<char, std::1::char_traits<char>, std::1::allocator<char> >, std::1::basic_string<char, std::1::char_traits<char>, std::_1::allocator<char> > >' requested here
: public integral_constant<bool, __is_trivially_destructible(_Tp)> {};
^
/usr/lib/llvm-10/bin/../include/c++/v1/optional:538:5: note: in instantiation of template class 'std::_1::is_trivially_destructible<std::1::pair<std::1::basic_string<char, std::1::char_traits<char>, std::1::allocator<char> >, std::1::basic_string<char, std::1::char_traits<char>, std::_1::allocator<char> > > >' requested here
is_trivially_destructible<_Tp>::value &&
^
/usr/lib/llvm-10/bin/../include/c++/v1/optional:585:15: note: in instantiation of default argument for '_optional_move_assign_base<std::1::pair<std::1::basic_string<char, std::1::char_traits<char>, std::1::allocator<char> >, std::1::basic_string<char, std::1::char_traits<char>, std::_1::allocator<char> > > >' required here
: private __optional_move_assign_base<_Tp>
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/gho/code/pc3-mongo-cxx-driver/src/mongocxx/options/auto_encryption.hpp:254:29: note: in instantiation of template class 'std::_1::optional<std::1::pair<std::1::basic_string<char, std::1::char_traits<char>, std::1::allocator<char> >, std::1::basic_string<char, std::1::char_traits<char>, std::_1::allocator<char> > > >' requested here
stdx::optional<ns_pair> _key_vault_namespace;
^
/usr/lib/llvm-10/bin/../include/c++/v1/iosfwd:209:32: note: template is declared here
class _LIBCPP_TEMPLATE_VIS basic_string;
^



 Comments   
Comment by Kevin Albertson [ 26/Oct/20 ]

As an update, we'll apply that fix on a 3.6.1 release. 94715d8cf has been applied to the 3.6 branch and will be included in the upcoming 3.6.1 release.

Comment by Magnus Håkansson [ 26/Oct/20 ]

Great. Thanks. I will check more carefully on master next time.

Comment by Roberto Sanchez [ 25/Oct/20 ]

magnus.l.hakansson@gmail.com, the r3.6.0 tag and the #include <string> workaround were the information I needed. This particular issue was recently fixed in commit 94715d8cf. At this moment, the next release that will include this fix will be 3.7.0.

Comment by Magnus Håkansson [ 23/Oct/20 ]

My colleague found that if we add #include <string> to auto_encryption.hpp and client_encryption.hpp it works.

Comment by Magnus Håkansson [ 23/Oct/20 ]

I'm sorry for the missing pieces in the description.

I checked out the tag "r.3.6.0"

Run cmake with:

cmake -DCMAKE_PREFIX_PATH="/home/gho/code/pc3-mongo-cxx-driver/packages/mongo-c-driver/Debug" -DCMAKE_INSTALL_PREFIX=install -DBUILD_SHARED_LIBS=OFF -DCMAKE_CXX_STANDARD=17 -DCMAKE_CXX_FLAGS="-stdlib=libc++" -DCMAKE_VERBOSE_MAKEFILE=ON ..

The once that make a difference for me between success/fail is "-stdlib=libc++"

build with

make -j 10 mongocxx_static

Clang version:

clang version 10.0.0-++20200412072704+50d7e5d5e7d-1~exp1~20200412053303.133

The output I have attached in the ticket.

 

Comment by Roberto Sanchez [ 22/Oct/20 ]

magnus.l.hakansson@gmail.com I tried to reproduce this on Debian sid, but the full build succeeds for me. Could you provide the complete cmake command you are using, its full output, the complete build command, and its full output as well. You can attach the output to this ticket or email it to me. Additionally, please make sure that your CMake command includes the option -DCMAKE_VERBOSE_MAKEFILE=ON.

Generated at Wed Feb 07 22:04:57 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.