Skip to content

Commit d9b0cde

Browse files
hjl-toolsH. Peter Anvin
authored and
H. Peter Anvin
committed
x86-64, gcc: Use -mpreferred-stack-boundary=3 if supported
On x86-64, the standard ABI requires alignment to 16 bytes. However, this is not actually necessary in the kernel (we don't do SSE except in very controlled ways); and furthermore, the standard kernel entry on x86-64 actually leaves the stack on an odd 8-byte boundary, which means that gcc will generate extra instructions to keep the stack *mis*aligned! gcc 4.8 adds an -mpreferred-stack-boundary=3 option to override this and lets us save some stack space and a handful of instructions. Note that this causes us to pass -mno-sse twice; this is redundant, but necessary since the cc-option test will fail unless -mno-sse is passed on the same command line. [ hpa: rewrote the patch description ] Signed-off-by: H.J. Lu <[email protected]> Link: http://lkml.kernel.org/r/CAMe9rOqPfy3JcZRLaUeCjBe9BVY-P6e0uaSbMi5hvS-6WwQueg@mail.gmail.com Signed-off-by: H. Peter Anvin <[email protected]>
1 parent 485802a commit d9b0cde

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

Diff for: arch/x86/Makefile

+3
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ else
4949
KBUILD_AFLAGS += -m64
5050
KBUILD_CFLAGS += -m64
5151

52+
# Use -mpreferred-stack-boundary=3 if supported.
53+
KBUILD_CFLAGS += $(call cc-option,-mno-sse -mpreferred-stack-boundary=3)
54+
5255
# FIXME - should be integrated in Makefile.cpu (Makefile_32.cpu)
5356
cflags-$(CONFIG_MK8) += $(call cc-option,-march=k8)
5457
cflags-$(CONFIG_MPSC) += $(call cc-option,-march=nocona)

0 commit comments

Comments
 (0)