Trying to sort out EXTRA_CFLAGS. Moving all flag handling to flags.m4. ihse-cflags-rewrite-branch
authorihse
Tue, 20 Feb 2018 20:41:51 +0100
branchihse-cflags-rewrite-branch
changeset 56161 a7585ecb9fc2
parent 56158 97b2b2de66f2
child 56162 d421dac1932f
Trying to sort out EXTRA_CFLAGS. Moving all flag handling to flags.m4.
make/autoconf/configure.ac
make/autoconf/flags-cflags.m4
make/autoconf/flags-ldflags.m4
make/autoconf/flags.m4
make/autoconf/hotspot.m4
make/autoconf/libraries.m4
make/autoconf/platform.m4
make/autoconf/toolchain.m4
--- a/make/autoconf/configure.ac	Tue Feb 20 12:05:50 2018 +0100
+++ b/make/autoconf/configure.ac	Tue Feb 20 20:41:51 2018 +0100
@@ -167,6 +167,7 @@
 FLAGS_SETUP_USER_SUPPLIED_FLAGS
 # The sysroot cflags are needed for configure to be able to run the compilers
 FLAGS_SETUP_SYSROOT_FLAGS
+FLAGS_SETUP_GLOBAL_FLAGS
 
 # Then detect the actual binaries needed
 TOOLCHAIN_PRE_DETECTION
@@ -196,6 +197,17 @@
 FLAGS_SETUP_COMPILER_FLAGS_FOR_JDK
 FLAGS_SETUP_COMPILER_FLAGS_MISC
 
+#FIXME: REMOVE
+JVM_CFLAGS=`$ECHO $JVM_CFLAGS | $TR ' ' '\n' | $SORT | $TR '\n' ' '`
+CFLAGS_JDKLIB=`$ECHO $CFLAGS_JDKLIB | $TR ' ' '\n' | $SORT | $TR '\n' ' '`
+CFLAGS_JDKEXE=`$ECHO $CFLAGS_JDKEXE | $TR ' ' '\n' | $SORT | $TR '\n' ' '`
+CXXFLAGS_JDKLIB=`$ECHO $CXXFLAGS_JDKLIB | $TR ' ' '\n' | $SORT | $TR '\n' ' '`
+CXXFLAGS_JDKEXE=`$ECHO $CXXFLAGS_JDKEXE | $TR ' ' '\n' | $SORT | $TR '\n' ' '`
+
+JVM_LDFLAGS=`$ECHO $JVM_LDFLAGS | $TR ' ' '\n' | $SORT | $TR '\n' ' '`
+LDFLAGS_JDKLIB=`$ECHO $LDFLAGS_JDKLIB | $TR ' ' '\n' | $SORT | $TR '\n' ' '`
+LDFLAGS_JDKEXE=`$ECHO $LDFLAGS_JDKEXE | $TR ' ' '\n' | $SORT | $TR '\n' ' '`
+
 # Setup debug symbols (need objcopy from the toolchain for that)
 JDKOPT_SETUP_DEBUG_SYMBOLS
 JDKOPT_SETUP_CODE_COVERAGE
--- a/make/autoconf/flags-cflags.m4	Tue Feb 20 12:05:50 2018 +0100
+++ b/make/autoconf/flags-cflags.m4	Tue Feb 20 20:41:51 2018 +0100
@@ -169,6 +169,16 @@
   fi
   AC_SUBST(CFLAGS_DEBUG_SYMBOLS)
   AC_SUBST(CXXFLAGS_DEBUG_SYMBOLS)
