The GCC 7 series introduces changes that expose ODP compilation issues. These include case statement fall through warnings, and stricter checks on potential string overflows and other semantic analysis.
Fixes: https://bugs.linaro.org/show_bug.cgi?id=3027 Signed-off-by: Brian Brooks <[email protected]> Reviewed-by: Ola Liljedahl <[email protected]> Reviewed-by: Honnappa Nagarahalli <[email protected]> --- DEPENDENCIES | 5 ++-- configure.ac | 13 ++++++++++ pkgconfig/libodp-linux.pc.in | 2 +- platform/linux-generic/Makefile.am | 2 ++ platform/linux-generic/m4/configure.m4 | 45 ++++++++++++++++++++++++++++++++++ 5 files changed, 64 insertions(+), 3 deletions(-) diff --git a/DEPENDENCIES b/DEPENDENCIES index a194cad1..7bcbd5eb 100644 --- a/DEPENDENCIES +++ b/DEPENDENCIES @@ -8,13 +8,14 @@ Prerequisites for building the OpenDataPlane (ODP) API automake autoconf + autoconf-archive libtool On Debian/Ubuntu systems: - $ sudo apt-get install automake autoconf libtool + $ sudo apt-get install automake autoconf autoconf-archive libtool On CentOS/RedHat/Fedora systems: - $ sudo yum install automake autoconf libtool + $ sudo yum install automake autoconf autoconf-archive libtool 3. Required libraries diff --git a/configure.ac b/configure.ac index 7569ebe0..6351878a 100644 --- a/configure.ac +++ b/configure.ac @@ -300,6 +300,19 @@ ODP_CFLAGS="$ODP_CFLAGS -Wmissing-declarations -Wold-style-definition -Wpointer- ODP_CFLAGS="$ODP_CFLAGS -Wcast-align -Wnested-externs -Wcast-qual -Wformat-nonliteral" ODP_CFLAGS="$ODP_CFLAGS -Wformat-security -Wundef -Wwrite-strings" ODP_CFLAGS="$ODP_CFLAGS -std=c99" + +dnl Use -Werror in the checks below since Clang emits a warning instead of +dnl an error when it encounters an unknown warning option. +AX_CHECK_COMPILE_FLAG([-Wimplicit-fallthrough=0], + [ODP_CFLAGS="$ODP_CFLAGS -Wimplicit-fallthrough=0"], + [], [-Werror]) +AX_CHECK_COMPILE_FLAG([-Wformat-truncation=0], + [ODP_CFLAGS="$ODP_CFLAGS -Wformat-truncation=0"], + [], [-Werror]) +AX_CHECK_COMPILE_FLAG([-Wformat-overflow=0], + [ODP_CFLAGS="$ODP_CFLAGS -Wformat-overflow=0"], + [], [-Werror]) + # Extra flags for example to suppress certain warning types ODP_CFLAGS="$ODP_CFLAGS $ODP_CFLAGS_EXTRA" diff --git a/pkgconfig/libodp-linux.pc.in b/pkgconfig/libodp-linux.pc.in index 0769b214..61770175 100644 --- a/pkgconfig/libodp-linux.pc.in +++ b/pkgconfig/libodp-linux.pc.in @@ -7,5 +7,5 @@ Name: libodp-linux Description: The ODP packet processing engine Version: @PKGCONFIG_VERSION@ Libs: -L${libdir} -lodp-linux -Libs.private: +Libs.private: @ATOMIC_LIBS@ Cflags: -I${includedir} diff --git a/platform/linux-generic/Makefile.am b/platform/linux-generic/Makefile.am index 69fdf8b9..00ce80d7 100644 --- a/platform/linux-generic/Makefile.am +++ b/platform/linux-generic/Makefile.am @@ -219,6 +219,8 @@ __LIB__libodp_linux_la_SOURCES = \ arch/@ARCH_DIR@/odp_cpu_arch.c \ arch/@ARCH_DIR@/odp_sysinfo_parse.c +__LIB__libodp_linux_la_LIBADD = $(ATOMIC_LIBS) + if HAVE_PCAP __LIB__libodp_linux_la_SOURCES += pktio/pcap.c endif diff --git a/platform/linux-generic/m4/configure.m4 b/platform/linux-generic/m4/configure.m4 index a2a25408..6a429f1d 100644 --- a/platform/linux-generic/m4/configure.m4 +++ b/platform/linux-generic/m4/configure.m4 @@ -28,6 +28,51 @@ AC_LINK_IFELSE( echo "Use newer version. For gcc > 4.7.0" exit -1) +dnl Check whether -latomic is needed +use_libatomic=no + +AC_MSG_CHECKING(whether -latomic is needed for 64-bit atomic built-ins) +AC_LINK_IFELSE( + [AC_LANG_SOURCE([[ + static int loc; + int main(void) + { + int prev = __atomic_exchange_n(&loc, 7, __ATOMIC_RELAXED); + return 0; + } + ]])], + [AC_MSG_RESULT(no)], + [AC_MSG_RESULT(yes) + AC_CHECK_LIB( + [atomic], [__atomic_exchange_8], + [use_libatomic=yes], + [AC_MSG_FAILURE([__atomic_exchange_8 is not available])]) + ]) + +AC_MSG_CHECKING(whether -latomic is needed for 128-bit atomic built-ins) +AC_LINK_IFELSE( + [AC_LANG_SOURCE([[ + static __int128 loc; + int main(void) + { + __int128 prev; + prev = __atomic_exchange_n(&loc, 7, __ATOMIC_RELAXED); + return 0; + } + ]])], + [AC_MSG_RESULT(no)], + [AC_MSG_RESULT(yes) + AC_CHECK_LIB( + [atomic], [__atomic_exchange_16], + [use_libatomic=yes], + [AC_MSG_FAILURE([cannot detect support for 128-bit atomics])]) + ]) + +if test "x$use_libatomic" = "xyes"; then + ATOMIC_LIBS="-latomic" +fi +AC_SUBST([ATOMIC_LIBS]) + m4_include([platform/linux-generic/m4/odp_pthread.m4]) m4_include([platform/linux-generic/m4/odp_openssl.m4]) m4_include([platform/linux-generic/m4/odp_pcap.m4]) -- 2.13.0
