Skip to content

Unable to build v29.3 with clang-cl #19975

@Neumann-A

Description

@Neumann-A

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

What operating system (Linux, Windows, ...) and version?
Windows 11

What runtime / compiler are you using (e.g., python version or gcc version)
clang-cl 19.1.6

What did you do?
Setup toolchain with clang-cl
Build protobuf (via vcpkg)

What did you expect to see
Successful build

What did you see instead?

[10/243] D:\vcpkg_folders\no_msvc\installed\x64-win-llvm\compiler-llvm\bin\clang-cl.exe   -TP -DABSL_CONSUME_DLL -DGOOGLE_PROTOBUF_CMAKE_BUILD -DLIBPROTOBUF_EXPORTS -DPROTOBUF_USE_DLLS -Dlibprotobuf_EXPORTS -ID:\vcpkg_folders\no_msvc\buildtrees\protobuf\x64-win-llvm-dbg -ID:\vcpkg_folders\no_msvc\buildtrees\protobuf\src\v5.29.3-a9486c2d3e.clean -ID:\vcpkg_folders\no_msvc\buildtrees\protobuf\x64-win-llvm-dbg\src -ID:\vcpkg_folders\no_msvc\buildtrees\protobuf\src\v5.29.3-a9486c2d3e.clean\src -imsvcD:\vcpkg_folders\no_msvc\installed\x64-win-llvm\VS\VC\Tools\MSVC\14.42.34433\include -imsvcD:\vcpkg_folders\no_msvc\installed\x64-win-llvm\VS\VC\Tools\MSVC\14.42.34433\ATLMFC\include -imsvcD:\vcpkg_folders\no_msvc\installed\x64-win-llvm\VS\VC\Auxiliary\VS\include -imsvc"D:\vcpkg_folders\no_msvc\installed\x64-win-llvm\WinSDK\Windows Kits\10\include\10.0.26100.0\ucrt" -imsvc"D:\vcpkg_folders\no_msvc\installed\x64-win-llvm\WinSDK\Windows Kits\10\include\10.0.26100.0\um" -imsvc"D:\vcpkg_folders\no_msvc\installed\x64-win-llvm\WinSDK\Windows Kits\10\include\10.0.26100.0\shared" -imsvc"D:\vcpkg_folders\no_msvc\installed\x64-win-llvm\WinSDK\Windows Kits\10\include\10.0.26100.0\winrt" -imsvc"D:\vcpkg_folders\no_msvc\installed\x64-win-llvm\WinSDK\Windows Kits\10\include\10.0.26100.0\cppwinrt" -imsvc"D:\vcpkg_folders\no_msvc\installed\x64-win-llvm\WinSDK\Windows Kits\NETFXSDK\4.8.1\include\um" -imsvcD:\vcpkg_folders\no_msvc\installed\x64-win-llvm\include /nologo /DWIN32 /D_WINDOWS -Wno-implicit-function-declaration /utf-8 -msse4.2 -m64 /GR /EHsc  /D_DEBUG /MDd /Z7 /Ob0 /Od /RTC1  -MDd /MP /utf-8 /wd4065 /wd4146 /wd4244 /wd4251 /wd4267 /wd4305 /wd4307 /wd4309 /wd4334 /wd4355 /wd4506 /wd4800 /wd4996 /bigobj /showIncludes /FoCMakeFiles\libprotobuf.dir\src\google\protobuf\dynamic_message.cc.obj /FdCMakeFiles\libprotobuf.dir\ -c -- D:\vcpkg_folders\no_msvc\buildtrees\protobuf\src\v5.29.3-a9486c2d3e.clean\src\google\protobuf\dynamic_message.cc
FAILED: CMakeFiles/libprotobuf.dir/src/google/protobuf/dynamic_message.cc.obj 
D:\vcpkg_folders\no_msvc\installed\x64-win-llvm\compiler-llvm\bin\clang-cl.exe   -TP -DABSL_CONSUME_DLL -DGOOGLE_PROTOBUF_CMAKE_BUILD -DLIBPROTOBUF_EXPORTS -DPROTOBUF_USE_DLLS -Dlibprotobuf_EXPORTS -ID:\vcpkg_folders\no_msvc\buildtrees\protobuf\x64-win-llvm-dbg -ID:\vcpkg_folders\no_msvc\buildtrees\protobuf\src\v5.29.3-a9486c2d3e.clean -ID:\vcpkg_folders\no_msvc\buildtrees\protobuf\x64-win-llvm-dbg\src -ID:\vcpkg_folders\no_msvc\buildtrees\protobuf\src\v5.29.3-a9486c2d3e.clean\src -imsvcD:\vcpkg_folders\no_msvc\installed\x64-win-llvm\VS\VC\Tools\MSVC\14.42.34433\include -imsvcD:\vcpkg_folders\no_msvc\installed\x64-win-llvm\VS\VC\Tools\MSVC\14.42.34433\ATLMFC\include -imsvcD:\vcpkg_folders\no_msvc\installed\x64-win-llvm\VS\VC\Auxiliary\VS\include -imsvc"D:\vcpkg_folders\no_msvc\installed\x64-win-llvm\WinSDK\Windows Kits\10\include\10.0.26100.0\ucrt" -imsvc"D:\vcpkg_folders\no_msvc\installed\x64-win-llvm\WinSDK\Windows Kits\10\include\10.0.26100.0\um" -imsvc"D:\vcpkg_folders\no_msvc\installed\x64-win-llvm\WinSDK\Windows Kits\10\include\10.0.26100.0\shared" -imsvc"D:\vcpkg_folders\no_msvc\installed\x64-win-llvm\WinSDK\Windows Kits\10\include\10.0.26100.0\winrt" -imsvc"D:\vcpkg_folders\no_msvc\installed\x64-win-llvm\WinSDK\Windows Kits\10\include\10.0.26100.0\cppwinrt" -imsvc"D:\vcpkg_folders\no_msvc\installed\x64-win-llvm\WinSDK\Windows Kits\NETFXSDK\4.8.1\include\um" -imsvcD:\vcpkg_folders\no_msvc\installed\x64-win-llvm\include /nologo /DWIN32 /D_WINDOWS -Wno-implicit-function-declaration /utf-8 -msse4.2 -m64 /GR /EHsc  /D_DEBUG /MDd /Z7 /Ob0 /Od /RTC1  -MDd /MP /utf-8 /wd4065 /wd4146 /wd4244 /wd4251 /wd4267 /wd4305 /wd4307 /wd4309 /wd4334 /wd4355 /wd4506 /wd4800 /wd4996 /bigobj /showIncludes /FoCMakeFiles\libprotobuf.dir\src\google\protobuf\dynamic_message.cc.obj /FdCMakeFiles\libprotobuf.dir\ -c -- D:\vcpkg_folders\no_msvc\buildtrees\protobuf\src\v5.29.3-a9486c2d3e.clean\src\google\protobuf\dynamic_message.cc
clang-cl: warning: argument unused during compilation: '/MP' [-Wunused-command-line-argument]
In file included from D:\vcpkg_folders\no_msvc\buildtrees\protobuf\src\v5.29.3-a9486c2d3e.clean\src\google\protobuf\dynamic_message.cc:42:
In file included from D:\vcpkg_folders\no_msvc\buildtrees\protobuf\src\v5.29.3-a9486c2d3e.clean\src\google/protobuf/dynamic_message.h:28:
In file included from D:\vcpkg_folders\no_msvc\buildtrees\protobuf\src\v5.29.3-a9486c2d3e.clean\src\google/protobuf/message.h:110:
D:\vcpkg_folders\no_msvc\buildtrees\protobuf\src\v5.29.3-a9486c2d3e.clean\src\google/protobuf/map.h(1324,50): error: invalid application of 'alignof' to an incomplete type 'mapped_type' (aka 'google::protobuf::MapValueRef')
 1324 |     static_assert(alignof(internal::NodeBase) >= alignof(mapped_type),
      |                                                  ^~~~~~~~~~~~~~~~~~~~
D:\vcpkg_folders\no_msvc\buildtrees\protobuf\src\v5.29.3-a9486c2d3e.clean\src\google/protobuf/map.h(1262,37): note: in instantiation of member function 'google::protobuf::Map<google::protobuf::MapKey, google::protobuf::MapValueRef>::StaticValidityCheck' requested here
 1262 |   constexpr Map() : Base(nullptr) { StaticValidityCheck(); }
      |                                     ^
D:\vcpkg_folders\no_msvc\buildtrees\protobuf\src\v5.29.3-a9486c2d3e.clean\src\google/protobuf/map_field.h(566,31): note: in instantiation of member function 'google::protobuf::Map<google::protobuf::MapKey, google::protobuf::MapValueRef>::Map' requested here
  566 |       : MapFieldBase(vtable), map_() {
      |                               ^
D:\vcpkg_folders\no_msvc\buildtrees\protobuf\src\v5.29.3-a9486c2d3e.clean\src\google/protobuf/map_field.h(563,7): note: in instantiation of member function 'google::protobuf::internal::TypeDefinedMapFieldBase<google::protobuf::MapKey, google::protobuf::MapValueRef>::TypeDefinedMapFieldBase' requested here
  563 | class TypeDefinedMapFieldBase : public MapFieldBase {
      |       ^
D:\vcpkg_folders\no_msvc\buildtrees\protobuf\src\v5.29.3-a9486c2d3e.clean\src\google/protobuf/map_field.h(695,7): note: due to 'TypeDefinedMapFieldBase<google::protobuf::MapKey, google::protobuf::MapValueRef>' being dllexported
  695 | class PROTOBUF_EXPORT DynamicMapField final
      |       ^
D:\vcpkg_folders\no_msvc\buildtrees\protobuf\src\v5.29.3-a9486c2d3e.clean\src\google/protobuf/port_def.inc(326,38): note: expanded from macro 'PROTOBUF_EXPORT'
  326 | #  define PROTOBUF_EXPORT __declspec(dllexport)
      |                                      ^
D:\vcpkg_folders\no_msvc\buildtrees\protobuf\src\v5.29.3-a9486c2d3e.clean\src\google/protobuf/generated_message_reflection.h(40,7): note: forward declaration of 'google::protobuf::MapValueRef'
   40 | class MapValueRef;
      |       ^
1 error generated.

Anything else we should know about your project / environment
One solution:

  • remove PROTOBUF_EXPORT from DynamicMapField since it lives in internal namespace any way and should probably not exported

next error after that is:

D:\vcpkg_folders\no_msvc\buildtrees\protobuf\src\v5.29.3-a9486c2d3e\src\google\protobuf\compiler\java\java_features.pb.cc(208,65): error: variable does not have a constant initializer
  208 | const ::google::protobuf::internal::ClassDataFull JavaFeatures::_class_data_ = {
      |                                                                 ^              ~
  209 |     ::google::protobuf::internal::ClassData{
      |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  210 |         &_JavaFeatures_default_instance_._instance,
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  211 |         &_table_.header,
      |         ~~~~~~~~~~~~~~~~
  212 |         nullptr,  // OnDemandRegisterArenaDtor
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  213 |         nullptr,  // IsInitialized
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~
  214 |         &JavaFeatures::MergeImpl,
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~
  215 |         ::google::protobuf::Message::GetNewImpl<JavaFeatures>(),
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  216 | #if defined(PROTOBUF_CUSTOM_VTABLE)
      | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  217 |         &JavaFeatures::SharedDtor,
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~
  218 |         ::google::protobuf::Message::GetClearImpl<JavaFeatures>(), &JavaFeatures::ByteSizeLong,
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  219 |             &JavaFeatures::_InternalSerialize,
      |             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  220 | #endif  // PROTOBUF_CUSTOM_VTABLE
      | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  221 |         PROTOBUF_FIELD_OFFSET(JavaFeatures, _impl_._cached_size_),
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  222 |         false,
      |         ~~~~~~
  223 |     },
      |     ~~

Removing && !defined(__clang__) from

#if defined(_MSC_VER) && !defined(__clang__)

fixes the build

Metadata

Metadata

Assignees

Labels

inactiveDenotes the issue/PR has not seen activity in the last 90 days.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions