gprof: Compile tst-gmon.c with -O2 -fno-omit-frame-pointer
Checks
Commit Message
Compile tst-gmon.c with -O2 -fno-omit-frame-pointer to ensure proper call
graph generation.
PR gprof/32768
* configure.ac: Compile tst-gmon.c with -fno-omit-frame-pointe.
* configure: Regenerated.
* testsuite/Makefile.am (GPROF_FLAGS): Add -O2
-fno-omit-frame-pointer.
(AM_CFLAGS): Removed.
(COMPILE): Append $(GPROF_FLAGS).
(LINK): Likewise.
* testsuite/Makefile.in: Regenerated.
Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
---
gprof/configure | 2 +-
gprof/configure.ac | 2 +-
gprof/testsuite/Makefile.am | 10 +++++-----
gprof/testsuite/Makefile.in | 10 ++++++----
4 files changed, 13 insertions(+), 11 deletions(-)
Comments
On Sat, Mar 08, 2025 at 05:46:56PM +0800, H.J. Lu wrote:
> +# NB: -O2 -fno-omit-frame-pointer is needed for expected call graph. See
> +# https://sourceware.org/bugzilla/show_bug.cgi?id=32768
> +GPROF_FLAGS = -O2 -fno-omit-frame-pointer -pg
Thanks. Fair enough. x86_64 at least complains if you have -pg and
-fomit-frame-pointer together, and -O2 on x86_64 puts functions on
16-byte boundaries.
On Sat, Mar 8, 2025 at 6:20 PM Alan Modra <amodra@gmail.com> wrote:
>
> On Sat, Mar 08, 2025 at 05:46:56PM +0800, H.J. Lu wrote:
> > +# NB: -O2 -fno-omit-frame-pointer is needed for expected call graph. See
> > +# https://sourceware.org/bugzilla/show_bug.cgi?id=32768
> > +GPROF_FLAGS = -O2 -fno-omit-frame-pointer -pg
>
> Thanks. Fair enough. x86_64 at least complains if you have -pg and
> -fomit-frame-pointer together, and -O2 on x86_64 puts functions on
> 16-byte boundaries.
>
This test works in glibc for many targets compiled with
-O2 -fno-omit-frame-pointer -pg. I am checking it in.
Thanks.
@@ -13972,7 +13972,7 @@ if ${gprof_cv_sys_native+:} false; then :
else
gprof_cv_sys_native=no
if test x"${host}" = x"${target}" \
- && ${CC-cc} -O2 -pg -o tst-gmon $srcdir/testsuite/tst-gmon.c; then
+ && ${CC-cc} -O2 -fno-omit-frame-pointer -pg -o tst-gmon $srcdir/testsuite/tst-gmon.c; then
rm -f gmon.out
./tst-gmon
if test -s gmon.out; then
@@ -77,7 +77,7 @@ AC_CACHE_CHECK([whether gprof tests can run],
[gprof_cv_sys_native], [dnl
gprof_cv_sys_native=no
if test x"${host}" = x"${target}" \
- && ${CC-cc} -O2 -pg -o tst-gmon $srcdir/testsuite/tst-gmon.c; then
+ && ${CC-cc} -O2 -fno-omit-frame-pointer -pg -o tst-gmon $srcdir/testsuite/tst-gmon.c; then
rm -f gmon.out
./tst-gmon
if test -s gmon.out; then
@@ -4,13 +4,13 @@ AUTOMAKE_OPTIONS = foreign
GPROF = ../gprof$(EXEEXT)
-GPROF_FLAGS = -pg
-
-AM_CFLAGS = $(GPROF_FLAGS)
+# NB: -O2 -fno-omit-frame-pointer is needed for expected call graph. See
+# https://sourceware.org/bugzilla/show_bug.cgi?id=32768
+GPROF_FLAGS = -O2 -fno-omit-frame-pointer -pg
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
- $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
-LINK = $(CC) $(AM_CFLAGS) $(CFLAGS) $(OPT_NO_PLUGINS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) $(GPROF_FLAGS)
+LINK = $(CC) $(AM_CFLAGS) $(CFLAGS) $(OPT_NO_PLUGINS) $(GPROF_FLAGS) \
$(AM_LDFLAGS) $(LDFLAGS) -o $@
# We will add to these later, for each individual test. Note
@@ -493,12 +493,14 @@ top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
AUTOMAKE_OPTIONS = foreign
GPROF = ../gprof$(EXEEXT)
-GPROF_FLAGS = -pg
-AM_CFLAGS = $(GPROF_FLAGS)
+
+# NB: -O2 -fno-omit-frame-pointer is needed for expected call graph. See
+# https://sourceware.org/bugzilla/show_bug.cgi?id=32768
+GPROF_FLAGS = -O2 -fno-omit-frame-pointer -pg
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
- $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) $(GPROF_FLAGS)
-LINK = $(CC) $(AM_CFLAGS) $(CFLAGS) $(OPT_NO_PLUGINS) \
+LINK = $(CC) $(AM_CFLAGS) $(CFLAGS) $(OPT_NO_PLUGINS) $(GPROF_FLAGS) \
$(AM_LDFLAGS) $(LDFLAGS) -o $@