protocolbuffers / protobuf

Protocol Buffers - Google's data interchange format
http://protobuf.dev
Other
65.87k stars 15.52k forks source link

Missing proper includes for WrappedMutex and Mutex #7873

Open advancedwebdeveloper opened 4 years ago

advancedwebdeveloper commented 4 years ago

Hi. I was trying to build ONNX using https://github.com/onnx/onnx#windows instructions.

https://groups.google.com/g/protobuf/c/GLFWU3ZkvOM - reported about that already.

What version of protobuf and what language are you using? Version: 3.9.x Language: C++

What operating system (Linux, Windows, ...) and version? Windows 10 32bit - but will try on Windows 10 x86_64.

What runtime / compiler are you using (e.g., python version or gcc version) Clang 11.0.0 RC1 - and expecting similar bugs with Clang 11.0.0 RC2.

What did you do? Steps to reproduce the behavior:

  1. Building protobuf: cd C:\Users\clang git clone https://github.com/protocolbuffers/protobuf.git cd protobuf git checkout 3.9.x cd cmake cmake -G Ninja -Dprotobuf_MSVC_STATIC_RUNTIME=OFF -Dprotobuf_BUILD_TESTS=OFF -Dprotobuf_BUILD_EXAMPLES=OFF -DCMAKE_INSTALL_PREFIX=C:\Users\clang\protobuf4clang . ninja install
  2. Building ONNX: cd .. git clone https://github.com/onnx/onnx.git cd onnx git submodule update --init --recursive set PATH=C:\Users\clang\protobuf4clang\bin;%PATH% set USE_MSVC_STATIC_RUNTIME=0 set ONNX_ML=1 mkdir build cd build cmake -G Ninja .. ninja

And then my compilation crashes.

What did you expect to see Some warnings - and all Ninja's targets built.

What did you see instead?

[2/57] Building CXX object CMakeFiles\onnx_proto.dir\onnx\onnx-operators-ml.pb.cc.obj FAILED: CMakeFiles/onnx_proto.dir/onnx/onnx-operators-ml.pb.cc.obj C:\PROGRA~1\LLVM\bin\clang-cl.exe /nologo -TP -DONNX_API="" -DONNX_ML=1 -DONNX_NAMESPACE=onnx -DPROTOBUF_USE_DLLS -I. -IC:\Users\clang\protobuf_llvm\include /DWIN32 /D_WINDOWS /W3 /GR /EHsc /MD /O2 /Ob2 /DNDEBUG /MP /WX /wd4800 /wd4503 /wd4146 /wd4244 /wd4267 -Wno-implicit-function-declaration -Wno-undefined-inline -Wno-incompatible-pointer-types -Wno-dllexport-explicit-instantiation-decl -Wno-microsoft-unqualified-friend -Wno-absolute-value -Wno-unused-variable -Wno-unknown-argument -Wno-writable-strings -Qunused-arguments /MD /showIncludes /FoCMakeFiles\onnx_proto.dir\onnx\onnx-operators-ml.pb.cc.obj /FdCMakeFiles\onnx_proto.dir\onnx_proto.pdb -c onnx\onnx-operators-ml.pb.cc In file included from onnx\onnx-operators-ml.pb.cc:4: In file included from .\onnx/onnx-operators-ml.pb.h:30: In file included from C:\Users\clang\protobuf_llvm\include\google/protobuf/generated_message_reflection.h:47: In file included from C:\Users\clang\protobuf_llvm\include\google/protobuf/descriptor.h:62: C:\Users\clang\protobuf_llvm\include\google/protobuf/stubs/mutex.h(96,1): error: declaration of anonymous class must be a definition class PROTOBUF_EXPORT GOOGLE_PROTOBUF_CAPABILITY("mutex") WrappedMutex { ^ C:\Users\clang\protobuf_llvm\include\google/protobuf/stubs/mutex.h(96,1): error: declaration does not declare anything [-Werror,-Wmissing-declarations] C:\Users\clang\protobufllvm\include\google/protobuf/stubs/mutex.h(113,15): error: unknown type name 'WrappedMutex' using Mutex = WrappedMutex; ^ C:\Users\clang\protobufllvm\include\google/protobuf/stubs/mutex.h(118,22): error: unknown type name 'Mutex' explicit MutexLock(Mutex *mu) : mu(mu) { this->mu->Lock(); } ^ C:\Users\clang\protobufllvm\include\google/protobuf/stubs/mutex.h(121,3): error: unknown type name 'Mutex' Mutex const mu; ^ C:\Users\clang\protobuf_llvm\include\google/protobuf/stubs/mutex.h(132,27): error: unknown type name 'Mutex' explicit MutexLockMaybe(Mutex mu) : ^ C:\Users\clang\protobufllvm\include\google/protobuf/stubs/mutex.h(136,3): error: unknown type name 'Mutex' Mutex const mu; ^ C:\Users\clang\protobuf_llvm\include\google/protobuf/stubs/mutex.h(172,17): error: no member named 'Mutex' in namespace 'google::protobuf::internal' using internal::Mutex; ~~^ In file included from onnx\onnx-operators-ml.pb.cc:4: In file included from .\onnx/onnx-operators-ml.pb.h:30: In file included from C:\Users\clang\protobuf_llvm\include\google/protobuf/generated_message_reflection.h:47: C:\Users\clang\protobufllvm\include\google/protobuf/descriptor.h(1848,13): error: no type named 'WrappedMutex' in namespace 'google::protobuf::internal' internal::WrappedMutex mutex; ~~^ 9 errors generated. ninja: build stopped: subcommand failed.

It seems to be related to https://github.com/onnx/onnx/tree/2896c77cfc628f18b6ca6b28e3a380807fa00f53/onnx

Make sure you include information that can help us debug (full error message, exception listing, stack trace, logs).

onnx4clang.zip

I am attaching my compressed build folder, for ONNX (onnx4clang.zip) and compressed post-install folder of protobuf (protobuf_llvm.zip).

protobuf_llvm.zip

Anything else we should know about your project / environment

advancedwebdeveloper commented 4 years ago

generated_files.zip

Generated onnx-operators-ml.pb.cc and onnx-operators-ml.pb.h where archived into generate_files.zip.

Looks like there is some support for MSVC, using Windows 10 SDK - but I am interesting in libc++ support of Mutex . So this bug is about the second option only.

Ivan

advancedwebdeveloper commented 4 years ago

@kentov , please share some hints

kentonv commented 4 years ago

@advancedwebdeveloper Sorry, I haven't worked on Protobuf in nearly a decade.

deannagarcia commented 2 years ago

Sorry for the long delay. Are you still seeing this error in newer versions of protobuf?