mesa: use build flag to ensure stack is realigned on x86
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. V4: fix comment and indentation 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@yahoo.com.au> Reviewed-by: Matt Turner <mattst88@gmail.com> CC: "10.4" <mesa-stable@lists.freedesktop.org>
This commit is contained in:
11
configure.ac
11
configure.ac
@@ -253,8 +253,16 @@ AC_SUBST([VISIBILITY_CXXFLAGS])
|
|||||||
dnl
|
dnl
|
||||||
dnl Optional flags, check for compiler support
|
dnl Optional flags, check for compiler support
|
||||||
dnl
|
dnl
|
||||||
|
SSE41_CFLAGS="-msse4.1"
|
||||||
|
dnl Code compiled by GCC with -msse* assumes a 16 byte aligned
|
||||||
|
dnl stack, but on x86-32 such alignment is not guaranteed.
|
||||||
|
case "$target_cpu" in
|
||||||
|
i?86)
|
||||||
|
SSE41_CFLAGS="$SSE41_CFLAGS -mstackrealign"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
save_CFLAGS="$CFLAGS"
|
save_CFLAGS="$CFLAGS"
|
||||||
CFLAGS="-msse4.1 $CFLAGS"
|
CFLAGS="$SSE41_CFLAGS $CFLAGS"
|
||||||
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
|
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
|
||||||
#include <smmintrin.h>
|
#include <smmintrin.h>
|
||||||
int main () {
|
int main () {
|
||||||
@@ -267,6 +275,7 @@ if test "x$SSE41_SUPPORTED" = x1; then
|
|||||||
DEFINES="$DEFINES -DUSE_SSE41"
|
DEFINES="$DEFINES -DUSE_SSE41"
|
||||||
fi
|
fi
|
||||||
AM_CONDITIONAL([SSE41_SUPPORTED], [test x$SSE41_SUPPORTED = x1])
|
AM_CONDITIONAL([SSE41_SUPPORTED], [test x$SSE41_SUPPORTED = x1])
|
||||||
|
AC_SUBST([SSE41_CFLAGS], $SSE41_CFLAGS)
|
||||||
|
|
||||||
dnl Can't have static and shared libraries, default to static if user
|
dnl Can't have static and shared libraries, default to static if user
|
||||||
dnl explicitly requested. If both disabled, set to static since shared
|
dnl explicitly requested. If both disabled, set to static since shared
|
||||||
|
@@ -153,7 +153,7 @@ libmesagallium_la_LIBADD = \
|
|||||||
libmesa_sse41_la_SOURCES = \
|
libmesa_sse41_la_SOURCES = \
|
||||||
main/streaming-load-memcpy.c \
|
main/streaming-load-memcpy.c \
|
||||||
main/sse_minmax.c
|
main/sse_minmax.c
|
||||||
libmesa_sse41_la_CFLAGS = $(AM_CFLAGS) -msse4.1
|
libmesa_sse41_la_CFLAGS = $(AM_CFLAGS) $(SSE41_CFLAGS)
|
||||||
|
|
||||||
pkgconfigdir = $(libdir)/pkgconfig
|
pkgconfigdir = $(libdir)/pkgconfig
|
||||||
pkgconfig_DATA = gl.pc
|
pkgconfig_DATA = gl.pc
|
||||||
|
@@ -31,9 +31,6 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
void
|
void
|
||||||
#if !defined(__x86_64__)
|
|
||||||
__attribute__((force_align_arg_pointer))
|
|
||||||
#endif
|
|
||||||
_mesa_uint_array_min_max(const unsigned *ui_indices, unsigned *min_index,
|
_mesa_uint_array_min_max(const unsigned *ui_indices, unsigned *min_index,
|
||||||
unsigned *max_index, const unsigned count)
|
unsigned *max_index, const unsigned count)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user