diff mbox series

[3/3] aarch64: libgcc: Add -Werror support

Message ID 20241003194450.1052220-4-christophe.lyon@linaro.org
State New
Headers show
Series aarch64: Clean warnings in libgcc | expand

Commit Message

Christophe Lyon Oct. 3, 2024, 7:44 p.m. UTC
When --enable-werror is enabled when running the top-level configure,
it passes --enable-werror-always to subdirs.  Some of them, like
libgcc, ignore it.

This patch adds support for it, enabled only for aarch64, to avoid
breaking bootstrap for other targets.

The patch also adds -Wno-prio-ctor-dtor to avoid a warning when compiling lse_init.c

	libgcc/
	* Makefile.in (WERROR): New.
	* config/aarch64/t-aarch64: Handle WERROR. Always use
	-Wno-prio-ctor-dtor.
	* configure.ac: Add support for --enable-werror-always.
	* configure: Regenerate.
---
 libgcc/Makefile.in              |  1 +
 libgcc/config/aarch64/t-aarch64 |  1 +
 libgcc/configure                | 31 +++++++++++++++++++++++++++++++
 libgcc/configure.ac             |  5 +++++
 4 files changed, 38 insertions(+)

Comments

Kyrylo Tkachov Oct. 4, 2024, 8:50 a.m. UTC | #1
> On 3 Oct 2024, at 21:44, Christophe Lyon <christophe.lyon@linaro.org> wrote:
> 
> External email: Use caution opening links or attachments
> 
> 
> When --enable-werror is enabled when running the top-level configure,
> it passes --enable-werror-always to subdirs.  Some of them, like
> libgcc, ignore it.
> 
> This patch adds support for it, enabled only for aarch64, to avoid
> breaking bootstrap for other targets.
> 

The aarch64 part is ok but you’ll need a wider libgcc approval.
It seems to me that if libgcc is intended to compile cleanly with -Werror then it should be a libgcc-wide change, but maybe doing it port-by-port is the only practical way of getting there?
Thanks,
Kyrill


