Skip to content
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

osquery Windows build fails with error C3892 #6655

Closed
spacelg opened this issue Sep 18, 2020 · 4 comments · Fixed by #6759
Closed

osquery Windows build fails with error C3892 #6655

spacelg opened this issue Sep 18, 2020 · 4 comments · Fixed by #6759
Labels
bug build libraries For things referring to osquery third party libraries Windows

Comments

@spacelg
Copy link

spacelg commented Sep 18, 2020

Hi All,

We tried to build osquery on Windows with unreleased VS2019. It failed to build due to error C3892: '_First': you cannot assign to a variable that is const with MSVC on windows. It can be reproduced on latest reversion f4555ac . Could you please help take a look at this? Thanks!

Steps to reproduce:

  1. git clone https://github.com/facebook/osquery F:\gitP\facebook\osquery
  2. Open VS2019 x64 command prompt as admin and browse to F:\gitP\facebook\osquery\build
  3. set PATH=C:\Python\Python27;%PATH%
  4. set PATH=C:\Python\Python27\Scripts;%PATH%
  5. cmake -G "Visual Studio 16 2019" -A x64 -DCMAKE_SYSTEM_VERSION=10.0.18362.0 ..
  6. set CL=/D_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING
  7. cmake --build . --target osqueryd --config Release --verbose -- /maxcpucount

build.log

