]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
x86: Warn -pg without -mfentry only on glibc targets
authorH.J. Lu <hjl.tools@gmail.com>
Wed, 16 Jul 2025 05:49:12 +0000 (22:49 -0700)
committerH.J. Lu <hjl.tools@gmail.com>
Wed, 16 Jul 2025 18:29:08 +0000 (11:29 -0700)
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.tools@gmail.com>
gcc/config/i386/i386-options.cc
gcc/testsuite/gcc.dg/20021014-1.c
gcc/testsuite/gcc.dg/aru-2.c
gcc/testsuite/gcc.dg/nest.c
gcc/testsuite/gcc.dg/pr32450.c
gcc/testsuite/gcc.dg/pr43643.c
gcc/testsuite/gcc.target/i386/pr104447.c
gcc/testsuite/gcc.target/i386/pr113122-3.c
gcc/testsuite/gcc.target/i386/pr119386-1.c
gcc/testsuite/gcc.target/i386/pr119386-2.c

index 53658496efdceba0f1a2745323ca18b3e3f57608..d244b225afeeb09b9974a4d12a5d0a51a14565a2 100644 (file)
@@ -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");
index f5f6fcf36251a21d2f2a42ee3699062d8b2d0f96..ee5d4597aa37d8613bed7e8c0df103ccba0d3f1a 100644 (file)
@@ -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 } */
 
index 102ece1772649f0a0bebcad771d36cc3e7e767e9..61898de032ad0b2bdc545fb7d715610f0f88182a 100644 (file)
@@ -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)
index 9221ed1c8f81552e06b6cf1379d7573b4f29ff05..2dce65edb88d004a66a36dbc37b04b785af7254a 100644 (file)
@@ -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);
index 4aaeb7dd654633e3fdb9390fd880bad963969dd0..0af262f5c673468a219a831c2e4e02eb6f702cc3 100644 (file)
@@ -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);
index a62586dc7196d0c6b6566bdc965fdfc7540b83c9..41c00c8a2af83a1d2b38a0862b6cc9c9370a5a36 100644 (file)
@@ -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 *);
 
index f58170db7ecf7e5bbaf78981e1c9829e20166299..145ba90ac0c3d34eb4266c112c0e371f8adbca34 100644 (file)
@@ -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)
index c46805dd772249b06a78a2f42cd670fcd721aff1..87b76de1a21a28c234e0fda3bf1c08cc921ecc83 100644 (file)
@@ -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)
index 39a3e1d2e806773006f5f5914bf83b14cc4e8827..7a56eacc221dedcb1b00bd76aa71755f4d465bfd 100644 (file)
@@ -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 ()
index d516aa9bd6af0dcdb5a408b54d6cf57861c676c4..cddaaf0705c71e3d69a86c965c1acffc2eb1a3f8 100644 (file)
@@ -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 } } } */