https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89221
Bug ID: 89221
Summary: --enable-frame-pointer does not work as intended
Product: gcc
Version: 9.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: target
Assignee: unassigned at gcc dot gnu.org
Reporter: ebotcazou at gcc dot gnu.org
Target Milestone: ---
Target: i?86-*-*, x86_64-*-*
The first issue is that the code in configure.ac line 1882 reads:
AC_ARG_ENABLE(frame-pointer,
[AS_HELP_STRING([--enable-frame-pointer],
[enable -fno-omit-frame-pointer by default for 32bit x86])],
[],
[
case $target_os in
linux* | darwin[[8912]]*)
# Enable -fomit-frame-pointer by default for Linux and Darwin with
# DWARF2.
enable_frame_pointer=no
;;
*)
enable_frame_pointer=yes
;;
esac
])
so it's clear that the idea is to default to enable_frame_pointer on Linux and
Darwin and neither on Solaris nor Windows for example.
But the second part doesn't work because the associated code in config.gcc:
i[34567]86-*-*)
if test "x$enable_frame_pointer" = xyes; then
tm_defines="${tm_defines} USE_IX86_FRAME_POINTER=1"
fi
is executed *before* (line 1488 of configure.ac) so enable_frame_pointer is
empty at this point. That's why config/i386/sol2.h forcibly defines it.
On the plus side, explicitly passing --enable-frame-pointer works.
The second issue is that the x86-64 code in config.gcc reads:
x86_64-*-*)
if test "x$enable_frame_pointer" = xyes; then
tm_defines="${tm_defines} USE_IX86_FRAME_POINTER=1"
fi
but the macro is i386.c is different:
#ifndef USE_X86_64_FRAME_POINTER
#define USE_X86_64_FRAME_POINTER 0
#endif
so --enable-frame-pointer doesn't work at all for x86-64.