> The patch also adds -Wno-prio-ctor-dtor to avoid a warning when compiling lse_init.c
> 
>        libgcc/
>        * Makefile.in (WERROR): New.
>        * config/aarch64/t-aarch64: Handle WERROR. Always use
>        -Wno-prio-ctor-dtor.
>        * configure.ac: Add support for --enable-werror-always.
>        * configure: Regenerate.
> ---
> libgcc/Makefile.in              |  1 +
> libgcc/config/aarch64/t-aarch64 |  1 +
> libgcc/configure                | 31 +++++++++++++++++++++++++++++++
> libgcc/configure.ac             |  5 +++++
> 4 files changed, 38 insertions(+)
> 
> diff --git a/libgcc/Makefile.in b/libgcc/Makefile.in
> index 0e46e9ef768..eca62546642 100644
> --- a/libgcc/Makefile.in
> +++ b/libgcc/Makefile.in
> @@ -84,6 +84,7 @@ AR_FLAGS = rc
> 
> CC = @CC@
> CFLAGS = @CFLAGS@
> +WERROR = @WERROR@
> RANLIB = @RANLIB@
> LN_S = @LN_S@
> 
> diff --git a/libgcc/config/aarch64/t-aarch64 b/libgcc/config/aarch64/t-aarch64
> index b70e7b94edd..ae1588ce307 100644
> --- a/libgcc/config/aarch64/t-aarch64
> +++ b/libgcc/config/aarch64/t-aarch64
> @@ -30,3 +30,4 @@ LIB2ADDEH += \
>        $(srcdir)/config/aarch64/__arm_za_disable.S
> 
> SHLIB_MAPFILES += $(srcdir)/config/aarch64/libgcc-sme.ver
> +LIBGCC2_CFLAGS += $(WERROR) -Wno-prio-ctor-dtor
> diff --git a/libgcc/configure b/libgcc/configure
> index cff1eff9625..ae56f7dbdc9 100755
> --- a/libgcc/configure
> +++ b/libgcc/configure
> @@ -592,6 +592,7 @@ enable_execute_stack
> asm_hidden_op
> extra_parts
> cpu_type
> +WERROR
> get_gcc_base_ver
> HAVE_STRUB_SUPPORT
> thread_header
> @@ -719,6 +720,7 @@ enable_tm_clone_registry
> with_glibc_version
> enable_tls
> with_gcc_major_version_only
> +enable_werror_always
> '
>       ac_precious_vars='build_alias
> host_alias
> @@ -1361,6 +1363,7 @@ Optional Features:
>                           installations without PT_GNU_EH_FRAME support
>   --disable-tm-clone-registry    disable TM clone registry
>   --enable-tls            Use thread-local storage [default=yes]
> +  --enable-werror-always  enable -Werror despite compiler version
> 
> Optional Packages:
>   --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
> @@ -5808,6 +5811,34 @@ fi
> 
> 
> 
> +# Only enable with --enable-werror-always until existing warnings are
> +# corrected.
> +ac_ext=c
> +ac_cpp='$CPP $CPPFLAGS'
> +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
> +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
> +ac_compiler_gnu=$ac_cv_c_compiler_gnu
> +
> +WERROR=
> +# Check whether --enable-werror-always was given.
> +if test "${enable_werror_always+set}" = set; then :
> +  enableval=$enable_werror_always;
> +else
> +  enable_werror_always=no
> +fi
> +
> +if test $enable_werror_always = yes; then :
> +  WERROR="$WERROR${WERROR:+ }-Werror"
> +fi
> +
> +ac_ext=c
> +ac_cpp='$CPP $CPPFLAGS'
> +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
> +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
> +ac_compiler_gnu=$ac_cv_c_compiler_gnu
> +
> +
> +
> # Substitute configuration variables
> 
> 
> diff --git a/libgcc/configure.ac b/libgcc/configure.ac
> index 4e8c036990f..6b3ea2aea5c 100644
> --- a/libgcc/configure.ac
> +++ b/libgcc/configure.ac
> @@ -13,6 +13,7 @@ sinclude(../config/unwind_ipinfo.m4)
> sinclude(../config/gthr.m4)
> sinclude(../config/sjlj.m4)
> sinclude(../config/cet.m4)
> +sinclude(../config/warnings.m4)
> 
> AC_INIT([GNU C Runtime Library], 1.0,,[libgcc])
> AC_CONFIG_SRCDIR([static-object.mk])
> @@ -746,6 +747,10 @@ AC_SUBST(HAVE_STRUB_SUPPORT)
> # Determine what GCC version number to use in filesystem paths.
> GCC_BASE_VER
> 
> +# Only enable with --enable-werror-always until existing warnings are
> +# corrected.
> +ACX_PROG_CC_WARNINGS_ARE_ERRORS([manual])
> +
> # Substitute configuration variables
> AC_SUBST(cpu_type)
> AC_SUBST(extra_parts)
> --
> 2.34.1
>
Christophe Lyon Oct. 4, 2024, 8:58 a.m. UTC | #2
On Fri, 4 Oct 2024 at 10:50, Kyrylo Tkachov <ktkachov@nvidia.com> wrote:
>
>
>
> > On 3 Oct 2024, at 21:44, Christophe Lyon <christophe.lyon@linaro.org> wrote:
> >
> > External email: Use caution opening links or attachments
> >
> >
> > When --enable-werror is enabled when running the top-level configure,
> > it passes --enable-werror-always to subdirs.  Some of them, like
> > libgcc, ignore it.
> >
> > This patch adds support for it, enabled only for aarch64, to avoid
> > breaking bootstrap for other targets.
> >
>
> The aarch64 part is ok but you’ll need a wider libgcc approval.
> It seems to me that if libgcc is intended to compile cleanly with -Werror then it should be a libgcc-wide change, but maybe doing it port-by-port is the only practical way of getting there?

Indeed, it was not clear to me if libgcc is supposed to compile
without warnings.... My feeling is that warnings or often worth having
a look, but without -Werror they get unnoticed.

Adding Ian in cc as libgcc maintainer.

Thanks,

Christophe

