Fixing PIC-flag issues, and all remaining differences on linux_x64. ihse-cflags-rewrite-branch
authorihse
Tue, 20 Feb 2018 12:05:50 +0100 (2018-02-20)
branchihse-cflags-rewrite-branch
changeset 56158 97b2b2de66f2
parent 56155 f98e22c513dd
child 56161 a7585ecb9fc2
Fixing PIC-flag issues, and all remaining differences on linux_x64.
make/autoconf/flags-cflags.m4
make/autoconf/flags-ldflags.m4
make/autoconf/flags.m4
make/autoconf/libraries.m4
--- a/make/autoconf/flags-cflags.m4	Mon Feb 19 23:25:11 2018 +0100
+++ b/make/autoconf/flags-cflags.m4	Tue Feb 20 12:05:50 2018 +0100
@@ -44,7 +44,7 @@
       if test "x$STATIC_BUILD" = xtrue; then
         SHARED_LIBRARY_FLAGS ='-undefined dynamic_lookup'
       else
-        SHARED_LIBRARY_FLAGS="-dynamiclib -compatibility_version 1.0.0 -current_version 1.0.0 $PICFLAG"
+        SHARED_LIBRARY_FLAGS="-dynamiclib -compatibility_version 1.0.0 -current_version 1.0.0 -fPIC"
       fi
       SET_EXECUTABLE_ORIGIN='-Wl,-rpath,@loader_path$(or [$]1,/.)'
       SET_SHARED_LIBRARY_ORIGIN="$SET_EXECUTABLE_ORIGIN"
@@ -65,7 +65,7 @@
     if test "x$OPENJDK_TARGET_OS" = xmacosx; then
       # Linking is different on MacOSX
       PICFLAG=''
-      SHARED_LIBRARY_FLAGS="-dynamiclib -compatibility_version 1.0.0 -current_version 1.0.0 $PICFLAG"
+      SHARED_LIBRARY_FLAGS="-dynamiclib -compatibility_version 1.0.0 -current_version 1.0.0"
       SET_EXECUTABLE_ORIGIN='-Wl,-rpath,@loader_path$(or [$]1,/.)'
       SET_SHARED_LIBRARY_ORIGIN="$SET_EXECUTABLE_ORIGIN"
       SET_SHARED_LIBRARY_NAME='-Wl,-install_name,@rpath/[$]1'
--- a/make/autoconf/flags-ldflags.m4	Mon Feb 19 23:25:11 2018 +0100
+++ b/make/autoconf/flags-ldflags.m4	Tue Feb 20 12:05:50 2018 +0100
@@ -192,7 +192,7 @@
 
   # Export to old API, prefix with $2 if present
   LDFLAGS_JDK_COMMON="$BASIC_LDFLAGS $BASIC_LDFLAGS_JDK_ONLY $OS_LDFLAGS_JDK_ONLY $DEBUGLEVEL_LDFLAGS_JDK_ONLY $EXTRA_LDFLAGS"