+
+  # FIXME: This was never used in the old build. What to do with it?
+  if test "x$TOOLCHAIN_TYPE" = xgcc; then
+    # "-Og" suppported for GCC 4.8 and later
+    CFLAG_OPTIMIZE_DEBUG_FLAG="-Og"
+    FLAGS_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [$CFLAG_OPTIMIZE_DEBUG_FLAG],
+      IF_TRUE: [HAS_CFLAG_OPTIMIZE_DEBUG=true],
+      IF_FALSE: [HAS_CFLAG_OPTIMIZE_DEBUG=false])
+  fi
+
 ])
 
 AC_DEFUN([FLAGS_SETUP_QUALITY_CHECKS],
--- a/make/autoconf/flags-ldflags.m4	Tue Feb 20 12:05:50 2018 +0100
+++ b/make/autoconf/flags-ldflags.m4	Tue Feb 20 20:41:51 2018 +0100
@@ -65,6 +65,18 @@
 [
   # BASIC_LDFLAGS (per toolchain)
   if test "x$TOOLCHAIN_TYPE" = xgcc; then
+    # "-z relro" supported in GNU binutils 2.17 and later
+    LINKER_RELRO_FLAG="-Wl,-z,relro"
+    FLAGS_LINKER_CHECK_ARGUMENTS(ARGUMENT: [$LINKER_RELRO_FLAG],
+      IF_TRUE: [HAS_LINKER_RELRO=true],
+      IF_FALSE: [HAS_LINKER_RELRO=false])
+
+    # "-z now" supported in GNU binutils 2.11 and later
+    LINKER_NOW_FLAG="-Wl,-z,now"
+    FLAGS_LINKER_CHECK_ARGUMENTS(ARGUMENT: [$LINKER_NOW_FLAG],
+      IF_TRUE: [HAS_LINKER_NOW=true],
+      IF_FALSE: [HAS_LINKER_NOW=false])
+
     # 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
@@ -162,24 +174,32 @@
   # CPU_LDFLAGS (per toolchain)
   # These can differ between TARGET and BUILD.
   if test "x$TOOLCHAIN_TYPE" = xgcc; then
-      if test "x${OPENJDK_$1_CPU}" = xx86; then
-        $1_CPU_LDFLAGS_JVM_ONLY="-march=i586"
+    if test "x${OPENJDK_$1_CPU}" = xx86; then
+      $1_CPU_LDFLAGS_JVM_ONLY="-march=i586"
+    elif test "x$OPENJDK_$1_CPU" = xarm; then
+      $1_CPU_LDFLAGS_JVM_ONLY="${$1_CPU_LDFLAGS_JVM_ONLY} -fsigned-char"
+      $1_CPU_LDFLAGS="$ARM_ARCH_TYPE_FLAGS $ARM_FLOAT_TYPE_FLAGS"
+    elif test "x$FLAGS_CPU" = xaarch64; then
+      if test "x$HOTSPOT_TARGET_CPU_PORT" = xarm64; then
+        $1_CPU_LDFLAGS_JVM_ONLY="${$1_CPU_LDFLAGS_JVM_ONLY} -fsigned-char"
       fi
+    fi
+
   elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
     if test "x${OPENJDK_$1_CPU}" = "xsparcv9"; then
       $1_CPU_LDFLAGS_JVM_ONLY="-xarch=sparc"
     fi
+
   elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
     if test "x${OPENJDK_$1_CPU}" = "xx86"; then
       $1_CPU_LDFLAGS="-safeseh"
       # NOTE: Old build added -machine. Probably not needed.
       $1_CPU_LDFLAGS_JVM_ONLY="-machine:I386"
-      LDFLAGS_STACK_SIZE=327680
+      $1_CPU_EXECUTABLE_LDFLAGS="-stack:327680"
     else
       $1_CPU_LDFLAGS_JVM_ONLY="-machine:AMD64"
-      LDFLAGS_STACK_SIZE=1048576
+      $1_CPU_EXECUTABLE_LDFLAGS="-stack:1048576"
     fi
-    $1_CPU_EXECUTABLE_LDFLAGS="-stack:$LDFLAGS_STACK_SIZE"
   fi
 
   # JVM_VARIANT_PATH depends on if this is build or target...
--- a/make/autoconf/flags.m4	Tue Feb 20 12:05:50 2018 +0100
+++ b/make/autoconf/flags.m4	Tue Feb 20 20:41:51 2018 +0100
@@ -98,15 +98,6 @@
     AC_MSG_CHECKING([for ABI property name])
     AC_MSG_RESULT([$JDK_ARCH_ABI_PROP_NAME])
     AC_SUBST(JDK_ARCH_ABI_PROP_NAME)
-
-    # Pass these on to the open part of configure as if they were set using
-    # --with-extra-c[xx]flags.
-    EXTRA_CFLAGS="$EXTRA_CFLAGS $ARM_ARCH_TYPE_FLAGS $ARM_FLOAT_TYPE_FLAGS"
-    EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS $ARM_ARCH_TYPE_FLAGS $ARM_FLOAT_TYPE_FLAGS"
-    # Also add JDK_ARCH_ABI_PROP_NAME define, but only to CFLAGS.
-    EXTRA_CFLAGS="$EXTRA_CFLAGS -DJDK_ARCH_ABI_PROP_NAME='\"\$(JDK_ARCH_ABI_PROP_NAME)\"'"
-    # And pass the architecture flags to the linker as well
-    EXTRA_LDFLAGS="$EXTRA_LDFLAGS $ARM_ARCH_TYPE_FLAGS $ARM_FLOAT_TYPE_FLAGS"
   fi
 
   # When building with an abi profile, the name of that profile is appended on the
@@ -120,15 +111,15 @@
 # corresponding configure arguments instead
 AC_DEFUN_ONCE([FLAGS_SETUP_USER_SUPPLIED_FLAGS],
 [
-  if test "x$CFLAGS" != "x${ADDED_CFLAGS}"; then
+  if test "x$CFLAGS" != "x"; then
     AC_MSG_WARN([Ignoring CFLAGS($CFLAGS) found in environment. Use --with-extra-cflags])
   fi
 
-  if test "x$CXXFLAGS" != "x${ADDED_CXXFLAGS}"; then
+  if test "x$CXXFLAGS" != "x"; then
     AC_MSG_WARN([Ignoring CXXFLAGS($CXXFLAGS) found in environment. Use --with-extra-cxxflags])
   fi
 
-  if test "x$LDFLAGS" != "x${ADDED_LDFLAGS}"; then
+  if test "x$LDFLAGS" != "x"; then
     AC_MSG_WARN([Ignoring LDFLAGS($LDFLAGS) found in environment. Use --with-extra-ldflags])
   fi
 
@@ -141,20 +132,9 @@
   AC_ARG_WITH(extra-ldflags, [AS_HELP_STRING([--with-extra-ldflags],
       [extra flags to be used when linking jdk])])
 
-  EXTRA_CFLAGS="$with_extra_cflags"
-  EXTRA_CXXFLAGS="$with_extra_cxxflags"
-  EXTRA_LDFLAGS="$with_extra_ldflags"
-
-  AC_SUBST(EXTRA_CFLAGS)
-  AC_SUBST(EXTRA_CXXFLAGS)
-  AC_SUBST(EXTRA_LDFLAGS)
-
-  # The global CFLAGS and LDLAGS variables are used by configure tests and
-  # should include the extra parameters
-  CFLAGS="$EXTRA_CFLAGS"
-  CXXFLAGS="$EXTRA_CXXFLAGS"
-  LDFLAGS="$EXTRA_LDFLAGS"
-  CPPFLAGS=""
+  USER_CFLAGS="$with_extra_cflags"
+  USER_CXXFLAGS="$with_extra_cxxflags"
+  USER_LDFLAGS="$with_extra_ldflags"
 ])
 
 # Setup the sysroot flags and add them to global CFLAGS and LDFLAGS so
@@ -191,11 +171,6 @@
       $1SYSROOT_CFLAGS="-isysroot [$]$1SYSROOT"
       $1SYSROOT_LDFLAGS="-isysroot [$]$1SYSROOT"
     fi
-    # The global CFLAGS and LDFLAGS variables need these for configure to function
-    $1CFLAGS="[$]$1CFLAGS [$]$1SYSROOT_CFLAGS"
-    $1CPPFLAGS="[$]$1CPPFLAGS [$]$1SYSROOT_CFLAGS"
-    $1CXXFLAGS="[$]$1CXXFLAGS [$]$1SYSROOT_CFLAGS"
-    $1LDFLAGS="[$]$1LDFLAGS [$]$1SYSROOT_LDFLAGS"
   fi
 
   if test "x$OPENJDK_TARGET_OS" = xmacosx; then
@@ -212,6 +187,44 @@
   AC_SUBST($1SYSROOT_LDFLAGS)
 ])
 
