https://gcc.gnu.org/g:339af68e44ebd065255a19bfaa182a67af9b43c2

commit 339af68e44ebd065255a19bfaa182a67af9b43c2
Author: H.J. Lu <hjl.to...@gmail.com>
Date:   Tue Jul 15 22:49:12 2025 -0700

    x86: Warn -pg without -mfentry only on glibc targets
    
    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.
    
    Signed-off-by: H.J. Lu <hjl.to...@gmail.com>

Diff:
---
 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 53658496efdc..d244b225afee 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 f5f6fcf36251..ee5d4597aa37 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 102ece177264..61898de032ad 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 9221ed1c8f81..2dce65edb88d 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 4aaeb7dd6546..0af262f5c673 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 a62586dc7196..41c00c8a2af8 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 f58170db7ecf..145ba90ac0c3 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 c46805dd7722..87b76de1a21a 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 39a3e1d2e806..7a56eacc221d 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 d516aa9bd6af..cddaaf0705c7 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 } 
} } */

Reply via email to