[SERVER-39189] MongoDB failed to buid due to C2039 C2275 C2059 C3536 and C2440 on MSVC Created: 25/Jan/19  Updated: 20/Feb/19  Resolved: 20/Feb/19

Status: Closed
Project: Core Server
Component/s: Build
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: LinGao Assignee: Andrew Morrow (Inactive)
Resolution: Cannot Reproduce Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

VS 2017 + Windows Server 2016 + MongoDB master branch latest revision


Attachments: Text File log_scons.log     Text File log_x64_build.log     Text File log_x64_build_latestversion.log     Text File log_x64_build_withoutpatch__latestmaster.log     Text File mongodb.patch     Text File mongodb_bug668740.patch     Text File mongodb_c2039,c3646.patch     Text File mongodb_permissive_c3861.patch    
Operating System: ALL
Steps To Reproduce:

Reproduce steps:
1. git clone -c core.autocrlf=true https://github.com/mongodb/mongo D:\MongoDB\src
2. Open a VS 2017 x64 command prompt and browse to D:\MongoDB\src
3. Download the attachments and apply all patches for MongoDB.
4. pip.exe install -r .\buildscripts\requirements.txt
5. set CL=/wd4756 /wd4056
6. scons all -j4 CXXFLAGS="/wd4756 /wd4056"

 

Acutal result:
service_context.cpp
D:\MongoDB\src\src\mongo/util/future.h(1726): error C2039: 'make_intrusive': is not a member of 'mongo::future_details'
D:\MongoDB\src\src\mongo/util/future.h(55): note: see declaration of 'mongo::future_details'
D:\MongoDB\src\src\mongo/util/future.h(1722): note: while compiling class template member function 'mongo::future_details::SharedSemiFuture<T> mongo::future_details::Future<T>::share(void) noexcept &&'
with
[
T=mongo::future_details::FakeVoid
]
D:\MongoDB\src\src\mongo/util/future.h(1732): note: see reference to function template instantiation 'mongo::future_details::SharedSemiFuture<T> mongo::future_details::Future<T>::share(void) noexcept &&' being compiled
with
[
T=mongo::future_details::FakeVoid
]
D:\MongoDB\src\src\mongo/util/future.h(1423): note: see reference to class template instantiation 'mongo::future_details::Future<mongo::future_details::FakeVoid>' being compiled
D:\MongoDB\src\src\mongo/util/future.h(1726): error C2275: 'mongo::future_details::SharedState<mongo::future_details::FakeVoid>': illegal use of this type as an expression
D:\MongoDB\src\src\mongo/util/future.h(1726): note: see declaration of 'mongo::future_details::SharedState<mongo::future_details::FakeVoid>'
D:\MongoDB\src\src\mongo/util/future.h(1726): error C2059: syntax error: ')'
D:\MongoDB\src\src\mongo/util/future.h(1727): error C3536: 'shared': cannot be used before it is initialized
D:\MongoDB\src\src\mongo/util/future.h(1728): error C2440: '<function-style-cast>': cannot convert from 'int' to 'mongo::future_details::SharedSemiFuture<T>'
with
[
T=mongo::future_details::FakeVoid
]
D:\MongoDB\src\src\mongo/util/future.h(1728): note: No constructor could take the source type, or constructor overload resolution was ambiguous
scons: *** [build\opt\mongo\db\operation_context.obj] Error 2

 


  • Acutal result:
Sprint: Dev Tools 2019-02-11, Dev Tools 2019-02-25
Participants:

 Description   

MongoDB failed to buid due to C2039 C2275 C2059 C3536 and C2440 on MSVC. These errors appears to be make_intrusive not defined in the future.h file and can be first reproduced on 3e402ff version. We use latest version of MongoDB to test VS copmlier. And we know building MongoDB with VS 2017 is currently not supported, so we apply patch to support this, I attach this patch. Could you please help to take a look at this? Thanks in advance!



 Comments   
Comment by Andrew Morrow (Inactive) [ 20/Feb/19 ]

