8204935: [aix] TOC overflow in libjvm.so (release build)
authorstuefe
Wed, 13 Jun 2018 07:53:27 +0200
changeset 50550 41ff671ed8cf
parent 50549 75a03a4cfbca
child 50551 367763702685
8204935: [aix] TOC overflow in libjvm.so (release build) Reviewed-by: goetz, mbaesken, ihse
make/autoconf/flags-cflags.m4
make/autoconf/flags-ldflags.m4
make/hotspot/lib/CompileGtest.gmk
--- a/make/autoconf/flags-cflags.m4	Wed Jun 13 20:11:18 2018 +0200
+++ b/make/autoconf/flags-cflags.m4	Wed Jun 13 07:53:27 2018 +0200
@@ -573,22 +573,24 @@
     # '-qpic' defaults to 'qpic=small'. This means that the compiler generates only
     # one instruction for accessing the TOC. If the TOC grows larger than 64K, the linker
     # will have to patch this single instruction with a call to some out-of-order code which
-    # does the load from the TOC. This is of course slow. But in that case we also would have
+    # does the load from the TOC. This is of course slower, and we also would have
     # to use '-bbigtoc' for linking anyway so we could also change the PICFLAG to 'qpic=large'.
     # With 'qpic=large' the compiler will by default generate a two-instruction sequence which
     # can be patched directly by the linker and does not require a jump to out-of-order code.
-    # Another alternative instead of using 'qpic=large -bbigtoc' may be to use '-qminimaltoc'
-    # instead. This creates a distinct TOC for every compilation unit (and thus requires two
-    # loads for accessing a global variable). But there are rumors that this may be seen as a
-    # 'performance feature' because of improved code locality of the symbols used in a
-    # compilation unit.
-    PICFLAG="-qpic"
+    #
+    # Since large TOC causes perf. overhead, only pay it where we must. Currently this is
+    # for all libjvm variants (both gtest and normal) but no other binaries. So, build
+    # libjvm with -qpic=large and link with -bbigtoc.
+    JVM_PICFLAG="-qpic=large"
+    JDK_PICFLAG="-qpic"
   elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
     PICFLAG=""
   fi
 
-  JVM_PICFLAG="$PICFLAG"
-  JDK_PICFLAG="$PICFLAG"
+  if test "x$TOOLCHAIN_TYPE" != xxlc; then
+    JVM_PICFLAG="$PICFLAG"
+    JDK_PICFLAG="$PICFLAG"
+  fi
 
   if test "x$OPENJDK_TARGET_OS" = xmacosx; then
     # Linking is different on MacOSX
--- a/make/autoconf/flags-ldflags.m4	Wed Jun 13 20:11:18 2018 +0200
+++ b/make/autoconf/flags-ldflags.m4	Wed Jun 13 07:53:27 2018 +0200
@@ -94,7 +94,8 @@
   elif test "x$TOOLCHAIN_TYPE" = xxlc; then
     BASIC_LDFLAGS="-b64 -brtl -bnolibpath -bexpall -bernotok -btextpsize:64K \
         -bdatapsize:64K -bstackpsize:64K"
-    BASIC_LDFLAGS_JVM_ONLY="-Wl,-lC_r"
+    # libjvm.so has gotten too large for normal TOC size; compile with qpic=large and link with bigtoc
+    BASIC_LDFLAGS_JVM_ONLY="-Wl,-lC_r -bbigtoc"
 
   elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
     BASIC_LDFLAGS="-nologo -opt:ref"
--- a/make/hotspot/lib/CompileGtest.gmk	Wed Jun 13 20:11:18 2018 +0200
+++ b/make/hotspot/lib/CompileGtest.gmk	Wed Jun 13 07:53:27 2018 +0200
@@ -55,13 +55,6 @@
 # Disabling undef, switch, format-nonliteral and tautological-undefined-compare
 # warnings for clang because of test source.
 
-# Note: On AIX, the gtest test classes linked into the libjvm.so push the TOC
-# size beyond 64k, so we need to link with bigtoc. However, this means that
-# -qpic=large would be advisable to lessen the performance effect of bigtoc.
-# But we want to avoid imposing -qpic=large onto the regular libjvm.so, which
-# has no problem with its TOC, so do this only for object files which are
-# exclusive to the gtest libjvm.so.
-
 $(eval $(call SetupNativeCompilation, BUILD_GTEST_LIBJVM, \
     NAME := jvm, \
     TOOLCHAIN := TOOLCHAIN_LINK_CXX, \
@@ -80,7 +73,6 @@
     CFLAGS_windows := -EHsc, \
     CFLAGS_solaris := -DGTEST_HAS_EXCEPTIONS=0 -library=stlport4, \
     CFLAGS_macosx := -DGTEST_OS_MAC=1, \
-    CFLAGS_aix := -qpic=large, \
     DISABLED_WARNINGS_gcc := undef, \
     DISABLED_WARNINGS_clang := undef switch format-nonliteral \
         tautological-undefined-compare $(BUILD_LIBJVM_DISABLED_WARNINGS_clang), \
@@ -88,7 +80,6 @@
     DISABLED_WARNINGS_CXX_microsoft := 4996, \
     LDFLAGS := $(JVM_LDFLAGS), \
     LDFLAGS_solaris := -library=stlport4 $(call SET_SHARED_LIBRARY_ORIGIN), \
-    LDFLAGS_aix := -bbigtoc, \
     LIBS := $(JVM_LIBS), \
     OPTIMIZATION := $(JVM_OPTIMIZATION), \
     MAPFILE := $(GTEST_JVM_MAPFILE), \