Skip to content

Commit

Permalink
Fix build issues with gcc 9 (#1090)
Browse files Browse the repository at this point in the history
* Remove redundant moves in return statements

With recent g++ versions:

../include/bm/bm_sim/queueing.h:780:24: error: redundant move in return statement [-Werror=redundant-move]
  780 |     return std::move(fn);
      |                        ^
../include/bm/bm_sim/queueing.h:780:24: note: remove 'std::move' call
cc1plus: all warnings being treated as error

While copy elision is not possible when retruning a function parameter,
if the other conditions for NVO are met, a move operation should be
used. The std::move doesn't cause the compiler to perform worse (unlike
for RVO), but it is redundant.

* Do not treat deprecated-declarations warnings as errors

When compiling code which depends on the generated Protobuf code for
P4Runtime.

* Fix linking for example program in simple_switch_grpc/tests

Linking was broken after Ubuntu 20.04 / gcc 9 upgrade.
Not sure exactly why but removing some unused library dependencies can
resolve the issue ("undefined reference" for PI symbols).
  • Loading branch information
antoninbas authored Feb 10, 2022
1 parent ed36d8b commit a341309
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
4 changes: 2 additions & 2 deletions include/bm/bm_sim/queueing.h
Original file line number Diff line number Diff line change
Expand Up @@ -777,15 +777,15 @@ class QueueingLogicPriRL {
Function for_each_q(size_t queue_id, Function fn) {
auto &q_info = get_queue(queue_id);
for (auto &q_info_pri : q_info) fn(q_info_pri);
return std::move(fn);
return fn;
}

template <typename Function>
Function for_one_q(size_t queue_id, size_t priority, Function fn) {
auto &q_info = get_queue(queue_id);
auto &q_info_pri = q_info.at(priority);
fn(q_info_pri);
return std::move(fn);
return fn;
}

struct SetCapacityFn {
Expand Down
10 changes: 9 additions & 1 deletion targets/simple_switch_grpc/tests/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ ACLOCAL_AMFLAGS = ${ACLOCAL_FLAGS} -I m4
# Ensures that gtest has been built
SUBDIRS = ../../../third_party

# for deprecated Protobuf fields
AM_CXXFLAGS += -Wno-error=deprecated-declarations

AM_CPPFLAGS += \
-isystem $(top_srcdir)/../../third_party/gtest/include \
-I$(top_srcdir) \
Expand Down Expand Up @@ -31,6 +34,7 @@ check_PROGRAMS = example test_gtest
common_source = utils.h utils.cpp base_test.h base_test.cpp

example_SOURCES = example.cpp utils.h utils.cpp

test_gtest_SOURCES = \
$(common_source) main.cpp \
test_basic.cpp test_grpc_dp.cpp test_packet_io.cpp \
Expand All @@ -45,7 +49,11 @@ if WITH_SYSREPO
test_gtest_SOURCES += test_gnmi.cpp
endif

LDADD = \
example_LDADD = \
-lpiprotogrpc -lpiprotobuf \
$(PROTOBUF_LIBS) $(GRPC_LIBS)

test_gtest_LDADD = \
$(top_builddir)/libsimple_switch_grpc.la \
$(top_builddir)/../simple_switch/libsimpleswitch.la \
-lpiprotogrpc -lpiprotobuf \
Expand Down

0 comments on commit a341309

Please sign in to comment.