> Thanks,
> Kyrill
>
>
> > The patch also adds -Wno-prio-ctor-dtor to avoid a warning when compiling lse_init.c
> >
> >        libgcc/
> >        * Makefile.in (WERROR): New.
> >        * config/aarch64/t-aarch64: Handle WERROR. Always use
> >        -Wno-prio-ctor-dtor.
> >        * configure.ac: Add support for --enable-werror-always.
> >        * configure: Regenerate.
> > ---
> > libgcc/Makefile.in              |  1 +
> > libgcc/config/aarch64/t-aarch64 |  1 +
> > libgcc/configure                | 31 +++++++++++++++++++++++++++++++
> > libgcc/configure.ac             |  5 +++++
> > 4 files changed, 38 insertions(+)
> >
> > diff --git a/libgcc/Makefile.in b/libgcc/Makefile.in
> > index 0e46e9ef768..eca62546642 100644
> > --- a/libgcc/Makefile.in
> > +++ b/libgcc/Makefile.in
> > @@ -84,6 +84,7 @@ AR_FLAGS = rc
> >
> > CC = @CC@
> > CFLAGS = @CFLAGS@
> > +WERROR = @WERROR@
> > RANLIB = @RANLIB@
> > LN_S = @LN_S@
> >
> > diff --git a/libgcc/config/aarch64/t-aarch64 b/libgcc/config/aarch64/t-aarch64
> > index b70e7b94edd..ae1588ce307 100644
> > --- a/libgcc/config/aarch64/t-aarch64
> > +++ b/libgcc/config/aarch64/t-aarch64
> > @@ -30,3 +30,4 @@ LIB2ADDEH += \
> >        $(srcdir)/config/aarch64/__arm_za_disable.S
> >
> > SHLIB_MAPFILES += $(srcdir)/config/aarch64/libgcc-sme.ver
> > +LIBGCC2_CFLAGS += $(WERROR) -Wno-prio-ctor-dtor
> > diff --git a/libgcc/configure b/libgcc/configure
> > index cff1eff9625..ae56f7dbdc9 100755
> > --- a/libgcc/configure
> > +++ b/libgcc/configure
> > @@ -592,6 +592,7 @@ enable_execute_stack
> > asm_hidden_op
> > extra_parts
> > cpu_type
> > +WERROR
> > get_gcc_base_ver
> > HAVE_STRUB_SUPPORT
> > thread_header
> > @@ -719,6 +720,7 @@ enable_tm_clone_registry
> > with_glibc_version
> > enable_tls
> > with_gcc_major_version_only
> > +enable_werror_always
> > '
> >       ac_precious_vars='build_alias
> > host_alias
> > @@ -1361,6 +1363,7 @@ Optional Features:
> >                           installations without PT_GNU_EH_FRAME support
> >   --disable-tm-clone-registry    disable TM clone registry
> >   --enable-tls            Use thread-local storage [default=yes]
> > +  --enable-werror-always  enable -Werror despite compiler version
> >
> > Optional Packages:
> >   --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
> > @@ -5808,6 +5811,34 @@ fi
> >
> >
> >
> > +# Only enable with --enable-werror-always until existing warnings are
> > +# corrected.
> > +ac_ext=c
> > +ac_cpp='$CPP $CPPFLAGS'
> > +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
> > +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
> > +ac_compiler_gnu=$ac_cv_c_compiler_gnu
> > +
> > +WERROR=
> > +# Check whether --enable-werror-always was given.
> > +if test "${enable_werror_always+set}" = set; then :
> > +  enableval=$enable_werror_always;
> > +else
> > +  enable_werror_always=no
> > +fi
> > +
> > +if test $enable_werror_always = yes; then :
> > +  WERROR="$WERROR${WERROR:+ }-Werror"
> > +fi
> > +
> > +ac_ext=c
> > +ac_cpp='$CPP $CPPFLAGS'
> > +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
> > +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
> > +ac_compiler_gnu=$ac_cv_c_compiler_gnu
> > +
> > +
> > +
> > # Substitute configuration variables
> >
> >
> > diff --git a/libgcc/configure.ac b/libgcc/configure.ac
> > index 4e8c036990f..6b3ea2aea5c 100644
> > --- a/libgcc/configure.ac
> > +++ b/libgcc/configure.ac
> > @@ -13,6 +13,7 @@ sinclude(../config/unwind_ipinfo.m4)
> > sinclude(../config/gthr.m4)
> > sinclude(../config/sjlj.m4)
> > sinclude(../config/cet.m4)
> > +sinclude(../config/warnings.m4)
> >
> > AC_INIT([GNU C Runtime Library], 1.0,,[libgcc])
> > AC_CONFIG_SRCDIR([static-object.mk])
> > @@ -746,6 +747,10 @@ AC_SUBST(HAVE_STRUB_SUPPORT)
> > # Determine what GCC version number to use in filesystem paths.
> > GCC_BASE_VER
> >
> > +# Only enable with --enable-werror-always until existing warnings are
> > +# corrected.
> > +ACX_PROG_CC_WARNINGS_ARE_ERRORS([manual])
> > +
> > # Substitute configuration variables
> > AC_SUBST(cpu_type)
> > AC_SUBST(extra_parts)
> > --
> > 2.34.1
> >
>
diff mbox series

