configure: Remove -malign-* and fix Clang 14 breakage
cover configure: Remove -malign-* and fix Clang 14 breakage
This replaces
https://lists.gnu.org/archive/html/grub-devel/2021-08/threads.html
("[PATCH v2] configure: Check -falign-jumps=1 -falign-functions=1 beside -")
Fangrui Song (2):
configure: Remove obsoleted -malign-{jumps,loops,functions}
configure: Check -falign-jumps=1 -falign-functions=1 beside
-falign-loops=1
configure.ac | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-)
Signature · 1 line
2.33.0.rc2.250.ged5fa647cd-goog
PATCH 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
@@ -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
Re: [PATCH 1/2] configure: Remove obsoleted -malign-{jumps, loops, functions}
Dear Fāng-ruì,
Am 24.08.21 um 08:18 schrieb Fangrui Song via Grub-devel:
Quoted 5 lines
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}.
In INSTALL under *The Requirements* at least GCC 5.1 is required.
Quoted 3 lines
* GCC 5.1.0 or later
Experimental support for clang 3.8.0 or later (results in much bigger binaries) for i386,x86_64, arm (including thumb), arm64, mips(el), powerpc, sparc64
So, this works.
Quoted 17 lines
Signed-off-by Fangrui Song <[email protected]>--- configure.ac | 9 --------- 1 file changed, 9 deletions(-)configure.ac +0
-4@@ -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],
configure.ac if test "x$target_cpu" = xi386; then · line 812
Quoted 10 lines
configure.ac +0
-5- [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
Kind regards,
Paul
Daniel Kiper
Reviewed-byRe: [PATCH 1/2] configure: Remove obsoleted -malign-{jumps, loops, functions}
Quoted 36 lines · Paul Menzel
Dear Fāng-ruì,
Am 24.08.21 um 08:18 schrieb Fangrui Song via Grub-devel:
Quoted 5 lines
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}.
In
INSTALLunder *The Requirements* at least GCC 5.1 is required.Quoted 3 lines
* GCC 5.1.0 or later
Experimental support for clang 3.8.0 or later (results in much bigger binaries) for i386,x86_64, arm (including thumb), arm64, mips(el), powerpc, sparc64So, this works.
Quoted 19 lines
Signed-off-by Fangrui Song <[email protected]>--- configure.ac | 9 --------- 1 file changed, 9 deletions(-)configure.ac +0
-7@@ -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]) - ]) -
Quoted 8 lines
configure.ac if test "x$target_cpu" = xi386; then · line 811
Quoted 6 lines
configure.ac +0
-2if 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 fiAcked-by Paul Menzel <[email protected]>
Daniel
PATCH 2/2 configure: Check -falign-jumps=1 -falign-functions=1 beside -falign-loops=1
In reply to Fangrui SongClang does not support -falign-jumps and only recently gained support for -falign-loops. Test all the alignment options to avoid passing unrecognized options to Clang:
clang-14: error: optimization flag '-falign-jumps=1' is not supported [-Werror,-Wignored-optimization-argument]
When compiled with older Clang, the alignment options are not added, so just avoid the complexity for each option.
--- configure.ac | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
configure.ac +3 -2
@@ -798,8 +798,9 @@ fi # Force no alignment to save space on i386. if test "x$target_cpu" = xi386; then - AC_CACHE_CHECK([whether -falign-loops works], [grub_cv_cc_falign_loop], [ - CFLAGS="$TARGET_CFLAGS -falign-loops=1 -Werror" + AC_CACHE_CHECK([whether -falign-jumps=1 -falign-loops=1 -falign-functions=1 works], + [grub_cv_cc_falign_loop], [ + CFLAGS="$TARGET_CFLAGS -falign-jumps=1 -falign-loops=1 -falign-functions=1 -Werror" AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], [grub_cv_cc_falign_loop=yes], [grub_cv_cc_falign_loop=no])
Signature · 1 line
2.33.0.rc2.250.ged5fa647cd-goog
Re: [PATCH 2/2] configure: Check -falign-jumps=1 -falign-functions=1 beside -falign-loops=1
Dear Fāng-ruì,
Am 24.08.21 um 08:18 schrieb Fangrui Song via Grub-devel:
Quoted 21 lines
Clang does not support -falign-jumps and only recently gained support for -falign-loops. Test all the alignment options to avoid passing unrecognized options to Clang:
clang-14: error: optimization flag '-falign-jumps=1' is not supported [-Werror,-Wignored-optimization-argument]
When compiled with older Clang, the alignment options are not added, so just avoid the complexity for each option.
Signed-off-by Fangrui Song <[email protected]>--- configure.ac | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)configure.ac +0
-0@@ -798,8 +798,9 @@ fi
configure.ac fi · line 806
Quoted 10 lines
configure.ac +3
-2# Force no alignment to save space on i386. if test "x$target_cpu" = xi386; then - AC_CACHE_CHECK([whether -falign-loops works], [grub_cv_cc_falign_loop], [ - CFLAGS="$TARGET_CFLAGS -falign-loops=1 -Werror" + AC_CACHE_CHECK([whether -falign-jumps=1 -falign-loops=1 -falign-functions=1 works], + [grub_cv_cc_falign_loop], [ + CFLAGS="$TARGET_CFLAGS -falign-jumps=1 -falign-loops=1 -falign-functions=1 -Werror" AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], [grub_cv_cc_falign_loop=yes], [grub_cv_cc_falign_loop=no])
Kind regards,
Paul
Re: [PATCH 2/2] configure: Check -falign-jumps=1 -falign-functions=1 beside -falign-loops=1
In reply to Fangrui SongQuoted 19 lines · Fangrui Song
Clang does not support -falign-jumps and only recently gained support for -falign-loops. Test all the alignment options to avoid passing unrecognized options to Clang:
clang-14: error: optimization flag '-falign-jumps=1' is not supported [-Werror,-Wignored-optimization-argument]
When compiled with older Clang, the alignment options are not added, so just avoid the complexity for each option.
Signed-off-by Fangrui Song <[email protected]>--- configure.ac | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)configure.ac +0
-0
configure.ac fi · line 803
Quoted 8 lines
configure.ac +3
-2@@ -798,8 +798,9 @@ fi # Force no alignment to save space on i386. if test "x$target_cpu" = xi386; then - AC_CACHE_CHECK([whether -falign-loops works], [grub_cv_cc_falign_loop], [ - CFLAGS="$TARGET_CFLAGS -falign-loops=1 -Werror" + AC_CACHE_CHECK([whether -falign-jumps=1 -falign-loops=1 -falign-functions=1 works], + [grub_cv_cc_falign_loop], [ + CFLAGS="$TARGET_CFLAGS -falign-jumps=1 -falign-loops=1 -falign-functions=1 -Werror"
I would prefer if you add a separate check for every -falign-* option.
Daniel
Re: [PATCH 2/2] configure: Check -falign-jumps=1 -falign-functions=1 beside -falign-loops=1
Quoted 31 lines · Daniel Kiper
Quoted 19 lines · Fangrui Song
Clang does not support -falign-jumps and only recently gained support for -falign-loops. Test all the alignment options to avoid passing unrecognized options to Clang:
clang-14: error: optimization flag '-falign-jumps=1' is not supported [-Werror,-Wignored-optimization-argument]
When compiled with older Clang, the alignment options are not added, so just avoid the complexity for each option.
Signed-off-by Fangrui Song <[email protected]>--- configure.ac | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)configure.ac +0
-0configure.ac fi · line 803
Quoted 8 lines
configure.ac +3
-2@@ -798,8 +798,9 @@ fi # Force no alignment to save space on i386. if test "x$target_cpu" = xi386; then - AC_CACHE_CHECK([whether -falign-loops works], [grub_cv_cc_falign_loop], [ - CFLAGS="$TARGET_CFLAGS -falign-loops=1 -Werror" + AC_CACHE_CHECK([whether -falign-jumps=1 -falign-loops=1 -falign-functions=1 works], + [grub_cv_cc_falign_loop], [ + CFLAGS="$TARGET_CFLAGS -falign-jumps=1 -falign-loops=1 -falign-functions=1 -Werror"I would prefer if you add a separate check for every -falign-* option.
Quoted 1 line
Daniel
The attached patch checks both -falign-jumps=1 and -falign-loops=1
From fbef8198d26babeb402b480d333a4a5212069afb Mon Sep 17 00:00:00 2001
From: Fangrui Song <[email protected]>
Date: Wed, 25 Aug 2021 09:28:46 -0700
Subject: [PATCH] configure: Check -falign-jumps=1 beside -falign-loops=1
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
@@ -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
Re: [PATCH 2/2] configure: Check -falign-jumps=1 -falign-functions=1 beside -falign-loops=1
Quoted 71 lines · Fangrui Song
Quoted 31 lines · Daniel Kiper
Quoted 19 lines · Fangrui Song
Clang does not support -falign-jumps and only recently gained support for -falign-loops. Test all the alignment options to avoid passing unrecognized options to Clang:
clang-14: error: optimization flag '-falign-jumps=1' is not supported [-Werror,-Wignored-optimization-argument]
When compiled with older Clang, the alignment options are not added, so just avoid the complexity for each option.
Signed-off-by Fangrui Song <[email protected]>--- configure.ac | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)configure.ac +0
-0configure.ac fi · line 803
Quoted 8 lines
configure.ac +3
-2@@ -798,8 +798,9 @@ fi # Force no alignment to save space on i386. if test "x$target_cpu" = xi386; then - AC_CACHE_CHECK([whether -falign-loops works], [grub_cv_cc_falign_loop], [ - CFLAGS="$TARGET_CFLAGS -falign-loops=1 -Werror" + AC_CACHE_CHECK([whether -falign-jumps=1 -falign-loops=1 -falign-functions=1 works], + [grub_cv_cc_falign_loop], [ + CFLAGS="$TARGET_CFLAGS -falign-jumps=1 -falign-loops=1 -falign-functions=1 -Werror"I would prefer if you add a separate check for every -falign-* option.
Quoted 1 line
Daniel
The attached patch checks both -falign-jumps=1 and -falign-loops=1
From
fbef8198d26babeb402b480d333a4a5212069afbMon Sep 17 00:00:00 2001
From: Fangrui Song <[email protected]>
Date: Wed, 25 Aug 2021 09:28:46 -0700
Subject: [PATCH] configure: Check -falign-jumps=1 beside -falign-loops=1Clang does not support -falign-jumps and only recently gained support for -falign-loops. -falign-jumps=1 should be tested beside
(quoted diff) +0
-2-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 addthe option unconditionally.
Signed-off-by Fangrui Song <[email protected]>--- configure.ac | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)configure.ac +2
-0@@ -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 ])
configure.ac if test "x$target_cpu" = xi386; then · line 818
Quoted 10 lines
configure.ac +8
-1if 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])
It seems to me formatting is broken somehow here. It should be the same like for -falign-loops detection.
Otherwise LGTM...
Please repost both patches using "git send-email" as v3.
You can add Reviewed-by: Daniel Kiper <[email protected]> and Paul's Acked-by to the patches before posting. If there are no objections I will merge them and other reviewed patches next week...
Daniel