spacelg - I'm closing this ticket out because I believe the codebase on the master branch works out of the box with VS 2017. Please feel free to comment on this ticket if you are still having issues and we can re-open it.

Comment by Andrew Morrow (Inactive) [ 14/Feb/19 ]

spacelg - This is quite puzzling to me. You can see our build log for that file on master on Windows with VS 2017 here: https://evergreen.mongodb.com/task_log_raw/mongodb_mongo_master_enterprise_windows_64_2k8_compile_27d6644dffd80f139b90a8e89f1b21d8830ec35a_19_02_14_14_51_41/0?type=T#L2825

It compiles for us without warnings or errors, that I see. Our command line for that file looks like:

cl /Fobuild\cached\mongo\scripting\mozjs\base.obj /c src\mongo\scripting\mozjs\base.cpp /TP /nologo /EHsc /W3 /wd4068 /wd4244 /wd4267 /wd4290 /wd4351 /wd4355 /wd4373 /wd4800 /wd5041 /wd4291 /we4013 /we4099 /we4930 /WX /errorReport:none /MD /O2 /Oy- /bigobj /utf-8 /Zc:rvalueCast /Zc:strictStrings /volatile:iso /Zc:__cplusplus /permissive- /std:c++17 /Gw /Gy /Zc:inline /FI js-config.h /FI js/RequiredDefines.h /DJS_USE_CUSTOM_ALLOCATOR /DSTATIC_JS_API=1 /DPCRE_STATIC /DNDEBUG /DBOOST_ALL_NO_LIB /D_UNICODE /DUNICODE /D_SILENCE_CXX17_ALLOCATOR_VOID_DEPRECATION_WARNING /D_SILENCE_CXX17_OLD_ALLOCATOR_MEMBERS_DEPRECATION_WARNING /D_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING /D_CONSOLE /D_CRT_SECURE_NO_WARNINGS /D_SCL_SECURE_NO_WARNINGS /D_WIN32_WINNT=0x0601 /DNTDDI_VERSION=0x06010000 /DBOOST_SYSTEM_NO_DEPRECATED /DBOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS /DABSL_FORCE_ALIGNED_ACCESS /D_SILENCE_CXX17_ITERATOR_BASE_CLASS_DEPRECATION_WARNING /Isrc\third_party\mozjs-60\include /Isrc\third_party\mozjs-60\mongo_sources /Isrc\third_party\mozjs-60\platform\x86_64\windows\include /Isrc\third_party\pcre-8.42 /Isrc\third_party\boost-1.69.0 /Isrc\third_party\abseil-cpp-master\abseil-cpp /IC:\sasl\include /IC:\snmp\include /Ibuild\cached /Isrc /Z7

I'd be interested to know what your cl invocation for that file looks like in your build so we can diff them.

Comment by LinGao [ 14/Feb/19 ]

Hi Andrew Morrow -Thanks for your information!  I'm sorry that I use wrong path.

As you said. I ues right path in my script as below:

call %_SCRIPT_DIR%\RunHelper.cmd "python.exe buildscripts/scons.py" %_LOG_DIR%\log_scons.log & if NOT "Unable to render embedded object: File (ERRORLEVEL) not found." == "0" exit /b 2008

 

python.exe buildscripts/scons.py  will get the following errors:

