Skip to contentSkip to conversation

configure: Remove -malign-* and fix Clang 14 breakage

PATCH In review Fangrui Song 2 participants 4 messages Aug 26, 2021

lore
Share & tools
lore
#0 lore raw

v3 cover configure: Remove -malign-* and fix Clang 14 breakage

Replaces https://lists.gnu.org/archive/html/grub-devel/2021-08/msg00094.html
("[PATCH 0/2] configure: Remove -malign-* and fix Clang 14 breakage")

Changes from v2:
Split -falign-jumps=1 -falign-loops=1 checks
Change a tab to spaces

Fangrui Song (2):
configure: Remove obsoleted -malign-{jumps,loops,functions}
configure: Check -falign-jumps=1 beside -falign-loops=1

 configure.ac | 24 ++++++++++++++----------
 1 file changed, 14 insertions(+), 10 deletions(-)
Signature · 1 line
2.33.0.rc2.250.ged5fa647cd-goog
#1 lore raw

PATCH v3 1/2 configure: Remove obsoleted -malign-{jumps, loops, functions}

GCC warns cc1: warning: ‘-malign-loops’ is obsolete, use ‘-falign-loops’. Clang silently ignores -malign-{jumps,loops,functions}.

The preferred -falign-* forms have been supported since GCC 3.2, so just remove -malign-{jumps,loops,functions}.

---
 configure.ac | 9 ---------
 1 file changed, 9 deletions(-)
configure.ac +0 -9
index bee28dbeb..9a12151bd 100644
@@ -805,17 +805,8 @@ if test "x$target_cpu" = xi386; then
 	[grub_cv_cc_falign_loop=no])
   ])
 
-  AC_CACHE_CHECK([whether -malign-loops works], [grub_cv_cc_malign_loop], [
-    CFLAGS="$TARGET_CFLAGS -malign-loops=1 -Werror"
-    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
-        [grub_cv_cc_malign_loop=yes],
-	[grub_cv_cc_malign_loop=no])
-  ])
-
   if test "x$grub_cv_cc_falign_loop" = xyes; then
     TARGET_CFLAGS="$TARGET_CFLAGS -falign-jumps=1 -falign-loops=1 -falign-functions=1"
-  elif test "x$grub_cv_cc_malign_loop" = xyes; then
-    TARGET_CFLAGS="$TARGET_CFLAGS -malign-jumps=1 -malign-loops=1 -malign-functions=1"
   fi
 fi
 
Signature · 1 line
2.33.0.rc2.250.ged5fa647cd-goog
Acked-by Paul Menzel Reviewed-by on v3 1/2
#2 lore raw

Re: [PATCH v3 1/2] configure: Remove obsoleted -malign-{jumps,loops,functions}

Quoted 9 lines · Fangrui Song

GCC warns cc1: warning: ‘-malign-loops’ is obsolete, use ‘-falign-loops’. Clang silently ignores -malign-{jumps,loops,functions}.

The preferred -falign-* forms have been supported since GCC 3.2, so just remove -malign-{jumps,loops,functions}.

This should be in the following order:

I will fix this before commiting. Otherwise LGTM.

Thank you for making this patches.

Daniel

#3 lore raw

PATCH v3 2/2 configure: Check -falign-jumps=1 beside -falign-loops=1

In reply to Fangrui Song

Clang does not support -falign-jumps and only recently gained support for -falign-loops. -falign-jumps=1 should be tested beside -fliang-loops=1 to avoid passing unrecognized options to Clang:

clang-14: error: optimization flag '-falign-jumps=1' is not supported [-Werror,-Wignored-optimization-argument]

-falign-functions=1 is supported by GCC 5.1.0/Clang 3.8.0, so just add the option unconditionally.

---
 configure.ac | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)
configure.ac +14 -1
index 9a12151bd..eeb5d2211 100644
@@ -798,6 +798,8 @@ fi
 
 # Force no alignment to save space on i386.
 if test "x$target_cpu" = xi386; then
+  TARGET_CFLAGS="$TARGET_CFLAGS -falign-functions=1"
+
   AC_CACHE_CHECK([whether -falign-loops works], [grub_cv_cc_falign_loop], [
     CFLAGS="$TARGET_CFLAGS -falign-loops=1 -Werror"
     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
@@ -806,7 +808,18 @@ if test "x$target_cpu" = xi386; then
   ])
 
   if test "x$grub_cv_cc_falign_loop" = xyes; then
-    TARGET_CFLAGS="$TARGET_CFLAGS -falign-jumps=1 -falign-loops=1 -falign-functions=1"
+    TARGET_CFLAGS="$TARGET_CFLAGS -falign-loops=1"
+  fi
+
+  AC_CACHE_CHECK([whether -falign-jumps works], [grub_cv_cc_falign_jumps], [
+    CFLAGS="$TARGET_CFLAGS -falign-jumps=1 -Werror"
+    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
+        [grub_cv_cc_falign_jumps=yes],
+        [grub_cv_cc_falign_jumps=no])
+  ])
+
+  if test "x$grub_cv_cc_falign_jumps" = xyes; then
+    TARGET_CFLAGS="$TARGET_CFLAGS -falign-jumps=1"
   fi
 fi
 
Signature · 1 line
2.33.0.rc2.250.ged5fa647cd-goog