> >>> diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi > >>> index 4c5c79f..daa1f3a 100644 > >>> --- a/gcc/doc/invoke.texi > >>> +++ b/gcc/doc/invoke.texi > >>> @@ -13521,6 +13521,12 @@ Attempt to keep the stack boundary aligned to a > >>> 2 raised to @var{num} > >>> byte boundary. If @option{-mpreferred-stack-boundary} is not specified, > >>> the default is 4 (16 bytes or 128 bits). > >>> > >>> +@strong{Warning:} When generating code for the x86-64 architecture with > >>> +SSE extensions disabled, @option{-mpreferred-stack-boundary=3} can be > >>> +used to keep the stack boundary aligned to 8 byte boundary. You must > >>> +build all modules with @option{-mpreferred-stack-boundary=3}, including > >>> +any libraries. This includes the system libraries and startup modules.
I would suggest to re-word this paragraph. Perhaps something along lines x86-64 ABI require 16 byte stack alignment. It is possible to compile code with -mpreferred-stack-boundary=3 where stack alignment is 8 bytes only. This is ABI incompatible and intended to be used in controlled environment where stack space is important limitation. It may lead to wrong code when functions compiled with 16 byte stack alignment (such as functions from a standard library) are called with misaligned stack. In this case the of SSE registers may lead to misaligned memory access traps. In addition, va-arg will incorrectly handle 16 byte aligned objects (including x87 long double and __int128) leading to wrong results rather than traps. Fell free to fix my english and extend it. I just want to make it sure that the paragraph explains how things break (i.e. by calling something with default stack alignment from function with 8byte alignment.) and that it can break for non-SSE code, too, when using va-args on 16 byte aligned objects. The patch is fine with this change. Please also add change to news.html with similar explanation. Honza > >>> + > >>> @item -mincoming-stack-boundary=@var{num} > >>> @opindex mincoming-stack-boundary > >>> Assume the incoming stack is aligned to a 2 raised to @var{num} byte > >> > >> I applied the above patch to GCC 4.7 and the following patch to > >> Linux kernel 3.4.0. Kernel boots and runs correctly. Is the patch > >> OK for trunk? > >> > >> Thanks. > >> > >> -- > >> H.J. > >> --- > >> diff --git a/arch/x86/Makefile b/arch/x86/Makefile > >> index 94e91e4..cd4a4f7 100644 > >> --- a/arch/x86/Makefile > >> +++ b/arch/x86/Makefile > >> @@ -49,6 +49,9 @@ else > >> KBUILD_AFLAGS += -m64 > >> KBUILD_CFLAGS += -m64 > >> > >> + # Use -mpreferred-stack-boundary=3 if supported. > >> + KBUILD_CFLAGS += $(call cc-option,-mno-sse > >> -mpreferred-stack-boundary=3) > >> + > >> # FIXME - should be integrated in Makefile.cpu (Makefile_32.cpu) > >> cflags-$(CONFIG_MK8) += $(call cc-option,-march=k8) > >> cflags-$(CONFIG_MPSC) += $(call cc-option,-march=nocona) > > > > Ping > > > > Ping. > > I have been running Linux kernel compiled with this option for > weeks. Since -mpreferred-stack-boundary=3 will only be allowed > with -mno-sse, it will be used only with incompatible ABI. Any > objections to this patch? > > Thanks. > > > -- > H.J.