D:\MongoDB\src\src\third_party\mozjs-60\include\mozilla/Variant.h(247): error C2988: unrecognizable template declaration/definition
D:\MongoDB\src\src\third_party\mozjs-60\include\mozilla/Variant.h(723): note: see reference to class template instantiation 'mozilla::detail::VariantImplementation<bool,0,const char *,JS::UniqueChars>' being compiled
D:\MongoDB\src\src\third_party\mozjs-60\include\jsapi.h(5968): note: see reference to class template instantiation 'mozilla::Variant<const char *,JS::UniqueChars>' being compiled
D:\MongoDB\src\src\third_party\mozjs-60\include\mozilla/Variant.h(247): error C2059: syntax error: 'template'
D:\MongoDB\src\src\third_party\mozjs-60\include\mozilla/Variant.h(247): error C3553: decltype expects an expression not a type
D:\MongoDB\src\src\third_party\mozjs-60\include\mozilla/Variant.h(247): error C3646: 'as': unknown override specifier
D:\MongoDB\src\src\third_party\mozjs-60\include\mozilla/Variant.h(247): error C2059: syntax error: '<'
D:\MongoDB\src\src\third_party\mozjs-60\include\mozilla/Variant.h(248): error C2334: unexpected token(s) preceding '{'; skipping apparent function body
scons: *** [build\opt\mongo\scripting\mozjs\base.obj] Error 2

 

Could you please help to take a look at this? Thanks in advance!

log_scons.log

 

 

 

Comment by Andrew Morrow (Inactive) [ 13/Feb/19 ]

I think I just had a typo in my prior posting (builscripts vs buildscripts). You should be able to run python ./buildscripts/scons.py to start the build.

Comment by LinGao [ 13/Feb/19 ]

Hi Andrew Morrow -Thanks for your information!

At the beginning,MongoDB failed to build due to upgrade SCons to version 3.0.4. Scons 3.0.0 was used in our test machine. So we replaced scons 3.0.0 with scons 3.0.4 .

Extract the downloaded scons-3.0.4.zip file to D:\MongoDB\tools\ and execute the following commands:
Python.exe -m pip install pymongo
Python.exe -m pip install pyyaml
Python.exe -m pip install pypiwin32
Python.exe -m pip install requests
Pip.exe install -r D:\MongoDB\src\etc\pip\compile-requirements.txt

Then we started to build.

Currently,i try building with the built-in copy of SCons we have in the tree. When i get it by running python builscripts/scons.py. Always get the following results:

[executing command] python.exe builscripts/scons.py
python.exe: can't open file 'builscripts/scons.py': [Errno 2] No such file or directory
[command took 0 seconds]

We are able to determine that the scons.py file is present in this path D:\MongoDB\src\buildscripts.

Is there a change in the way to build mongodb?

Could you please help to take a look at this? Thanks in advance!

 

 

Comment by Andrew Morrow (Inactive) [ 12/Feb/19 ]

spacelg - That is a very odd error. I don't think it is related to our recent C++17 changes, but it could be related to some upstream changes that SCons has recently made. Could you please try building with the built-in copy of SCons we have in the tree? You can get it by running python builscripts/scons.py. We generally prefer to build using the built-in SCons as we sometimes cherry-pick in important fixes.

Comment by LinGao [ 12/Feb/19 ]

Hi Andrew Morrow - Thank you so much for your reply! I am very sorry that I have not responded to you in time due to the Chinese New Year holiday.

I have tested with latest version of master branch 8e76d8c. It failed to build due to D:\MongoDB\src\src\mongo/db/auth/action_set.h(38): fatal error C1083: Cannot open include file: 'mongo/db/auth/action_type.h': No such file or directory

 

In action_set.h line 38: #include "mongo/db/auth/action_type.h".  But we couldn't find action_type.h in source code path. Could you please help to take a look at this? Thanks in advance!

 

Acutal result:

D:\MongoDB\src\src\mongo/db/auth/action_set.h(38): fatal error C1083: Cannot open include file: 'mongo/db/auth/action_type.h': No such file or directory

 

log_x64_build_latestversion.log

 

 

Comment by Andrew Morrow (Inactive) [ 07/Feb/19 ]

Hi spacelg - Just checking back on this ticket. Have you been able to test with the latest version of master branch?

Comment by Andrew Morrow (Inactive) [ 01/Feb/19 ]

spacelg - Please note that SERVER-38176 has been fixed on master, so the tree should build now with /permissive-.

Comment by Andrew Morrow (Inactive) [ 01/Feb/19 ]