Patch

diff --git a/libgcc/Makefile.in b/libgcc/Makefile.in
index 0e46e9ef768..eca62546642 100644
--- a/libgcc/Makefile.in
+++ b/libgcc/Makefile.in
@@ -84,6 +84,7 @@  AR_FLAGS = rc
 
 CC = @CC@
 CFLAGS = @CFLAGS@
+WERROR = @WERROR@
 RANLIB = @RANLIB@
 LN_S = @LN_S@
 
diff --git a/libgcc/config/aarch64/t-aarch64 b/libgcc/config/aarch64/t-aarch64
index b70e7b94edd..ae1588ce307 100644
--- a/libgcc/config/aarch64/t-aarch64
+++ b/libgcc/config/aarch64/t-aarch64
@@ -30,3 +30,4 @@  LIB2ADDEH += \
 	$(srcdir)/config/aarch64/__arm_za_disable.S
 
 SHLIB_MAPFILES += $(srcdir)/config/aarch64/libgcc-sme.ver
+LIBGCC2_CFLAGS += $(WERROR) -Wno-prio-ctor-dtor
diff --git a/libgcc/configure b/libgcc/configure
index cff1eff9625..ae56f7dbdc9 100755
--- a/libgcc/configure
+++ b/libgcc/configure
@@ -592,6 +592,7 @@  enable_execute_stack
 asm_hidden_op
 extra_parts
 cpu_type
+WERROR
 get_gcc_base_ver
 HAVE_STRUB_SUPPORT
 thread_header
@@ -719,6 +720,7 @@  enable_tm_clone_registry
 with_glibc_version
 enable_tls
 with_gcc_major_version_only
+enable_werror_always
 '
       ac_precious_vars='build_alias
 host_alias
@@ -1361,6 +1363,7 @@  Optional Features:
                           installations without PT_GNU_EH_FRAME support
   --disable-tm-clone-registry    disable TM clone registry
   --enable-tls            Use thread-local storage [default=yes]
+  --enable-werror-always  enable -Werror despite compiler version
 
 Optional Packages:
   --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
@@ -5808,6 +5811,34 @@  fi
 
 
 
+# Only enable with --enable-werror-always until existing warnings are
+# corrected.
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+WERROR=
+# Check whether --enable-werror-always was given.
+if test "${enable_werror_always+set}" = set; then :
+  enableval=$enable_werror_always;
+else
+  enable_werror_always=no
+fi
+
+if test $enable_werror_always = yes; then :
+  WERROR="$WERROR${WERROR:+ }-Werror"
+fi
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
+
 # Substitute configuration variables
 
 
diff --git a/libgcc/configure.ac b/libgcc/configure.ac
index 4e8c036990f..6b3ea2aea5c 100644
--- a/libgcc/configure.ac
+++ b/libgcc/configure.ac
@@ -13,6 +13,7 @@  sinclude(../config/unwind_ipinfo.m4)
 sinclude(../config/gthr.m4)
 sinclude(../config/sjlj.m4)
 sinclude(../config/cet.m4)
+sinclude(../config/warnings.m4)
 
 AC_INIT([GNU C Runtime Library], 1.0,,[libgcc])
 AC_CONFIG_SRCDIR([static-object.mk])
@@ -746,6 +747,10 @@  AC_SUBST(HAVE_STRUB_SUPPORT)
 # Determine what GCC version number to use in filesystem paths.
 GCC_BASE_VER
 
+# Only enable with --enable-werror-always until existing warnings are
+# corrected.
+ACX_PROG_CC_WARNINGS_ARE_ERRORS([manual])
+
 # Substitute configuration variables
 AC_SUBST(cpu_type)
 AC_SUBST(extra_parts)