+AC_DEFUN_ONCE([FLAGS_SETUP_GLOBAL_FLAGS],
+[
+  if test "x$TOOLCHAIN_TYPE" = xxlc; then
+    MACHINE_FLAG="-q${OPENJDK_TARGET_CPU_BITS}"
+  elif test "x$TOOLCHAIN_TYPE" != xmicrosoft; then
+    MACHINE_FLAG="-m${OPENJDK_TARGET_CPU_BITS}"
+  fi
+
+  # FIXME: global flags are not used yet...
+  # The "global" flags will *always* be set. Without them, it is not possible to
+  # get a working compilation.
+  GLOBAL_CFLAGS="$MACHINE_FLAG $SYSROOT_CFLAGS $USER_CFLAGS"
+  GLOBAL_CXXFLAGS="$MACHINE_FLAG $SYSROOT_CFLAGS $USER_CXXFLAGS"
+  GLOBAL_LDFLAGS="$MACHINE_FLAG $SYSROOT_LDFLAGS $USER_LDFLAGS"
+  # FIXME: Don't really know how to do with this, but this was the old behavior
+  GLOBAL_CPPFLAGS="$SYSROOT_CFLAGS"
+  AC_SUBST(GLOBAL_CFLAGS)
+  AC_SUBST(GLOBAL_CXXFLAGS)
+  AC_SUBST(GLOBAL_LDFLAGS)
+  AC_SUBST(GLOBAL_CPPFLAGS)
+
+  # FIXME: For compatilibity, export this as EXTRA_CFLAGS for now.
+  EXTRA_CFLAGS="$MACHINE_FLAG $USER_CFLAGS"
+  EXTRA_CXXFLAGS="$MACHINE_FLAG $USER_CXXFLAGS"
+  EXTRA_LDFLAGS="$MACHINE_FLAG $USER_LDFLAGS"
+
+  AC_SUBST(EXTRA_CFLAGS)
+  AC_SUBST(EXTRA_CXXFLAGS)
+  AC_SUBST(EXTRA_LDFLAGS)
+
+  # For autoconf testing to work, the global flags must also be stored in the
+  # "unnamed" CFLAGS etc.
+  CFLAGS="$GLOBAL_CFLAGS"
+  CXXFLAGS="$GLOBAL_CXXFLAGS"
+  LDFLAGS="$GLOBAL_LDFLAGS"
+  CPPFLAGS="$GLOBAL_CPPFLAGS"
+])
+
 AC_DEFUN_ONCE([FLAGS_SETUP_INIT_FLAGS],
 [
   FLAGS_SETUP_TOOLCHAIN_CONTROL
@@ -225,6 +238,16 @@
     # silence copyright notice and other headers.
     COMMON_CCXXFLAGS="$COMMON_CCXXFLAGS -nologo"
   fi
+
+  if test "x$BUILD_SYSROOT" != x; then
+    FLAGS_SETUP_SYSROOT_FLAGS([BUILD_])
+  else
+    BUILD_SYSROOT_CFLAGS="$SYSROOT_CFLAGS"
+    BUILD_SYSROOT_LDFLAGS="$SYSROOT_LDFLAGS"
+  fi
+  AC_SUBST(BUILD_SYSROOT_CFLAGS)
+  AC_SUBST(BUILD_SYSROOT_LDFLAGS)
+
 ])
 
 AC_DEFUN([FLAGS_SETUP_COMPILER_FLAGS_FOR_LIBS],
@@ -406,6 +429,8 @@
   if test "x$OPENJDK_TARGET_OS" = xmacosx; then
     JVM_ASFLAGS="-x assembler-with-cpp -mno-omit-leaf-frame-pointer -mstack-alignment=16"
   fi
+  JVM_ASFLAGS="$JVM_ASFLAGS $MACHINE_FLAG"
+
   AC_SUBST(JVM_ASFLAGS)
 ])
 
@@ -662,10 +687,15 @@
   fi
 
   # setup CPU bit size
-  $1_DEFINES_CPU_JDK="${$1_DEFINES_CPU_JDK} $FLAGS_ADD_LP64 \
-      -DARCH='\"$FLAGS_CPU_LEGACY\"' -D$FLAGS_CPU_LEGACY"
+  $1_DEFINES_CPU_JDK="${$1_DEFINES_CPU_JDK} -DARCH='\"$FLAGS_CPU_LEGACY\"' \
+      -D$FLAGS_CPU_LEGACY"
 
   if test "x$FLAGS_CPU_BITS" = x64; then
+    # -D_LP64=1 is only set on linux and mac. Setting on windows causes diff in
+    # unpack200.exe.
+    if test "x$FLAGS_OS" = xlinux || test "x$FLAGS_OS" = xmacosx; then
+      $1_DEFINES_CPU_JDK="${$1_DEFINES_CPU_JDK} -D_LP64=1"
+    fi
     if test "x$FLAGS_OS" != xsolaris && test "x$FLAGS_OS" != xaix; then
       # Solaris does not have _LP64=1 in the old build.
       # xlc on AIX defines _LP64=1 by default and issues a warning if we redefine it.
@@ -697,11 +727,13 @@
 
   if test "x$TOOLCHAIN_TYPE" = xgcc; then
     if test "x$FLAGS_CPU" = xarm; then
-      $1_CFLAGS_CPU_JDK="-fsigned-char"
-
-      # Get rid of annoying "note: the mangling of 'va_list' has changed in GCC 4.4"
-      # FIXME: This should not really be set using extra_cflags.
-      $1_CFLAGS_CPU="-Wno-psabi"
+      # -Wno-psabi to get rid of annoying "note: the mangling of 'va_list' has changed in GCC 4.4"
+      $1_CFLAGS_CPU="-fsigned-char -Wno-psabi $ARM_ARCH_TYPE_FLAGS $ARM_FLOAT_TYPE_FLAGS -DJDK_ARCH_ABI_PROP_NAME='\"\$(JDK_ARCH_ABI_PROP_NAME)\"'"
+      $1_CFLAGS_CPU_JVM="-DARM"
+    elif test "x$FLAGS_CPU" = xaarch64; then
+      if test "x$HOTSPOT_TARGET_CPU_PORT" = xarm64; then
+        $1_CFLAGS_CPU_JVM="-fsigned-char -DARM"
+      fi
     elif test "x$FLAGS_CPU_ARCH" = xppc; then
       $1_CFLAGS_CPU_JVM="-minsert-sched-nops=regroup_exact -mno-multiple -mno-string"
       if test "x$FLAGS_CPU" = xppc64; then
@@ -730,6 +762,7 @@
         $1_CFLAGS_CPU_JDK="${$1_CFLAGS_CPU_JDK} -fno-omit-frame-pointer"
       fi
     fi
+
   elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
     if test "x$FLAGS_CPU" = xsparcv9; then
       $1_CFLAGS_CPU_JVM="-xarch=sparc"
@@ -740,6 +773,7 @@
     if test "x$FLAGS_CPU" = xppc64; then
       $1_CFLAGS_CPU_JVM="-qarch=ppc64"
     fi
+
   elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
     if test "x$FLAGS_CPU" = xx86; then
       $1_CFLAGS_CPU_JVM="-arch:IA32"
--- a/make/autoconf/hotspot.m4	Tue Feb 20 12:05:50 2018 +0100
+++ b/make/autoconf/hotspot.m4	Tue Feb 20 20:41:51 2018 +0100
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2011, 2017, 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
@@ -277,13 +277,9 @@
   if test "x$OPENJDK_TARGET_CPU" = xarm; then
     HOTSPOT_TARGET_CPU=arm_32
     HOTSPOT_TARGET_CPU_DEFINE="ARM32"
-    JVM_LDFLAGS="$JVM_LDFLAGS -fsigned-char"
-    JVM_CFLAGS="$JVM_CFLAGS -DARM -fsigned-char"
   elif test "x$OPENJDK_TARGET_CPU" = xaarch64 && test "x$HOTSPOT_TARGET_CPU_PORT" = xarm64; then
     HOTSPOT_TARGET_CPU=arm_64
     HOTSPOT_TARGET_CPU_ARCH=arm
-    JVM_LDFLAGS="$JVM_LDFLAGS -fsigned-char"
-    JVM_CFLAGS="$JVM_CFLAGS -DARM -fsigned-char"
   fi
 
   # Verify that dependencies are met for explicitly set features.
--- a/make/autoconf/libraries.m4	Tue Feb 20 12:05:50 2018 +0100
+++ b/make/autoconf/libraries.m4	Tue Feb 20 20:41:51 2018 +0100
@@ -115,37 +115,37 @@
   BASIC_JDKLIB_LIBS="$BASIC_JDKLIB_LIBS $ALWAYS_LIBS"
 
   # Math library
-  if test "x$FLAGS_OS" != xsolaris; then
+  if test "x$OPENJDK_TARGET_OS" != xsolaris; then
     BASIC_JVM_LIBS="$LIBM"
   else
     # FIXME: This hard-coded path is not really proper.
-    if test "x$FLAGS_CPU" = xx86_64; then
+    if test "x$OPENJDK_TARGET_CPU" = xx86_64; then
       BASIC_SOLARIS_LIBM_LIBS="/usr/lib/amd64/libm.so.1"
-    elif test "x$FLAGS_CPU" = xsparcv9; then
+    elif test "x$OPENJDK_TARGET_CPU" = xsparcv9; then
       BASIC_SOLARIS_LIBM_LIBS="/usr/lib/sparcv9/libm.so.1"
     fi
     BASIC_JVM_LIBS="$BASIC_SOLARIS_LIBM_LIBS"
   fi
 
   # Dynamic loading library