Hi spacelg - We are actively working on fixing issues such that we can enable /permissive- in SERVER-38176. I am puzzled though by the issues you are seeing in the new mozjs-60 integration. That just landed a few days ago, but it is building fine for us in C++17 mode with VS 2017.

Comment by LinGao [ 01/Feb/19 ]

Hi Ander Morrow

Thanks for your reply.

The mongodb_permissive_c3861.patch in the attachment replaces ''SharedState<T>'' in './src/mongo/util/future.h with ''future_details::SharedState<T>''. This may be reported Error ''error C2039: 'make_intrusive': is not a member of 'mongo::future_details' '' related.

So I removed this mongodb_permissive_c3861.patch and pulled the latest master. Re-follow the Reproduce steps to build MongoDB. But I got a lot of other errors.

 

log_x64_build_withoutpatch__latestmaster.log

Acutal result:

D:\MongoDB\src\src\third_party\mozjs-60\include\mozilla/Variant.h(247): error C2988: unrecognizable template declaration/definition
D:\MongoDB\src\src\third_party\mozjs-60\include\mozilla/Variant.h(723): note: see reference to class template instantiation 'mozilla::detail::VariantImplementation<bool,0,const char *,JS::UniqueChars>' being compiled
D:\MongoDB\src\src\third_party\mozjs-60\extract\js\src\jsapi.h(5968): note: see reference to class template instantiation 'mozilla::Variant<const char *,JS::UniqueChars>' being compiled
D:\MongoDB\src\src\third_party\mozjs-60\include\mozilla/Variant.h(247): error C2059: syntax error: 'template'
D:\MongoDB\src\src\third_party\mozjs-60\include\mozilla/Variant.h(247): error C3553: decltype expects an expression not a type
D:\MongoDB\src\src\third_party\mozjs-60\include\mozilla/Variant.h(247): error C3646: 'as': unknown override specifier
D:\MongoDB\src\src\third_party\mozjs-60\include\mozilla/Variant.h(247): error C2059: syntax error: '<'
D:\MongoDB\src\src\third_party\mozjs-60\include\mozilla/Variant.h(248): error C2334: unexpected token(s) preceding '{'; skipping apparent function body
D:\MongoDB\src\src\third_party\mozjs-60\include\mozilla/Variant.h(247): error C2988: unrecognizable template declaration/definition
D:\MongoDB\src\src\third_party\mozjs-60\include\mozilla/Variant.h(723): note: see reference to class template instantiation 'mozilla::detail::VariantImplementation<bool,0,const char *,JS::UniqueChars>' being compiled
D:\MongoDB\src\src\third_party\mozjs-60\extract\js\src\jsapi.h(5968): note: see reference to class template instantiation 'mozilla::Variant<const char *,JS::UniqueChars>' being compiled
D:\MongoDB\src\src\third_party\mozjs-60\include\mozilla/Variant.h(247): error C2059: syntax error: 'template'
D:\MongoDB\src\src\third_party\mozjs-60\include\mozilla/Variant.h(247): error C3553: decltype expects an expression not a type
D:\MongoDB\src\src\third_party\mozjs-60\include\mozilla/Variant.h(247): error C3646: 'as': unknown override specifier
D:\MongoDB\src\src\third_party\mozjs-60\include\mozilla/Variant.h(247): error C2059: syntax error: '<'
D:\MongoDB\src\src\third_party\mozjs-60\include\mozilla/Variant.h(248): error C2334: unexpected token(s) preceding '{'; skipping apparent function body

 

 

 

Comment by Andrew Morrow (Inactive) [ 31/Jan/19 ]

Hi spacelg -

We believe that the mongodb master branch should now compile without modification in VS 2017, and without additional warning flags passed on the command line. Could you please pull the latest master and see if it works for you?

Comment by Danny Hatcher (Inactive) [ 25/Jan/19 ]

Hello,

Thank you for your report. I have forwarded this ticket to the appropriate team.

Danny

Generated at Thu Feb 08 04:51:18 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.