Blame SOURCES/jdk8199936-pr3533-enable_mstackrealign_on_x86_linux_as_well_as_x86_mac_os_x.patch

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