[PATCH 53/59] gmon: Only used -fno-tree-loop-distribute-patterns if compiler supports it

Collin Funk collin.funk1@gmail.com
Mon Oct 20 19:27:28 GMT 2025


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

> ---
>  configure     | 11 ++++++++---
>  configure.ac  |  1 +
>  gmon/Makefile |  5 ++++-
>  3 files changed, 13 insertions(+), 4 deletions(-)
>
> diff --git a/configure b/configure
> index 26f6682c1e6..c8ed16bd79d 100755
> --- a/configure
> +++ b/configure
> @@ -7515,7 +7515,8 @@ $conftest_code
>  EOF
>  
>  saved_CC="$CC"
> -CC="$TEST_CC"
> +saved_CFLAGS="$CFLAGS"
> +CC="$TEST_CC -Wno-unused-command-line-argument"
>  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for traditional tls support in testing" >&5
>  printf %s "checking for traditional tls support in testing... " >&6; }
>  if test ${libc_cv_test_mtls_traditional+y}
> @@ -8015,6 +8016,8 @@ if test $libc_cv_test_cc_loop_to_function = yes; then
>  
>  fi
>  
> +config_vars="$config_vars
> +config-cflags-cc-loop-to-function = $libc_cv_cc_loop_to_function"
>  
>  
>  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for -Wimplicit-fallthrough" >&5
> @@ -8107,7 +8110,8 @@ if test "$TEST_CC" = "$CC"; then
>  else
>  
>  saved_CC="$CC"
> -CC="$TEST_CC"
> +saved_CFLAGS="$CFLAGS"
> +CC="$TEST_CC -Wno-unused-command-line-argument"
>  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for -Wfree-labels in testing" >&5
>  printf %s "checking for -Wfree-labels in testing... " >&6; }
>  if test ${libc_cv_test_cc_wfree_labels+y}
> @@ -8167,7 +8171,8 @@ if test "$TEST_CC" = "$CC"; then
>  else
>  
>  saved_CC="$CC"
> -CC="$TEST_CC"
> +saved_CFLAGS="$CFLAGS"
> +CC="$TEST_CC -Wno-unused-command-line-argument"
>  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for -Wmissing-parameter-name in testing" >&5
>  printf %s "checking for -Wmissing-parameter-name in testing... " >&6; }
>  if test ${libc_cv_test_cc_wmissing_parameter_name+y}
> diff --git a/configure.ac b/configure.ac
> index 7111d081f20..f5cbdd6bdb5 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -1599,6 +1599,7 @@ if test $libc_cv_test_cc_loop_to_function = yes; then
>    AC_DEFINE(HAVE_TEST_CC_INHIBIT_LOOP_TO_LIBCALL)
>  fi
>  AC_SUBST(libc_cv_cc_loop_to_function)
> +LIBC_CONFIG_VAR(config-cflags-cc-loop-to-function,$libc_cv_cc_loop_to_function)
>  
>  LIBC_TRY_CC_AND_TEST_CC_OPTION([for -Wimplicit-fallthrough],
>    [-Werror -Wimplicit-fallthrough],
> diff --git a/gmon/Makefile b/gmon/Makefile
> index b42c14aa83d..c7534bff67c 100644
> --- a/gmon/Makefile
> +++ b/gmon/Makefile
> @@ -64,7 +64,10 @@ endif
>  
>  # The mcount code won't work without a frame pointer nor when memcpy or
>  # memset are called.
> -CFLAGS-mcount.c := -fno-omit-frame-pointer -fno-tree-loop-distribute-patterns
> +CFLAGS-mcount.c := -fno-omit-frame-pointer
> +ifeq (yes,$(config-cflags-cc-loop-to-function))
> +CFLAGS-mcount.c += -fno-tree-loop-distribute-patterns
> +endif
>  
>  CFLAGS-tst-gmon.c := -fno-omit-frame-pointer -pg
>  tst-gmon-no-pie = yes

I couldn't find an equivalent option to disable this optimization with
clang. I'm assuming you checked and couldn't find it as well?

If so, this patch makes sense.

Reviewed-by: Collin Funk <collin.funk1@gmail.com>

Collin


More information about the Libc-alpha mailing list