Andrew Geissler | 87f5cff | 2022-09-30 13:13:31 -0500 | [diff] [blame] | 1 | From e372dcb0d4541ee9b9682cde088ec87a7b238ca2 Mon Sep 17 00:00:00 2001 |
| 2 | From: Fangrui Song via Grub-devel <grub-devel@gnu.org> |
| 3 | Date: Thu, 26 Aug 2021 09:02:32 -0700 |
| 4 | Subject: [PATCH 2/2] configure: Check for -falign-jumps=1 beside |
| 5 | -falign-loops=1 |
| 6 | |
| 7 | The Clang does not support -falign-jumps and only recently gained support |
| 8 | for -falign-loops. The -falign-jumps=1 should be tested beside |
| 9 | -fliang-loops=1 to avoid passing unrecognized options to the Clang: |
| 10 | |
| 11 | clang-14: error: optimization flag '-falign-jumps=1' is not supported [-Werror,-Wignored-optimization-argument] |
| 12 | |
| 13 | The -falign-functions=1 is supported by GCC 5.1.0/Clang 3.8.0. So, just |
| 14 | add the option unconditionally. |
| 15 | |
| 16 | Upstream-Status: Backport [https://git.savannah.gnu.org/cgit/grub.git/commit/?id=e372dcb0d4541ee9b9682cde088ec87a7b238ca2] |
| 17 | Signed-off-by: Fangrui Song <maskray@google.com> |
| 18 | Acked-by: Paul Menzel <pmenzel@molgen.mpg.de> |
| 19 | Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com> |
| 20 | --- |
| 21 | configure.ac | 15 ++++++++++++++- |
| 22 | 1 file changed, 14 insertions(+), 1 deletion(-) |
| 23 | |
| 24 | diff --git a/configure.ac b/configure.ac |
| 25 | index 9a12151bd..eeb5d2211 100644 |
| 26 | --- a/configure.ac |
| 27 | +++ b/configure.ac |
| 28 | @@ -798,6 +798,8 @@ fi |
| 29 | |
| 30 | # Force no alignment to save space on i386. |
| 31 | if test "x$target_cpu" = xi386; then |
| 32 | + TARGET_CFLAGS="$TARGET_CFLAGS -falign-functions=1" |
| 33 | + |
| 34 | AC_CACHE_CHECK([whether -falign-loops works], [grub_cv_cc_falign_loop], [ |
| 35 | CFLAGS="$TARGET_CFLAGS -falign-loops=1 -Werror" |
| 36 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], |
| 37 | @@ -806,7 +808,18 @@ if test "x$target_cpu" = xi386; then |
| 38 | ]) |
| 39 | |
| 40 | if test "x$grub_cv_cc_falign_loop" = xyes; then |
| 41 | - TARGET_CFLAGS="$TARGET_CFLAGS -falign-jumps=1 -falign-loops=1 -falign-functions=1" |
| 42 | + TARGET_CFLAGS="$TARGET_CFLAGS -falign-loops=1" |
| 43 | + fi |
| 44 | + |
| 45 | + AC_CACHE_CHECK([whether -falign-jumps works], [grub_cv_cc_falign_jumps], [ |
| 46 | + CFLAGS="$TARGET_CFLAGS -falign-jumps=1 -Werror" |
| 47 | + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], |
| 48 | + [grub_cv_cc_falign_jumps=yes], |
| 49 | + [grub_cv_cc_falign_jumps=no]) |
| 50 | + ]) |
| 51 | + |
| 52 | + if test "x$grub_cv_cc_falign_jumps" = xyes; then |
| 53 | + TARGET_CFLAGS="$TARGET_CFLAGS -falign-jumps=1" |
| 54 | fi |
| 55 | fi |
| 56 | |
| 57 | -- |
| 58 | 2.37.3 |
| 59 | |