[Mesa-stable] [Mesa-dev] [PATCH V3] mesa: use build flag to ensure stack is realigned on x86

Matt Turner mattst88 at gmail.com
Mon Dec 8 22:08:01 PST 2014


On Mon, Dec 8, 2014 at 9:43 PM, Timothy Arceri <t_arceri at yahoo.com.au> wrote:
> Nowadays GCC assumes stack pointer is 16-byte aligned even on 32-bits, but
>  that is an assumption OpenGL drivers (or any dynamic library for that matter)
>  can't afford to make as there are many closed- and open- source application
>  binaries out there that only assume 4-byte stack alignment.
>
> V3: move all sse4.1 build flag config to the same location
>  and add comment as to why we need to do the realign
>
> V2: use $target_cpu rather than $host_cpu
>   and setup build flags in config rather than makefile
>
> https://bugs.freedesktop.org/show_bug.cgi?id=86788
> Signed-off-by: Timothy Arceri <t_arceri at yahoo.com.au>
> Reviewed-by: Matt Turner <mattst88 at gmail.com>
> CC: "10.4" <mesa-stable at lists.freedesktop.org>
> ---
>  If there are no other comments I'll commit it to master
>  tomorrow.
>
>  The last hunk should be dropped when applying to 10.4.
>
>  configure.ac               | 11 ++++++++++-
>  src/mesa/Makefile.am       |  2 +-
>  src/mesa/main/sse_minmax.c |  3 ---
>  3 files changed, 11 insertions(+), 5 deletions(-)
>
> diff --git a/configure.ac b/configure.ac
> index b0df1bb..e510bcf 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -253,8 +253,16 @@ AC_SUBST([VISIBILITY_CXXFLAGS])
>  dnl
>  dnl Optional flags, check for compiler support
>  dnl
> +SSE41_CFLAGS="-msse4.1"
> +dnl 32-bit Mesa is 4-byte aligned to allow support for old applications
> +dnl therefore we need to realign the stack when using SSE

I don't think this comment is right. It doesn't have anything to do
with Mesa. The 32-bit ABI just doesn't require the stack to be >4 byte
aligned.

Søren's pixman patch has this comment, which I think is fine:

Code compiled by GCC with -msse2 and -mssse3 assumes a 16 byte aligned
stack, but on x86-32 such alignment is not guaranteed.

(Just replace "-msse2 and -mssse3" with "-msse*")

> +case "$target_cpu" in
> +    i?86)
> +        SSE41_CFLAGS="$SSE41_CFLAGS -mstackrealign"
> +    ;;

Okay, starting to wonder if you're trolling me with this. :-|

Look at the other instances of ;; -- they're either on the same line
as the previous statement or they're aligned with it.


More information about the mesa-stable mailing list