-  $2LDFLAGS_JDKLIB="$LDFLAGS_JDK_COMMON $BASIC_LDFLAGS_JDK_LIB_ONLY ${$1_LDFLAGS_JDK_LIBPATH}"
+  $2LDFLAGS_JDKLIB="$LDFLAGS_JDK_COMMON $BASIC_LDFLAGS_JDK_LIB_ONLY ${$1_LDFLAGS_JDK_LIBPATH} $SHARED_LIBRARY_FLAGS"
   $2LDFLAGS_JDKEXE="$LDFLAGS_JDK_COMMON $EXECUTABLE_LDFLAGS ${$1_CPU_EXECUTABLE_LDFLAGS}"
 
   $2JVM_LDFLAGS="$BASIC_LDFLAGS $BASIC_LDFLAGS_JVM_ONLY $OS_LDFLAGS_JVM_ONLY \
--- a/make/autoconf/flags.m4	Mon Feb 19 23:25:11 2018 +0100
+++ b/make/autoconf/flags.m4	Tue Feb 20 12:05:50 2018 +0100
@@ -231,22 +231,6 @@
 [
   FLAGS_SETUP_SHARED_LIBS
 
-  if test "x$TOOLCHAIN_TYPE" = xgcc; then
-    if test "x$OPENJDK_TARGET_OS" = xmacosx; then
-      if test "x$STATIC_BUILD" = xfalse; then
-        JVM_CFLAGS="$JVM_CFLAGS $PICFLAG"
-      fi
-    fi
-  elif test "x$TOOLCHAIN_TYPE" = xclang; then
-    if test "x$OPENJDK_TARGET_OS" = xmacosx; then
-      if test "x$STATIC_BUILD" = xfalse; then
-        JVM_CFLAGS="$JVM_CFLAGS -fPIC"
-      fi
-    fi
-  elif test "x$TOOLCHAIN_TYPE" = xxlc; then
-    JVM_CFLAGS="$JVM_CFLAGS $PICFLAG"
-  fi
-
 
   # The (cross) compiler is now configured, we can now test capabilities
   # of the target platform.
@@ -547,7 +531,7 @@
     TOOLCHAIN_CFLAGS_JDK="mt"
     TOOLCHAIN_CFLAGS_JDK_CONLY="-xc99=%none -xCC -Xa -v -W0,-noglobal" # C only
     TOOLCHAIN_CFLAGS_JDK_CXXONLY="-features=no%except -norunpath -xnolib" # CXX only
-    TOOLCHAIN_CFLAGS_JVM="$PICFLAG -template=no%extdef -features=no%split_init \
+    TOOLCHAIN_CFLAGS_JVM="-template=no%extdef -features=no%split_init \
         -library=stlport4 -mt -features=no%except"
   elif test "x$TOOLCHAIN_TYPE" = xxlc; then
     TOOLCHAIN_CFLAGS_JDK="-qchars=signed -qfullpath -qsaveopt"  # add on both CFLAGS
@@ -609,9 +593,40 @@
   fi
 
   # Where does this really belong??
-  if test "x$OPENJDK_TARGET_OS" = xlinux; then
-    OS_CFLAGS_JVM="$OS_CFLAGS_JVM $PICFLAG"
-  elif test "x$OPENJDK_TARGET_OS" = xmacosx; then
+  if test "x$TOOLCHAIN_TYPE" = xgcc || test "x$TOOLCHAIN_TYPE" = xclang; then
+    PICFLAG="-fPIC"
+  elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
+    PICFLAG="-KPIC"
+  elif test "x$TOOLCHAIN_TYPE" = xxlc; then
+    # '-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
+    # 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"
+  elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
+    PICFLAG=""
+  fi
+
+  JVM_PICFLAG="$PICFLAG"
+  JDK_PICFLAG="$PICFLAG"
+
+  if test "x$OPENJDK_TARGET_OS" = xmacosx; then
+    # Linking is different on MacOSX
+    JDK_PICFLAG=''
+    if test "x$STATIC_BUILD" = xtrue; then
+      JVM_PICFLAG=""
+    fi
+  fi
+
+  if test "x$OPENJDK_TARGET_OS" = xmacosx; then
     OS_CFLAGS_JVM="$OS_CFLAGS_JVM -mno-omit-leaf-frame-pointer -mstack-alignment=16"
   fi
   # Optional POSIX functionality needed by the VM
@@ -647,7 +662,7 @@
   fi
 
   # setup CPU bit size
-  $1_DEFINES_CPU_JDK="$FLAGS_ADD_LP64 \
+  $1_DEFINES_CPU_JDK="${$1_DEFINES_CPU_JDK} $FLAGS_ADD_LP64 \
       -DARCH='\"$FLAGS_CPU_LEGACY\"' -D$FLAGS_CPU_LEGACY"
 
   if test "x$FLAGS_CPU_BITS" = x64; then
@@ -746,7 +761,7 @@
   # EXPORT to API
   CFLAGS_JVM_COMMON="$ALWAYS_CFLAGS_JVM $ALWAYS_DEFINES_JVM $TOOLCHAIN_CFLAGS_JVM \
       $OS_CFLAGS $OS_CFLAGS_JVM $CFLAGS_OS_DEF_JVM $DEBUG_CFLAGS_JVM \
-      $WARNING_CFLAGS $WARNING_CFLAGS_JVM"
+      $WARNING_CFLAGS $WARNING_CFLAGS_JVM $JVM_PICFLAG"
 
   CFLAGS_JDK_COMMON="$ALWAYS_CFLAGS_JDK $ALWAYS_DEFINES_JDK $TOOLCHAIN_CFLAGS_JDK \
       $OS_CFLAGS $CFLAGS_OS_DEF_JDK $DEBUG_CFLAGS_JDK $DEBUG_SYMBOLS_CFLAGS_JDK \
@@ -763,8 +778,8 @@
 
   $2CFLAGS_JDKEXE="$CFLAGS_JDK_COMMON $CFLAGS_JDK_COMMON_CONLY ${$1_CFLAGS_JDK}"
   $2CXXFLAGS_JDKEXE="$CFLAGS_JDK_COMMON $CFLAGS_JDK_COMMON_CXXONLY ${$1_CFLAGS_JDK}"
-  $2CFLAGS_JDKLIB="${$2CFLAGS_JDKEXE} $PICFLAG"
-  $2CXXFLAGS_JDKLIB="${$2CXXFLAGS_JDKEXE} $PICFLAG"
+  $2CFLAGS_JDKLIB="${$2CFLAGS_JDKEXE} $JDK_PICFLAG"
+  $2CXXFLAGS_JDKLIB="${$2CXXFLAGS_JDKEXE} $JDK_PICFLAG"
 
   AC_SUBST($2JVM_CFLAGS)
   AC_SUBST($2CFLAGS_JDKLIB)
--- a/make/autoconf/libraries.m4	Mon Feb 19 23:25:11 2018 +0100
+++ b/make/autoconf/libraries.m4	Tue Feb 20 12:05:50 2018 +0100
@@ -153,9 +153,16 @@
   BASIC_JVM_LIBS="$BASIC_JVM_LIBS $ALWAYS_LIBS"
 
   JDKLIB_LIBS="$BASIC_JDKLIB_LIBS"
+  JDKEXE_LIBS=""
   JVM_LIBS="$BASIC_JVM_LIBS"
   OPENJDK_BUILD_JDKLIB_LIBS="$BASIC_JDKLIB_LIBS"
   OPENJDK_BUILD_JVM_LIBS="$BASIC_JVM_LIBS"
+
+  AC_SUBST(JDKLIB_LIBS)
+  AC_SUBST(JDKEXE_LIBS)
+  AC_SUBST(JVM_LIBS)
+  AC_SUBST(OPENJDK_BUILD_JDKLIB_LIBS)
+  AC_SUBST(OPENJDK_BUILD_JVM_LIBS)
 ])
 
 ################################################################################