configure: Enable -fno-omit-frame-pointer for backtrace module
RFC PATCH 1/1 configure: Enable -fno-omit-frame-pointer for backtrace module
The backtrace module is written assuming that the frame pointer is in %ebp. By default, -Os optimization level is used, which enables the gcc option -fomit-frame-pointer. This break the backtrace functionality. Enabling this may cause an unnoticeable performance cost and virtually no size increase.
---
The backtrace command on x86_64 and probably i386 is broken due to the above rationale. I've not verified, but presumably the backtrace that used to be printed for an unhandled CPU exception is also broken. Do any distros handle this?
Considering that (to my knowledge) no one has complained about this in the over 13 years that -Os has been used, has this code actually been useful? Is it worth disabling -fomit-frame-pointer? Though, I don't see much downside right now in disabling it. Alternatively, we could disable/remove the backtrace code. I think it would be nice to keep it and have it working.
Nowadays, presumably QEMU makes the GDB stub rarely used as I imagine most are developing in a virual machine. Also, the GDB stub does not work in UEFI so if anyone is using it on real hardware, they are doing so on pretty old machines. The lack of a GDB stub does not seem to be a pain point because no one has got it working on UEFI.
This patch gets the backtrace command working on x86_64-efi in QEMU for me. However, it hangs when run on my laptop. Not sure what's going on there.
Also, I've noticed that recents builds have caused a big slow down in the already slow LUKS unlock code on real hardware, but not noticeable in QEMU. It seems to occur with and without this patch. I mention this if others would be interested in testing this.
Glenn
--- configure.ac | 13 +++++++++++++ 1 file changed, 13 insertions(+)
configure.ac +13 -0
@@ -1020,6 +1020,19 @@ if test x"$target_cpu" = xsparc64 ; then TARGET_LDFLAGS="$TARGET_LDFLAGS $grub_cv_target_cc_mno_relax" fi +# The backtrace module relies on frame pointers and the default optimization +# level, -Os, omits them. Make sure they are enabled. +AC_CACHE_CHECK([whether -fno-omit-frame-pointer works], [grub_cv_cc_fno_omit_frame_pointer], [ + CFLAGS="$TARGET_CFLAGS -fno-omit-frame-pointer" + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], + [grub_cv_cc_fno_omit_frame_pointer=yes], + [grub_cv_cc_fno_omit_frame_pointer=no]) +]) + +if test "x$grub_cv_cc_fno_omit_frame_pointer" = xyes; then + TARGET_CFLAGS="$TARGET_CFLAGS -fno-omit-frame-pointer" +fi + # By default, GCC 4.4 generates .eh_frame sections containing unwind # information in some cases where it previously did not. GRUB doesn't need # these and they just use up vital space. Restore the old compiler
Signature · 7 lines
2.34.1 _______________________________________________ Grub-devel mailing list [email protected] https://lists.gnu.org/mailman/listinfo/grub-devel
Le sam. 12 août 2023, 00:22, Glenn Washburn <[email protected]> a écrit :
Quoted 6 lines
The backtrace module is written assuming that the frame pointer is in %ebp. By default, -Os optimization level is used, which enables the gcc option -fomit-frame-pointer. This break the backtrace functionality. Enabling this may cause an unnoticeable performance cost and virtually no size increase.
Do you have numbers on core.img size on i386-pc?
Quoted 62 lines
Signed-off-by Glenn Washburn <[email protected]>---
The backtrace command onx86_64and probably i386 is broken due to the above rationale. I've not verified, but presumably the backtrace that used to be printed for an unhandled CPU exception is also broken. Do any distros handle this?Considering that (to my knowledge) no one has complained about this in the over 13 years that -Os has been used, has this code actually been useful? Is it worth disabling -fomit-frame-pointer? Though, I don't see much downside
right now in disabling it. Alternatively, we could disable/remove the backtrace code. I think it would be nice to keep it and have it working.Nowadays, presumably QEMU makes the GDB stub rarely used as I imagine most are developing in a virual machine. Also, the GDB stub does not work in UEFI
so if anyone is using it on real hardware, they are doing so on pretty old machines. The lack of a GDB stub does not seem to be a pain point because no one has got it working on UEFI.This patch gets the backtrace command working on x86_64-efi in QEMU for me. However, it hangs when run on my laptop. Not sure what's going on there.
Also, I've noticed that recents builds have caused a big slow down in the already slow LUKS unlock code on real hardware, but not noticeable in QEMU. It seems to occur with and without this patch. I mention this if others would be interested in testing this.
Glenn
--- configure.ac | 13 +++++++++++++ 1 file changed, 13 insertions(+)configure.ac +1
-0@@ -1020,6 +1020,19 @@ if test x"$target_cpu" = xsparc64 ; then TARGET_LDFLAGS="$TARGET_LDFLAGS $grub_cv_target_cc_mno_relax" fi +# The backtrace module relies on frame pointers and the defaultoptimization
configure.ac +2
-0+# level, -Os, omits them. Make sure they are enabled. +AC_CACHE_CHECK([whether -fno-omit-frame-pointer works],[
grub_cv_cc_fno_omit_frame_pointer], [configure.ac +10
-1+ CFLAGS="$TARGET_CFLAGS -fno-omit-frame-pointer" + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], + [grub_cv_cc_fno_omit_frame_pointer=yes], + [grub_cv_cc_fno_omit_frame_pointer=no]) +]) + +if test "x$grub_cv_cc_fno_omit_frame_pointer" = xyes; then + TARGET_CFLAGS="$TARGET_CFLAGS -fno-omit-frame-pointer" +fi + # By default, GCC 4.4 generates .eh_frame sections containing unwind # information in some cases where it previously did not. GRUB doesn't need # these and they just use up vital space. Restore the old compiler --
Quoted 3 lines
2.34.1
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
Quoted 10 lines · On Sat, 12 Aug 2023 01:57:42 +0200 "Vladimir 'phcoder' Serbinenko"…
Le sam. 12 août 2023, 00:22, Glenn Washburn <[email protected]> a écrit :
Quoted 6 lines
The backtrace module is written assuming that the frame pointer is in %ebp. By default, -Os optimization level is used, which enables the gcc option -fomit-frame-pointer. This break the backtrace functionality. Enabling this may cause an unnoticeable performance cost and virtually no size increase.
Do you have numbers on core.img size on i386-pc?
No, I don't because I'm not really using i386-pc. However, do these numbers work for you instead? Or are you wanting to see if the core.img gets too large?
==== With frame pointer
$ du -bc grub-i386-pc/lib/grub/i386-pc/*.mod | tail -n 1 1932852 total $ du -bc grub-i386-pc/lib/grub/i386-pc/kernel.img 34672 grub-i386-pc/lib/grub/i386-pc/kernel.img 43152 total
==== No frame pointer
$ du -bc grub-i386-pc/lib/grub/i386-pc/*.mod | tail -n 1 1923236 total $ du -bc grub-i386-pc/lib/grub/i386-pc/kernel.img 34512 grub-i386-pc/lib/grub/i386-pc/kernel.img
Glenn
Quoted 57 lines
Quoted 57 lines
Signed-off-by Glenn Washburn <[email protected]>---
The backtrace command onx86_64and probably i386 is broken due to the above rationale. I've not verified, but presumably the backtrace that used to be printed for an unhandled CPU exception is also broken. Do any distros handle this?Considering that (to my knowledge) no one has complained about this in the over 13 years that -Os has been used, has this code actually been useful? Is it worth disabling -fomit-frame-pointer? Though, I don't see much downside
right now in disabling it. Alternatively, we could disable/remove the backtrace code. I think it would be nice to keep it and have it working.Nowadays, presumably QEMU makes the GDB stub rarely used as I imagine most are developing in a virual machine. Also, the GDB stub does not work in UEFI
so if anyone is using it on real hardware, they are doing so on pretty old machines. The lack of a GDB stub does not seem to be a pain point because no one has got it working on UEFI.This patch gets the backtrace command working on x86_64-efi in QEMU for me. However, it hangs when run on my laptop. Not sure what's going on there.
Also, I've noticed that recents builds have caused a big slow down in the already slow LUKS unlock code on real hardware, but not noticeable in QEMU. It seems to occur with and without this patch. I mention this if others would be interested in testing this.
Glenn
--- configure.ac | 13 +++++++++++++ 1 file changed, 13 insertions(+)configure.ac +1
-0@@ -1020,6 +1020,19 @@ if test x"$target_cpu" = xsparc64 ; then TARGET_LDFLAGS="$TARGET_LDFLAGS $grub_cv_target_cc_mno_relax" fi +# The backtrace module relies on frame pointers and the defaultoptimization
configure.ac +2
-0+# level, -Os, omits them. Make sure they are enabled. +AC_CACHE_CHECK([whether -fno-omit-frame-pointer works],[
grub_cv_cc_fno_omit_frame_pointer], [configure.ac +9
-0+ CFLAGS="$TARGET_CFLAGS -fno-omit-frame-pointer" + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], + [grub_cv_cc_fno_omit_frame_pointer=yes], + [grub_cv_cc_fno_omit_frame_pointer=no]) +]) + +if test "x$grub_cv_cc_fno_omit_frame_pointer" = xyes; then + TARGET_CFLAGS="$TARGET_CFLAGS -fno-omit-frame-pointer" +fi
Quoted 8 lines
Quoted 8 lines
+
# By default, GCC 4.4 generates .eh_frame sections containing unwind# information in some cases where it previously did not. GRUB doesn't need # these and they just use up vital space. Restore the old compiler -- 2.34.1
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
Quoted 24 lines · Glenn Washburn
Quoted 10 lines · On Sat, 12 Aug 2023 01:57:42 +0200 "Vladimir 'phcoder' Serbinenko"…
Le sam. 12 août 2023, 00:22, Glenn Washburn <[email protected]> a écrit :
Quoted 6 lines
The backtrace module is written assuming that the frame pointer is in %ebp. By default, -Os optimization level is used, which enables the gcc option -fomit-frame-pointer. This break the backtrace functionality. Enabling this may cause an unnoticeable performance cost and virtually no size increase.
Do you have numbers on core.img size on i386-pc?
No, I don't because I'm not really using i386-pc. However, do these numbers work for you instead? Or are you wanting to see if the core.img gets too large?
==== With frame pointer
$ du -bc grub-i386-pc/lib/grub/i386-pc/*.mod | tail -n 1 1932852 total $ du -bc grub-i386-pc/lib/grub/i386-pc/kernel.img 34672 grub-i386-pc/lib/grub/i386-pc/kernel.img 43152 total
Quoted 5 lines
==== No frame pointer
$ du -bc grub-i386-pc/lib/grub/i386-pc/*.mod | tail -n 1 1923236 total $ du -bc grub-i386-pc/lib/grub/i386-pc/kernel.img 34512 grub-i386-pc/lib/grub/i386-pc/kernel.img
I would not bother much here because we do not support small MBR gaps for quite long time. So, Reviewed-by: Daniel Kiper <[email protected]>...
Though...
Quoted 26 lines
Glenn
Quoted 24 lines
Quoted 24 lines
Signed-off-by Glenn Washburn <[email protected]>---
The backtrace command onx86_64and probably i386 is broken due to the above rationale. I've not verified, but presumably the backtrace that used to be printed for an unhandled CPU exception is also broken. Do any distros handle this?Considering that (to my knowledge) no one has complained about this in the over 13 years that -Os has been used, has this code actually been useful? Is it worth disabling -fomit-frame-pointer? Though, I don't see much downside
right now in disabling it. Alternatively, we could disable/remove the backtrace code. I think it would be nice to keep it and have it working.Nowadays, presumably QEMU makes the GDB stub rarely used as I imagine most are developing in a virual machine. Also, the GDB stub does not work in UEFI
so if anyone is using it on real hardware, they are doing so on pretty old machines. The lack of a GDB stub does not seem to be a pain point because no one has got it working on UEFI.This patch gets the backtrace command working on x86_64-efi in QEMU for me. However, it hangs when run on my laptop. Not sure what's going on there.
... I would move everything up until here to the commit message. If you are OK with it I can do it for you.
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Also, I've noticed that recents builds have caused a big slow down in the already slow LUKS unlock code on real hardware, but not noticeable in QEMU. It seems to occur with and without this patch. I mention this if others would be interested in testing this.
Daniel
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
Quoted 60 lines · On Thu, 14 Sep 2023 17:04:08 +0200 Daniel Kiper <[email protected]> wrote:
Quoted 24 lines · Glenn Washburn
Quoted 10 lines · On Sat, 12 Aug 2023 01:57:42 +0200 "Vladimir 'phcoder' Serbinenko"…
Le sam. 12 août 2023, 00:22, Glenn Washburn <[email protected]> a écrit :
Quoted 6 lines
The backtrace module is written assuming that the frame pointer is in %ebp. By default, -Os optimization level is used, which enables the gcc option -fomit-frame-pointer. This break the backtrace functionality. Enabling this may cause an unnoticeable performance cost and virtually no size increase.
Do you have numbers on core.img size on i386-pc?
No, I don't because I'm not really using i386-pc. However, do these numbers work for you instead? Or are you wanting to see if the core.img gets too large?
==== With frame pointer
$ du -bc grub-i386-pc/lib/grub/i386-pc/*.mod | tail -n 1 1932852 total $ du -bc grub-i386-pc/lib/grub/i386-pc/kernel.img 34672 grub-i386-pc/lib/grub/i386-pc/kernel.img 43152 totalQuoted 5 lines
==== No frame pointer
$ du -bc grub-i386-pc/lib/grub/i386-pc/*.mod | tail -n 1 1923236 total $ du -bc grub-i386-pc/lib/grub/i386-pc/kernel.img 34512 grub-i386-pc/lib/grub/i386-pc/kernel.imgI would not bother much here because we do not support small MBR gaps for quite long time. So, Reviewed-by: Daniel Kiper <[email protected]>...
Though...
Quoted 24 lines
Glenn
Quoted 22 lines
Quoted 22 lines
Signed-off-by Glenn Washburn <[email protected]>---
The backtrace command onx86_64and probably i386 is broken due to the above rationale. I've not verified, but presumably the backtrace that used to be printed for an unhandled CPU exception is also broken. Do any distros handle this?Considering that (to my knowledge) no one has complained about this in the over 13 years that -Os has been used, has this code actually been useful? Is it worth disabling -fomit-frame-pointer? Though, I don't see much downside
right now in disabling it. Alternatively, we could disable/remove the backtrace code. I think it would be nice to keep it and have it working.Nowadays, presumably QEMU makes the GDB stub rarely used as I imagine most are developing in a virual machine. Also, the GDB stub does not work in UEFI
so if anyone is using it on real hardware, they are doing so on pretty old machines. The lack of a GDB stub does not seem to be a pain point because no one has got it working on UEFI.
Quoted 5 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
This patch gets the backtrace command working on x86_64-efi in QEMU for me. However, it hangs when run on my laptop. Not sure what's going on there.
... I would move everything up until here to the commit message. If you are OK with it I can do it for you.
I'll let you take care of it, thanks.
Glenn
Quoted 7 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Also, I've noticed that recents builds have caused a big slow down in the already slow LUKS unlock code on real hardware, but not noticeable in QEMU. It seems to occur with and without this patch. I mention this if others would be interested in testing this.
Daniel
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel