smanders / externpro

build external projects with cmake
MIT License
13 stars 12 forks source link

update protobuf #353

Closed smanders closed 2 years ago

smanders commented 2 years ago

externpro currently builds protobuf 3.13.0 (issue https://github.com/smanders/externpro/issues/75 pull https://github.com/smanders/externpro/pull/285)

as part of the effort to support compiling with gcc9 there is a -Werror=array-bounds compiler warning https://isrhub.usurf.usu.edu/palam/palam/issues/237 which protobuf developers made a fix for (in version 3.14.0) protobuf issue https://github.com/protocolbuffers/protobuf/issues/7140 protobuf commit https://github.com/protocolbuffers/protobuf/commit/d16bf914bc5ba569d2b70376051d15f68ce4322d

smanders commented 2 years ago

current protobuf patch https://github.com/protocolbuffers/protobuf/compare/v3.13.0...smanders:protobuf:xp3.13.0

smanders commented 2 years ago

maybe a good time to see if this issue is still an issue? https://github.com/smanders/externpro/issues/12

smanders commented 2 years ago

there's probably a story behind the recent tagging scheme for protobuf, but it appears that the v21.2 tag points to the same hash as the v3.21.2 tag https://github.com/protocolbuffers/protobuf/tags

smanders commented 2 years ago

compile errors that seem likely to be related to the protobuf update

[ 57%] Building CXX object mb/CMakeFiles/mb.dir/aux_/routing/routeMessage.cpp.o
/bpvol/palamdev/mb/aux_/routing/routeMessage.cpp: In lambda function:
/bpvol/palamdev/mb/aux_/routing/routeMessage.cpp:76:22: error: ignoring return value of 'std::string* aux_palam::mb::pb::RouterToWatcher::Message::release_from()', declared with attribute warn_unused_result [-Werror=unused-result]
       pb.release_from();
       ~~~~~~~~~~~~~~~^~
/bpvol/palamdev/mb/aux_/routing/routeMessage.cpp:77:30: error: ignoring return value of 'aux_palam::mb::pb::To* aux_palam::mb::pb::RouterToWatcher::Message::release_addressed_to()', declared with attribute warn_unused_result [-Werror=unused-result]
       pb.release_addressed_to();
       ~~~~~~~~~~~~~~~~~~~~~~~^~
/bpvol/palamdev/mb/aux_/routing/routeMessage.cpp:78:22: error: ignoring return value of 'aux_palam::mb::pb::MessageBodyType* aux_palam::mb::pb::RouterToWatcher::Message::release_type()', declared with attribute warn_unused_result [-Werror=unused-result]
       pb.release_type();
       ~~~~~~~~~~~~~~~^~
/bpvol/palamdev/mb/aux_/routing/routeMessage.cpp:81:30: error: ignoring return value of 'std::string* aux_palam::mb::pb::RouterToWatcher::DecoratedBody::release_body()', declared with attribute warn_unused_result [-Werror=unused-result]
         rOrdBody.release_body();
         ~~~~~~~~~~~~~~~~~~~~~^~
/bpvol/palamdev/mb/aux_/routing/routeMessage.cpp: In lambda function:
/bpvol/palamdev/mb/aux_/routing/routeMessage.cpp:46:22: error: ignoring return value of 'std::string* aux_palam::mb::pb::RouterToClient::Message::release_from()', declared with attribute warn_unused_result [-Werror=unused-result]
       pb.release_from();
       ~~~~~~~~~~~~~~~^~
/bpvol/palamdev/mb/aux_/routing/routeMessage.cpp:47:22: error: ignoring return value of 'aux_palam::mb::pb::MessageBodyType* aux_palam::mb::pb::RouterToClient::Message::release_type()', declared with attribute warn_unused_result [-Werror=unused-result]
       pb.release_type();
       ~~~~~~~~~~~~~~~^~
cc1plus: all warnings being treated as errors
make[2]: *** [mb/CMakeFiles/mb.dir/aux_/routing/routeMessage.cpp.o] Error 1
make[1]: *** [mb/CMakeFiles/mb.dir/all] Error 2
make: *** [all] Error 2

after discussing these with the developer, we are fairly confident this would be one of the only areas of code that gets hit with this and the "fix" will be to turn off the warning in these areas of code

diff --git a/aux_/routing/routeMessage.cpp b/aux_/routing/routeMessage.cpp
index 0ab0945..488af22 100644
--- a/aux_/routing/routeMessage.cpp
+++ b/aux_/routing/routeMessage.cpp
@@ -40,6 +40,10 @@ namespace
     std::vector<std::string> const& bodies)
   {
     pb::RouterToClient::Message pb;
+#if defined(__GNUC__) || defined(__clang__)
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-result"
+#endif
     // make sure the pointers will be released; the caller is reponsible
     // for them:
     ScopeExit se([&pb] {
@@ -47,6 +51,9 @@ namespace
       pb.release_type();
       forgetPbStrings(*(pb.mutable_messages()));
     });
+#if defined(__GNUC__) || defined(__clang__)
+#pragma GCC diagnostic pop
+#endif
     pb.set_allocated_from(const_cast<std::string*>(pFrom));
     pb.set_allocated_type(const_cast<pb::MessageBodyType*>(pMsgType));
     { // bodies
@@ -70,6 +77,10 @@ namespace
     routing::OrdinaledMessageBodies const& ordinaledMsgs)
   {
     pb::RouterToWatcher::Message pb;
+#if defined(__GNUC__) || defined(__clang__)
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-result"
+#endif
     // make sure the pointers will be released; the caller is reponsible
     // for them:
     ScopeExit se([&pb] {
@@ -81,6 +92,9 @@ namespace
         rOrdBody.release_body();
       }
     });
+#if defined(__GNUC__) || defined(__clang__)
+#pragma GCC diagnostic pop
+#endif
     pb.set_allocated_from(const_cast<std::string*>(pFrom));
     pb.set_allocated_addressed_to(const_cast<pb::To*>(pAddressedTo));
     { // shipped_to

except that I am seeing it in multiple other places

CommonLibraries/Store_MissionPlan_v1

[ 16%] Building CXX object Store_MissionPlan_v1/CMakeFiles/Store_MissionPlan_v1.dir/src/MissionPlanAnnouncement.cpp.o
/bpvol/CommonLibraries/Store_MissionPlan_v1/src/MissionPlanAnnouncement.cpp: In member function 'std::vector<unsigned char> store_missionplan_v1::MissionPlanAnnouncement::getSerializedBytes() const':
/bpvol/CommonLibraries/Store_MissionPlan_v1/src/MissionPlanAnnouncement.cpp:45:29: error: ignoring return value of 'store_missionplan_v1_proto::PlanInfo* store_missionplan_v1_proto::MissionPlanAnnouncement::release_info()', declared with attribute warn_unused_result [-Werror=unused-result]
     announceMsg.release_info();
     ~~~~~~~~~~~~~~~~~~~~~~~~^~
cc1plus: all warnings being treated as errors
make[2]: *** [Store_MissionPlan_v1/CMakeFiles/Store_MissionPlan_v1.dir/src/MissionPlanAnnouncement.cpp.o] Error 1
make[2]: Target `Store_MissionPlan_v1/CMakeFiles/Store_MissionPlan_v1.dir/build' not remade because of errors.
make[1]: *** [Store_MissionPlan_v1/CMakeFiles/Store_MissionPlan_v1.dir/all] Error 2

CommonLibraries/vantComm

[ 25%] Building CXX object vantComm/CMakeFiles/vantComm.dir/src/private/broker_stream/OutboundProducer.cpp.o
In file included from /bpvol/CommonLibraries/vantComm/src/private/broker_stream/OutboundProducer.cpp:12:0:
/bpvol/CommonLibraries/vantComm/src/private/broker_stream/OutboundProducer.cpp: In lambda function:
/bpvol/CommonLibraries/vantComm/src/private/broker_stream/OutboundProducer.cpp:105:31: error: ignoring return value of 'vantComm::pb::BrokerToService::ClientChannelMsg* vantComm::pb::BrokerToService::ChannelMsg::release_client_msg()', declared with attribute warn_unused_result [-Werror=unused-result]
     chanMsg.release_client_msg();
     ~~~~~~~~~~~~~~~~~~~~~~~~~~^~
/bpvol/CommonLibraries/vantComm/src/private/broker_stream/OutboundProducer.cpp:106:37: error: ignoring return value of 'vantComm::pb::BrokerToService::RoutedMsg* vantComm::pb::BrokerToService::ClientChannelMsg::release_routed_msg()', declared with attribute warn_unused_result [-Werror=unused-result]
     clientChanMsg.release_routed_msg();
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
/bpvol/CommonLibraries/vantComm/src/private/broker_stream/OutboundProducer.cpp: In lambda function:
/bpvol/CommonLibraries/vantComm/src/private/broker_stream/OutboundProducer.cpp:133:32: error: ignoring return value of 'vantComm::pb::BrokerToService::WatcherChannelMsg* vantComm::pb::BrokerToService::ChannelMsg::release_watcher_msg()', declared with attribute warn_unused_result [-Werror=unused-result]
     chanMsg.release_watcher_msg();
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
/bpvol/CommonLibraries/vantComm/src/private/broker_stream/OutboundProducer.cpp:134:39: error: ignoring return value of 'vantComm::pb::BrokerToService::WatchedMsg* vantComm::pb::BrokerToService::WatcherChannelMsg::release_watched_msg()', declared with attribute warn_unused_result [-Werror=unused-result]
     watcherChanMsg.release_watched_msg();
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
/bpvol/CommonLibraries/vantComm/src/private/broker_stream/OutboundProducer.cpp: In lambda function:
/bpvol/CommonLibraries/vantComm/src/private/broker_stream/OutboundProducer.cpp:164:32: error: ignoring return value of 'vantComm::pb::BrokerToService::MonitorChannelMsg* vantComm::pb::BrokerToService::ChannelMsg::release_monitor_msg()', declared with attribute warn_unused_result [-Werror=unused-result]
     chanMsg.release_monitor_msg();
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
/bpvol/CommonLibraries/vantComm/src/private/broker_stream/OutboundProducer.cpp:165:51: error: ignoring return value of 'vantComm::pb::BrokerToService::ClientDisconnectNotification* vantComm::pb::BrokerToService::MonitorChannelMsg::release_client_disconnect_notification()', declared with attribute warn_unused_result [-Werror=unused-result]
     mntrMsg.release_client_disconnect_notification();
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
/bpvol/CommonLibraries/vantComm/src/private/broker_stream/OutboundProducer.cpp: In lambda function:
/bpvol/CommonLibraries/vantComm/src/private/broker_stream/OutboundProducer.cpp:191:32: error: ignoring return value of 'vantComm::pb::BrokerToService::MonitorChannelMsg* vantComm::pb::BrokerToService::ChannelMsg::release_monitor_msg()', declared with attribute warn_unused_result [-Werror=unused-result]
     chanMsg.release_monitor_msg();
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
/bpvol/CommonLibraries/vantComm/src/private/broker_stream/OutboundProducer.cpp:192:35: error: ignoring return value of 'vantComm::pb::BrokerToService::WhoisResponse* vantComm::pb::BrokerToService::MonitorChannelMsg::release_whois_response()', declared with attribute warn_unused_result [-Werror=unused-result]
     mntrMsg.release_whois_response();
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
/bpvol/CommonLibraries/vantComm/src/private/broker_stream/OutboundProducer.cpp: In lambda function:
/bpvol/CommonLibraries/vantComm/src/private/broker_stream/OutboundProducer.cpp:220:32: error: ignoring return value of 'vantComm::pb::BrokerToService::MonitorChannelMsg* vantComm::pb::BrokerToService::ChannelMsg::release_monitor_msg()', declared with attribute warn_unused_result [-Werror=unused-result]
     chanMsg.release_monitor_msg();
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
/bpvol/CommonLibraries/vantComm/src/private/broker_stream/OutboundProducer.cpp:221:56: error: ignoring return value of 'vantComm::pb::BrokerToService::GetClientAssociatedTagsResponse* vantComm::pb::BrokerToService::MonitorChannelMsg::release_get_client_associated_tags_response()', declared with attribute warn_unused_result [-Werror=unused-result]
     mntrMsg.release_get_client_associated_tags_response();
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
/bpvol/CommonLibraries/vantComm/src/private/broker_stream/OutboundProducer.cpp: In lambda function:
/bpvol/CommonLibraries/vantComm/src/private/broker_stream/OutboundProducer.cpp:250:32: error: ignoring return value of 'vantComm::pb::BrokerToService::MonitorChannelMsg* vantComm::pb::BrokerToService::ChannelMsg::release_monitor_msg()', declared with attribute warn_unused_result [-Werror=unused-result]
     chanMsg.release_monitor_msg();
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
/bpvol/CommonLibraries/vantComm/src/private/broker_stream/OutboundProducer.cpp:251:59: error: ignoring return value of 'vantComm::pb::BrokerToService::GetClientBadDatagramCountResponse* vantComm::pb::BrokerToService::MonitorChannelMsg::release_get_client_bad_datagram_count_response()', declared with
attribute warn_unused_result [-Werror=unused-result]
     mntrMsg.release_get_client_bad_datagram_count_response();
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
/bpvol/CommonLibraries/vantComm/src/private/broker_stream/OutboundProducer.cpp: In lambda function:
/bpvol/CommonLibraries/vantComm/src/private/broker_stream/OutboundProducer.cpp:279:32: error: ignoring return value of 'vantComm::pb::BrokerToService::MonitorChannelMsg* vantComm::pb::BrokerToService::ChannelMsg::release_monitor_msg()', declared with attribute warn_unused_result [-Werror=unused-result]
     chanMsg.release_monitor_msg();
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
/bpvol/CommonLibraries/vantComm/src/private/broker_stream/OutboundProducer.cpp:280:54: error: ignoring return value of 'vantComm::pb::BrokerToService::GetClientMessageStatsResponse* vantComm::pb::BrokerToService::MonitorChannelMsg::release_get_client_message_stats_response()', declared with attribute warn_unused_result [-Werror=unused-result]
     mntrMsg.release_get_client_message_stats_response();
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
/bpvol/CommonLibraries/vantComm/src/private/broker_stream/OutboundProducer.cpp: In lambda function:
/bpvol/CommonLibraries/vantComm/src/private/broker_stream/OutboundProducer.cpp:308:32: error: ignoring return value of 'vantComm::pb::BrokerToService::MonitorChannelMsg* vantComm::pb::BrokerToService::ChannelMsg::release_monitor_msg()', declared with attribute warn_unused_result [-Werror=unused-result]
     chanMsg.release_monitor_msg();
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
/bpvol/CommonLibraries/vantComm/src/private/broker_stream/OutboundProducer.cpp:309:49: error: ignoring return value of 'vantComm::pb::BrokerToService::GetCurrentClientsResponse* vantComm::pb::BrokerToService::MonitorChannelMsg::release_get_current_clients_response()', declared with attribute warn_unused_result [-Werror=unused-result]
     mntrMsg.release_get_current_clients_response();
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
cc1plus: all warnings being treated as errors
make[2]: *** [vantComm/CMakeFiles/vantComm.dir/src/private/broker_stream/OutboundProducer.cpp.o] Error 1
make[2]: Target `vantComm/CMakeFiles/vantComm.dir/build' not remade because of errors.
make[1]: *** [vantComm/CMakeFiles/vantComm.dir/all] Error 2
smanders commented 2 years ago

completed with commits referenced above

smanders commented 2 years ago

3.21.5 patch https://github.com/protocolbuffers/protobuf/compare/v3.21.5...smanders:protobuf:xp3.21.5 at some point between 3.14.0 and 3.21.5 a root CMakeLists.txt file is introduced -- so this commit may be useful as we go forward in versions -- although there are also some new gcc compiler warnings to deal with