Cleaning up. ihse-cflags-rewrite-branch
authorihse
Tue, 20 Feb 2018 21:46:02 +0100
branchihse-cflags-rewrite-branch
changeset 56168 cb0b10e44247
parent 56162 d421dac1932f
child 56169 8ab1a1ee2af6
Cleaning up.
make/autoconf/flags-cflags.m4
make/autoconf/flags-ldflags.m4
make/autoconf/spec.gmk.in
make/common/NativeCompilation.gmk
--- a/make/autoconf/flags-cflags.m4	Tue Feb 20 21:30:05 2018 +0100
+++ b/make/autoconf/flags-cflags.m4	Tue Feb 20 21:46:02 2018 +0100
@@ -35,36 +35,20 @@
 AC_DEFUN([FLAGS_SETUP_SHARED_LIBS],
 [
   if test "x$TOOLCHAIN_TYPE" = xgcc; then
-    PICFLAG="-fPIC"
     C_FLAG_REORDER=''
-    CXX_FLAG_REORDER=''
+
+    # Default works for linux, might work on other platforms as well.
+    SHARED_LIBRARY_FLAGS='-shared'
+    SET_EXECUTABLE_ORIGIN='-Wl,-rpath,\$$ORIGIN[$]1'
+    SET_SHARED_LIBRARY_ORIGIN="-Wl,-z,origin $SET_EXECUTABLE_ORIGIN"
+    SET_SHARED_LIBRARY_NAME='-Wl,-soname=[$]1'
+    SET_SHARED_LIBRARY_MAPFILE='-Wl,-version-script=[$]1'
+
+  elif test "x$TOOLCHAIN_TYPE" = xclang; then
+    C_FLAG_REORDER=''
 
     if test "x$OPENJDK_TARGET_OS" = xmacosx; then
       # Linking is different on MacOSX
-      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 -fPIC"
-      fi
-      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'
-      SET_SHARED_LIBRARY_MAPFILE='-Wl,-exported_symbols_list,[$]1'
-    else
-      # Default works for linux, might work on other platforms as well.
-      SHARED_LIBRARY_FLAGS='-shared'
-      SET_EXECUTABLE_ORIGIN='-Wl,-rpath,\$$ORIGIN[$]1'
-      SET_SHARED_LIBRARY_ORIGIN="-Wl,-z,origin $SET_EXECUTABLE_ORIGIN"
-      SET_SHARED_LIBRARY_NAME='-Wl,-soname=[$]1'
-      SET_SHARED_LIBRARY_MAPFILE='-Wl,-version-script=[$]1'
-    fi
-  elif test "x$TOOLCHAIN_TYPE" = xclang; then
-    C_FLAG_REORDER=''
-    CXX_FLAG_REORDER=''
-
-    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"
       SET_EXECUTABLE_ORIGIN='-Wl,-rpath,@loader_path$(or [$]1,/.)'
       SET_SHARED_LIBRARY_ORIGIN="$SET_EXECUTABLE_ORIGIN"
@@ -73,7 +57,6 @@
 
     else
       # Default works for linux, might work on other platforms as well.
-      PICFLAG='-fPIC'
       SHARED_LIBRARY_FLAGS='-shared'
       SET_EXECUTABLE_ORIGIN='-Wl,-rpath,\$$ORIGIN[$]1'
       SET_SHARED_LIBRARY_NAME='-Wl,-soname=[$]1'
@@ -86,46 +69,26 @@
       else
         SET_SHARED_LIBRARY_ORIGIN="-Wl,-z,origin $SET_EXECUTABLE_ORIGIN"
       fi
+    fi
 
-    fi
   elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
-    if test "x$OPENJDK_TARGET_CPU" = xsparcv9; then
-      PICFLAG="-xcode=pic32"
-    else
-      PICFLAG="-KPIC"
-    fi
     C_FLAG_REORDER='-xF'
-    CXX_FLAG_REORDER='-xF'
     SHARED_LIBRARY_FLAGS="-G"
     SET_EXECUTABLE_ORIGIN='-R\$$ORIGIN[$]1'
     SET_SHARED_LIBRARY_ORIGIN="$SET_EXECUTABLE_ORIGIN"
     SET_SHARED_LIBRARY_NAME='-h [$]1'
     SET_SHARED_LIBRARY_MAPFILE='-M[$]1'
+
   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"
     C_FLAG_REORDER=''
-    CXX_FLAG_REORDER=''
     SHARED_LIBRARY_FLAGS="-qmkshrobj -bM:SRE -bnoentry"
     SET_EXECUTABLE_ORIGIN=""
     SET_SHARED_LIBRARY_ORIGIN=''
     SET_SHARED_LIBRARY_NAME=''
     SET_SHARED_LIBRARY_MAPFILE=''
+
   elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
-    PICFLAG=""
     C_FLAG_REORDER=''
-    CXX_FLAG_REORDER=''
     SHARED_LIBRARY_FLAGS="-dll"
     SET_EXECUTABLE_ORIGIN=''
     SET_SHARED_LIBRARY_ORIGIN=''
@@ -134,7 +97,6 @@
   fi
 
   AC_SUBST(C_FLAG_REORDER)
-  AC_SUBST(CXX_FLAG_REORDER)
   AC_SUBST(SET_EXECUTABLE_ORIGIN)
   AC_SUBST(SET_SHARED_LIBRARY_ORIGIN)
   AC_SUBST(SET_SHARED_LIBRARY_NAME)
@@ -178,7 +140,6 @@
       IF_TRUE: [HAS_CFLAG_OPTIMIZE_DEBUG=true],
       IF_FALSE: [HAS_CFLAG_OPTIMIZE_DEBUG=false])
   fi
-
 ])
 
 AC_DEFUN([FLAGS_SETUP_QUALITY_CHECKS],
@@ -200,7 +161,8 @@
       # Add runtime stack smashing and undefined behavior checks.
       # Not all versions of gcc support -fstack-protector
       STACK_PROTECTOR_CFLAG="-fstack-protector-all"
-      FLAGS_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [$STACK_PROTECTOR_CFLAG -Werror], IF_FALSE: [STACK_PROTECTOR_CFLAG=""])
+      FLAGS_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [$STACK_PROTECTOR_CFLAG -Werror],
+          IF_FALSE: [STACK_PROTECTOR_CFLAG=""])
 
       CFLAGS_DEBUG_OPTIONS="$STACK_PROTECTOR_CFLAG --param ssp-buffer-size=1"
       CXXFLAGS_DEBUG_OPTIONS="$STACK_PROTECTOR_CFLAG --param ssp-buffer-size=1"
