gcc11: Enable frame pointers by default for Haiku

* fno-omit-frame-pointer is enabled by default on all architectures
* This provides easier/faster backtraces at the cost of lower
  performance (Fedora benchmarks show between no difference and 10%
  depending on the scenario, with most things being around 2%)
* 32-bit x86 is not changed, because it has very few registes compared
  to other architectures, the performance cost would be even worse there
  (Fedora backed out the change on 32bit x86 as well)

On ARM and RISV-V, unwinding without a frame pointer is difficult (on
ARM this is due to the architecture defining mainly the link register as
a way to chaun functions, there is no fixed stack structure, on RISC-V I
don't know what the situation is but I expect there is something
similar). So on these architectures, the frame pointer should always be
enabled. On PPC, there is an hardware register doing pretty much the
frame pointer role, and that can't be disabled. On other architectures
(m68k and x86_64), it is mostly a matter of balance between the
performance cost and the ease of getting backtraces (for example for
realtime profiling). This can now easily be tweaked per architecture as
needed, with frame pointers being enabled by default (a reasonable
choice for someone starting a new architecture, ease of debugging is
more important than performance then).

Note that code that enables -fomit-frame-pointer explicitly can still do
that if needed, so the bad cases where the performance cost is very high
can be handled in this way.

Source for Fedora benchmarks: https://pagure.io/fesco/issue/2817#comment-826636

Change-Id: Iea9b8fec51adb192052f55cc49a8c1d922e27aa4
Reviewed-on: https://review.haiku-os.org/c/buildtools/+/4368
Reviewed-by: X512 X512 <danger_mail@list.ru>
Reviewed-by: David Karoly <karolyd577@gmail.com>
Reviewed-by: Fredrik Holmqvist <fredrik.holmqvist@gmail.com>
Reviewed-by: Alex von Gluck IV <kallisti5@unixzen.com>
This commit is contained in:
X512 2021-05-29 16:20:38 +09:00 committed by Alex von Gluck IV
parent d11a12c7ae
commit ef1ae53606
2 changed files with 14 additions and 3 deletions

View File

@ -44,11 +44,17 @@ Boston, MA 02111-1307, USA. */
/* Haiku uses lots of multichars, so don't warn about them unless the
user explicitly asks for the warnings with -Wmultichar. Note that
CC1_SPEC is used for both cc1 and cc1plus. */
#undef CC1_SPEC
#define CC1_SPEC \
CC1_SPEC is used for both cc1 and cc1plus.
HAIKU_CC1_SPEC is common options for all architectures. The frame pointer is also enabled
for all architectures, except for 32-bit i386, because that one has a very limited number of
registers, and the performance impact is too high. */
#define HAIKU_CC1_SPEC \
"%{fpic|fPIC|fpie|fPIE|fno-pic|fno-PIC|fno-pie|fno-PIE:;:-fPIC} \
%{!Wmultichar: -Wno-multichar} %(cc1_cpu) %{profile:-p}"
#undef CC1_SPEC
#define CC1_SPEC \
HAIKU_CC1_SPEC " %{!fomit-frame-pointer: -fno-omit-frame-pointer}"
#undef CC1PLUS_SPEC
#define CC1PLUS_SPEC "%{!Wctor-dtor-privacy:-Wno-ctor-dtor-privacy}"

View File

@ -75,3 +75,8 @@ Boston, MA 02111-1307, USA. */
if ((MAX_SKIP)==0) fprintf ((FILE), "\t.p2align %d\n", (LOG)); \
else fprintf ((FILE), "\t.p2align %d,,%d\n", (LOG), (MAX_SKIP))
#endif
/* On 32-bit i386, because there are so few registers, keep the frame pointer disabled by default.
* Other architectures have it always enabled for Haiku */
#undef CC1_SPEC
#define CC1_SPEC HAIKU_CC1_SPEC