Actual result:
445>C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.26.28801\include\algorithm(7447,17): error C3892: '_First': you cannot assign to a variable that is const [F:\gitP\facebook\osquery\build\libs\src\rocksdb\thirdparty_rocksdb.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.26.28801\include\algorithm(7569): message : see reference to function template instantiation '_BidIt std::_Insertion_sort_unchecked<_RanIt,_Pr>(const _BidIt,const _BidIt,_Pr)' being compiled [F:\gitP\facebook\osquery\build\libs\src\rocksdb\thirdparty_rocksdb.vcxproj]
with
[
_BidIt=rocksdb::autovector<const rocksdb::IngestedFileInfo *,8>::iterator_impl<rocksdb::autovector<const rocksdb::IngestedFileInfo *,8>,const rocksdb::IngestedFileInfo *>,
_RanIt=rocksdb::autovector<const rocksdb::IngestedFileInfo *,8>::iterator_impl<rocksdb::autovector<const rocksdb::IngestedFileInfo *,8>,const rocksdb::IngestedFileInfo *>,
_Pr=rocksdb::ExternalSstFileIngestionJob::Prepare::<lambda_5cd11890b167765aab44fdd1b21b5d50>
]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.26.28801\include\algorithm(7599): message : see reference to function template instantiation 'void std::_Sort_unchecked<_RanIt,_Fn>(_RanIt,_RanIt,__int64,_Pr)' being compiled [F:\gitP\facebook\osquery\build\libs\src\rocksdb\thirdparty_rocksdb.vcxproj]
with
[
_RanIt=rocksdb::autovector<const rocksdb::IngestedFileInfo *,8>::iterator_impl<rocksdb::autovector<const rocksdb::IngestedFileInfo *,8>,const rocksdb::IngestedFileInfo *>,
_Fn=rocksdb::ExternalSstFileIngestionJob::Prepare::<lambda_5cd11890b167765aab44fdd1b21b5d50>,
_Pr=rocksdb::ExternalSstFileIngestionJob::Prepare::<lambda_5cd11890b167765aab44fdd1b21b5d50>
]
F:\gitP\facebook\osquery\libraries\cmake\source\rocksdb\src\db\external_sst_file_ingestion_job.cc(70): message : see reference to function template instantiation 'void std::sort<rocksdb::autovector<const rocksdb::IngestedFileInfo *,8>::iterator_impl<rocksdb::autovector<const rocksdb::IngestedFileInfo *,8>,const rocksdb::IngestedFileInfo *>,rocksdb::ExternalSstFileIngestionJob::Prepare::<lambda_5cd11890b167765aab44fdd1b21b5d50>>(const _RanIt,const _RanIt,_Pr)' being compiled [F:\gitP\facebook\osquery\build\libs\src\rocksdb\thirdparty_rocksdb.vcxproj]
with
[
_RanIt=rocksdb::autovector<const rocksdb::IngestedFileInfo *,8>::iterator_impl<rocksdb::autovector<const rocksdb::IngestedFileInfo *,8>,const rocksdb::IngestedFileInfo *>,
_Pr=rocksdb::ExternalSstFileIngestionJob::Prepare::<lambda_5cd11890b167765aab44fdd1b21b5d50>
]
experimental.cc

@theopolis theopolis added libraries For things referring to osquery third party libraries Windows labels Sep 18, 2020
@Smjert
Copy link
Member

Smjert commented Sep 18, 2020

Hi @spacelg, from the error you've copied here I only see sources which are related to RocksDB, not osquery itself.
Does the most recent RocksDB version compiles correctly?

@spacelg
Copy link
Author

spacelg commented Sep 22, 2020

Hi @Smjert ,

Thanks for your reply. I tried to build RocksDB with latest RocksDB reversion 9d8eb77. It can build pass.

For above error C3892: '_First': you cannot assign to a variable that is const. Found that only failed to compile ..\rocksdb\src\db\external_sst_file_ingestion_job.cc as below:

F:\gitP\facebook\osquery\build\libs\src\rocksdb>"C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.26.28801\bin\HostX64\x64\CL.exe" /c /IF:\gitP\facebook\osquery\libraries\cmake\source\rocksdb\src /IF:\gitP\facebook\osquery\libraries\cmake\source\rocksdb\src\util /IF:\gitP\facebook\osquery\libraries\cmake\source\rocksdb\src\include /nologo /W0 /WX- /diagnostics:column /O2 /Ob2 /Ot /D WIN32 /D _WINDOWS /D NDEBUG /D OS_WIN /D _MBCS /D WIN64 /D NOMINMAX /D _WIN32_WINNT=_WIN32_WINNT_WIN7 /D NTDDI_VERSION=NTDDI_WIN7 /D BOOST_ALL_NO_LIB /D BOOST_ALL_STATIC_LINK /D "CMAKE_INTDIR="Release"" /D _MBCS /Gm- /EHs /MT /GS /guard:cf /fp:precise /Zc:wchar_t /Zc:forScope /GR /Fo"thirdparty_rocksdb.dir\Release\" /Fd"thirdparty_rocksdb.dir\Release\thirdparty_rocksdb.pdb" /Gd /TP /errorReport:queue /bigobj F:\gitP\facebook\osquery\libraries\cmake\source\rocksdb\src\db\external_sst_file_ingestion_job.cc
external_sst_file_ingestion_job.cc
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.26.28801\include\algorithm(7447,17): error C3892: '_First': you cannot assign to a variable that is const
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.26.28801\include\algorithm(7569): note: see reference to function template instantiation '_BidIt std::_Insertion_sort_unchecked<_RanIt,_Pr>(const _BidIt,const _BidIt,_Pr)' being compiled

And found that the external_sst_file_ingestion_job.cc in the osquery libraries is very different from the external_sst_file_ingestion_job.cc in the rocksdb source code.

Is the rocksdb in osquery libraries not updated in time cause this?

Thanks,
Lin

@Agile86
Copy link
Contributor

Agile86 commented Nov 20, 2020

Having the same error with the latest osquery release (4.5.1, 4.5.0).
VS2019 v16.8.2, stdc++ v14.28.29333

p.s. 4.4.0 compiling without issues.

@mike-myers-tob
Copy link
Member

In a discussion in Slack, we identified a likely fix: to upgrade our RocksDB pinned version. This build error happens as a result of a new MSVC: version 14.26.28801 won't have this error but version 14.28.29333 will.

@mike-myers-tob mike-myers-tob changed the title Osquery failed with error C3892 with MSVC on windows osquery Windows build fails with error C3892 Nov 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug build libraries For things referring to osquery third party libraries Windows
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants