Sorting out LDFLAGS. ihse-cflags-rewrite-branch
authorihse
Fri, 16 Feb 2018 20:45:47 +0100
branchihse-cflags-rewrite-branch
changeset 56144 c9a52985c325
parent 56125 4e2422994c9e
child 56145 718aa4c360c4
Sorting out LDFLAGS.
make/autoconf/flags.m4
make/autoconf/spec.gmk.in
make/hotspot/lib/CompileLibjsig.gmk
--- a/make/autoconf/flags.m4	Wed Feb 14 14:31:00 2018 +0100
+++ b/make/autoconf/flags.m4	Fri Feb 16 20:45:47 2018 +0100
@@ -317,6 +317,37 @@
 
 AC_DEFUN([FLAGS_SETUP_COMPILER_FLAGS_FOR_JDK],
 [
+  # Additional macosx handling
+  if test "x$FLAGS_OS" = xmacosx; then
+    # MACOSX_VERSION_MIN specifies the lowest version of Macosx that the built
+    # binaries should be compatible with, even if compiled on a newer version
+    # of the OS. It currently has a hard coded value. Setting this also limits
+    # exposure to API changes in header files. Bumping this is likely to
+    # require code changes to build.
+    MACOSX_VERSION_MIN=10.7.0
+    AC_SUBST(MACOSX_VERSION_MIN)
+
+    # Setting --with-macosx-version-max=<version> makes it an error to build or
+    # link to macosx APIs that are newer than the given OS version. The expected
+    # format for <version> is either nn.n.n or nn.nn.nn. See /usr/include/AvailabilityMacros.h.
+    AC_ARG_WITH([macosx-version-max], [AS_HELP_STRING([--with-macosx-version-max],
+        [error on use of newer functionality. @<:@macosx@:>@])],
+        [
+          if echo "$with_macosx_version_max" | $GREP -q "^[[0-9]][[0-9]]\.[[0-9]]\.[[0-9]]\$"; then
+              MACOSX_VERSION_MAX=$with_macosx_version_max
+          elif echo "$with_macosx_version_max" | $GREP -q "^[[0-9]][[0-9]]\.[[0-9]][[0-9]]\.[[0-9]][[0-9]]\$"; then
+              MACOSX_VERSION_MAX=$with_macosx_version_max
+          elif test "x$with_macosx_version_max" = "xno"; then
+              # Use build system default
+              MACOSX_VERSION_MAX=
+          else
+              AC_MSG_ERROR([osx version format must be nn.n.n or nn.nn.nn])
+          fi
+        ],
+        [MACOSX_VERSION_MAX=]
+    )
+    AC_SUBST(MACOSX_VERSION_MAX)
+  fi
 
   FLAGS_SETUP_ABI_PROFILE
 
@@ -341,6 +372,17 @@
   FLAGS_CPU_LEGACY=OPENJDK_TARGET_CPU_LEGACY
   FLAGS_ADD_LP64=OPENJDK_TARGET_ADD_LP64
 
+  # On some platforms (mac) the linker warns about non existing -L dirs.
+  # For any of the variants server, client or minimal, the dir matches the
+  # variant name. The "main" variant should be used for linking. For the
+  # rest, the dir is just server.
+  if HOTSPOT_CHECK_JVM_VARIANT(server) || HOTSPOT_CHECK_JVM_VARIANT(client) \
+      || HOTSPOT_CHECK_JVM_VARIANT(minimal); then
+    JVM_VARIANT_PATH=$JVM_VARIANT_MAIN
+  else
+    JVM_VARIANT_PATH=server
+  fi
+
   FLAGS_SETUP_COMPILER_FLAGS_FOR_JDK_HELPER([TARGET])
 
   FLAGS_OS=OPENJDK_BUILD_OS
@@ -352,6 +394,9 @@
   FLAGS_CPU_LEGACY=OPENJDK_BUILD_CPU_LEGACY
   FLAGS_ADD_LP64=OPENJDK_BUILD_ADD_LP64=
 
+  # When building a buildjdk, it's always only the server variant
+  OPENJDK_BUILD_JVM_VARIANT_PATH=server
+
   FLAGS_SETUP_COMPILER_FLAGS_FOR_JDK_HELPER([BUILD], [OPENJDK_BUILD_])
 
   # Tests are only ever compiled for TARGET
@@ -410,6 +455,156 @@
   $2CXXFLAGS_JDK="${$2CXXFLAGS_JDK} ${$2EXTRA_CXXFLAGS}"
   $2LDFLAGS_JDK="${$2LDFLAGS_JDK} ${$2EXTRA_LDFLAGS}"
 
+
+  # PER TOOLCHAIN:
+    # LINKER_BASIC
+    # LINKER: shared-lib-special, exe-special
+    # LINKER: arch/cpu-special
+  # COMPILER-ARCH/CPU-special (-m, -f...)
+  # COMPILER-warnings
+  # COMPILER: shared-lib-special, exe-special
+
+  # LINKER LDFLAGS
+
+  # BASIC_LDFLAGS (per toolchain)
+  if test "x$TOOLCHAIN_TYPE" = xgcc; then
+    # If this is a --hash-style=gnu system, use --hash-style=both, why?
+    # We have previously set HAS_GNU_HASH if this is the case
+    if test -n "$HAS_GNU_HASH"; then
+      BASIC_LDFLAGS="-Wl,--hash-style=both"
+      LIBJSIG_HASHSTYLE_LDFLAGS="-Wl,--hash-style=both"
+      AC_SUBST(LIBJSIG_HASHSTYLE_LDFLAGS)
+    fi
+
+    # And since we now know that the linker is gnu, then add -z defs, to forbid
+    # undefined symbols in object files.
+    BASIC_LDFLAGS="$BASIC_LDFLAGS -Wl,-z,defs"
+
+    BASIC_LDFLAGS_JDK_ONLY=
+    BASIC_LDFLAGS_JVM_ONLY="-Wl,-z,noexecstack -Wl,-O1"
+
+    BASIC_LDFLAGS_JDK_LIB_ONLY="-Wl,-z,noexecstack"
+    LIBJSIG_NOEXECSTACK_LDFLAGS="-Wl,-z,noexecstack"
+
+
+    if test "x$HAS_LINKER_RELRO" = "xtrue"; then
+      BASIC_LDFLAGS_JVM_ONLY="$BASIC_LDFLAGS_JVM_ONLY $LINKER_RELRO_FLAG"
+    fi
+
+  elif test "x$TOOLCHAIN_TYPE" = xclang; then
+    BASIC_LDFLAGS_JVM_ONLY="-mno-omit-leaf-frame-pointer -mstack-alignment=16 -stdlib=libstdc++ -fPIC"
+  elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
+    BASIC_LDFLAGS="-Wl,-z,defs"
+    BASIC_LDFLAGS_ONLYCXX="-norunpath"
+    BASIC_LDFLAGS_ONLYCXX_JDK_ONLY="-xnolib"
+
+    BASIC_LDFLAGS_JDK_ONLY="-ztext"
+    BASIC_LDFLAGS_JVM_ONLY="-library=%none -mt -z noversion"
+  elif test "x$TOOLCHAIN_TYPE" = xxlc; then
+    BASIC_LDFLAGS="-b64 -brtl -bnolibpath -bexpall -bernotok -btextpsize:64K -bdatapsize:64K -bstackpsize:64K"
+  elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
+    BASIC_LDFLAGS="-nologo -opt:ref"
+    BASIC_LDFLAGS_JDK_ONLY="-incremental:no"
+    BASIC_LDFLAGS_JVM_ONLY="-opt:icf,8 -subsystem:windows -base:0x8000000"
+  fi
+  $2LDFLAGS_JDK="${$2LDFLAGS_JDK} ${BASIC_LDFLAGS}"
+  $2JVM_LDFLAGS="${$2JVM_LDFLAGS} ${BASIC_LDFLAGS} $BASIC_LDFLAGS_ONLYCXX"
+  $2LDFLAGS_CXX_JDK="[$]$2LDFLAGS_CXX_JDK $BASIC_LDFLAGS_ONLYCXX"
+
+  # CPU_LDFLAGS (per toolchain)
+  # This can differ between TARGET and BUILD.
+  if test "x$TOOLCHAIN_TYPE" = xgcc; then
+      if test "x$FLAGS_CPU" = xx86; then
+        $2_CPU_LDFLAGS_JVM_ONLY="-march=i586"
+      fi
+  elif test "x$TOOLCHAIN_TYPE" = xclang; then
+  elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
+    if test "x$FLAGS_CPU_ARCH" = "xsparc"; then
+      $2_CPU_LDFLAGS_JVM_ONLY="-xarch=sparc"
+    fi
+  elif test "x$TOOLCHAIN_TYPE" = xxlc; then
+  elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
+    if test "x$FLAGS_CPU" = "xx86"; then
+      $2_CPU_LDFLAGS="-safeseh"
+      # NOTE: Old build added -machine. Probably not needed.
+      $2_CPU_LDFLAGS_JVM_ONLY="-machine:I386"
+    else
+      $2_CPU_LDFLAGS_JVM_ONLY="-machine:AMD64"
+    fi
+    fi
+  fi
+  $2LDFLAGS_JDK="${$2LDFLAGS_JDK} ${$2_CPU_LDFLAGS}"
+  $2JVM_LDFLAGS="${$2JVM_LDFLAGS} ${$2_CPU_LDFLAGS} ${$2_CPU_LDFLAGS_JVM_ONLY}"
+
+  # OS_LDFLAGS (per toolchain)
+  if test "x$TOOLCHAIN_TYPE" = xclang || test "x$TOOLCHAIN_TYPE" = xgcc; then
+    if test "x$FLAGS_OS" = xmacosx; then
+      # Assume clang or gcc.
+      # FIXME: We should really generalize SET_SHARED_LIBRARY_ORIGIN instead.
+      OS_LDFLAGS_JVM_ONLY="[$]$2JVM_LDFLAGS -Wl,-rpath,@loader_path/. -Wl,-rpath,@loader_path/.."
+
+      OS_LDFLAGS_JDK_ONLY="[$]$2LDFLAGS_JDK -mmacosx-version-min=\$(MACOSX_VERSION_MIN)"
+    fi
+  fi
+  $2LDFLAGS_JDK="${$2LDFLAGS_JDK} ${$OS_LDFLAGS_JDK_ONLY}"
+  $2JVM_LDFLAGS="${$2JVM_LDFLAGS} ${$OS_LDFLAGS_JVM_ONLY}"
+
+  # DEBUGLEVEL_LDFLAGS (per toolchain)
+  if test "x$TOOLCHAIN_TYPE" = xgcc; then
+    if test "x$FLAGS_OS" = xlinux; then
+       if test x$DEBUG_LEVEL = xrelease; then
+          DEBUGLEVEL_LDFLAGS_JDK_ONLY="${$2LDFLAGS_JDK} -Wl,-O1"
+       else
+          # mark relocations read only on (fast/slow) debug builds
+          if test "x$HAS_LINKER_RELRO" = "xtrue"; then
+            DEBUGLEVEL_LDFLAGS_JDK_ONLY="$LINKER_RELRO_FLAG"
+          fi
+       fi
+       if test x$DEBUG_LEVEL = xslowdebug; then
+          if test "x$HAS_LINKER_NOW" = "xtrue"; then
+            # do relocations at load
+            DEBUGLEVEL_LDFLAGS="$LINKER_NOW_FLAG"
+          fi
+       fi
+    fi
+  elif test "x$TOOLCHAIN_TYPE" = xxlc; then
+    # We need '-qminimaltoc' or '-qpic=large -bbigtoc' if the TOC overflows.
+    # Hotspot now overflows its 64K TOC (currently only for debug),
+    # so we build with '-qpic=large -bbigtoc'.
+    if test "x$DEBUG_LEVEL" != xrelease; then
+      DEBUGLEVEL_LDFLAGS_JVM_ONLY="[$]$2JVM_LDFLAGS -bbigtoc"
+    fi
+  fi
+
+  # EXECUTABLE_LDFLAGS (per toolchain)
+  if test "x$TOOLCHAIN_TYPE" = xgcc; then
+    EXECUTABLE_LDFLAGS="[$]$2LDFLAGS_JDKEXE -Wl,--allow-shlib-undefined"
+  elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
+    if test "x$FLAGS_CPU" = "x86_64"; then
+      LDFLAGS_STACK_SIZE=1048576
+    else
+      LDFLAGS_STACK_SIZE=327680
+    fi
+    $2_CPU_EXECUTABLE_LDFLAGS="${$2LDFLAGS_JDKEXE} -stack:$LDFLAGS_STACK_SIZE"
+  fi
+  $2LDFLAGS_JDKEXE="${$2LDFLAGS_JDK}"
+  $2LDFLAGS_JDKEXE="${$2LDFLAGS_JDKEXE} ${$2EXTRA_LDFLAGS_JDK}"
+
+  # LIBRARY_LDFLAGS (per toolchain)
+  # Customize LDFLAGS for libs
+  if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
+    LDFLAGS_JDK_LIBPATH="-libpath:${OUTPUTDIR}/support/modules_libs/java.base"
+  else
+    LDFLAGS_JDK_LIBPATH="-L\$(SUPPORT_OUTPUTDIR)/modules_libs/java.base \
+        -L\$(SUPPORT_OUTPUTDIR)/modules_libs/java.base/${$2JVM_VARIANT_PATH}"
+  fi
+
+  LIBRARY_LDFLAGS_JDK_ONLY="${SHARED_LIBRARY_FLAGS} ${LDFLAGS_NO_EXEC_STACK} $LDFLAGS_JDK_LIBPATH ${$2EXTRA_LDFLAGS_JDK} $BASIC_LDFLAGS_JDK_LIB_ONLY"
+  $2LDFLAGS_JDKLIB="${LIBRARY_LDFLAGS_JDK_ONLY} "
+
+  # PER OS?
+    # LIBS: default libs
+
   ###############################################################################
   #
   # Now setup the CFLAGS and LDFLAGS for the JDK build.
@@ -690,41 +885,11 @@
 
   # Additional macosx handling
   if test "x$FLAGS_OS" = xmacosx; then
-    # MACOSX_VERSION_MIN specifies the lowest version of Macosx that the built
-    # binaries should be compatible with, even if compiled on a newer version
-    # of the OS. It currently has a hard coded value. Setting this also limits
-    # exposure to API changes in header files. Bumping this is likely to
-    # require code changes to build.
-    MACOSX_VERSION_MIN=10.7.0
-    AC_SUBST(MACOSX_VERSION_MIN)
-
-    # Setting --with-macosx-version-max=<version> makes it an error to build or
-    # link to macosx APIs that are newer than the given OS version. The expected
-    # format for <version> is either nn.n.n or nn.nn.nn. See /usr/include/AvailabilityMacros.h.
-    AC_ARG_WITH([macosx-version-max], [AS_HELP_STRING([--with-macosx-version-max],
-        [error on use of newer functionality. @<:@macosx@:>@])],
-        [
-          if echo "$with_macosx_version_max" | $GREP -q "^[[0-9]][[0-9]]\.[[0-9]]\.[[0-9]]\$"; then
-              MACOSX_VERSION_MAX=$with_macosx_version_max
-          elif echo "$with_macosx_version_max" | $GREP -q "^[[0-9]][[0-9]]\.[[0-9]][[0-9]]\.[[0-9]][[0-9]]\$"; then
-              MACOSX_VERSION_MAX=$with_macosx_version_max
-          elif test "x$with_macosx_version_max" = "xno"; then
-              # Use build system default
-              MACOSX_VERSION_MAX=
-          else
-              AC_MSG_ERROR([osx version format must be nn.n.n or nn.nn.nn])
-          fi
-        ],
-        [MACOSX_VERSION_MAX=]
-    )
-    AC_SUBST(MACOSX_VERSION_MAX)
-
     # Let the flags variables get resolved in make for easier override on make
     # command line. AvailabilityMacros.h versions have no dots, ex: 1070.
     $2COMMON_CCXXFLAGS_JDK="[$]$2COMMON_CCXXFLAGS_JDK \
         -DMAC_OS_X_VERSION_MIN_REQUIRED=\$(subst .,,\$(MACOSX_VERSION_MIN)) \
         -mmacosx-version-min=\$(MACOSX_VERSION_MIN)"
-    $2LDFLAGS_JDK="[$]$2LDFLAGS_JDK -mmacosx-version-min=\$(MACOSX_VERSION_MIN)"
     $2JVM_CFLAGS="[$]$2JVM_CFLAGS \
         -DMAC_OS_X_VERSION_MIN_REQUIRED=\$(subst .,,\$(MACOSX_VERSION_MIN)) \
         -mmacosx-version-min=\$(MACOSX_VERSION_MIN)"
@@ -763,171 +928,16 @@
   AC_SUBST($2CXXFLAGS_JDKLIB)
   AC_SUBST($2CXXFLAGS_JDKEXE)
 
-  # Setup LDFLAGS et al.
-  #
 
   if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
-    LDFLAGS_MICROSOFT="-nologo -opt:ref"
-    $2LDFLAGS_JDK="[$]$2LDFLAGS_JDK $LDFLAGS_MICROSOFT -incremental:no"
-    $2JVM_LDFLAGS="[$]$2JVM_LDFLAGS $LDFLAGS_MICROSOFT -opt:icf,8 -subsystem:windows -base:0x8000000"
-    if test "x$FLAGS_CPU_BITS" = "x32"; then
-      LDFLAGS_SAFESH="-safeseh"
-      $2LDFLAGS_JDK="[$]$2LDFLAGS_JDK $LDFLAGS_SAFESH"
-      $2JVM_LDFLAGS="[$]$2JVM_LDFLAGS $LDFLAGS_SAFESH"
-      # NOTE: Old build added -machine. Probably not needed.
-      $2JVM_LDFLAGS="[$]$2JVM_LDFLAGS -machine:I386"
-    else
-      $2JVM_LDFLAGS="[$]$2JVM_LDFLAGS -machine:AMD64"
-    fi
-  elif test "x$TOOLCHAIN_TYPE" = xclang; then
-      $2JVM_LDFLAGS="[$]$2JVM_LDFLAGS -mno-omit-leaf-frame-pointer -mstack-alignment=16 -stdlib=libstdc++ -fPIC"
-      if test "x$FLAGS_OS" = xmacosx; then
-        # FIXME: We should really generalize SET_SHARED_LIBRARY_ORIGIN instead.
-        $2JVM_LDFLAGS="[$]$2JVM_LDFLAGS -Wl,-rpath,@loader_path/. -Wl,-rpath,@loader_path/.."
-    fi
-  elif test "x$TOOLCHAIN_TYPE" = xgcc; then
-    # If this is a --hash-style=gnu system, use --hash-style=both, why?
-    # We have previously set HAS_GNU_HASH if this is the case
-    if test -n "$HAS_GNU_HASH"; then
-      $2LDFLAGS_HASH_STYLE="-Wl,--hash-style=both"
-      $2LDFLAGS_JDK="${$2LDFLAGS_JDK} [$]$2LDFLAGS_HASH_STYLE"
-      $2JVM_LDFLAGS="[$]$2JVM_LDFLAGS [$]$2LDFLAGS_HASH_STYLE"
-    fi
-      if test "x$FLAGS_OS" = xmacosx; then
-        $2JVM_LDFLAGS="[$]$2JVM_LDFLAGS -Wl,-rpath,@loader_path/. -Wl,-rpath,@loader_path/.."
-    fi
-    if test "x$FLAGS_OS" = xlinux; then
-      # And since we now know that the linker is gnu, then add -z defs, to forbid
-      # undefined symbols in object files.
-      LDFLAGS_NO_UNDEF_SYM="-Wl,-z,defs"
-      $2LDFLAGS_JDK="${$2LDFLAGS_JDK} $LDFLAGS_NO_UNDEF_SYM"
-      $2JVM_LDFLAGS="[$]$2JVM_LDFLAGS  $LDFLAGS_NO_UNDEF_SYM"
-      LDFLAGS_NO_EXEC_STACK="-Wl,-z,noexecstack"
-      $2JVM_LDFLAGS="[$]$2JVM_LDFLAGS $LDFLAGS_NO_EXEC_STACK"
-      if test "x$FLAGS_CPU" = xx86; then
-        $2JVM_LDFLAGS="[$]$2JVM_LDFLAGS -march=i586"
-      fi
-      case $DEBUG_LEVEL in
-        release )
-          # tell linker to optimize libraries.
-          # Should this be supplied to the OSS linker as well?
-          LDFLAGS_DEBUGLEVEL_release="-Wl,-O1"
-          $2LDFLAGS_JDK="${$2LDFLAGS_JDK} $LDFLAGS_DEBUGLEVEL_release"
-          $2JVM_LDFLAGS="[$]$2JVM_LDFLAGS $LDFLAGS_DEBUGLEVEL_release"
-          if test "x$HAS_LINKER_RELRO" = "xtrue"; then
-            $2JVM_LDFLAGS="[$]$2JVM_LDFLAGS $LINKER_RELRO_FLAG"
-          fi
-          ;;
-        slowdebug )
-          # Hotspot always let the linker optimize
-          $2JVM_LDFLAGS="[$]$2JVM_LDFLAGS -Wl,-O1"
-          if test "x$HAS_LINKER_NOW" = "xtrue"; then
-            # do relocations at load
-            $2LDFLAGS_JDK="[$]$2LDFLAGS_JDK $LINKER_NOW_FLAG"
-            $2LDFLAGS_CXX_JDK="[$]$2LDFLAGS_CXX_JDK $LINKER_NOW_FLAG"
-            $2JVM_LDFLAGS="[$]$2JVM_LDFLAGS $LINKER_NOW_FLAG"
-          fi
-          if test "x$HAS_LINKER_RELRO" = "xtrue"; then
-            # mark relocations read only
-            $2LDFLAGS_JDK="[$]$2LDFLAGS_JDK $LINKER_RELRO_FLAG"
-            $2LDFLAGS_CXX_JDK="[$]$2LDFLAGS_CXX_JDK $LINKER_RELRO_FLAG"
-            $2JVM_LDFLAGS="[$]$2JVM_LDFLAGS $LINKER_RELRO_FLAG"
-          fi
-          ;;
-        fastdebug )
-          # Hotspot always let the linker optimize
-          $2JVM_LDFLAGS="[$]$2JVM_LDFLAGS -Wl,-O1"
-          if test "x$HAS_LINKER_RELRO" = "xtrue"; then
-            # mark relocations read only
-            $2LDFLAGS_JDK="[$]$2LDFLAGS_JDK $LINKER_RELRO_FLAG"
-            $2LDFLAGS_CXX_JDK="[$]$2LDFLAGS_CXX_JDK $LINKER_RELRO_FLAG"
-            $2JVM_LDFLAGS="[$]$2JVM_LDFLAGS $LINKER_RELRO_FLAG"
-          fi
-          ;;
-        * )
-          AC_MSG_ERROR([Unrecognized \$DEBUG_LEVEL: $DEBUG_LEVEL])
-          ;;
-        esac
-    fi
-  elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
-    LDFLAGS_SOLSTUDIO="-Wl,-z,defs"
-    $2LDFLAGS_JDK="[$]$2LDFLAGS_JDK $LDFLAGS_SOLSTUDIO -ztext"
-    LDFLAGS_CXX_SOLSTUDIO="-norunpath"
-    $2LDFLAGS_CXX_JDK="[$]$2LDFLAGS_CXX_JDK $LDFLAGS_CXX_SOLSTUDIO -xnolib"
-    $2JVM_LDFLAGS="[$]$2JVM_LDFLAGS $LDFLAGS_SOLSTUDIO -library=%none -mt $LDFLAGS_CXX_SOLSTUDIO -z noversion"
-    if test "x$FLAGS_CPU_ARCH" = "xsparc"; then
-      $2JVM_LDFLAGS="[$]$2JVM_LDFLAGS -xarch=sparc"
-    fi
-  elif test "x$TOOLCHAIN_TYPE" = xxlc; then
-    LDFLAGS_XLC="-b64 -brtl -bnolibpath -bexpall -bernotok -btextpsize:64K -bdatapsize:64K -bstackpsize:64K"
-    $2LDFLAGS_JDK="${$2LDFLAGS_JDK} $LDFLAGS_XLC"
-    $2JVM_LDFLAGS="[$]$2JVM_LDFLAGS $LDFLAGS_XLC"
-    # We need '-qminimaltoc' or '-qpic=large -bbigtoc' if the TOC overflows.
-    # Hotspot now overflows its 64K TOC (currently only for debug),
-    # so we build with '-qpic=large -bbigtoc'.
-    if test "x$DEBUG_LEVEL" = xslowdebug || test "x$DEBUG_LEVEL" = xfastdebug; then
-      $2JVM_LDFLAGS="[$]$2JVM_LDFLAGS -bbigtoc"
-    fi
-  fi
-
-  # Customize LDFLAGS for executables
-
-  $2LDFLAGS_JDKEXE="${$2LDFLAGS_JDK}"
-
-  if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
-    if test "x$FLAGS_CPU_BITS" = "x64"; then
-      LDFLAGS_STACK_SIZE=1048576
-    else
-      LDFLAGS_STACK_SIZE=327680
-    fi
-    $2LDFLAGS_JDKEXE="${$2LDFLAGS_JDKEXE} /STACK:$LDFLAGS_STACK_SIZE"
-  elif test "x$FLAGS_OS" = xlinux; then
-    $2LDFLAGS_JDKEXE="[$]$2LDFLAGS_JDKEXE -Wl,--allow-shlib-undefined"
-  fi
-
-  $2LDFLAGS_JDKEXE="${$2LDFLAGS_JDKEXE} ${$2EXTRA_LDFLAGS_JDK}"
-
-  # Customize LDFLAGS for libs
-  $2LDFLAGS_JDKLIB="${$2LDFLAGS_JDK}"
-
-  $2LDFLAGS_JDKLIB="${$2LDFLAGS_JDKLIB} ${SHARED_LIBRARY_FLAGS}"
-  $2LDFLAGS_JDKLIB="${$2LDFLAGS_JDKLIB} ${LDFLAGS_NO_EXEC_STACK}"
-  if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
-    $2JAVA_BASE_LDFLAGS="${$2JAVA_BASE_LDFLAGS} \
-        -libpath:${OUTPUTDIR}/support/modules_libs/java.base"
     $2JDKLIB_LIBS=""
   else