-  if test "x$FLAGS_OS" = xlinux || test "x$FLAGS_OS" = xsolaris || test "x$FLAGS_OS" = xaix; then
+  if test "x$OPENJDK_TARGET_OS" = xlinux || test "x$OPENJDK_TARGET_OS" = xsolaris || test "x$OPENJDK_TARGET_OS" = xaix; then
     BASIC_JVM_LIBS="$BASIC_JVM_LIBS $LIBDL"
   fi
 
   # Threading library
-  if test "x$FLAGS_OS" = xlinux || test "x$FLAGS_OS" = xaix; then
+  if test "x$OPENJDK_TARGET_OS" = xlinux || test "x$OPENJDK_TARGET_OS" = xaix; then
     BASIC_JVM_LIBS="$BASIC_JVM_LIBS -lpthread"
-  elif test "x$FLAGS_OS" = xsolaris; then
+  elif test "x$OPENJDK_TARGET_OS" = xsolaris; then
     BASIC_JVM_LIBS="$BASIC_JVM_LIBS -lthread"
   fi
 
-  if test "x$FLAGS_OS" = xsolaris; then
+  if test "x$OPENJDK_TARGET_OS" = xsolaris; then
     BASIC_JVM_LIBS="$BASIC_JVM_LIBS -lsocket -lsched -ldoor -ldemangle -lnsl \
         -lrt"
     BASIC_JVM_LIBS="$BASIC_JVM_LIBS $LIBCXX_JVM"
   fi
 
-  if test "x$FLAGS_OS" = xwindows; then
+  if test "x$OPENJDK_TARGET_OS" = xwindows; then
     BASIC_JVM_LIBS="$BASIC_JVM_LIBS kernel32.lib user32.lib gdi32.lib winspool.lib \
         comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib \
         wsock32.lib winmm.lib version.lib psapi.lib"
--- a/make/autoconf/platform.m4	Tue Feb 20 12:05:50 2018 +0100
+++ b/make/autoconf/platform.m4	Tue Feb 20 20:41:51 2018 +0100
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2011, 2017, 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
@@ -403,15 +403,6 @@
   OPENJDK_$1_BUNDLE_PLATFORM="${OPENJDK_$1_OS_BUNDLE}-${OPENJDK_$1_CPU_BUNDLE}"
   AC_SUBST(OPENJDK_$1_BUNDLE_PLATFORM)
 
-  if test "x$OPENJDK_$1_CPU_BITS" = x64; then
-    # -D_LP64=1 is only set on linux and mac. Setting on windows causes diff in
-    # unpack200.exe. This variable is used in
-    # FLAGS_SETUP_COMPILER_FLAGS_FOR_JDK_HELPER.
-    if test "x$OPENJDK_$1_OS" = xlinux || test "x$OPENJDK_$1_OS" = xmacosx; then
-      OPENJDK_$1_ADD_LP64="-D_LP64=1"
-    fi
-  fi
-
   if test "x$COMPILE_TYPE" = "xcross"; then
     # FIXME: ... or should this include reduced builds..?
     DEFINE_CROSS_COMPILE_ARCH="CROSS_COMPILE_ARCH:=$OPENJDK_$1_CPU_LEGACY"
@@ -563,31 +554,6 @@
   AC_SUBST(OS_VERSION_MICRO)
 ])
 
