Upgrade objectstore protoc version.
The current version of protobuf and protoc we are using is quite old (2015: https://github.com/protocolbuffers/protobuf/releases/tag/v2.5.0). I was trying to add a map to the retrieve queue schema for https://gitlab.cern.ch/cta/CTA/-/issues/1095 but the generated code doesn't compile with gcc8:
In file included from /usr/include/protobuf3/google/protobuf/map_field.h:40,
from /usr/include/protobuf3/google/protobuf/map_field_inl.h:40,
from /home/cta/CTA-build/objectstore/cta.pb.h:32,
from /home/cta/CTA-build/objectstore/cta.pb.cc:5:
/usr/include/protobuf3/google/protobuf/map_entry.h: In instantiation of ‘static const google::protobuf::Reflection* google::protobuf::internal::MapEntry<Derived, Key, Value, kKeyFieldType, kValueFieldType, default_enum_value>::CreateReflection(const google::protobuf::Descriptor*, const Derived*) [with Derived = cta::objectstore::serializers::RetrieveQueue::RetrieveQueue_DisksystemjobcounterEntry; Key = std::basic_string<char>; Value = long unsigned int; google::protobuf::internal::WireFormatLite::FieldType kKeyFieldType = (google::protobuf::internal::WireFormatLite::FieldType)9; google::protobuf::internal::WireFormatLite::FieldType kValueFieldType = (google::protobuf::internal::WireFormatLite::FieldType)4; int default_enum_value = 0]’:
/home/cta/CTA-build/objectstore/cta.pb.cc:1280:94: required from here
/usr/include/protobuf3/google/protobuf/map_entry.h:96:22: error: narrowing conversion of ‘(google::protobuf::uint32)((((const char*)(&((const google::protobuf::internal::MapEntry<cta::objectstore::serializers::RetrieveQueue::RetrieveQueue_DisksystemjobcounterEntry, std::basic_string<char>, long unsigned int, (google::protobuf::internal::WireFormatLite::FieldType)9, (google::protobuf::internal::WireFormatLite::FieldType)4, 0>*)16)->google::protobuf::internal::MapEntry<cta::objectstore::serializers::RetrieveQueue::RetrieveQueue_DisksystemjobcounterEntry, std::basic_string<char>, long unsigned int, (google::protobuf::internal::WireFormatLite::FieldType)9, (google::protobuf::internal::WireFormatLite::FieldType)4, 0>::<anonymous>.google::protobuf::internal::MapEntryImpl<cta::objectstore::serializers::RetrieveQueue::RetrieveQueue_DisksystemjobcounterEntry, google::protobuf::Message, std::basic_string<char>, long unsigned int, (google::protobuf::internal::WireFormatLite::FieldType)9, (google::protobuf::internal::WireFormatLite::FieldType)4, 0>::_has_bits_)) - ((const char*)16)) <unknown operator> 1)’ from ‘google::protobuf::uint32’ {aka ‘unsigned int’} to ‘int’ inside { } [-Werror=narrowing]
ReflectionSchema schema = {
^~~~~~
/usr/include/protobuf3/google/protobuf/map_entry.h:96:22: note: the expression has a constant value but is not a C++ constant-expression
/usr/include/protobuf3/google/protobuf/map_entry.h:96:22: error: narrowing conversion of ‘(google::protobuf::uint32)((((const char*)(&((const google::protobuf::internal::MapEntry<cta::objectstore::serializers::RetrieveQueue::RetrieveQueue_DisksystemjobcounterEntry, std::basic_string<char>, long unsigned int, (google::protobuf::internal::WireFormatLite::FieldType)9, (google::protobuf::internal::WireFormatLite::FieldType)4, 0>*)16)->google::protobuf::internal::MapEntry<cta::objectstore::serializers::RetrieveQueue::RetrieveQueue_DisksystemjobcounterEntry, std::basic_string<char>, long unsigned int, (google::protobuf::internal::WireFormatLite::FieldType)9, (google::protobuf::internal::WireFormatLite::FieldType)4, 0>::_internal_metadata_)) - ((const char*)16)) <unknown operator> 1)’ from ‘google::protobuf::uint32’ {aka ‘unsigned int’} to ‘int’ inside { } [-Werror=narrowing]
/usr/include/protobuf3/google/protobuf/map_entry.h:96:22: note: the expression has a constant value but is not a C++ constant-expression
/usr/include/protobuf3/google/protobuf/map_entry.h:96:22: error: missing initializer for member ‘google::protobuf::internal::ReflectionSchema::weak_field_map_offset_’ [-Werror=missing-field-initializers]
In file included from /usr/include/protobuf3/google/protobuf/map_entry.h:35,
from /usr/include/protobuf3/google/protobuf/map_field.h:40,
from /usr/include/protobuf3/google/protobuf/map_field_inl.h:40,
from /home/cta/CTA-build/objectstore/cta.pb.h:32,
from /home/cta/CTA-build/objectstore/cta.pb.cc:5:
/usr/include/protobuf3/google/protobuf/map_entry_lite.h: In member function ‘bool google::protobuf::internal::MapEntryImpl<Derived, Base, Key, Value, kKeyFieldType, kValueFieldType, default_enum_value>::MergePartialFromCodedStream(google::protobuf::io::CodedInputStream*) [with Derived = cta::objectstore::serializers::RetrieveQueue::RetrieveQueue_DisksystemjobcounterEntry; Base = google::protobuf::Message; Key = std::basic_string<char>; Value = long unsigned int; google::protobuf::internal::WireFormatLite::FieldType kKeyFieldType = (google::protobuf::internal::WireFormatLite::FieldType)9; google::protobuf::internal::WireFormatLite::FieldType kValueFieldType = (google::protobuf::internal::WireFormatLite::FieldType)4; int default_enum_value = 0]’:
/usr/include/protobuf3/google/protobuf/map_entry_lite.h:204:11: error: this statement may fall through [-Werror=implicit-fallthrough=]
if (!input->ExpectTag(kValueTag)) break;
^~
/usr/include/protobuf3/google/protobuf/map_entry_lite.h:207:9: note: here
case kValueTag:
^~~~
[ 49%] Building CXX object tapeserver/castor/tape/tapeserver/daemon/CMakeFiles/ctatapeserverdaemonunittests.dir/DiskWriteThreadPoolTest.cpp.o
cc1plus: all warnings being treated as errors
The problem was fixed in this commit (thanks @jcamarer): https://github.com/protocolbuffers/protobuf/issues/3700
We should consider updating the protoc compiler. Maybe there is a newer version in the software collections (centos 7 only has 2.5.0). Maybe we could even consider moving to proto3, but that seems like a more drastic change, so we should avoid it if we can.
For now I can work around this issue by using a repeated field instead of a map, so I will do that.