Blame jdk8199936-pr3533-enable_mstackrealign_on_x86_linux_as_well_as_x86_mac_os_x.patch

Alex Kashchenko d6f9d06
# HG changeset patch
Alex Kashchenko d6f9d06
# User andrew
Alex Kashchenko d6f9d06
# Date 1526122977 -3600
Alex Kashchenko d6f9d06
#      Sat May 12 12:02:57 2018 +0100
Alex Kashchenko d6f9d06
# Node ID 00ccc73498628a51a45301322e64ce2ad06e49be
Alex Kashchenko d6f9d06
# Parent  aecf9f48f7b5c6148b62713a6b746301435b57cc
Alex Kashchenko d6f9d06
PR3533: HotSpot generates code with unaligned stack, crashes on SSE operations
Alex Kashchenko d6f9d06
Summary: Enable -mstackrealign on x86 Linux as well as x86 Mac OS X
Alex Kashchenko d6f9d06
Alex Kashchenko af80df1
diff --git openjdk.orig///common/autoconf/flags.m4 openjdk///common/autoconf/flags.m4
Alex Kashchenko af80df1
--- openjdk.orig///common/autoconf/flags.m4
Alex Kashchenko af80df1
+++ openjdk///common/autoconf/flags.m4
Alex Kashchenko af80df1
@@ -389,6 +389,21 @@
Alex Kashchenko af80df1
     AC_SUBST($2CXXSTD_CXXFLAG)
Alex Kashchenko af80df1
   fi
Alex Kashchenko af80df1
 
Alex Kashchenko af80df1
+  #
Alex Kashchenko af80df1
+  # NOTE: check for -mstackrealign needs to be below potential addition of -m32
Alex Kashchenko af80df1
+  #
Alex Kashchenko af80df1
+  if test "x$OPENJDK_TARGET_CPU" = xx86 && test "x$OPENJDK_TARGET_OS" = xmacosx -o \
Alex Kashchenko af80df1
+                                                "x$OPENJDK_TARGET_OS" = xlinux; then
Alex Kashchenko af80df1
+    # On 32-bit MacOSX the OS requires C-entry points to be 16 byte aligned.
Alex Kashchenko af80df1
+    # While waiting for a better solution, the current workaround is to use -mstackrealign
Alex Kashchenko af80df1
+    # This is also required on Linux systems which use libraries compiled with SSE instructions
Alex Kashchenko af80df1
+    REALIGN_CFLAG="-mstackrealign"
Alex Kashchenko af80df1
+    FLAGS_COMPILER_CHECK_ARGUMENTS([$REALIGN_CFLAG -Werror], [],
Alex Kashchenko af80df1
+      AC_MSG_ERROR([The selected compiler $CXX does not support -mstackrealign! Try to put another compiler in the path.])
Alex Kashchenko af80df1
+    )
Alex Kashchenko af80df1
+    AC_SUBST([REALIGN_CFLAG])
Alex Kashchenko af80df1
+  fi
Alex Kashchenko af80df1
+
Alex Kashchenko af80df1
   if test "x$CFLAGS" != "x${ADDED_CFLAGS}"; then
Alex Kashchenko af80df1
     AC_MSG_WARN([Ignoring CFLAGS($CFLAGS) found in environment. Use --with-extra-cflags])
Alex Kashchenko af80df1
   fi
Alex Kashchenko d6f9d06
diff --git openjdk.orig///common/autoconf/hotspot-spec.gmk.in openjdk///common/autoconf/hotspot-spec.gmk.in
Alex Kashchenko d6f9d06
--- openjdk.orig///common/autoconf/hotspot-spec.gmk.in
Alex Kashchenko d6f9d06
+++ openjdk///common/autoconf/hotspot-spec.gmk.in
Alex Kashchenko af80df1
@@ -112,7 +112,8 @@
Alex Kashchenko d6f9d06
 RC:=@HOTSPOT_RC@
Alex Kashchenko d6f9d06
 
Alex Kashchenko d6f9d06
 EXTRA_CFLAGS=@LEGACY_EXTRA_CFLAGS@ $(NO_DELETE_NULL_POINTER_CHECKS_CFLAG) \
Alex Kashchenko d6f9d06
-				   $(NO_LIFETIME_DSE_CFLAG) $(CXXSTD_CXXFLAG)
Alex Kashchenko d6f9d06
+				   $(NO_LIFETIME_DSE_CFLAG) $(CXXSTD_CXXFLAG) \
Alex Kashchenko d6f9d06
+				   $(REALIGN_CFLAG)
Alex Kashchenko d6f9d06
 EXTRA_CXXFLAGS=@LEGACY_EXTRA_CXXFLAGS@
Alex Kashchenko d6f9d06
 EXTRA_LDFLAGS=@LEGACY_EXTRA_LDFLAGS@
Alex Kashchenko d6f9d06
 
Alex Kashchenko d6f9d06
diff --git openjdk.orig///common/autoconf/spec.gmk.in openjdk///common/autoconf/spec.gmk.in
Alex Kashchenko d6f9d06
--- openjdk.orig///common/autoconf/spec.gmk.in
Alex Kashchenko d6f9d06
+++ openjdk///common/autoconf/spec.gmk.in
Alex Kashchenko af80df1
@@ -334,6 +334,7 @@
Alex Kashchenko d6f9d06
 
Alex Kashchenko d6f9d06
 NO_DELETE_NULL_POINTER_CHECKS_CFLAG=@NO_DELETE_NULL_POINTER_CHECKS_CFLAG@
Alex Kashchenko d6f9d06
 NO_LIFETIME_DSE_CFLAG=@NO_LIFETIME_DSE_CFLAG@
Alex Kashchenko d6f9d06
+REALIGN_CFLAG=@REALIGN_CFLAG@
Alex Kashchenko d6f9d06
 CXXSTD_CXXFLAG=@CXXSTD_CXXFLAG@
Alex Kashchenko d6f9d06
 
Alex Kashchenko d6f9d06
 CXX:=@FIXPATH@ @CCACHE@ @CXX@