[PATCH] x86/build: Refresh stale cc-option check for stack alignment

From: Nick Desaulniers
Date: Thu Aug 26 2021 - 14:58:53 EST


GCC did not support values for -mpreferred-stack-boundary= outside the
range [4, 12] for -m64 until GCC 7+. Modify the cc-option tests to check
for support for a value of 3, and only when using GCC.

GCC has long supported values in the range [2, 12] for -m16 and -m32
targets, so there's no need to test for support for
-mpreferred-stack-boundary=2, since cc_stack_align4 is only used for
-m16 and -m32 targets.

Signed-off-by: Nick Desaulniers <ndesaulniers@xxxxxxxxxx>
---
arch/x86/Makefile | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/arch/x86/Makefile b/arch/x86/Makefile
index d82d01490dd3..2744c4f60b63 100644
--- a/arch/x86/Makefile
+++ b/arch/x86/Makefile
@@ -14,10 +14,11 @@ endif

# For gcc stack alignment is specified with -mpreferred-stack-boundary,
# clang has the option -mstack-alignment for that purpose.
-ifneq ($(call cc-option, -mpreferred-stack-boundary=4),)
+ifdef CONFIG_CC_IS_GCC
cc_stack_align4 := -mpreferred-stack-boundary=2
- cc_stack_align8 := -mpreferred-stack-boundary=3
-else ifneq ($(call cc-option, -mstack-alignment=16),)
+ cc_stack_align8 := $(call cc-option,-mpreferred-stack-boundary=3)
+endif
+ifdef CONFIG_CC_IS_CLANG
cc_stack_align4 := -mstack-alignment=4
cc_stack_align8 := -mstack-alignment=8
endif

base-commit: 2e98d9bede666aa8f2137047043bfba9c2c2edc0
--
2.33.0.259.gc128427fd7-goog