-    $2JAVA_BASE_LDFLAGS="${$2JAVA_BASE_LDFLAGS} \
-        -L\$(SUPPORT_OUTPUTDIR)/modules_libs/java.base"
-
-    if test "x$1" = "xTARGET"; then
-      # On some platforms (mac) the linker warns about non existing -L dirs.
-      # For any of the variants server, client or minimal, the dir matches the
-      # variant name. The "main" variant should be used for linking. For the
-      # rest, the dir is just server.
-      if HOTSPOT_CHECK_JVM_VARIANT(server) || HOTSPOT_CHECK_JVM_VARIANT(client) \
-          || HOTSPOT_CHECK_JVM_VARIANT(minimal); then
-        $2JAVA_BASE_LDFLAGS="${$2JAVA_BASE_LDFLAGS} \
-            -L\$(SUPPORT_OUTPUTDIR)/modules_libs/java.base/$JVM_VARIANT_MAIN"
-      else
-        $2JAVA_BASE_LDFLAGS="${$2JAVA_BASE_LDFLAGS} \
-            -L\$(SUPPORT_OUTPUTDIR)/modules_libs/java.base/server"
-      fi
-    elif test "x$1" = "xBUILD"; then
-      # When building a buildjdk, it's always only the server variant
-      $2JAVA_BASE_LDFLAGS="${$2JAVA_BASE_LDFLAGS} \
-          -L\$(SUPPORT_OUTPUTDIR)/modules_libs/java.base/server"
-    fi
-
     $2JDKLIB_LIBS="-ljava -ljvm"
     if test "x$TOOLCHAIN_TYPE" = xsolstudio; then
       $2JDKLIB_LIBS="[$]$2JDKLIB_LIBS -lc"
     fi
