[v4,1/2] build: GCC 7 fixes

Message ID 20170608034006.106135-2-brian.brooks@arm.com
State New
Headers show
Series
  • GCC 7 fixes
Related show

Commit Message

Brian Brooks June 8, 2017, 3:40 a.m.
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 <brian.brooks@arm.com>

Reviewed-by: Ola Liljedahl <ola.liljedahl@arm.com>

Reviewed-by: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>

---
 DEPENDENCIES                           |  5 ++--
 configure.ac                           | 13 ++++++++++
 platform/linux-generic/m4/configure.m4 | 44 ++++++++++++++++++++++++++++++++++
 3 files changed, 60 insertions(+), 2 deletions(-)

-- 
2.13.0

Comments

Dmitry Eremin-Solenikov June 8, 2017, 1 p.m. | #1
On 08.06.2017 06:40, Brian Brooks wrote:
> 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 <brian.brooks@arm.com>

> Reviewed-by: Ola Liljedahl <ola.liljedahl@arm.com>

> Reviewed-by: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>

> ---

>  DEPENDENCIES                           |  5 ++--

>  configure.ac                           | 13 ++++++++++

>  platform/linux-generic/m4/configure.m4 | 44 ++++++++++++++++++++++++++++++++++

>  3 files changed, 60 insertions(+), 2 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


As with ax_pthread, it might be easier to just import corresponding .m4
file.

>  

>  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/platform/linux-generic/m4/configure.m4 b/platform/linux-generic/m4/configure.m4

> index a2a25408..be04da8a 100644

> --- a/platform/linux-generic/m4/configure.m4

> +++ b/platform/linux-generic/m4/configure.m4

> @@ -28,6 +28,50 @@ 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

> +  AM_LDFLAGS="$AM_LDFLAGS -latomic"

> +fi


Could you please change this to ATOMIC_LDFLAGS (see PR #45)

> +

>  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])

> 



-- 
With best wishes
Dmitry
Brian Brooks June 8, 2017, 2:30 p.m. | #2
On 06/08 16:00:21, Dmitry Eremin-Solenikov wrote:
> On 08.06.2017 06:40, Brian Brooks wrote:

> > 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 <brian.brooks@arm.com>

> > Reviewed-by: Ola Liljedahl <ola.liljedahl@arm.com>

> > Reviewed-by: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>

> > ---

> >  DEPENDENCIES                           |  5 ++--

> >  configure.ac                           | 13 ++++++++++

> >  platform/linux-generic/m4/configure.m4 | 44 ++++++++++++++++++++++++++++++++++

> >  3 files changed, 60 insertions(+), 2 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

> 

> As with ax_pthread, it might be easier to just import corresponding .m4

> file.


I'd prefer we just require autoconf-archive and removes other duplicated
m4 files from this repo. checkpatch.pl is an example of why copying files
is generally not a good practice.

> >  

> >  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/platform/linux-generic/m4/configure.m4 b/platform/linux-generic/m4/configure.m4

> > index a2a25408..be04da8a 100644

> > --- a/platform/linux-generic/m4/configure.m4

> > +++ b/platform/linux-generic/m4/configure.m4

> > @@ -28,6 +28,50 @@ 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

> > +  AM_LDFLAGS="$AM_LDFLAGS -latomic"

> > +fi

> 

> Could you please change this to ATOMIC_LDFLAGS (see PR #45)


I see. Yes.

> > +

> >  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])

> > 

> 

> 

> -- 

> With best wishes

> Dmitry

Patch hide | download patch | download mbox

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/platform/linux-generic/m4/configure.m4 b/platform/linux-generic/m4/configure.m4
index a2a25408..be04da8a 100644
--- a/platform/linux-generic/m4/configure.m4
+++ b/platform/linux-generic/m4/configure.m4
@@ -28,6 +28,50 @@  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
+  AM_LDFLAGS="$AM_LDFLAGS -latomic"
+fi
+
 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])