Blame SOURCES/8199936-pr3533-workaround.patch

95d809
# HG changeset patch
95d809
# User andrew
95d809
# Date 1526122977 -3600
95d809
#      Sat May 12 12:02:57 2018 +0100
95d809
# Node ID 00ccc73498628a51a45301322e64ce2ad06e49be
95d809
# Parent  aecf9f48f7b5c6148b62713a6b746301435b57cc
95d809
PR3533: HotSpot generates code with unaligned stack, crashes on SSE operations
95d809
Summary: Enable -mstackrealign on x86 Linux as well as x86 Mac OS X
95d809
95d809
diff --git openjdk.orig///common/autoconf/hotspot-spec.gmk.in openjdk///common/autoconf/hotspot-spec.gmk.in
95d809
--- openjdk.orig///common/autoconf/hotspot-spec.gmk.in
95d809
+++ openjdk///common/autoconf/hotspot-spec.gmk.in
95d809
@@ -110,7 +110,8 @@
95d809
 RC:=@HOTSPOT_RC@
95d809
 
95d809
 EXTRA_CFLAGS=@LEGACY_EXTRA_CFLAGS@ $(NO_DELETE_NULL_POINTER_CHECKS_CFLAG) \
95d809
-				   $(NO_LIFETIME_DSE_CFLAG) $(CXXSTD_CXXFLAG)
95d809
+				   $(NO_LIFETIME_DSE_CFLAG) $(CXXSTD_CXXFLAG) \
95d809
+				   $(REALIGN_CFLAG)
95d809
 EXTRA_CXXFLAGS=@LEGACY_EXTRA_CXXFLAGS@
95d809
 EXTRA_LDFLAGS=@LEGACY_EXTRA_LDFLAGS@
95d809
 
95d809
diff --git openjdk.orig///common/autoconf/spec.gmk.in openjdk///common/autoconf/spec.gmk.in
95d809
--- openjdk.orig///common/autoconf/spec.gmk.in
95d809
+++ openjdk///common/autoconf/spec.gmk.in
95d809
@@ -333,6 +333,7 @@
95d809
 
95d809
 NO_DELETE_NULL_POINTER_CHECKS_CFLAG=@NO_DELETE_NULL_POINTER_CHECKS_CFLAG@
95d809
 NO_LIFETIME_DSE_CFLAG=@NO_LIFETIME_DSE_CFLAG@
95d809
+REALIGN_CFLAG=@REALIGN_CFLAG@
95d809
 CXXSTD_CXXFLAG=@CXXSTD_CXXFLAG@
95d809
 
95d809
 CXX:=@FIXPATH@ @CCACHE@ @CXX@
95d809
diff --git openjdk.orig///common/autoconf/toolchain.m4 openjdk///common/autoconf/toolchain.m4
95d809
--- openjdk.orig///common/autoconf/toolchain.m4
95d809
+++ openjdk///common/autoconf/toolchain.m4
95d809
@@ -796,20 +796,16 @@
95d809
   #
95d809
   # NOTE: check for -mstackrealign needs to be below potential addition of -m32
95d809
   #
95d809
-  if test "x$OPENJDK_TARGET_CPU_BITS" = x32 && test "x$OPENJDK_TARGET_OS" = xmacosx; then
95d809
+  if test "x$OPENJDK_TARGET_CPU" = xx86 && test "x$OPENJDK_TARGET_OS" = xmacosx -o \
95d809
+                                                "x$OPENJDK_TARGET_OS" = xlinux; then
95d809
     # On 32-bit MacOSX the OS requires C-entry points to be 16 byte aligned.
95d809
-    # While waiting for a better solution, the current workaround is to use -mstackrealign.
95d809
-    CFLAGS="$CFLAGS -mstackrealign"
95d809
-    AC_MSG_CHECKING([if 32-bit compiler supports -mstackrealign])
95d809
-    AC_LINK_IFELSE([AC_LANG_SOURCE([[int main() { return 0; }]])],
95d809
-        [
95d809
-          AC_MSG_RESULT([yes])
95d809
-        ],
95d809
-        [
95d809
-          AC_MSG_RESULT([no])
95d809
-          AC_MSG_ERROR([The selected compiler $CXX does not support -mstackrealign! Try to put another compiler in the path.])
95d809
-        ]
95d809
+    # While waiting for a better solution, the current workaround is to use -mstackrealign
95d809
+    # This is also required on Linux systems which use libraries compiled with SSE instructions
95d809
+    REALIGN_CFLAG="-mstackrealign"
95d809
+    TOOLCHAIN_COMPILER_CHECK_ARGUMENTS([$REALIGN_CFLAG -Werror], [],
95d809
+      AC_MSG_ERROR([The selected compiler $CXX does not support -mstackrealign! Try to put another compiler in the path.])
95d809
     )
95d809
+    AC_SUBST([REALIGN_CFLAG])
95d809
   fi
95d809
 
95d809
   C_FLAG_DEPS="-MMD -MF"