[PATCH 04/59] configure: Use -Wno-maybe-uninitialized iff compiler supports it

Sam James sam@gentoo.org
Mon Oct 20 19:41:57 GMT 2025


Adhemerval Zanella <adhemerval.zanella@linaro.org> writes:

> clang does not support the flag.

Clang does have -Wsometimes-uninitialized but I think (not checked) it's
still implemented in the FE.

Anyway, suppressions for GCC's -Wmaybe-uninitialized wouldn't
necessarily hold for -Wsometimes-uninitialized (I think it would be
harmless but I'd want to check whether -Wsometimes-uninitialized flags
things in glibc and categorise the result sfirst).

So, all that said, it's fine, and:

Reviewed-by: Sam James <sam@gentoo.org>


> ---
>  configure         | 26 ++++++++++++++++++++++++++
>  configure.ac      |  9 +++++++++
>  timezone/Makefile |  2 +-
>  3 files changed, 36 insertions(+), 1 deletion(-)
>
> diff --git a/configure b/configure
> index 222f04db22..fa888eeb9f 100755
> --- a/configure
> +++ b/configure
> @@ -7613,6 +7613,32 @@ config_vars="$config_vars
>  config-cflags-wno-ignored-attributes = $libc_cv_wno_ignored_attributes"
>  
>  
> +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for -Wno-maybe-uninitialized" >&5
> +printf %s "checking for -Wno-maybe-uninitialized... " >&6; }
> +if test ${libc_cv_wno_maybe_uninitialized+y}
> +then :
> +  printf %s "(cached) " >&6
> +else case e in #(
> +  e) 		if { ac_try='${CC-cc} -Werror -Wno-maybe-uninitialized -xc /dev/null -S -o /dev/null'
> +  { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
> +  (eval $ac_try) 2>&5
> +  ac_status=$?
> +  printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
> +  test $ac_status = 0; }; }
> +then :
> +  libc_cv_wno_maybe_uninitialized=-Wno-maybe-uninitialized
> +else case e in #(
> +  e) libc_cv_wno_maybe_uninitialized= ;;
> +esac
> +fi
> + ;;
> +esac
> +fi
> +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $libc_cv_wno_maybe_uninitialized" >&5
> +printf "%s\n" "$libc_cv_wno_maybe_uninitialized" >&6; }
> +config_vars="$config_vars
> +config-cflags-wno-maybe-uninitialized = $libc_cv_wno_maybe_uninitialized"
> +
>  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether cc puts quotes around section names" >&5
>  printf %s "checking whether cc puts quotes around section names... " >&6; }
>  if test ${libc_cv_have_section_quotes+y}
> diff --git a/configure.ac b/configure.ac
> index af57b0cbae..fe78f7f802 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -1444,6 +1444,15 @@ LIBC_CONFIG_VAR([config-cflags-wno-ignored-attributes],
>  		[$libc_cv_wno_ignored_attributes])
>  AC_SUBST(libc_cv_test_wno_ignored_attributes)
>  
> +AC_CACHE_CHECK([for -Wno-maybe-uninitialized],
> +                libc_cv_wno_maybe_uninitialized, [dnl
> +		LIBC_TRY_CC_OPTION([-Werror -Wno-maybe-uninitialized],
> +				   [libc_cv_wno_maybe_uninitialized=-Wno-maybe-uninitialized],
> +				   [libc_cv_wno_maybe_uninitialized=])
> +])
> +LIBC_CONFIG_VAR([config-cflags-wno-maybe-uninitialized],
> +		[$libc_cv_wno_maybe_uninitialized])
> +
>  AC_CACHE_CHECK(whether cc puts quotes around section names,
>  	       libc_cv_have_section_quotes,
>  	       [cat > conftest.c <<EOF
> diff --git a/timezone/Makefile b/timezone/Makefile
> index ebe5cf73a1..6c7a7d4f4d 100644
> --- a/timezone/Makefile
> +++ b/timezone/Makefile
> @@ -68,7 +68,7 @@ tz-cflags = -DTZDIR='"$(zonedir)"' \
>  	    -DTZDEFRULES='"$(posixrules-file)"' \
>  	    -DTM_GMTOFF=tm_gmtoff -DTM_ZONE=tm_zone \
>  	    -DHAVE_GETTEXT -DUSE_LTZ=0 -D_ISOMAC -DTZ_DOMAIN='"libc"' \
> -	    -include $(common-objpfx)config.h -Wno-maybe-uninitialized
> +	    -include $(common-objpfx)config.h $(config-cflags-wno-maybe-uninitialized)
>  
>  # The -Wno-unused-variable flag is used to prevent GCC 6
>  # from warning about time_t_min and time_t_max which are


More information about the Libc-alpha mailing list