-
   fi
 
-  $2LDFLAGS_JDKLIB="${$2LDFLAGS_JDKLIB} ${$2JAVA_BASE_LDFLAGS}"
-
   # Set $2JVM_LIBS (per os)
   if test "x$FLAGS_OS" = xlinux; then
     $2JVM_LIBS="[$]$2JVM_LIBS -lm -ldl -lpthread"
@@ -961,8 +971,6 @@
     $2JVM_ASFLAGS="[$]$2JVM_ASFLAGS -x assembler-with-cpp -mno-omit-leaf-frame-pointer -mstack-alignment=16"
   fi
 
-  $2LDFLAGS_JDKLIB="${$2LDFLAGS_JDKLIB} ${$2EXTRA_LDFLAGS_JDK}"
-
   AC_SUBST($2LDFLAGS_JDKLIB)
   AC_SUBST($2LDFLAGS_JDKEXE)
   AC_SUBST($2JDKLIB_LIBS)
--- a/make/autoconf/spec.gmk.in	Wed Feb 14 14:31:00 2018 +0100
+++ b/make/autoconf/spec.gmk.in	Fri Feb 16 20:45:47 2018 +0100
@@ -436,8 +436,8 @@
 CFLAGS_JDKEXE:=@CFLAGS_JDKEXE@
 CXXFLAGS_JDKEXE:=@CXXFLAGS_JDKEXE@
 
