Blame jdk8199936-pr3533-enable_mstackrealign_on_x86_linux_as_well_as_x86_mac_os_x.patch

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