-# Support macro for PLATFORM_SETUP_OPENJDK_TARGET_BITS.
-# Add -mX to various FLAGS variables.
-AC_DEFUN([PLATFORM_SET_COMPILER_TARGET_BITS_FLAGS],
-[
-  # When we add flags to the "official" CFLAGS etc, we need to
-  # keep track of these additions in ADDED_CFLAGS etc. These
-  # will later be checked to make sure only controlled additions
-  # have been made to CFLAGS etc.
-  ADDED_CFLAGS=" ${COMPILER_TARGET_BITS_FLAG}${OPENJDK_TARGET_CPU_BITS}"
-  ADDED_CXXFLAGS=" ${COMPILER_TARGET_BITS_FLAG}${OPENJDK_TARGET_CPU_BITS}"
-  ADDED_LDFLAGS=" ${COMPILER_TARGET_BITS_FLAG}${OPENJDK_TARGET_CPU_BITS}"
-
-  CFLAGS="${CFLAGS}${ADDED_CFLAGS}"
-  CXXFLAGS="${CXXFLAGS}${ADDED_CXXFLAGS}"
-  LDFLAGS="${LDFLAGS}${ADDED_LDFLAGS}"
-
-  CFLAGS_JDK="${CFLAGS_JDK}${ADDED_CFLAGS}"
-  CXXFLAGS_JDK="${CXXFLAGS_JDK}${ADDED_CXXFLAGS}"
-  LDFLAGS_JDK="${LDFLAGS_JDK}${ADDED_LDFLAGS}"
-
-  JVM_CFLAGS="$JVM_CFLAGS $ADDED_CFLAGS"
-  JVM_LDFLAGS="$JVM_LDFLAGS $ADDED_LDFLAGS"
-  JVM_ASFLAGS="$JVM_ASFLAGS $ADDED_CFLAGS"
-])
-
 AC_DEFUN_ONCE([PLATFORM_SETUP_OPENJDK_TARGET_BITS],
 [
   ###############################################################################
@@ -597,22 +563,6 @@
   # is made at runtime.)
   #
 
-  if test "x$OPENJDK_TARGET_OS" = xsolaris || test "x$OPENJDK_TARGET_OS" = xaix; then
-    # Always specify -m flag on Solaris
-    # And -q on AIX because otherwise the compiler produces 32-bit objects by default
-    PLATFORM_SET_COMPILER_TARGET_BITS_FLAGS
-  elif test "x$COMPILE_TYPE" = xreduced; then
-    if test "x$OPENJDK_TARGET_OS_TYPE" = xunix; then
-      # Specify -m if running reduced on unix platforms
-      PLATFORM_SET_COMPILER_TARGET_BITS_FLAGS
-    fi
-  fi
-  if test "x$OPENJDK_TARGET_OS" = xmacosx; then
-    JVM_CFLAGS="$JVM_CFLAGS ${COMPILER_TARGET_BITS_FLAG}${OPENJDK_TARGET_CPU_BITS}"
-    JVM_LDFLAGS="$JVM_LDFLAGS ${COMPILER_TARGET_BITS_FLAG}${OPENJDK_TARGET_CPU_BITS}"
-    JVM_ASFLAGS="$JVM_ASFLAGS ${COMPILER_TARGET_BITS_FLAG}${OPENJDK_TARGET_CPU_BITS}"
-  fi
-
   # Make compilation sanity check
   AC_CHECK_HEADERS([stdio.h], , [
     AC_MSG_NOTICE([Failed to compile stdio.h. This likely implies missing compile dependencies.])
@@ -635,33 +585,14 @@
     TESTED_TARGET_CPU_BITS=`expr 8 \* $ac_cv_sizeof_int_p`
 
     if test "x$TESTED_TARGET_CPU_BITS" != "x$OPENJDK_TARGET_CPU_BITS"; then
-      # This situation may happen on 64-bit platforms where the compiler by default only generates 32-bit objects
-      # Let's try to implicitely set the compilers target architecture and retry the test
-      AC_MSG_NOTICE([The tested number of bits in the target ($TESTED_TARGET_CPU_BITS) differs from the number of bits expected to be found in the target ($OPENJDK_TARGET_CPU_BITS).])
-      AC_MSG_NOTICE([Retrying with platforms compiler target bits flag to ${COMPILER_TARGET_BITS_FLAG}${OPENJDK_TARGET_CPU_BITS}])
-      PLATFORM_SET_COMPILER_TARGET_BITS_FLAGS
-
-      # We have to unset 'ac_cv_sizeof_int_p' first, otherwise AC_CHECK_SIZEOF will use the previously cached value!
-      unset ac_cv_sizeof_int_p
-      # And we have to undef the definition of SIZEOF_INT_P in confdefs.h by the previous invocation of AC_CHECK_SIZEOF
-      cat >>confdefs.h <<_ACEOF
-#undef SIZEOF_INT_P
-_ACEOF
-
-      AC_CHECK_SIZEOF([int *], [1111])
-
-      TESTED_TARGET_CPU_BITS=`expr 8 \* $ac_cv_sizeof_int_p`
-
-      if test "x$TESTED_TARGET_CPU_BITS" != "x$OPENJDK_TARGET_CPU_BITS"; then
-        AC_MSG_NOTICE([The tested number of bits in the target ($TESTED_TARGET_CPU_BITS) differs from the number of bits expected to be found in the target ($OPENJDK_TARGET_CPU_BITS)])
-        if test "x$COMPILE_TYPE" = xreduced; then
-          HELP_MSG_MISSING_DEPENDENCY([reduced])
-          AC_MSG_NOTICE([You are doing a reduced build. Check that you have 32-bit libraries installed. $HELP_MSG])
-        elif test "x$COMPILE_TYPE" = xcross; then
-          AC_MSG_NOTICE([You are doing a cross-compilation. Check that you have all target platform libraries installed.])
-        fi
-        AC_MSG_ERROR([Cannot continue.])
+      AC_MSG_NOTICE([The tested number of bits in the target ($TESTED_TARGET_CPU_BITS) differs from the number of bits expected to be found in the target ($OPENJDK_TARGET_CPU_BITS)])
+      if test "x$COMPILE_TYPE" = xreduced; then
+        HELP_MSG_MISSING_DEPENDENCY([reduced])
+        AC_MSG_NOTICE([You are doing a reduced build. Check that you have 32-bit libraries installed. $HELP_MSG])
+      elif test "x$COMPILE_TYPE" = xcross; then
+        AC_MSG_NOTICE([You are doing a cross-compilation. Check that you have all target platform libraries installed.])
       fi
+      AC_MSG_ERROR([Cannot continue.])
     fi
   fi
 
--- a/make/autoconf/toolchain.m4	Tue Feb 20 12:05:50 2018 +0100
+++ b/make/autoconf/toolchain.m4	Tue Feb 20 20:41:51 2018 +0100
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2011, 2017, 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
@@ -783,7 +783,6 @@
         fi
 
         BUILD_SYSROOT="$BUILD_DEVKIT_SYSROOT"
-        FLAGS_SETUP_SYSROOT_FLAGS([BUILD_])
 
          # Fallback default of just /bin if DEVKIT_PATH is not defined
         if test "x$BUILD_DEVKIT_TOOLCHAIN_PATH" = x; then
@@ -830,8 +829,6 @@
     BUILD_AS="$AS"
     BUILD_OBJCOPY="$OBJCOPY"
     BUILD_STRIP="$STRIP"
-    BUILD_SYSROOT_CFLAGS="$SYSROOT_CFLAGS"
-    BUILD_SYSROOT_LDFLAGS="$SYSROOT_LDFLAGS"
     BUILD_AR="$AR"
 
     TOOLCHAIN_PREPARE_FOR_VERSION_COMPARISONS([], [OPENJDK_BUILD_])
@@ -843,8 +840,6 @@
   AC_SUBST(BUILD_LDCXX)
   AC_SUBST(BUILD_NM)
   AC_SUBST(BUILD_AS)
-  AC_SUBST(BUILD_SYSROOT_CFLAGS)
-  AC_SUBST(BUILD_SYSROOT_LDFLAGS)
   AC_SUBST(BUILD_AR)
 ])
 
@@ -876,24 +871,6 @@
     # If this is a --hash-style=gnu system, use --hash-style=both, why?
     HAS_GNU_HASH=`$CC -dumpspecs 2>/dev/null | $GREP 'hash-style=gnu'`
     # This is later checked when setting flags.
-
-    # "-Og" suppported for GCC 4.8 and later
-    CFLAG_OPTIMIZE_DEBUG_FLAG="-Og"
-    FLAGS_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [$CFLAG_OPTIMIZE_DEBUG_FLAG],
-      IF_TRUE: [HAS_CFLAG_OPTIMIZE_DEBUG=true],
-      IF_FALSE: [HAS_CFLAG_OPTIMIZE_DEBUG=false])
-
-    # "-z relro" supported in GNU binutils 2.17 and later
-    LINKER_RELRO_FLAG="-Wl,-z,relro"
-    FLAGS_LINKER_CHECK_ARGUMENTS(ARGUMENT: [$LINKER_RELRO_FLAG],
-      IF_TRUE: [HAS_LINKER_RELRO=true],
-      IF_FALSE: [HAS_LINKER_RELRO=false])
-
-    # "-z now" supported in GNU binutils 2.11 and later
-    LINKER_NOW_FLAG="-Wl,-z,now"
-    FLAGS_LINKER_CHECK_ARGUMENTS(ARGUMENT: [$LINKER_NOW_FLAG],
-      IF_TRUE: [HAS_LINKER_NOW=true],
-      IF_FALSE: [HAS_LINKER_NOW=false])
   fi
 
   # Check for broken SuSE 'ld' for which 'Only anonymous version tag is allowed