-LDFLAGS_HASH_STYLE := @LDFLAGS_HASH_STYLE@
-LDFLAGS_NO_EXEC_STACK := @LDFLAGS_NO_EXEC_STACK@
+LIBJSIG_HASHSTYLE_LDFLAGS := @LIBJSIG_HASHSTYLE_LDFLAGS@
+LIBJSIG_NOEXECSTACK_LDFLAGS := @LIBJSIG_NOEXECSTACK_LDFLAGS@
 
 JVM_CFLAGS := @JVM_CFLAGS@
 JVM_CFLAGS_SYMBOLS := @JVM_CFLAGS_SYMBOLS@
--- a/make/hotspot/lib/CompileLibjsig.gmk	Wed Feb 14 14:31:00 2018 +0100
+++ b/make/hotspot/lib/CompileLibjsig.gmk	Fri Feb 16 20:45:47 2018 +0100
@@ -36,7 +36,7 @@
   ifeq ($(STATIC_BUILD), false)
     ifeq ($(OPENJDK_TARGET_OS), linux)
       LIBJSIG_CFLAGS := -fPIC -D_GNU_SOURCE -D_REENTRANT $(EXTRA_CFLAGS)
-      LIBJSIG_LDFLAGS := $(LDFLAGS_HASH_STYLE) ${LDFLAGS_NO_EXEC_STACK} $(EXTRA_CFLAGS)
+      LIBJSIG_LDFLAGS := $(LIBJSIG_HASHSTYLE_LDFLAGS) ${LIBJSIG_NOEXECSTACK_LDFLAGS} $(EXTRA_CFLAGS)
       LIBJSIG_LIBS := $(LIBDL)
 
       # NOTE: The old build compiled this library without -soname.
@@ -76,7 +76,7 @@
 
     else ifeq ($(OPENJDK_TARGET_OS), macosx)
       LIBJSIG_CFLAGS := -m64 -D_GNU_SOURCE -pthread -mno-omit-leaf-frame-pointer -mstack-alignment=16 -fPIC
-      LIBJSIG_LDFLAGS := $(LDFLAGS_HASH_STYLE)
+      LIBJSIG_LDFLAGS := $(LIBJSIG_HASHSTYLE_LDFLAGS)
     else
       $(error Unknown target OS $(OPENJDK_TARGET_OS) in CompileLibjsig.gmk)
     endif