On Wed, Jul 16, 2025 at 5:15 PM H.J. Lu <hjl.to...@gmail.com> wrote:
>
> Since only glibc targets support -mfentry, warn -pg without -mfentry only
> on glibc targets.
>
> gcc/
>
>         PR target/120881
>         PR testsuite/121078
>         * config/i386/i386-options.cc (ix86_option_override_internal):
>         Warn -pg without -mfentry only on glibc targets.
>
> gcc/testsuite/
>
>         PR target/120881
>         PR testsuite/121078
>         * gcc.dg/20021014-1.c (dg-additional-options): Add -mfentry
>         -fno-pic only on gnu/x86 targets.
>         * gcc.dg/aru-2.c (dg-additional-options): Likewise.
>         * gcc.dg/nest.c (dg-additional-options): Likewise.
>         * gcc.dg/pr32450.c (dg-additional-options): Likewise.
>         * gcc.dg/pr43643.c (dg-additional-options): Likewise.
>         * gcc.target/i386/pr104447.c (dg-additional-options): Likewise.
>         * gcc.target/i386/pr113122-3.c(dg-additional-options): Likewise.
>         * gcc.target/i386/pr119386-1.c (dg-additional-options): Add
>         -mfentry only on gnu targets.
>         * gcc.target/i386/pr119386-2.c (dg-additional-options): Likewise.

LGTM.

Thanks,
Uros.

