> On 3 Oct 2024, at 21:44, Christophe Lyon <christophe.l...@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 >