@@ -229,7 +191,8 @@
       C_O_FLAG_HI="-xO4 -Wu,-O4~yz"
       C_O_FLAG_NORM="-xO2 -Wu,-O2~yz"
     elif test "x$OPENJDK_TARGET_CPU_ARCH" = "xsparc"; then
-      C_O_FLAG_HIGHEST="-xO4 -Wc,-Qrm-s -Wc,-Qiselect-T0 -xprefetch=auto,explicit -xchip=ultra $CC_HIGHEST"
+      C_O_FLAG_HIGHEST="-xO4 -Wc,-Qrm-s -Wc,-Qiselect-T0 \
+          -xprefetch=auto,explicit -xchip=ultra $CC_HIGHEST"
       C_O_FLAG_HI="-xO4 -Wc,-Qrm-s -Wc,-Qiselect-T0"
       C_O_FLAG_NORM="-xO2 -Wc,-Qrm-s -Wc,-Qiselect-T0"
     fi
--- a/make/autoconf/flags-ldflags.m4	Tue Feb 20 21:30:05 2018 +0100
+++ b/make/autoconf/flags-ldflags.m4	Tue Feb 20 21:46:02 2018 +0100
@@ -28,11 +28,10 @@
 
 AC_DEFUN([FLAGS_SETUP_LINKER_FLAGS_FOR_JDK],
 [
-  ### LINKER
-  ### COMMON LINKER FLAGS
   FLAGS_SETUP_LINKER_FLAGS_FOR_JDK_HELPER
 
-  # TARGET CHAIN
+  # Setup the target toolchain
+
   # 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
@@ -45,7 +44,7 @@
   fi
   FLAGS_SETUP_LINKER_FLAGS_FOR_JDK_CPU_DEP([TARGET])
 
-  # BUILD CHAIN
+  # Setup the build toolchain
 
   # When building a buildjdk, it's always only the server variant
   BUILD_JVM_VARIANT_PATH=server
@@ -60,10 +59,10 @@
 
 ################################################################################
 
-# CPU independent
+# CPU independent LDFLAGS setup, used for both target and build toolchain.
 AC_DEFUN([FLAGS_SETUP_LINKER_FLAGS_FOR_JDK_HELPER],
 [
-  # BASIC_LDFLAGS (per toolchain)
+  # Setup basic LDFLAGS
   if test "x$TOOLCHAIN_TYPE" = xgcc; then
     # "-z relro" supported in GNU binutils 2.17 and later
     LINKER_RELRO_FLAG="-Wl,-z,relro"
@@ -99,7 +98,9 @@
     fi
 
   elif test "x$TOOLCHAIN_TYPE" = xclang; then
-    BASIC_LDFLAGS_JVM_ONLY="-mno-omit-leaf-frame-pointer -mstack-alignment=16 -stdlib=libstdc++ -fPIC"
+    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"
@@ -107,16 +108,19 @@
 
     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"
+    BASIC_LDFLAGS="-b64 -brtl -bnolibpath -bexpall -bernotok -btextpsize:64K \
+        -bdatapsize:64K -bstackpsize:64K"
     BASIC_LDFLAGS_JVM_ONLY="-Wl,-lC_r"
+
   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
 
-  # OS_LDFLAGS (per toolchain)
+  # Setup OS-dependent LDFLAGS
   if test "x$TOOLCHAIN_TYPE" = xclang || test "x$TOOLCHAIN_TYPE" = xgcc; then
     if test "x$OPENJDK_TARGET_OS" = xmacosx; then
       # Assume clang or gcc.
@@ -126,7 +130,7 @@
     fi
   fi
 
-  # DEBUGLEVEL_LDFLAGS (per toolchain)
+  # Setup debug level-dependent LDFLAGS
   if test "x$TOOLCHAIN_TYPE" = xgcc; then
     if test "x$OPENJDK_TARGET_OS" = xlinux; then
        if test x$DEBUG_LEVEL = xrelease; then
@@ -144,6 +148,7 @@
           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),
@@ -153,12 +158,12 @@
     fi
   fi
 
-  # EXECUTABLE_LDFLAGS (per toolchain)
+  # Setup LDFLAGS for linking executables
   if test "x$TOOLCHAIN_TYPE" = xgcc; then
     EXECUTABLE_LDFLAGS="$EXECUTABLE_LDFLAGS -Wl,--allow-shlib-undefined"
   fi
 
-  # EXPORT to old api
+  # Export some intermediate variables for compatibility
   LDFLAGS_CXX_JDK="$BASIC_LDFLAGS_ONLYCXX $BASIC_LDFLAGS_ONLYCXX_JDK_ONLY"
   AC_SUBST(LDFLAGS_CXX_JDK)
   AC_SUBST(LIBJSIG_HASHSTYLE_LDFLAGS)
@@ -171,8 +176,8 @@
 # $2 - Optional prefix for each variable defined.
 AC_DEFUN([FLAGS_SETUP_LINKER_FLAGS_FOR_JDK_CPU_DEP],
 [
-  # CPU_LDFLAGS (per toolchain)
-  # These can differ between TARGET and BUILD.
+  # Setup CPU-dependent basic LDFLAGS. These can differ between the target and
+  # build toolchain.
   if test "x$TOOLCHAIN_TYPE" = xgcc; then
     if test "x${OPENJDK_$1_CPU}" = xx86; then
       $1_CPU_LDFLAGS_JVM_ONLY="-march=i586"
@@ -210,10 +215,13 @@
         -L\$(SUPPORT_OUTPUTDIR)/modules_libs/java.base/${$1_JVM_VARIANT_PATH}"
   fi
 
-  # 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} $SHARED_LIBRARY_FLAGS"
-  $2LDFLAGS_JDKEXE="$LDFLAGS_JDK_COMMON $EXECUTABLE_LDFLAGS ${$1_CPU_EXECUTABLE_LDFLAGS}"
+  # Export variables according to old definitions, 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} $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 \
       $DEBUGLEVEL_LDFLAGS $DEBUGLEVEL_LDFLAGS_JVM_ONLY $BASIC_LDFLAGS_ONLYCXX \
--- a/make/autoconf/spec.gmk.in	Tue Feb 20 21:30:05 2018 +0100
+++ b/make/autoconf/spec.gmk.in	Tue Feb 20 21:46:02 2018 +0100
@@ -524,7 +524,6 @@
 # Options for C/CXX compiler to be used if linking is performed
 #   using reorder file
 C_FLAG_REORDER:=@C_FLAG_REORDER@
-CXX_FLAG_REORDER:=@CXX_FLAG_REORDER@
 
 #
 # Options for generating debug symbols
--- a/make/common/NativeCompilation.gmk	Tue Feb 20 21:30:05 2018 +0100
+++ b/make/common/NativeCompilation.gmk	Tue Feb 20 21:46:02 2018 +0100
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -618,7 +618,7 @@
 
   ifneq (,$$($1_REORDER))
     $1_EXTRA_CFLAGS += $$(C_FLAG_REORDER)
-    $1_EXTRA_CXXFLAGS += $$(CXX_FLAG_REORDER)
+    $1_EXTRA_CXXFLAGS += $$(C_FLAG_REORDER)
   endif
 
   # Pass the library name for static JNI library naming