>
> Signed-off-by: H.J. Lu <hjl.to...@gmail.com>
> ---
>  gcc/config/i386/i386-options.cc            | 4 ++++
>  gcc/testsuite/gcc.dg/20021014-1.c          | 2 +-
>  gcc/testsuite/gcc.dg/aru-2.c               | 2 +-
>  gcc/testsuite/gcc.dg/nest.c                | 2 +-
>  gcc/testsuite/gcc.dg/pr32450.c             | 3 ++-
>  gcc/testsuite/gcc.dg/pr43643.c             | 2 +-
>  gcc/testsuite/gcc.target/i386/pr104447.c   | 3 ++-
>  gcc/testsuite/gcc.target/i386/pr113122-3.c | 3 ++-
>  gcc/testsuite/gcc.target/i386/pr119386-1.c | 4 ++--
>  gcc/testsuite/gcc.target/i386/pr119386-2.c | 4 ++--
>  10 files changed, 18 insertions(+), 11 deletions(-)
>
> diff --git a/gcc/config/i386/i386-options.cc b/gcc/config/i386/i386-options.cc
> index 53658496efd..d244b225afe 100644
> --- a/gcc/config/i386/i386-options.cc
> +++ b/gcc/config/i386/i386-options.cc
> @@ -2852,12 +2852,16 @@ ix86_option_override_internal (bool main_args_p,
>         sorry ("%<-mno-fentry%> isn%'t compatible with SEH");
>      }
>
> +#ifdef OPTION_GLIBC_P
> +  /* -mfentry is supported only on glibc targets.  */
>    if (!opts->x_flag_fentry
> +      && OPTION_GLIBC_P (opts)
>        && (TARGET_64BIT_P (opts->x_ix86_isa_flags) || !opts->x_flag_pic)
>        && opts->x_flag_shrink_wrap
>        && opts->x_profile_flag)
>      warning (0, "%<-pg%> without %<-mfentry%> may be unreliable with "
>              "shrink wrapping");
> +#endif
>
>    if (TARGET_SEH && TARGET_CALL_MS2SYSV_XLOGUES)
>      sorry ("%<-mcall-ms2sysv-xlogues%> isn%'t currently supported with SEH");
> diff --git a/gcc/testsuite/gcc.dg/20021014-1.c 
> b/gcc/testsuite/gcc.dg/20021014-1.c
> index f5f6fcf3625..ee5d4597aa3 100644
> --- a/gcc/testsuite/gcc.dg/20021014-1.c
> +++ b/gcc/testsuite/gcc.dg/20021014-1.c
> @@ -2,7 +2,7 @@
>  /* { dg-require-profiling "-p" } */
>  /* { dg-options "-O2 -p" } */
>  /* { dg-options "-O2 -p -static" { target hppa*-*-hpux* } } */
> -/* { dg-additional-options "-mfentry -fno-pic" { target i?86-*-* x86_64-*-* 
> } } */
> +/* { dg-additional-options "-mfentry -fno-pic" { target i?86-*-gnu* 
> x86_64-*-gnu* } } */
>  /* { dg-error "profiler" "No profiler support" { target xstormy16-*-* } 0 } 
> */
>  /* { dg-message "" "consider using `-pg' instead of `-p' with gprof(1)" { 
> target *-*-freebsd* } 0 } */
>
> diff --git a/gcc/testsuite/gcc.dg/aru-2.c b/gcc/testsuite/gcc.dg/aru-2.c
> index 102ece17726..61898de032a 100644
> --- a/gcc/testsuite/gcc.dg/aru-2.c
> +++ b/gcc/testsuite/gcc.dg/aru-2.c
> @@ -1,7 +1,7 @@
>  /* { dg-do run } */
>  /* { dg-require-profiling "-pg" } */
>  /* { dg-options "-O2 -pg" } */
> -/* { dg-additional-options "-mfentry -fno-pic" { target i?86-*-* x86_64-*-* 
> } } */
> +/* { dg-additional-options "-mfentry -fno-pic" { target i?86-*-gnu* 
> x86_64-*-gnu* } } */
>
>  static int __attribute__((noinline))
>  bar (int x)
> diff --git a/gcc/testsuite/gcc.dg/nest.c b/gcc/testsuite/gcc.dg/nest.c
> index 9221ed1c8f8..2dce65edb88 100644
> --- a/gcc/testsuite/gcc.dg/nest.c
> +++ b/gcc/testsuite/gcc.dg/nest.c
> @@ -3,7 +3,7 @@
>  /* { dg-require-profiling "-pg" } */
>  /* { dg-options "-O2 -pg" } */
>  /* { dg-options "-O2 -pg -static" { target hppa*-*-hpux* } } */
> -/* { dg-additional-options "-mfentry -fno-pic" { target i?86-*-* x86_64-*-* 
> } } */
> +/* { dg-additional-options "-mfentry -fno-pic" { target i?86-*-gnu* 
> x86_64-*-gnu* } } */
>  /* { dg-error "profiler" "No profiler support" { target xstormy16-*-* } 0 } 
> */
>
>  extern void abort (void);
> diff --git a/gcc/testsuite/gcc.dg/pr32450.c b/gcc/testsuite/gcc.dg/pr32450.c
> index 4aaeb7dd654..0af262f5c67 100644
> --- a/gcc/testsuite/gcc.dg/pr32450.c
> +++ b/gcc/testsuite/gcc.dg/pr32450.c
> @@ -3,7 +3,8 @@
>  /* { dg-do run } */
>  /* { dg-require-profiling "-pg" } */
>  /* { dg-options "-O2 -pg" } */
> -/* { dg-options "-O2 -pg -mtune=core2 -mfentry -fno-pic" { target { i?86-*-* 
> x86_64-*-* } } } */
> +/* { dg-options "-O2 -pg -mtune=core2" { target { i?86-*-* x86_64-*-* } } } 
> */
> +/* { dg-additional-options "-mfentry -fno-pic" { target i?86-*-gnu* 
> x86_64-*-gnu* } } */
>  /* { dg-options "-O2 -pg -static" { target hppa*-*-hpux* } } */
>
>  extern void abort (void);
> diff --git a/gcc/testsuite/gcc.dg/pr43643.c b/gcc/testsuite/gcc.dg/pr43643.c
> index a62586dc719..41c00c8a2af 100644
> --- a/gcc/testsuite/gcc.dg/pr43643.c
> +++ b/gcc/testsuite/gcc.dg/pr43643.c
> @@ -4,7 +4,7 @@
>  /* { dg-require-profiling "-pg" } */
>  /* { dg-options "-O2 -pg" } */
>  /* { dg-options "-O2 -pg -static" { target hppa*-*-hpux* } } */
> -/* { dg-additional-options "-mfentry -fno-pic" { target i?86-*-* x86_64-*-* 
> } } */
> +/* { dg-additional-options "-mfentry -fno-pic" { target i?86-*-gnu* 
> x86_64-*-gnu* } } */
>
>  extern char *strdup (const char *);
>
> diff --git a/gcc/testsuite/gcc.target/i386/pr104447.c 
> b/gcc/testsuite/gcc.target/i386/pr104447.c
> index f58170db7ec..145ba90ac0c 100644
> --- a/gcc/testsuite/gcc.target/i386/pr104447.c
> +++ b/gcc/testsuite/gcc.target/i386/pr104447.c
> @@ -1,6 +1,7 @@
>  /* { dg-do compile } */
>  /* { dg-require-profiling "-pg" } */
> -/* { dg-options "-O2 -pg -mfentry -fno-pic" } */
> +/* { dg-options "-O2 -pg" } */
> +/* { dg-additional-options "-mfentry -fno-pic" { target *-*-gnu* } } */
>
>  int
>  bar (int x)
> diff --git a/gcc/testsuite/gcc.target/i386/pr113122-3.c 
> b/gcc/testsuite/gcc.target/i386/pr113122-3.c
> index c46805dd772..87b76de1a21 100644
> --- a/gcc/testsuite/gcc.target/i386/pr113122-3.c
> +++ b/gcc/testsuite/gcc.target/i386/pr113122-3.c
> @@ -1,7 +1,8 @@
>  /* PR target/113122 */
>  /* { dg-do assemble { target *-*-linux* } } */
>  /* { dg-require-effective-target masm_intel } */
> -/* { dg-options "-fprofile -mfentry -fno-pic -O2 -masm=intel" } */
> +/* { dg-options "-fprofile -O2 -masm=intel" } */
> +/* { dg-additional-options "-mfentry -fno-pic" { target *-*-gnu* } } */
>
>  void
>  func (void)
> diff --git a/gcc/testsuite/gcc.target/i386/pr119386-1.c 
> b/gcc/testsuite/gcc.target/i386/pr119386-1.c
> index 39a3e1d2e80..7a56eacc221 100644
> --- a/gcc/testsuite/gcc.target/i386/pr119386-1.c
> +++ b/gcc/testsuite/gcc.target/i386/pr119386-1.c
> @@ -1,9 +1,9 @@
>  /* PR target/119386 */
>  /* { dg-do compile { target *-*-linux* } } */
>  /* { dg-options "-O2 -fpic -pg" } */
> -/* { dg-additional-options "-mfentry" { target { ! ia32 }  } } */
> +/* { dg-additional-options "-mfentry" { target { *-*-gnu* && { ! ia32 } } } 
> } */
>  /* { dg-final { scan-assembler "call\[ \t\]+mcount@PLT" { target ia32 } } } 
> */
> -/* { dg-final { scan-assembler "call\[ \t\]+__fentry__@PLT" { target { ! 
> ia32 } } } } */
> +/* { dg-final { scan-assembler "call\[ \t\]+__fentry__@PLT" { target { 
> *-*-gnu* && { ! ia32 } } } } } */
>
>  int
>  main ()
> diff --git a/gcc/testsuite/gcc.target/i386/pr119386-2.c 
> b/gcc/testsuite/gcc.target/i386/pr119386-2.c
> index d516aa9bd6a..cddaaf0705c 100644
> --- a/gcc/testsuite/gcc.target/i386/pr119386-2.c
> +++ b/gcc/testsuite/gcc.target/i386/pr119386-2.c
> @@ -1,8 +1,8 @@
>  /* PR target/119386 */
>  /* { dg-do compile { target *-*-linux* } } */
>  /* { dg-options "-O2 -fpic -fno-plt -pg" } */
> -/* { dg-additional-options "-mfentry" { target { ! ia32 }  } } */
> -/* { dg-final { scan-assembler "call\[ \t\]+\\*__fentry__@GOTPCREL" { target 
> { ! ia32 } } } } */
> +/* { dg-additional-options "-mfentry" { target { *-*-gnu* && { ! ia32 } } } 
> } */
> +/* { dg-final { scan-assembler "call\[ \t\]+\\*__fentry__@GOTPCREL" { target 
> { *-*-gnu* && { ! ia32 } } } } } */
>  /* { dg-final { scan-assembler "call\[ \t\]+\\*mcount@GOT\\(" { target ia32 
> } } } */
>
>
> --
> 2.50.1
>

Reply via email to