changeset 49718:c66cba389571 raw-string-literal

manual merge with default
author mcimadamore
date Tue, 10 Apr 2018 18:20:45 +0100
parents f2ec59847c27 26f624b33218
children cd56311735af
files make/data/x11wrappergen/functions.txt make/data/x11wrappergen/sizes.32 make/data/x11wrappergen/sizes.64 make/data/x11wrappergen/sizes.64-solaris-i386 make/devkit/createSolarisDevkit.sh make/hotspot/src/native/dtrace/generateJvmOffsetsMain.c make/lib/LibosxLibraries.gmk make/lib/NetworkingLibraries.gmk make/lib/NioLibraries.gmk make/lib/PlatformLibraries.gmk make/lib/SecurityLibraries.gmk src/hotspot/share/gc/parallel/cardTableExtension.cpp src/hotspot/share/gc/parallel/cardTableExtension.hpp src/hotspot/share/gc/shared/cardTableModRefBSForCTRS.cpp src/hotspot/share/logging/logTagLevelExpression.cpp src/hotspot/share/logging/logTagLevelExpression.hpp src/hotspot/share/memory/universe_ext.cpp src/hotspot/share/services/allocationContextService.hpp src/java.base/share/classes/java/lang/String.java src/java.base/share/classes/java/lang/StringLatin1.java src/java.base/share/classes/java/lang/StringUTF16.java src/java.base/share/classes/javax/security/auth/Policy.java src/java.base/share/classes/sun/security/provider/AuthPolicyFile.java src/java.base/unix/classes/java/io/FileDescriptor.java src/java.base/windows/classes/java/io/FileDescriptor.java src/java.management/share/classes/sun/management/TypeVersionMapper.java src/java.sql/share/classes/javax/transaction/xa/XAException.java src/java.sql/share/classes/javax/transaction/xa/XAResource.java src/java.sql/share/classes/javax/transaction/xa/Xid.java src/java.sql/share/classes/javax/transaction/xa/package.html src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties test/hotspot/gtest/logging/test_logTagLevelExpression.cpp test/jdk/com/sun/jdi/JDIScaffold.java test/jdk/java/lang/System/ExitFinalizersAndJIT.java test/jdk/java/lang/System/finalization/FinExit.java test/jdk/java/lang/System/finalization/FinExit.sh test/jdk/java/nio/channels/spi/SelectorProvider/inheritedChannel/Launcher.c test/jdk/java/nio/channels/spi/SelectorProvider/inheritedChannel/Makefile test/jdk/java/nio/channels/spi/SelectorProvider/inheritedChannel/lib/linux-i586/libLauncher.so test/jdk/java/nio/channels/spi/SelectorProvider/inheritedChannel/lib/solaris-amd64/libLauncher.so test/jdk/java/nio/channels/spi/SelectorProvider/inheritedChannel/lib/solaris-sparcv9/libLauncher.so test/jdk/javax/transaction/testng/Driver.java test/jdk/javax/transaction/testng/test/transaction/XAExceptionTests.java test/jdk/javax/transaction/testng/util/SerializedTransactionExceptions.java test/jdk/sanity/releaseFile/NegativeSOURCETest.java test/jdk/sun/java2d/OpenGL/CopyAreaOOB.java test/jdk/sun/java2d/OpenGL/CustomCompositeTest.java test/jdk/sun/java2d/OpenGL/DrawBufImgOp.java test/jdk/sun/java2d/OpenGL/DrawHugeImageTest.java test/jdk/sun/java2d/OpenGL/GradientPaints.java test/jdk/sun/java2d/OpenGL/bug7181438.java
diffstat 1570 files changed, 203032 insertions(+), 29008 deletions(-) [+]
line wrap: on
line diff
--- a/.hgtags	Wed Mar 21 10:35:21 2018 -0300
+++ b/.hgtags	Tue Apr 10 18:20:45 2018 +0100
@@ -469,3 +469,9 @@
 3eae36c6baa5f916a3024cf1513e22357e00185d jdk-10+41
 4b62b815b4f49970b91a952929cf50115c263cb3 jdk-10+42
 107413b070b92c88bde6230ceb4a19b579781068 jdk-10+43
+dfa46cfe56346884a61efdc30dc50f7505d66761 jdk-11+1
+03ae177c26b016353e5ea1cab6ffd051dfa086ca jdk-11+2
+663f20fc51091bd7f95d18448850ba091207b7bd jdk-10+44
+4f96cf952e71cb8a127334494faf28880c26181b jdk-10+45
+1fd4d6068f54561cfc67d54fc9ca84af7212c4f8 jdk-11+3
+e59941f7247d451fa7df9eaef3fce0f492f8420c jdk-11+4
--- a/doc/building.html	Wed Mar 21 10:35:21 2018 -0300
+++ b/doc/building.html	Tue Apr 10 18:20:45 2018 +0100
@@ -44,10 +44,7 @@
 <li><a href="#ibm-xl-cc">IBM XL C/C++</a></li>
 </ul></li>
 <li><a href="#boot-jdk-requirements">Boot JDK Requirements</a><ul>
-<li><a href="#jdk-8-on-linux">JDK 8 on Linux</a></li>
-<li><a href="#jdk-8-on-windows">JDK 8 on Windows</a></li>
-<li><a href="#jdk-8-on-macos">JDK 8 on macOS</a></li>
-<li><a href="#jdk-8-on-aix">JDK 8 on AIX</a></li>
+<li><a href="#getting-jdk-binaries">Getting JDK binaries</a></li>
 </ul></li>
 <li><a href="#external-library-requirements">External Library Requirements</a><ul>
 <li><a href="#freetype">FreeType</a></li>
@@ -194,7 +191,7 @@
 <p>Windows XP is not a supported platform, but all newer Windows should be able to build OpenJDK.</p>
 <p>On Windows, it is important that you pay attention to the instructions in the <a href="#special-considerations">Special Considerations</a>.</p>
 <p>Windows is the only non-POSIX OS supported by OpenJDK, and as such, requires some extra care. A POSIX support layer is required to build on Windows. For OpenJDK 9, the only supported such layer is Cygwin. (Msys is no longer supported due to a too old bash; msys2 and the new Windows Subsystem for Linux (WSL) would likely be possible to support in a future version but that would require a community effort to implement.)</p>
-<p>Internally in the build system, all paths are represented as Unix-style paths, e.g. <code>/cygdrive/c/hg/jdk9/Makefile</code> rather than <code>C:\hg\jdk9\Makefile</code>. This rule also applies to input to the build system, e.g. in arguments to <code>configure</code>. So, use <code>--with-freetype=/cygdrive/c/freetype</code> rather than <code>--with-freetype=c:\freetype</code>. For details on this conversion, see the section on <a href="#fixpath">Fixpath</a>.</p>
+<p>Internally in the build system, all paths are represented as Unix-style paths, e.g. <code>/cygdrive/c/hg/jdk9/Makefile</code> rather than <code>C:\hg\jdk9\Makefile</code>. This rule also applies to input to the build system, e.g. in arguments to <code>configure</code>. So, use <code>--with-msvcr-dll=/cygdrive/c/msvcr100.dll</code> rather than <code>--with-msvcr-dll=c:\msvcr100.dll</code>. For details on this conversion, see the section on <a href="#fixpath">Fixpath</a>.</p>
 <h4 id="cygwin">Cygwin</h4>
 <p>A functioning <a href="http://www.cygwin.com/">Cygwin</a> environment is thus required for building OpenJDK on Windows. If you have a 64-bit OS, we strongly recommend using the 64-bit version of Cygwin.</p>
 <p><strong>Note:</strong> Cygwin has a model of continuously updating all packages without any easy way to install or revert to a specific version of a package. This means that whenever you add or update a package in Cygwin, you might (inadvertently) update tools that are used by the OpenJDK build process, and that can cause unexpected build problems.</p>
@@ -364,37 +361,24 @@
 <p>See the <a href="http://cr.openjdk.java.net/~simonis/ppc-aix-port">OpenJDK PowerPC Port Status Page</a> for details.</p>
 <h2 id="boot-jdk-requirements">Boot JDK Requirements</h2>
 <p>Paradoxically, building OpenJDK requires a pre-existing JDK. This is called the &quot;boot JDK&quot;. The boot JDK does not have to be OpenJDK, though. If you are porting OpenJDK to a new platform, chances are that there already exists another JDK for that platform that is usable as boot JDK.</p>
-<p>The rule of thumb is that the boot JDK for building JDK major version <em>N</em> should be an JDK of major version <em>N-1</em>, so for building JDK 9 a JDK 8 would be suitable as boot JDK. However, OpenJDK should be able to &quot;build itself&quot;, so an up-to-date build of the current OpenJDK source is an acceptable alternative. If you are following the <em>N-1</em> rule, make sure you got the latest update version, since JDK 8 GA might not be able to build JDK 9 on all platforms.</p>
+<p>The rule of thumb is that the boot JDK for building JDK major version <em>N</em> should be a JDK of major version <em>N-1</em>, so for building JDK 9 a JDK 8 would be suitable as boot JDK. However, OpenJDK should be able to &quot;build itself&quot;, so an up-to-date build of the current OpenJDK source is an acceptable alternative. If you are following the <em>N-1</em> rule, make sure you've got the latest update version, since JDK 8 GA might not be able to build JDK 9 on all platforms.</p>
+<p>Early in the release cycle, version <em>N-1</em> may not yet have been released. In that case, the preferred boot JDK will be version <em>N-2</em> until version <em>N-1</em> is available.</p>
 <p>If the Boot JDK is not automatically detected, or the wrong JDK is picked, use <code>--with-boot-jdk</code> to point to the JDK to use.</p>
-<h3 id="jdk-8-on-linux">JDK 8 on Linux</h3>
-<p>On apt-based distros (like Debian and Ubuntu), <code>sudo apt-get install openjdk-8-jdk</code> is typically enough to install OpenJDK 8. On rpm-based distros (like Fedora and Red Hat), try <code>sudo yum install java-1.8.0-openjdk-devel</code>.</p>
-<h3 id="jdk-8-on-windows">JDK 8 on Windows</h3>
-<p>No pre-compiled binaries of OpenJDK 8 are readily available for Windows at the time of writing. An alternative is to download the <a href="http://www.oracle.com/technetwork/java/javase/downloads">Oracle JDK</a>. Another is the <a href="https://adoptopenjdk.net/">Adopt OpenJDK Project</a>, which publishes experimental prebuilt binaries for Windows.</p>
-<h3 id="jdk-8-on-macos">JDK 8 on macOS</h3>
-<p>No pre-compiled binaries of OpenJDK 8 are readily available for macOS at the time of writing. An alternative is to download the <a href="http://www.oracle.com/technetwork/java/javase/downloads">Oracle JDK</a>, or to install it using <code>brew cask install java</code>. Another option is the <a href="https://adoptopenjdk.net/">Adopt OpenJDK Project</a>, which publishes experimental prebuilt binaries for macOS.</p>
-<h3 id="jdk-8-on-aix">JDK 8 on AIX</h3>
-<p>No pre-compiled binaries of OpenJDK 8 are readily available for AIX at the time of writing. A starting point for working with OpenJDK on AIX is the <a href="http://openjdk.java.net/projects/ppc-aix-port/">PowerPC/AIX Port Project</a>.</p>
+<h3 id="getting-jdk-binaries">Getting JDK binaries</h3>
+<p>OpenJDK binaries for Linux, Windows and macOS can be downloaded from <a href="http://jdk.java.net">jdk.java.net</a>. An alternative is to download the <a href="http://www.oracle.com/technetwork/java/javase/downloads">Oracle JDK</a>. Another is the <a href="https://adoptopenjdk.net/">Adopt OpenJDK Project</a>, which publishes experimental prebuilt binaries for various platforms.</p>
+<p>On Linux you can also get OpenJDK from the Linux distribution. On apt-based distros (like Debian and Ubuntu), <code>sudo apt-get install openjdk-&lt;VERSION&gt;-jdk</code> is typically enough to install OpenJDK &lt;VERSION&gt;. On rpm-based distros (like Fedora and Red Hat), try <code>sudo yum install java-&lt;VERSION&gt;-openjdk-devel</code>.</p>
 <h2 id="external-library-requirements">External Library Requirements</h2>
 <p>Different platforms require different external libraries. In general, libraries are not optional - that is, they are either required or not used.</p>
 <p>If a required library is not detected by <code>configure</code>, you need to provide the path to it. There are two forms of the <code>configure</code> arguments to point to an external library: <code>--with-&lt;LIB&gt;=&lt;path&gt;</code> or <code>--with-&lt;LIB&gt;-include=&lt;path to include&gt; --with-&lt;LIB&gt;-lib=&lt;path to lib&gt;</code>. The first variant is more concise, but require the include files an library files to reside in a default hierarchy under this directory. In most cases, it works fine.</p>
 <p>As a fallback, the second version allows you to point to the include directory and the lib directory separately.</p>
 <h3 id="freetype">FreeType</h3>
-<p>FreeType2 from <a href="http://www.freetype.org/">The FreeType Project</a> is required on all platforms. At least version 2.3 is required.</p>
+<p>FreeType2 from <a href="http://www.freetype.org/">The FreeType Project</a> is not required on any platform. The exception is on Unix-based platforms when configuring such that the build artifacts will reference a system installed library, rather than bundling OpenJDK's own copy.</p>
 <ul>
-<li>To install on an apt-based Linux, try running <code>sudo apt-get install libcups2-dev</code>.</li>
-<li>To install on an rpm-based Linux, try running <code>sudo yum install cups-devel</code>.</li>
+<li>To install on an apt-based Linux, try running <code>sudo apt-get install libfreetype6-dev</code>.</li>
+<li>To install on an rpm-based Linux, try running <code>sudo yum install freetype-devel</code>.</li>
 <li>To install on Solaris, try running <code>pkg install system/library/freetype-2</code>.</li>
-<li>To install on macOS, try running <code>brew install freetype</code>.</li>
-<li>To install on Windows, see <a href="#building-freetype-on-windows">below</a>.</li>
 </ul>
-<p>Use <code>--with-freetype=&lt;path&gt;</code> if <code>configure</code> does not properly locate your FreeType files.</p>
-<h4 id="building-freetype-on-windows">Building FreeType on Windows</h4>
-<p>On Windows, there is no readily available compiled version of FreeType. OpenJDK can help you compile FreeType from source. Download the FreeType sources and unpack them into an arbitrary directory:</p>
-<pre><code>wget http://download.savannah.gnu.org/releases/freetype/freetype-2.5.3.tar.gz
-tar -xzf freetype-2.5.3.tar.gz</code></pre>
-<p>Then run <code>configure</code> with <code>--with-freetype-src=&lt;freetype_src&gt;</code>. This will automatically build the freetype library into <code>&lt;freetype_src&gt;/lib64</code> for 64-bit builds or into <code>&lt;freetype_src&gt;/lib32</code> for 32-bit builds. Afterwards you can always use <code>--with-freetype-include=&lt;freetype_src&gt;/include</code> and <code>--with-freetype-lib=&lt;freetype_src&gt;/lib[32|64]</code> for other builds.</p>
-<p>Alternatively you can unpack the sources like this to use the default directory:</p>
-<pre><code>tar --one-top-level=$HOME/freetype --strip-components=1 -xzf freetype-2.5.3.tar.gz</code></pre>
+<p>Use <code>--with-freetype-include=&lt;path&gt;</code> and <code>--with-freetype-lib=&lt;path&gt;</code> if <code>configure</code> does not automatically locate the platform FreeType files.</p>
 <h3 id="cups">CUPS</h3>
 <p>CUPS, <a href="http://www.cups.org">Common UNIX Printing System</a> header files are required on all platforms, except Windows. Often these files are provided by your operating system.</p>
 <ul>
@@ -758,12 +742,7 @@
 spawn failed</code></pre>
 <p>This can be a sign of a Cygwin problem. See the information about solving problems in the <a href="#cygwin">Cygwin</a> section. Rebooting the computer might help temporarily.</p>
 <h3 id="getting-help">Getting Help</h3>
-<p>If none of the suggestions in this document helps you, or if you find what you believe is a bug in the build system, please contact the Build Group by sending a mail to <script type="text/javascript">
-<!--
-h='&#x6f;&#112;&#x65;&#110;&#106;&#100;&#x6b;&#46;&#106;&#x61;&#118;&#x61;&#46;&#110;&#x65;&#116;';a='&#64;';n='&#98;&#x75;&#x69;&#108;&#100;&#x2d;&#100;&#x65;&#118;';e=n+a+h;
-document.write('<a h'+'ref'+'="ma'+'ilto'+':'+e+'" clas'+'s="em' + 'ail">'+e+'<\/'+'a'+'>');
-// -->
-</script><noscript>&#98;&#x75;&#x69;&#108;&#100;&#x2d;&#100;&#x65;&#118;&#32;&#x61;&#116;&#32;&#x6f;&#112;&#x65;&#110;&#106;&#100;&#x6b;&#32;&#100;&#x6f;&#116;&#32;&#106;&#x61;&#118;&#x61;&#32;&#100;&#x6f;&#116;&#32;&#110;&#x65;&#116;</noscript>. Please include the relevant parts of the configure and/or build log.</p>
+<p>If none of the suggestions in this document helps you, or if you find what you believe is a bug in the build system, please contact the Build Group by sending a mail to <a href="mailto:build-dev@openjdk.java.net">build-dev@openjdk.java.net</a>. Please include the relevant parts of the configure and/or build log.</p>
 <p>If you need general help or advice about developing for OpenJDK, you can also contact the Adoption Group. See the section on <a href="#contributing-to-openjdk">Contributing to OpenJDK</a> for more information.</p>
 <h2 id="hints-and-suggestions-for-advanced-users">Hints and Suggestions for Advanced Users</h2>
 <h3 id="setting-up-a-forest-for-pushing-changes-defpath">Setting Up a Forest for Pushing Changes (defpath)</h3>
--- a/doc/building.md	Wed Mar 21 10:35:21 2018 -0300
+++ b/doc/building.md	Tue Apr 10 18:20:45 2018 +0100
@@ -173,8 +173,8 @@
 Internally in the build system, all paths are represented as Unix-style paths,
 e.g. `/cygdrive/c/hg/jdk9/Makefile` rather than `C:\hg\jdk9\Makefile`. This
 rule also applies to input to the build system, e.g. in arguments to
-`configure`. So, use `--with-freetype=/cygdrive/c/freetype` rather than
-`--with-freetype=c:\freetype`. For details on this conversion, see the section
+`configure`. So, use `--with-msvcr-dll=/cygdrive/c/msvcr100.dll` rather than
+`--with-msvcr-dll=c:\msvcr100.dll`. For details on this conversion, see the section
 on [Fixpath](#fixpath).
 
 #### Cygwin
@@ -401,43 +401,31 @@
 another JDK for that platform that is usable as boot JDK.
 
 The rule of thumb is that the boot JDK for building JDK major version *N*
-should be an JDK of major version *N-1*, so for building JDK 9 a JDK 8 would be
+should be a JDK of major version *N-1*, so for building JDK 9 a JDK 8 would be
 suitable as boot JDK. However, OpenJDK should be able to "build itself", so an
 up-to-date build of the current OpenJDK source is an acceptable alternative. If
-you are following the *N-1* rule, make sure you got the latest update version,
-since JDK 8 GA might not be able to build JDK 9 on all platforms.
+you are following the *N-1* rule, make sure you've got the latest update
+version, since JDK 8 GA might not be able to build JDK 9 on all platforms.
+
+Early in the release cycle, version *N-1* may not yet have been released. In
+that case, the preferred boot JDK will be version *N-2* until version *N-1*
+is available.
 
 If the Boot JDK is not automatically detected, or the wrong JDK is picked, use
 `--with-boot-jdk` to point to the JDK to use.
 
-### JDK 8 on Linux
+### Getting JDK binaries
 
-On apt-based distros (like Debian and Ubuntu), `sudo apt-get install
-openjdk-8-jdk` is typically enough to install OpenJDK 8. On rpm-based distros
-(like Fedora and Red Hat), try `sudo yum install java-1.8.0-openjdk-devel`.
+OpenJDK binaries for Linux, Windows and macOS can be downloaded from
+[jdk.java.net](http://jdk.java.net). An alternative is to download the
+[Oracle JDK](http://www.oracle.com/technetwork/java/javase/downloads). Another
+is the [Adopt OpenJDK Project](https://adoptopenjdk.net/), which publishes
+experimental prebuilt binaries for various platforms.
 
-### JDK 8 on Windows
-
-No pre-compiled binaries of OpenJDK 8 are readily available for Windows at the
-time of writing. An alternative is to download the [Oracle JDK](
-http://www.oracle.com/technetwork/java/javase/downloads). Another is the [Adopt
-OpenJDK Project](https://adoptopenjdk.net/), which publishes experimental
-prebuilt binaries for Windows.
-
-### JDK 8 on macOS
-
-No pre-compiled binaries of OpenJDK 8 are readily available for macOS at the
-time of writing. An alternative is to download the [Oracle JDK](
-http://www.oracle.com/technetwork/java/javase/downloads), or to install it
-using `brew cask install java`. Another option is the [Adopt OpenJDK Project](
-https://adoptopenjdk.net/), which publishes experimental prebuilt binaries for
-macOS.
-
-### JDK 8 on AIX
-
-No pre-compiled binaries of OpenJDK 8 are readily available for AIX at the
-time of writing. A starting point for working with OpenJDK on AIX is
-the [PowerPC/AIX Port Project](http://openjdk.java.net/projects/ppc-aix-port/).
+On Linux you can also get OpenJDK from the Linux distribution. On apt-based
+distros (like Debian and Ubuntu), `sudo apt-get install openjdk-<VERSION>-jdk`
+is typically enough to install OpenJDK \<VERSION\>. On rpm-based distros (like
+Fedora and Red Hat), try `sudo yum install java-<VERSION>-openjdk-devel`.
 
 ## External Library Requirements
 
@@ -456,43 +444,19 @@
 
 ### FreeType
 
-FreeType2 from [The FreeType Project](http://www.freetype.org/) is required on
-all platforms. At least version 2.3 is required.
+FreeType2 from [The FreeType Project](http://www.freetype.org/) is not required
+on any platform. The exception is on Unix-based platforms when configuring such
+that the build artifacts will reference a system installed library,
+rather than bundling OpenJDK's own copy.
 
   * To install on an apt-based Linux, try running `sudo apt-get install
-    libcups2-dev`.
+    libfreetype6-dev`.
   * To install on an rpm-based Linux, try running `sudo yum install
-    cups-devel`.
+    freetype-devel`.
   * To install on Solaris, try running `pkg install system/library/freetype-2`.
-  * To install on macOS, try running `brew install freetype`.
-  * To install on Windows, see [below](#building-freetype-on-windows).
 
-Use `--with-freetype=<path>` if `configure` does not properly locate your
-FreeType files.
-
-#### Building FreeType on Windows
-
-On Windows, there is no readily available compiled version of FreeType. OpenJDK
-can help you compile FreeType from source. Download the FreeType sources and
-unpack them into an arbitrary directory:
-
-```
-wget http://download.savannah.gnu.org/releases/freetype/freetype-2.5.3.tar.gz
-tar -xzf freetype-2.5.3.tar.gz
-```
-
-Then run `configure` with `--with-freetype-src=<freetype_src>`. This will
-automatically build the freetype library into `<freetype_src>/lib64` for 64-bit
-builds or into `<freetype_src>/lib32` for 32-bit builds. Afterwards you can
-always use `--with-freetype-include=<freetype_src>/include` and
-`--with-freetype-lib=<freetype_src>/lib[32|64]` for other builds.
-
-Alternatively you can unpack the sources like this to use the default
-directory:
-
-```
-tar --one-top-level=$HOME/freetype --strip-components=1 -xzf freetype-2.5.3.tar.gz
-```
+Use `--with-freetype-include=<path>` and `--with-freetype-lib=<path>`
+if `configure` does not automatically locate the platform FreeType files.
 
 ### CUPS
 
--- a/make/CompileJavaModules.gmk	Wed Mar 21 10:35:21 2018 -0300
+++ b/make/CompileJavaModules.gmk	Tue Apr 10 18:20:45 2018 +0100
@@ -252,6 +252,10 @@
 
 ################################################################################
 
+java.transaction.xa_ADD_JAVAC_FLAGS += -Xdoclint:all/protected '-Xdoclint/package:javax.*'
+
+################################################################################
+
 java.sql_ADD_JAVAC_FLAGS += -Xdoclint:all/protected '-Xdoclint/package:java.*,javax.*'
 java.sql_SETUP := GENERATE_JDKBYTECODE_NOWARNINGS
 
--- a/make/Docs.gmk	Wed Mar 21 10:35:21 2018 -0300
+++ b/make/Docs.gmk	Tue Apr 10 18:20:45 2018 +0100
@@ -61,7 +61,7 @@
     $(SUPPORT_OUTPUTDIR)/rmic/* $(TOPDIR)/src/*/share/doc/stub)
 
 # URLs
-JAVADOC_BASE_URL := http://www.oracle.com/pls/topic/lookup?ctx=javase9&amp;id=homepage
+JAVADOC_BASE_URL := http://www.oracle.com/pls/topic/lookup?ctx=javase10&amp;id=homepage
 BUG_SUBMIT_URL := http://bugreport.java.com/bugreport/
 COPYRIGHT_URL := {@docroot}/../legal/copyright.html
 LICENSE_URL := http://www.oracle.com/technetwork/java/javase/terms/license/java10speclicense.html
--- a/make/Images.gmk	Wed Mar 21 10:35:21 2018 -0300
+++ b/make/Images.gmk	Tue Apr 10 18:20:45 2018 +0100
@@ -134,18 +134,22 @@
     $(call DependOnVariable, JDK_MODULES_LIST) $(BASE_RELEASE_FILE)
 	$(ECHO) Creating jdk jimage
 	$(RM) -r $(JDK_IMAGE_DIR)
-	$(JLINK_TOOL) --add-modules $(JDK_MODULES_LIST) \
-	    $(JLINK_JDK_EXTRA_OPTS) \
-	    --output $(JDK_IMAGE_DIR)
+	$(call ExecuteWithLog, $(SUPPORT_OUTPUTDIR)/images/jdk, \
+	    $(JLINK_TOOL) --add-modules $(JDK_MODULES_LIST) \
+	        $(JLINK_JDK_EXTRA_OPTS) \
+	        --output $(JDK_IMAGE_DIR) \
+	)
 	$(TOUCH) $@
 
 $(JRE_IMAGE_DIR)/$(JIMAGE_TARGET_FILE): $(JMODS) \
     $(call DependOnVariable, JRE_MODULES_LIST) $(BASE_RELEASE_FILE)
 	$(ECHO) Creating jre jimage
 	$(RM) -r $(JRE_IMAGE_DIR)
-	$(JLINK_TOOL) --add-modules $(JRE_MODULES_LIST) \
-	    $(JLINK_JRE_EXTRA_OPTS) \
-	    --output $(JRE_IMAGE_DIR)
+	$(call ExecuteWithLog, $(SUPPORT_OUTPUTDIR)/images/jre, \
+	    $(JLINK_TOOL) --add-modules $(JRE_MODULES_LIST) \
+	        $(JLINK_JRE_EXTRA_OPTS) \
+	        --output $(JRE_IMAGE_DIR) \
+	)
 	$(TOUCH) $@
 
 
@@ -153,27 +157,33 @@
     $(call DependOnVariable, JRE_COMPACT1_MODULES_LIST) $(BASE_RELEASE_FILE)
 	$(ECHO) Creating jre compact1 jimage
 	$(RM) -r $(JRE_COMPACT1_IMAGE_DIR)
-	$(JLINK_TOOL) --add-modules $(JRE_COMPACT1_MODULES_LIST) \
-	    $(JLINK_JRE_EXTRA_OPTS) \
-	    --output $(JRE_COMPACT1_IMAGE_DIR)
+	$(call ExecuteWithLog, $(SUPPORT_OUTPUTDIR)/images/jre_compact1, \
+	    $(JLINK_TOOL) --add-modules $(JRE_COMPACT1_MODULES_LIST) \
+	        $(JLINK_JRE_EXTRA_OPTS) \
+	        --output $(JRE_COMPACT1_IMAGE_DIR) \
+	)
 	$(TOUCH) $@
 
 $(JRE_COMPACT2_IMAGE_DIR)/$(JIMAGE_TARGET_FILE): $(JMODS) \
     $(call DependOnVariable, JRE_COMPACT2_MODULES_LIST) $(BASE_RELEASE_FILE)
 	$(ECHO) Creating jre compact2 jimage
 	$(RM) -r $(JRE_COMPACT2_IMAGE_DIR)
-	$(JLINK_TOOL) --add-modules $(JRE_COMPACT2_MODULES_LIST) \
-	    $(JLINK_JRE_EXTRA_OPTS) \
-	    --output $(JRE_COMPACT2_IMAGE_DIR)
+	$(call ExecuteWithLog, $(SUPPORT_OUTPUTDIR)/images/jre_compact2, \
+	    $(JLINK_TOOL) --add-modules $(JRE_COMPACT2_MODULES_LIST) \
+	        $(JLINK_JRE_EXTRA_OPTS) \
+	        --output $(JRE_COMPACT2_IMAGE_DIR) \
+	)
 	$(TOUCH) $@
 
 $(JRE_COMPACT3_IMAGE_DIR)/$(JIMAGE_TARGET_FILE): $(JMODS) \
     $(call DependOnVariable, JRE_COMPACT3_MODULES_LIST) $(BASE_RELEASE_FILE)
 	$(ECHO) Creating jre compact3 jimage
 	$(RM) -r $(JRE_COMPACT3_IMAGE_DIR)
-	$(JLINK_TOOL) --add-modules $(JRE_COMPACT3_MODULES_LIST) \
-	    $(JLINK_JRE_EXTRA_OPTS) \
-	    --output $(JRE_COMPACT3_IMAGE_DIR)
+	$(call ExecuteWithLog, $(SUPPORT_OUTPUTDIR)/images/jre_compact3, \
+	    $(JLINK_TOOL) --add-modules $(JRE_COMPACT3_MODULES_LIST) \
+	        $(JLINK_JRE_EXTRA_OPTS) \
+	        --output $(JRE_COMPACT3_IMAGE_DIR) \
+	)
 	$(TOUCH) $@
 
 TOOL_JRE_TARGETS := $(JRE_IMAGE_DIR)/$(JIMAGE_TARGET_FILE)
--- a/make/InitSupport.gmk	Wed Mar 21 10:35:21 2018 -0300
+++ b/make/InitSupport.gmk	Tue Apr 10 18:20:45 2018 +0100
@@ -361,6 +361,12 @@
 
   BUILD_LOG_PIPE := > >($(TEE) -a $(BUILD_LOG)) 2> >($(TEE) -a $(BUILD_LOG) >&2) && wait
 
+  ifneq ($(CUSTOM_ROOT), )
+    topdir=$(CUSTOM_ROOT)
+  else
+    topdir=$(TOPDIR)
+  endif
+
   # Parse COMPARE_BUILD into COMPARE_BUILD_*
   # Syntax: COMPARE_BUILD=CONF=<configure options>:PATCH=<patch file>:
   #         MAKE=<make targets>:COMP_OPTS=<compare script options>:
@@ -373,7 +379,7 @@
   # FAIL can be set to false to have the return value of compare be ignored.
   define ParseCompareBuild
     ifneq ($$(COMPARE_BUILD), )
-      COMPARE_BUILD_OUTPUTDIR := $(TOPDIR)/build/compare-build/$(CONF_NAME)
+      COMPARE_BUILD_OUTPUTDIR := $(topdir)/build/compare-build/$(CONF_NAME)
       COMPARE_BUILD_FAIL := true
 
       ifneq ($$(findstring :, $$(COMPARE_BUILD)), )
@@ -412,9 +418,9 @@
         endif
       endif
       ifneq ($$(COMPARE_BUILD_PATCH), )
-        ifneq ($$(wildcard $$(TOPDIR)/$$(COMPARE_BUILD_PATCH)), )
+        ifneq ($$(wildcard $$(topdir)/$$(COMPARE_BUILD_PATCH)), )
           # Assume relative path, if file exists
-          COMPARE_BUILD_PATCH := $$(wildcard $$(TOPDIR)/$$(COMPARE_BUILD_PATCH))
+          COMPARE_BUILD_PATCH := $$(wildcard $$(topdir)/$$(COMPARE_BUILD_PATCH))
         else ifeq ($$(wildcard $$(COMPARE_BUILD_PATCH)), )
           $$(error Patch file $$(COMPARE_BUILD_PATCH) does not exist)
         endif
@@ -429,11 +435,11 @@
   define PrepareCompareBuild
 	$(ECHO) "Preparing for comparison rebuild"
         # Apply patch, if any
-	$(if $(COMPARE_BUILD_PATCH), $(PATCH) -p1 < $(COMPARE_BUILD_PATCH))
+	$(if $(COMPARE_BUILD_PATCH), cd $(topdir) && $(PATCH) -p1 < $(COMPARE_BUILD_PATCH))
         # Move the first build away temporarily
-	$(RM) -r $(TOPDIR)/build/.compare-build-temp
-	$(MKDIR) -p $(TOPDIR)/build/.compare-build-temp
-	$(MV) $(OUTPUTDIR) $(TOPDIR)/build/.compare-build-temp
+	$(RM) -r $(topdir)/build/.compare-build-temp
+	$(MKDIR) -p $(topdir)/build/.compare-build-temp
+	$(MV) $(OUTPUTDIR) $(topdir)/build/.compare-build-temp
         # Restore an old compare-build, or create a new compare-build directory.
 	if test -d $(COMPARE_BUILD_OUTPUTDIR); then \
 	  $(MV) $(COMPARE_BUILD_OUTPUTDIR) $(OUTPUTDIR); \
@@ -443,18 +449,18 @@
         # Re-run configure with the same arguments (and possibly some additional),
         # must be done after patching.
 	( cd $(OUTPUTDIR) && PATH="$(ORIGINAL_PATH)" \
-	    $(BASH) $(TOPDIR)/configure $(CONFIGURE_COMMAND_LINE) $(COMPARE_BUILD_CONF))
+	    $(BASH) $(topdir)/configure $(CONFIGURE_COMMAND_LINE) $(COMPARE_BUILD_CONF))
   endef
 
   # Cleanup after a compare build
   define CleanupCompareBuild
         # If running with a COMPARE_BUILD patch, reverse-apply it
-	$(if $(COMPARE_BUILD_PATCH), $(PATCH) -R -p1 < $(COMPARE_BUILD_PATCH))
+	$(if $(COMPARE_BUILD_PATCH), cd $(topdir) && $(PATCH) -R -p1 < $(COMPARE_BUILD_PATCH))
         # Move this build away and restore the original build
-	$(MKDIR) -p $(TOPDIR)/build/compare-build
+	$(MKDIR) -p $(topdir)/build/compare-build
 	$(MV) $(OUTPUTDIR) $(COMPARE_BUILD_OUTPUTDIR)
-	$(MV) $(TOPDIR)/build/.compare-build-temp/$(CONF_NAME) $(OUTPUTDIR)
-	$(RM) -r $(TOPDIR)/build/.compare-build-temp
+	$(MV) $(topdir)/build/.compare-build-temp/$(CONF_NAME) $(OUTPUTDIR)
+	$(RM) -r $(topdir)/build/.compare-build-temp
   endef
 
   # Do the actual comparison of two builds
--- a/make/InterimImage.gmk	Wed Mar 21 10:35:21 2018 -0300
+++ b/make/InterimImage.gmk	Tue Apr 10 18:20:45 2018 +0100
@@ -48,6 +48,7 @@
 	$(RM) -r $(INTERIM_IMAGE_DIR)
 	$(JLINK_TOOL) \
 	    --output $(INTERIM_IMAGE_DIR) \
+	    --disable-plugin generate-jli-classes \
 	    --add-modules $(INTERIM_MODULES_LIST)
 	$(TOUCH) $@
 
--- a/make/Main.gmk	Wed Mar 21 10:35:21 2018 -0300
+++ b/make/Main.gmk	Tue Apr 10 18:20:45 2018 +0100
@@ -399,10 +399,13 @@
 update-build-docs:
 	+($(CD) $(TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f UpdateBuildDocs.gmk)
 
+update-x11wrappers:
+	+($(CD) $(TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f UpdateX11Wrappers.gmk)
+
 ALL_TARGETS += docs-jdk-api-javadoc docs-jdk-api-modulegraph \
     docs-javase-api-javadoc docs-javase-api-modulegraph \
     docs-reference-api-javadoc docs-reference-api-modulegraph docs-jdk-specs \
-    docs-jdk-index docs-zip update-build-docs
+    docs-jdk-index docs-zip update-build-docs update-x11wrappers
 
 ################################################################################
 # Cross compilation support
@@ -641,8 +644,11 @@
 
   generate-exported-symbols: java.base-libs jdk.jdwp.agent-libs
 
+  # If not already set, set the JVM variant target so that the JVM will be built.
+  JVM_MAIN_LIB_TARGETS ?= hotspot-$(JVM_VARIANT_MAIN)-libs
+
   # Building one JVM variant is enough to start building the other libs
-  $(LIBS_TARGETS): hotspot-$(JVM_VARIANT_MAIN)-libs
+  $(LIBS_TARGETS): $(JVM_MAIN_LIB_TARGETS)
 
   $(LAUNCHER_TARGETS): java.base-libs
 
@@ -719,8 +725,11 @@
     java.base-jmod: jrtfs-jar $(filter-out java.base-jmod, $(JMOD_TARGETS))
   endif
 
-  # Building java.base-jmod requires all of hotspot to be built.
-  java.base-jmod: hotspot
+  # If not already set, set the JVM target so that the JVM will be built.
+  JVM_MAIN_TARGETS ?= hotspot
+
+  # Building java.base-jmod requires all of VM (ie hotspot) to be built.
+  java.base-jmod: $(JVM_MAIN_TARGETS)
 
   # Declare dependencies from <module>-jmod to all other module targets
   # When creating a BUILDJDK, the java compilation has already been done by the
@@ -746,7 +755,7 @@
   # in java.base-copy) and tzdb.dat (done in java.base-gendata) to the
   # appropriate location otherwise jimage, jlink and jmod won't start. This
   # also applies when creating the buildjdk.
-  DEFAULT_JMOD_DEPS := java.base-libs java.base-copy java.base-gendata \
+  DEFAULT_JMOD_DEPS += java.base-libs java.base-copy java.base-gendata \
       jdk.jlink-launchers
   # When cross compiling and buildjdk is to be created, depend on creating the
   # buildjdk instead of the default dependencies.
@@ -822,8 +831,11 @@
 
   docs-reference-api-modulegraph: exploded-image buildtools-modules
 
+  # If not already set, then set the JVM specific docs targets
+  JVM_DOCS_TARGETS ?= hotspot-$(JVM_VARIANT_MAIN)-gensrc
+
   # The gensrc steps for hotspot and jdk.jdi create html spec files.
-  docs-jdk-specs: hotspot-$(JVM_VARIANT_MAIN)-gensrc jdk.jdi-gensrc \
+  docs-jdk-specs: $(JVM_DOCS_TARGETS) jdk.jdi-gensrc \
       docs-jdk-index
 
   docs-jdk-index: exploded-image buildtools-modules
@@ -885,13 +897,17 @@
 
   generate-summary: jmods buildtools-modules
 
+  update-x11wrappers: java.base-copy buildtools-jdk
+
 endif
 
 ################################################################################
 # Virtual targets without recipes
 
+# If not already set, set the JVM specific tools targets
+JVM_TOOLS_TARGETS ?= buildtools-hotspot
 buildtools: buildtools-langtools interim-langtools interim-rmic \
-    buildtools-jdk buildtools-hotspot
+    buildtools-jdk $(JVM_TOOLS_TARGETS)
 
 hotspot: $(HOTSPOT_VARIANT_TARGETS) hotspot-jsig
 
@@ -934,7 +950,7 @@
 $(foreach m, $(ALL_COPY_MODULES), $(eval $m: $m-copy))
 
 # Building java.base includes building all of hotspot.
-java.base: hotspot
+java.base: $(JVM_MAIN_TARGETS)
 
 demos: demos-jdk
 
@@ -1001,10 +1017,15 @@
 # This target builds the documentation image
 docs-image: docs-jdk
 
+# If not already set, set the JVM specific targets to build the test image
+JVM_TEST_IMAGE_TARGETS ?= test-image-hotspot-jtreg-native test-image-hotspot-gtest
+
 # This target builds the test image
-test-image: prepare-test-image test-image-hotspot-jtreg-native \
-    test-image-jdk-jtreg-native test-image-failure-handler test-image-hotspot-gtest \
-    test-image-demos-jdk
+test-image: prepare-test-image \
+    test-image-jdk-jtreg-native test-image-failure-handler \
+    test-image-demos-jdk $(JVM_TEST_IMAGE_TARGETS)
+
+################################################################################
 
 # all-images builds all our deliverables as images.
 all-images: product-images test-image docs-image
@@ -1143,6 +1164,8 @@
 	      $(MAKESUPPORT_OUTPUTDIR)/main-targets.gmk
 
 ################################################################################
+# Hook to include the corresponding custom file, if present.
+$(eval $(call IncludeCustomExtension, Main-post.gmk))
 
 .PHONY: $(ALL_TARGETS)
 
--- a/make/RunTests.gmk	Wed Mar 21 10:35:21 2018 -0300
+++ b/make/RunTests.gmk	Tue Apr 10 18:20:45 2018 +0100
@@ -60,6 +60,18 @@
   endif
 endef
 
+# Setup _NT_SYMBOL_PATH on Windows
+ifeq ($(OPENJDK_TARGET_OS), windows)
+  ifndef _NT_SYMBOL_PATH
+    # Can't use PathList here as it adds quotes around the value.
+    _NT_SYMBOL_PATH := \
+        $(subst $(SPACE),;, $(foreach p, $(sort $(dir $(wildcard \
+        $(addprefix $(SYMBOLS_IMAGE_DIR)/bin/, *.pdb */*.pdb)))), $(call FixPath, $p)))
+    export _NT_SYMBOL_PATH
+    $(info _NT_SYMBOL_PATH $(_NT_SYMBOL_PATH))
+  endif
+endif
+
 ################################################################################
 # Hook to include the corresponding custom file, if present.
 $(eval $(call IncludeCustomExtension, RunTests.gmk))
@@ -496,6 +508,11 @@
   $1_JTREG_BASIC_OPTIONS += -e:JIB_DATA_DIR
   # Some tests needs to find a boot JDK using the JDK8_HOME variable.
   $1_JTREG_BASIC_OPTIONS += -e:JDK8_HOME=$$(BOOT_JDK)
+  # If running on Windows, propagate the _NT_SYMBOL_PATH to enable
+  # symbol lookup in hserr files
+  ifeq ($$(OPENJDK_TARGET_OS), windows)
+    $1_JTREG_BASIC_OPTIONS += -e:_NT_SYMBOL_PATH
+  endif
 
   $1_JTREG_BASIC_OPTIONS += \
       $$(addprefix -javaoption:, $$(JTREG_JAVA_OPTIONS)) \
--- a/make/RunTestsPrebuilt.gmk	Wed Mar 21 10:35:21 2018 -0300
+++ b/make/RunTestsPrebuilt.gmk	Tue Apr 10 18:20:45 2018 +0100
@@ -113,6 +113,7 @@
 # These can have default values based on the ones above
 $(eval $(call SetupVariable,JDK_IMAGE_DIR,$(OUTPUTDIR)/images/jdk))
 $(eval $(call SetupVariable,TEST_IMAGE_DIR,$(OUTPUTDIR)/images/test))
+$(eval $(call SetupVariable,SYMBOLS_IMAGE_DIR,$(OUTPUTDIR)/images/symbols))
 
 # Provide default values for tools that we need
 $(eval $(call SetupVariable,MAKE,make,NO_CHECK))
@@ -245,6 +246,7 @@
     JT_HOME := $(JT_HOME), \
     JDK_IMAGE_DIR := $(JDK_IMAGE_DIR), \
     TEST_IMAGE_DIR := $(TEST_IMAGE_DIR), \
+    SYMBOLS_IMAGE_DIR := $(SYMBOLS_IMAGE_DIR), \
     MAKE := $(MAKE), \
     BASH := $(BASH), \
     JIB_JAR := $(JIB_JAR), \
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/make/UpdateX11Wrappers.gmk	Tue Apr 10 18:20:45 2018 +0100
@@ -0,0 +1,101 @@
+#
+# Copyright (c) 2012, 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
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.  Oracle designates this
+# particular file as subject to the "Classpath" exception as provided
+# by Oracle in the LICENSE file that accompanied this code.
+#
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+# or visit www.oracle.com if you need additional information or have any
+# questions.
+#
+
+################################################################################
+
+default: all
+
+include $(SPEC)
+include MakeBase.gmk
+include NativeCompilation.gmk
+include ToolsJdk.gmk
+
+################################################################################
+# This file is responsible for extracting the x11 native struct offsets to
+# the xawt Java library. The tool needs to be run on the os/arch that
+# will host the final jvm, thus the tool cannot be used when cross compiling.
+#
+# Two versions of the generated offset file, sizes-32.txt and sizes-64.txt are
+# committed into the source code repository. These are the ones used in
+# GensrcX11Wrappers.gmk to generate the Java code during the build.
+################################################################################
+
+ifeq ($(COMPILE_TYPE), cross)
+  $(error It is not possible to update the x11wrappers when cross-compiling)
+endif
+
+X11WRAPPERS_OUTPUT := $(SUPPORT_OUTPUTDIR)/x11wrappers
+
+GENSRC_X11WRAPPERS_DATADIR := $(TOPDIR)/make/data/x11wrappergen
+
+BITS := $(OPENJDK_TARGET_CPU_BITS)
+
+# Generate the C code for the program that will output the offset file.
+$(X11WRAPPERS_OUTPUT)/src/data_generator.c: $(GENSRC_X11WRAPPERS_DATADIR)/xlibtypes.txt $(BUILD_TOOLS_JDK)
+	$(call LogInfo, Generating X11 wrapper data generator source code)
+	$(call MakeDir, $(@D))
+	$(call ExecuteWithLog, $@, \
+	    $(TOOL_WRAPPERGENERATOR) gen_c_source $@ $(GENSRC_X11WRAPPERS_DATADIR)/xlibtypes.txt $(BITS))
+
+DATA_GENERATOR_INCLUDES := \
+    -I$(TOPDIR)/src/hotspot/share/include \
+    -I$(TOPDIR)/src/hotspot/os/$(HOTSPOT_TARGET_OS_TYPE)/include \
+    -I$(SUPPORT_OUTPUTDIR)/modules_include/java.base \
+    -I$(SUPPORT_OUTPUTDIR)/modules_include/java.base/$(OPENJDK_TARGET_OS_INCLUDE_SUBDIR) \
+    -I$(TOPDIR)/src/java.base/share/native/libjava \
+    -I$(TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS_TYPE)/native/libjava \
+    -I$(TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_TYPE)/native/common/awt \
+    -I$(TOPDIR)/src/java.desktop/share/native/common/awt/debug \
+    -I$(TOPDIR)/src/java.desktop/share/native/libawt/awt/image/cvutils \
+    #
+
+# Compile the generated C code into an executable.
+$(eval $(call SetupNativeCompilation, BUILD_DATA_GENERATOR, \
+    PROGRAM := data_generator, \
+    OUTPUT_DIR := $(X11WRAPPERS_OUTPUT)/bin, \
+    EXTRA_FILES := $(X11WRAPPERS_OUTPUT)/src/data_generator.c, \
+    CFLAGS := $(X_CFLAGS) $(DATA_GENERATOR_INCLUDES) $(CFLAGS_JDKEXE), \
+    LDFLAGS := $(LDFLAGS_JDKEXE), \
+    LIBS := $(X_LIBS), \
+    OBJECT_DIR := $(X11WRAPPERS_OUTPUT)/objs, \
+))
+
+# Run the executable to create the data file.
+$(GENSRC_X11WRAPPERS_DATADIR)/sizes-$(BITS).txt: $(BUILD_DATA_GENERATOR_TARGET)
+	$(call LogInfo, Generating X11 wrapper data files)
+	$(call MakeDir, $(@D))
+	$(call ExecuteWithLog, $(X11WRAPPERS_OUTPUT)/generation, \
+	    $(BUILD_DATA_GENERATOR_TARGET) | $(SORT) > $@)
+	$(ECHO) IMPORTANT: If you update the X11 wrapper data files, they most certainly
+	$(ECHO) need to be updated for both 32 and 64 bit platforms. You have now
+	$(ECHO) updated them for $(BITS) bit platforms only.
+
+TARGETS += $(GENSRC_X11WRAPPERS_DATADIR)/sizes-$(BITS).txt
+
+################################################################################
+
+all: $(TARGETS)
+
+.PHONY: all default
--- a/make/autoconf/basics.m4	Wed Mar 21 10:35:21 2018 -0300
+++ b/make/autoconf/basics.m4	Tue Apr 10 18:20:45 2018 +0100
@@ -258,16 +258,12 @@
     if test "x$READLINK_TESTED" != yes; then
       # On MacOSX there is a readlink tool with a different
       # purpose than the GNU readlink tool. Check the found readlink.
-      ISGNU=`$READLINK --version 2>&1 | $GREP GNU`
-      if test "x$ISGNU" = x; then
-        # A readlink that we do not know how to use.
-        # Are there other non-GNU readlinks out there?
-        READLINK_TESTED=yes
-        READLINK=
-      fi
+      READLINK_ISGNU=`$READLINK --version 2>&1 | $GREP GNU`
+      # If READLINK_ISGNU is empty, then it's a non-GNU readlink. Don't use it.
+      READLINK_TESTED=yes
     fi
 
-    if test "x$READLINK" != x; then
+    if test "x$READLINK" != x && test "x$READLINK_ISGNU" != x; then
       $1=`$READLINK -f [$]$1`
     else
       # Save the current directory for restoring afterwards
@@ -494,6 +490,7 @@
   BASIC_REQUIRE_PROGS(MV, mv)
   BASIC_REQUIRE_PROGS(NAWK, [nawk gawk awk])
   BASIC_REQUIRE_PROGS(PRINTF, printf)
+  BASIC_REQUIRE_PROGS(READLINK, [greadlink readlink])
   BASIC_REQUIRE_PROGS(RM, rm)
   BASIC_REQUIRE_PROGS(RMDIR, rmdir)
   BASIC_REQUIRE_PROGS(SH, sh)
@@ -525,7 +522,6 @@
 
   # These are not required on all platforms
   BASIC_PATH_PROGS(CYGPATH, cygpath)
-  BASIC_PATH_PROGS(READLINK, [greadlink readlink])
   BASIC_PATH_PROGS(DF, df)
   BASIC_PATH_PROGS(CPIO, [cpio bsdcpio])
   BASIC_PATH_PROGS(NICE, nice)
@@ -1131,6 +1127,8 @@
       fi
     fi
     BASIC_REQUIRE_PROGS(SETFILE, SetFile)
+  elif test "x$OPENJDK_TARGET_OS" = "xsolaris"; then
+    BASIC_REQUIRE_PROGS(ELFEDIT, elfedit)
   fi
 ])
 
--- a/make/autoconf/boot-jdk.m4	Wed Mar 21 10:35:21 2018 -0300
+++ b/make/autoconf/boot-jdk.m4	Tue Apr 10 18:20:45 2018 +0100
@@ -77,10 +77,11 @@
           BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" -version 2>&1 | $HEAD -n 1`
 
           # Extra M4 quote needed to protect [] in grep expression.
-          [FOUND_CORRECT_VERSION=`$ECHO $BOOT_JDK_VERSION | $EGREP '\"10([\.+-].*)?\"|\"9([\.+-].*)?\"'`]
+          [FOUND_CORRECT_VERSION=`$ECHO $BOOT_JDK_VERSION \
+              | $EGREP "\"(${DEFAULT_ACCEPTABLE_BOOT_VERSIONS// /|})([\.+-].*)?\""`]
           if test "x$FOUND_CORRECT_VERSION" = x; then
             AC_MSG_NOTICE([Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring])
-            AC_MSG_NOTICE([(Your Boot JDK must be version 9 or 10)])
+            AC_MSG_NOTICE([(Your Boot JDK version must be one of: $DEFAULT_ACCEPTABLE_BOOT_VERSIONS)])
             BOOT_JDK_FOUND=no
           else
             # We're done! :-)
@@ -510,10 +511,10 @@
         BUILD_JDK_VERSION=`"$BUILD_JDK/bin/java" -version 2>&1 | $HEAD -n 1`
 
         # Extra M4 quote needed to protect [] in grep expression.
-        [FOUND_CORRECT_VERSION=`echo $BUILD_JDK_VERSION | $EGREP '\"10([\.+-].*)?\"'`]
+        [FOUND_CORRECT_VERSION=`echo $BUILD_JDK_VERSION | $EGREP "\"$VERSION_FEATURE([\.+-].*)?\""`]
         if test "x$FOUND_CORRECT_VERSION" = x; then
           AC_MSG_NOTICE([Potential Build JDK found at $BUILD_JDK is incorrect JDK version ($BUILD_JDK_VERSION); ignoring])
-          AC_MSG_NOTICE([(Your Build JDK must be version 10)])
+          AC_MSG_NOTICE([(Your Build JDK must be version $VERSION_FEATURE)])
           BUILD_JDK_FOUND=no
         else
           # We're done!
--- a/make/autoconf/configure.ac	Wed Mar 21 10:35:21 2018 -0300
+++ b/make/autoconf/configure.ac	Tue Apr 10 18:20:45 2018 +0100
@@ -163,10 +163,9 @@
 # First determine the toolchain type (compiler family)
 TOOLCHAIN_DETERMINE_TOOLCHAIN_TYPE
 
-# User supplied flags should be used when configure detects compilers
-FLAGS_SETUP_USER_SUPPLIED_FLAGS
-# The sysroot cflags are needed for configure to be able to run the compilers
-FLAGS_SETUP_SYSROOT_FLAGS
+# The global flags are needed for configure to be able to run the compilers
+# correctly.
+FLAGS_PRE_TOOLCHAIN
 
 # Then detect the actual binaries needed
 TOOLCHAIN_PRE_DETECTION
@@ -184,17 +183,15 @@
 # Setup Jib dependency tool
 TOOLCHAIN_SETUP_JIB
 
-FLAGS_SETUP_INIT_FLAGS
+# After toolchain setup, we need to process some flags to be able to continue.
+FLAGS_POST_TOOLCHAIN
 
 # Now we can test some aspects on the target using configure macros.
 PLATFORM_SETUP_OPENJDK_TARGET_BITS
 PLATFORM_SETUP_OPENJDK_TARGET_ENDIANNESS
 
 # Configure flags for the tools
-FLAGS_SETUP_COMPILER_FLAGS_FOR_LIBS
-FLAGS_SETUP_COMPILER_FLAGS_FOR_OPTIMIZATION
-FLAGS_SETUP_COMPILER_FLAGS_FOR_JDK
-FLAGS_SETUP_COMPILER_FLAGS_MISC
+FLAGS_SETUP_FLAGS
 
 # Setup debug symbols (need objcopy from the toolchain for that)
 JDKOPT_SETUP_DEBUG_SYMBOLS
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/make/autoconf/flags-cflags.m4	Tue Apr 10 18:20:45 2018 +0100
@@ -0,0 +1,840 @@
+#
+# 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
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.  Oracle designates this
+# particular file as subject to the "Classpath" exception as provided
+# by Oracle in the LICENSE file that accompanied this code.
+#
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+# or visit www.oracle.com if you need additional information or have any
+# questions.
+#
+
+################################################################################
+#
+# Setup flags for C/C++ compiler
+#
+
+###############################################################################
+#
+# How to compile shared libraries.
+#
+AC_DEFUN([FLAGS_SETUP_SHARED_LIBS],
+[
+  if test "x$TOOLCHAIN_TYPE" = xgcc; then
+    C_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
+      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'
+      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_NAME='-Wl,-soname=[$]1'
+      SET_SHARED_LIBRARY_MAPFILE='-Wl,-version-script=[$]1'
+
+      # arm specific settings
+      if test "x$OPENJDK_TARGET_CPU" = "xarm"; then
+        # '-Wl,-z,origin' isn't used on arm.
+        SET_SHARED_LIBRARY_ORIGIN='-Wl,-rpath,\$$$$ORIGIN[$]1'
+      else
+        SET_SHARED_LIBRARY_ORIGIN="-Wl,-z,origin $SET_EXECUTABLE_ORIGIN"
+      fi
+    fi
+
+  elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
+    C_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
+    C_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
+    C_FLAG_REORDER=''
+    SHARED_LIBRARY_FLAGS="-dll"
+    SET_EXECUTABLE_ORIGIN=''
+    SET_SHARED_LIBRARY_ORIGIN=''
+    SET_SHARED_LIBRARY_NAME=''
+    SET_SHARED_LIBRARY_MAPFILE='-def:[$]1'
+  fi
+
+  AC_SUBST(C_FLAG_REORDER)
+  AC_SUBST(SET_EXECUTABLE_ORIGIN)
+  AC_SUBST(SET_SHARED_LIBRARY_ORIGIN)
+  AC_SUBST(SET_SHARED_LIBRARY_NAME)
+  AC_SUBST(SET_SHARED_LIBRARY_MAPFILE)
+  AC_SUBST(SHARED_LIBRARY_FLAGS)
+])
+
+AC_DEFUN([FLAGS_SETUP_DEBUG_SYMBOLS],
+[
+  # Debug symbols
+  if test "x$TOOLCHAIN_TYPE" = xgcc; then
+    CFLAGS_DEBUG_SYMBOLS="-g"
+  elif test "x$TOOLCHAIN_TYPE" = xclang; then
+    CFLAGS_DEBUG_SYMBOLS="-g"
+  elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
+    # -g0 enables debug symbols without disabling inlining.
+    CFLAGS_DEBUG_SYMBOLS="-g0 -xs"
+  elif test "x$TOOLCHAIN_TYPE" = xxlc; then
+    CFLAGS_DEBUG_SYMBOLS="-g"
+  elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
+    CFLAGS_DEBUG_SYMBOLS="-Z7 -d2Zi+"
+  fi
+
+  AC_SUBST(CFLAGS_DEBUG_SYMBOLS)
+])
+
+AC_DEFUN([FLAGS_SETUP_WARNINGS],
+[
+  AC_ARG_ENABLE([warnings-as-errors], [AS_HELP_STRING([--disable-warnings-as-errors],
+      [do not consider native warnings to be an error @<:@enabled@:>@])])
+
+  AC_MSG_CHECKING([if native warnings are errors])
+  if test "x$enable_warnings_as_errors" = "xyes"; then
+    AC_MSG_RESULT([yes (explicitly set)])
+    WARNINGS_AS_ERRORS=true
+  elif test "x$enable_warnings_as_errors" = "xno"; then
+    AC_MSG_RESULT([no])
+    WARNINGS_AS_ERRORS=false
+  elif test "x$enable_warnings_as_errors" = "x"; then
+    AC_MSG_RESULT([yes (default)])
+    WARNINGS_AS_ERRORS=true
+  else
+    AC_MSG_ERROR([--enable-warnings-as-errors accepts no argument])
+  fi
+
+  AC_SUBST(WARNINGS_AS_ERRORS)
+
+  case "${TOOLCHAIN_TYPE}" in
+    microsoft)
+      DISABLE_WARNING_PREFIX="-wd"
+      CFLAGS_WARNINGS_ARE_ERRORS="-WX"
+      ;;
+    solstudio)
+      DISABLE_WARNING_PREFIX="-erroff="
+      CFLAGS_WARNINGS_ARE_ERRORS="-errtags -errwarn=%all"
+      ;;
+    gcc)
+      DISABLE_WARNING_PREFIX="-Wno-"
+      CFLAGS_WARNINGS_ARE_ERRORS="-Werror"
+      # Repeate the check for the BUILD_CC and BUILD_CXX. Need to also reset
+      # CFLAGS since any target specific flags will likely not work with the
+      # build compiler
+      CC_OLD="$CC"
+      CXX_OLD="$CXX"
+      CC="$BUILD_CC"
+      CXX="$BUILD_CXX"
+      CFLAGS_OLD="$CFLAGS"
+      CFLAGS=""
+      BUILD_CC_DISABLE_WARNING_PREFIX="-Wno-"
+      CC="$CC_OLD"
+      CXX="$CXX_OLD"
+      CFLAGS="$CFLAGS_OLD"
+      ;;
+    clang)
+      DISABLE_WARNING_PREFIX="-Wno-"
+      CFLAGS_WARNINGS_ARE_ERRORS="-Werror"
+      ;;
+    xlc)
+      DISABLE_WARNING_PREFIX="-qsuppress="
+      CFLAGS_WARNINGS_ARE_ERRORS="-qhalt=w"
+      ;;
+  esac
+  AC_SUBST(DISABLE_WARNING_PREFIX)
+  AC_SUBST(BUILD_CC_DISABLE_WARNING_PREFIX)
+  AC_SUBST(CFLAGS_WARNINGS_ARE_ERRORS)
+])
+
+AC_DEFUN([FLAGS_SETUP_QUALITY_CHECKS],
+[
+  # bounds, memory and behavior checking options
+  if test "x$TOOLCHAIN_TYPE" = xgcc; then
+    case $DEBUG_LEVEL in
+    release )
+      # no adjustment
+      ;;
+    fastdebug )
+      # no adjustment
+      ;;
+    slowdebug )
+      # FIXME: By adding this to C(XX)FLAGS_DEBUG_OPTIONS/JVM_CFLAGS_SYMBOLS it
+      # get's added conditionally on whether we produce debug symbols or not.
+      # This is most likely not really correct.
+
+      # Add runtime stack smashing and undefined behavior checks.
+      CFLAGS_DEBUG_OPTIONS="-fstack-protector-all --param ssp-buffer-size=1"
+      CXXFLAGS_DEBUG_OPTIONS="-fstack-protector-all --param ssp-buffer-size=1"
+
+      JVM_CFLAGS_SYMBOLS="$JVM_CFLAGS_SYMBOLS -fstack-protector-all --param ssp-buffer-size=1"
+      ;;
+    esac
+  fi
+])
+
+AC_DEFUN([FLAGS_SETUP_OPTIMIZATION],
+[
+  if test "x$TOOLCHAIN_TYPE" = xsolstudio; then
+    CC_HIGHEST="-fns -fsimple -fsingle -xbuiltin=%all -xdepend -xrestrict -xlibmil"
+
+    C_O_FLAG_HIGHEST_JVM="-xO4"
+    C_O_FLAG_DEBUG_JVM=""
+    C_O_FLAG_SIZE=""
+    C_O_FLAG_DEBUG=""
+    C_O_FLAG_NONE=""
+    if test "x$OPENJDK_TARGET_CPU_ARCH" = "xx86"; then
+      C_O_FLAG_HIGHEST="-xO4 -Wu,-O4~yz $CC_HIGHEST"
+      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_HI="-xO4 -Wc,-Qrm-s -Wc,-Qiselect-T0"
+      C_O_FLAG_NORM="-xO2 -Wc,-Qrm-s -Wc,-Qiselect-T0"
+    fi
+  elif test "x$TOOLCHAIN_TYPE" = xgcc; then
+    C_O_FLAG_HIGHEST_JVM="-O3"
+    C_O_FLAG_HIGHEST="-O3"
+    C_O_FLAG_HI="-O3"
+    C_O_FLAG_NORM="-O2"
+    C_O_FLAG_SIZE="-Os"
+    C_O_FLAG_DEBUG="-O0"
+    C_O_FLAG_DEBUG_JVM="-O0"
+    C_O_FLAG_NONE="-O0"
+  elif test "x$TOOLCHAIN_TYPE" = xclang; then
+    if test "x$OPENJDK_TARGET_OS" = xmacosx; then
+      # On MacOSX we optimize for size, something
+      # we should do for all platforms?
+      C_O_FLAG_HIGHEST_JVM="-Os"
+      C_O_FLAG_HIGHEST="-Os"
+      C_O_FLAG_HI="-Os"
+      C_O_FLAG_NORM="-Os"
+      C_O_FLAG_DEBUG_JVM=""
+    else
+      C_O_FLAG_HIGHEST_JVM="-O3"
+      C_O_FLAG_HIGHEST="-O3"
+      C_O_FLAG_HI="-O3"
+      C_O_FLAG_NORM="-O2"
+      C_O_FLAG_DEBUG_JVM="-O0"
+    fi
+    C_O_FLAG_SIZE="-Os"
+    C_O_FLAG_DEBUG="-O0"
+    C_O_FLAG_NONE="-O0"
+  elif test "x$TOOLCHAIN_TYPE" = xxlc; then
+    C_O_FLAG_HIGHEST_JVM="-O3 -qhot=level=1 -qinline -qinlglue"
+    C_O_FLAG_HIGHEST="-O3 -qhot=level=1 -qinline -qinlglue"
+    C_O_FLAG_HI="-O3 -qinline -qinlglue"
+    C_O_FLAG_NORM="-O2"
+    C_O_FLAG_DEBUG="-qnoopt"
+    # FIXME: Value below not verified.
+    C_O_FLAG_DEBUG_JVM=""
+    C_O_FLAG_NONE="-qnoopt"
+  elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
+    C_O_FLAG_HIGHEST_JVM="-O2 -Oy-"
+    C_O_FLAG_HIGHEST="-O2"
+    C_O_FLAG_HI="-O1"
+    C_O_FLAG_NORM="-O1"
+    C_O_FLAG_DEBUG="-Od"
+    C_O_FLAG_DEBUG_JVM=""
+    C_O_FLAG_NONE="-Od"
+    C_O_FLAG_SIZE="-Os"
+  fi
+
+  # Now copy to C++ flags
+  CXX_O_FLAG_HIGHEST_JVM="$C_O_FLAG_HIGHEST_JVM"
+  CXX_O_FLAG_HIGHEST="$C_O_FLAG_HIGHEST"
+  CXX_O_FLAG_HI="$C_O_FLAG_HI"
+  CXX_O_FLAG_NORM="$C_O_FLAG_NORM"
+  CXX_O_FLAG_DEBUG="$C_O_FLAG_DEBUG"
+  CXX_O_FLAG_DEBUG_JVM="$C_O_FLAG_DEBUG_JVM"
+  CXX_O_FLAG_NONE="$C_O_FLAG_NONE"
+  CXX_O_FLAG_SIZE="$C_O_FLAG_SIZE"
+
+  if test "x$TOOLCHAIN_TYPE" = xsolstudio; then
+    # In solstudio, also add this to C (but not C++) flags...
+    C_O_FLAG_HIGHEST="$C_O_FLAG_HIGHEST -xalias_level=basic"
+  fi
+
+  # Adjust optimization flags according to debug level.
+  case $DEBUG_LEVEL in
+    release )
+      # no adjustment
+      ;;
+    fastdebug )
+      # Not quite so much optimization
+      C_O_FLAG_HI="$C_O_FLAG_NORM"
+      CXX_O_FLAG_HI="$CXX_O_FLAG_NORM"
+      ;;
+    slowdebug )
+      # Disable optimization
+      C_O_FLAG_HIGHEST_JVM="$C_O_FLAG_DEBUG_JVM"
+      C_O_FLAG_HIGHEST="$C_O_FLAG_DEBUG"
+      C_O_FLAG_HI="$C_O_FLAG_DEBUG"
+      C_O_FLAG_NORM="$C_O_FLAG_DEBUG"
+      C_O_FLAG_SIZE="$C_O_FLAG_DEBUG"
+      CXX_O_FLAG_HIGHEST_JVM="$CXX_O_FLAG_DEBUG_JVM"
+      CXX_O_FLAG_HIGHEST="$CXX_O_FLAG_DEBUG"
+      CXX_O_FLAG_HI="$CXX_O_FLAG_DEBUG"
+      CXX_O_FLAG_NORM="$CXX_O_FLAG_DEBUG"
+      CXX_O_FLAG_SIZE="$CXX_O_FLAG_DEBUG"
+      ;;
+  esac
+
+  AC_SUBST(C_O_FLAG_HIGHEST_JVM)
+  AC_SUBST(C_O_FLAG_HIGHEST)
+  AC_SUBST(C_O_FLAG_HI)
+  AC_SUBST(C_O_FLAG_NORM)
+  AC_SUBST(C_O_FLAG_NONE)
+  AC_SUBST(C_O_FLAG_SIZE)
+  AC_SUBST(CXX_O_FLAG_HIGHEST_JVM)
+  AC_SUBST(CXX_O_FLAG_HIGHEST)
+  AC_SUBST(CXX_O_FLAG_HI)
+  AC_SUBST(CXX_O_FLAG_NORM)
+  AC_SUBST(CXX_O_FLAG_NONE)
+  AC_SUBST(CXX_O_FLAG_SIZE)
+])
+
+AC_DEFUN([FLAGS_SETUP_CFLAGS],
+[
+  ### CFLAGS
+
+  FLAGS_SETUP_CFLAGS_HELPER
+
+  FLAGS_OS=$OPENJDK_TARGET_OS
+  FLAGS_OS_TYPE=$OPENJDK_TARGET_OS_TYPE
+  FLAGS_CPU=$OPENJDK_TARGET_CPU
+  FLAGS_CPU_ARCH=$OPENJDK_TARGET_CPU_ARCH
+  FLAGS_CPU_BITS=$OPENJDK_TARGET_CPU_BITS
+  FLAGS_CPU_ENDIAN=$OPENJDK_TARGET_CPU_ENDIAN
+  FLAGS_CPU_LEGACY=$OPENJDK_TARGET_CPU_LEGACY
+  FLAGS_CPU_LEGACY_LIB=$OPENJDK_TARGET_CPU_LEGACY_LIB
+
+  FLAGS_SETUP_CFLAGS_CPU_DEP([TARGET])
+
+  FLAGS_OS=$OPENJDK_BUILD_OS
+  FLAGS_OS_TYPE=$OPENJDK_BUILD_OS_TYPE
+  FLAGS_CPU=$OPENJDK_BUILD_CPU
+  FLAGS_CPU_ARCH=$OPENJDK_BUILD_CPU_ARCH
+  FLAGS_CPU_BITS=$OPENJDK_BUILD_CPU_BITS
+  FLAGS_CPU_ENDIAN=$OPENJDK_BUILD_CPU_ENDIAN
+  FLAGS_CPU_LEGACY=$OPENJDK_BUILD_CPU_LEGACY
+  FLAGS_CPU_LEGACY_LIB=$OPENJDK_BUILD_CPU_LEGACY_LIB
+
+  FLAGS_SETUP_CFLAGS_CPU_DEP([BUILD], [OPENJDK_BUILD_])
+
+  # Tests are only ever compiled for TARGET
+  CFLAGS_TESTLIB="$CFLAGS_JDKLIB"
+  CXXFLAGS_TESTLIB="$CXXFLAGS_JDKLIB"
+  CFLAGS_TESTEXE="$CFLAGS_JDKEXE"
+  CXXFLAGS_TESTEXE="$CXXFLAGS_JDKEXE"
+
+  AC_SUBST(CFLAGS_TESTLIB)
+  AC_SUBST(CFLAGS_TESTEXE)
+  AC_SUBST(CXXFLAGS_TESTLIB)
+  AC_SUBST(CXXFLAGS_TESTEXE)
+])
+
+################################################################################
+# platform independent
+AC_DEFUN([FLAGS_SETUP_CFLAGS_HELPER],
+[
+  #### OS DEFINES, these should be independent on toolchain
+  if test "x$OPENJDK_TARGET_OS" = xlinux; then
+    CFLAGS_OS_DEF_JVM="-DLINUX"
+    CFLAGS_OS_DEF_JDK="-D_GNU_SOURCE -D_REENTRANT -D_LARGEFILE64_SOURCE"
+  elif test "x$OPENJDK_TARGET_OS" = xsolaris; then
+    CFLAGS_OS_DEF_JVM="-DSOLARIS"
+    CFLAGS_OS_DEF_JDK="-D__solaris__"
+  elif test "x$OPENJDK_TARGET_OS" = xmacosx; then
+    CFLAGS_OS_DEF_JVM="-D_ALLBSD_SOURCE -D_DARWIN_C_SOURCE -D_XOPEN_SOURCE"
+    CFLAGS_OS_DEF_JDK="-D_ALLBSD_SOURCE -D_DARWIN_UNLIMITED_SELECT"
+  elif test "x$OPENJDK_TARGET_OS" = xaix; then
+    CFLAGS_OS_DEF_JVM="-DAIX"
+  elif test "x$OPENJDK_TARGET_OS" = xbsd; then
+    CFLAGS_OS_DEF_JDK="-D_ALLBSD_SOURCE"
+  elif test "x$OPENJDK_TARGET_OS" = xwindows; then
+    CFLAGS_OS_DEF_JVM="-D_WINDOWS -DWIN32 -D_JNI_IMPLEMENTATION_"
+  fi
+
+  # Setup target OS define. Use OS target name but in upper case.
+  OPENJDK_TARGET_OS_UPPERCASE=`$ECHO $OPENJDK_TARGET_OS | $TR 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
+  CFLAGS_OS_DEF_JDK="$CFLAGS_OS_DEF_JDK -D$OPENJDK_TARGET_OS_UPPERCASE"
+
+  #### GLOBAL DEFINES
+  # Set some common defines. These works for all compilers, but assume
+  # -D is universally accepted.
+
+  # Always enable optional macros for VM.
+  ALWAYS_CFLAGS_JVM="-D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS"
+
+  # Setup some hard coded includes
+  ALWAYS_CFLAGS_JDK=" \
+      -I\$(SUPPORT_OUTPUTDIR)/modules_include/java.base \
+      -I\$(SUPPORT_OUTPUTDIR)/modules_include/java.base/\$(OPENJDK_TARGET_OS_INCLUDE_SUBDIR) \
+      -I${TOPDIR}/src/java.base/share/native/libjava \
+      -I${TOPDIR}/src/java.base/$OPENJDK_TARGET_OS_TYPE/native/libjava \
+      -I${TOPDIR}/src/hotspot/share/include \
+      -I${TOPDIR}/src/hotspot/os/${HOTSPOT_TARGET_OS_TYPE}/include"
+
+  ###############################################################################
+
+  # Adjust flags according to debug level.
+  # Setup debug/release defines
+  if test "x$DEBUG_LEVEL" = xrelease; then
+    DEBUG_CFLAGS_JDK="-DNDEBUG"
+    if test "x$OPENJDK_TARGET_OS" = xsolaris; then
+      DEBUG_CFLAGS_JDK="$DEBUG_CFLAGS_JDK -DTRIMMED"
+    fi
+  else
+    DEBUG_CFLAGS_JDK="-DDEBUG"
+
+    if 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 for debug we build with '-qpic=large -bbigtoc'.
+      DEBUG_CFLAGS_JVM="-qpic=large"
+    fi
+  fi
+
+  if test "x$DEBUG_LEVEL" != xrelease; then
+    DEBUG_OPTIONS_FLAGS_JDK="$CFLAGS_DEBUG_OPTIONS"
+    DEBUG_SYMBOLS_CFLAGS_JDK="$CFLAGS_DEBUG_SYMBOLS"
+  fi
+
+  #### TOOLCHAIN DEFINES
+
+  if test "x$TOOLCHAIN_TYPE" = xgcc; then
+    ALWAYS_DEFINES_JVM="-D_GNU_SOURCE -D_REENTRANT"
+  elif test "x$TOOLCHAIN_TYPE" = xclang; then
+    ALWAYS_DEFINES_JVM="-D_GNU_SOURCE"
+  elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
+    ALWAYS_DEFINES_JVM="-DSPARC_WORKS -D_Crun_inline_placement"
+    ALWAYS_DEFINES_JDK="-DTRACING -DMACRO_MEMSYS_OPS -DBREAKPTS"
+    ALWAYS_DEFINES_JDK_CXXONLY="-DCC_NOEX"
+  elif test "x$TOOLCHAIN_TYPE" = xxlc; then
+    ALWAYS_DEFINES_JVM="-D_REENTRANT"
+    ALWAYS_DEFINES_JDK="-D_GNU_SOURCE -D_REENTRANT -D_LARGEFILE64_SOURCE -DSTDC"
+  elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
+    ALWAYS_DEFINES_JDK="-DWIN32_LEAN_AND_MEAN -D_CRT_SECURE_NO_DEPRECATE \
+        -D_CRT_NONSTDC_NO_DEPRECATE -DWIN32 -DIAL"
+  fi
+
+  ###############################################################################
+  #
+  #
+  # CFLAGS BASIC
+  if test "x$TOOLCHAIN_TYPE" = xgcc || test "x$TOOLCHAIN_TYPE" = xclang; then
+    # COMMON to gcc and clang
+    TOOLCHAIN_CFLAGS_JVM="-pipe -fno-rtti -fno-exceptions \
+        -fvisibility=hidden -fno-strict-aliasing -fno-omit-frame-pointer"
+  fi
+
+  if test "x$TOOLCHAIN_TYPE" = xgcc; then
+    TOOLCHAIN_CFLAGS_JVM="$TOOLCHAIN_CFLAGS_JVM -fcheck-new"
+    TOOLCHAIN_CFLAGS_JDK="-pipe"
+    TOOLCHAIN_CFLAGS_JDK_CONLY="-fno-strict-aliasing" # technically NOT for CXX (but since this gives *worse* performance, use no-strict-aliasing everywhere!)
+
+    CXXSTD_CXXFLAG="-std=gnu++98"
+    FLAGS_CXX_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [$CXXSTD_CXXFLAG -Werror],
+    						 IF_FALSE: [CXXSTD_CXXFLAG=""])
+    TOOLCHAIN_CFLAGS_JDK_CXXONLY="$CXXSTD_CXXFLAG"
+    TOOLCHAIN_CFLAGS_JVM="$TOOLCHAIN_CFLAGS_JVM $CXXSTD_CXXFLAG"
+    ADLC_CXXFLAG="$CXXSTD_CXXFLAG"
+
+
+  elif test "x$TOOLCHAIN_TYPE" = xclang; then
+    # Restrict the debug information created by Clang to avoid
+    # too big object files and speed the build up a little bit
+    # (see http://llvm.org/bugs/show_bug.cgi?id=7554)
+    TOOLCHAIN_CFLAGS_JVM="$TOOLCHAIN_CFLAGS_JVM -flimit-debug-info"
+
+    if test "x$OPENJDK_TARGET_OS" = xlinux; then
+      TOOLCHAIN_CFLAGS_JDK="-pipe"
+      TOOLCHAIN_CFLAGS_JDK_CONLY="-fno-strict-aliasing" # technically NOT for CXX
+    fi
+  elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
+    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="-template=no%extdef -features=no%split_init \
+        -library=stlport4 -mt -features=no%except"
+    if test "x$DEBUG_LEVEL" = xslowdebug; then
+      # Previously -g was used instead of -g0 for slowdebug; this is equivalent
+      # to setting +d.
+      TOOLCHAIN_CFLAGS_JVM="$TOOLCHAIN_CFLAGS_JVM +d"
+    fi
+
+  elif test "x$TOOLCHAIN_TYPE" = xxlc; then
+    TOOLCHAIN_CFLAGS_JDK="-qchars=signed -qfullpath -qsaveopt"  # add on both CFLAGS
+    TOOLCHAIN_CFLAGS_JVM="-qtune=balanced \
+        -qalias=noansi -qstrict -qtls=default -qlanglvl=c99vla \
+        -qlanglvl=noredefmac -qnortti -qnoeh -qignerrno"
+  elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
+    TOOLCHAIN_CFLAGS_JVM="-nologo -MD -MP"
+    TOOLCHAIN_CFLAGS_JDK="-nologo -MD -Zc:wchar_t-"
+  fi
+
+  # CFLAGS WARNINGS STUFF
+  # Set JVM_CFLAGS warning handling
+  if test "x$TOOLCHAIN_TYPE" = xgcc || test "x$TOOLCHAIN_TYPE" = xclang; then
+    # COMMON to gcc and clang
+    WARNING_CFLAGS_JVM="-Wpointer-arith -Wsign-compare -Wunused-function"
+    if ! HOTSPOT_CHECK_JVM_VARIANT(zero); then
+      # Non-zero builds have stricter warnings
+      WARNING_CFLAGS_JVM="$WARNING_CFLAGS_JVM -Wundef -Wformat=2"
+    fi
+
+  fi
+  if test "x$TOOLCHAIN_TYPE" = xgcc; then
+    WARNING_CFLAGS_JDK="-Wall -Wextra -Wno-unused -Wno-unused-parameter -Wformat=2"
+    WARNING_CFLAGS_JVM="$WARNING_CFLAGS_JVM -Wunused-value -Woverloaded-virtual"
+
+    if ! HOTSPOT_CHECK_JVM_VARIANT(zero); then
+      # Non-zero builds have stricter warnings
+      WARNING_CFLAGS_JVM="$WARNING_CFLAGS_JVM -Wreturn-type"
+    fi
+  elif test "x$TOOLCHAIN_TYPE" = xclang; then
+    WARNING_CFLAGS_JVM="$WARNING_CFLAGS_JVM -Wno-deprecated"
+    if test "x$OPENJDK_TARGET_OS" = xlinux; then
+      WARNING_CFLAGS_JVM="$WARNING_CFLAGS_JVM -Wno-sometimes-uninitialized"
+      WARNING_CFLAGS_JDK="-Wall -Wextra -Wno-unused -Wno-unused-parameter -Wformat=2"
+    fi
+  elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
+    WARNING_CFLAGS_JDK_CONLY="-errshort=tags"
+    WARNING_CFLAGS_JDK_CXXONLY="+w"
+    WARNING_CFLAGS_JDK="-errtags=yes -errfmt"
+  elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
+    WARNING_CFLAGS="-W3"
+    WARNING_CFLAGS_JDK="-wd4800"
+  fi
+
+  # Set some additional per-OS defines.
+
+  # Additional macosx handling
+  if test "x$OPENJDK_TARGET_OS" = xmacosx; then
+    OS_CFLAGS="-DMAC_OS_X_VERSION_MIN_REQUIRED=$MACOSX_VERSION_MIN_NODOTS \
+        -mmacosx-version-min=$MACOSX_VERSION_MIN"
+
+    if test -n "$MACOSX_VERSION_MAX"; then
+        OS_CFLAGS="$OS_CFLAGS \
+            -DMAC_OS_X_VERSION_MAX_ALLOWED=$MACOSX_VERSION_MAX_NODOTS"
+    fi
+  fi
+
+  # Where does this really belong??
+  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 JVM
+  #
+  # Check if clock_gettime is available and in which library. This indicates
+  # availability of CLOCK_MONOTONIC for hotspot. But we don't need to link, so
+  # don't let it update LIBS.
+  save_LIBS="$LIBS"
+  AC_SEARCH_LIBS(clock_gettime, rt, [HAS_CLOCK_GETTIME=true], [])
+  if test "x$LIBS" = "x-lrt "; then
+    CLOCK_GETTIME_IN_LIBRT=true
+  fi
+  LIBS="$save_LIBS"
+
+  if test "x$HAS_CLOCK_GETTIME" = "xtrue"; then
+    OS_CFLAGS_JVM="$OS_CFLAGS_JVM -DSUPPORTS_CLOCK_MONOTONIC"
+    if test "x$CLOCK_GETTIME_IN_LIBRT" = "xtrue"; then
+      OS_CFLAGS_JVM="$OS_CFLAGS_JVM -DNEEDS_LIBRT"
+    fi
+  fi
+
+  # EXPORT
+  AC_SUBST(ADLC_CXXFLAG)
+])
+
+################################################################################
+# $1 - Either BUILD or TARGET to pick the correct OS/CPU variables to check
+#      conditionals against.
+# $2 - Optional prefix for each variable defined.
+AC_DEFUN([FLAGS_SETUP_CFLAGS_CPU_DEP],
+[
+  #### CPU DEFINES, these should (in theory) be independent on toolchain
+
+  # Setup target CPU
+  # Setup endianness
+  if test "x$FLAGS_CPU_ENDIAN" = xlittle; then
+    $1_DEFINES_CPU_JVM="-DVM_LITTLE_ENDIAN"
+  fi
+  if test "x$TOOLCHAIN_TYPE" = xsolstudio; then
+    # The macro _LITTLE_ENDIAN needs to be defined the same to avoid the
+    #   Sun C compiler warning message: warning: macro redefined: _LITTLE_ENDIAN
+    if test "x$FLAGS_CPU_ENDIAN" = xlittle; then
+      $1_DEFINES_CPU_JDK="-D_LITTLE_ENDIAN="
+    else
+      $1_DEFINES_CPU_JDK="-D_BIG_ENDIAN="
+    fi
+  else
+    if test "x$FLAGS_CPU_ENDIAN" = xlittle; then
+      $1_DEFINES_CPU_JDK="-D_LITTLE_ENDIAN"
+    else
+      $1_DEFINES_CPU_JDK="-D_BIG_ENDIAN"
+    fi
+  fi
+
+  # setup CPU bit size
+  $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.
+      $1_DEFINES_CPU_JVM="${$1_DEFINES_CPU_JVM} -D_LP64=1"
+    fi
+  fi
+
+  # toolchain dependend, per-cpu
+  if test "x$TOOLCHAIN_TYPE" = xsolstudio; then
+    if test "x$FLAGS_CPU_ARCH" = xx86; then
+      $1_DEFINES_CPU_JDK="${$1_DEFINES_CPU_JDK} -DcpuIntel -Di586 -D$FLAGS_CPU_LEGACY_LIB"
+    fi
+  elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
+    if test "x$FLAGS_CPU" = xx86_64; then
+      $1_DEFINES_CPU_JDK="${$1_DEFINES_CPU_JDK} -D_AMD64_ -Damd64"
+    else
+      $1_DEFINES_CPU_JDK="${$1_DEFINES_CPU_JDK} -D_X86_ -Dx86"
+    fi
+  fi
+
+  # CFLAGS PER CPU
+  if test "x$TOOLCHAIN_TYPE" = xgcc || test "x$TOOLCHAIN_TYPE" = xclang; then
+    # COMMON to gcc and clang
+    if test "x$FLAGS_CPU" = xx86; then
+      # Force compatibility with i586 on 32 bit intel platforms.
+      $1_CFLAGS_CPU="-march=i586"
+    fi
+  fi
+
+  if test "x$TOOLCHAIN_TYPE" = xgcc; then
+    if test "x$FLAGS_CPU" = xarm; then
+      # -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
+        # -mminimal-toc fixes `relocation truncated to fit' error for gcc 4.1.
+        # Use ppc64 instructions, but schedule for power5
+        $1_CFLAGS_CPU_JVM="${$1_CFLAGS_CPU_JVM} -mminimal-toc -mcpu=powerpc64 -mtune=power5"
+      elif test "x$FLAGS_CPU" = xppc64le; then
+        # Little endian machine uses ELFv2 ABI.
+        # Use Power8, this is the first CPU to support PPC64 LE with ELFv2 ABI.
+        $1_CFLAGS_CPU_JVM="${$1_CFLAGS_CPU_JVM} -DABI_ELFv2 -mcpu=power8 -mtune=power8"
+      fi
+    elif test "x$FLAGS_CPU" = xs390x; then
+      $1_CFLAGS_CPU="-mbackchain -march=z10"
+    fi
+
+    if test "x$FLAGS_CPU_ARCH" != xarm &&  test "x$FLAGS_CPU_ARCH" != xppc; then
+      # for all archs except arm and ppc, prevent gcc to omit frame pointer
+      $1_CFLAGS_CPU_JDK="${$1_CFLAGS_CPU_JDK} -fno-omit-frame-pointer"
+    fi
+
+  elif test "x$TOOLCHAIN_TYPE" = xclang; then
+    if test "x$FLAGS_OS" = xlinux; then
+      # ppc test not really needed for clang
+      if test "x$FLAGS_CPU_ARCH" != xarm &&  test "x$FLAGS_CPU_ARCH" != xppc; then
+        # for all archs except arm and ppc, prevent gcc to omit frame pointer
+        $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" = xx86_64; then
+      # NOTE: -xregs=no%frameptr is supposed to be default on x64
+      $1_CFLAGS_CPU_JDK="-xregs=no%frameptr"
+    elif test "x$FLAGS_CPU" = xsparcv9; then
+      $1_CFLAGS_CPU_JVM="-xarch=sparc"
+      $1_CFLAGS_CPU_JDK_LIBONLY="-xregs=no%appl"
+    fi
+
+  elif test "x$TOOLCHAIN_TYPE" = xxlc; then
+    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"
+    elif test "x$OPENJDK_TARGET_CPU" = xx86_64; then
+      if test "x$DEBUG_LEVEL" != xrelease; then
+        # NOTE: This is probably redundant; -homeparams is default on
+        # non-release builds.
+        $1_CFLAGS_CPU_JVM="-homeparams"
+      fi
+    fi
+  fi
+
+  if test "x$TOOLCHAIN_TYPE" = xgcc; then
+    TOOLCHAIN_CHECK_COMPILER_VERSION(VERSION: 6, PREFIX: $2, IF_AT_LEAST: FLAGS_SETUP_GCC6_COMPILER_FLAGS($1))
+    $1_TOOLCHAIN_CFLAGS="${$1_GCC6_CFLAGS}"
+
+    $1_WARNING_CFLAGS_JVM="-Wno-format-zero-length -Wtype-limits -Wuninitialized"
+  fi
+
+  # 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 $JVM_PICFLAG"
+
+  CFLAGS_JDK_COMMON="$ALWAYS_CFLAGS_JDK $ALWAYS_DEFINES_JDK $TOOLCHAIN_CFLAGS_JDK \
+      $OS_CFLAGS $CFLAGS_OS_DEF_JDK $DEBUG_CFLAGS_JDK $DEBUG_OPTIONS_FLAGS_JDK \
+      $WARNING_CFLAGS $WARNING_CFLAGS_JDK $DEBUG_SYMBOLS_CFLAGS_JDK"
+
+  # Use ${$2EXTRA_CFLAGS} to block EXTRA_CFLAGS to be added to build flags.
+  # (Currently we don't have any OPENJDK_BUILD_EXTRA_CFLAGS, but that might
+  # change in the future.)
+
+  CFLAGS_JDK_COMMON_CONLY="$TOOLCHAIN_CFLAGS_JDK_CONLY  \
+      $WARNING_CFLAGS_JDK_CONLY ${$2EXTRA_CFLAGS}"
+  CFLAGS_JDK_COMMON_CXXONLY="$ALWAYS_DEFINES_JDK_CXXONLY $TOOLCHAIN_CFLAGS_JDK_CXXONLY \
+      $WARNING_CFLAGS_JDK_CXXONLY ${$2EXTRA_CXXFLAGS}"
+
+  $1_CFLAGS_JVM="${$1_DEFINES_CPU_JVM} ${$1_CFLAGS_CPU} ${$1_CFLAGS_CPU_JVM} ${$1_TOOLCHAIN_CFLAGS} ${$1_WARNING_CFLAGS_JVM}"
+  $1_CFLAGS_JDK="${$1_DEFINES_CPU_JDK} ${$1_CFLAGS_CPU} ${$1_CFLAGS_CPU_JDK} ${$1_TOOLCHAIN_CFLAGS}"
+
+  $2JVM_CFLAGS="$CFLAGS_JVM_COMMON ${$1_CFLAGS_JVM} ${$2EXTRA_CXXFLAGS}"
+
+  $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} $JDK_PICFLAG ${$1_CFLAGS_CPU_JDK_LIBONLY}"
+  $2CXXFLAGS_JDKLIB="${$2CXXFLAGS_JDKEXE} $JDK_PICFLAG ${$1_CFLAGS_CPU_JDK_LIBONLY}"
+
+  AC_SUBST($2JVM_CFLAGS)
+  AC_SUBST($2CFLAGS_JDKLIB)
+  AC_SUBST($2CFLAGS_JDKEXE)
+  AC_SUBST($2CXXFLAGS_JDKLIB)
+  AC_SUBST($2CXXFLAGS_JDKEXE)
+])
+
+# FLAGS_SETUP_GCC6_COMPILER_FLAGS([PREFIX])
+# Arguments:
+# $1 - Prefix for each variable defined.
+AC_DEFUN([FLAGS_SETUP_GCC6_COMPILER_FLAGS],
+[
+  # These flags are required for GCC 6 builds as undefined behaviour in OpenJDK code
+  # runs afoul of the more aggressive versions of these optimisations.
+  # Notably, value range propagation now assumes that the this pointer of C++
+  # member functions is non-null.
+  NO_DELETE_NULL_POINTER_CHECKS_CFLAG="-fno-delete-null-pointer-checks"
+  dnl Argument check is disabled until FLAGS_COMPILER_CHECK_ARGUMENTS handles cross-compilation
+  dnl FLAGS_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [$NO_DELETE_NULL_POINTER_CHECKS_CFLAG -Werror],
+  dnl					     IF_FALSE: [NO_DELETE_NULL_POINTER_CHECKS_CFLAG=""])
+  NO_LIFETIME_DSE_CFLAG="-fno-lifetime-dse"
+  dnl Argument check is disabled until FLAGS_COMPILER_CHECK_ARGUMENTS handles cross-compilation
+  dnl FLAGS_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [$NO_LIFETIME_DSE_CFLAG -Werror],
+  dnl					     IF_FALSE: [NO_LIFETIME_DSE_CFLAG=""])
+  AC_MSG_NOTICE([GCC >= 6 detected; adding ${NO_DELETE_NULL_POINTER_CHECKS_CFLAG} and ${NO_LIFETIME_DSE_CFLAG}])
+  $1_GCC6_CFLAGS="${NO_DELETE_NULL_POINTER_CHECKS_CFLAG} ${NO_LIFETIME_DSE_CFLAG}"
+])
+
+# Documentation on common flags used for solstudio in HIGHEST.
+#
+# WARNING: Use of OPTIMIZATION_LEVEL=HIGHEST in your Makefile needs to be
+#          done with care, there are some assumptions below that need to
+#          be understood about the use of pointers, and IEEE behavior.
+#
+# -fns: Use non-standard floating point mode (not IEEE 754)
+# -fsimple: Do some simplification of floating point arithmetic (not IEEE 754)
+# -fsingle: Use single precision floating point with 'float'
+# -xalias_level=basic: Assume memory references via basic pointer types do not alias
+#   (Source with excessing pointer casting and data access with mixed
+#    pointer types are not recommended)
+# -xbuiltin=%all: Use intrinsic or inline versions for math/std functions
+#   (If you expect perfect errno behavior, do not use this)
+# -xdepend: Loop data dependency optimizations (need -xO3 or higher)
+# -xrestrict: Pointer parameters to functions do not overlap
+#   (Similar to -xalias_level=basic usage, but less obvious sometimes.
+#    If you pass in multiple pointers to the same data, do not use this)
+# -xlibmil: Inline some library routines
+#   (If you expect perfect errno behavior, do not use this)
+# -xlibmopt: Use optimized math routines (CURRENTLY DISABLED)
+#   (If you expect perfect errno behavior, do not use this)
+#  Can cause undefined external on Solaris 8 X86 on __sincos, removing for now
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/make/autoconf/flags-ldflags.m4	Tue Apr 10 18:20:45 2018 +0100
@@ -0,0 +1,212 @@
+#
+# 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
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.  Oracle designates this
+# particular file as subject to the "Classpath" exception as provided
+# by Oracle in the LICENSE file that accompanied this code.
+#
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+# or visit www.oracle.com if you need additional information or have any
+# questions.
+#
+
+################################################################################
+#
+
+AC_DEFUN([FLAGS_SETUP_LDFLAGS],
+[
+  FLAGS_SETUP_LDFLAGS_HELPER
+
+  # 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
+  # rest, the dir is just server.
+  if HOTSPOT_CHECK_JVM_VARIANT(server) || HOTSPOT_CHECK_JVM_VARIANT(client) \
+      || HOTSPOT_CHECK_JVM_VARIANT(minimal); then
+    TARGET_JVM_VARIANT_PATH=$JVM_VARIANT_MAIN
+  else
+    TARGET_JVM_VARIANT_PATH=server
+  fi
+  FLAGS_SETUP_LDFLAGS_CPU_DEP([TARGET])
+
+  # Setup the build toolchain
+
+  # When building a buildjdk, it's always only the server variant
+  BUILD_JVM_VARIANT_PATH=server
+
+  FLAGS_SETUP_LDFLAGS_CPU_DEP([BUILD], [OPENJDK_BUILD_])
+
+  LDFLAGS_TESTLIB="$LDFLAGS_JDKLIB"
+  LDFLAGS_TESTEXE="$LDFLAGS_JDKEXE ${TARGET_LDFLAGS_JDK_LIBPATH}"
+  AC_SUBST(LDFLAGS_TESTLIB)
+  AC_SUBST(LDFLAGS_TESTEXE)
+])
+
+################################################################################
+
+# CPU independent LDFLAGS setup, used for both target and build toolchain.
+AC_DEFUN([FLAGS_SETUP_LDFLAGS_HELPER],
+[
+  # Setup basic LDFLAGS
+  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"
+    fi
+
+    # Add -z defs, to forbid undefined symbols in object files.
+    BASIC_LDFLAGS="$BASIC_LDFLAGS -Wl,-z,defs"
+
+    BASIC_LDFLAGS_JVM_ONLY="-Wl,-z,noexecstack -Wl,-O1 -Wl,-z,relro"
+
+    BASIC_LDFLAGS_JDK_LIB_ONLY="-Wl,-z,noexecstack"
+    LIBJSIG_NOEXECSTACK_LDFLAGS="-Wl,-z,noexecstack"
+
+  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"
+    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
+
+  # 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.
+      # FIXME: We should really generalize SET_SHARED_LIBRARY_ORIGIN instead.
+      OS_LDFLAGS_JVM_ONLY="-Wl,-rpath,@loader_path/. -Wl,-rpath,@loader_path/.."
+      OS_LDFLAGS_JDK_ONLY="-mmacosx-version-min=$MACOSX_VERSION_MIN"
+    fi
+  fi
+
+  # 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
+        DEBUGLEVEL_LDFLAGS_JDK_ONLY="$DEBUGLEVEL_LDFLAGS_JDK_ONLY -Wl,-O1"
+      else
+        # mark relocations read only on (fast/slow) debug builds
+        DEBUGLEVEL_LDFLAGS_JDK_ONLY="-Wl,-z,relro"
+      fi
+      if test x$DEBUG_LEVEL = xslowdebug; then
+        # do relocations at load
+        DEBUGLEVEL_LDFLAGS="-Wl,-z,now"
+      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="$DEBUGLEVEL_LDFLAGS_JVM_ONLY -bbigtoc"
+    fi
+  fi
+
+  # Setup LDFLAGS for linking executables
+  if test "x$TOOLCHAIN_TYPE" = xgcc; then
+    EXECUTABLE_LDFLAGS="$EXECUTABLE_LDFLAGS -Wl,--allow-shlib-undefined"
+  fi
+
+  # Export some intermediate variables for compatibility
+  LDFLAGS_CXX_JDK="$BASIC_LDFLAGS_ONLYCXX $BASIC_LDFLAGS_ONLYCXX_JDK_ONLY $DEBUGLEVEL_LDFLAGS_JDK_ONLY"
+  AC_SUBST(LDFLAGS_CXX_JDK)
+  AC_SUBST(LIBJSIG_HASHSTYLE_LDFLAGS)
+  AC_SUBST(LIBJSIG_NOEXECSTACK_LDFLAGS)
+])
+
+################################################################################
+# $1 - Either BUILD or TARGET to pick the correct OS/CPU variables to check
+#      conditionals against.
+# $2 - Optional prefix for each variable defined.
+AC_DEFUN([FLAGS_SETUP_LDFLAGS_CPU_DEP],
+[
+  # 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"
+    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"
+      $1_CPU_EXECUTABLE_LDFLAGS="-stack:327680"
+    else
+      $1_CPU_LDFLAGS_JVM_ONLY="-machine:AMD64"
+      $1_CPU_EXECUTABLE_LDFLAGS="-stack:1048576"
+    fi
+  fi
+
+  # JVM_VARIANT_PATH depends on if this is build or target...
+  if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
+    $1_LDFLAGS_JDK_LIBPATH="-libpath:${OUTPUTDIR}/support/modules_libs/java.base"
+  else
+    $1_LDFLAGS_JDK_LIBPATH="-L\$(SUPPORT_OUTPUTDIR)/modules_libs/java.base \
+        -L\$(SUPPORT_OUTPUTDIR)/modules_libs/java.base/${$1_JVM_VARIANT_PATH}"
+  fi
+
+  # 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 ${$2EXTRA_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 \
+      ${$1_CPU_LDFLAGS} ${$1_CPU_LDFLAGS_JVM_ONLY} ${$2EXTRA_LDFLAGS}"
+
+  AC_SUBST($2LDFLAGS_JDKLIB)
+  AC_SUBST($2LDFLAGS_JDKEXE)
+
+  AC_SUBST($2JVM_LDFLAGS)
+])
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/make/autoconf/flags-other.m4	Tue Apr 10 18:20:45 2018 +0100
@@ -0,0 +1,126 @@
+#
+# 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
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.  Oracle designates this
+# particular file as subject to the "Classpath" exception as provided
+# by Oracle in the LICENSE file that accompanied this code.
+#
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+# or visit www.oracle.com if you need additional information or have any
+# questions.
+#
+
+################################################################################
+#
+# Setup flags for other tools than C/C++ compiler
+#
+
+AC_DEFUN([FLAGS_SETUP_ARFLAGS],
+[
+  # FIXME: figure out if we should select AR flags depending on OS or toolchain.
+  if test "x$OPENJDK_TARGET_OS" = xmacosx; then
+    ARFLAGS="-r -mmacosx-version-min=$MACOSX_VERSION_MIN"
+  elif test "x$OPENJDK_TARGET_OS" = xaix; then
+    ARFLAGS="-X64"
+  elif test "x$OPENJDK_TARGET_OS" = xwindows; then
+    # lib.exe is used as AR to create static libraries.
+    ARFLAGS="-nologo -NODEFAULTLIB:MSVCRT"
+  else
+    ARFLAGS=""
+  fi
+
+  AC_SUBST(ARFLAGS)
+])
+
+AC_DEFUN([FLAGS_SETUP_STRIPFLAGS],
+[
+  ## Setup strip.
+  # FIXME: should this really be per platform, or should it be per toolchain type?
+  # strip is not provided by clang or solstudio; so guessing platform makes most sense.
+  # FIXME: we should really only export STRIPFLAGS from here, not POST_STRIP_CMD.
+  if test "x$OPENJDK_TARGET_OS" = xlinux; then
+    STRIPFLAGS="-g"
+  elif test "x$OPENJDK_TARGET_OS" = xsolaris; then
+    STRIPFLAGS="-x"
+  elif test "x$OPENJDK_TARGET_OS" = xmacosx; then
+    STRIPFLAGS="-S"
+  elif test "x$OPENJDK_TARGET_OS" = xaix; then
+    STRIPFLAGS="-X32_64"
+  fi
+
+  AC_SUBST(STRIPFLAGS)
+])
+
+AC_DEFUN([FLAGS_SETUP_RCFLAGS],
+[
+  # On Windows, we need to set RC flags.
+  if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
+    RC_FLAGS="-nologo -l0x409"
+    JVM_RCFLAGS="-nologo"
+    if test "x$DEBUG_LEVEL" = xrelease; then
+      RC_FLAGS="$RC_FLAGS -DNDEBUG"
+      JVM_RCFLAGS="$JVM_RCFLAGS -DNDEBUG"
+    fi
+
+    # The version variables used to create RC_FLAGS may be overridden
+    # in a custom configure script, or possibly the command line.
+    # Let those variables be expanded at make time in spec.gmk.
+    # The \$ are escaped to the shell, and the $(...) variables
+    # are evaluated by make.
+    RC_FLAGS="$RC_FLAGS \
+        -D\"JDK_VERSION_STRING=\$(VERSION_STRING)\" \
+        -D\"JDK_COMPANY=\$(COMPANY_NAME)\" \
+        -D\"JDK_COMPONENT=\$(PRODUCT_NAME) \$(JDK_RC_PLATFORM_NAME) binary\" \
+        -D\"JDK_VER=\$(VERSION_NUMBER)\" \
+        -D\"JDK_COPYRIGHT=Copyright \xA9 $COPYRIGHT_YEAR\" \
+        -D\"JDK_NAME=\$(PRODUCT_NAME) \$(JDK_RC_PLATFORM_NAME) \$(VERSION_FEATURE)\" \
+        -D\"JDK_FVER=\$(subst .,\$(COMMA),\$(VERSION_NUMBER_FOUR_POSITIONS))\""
+
+    JVM_RCFLAGS="$JVM_RCFLAGS \
+        -D\"HS_BUILD_ID=\$(VERSION_STRING)\" \
+        -D\"HS_COMPANY=\$(COMPANY_NAME)\" \
+        -D\"JDK_DOTVER=\$(VERSION_NUMBER_FOUR_POSITIONS)\" \
+        -D\"HS_COPYRIGHT=Copyright $COPYRIGHT_YEAR\" \
+        -D\"HS_NAME=\$(PRODUCT_NAME) \$(VERSION_SHORT)\" \
+        -D\"JDK_VER=\$(subst .,\$(COMMA),\$(VERSION_NUMBER_FOUR_POSITIONS))\" \
+        -D\"HS_FNAME=jvm.dll\" \
+        -D\"HS_INTERNAL_NAME=jvm\""
+  fi
+  AC_SUBST(RC_FLAGS)
+  AC_SUBST(JVM_RCFLAGS)
+])
+
+################################################################################
+# platform independent
+AC_DEFUN([FLAGS_SETUP_ASFLAGS],
+[
+  if test "x$OPENJDK_TARGET_OS" = xmacosx; then
+    JVM_BASIC_ASFLAGS="-x assembler-with-cpp -mno-omit-leaf-frame-pointer -mstack-alignment=16"
+  fi
+])
+
+################################################################################
+# $1 - Either BUILD or TARGET to pick the correct OS/CPU variables to check
+#      conditionals against.
+# $2 - Optional prefix for each variable defined.
+AC_DEFUN([FLAGS_SETUP_ASFLAGS_CPU_DEP],
+[
+  # Misuse EXTRA_CFLAGS to mimic old behavior
+  $2JVM_ASFLAGS="$JVM_BASIC_ASFLAGS ${$2EXTRA_CFLAGS}"
+
+  AC_SUBST($2JVM_ASFLAGS)
+])
+
--- a/make/autoconf/flags.m4	Wed Mar 21 10:35:21 2018 -0300
+++ b/make/autoconf/flags.m4	Tue Apr 10 18:20:45 2018 +0100
@@ -23,6 +23,10 @@
 # questions.
 #
 
+m4_include([flags-cflags.m4])
+m4_include([flags-ldflags.m4])
+m4_include([flags-other.m4])
+
 ################################################################################
 #
 # Setup ABI profile (for arm)
@@ -94,21 +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"
-    # 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.
-    if test "x$OPENJDK_TARGET_CPU" = xarm; then
-        EXTRA_CFLAGS="$EXTRA_CFLAGS -Wno-psabi"
-        EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS -Wno-psabi"
-    fi
-    # 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
@@ -118,19 +107,58 @@
   fi
 ])
 
+AC_DEFUN([FLAGS_SETUP_MACOSX_VERSION],
+[
+  # Additional macosx handling
+  if test "x$OPENJDK_TARGET_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
+    MACOSX_VERSION_MIN_NODOTS=${MACOSX_VERSION_MIN//\./}
+
+    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=]
+    )
+    MACOSX_VERSION_MAX_NODOTS=${MACOSX_VERSION_MAX//\./}
+
+    AC_SUBST(MACOSX_VERSION_MAX)
+  fi
+])
+
 # Reset the global CFLAGS/LDFLAGS variables and initialize them with the
 # 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
 
@@ -143,20 +171,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
@@ -175,6 +192,16 @@
         $1SYSROOT_CFLAGS="-I-xbuiltin -I[$]$1SYSROOT/usr/include"
         $1SYSROOT_LDFLAGS="-L[$]$1SYSROOT/usr/lib$OPENJDK_TARGET_CPU_ISADIR \
             -L[$]$1SYSROOT/lib$OPENJDK_TARGET_CPU_ISADIR"
+        # If the devkit contains the ld linker, make sure we use it.
+        AC_PATH_PROG(SOLARIS_LD, ld, , $DEVKIT_TOOLCHAIN_PATH:$DEVKIT_EXTRA_PATH)
+        # Make sure this ld is runnable.
+        if test -f "$SOLARIS_LD"; then
+          if "$SOLARIS_LD" -V > /dev/null 2> /dev/null; then
+            $1SYSROOT_LDFLAGS="[$]$1SYSROOT_LDFLAGS -Yl,$(dirname $SOLARIS_LD)"
+          else
+            AC_MSG_WARN([Could not run $SOLARIS_LD found in devkit, reverting to system ld])
+          fi
+        fi
       fi
     elif test "x$TOOLCHAIN_TYPE" = xgcc; then
       $1SYSROOT_CFLAGS="--sysroot=[$]$1SYSROOT"
@@ -183,11 +210,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
@@ -204,7 +226,53 @@
   AC_SUBST($1SYSROOT_LDFLAGS)
 ])
 
-AC_DEFUN_ONCE([FLAGS_SETUP_INIT_FLAGS],
+AC_DEFUN_ONCE([FLAGS_PRE_TOOLCHAIN],
+[
+  # We should always include user supplied flags
+  FLAGS_SETUP_USER_SUPPLIED_FLAGS
+  # The sysroot flags are needed for configure to be able to run the compilers
+  FLAGS_SETUP_SYSROOT_FLAGS
+
+  if test "x$TOOLCHAIN_TYPE" = xxlc; then
+    MACHINE_FLAG="-q${OPENJDK_TARGET_CPU_BITS}"
+  elif test "x$TOOLCHAIN_TYPE" != xmicrosoft; then
+    if test "x$OPENJDK_TARGET_CPU" != xaarch64 &&
+        test "x$OPENJDK_TARGET_CPU" != xarm; then
+      MACHINE_FLAG="-m${OPENJDK_TARGET_CPU_BITS}"
+    fi
+  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([FLAGS_SETUP_TOOLCHAIN_CONTROL],
 [
   # COMPILER_TARGET_BITS_FLAG  : option for selecting 32- or 64-bit output
   # COMPILER_COMMAND_FILE_FLAG : option for passing a command file to the compiler
@@ -239,38 +307,17 @@
       $RM command.file
     fi
   fi
+
   AC_SUBST(COMPILER_TARGET_BITS_FLAG)
   AC_SUBST(COMPILER_COMMAND_FILE_FLAG)
   AC_SUBST(COMPILER_BINDCMD_FILE_FLAG)
 
-  # FIXME: figure out if we should select AR flags depending on OS or toolchain.
-  if test "x$OPENJDK_TARGET_OS" = xmacosx; then
-    ARFLAGS="-r"
-  elif test "x$OPENJDK_TARGET_OS" = xaix; then
-    ARFLAGS="-X64"
-  elif test "x$OPENJDK_TARGET_OS" = xwindows; then
-    # lib.exe is used as AR to create static libraries.
-    ARFLAGS="-nologo -NODEFAULTLIB:MSVCRT"
-  else
-    ARFLAGS=""
-  fi
-  AC_SUBST(ARFLAGS)
-
-  ## Setup strip.
-  # FIXME: should this really be per platform, or should it be per toolchain type?
-  # strip is not provided by clang or solstudio; so guessing platform makes most sense.
-  # FIXME: we should really only export STRIPFLAGS from here, not POST_STRIP_CMD.
-  if test "x$OPENJDK_TARGET_OS" = xlinux; then
-    STRIPFLAGS="-g"
-  elif test "x$OPENJDK_TARGET_OS" = xsolaris; then
-    STRIPFLAGS="-x"
-  elif test "x$OPENJDK_TARGET_OS" = xmacosx; then
-    STRIPFLAGS="-S"
-  elif test "x$OPENJDK_TARGET_OS" = xaix; then
-    STRIPFLAGS="-X32_64"
-  fi
-
-  AC_SUBST(STRIPFLAGS)
+  # Check that the compiler supports -mX (or -qX on AIX) flags
+  # Set COMPILER_SUPPORTS_TARGET_BITS_FLAG to 'true' if it does
+  FLAGS_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [${COMPILER_TARGET_BITS_FLAG}${OPENJDK_TARGET_CPU_BITS}],
+      IF_TRUE: [COMPILER_SUPPORTS_TARGET_BITS_FLAG=true],
+      IF_FALSE: [COMPILER_SUPPORTS_TARGET_BITS_FLAG=false])
+  AC_SUBST(COMPILER_SUPPORTS_TARGET_BITS_FLAG)
 
   if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
     CC_OUT_OPTION=-Fo
@@ -293,216 +340,6 @@
   AC_SUBST(LD_OUT_OPTION)
   AC_SUBST(AR_OUT_OPTION)
 
-  # On Windows, we need to set RC flags.
-  if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
-    RC_FLAGS="-nologo -l0x409"
-    JVM_RCFLAGS="-nologo"
-    if test "x$DEBUG_LEVEL" = xrelease; then
-      RC_FLAGS="$RC_FLAGS -DNDEBUG"
-      JVM_RCFLAGS="$JVM_RCFLAGS -DNDEBUG"
-    fi
-
-    # The version variables used to create RC_FLAGS may be overridden
-    # in a custom configure script, or possibly the command line.
-    # Let those variables be expanded at make time in spec.gmk.
-    # The \$ are escaped to the shell, and the $(...) variables
-    # are evaluated by make.
-    RC_FLAGS="$RC_FLAGS \
-        -D\"JDK_VERSION_STRING=\$(VERSION_STRING)\" \
-        -D\"JDK_COMPANY=\$(COMPANY_NAME)\" \
-        -D\"JDK_COMPONENT=\$(PRODUCT_NAME) \$(JDK_RC_PLATFORM_NAME) binary\" \
-        -D\"JDK_VER=\$(VERSION_NUMBER)\" \
-        -D\"JDK_COPYRIGHT=Copyright \xA9 $COPYRIGHT_YEAR\" \
-        -D\"JDK_NAME=\$(PRODUCT_NAME) \$(JDK_RC_PLATFORM_NAME) \$(VERSION_FEATURE)\" \
-        -D\"JDK_FVER=\$(subst .,\$(COMMA),\$(VERSION_NUMBER_FOUR_POSITIONS))\""
-
-    JVM_RCFLAGS="$JVM_RCFLAGS \
-        -D\"HS_BUILD_ID=\$(VERSION_STRING)\" \
-        -D\"HS_COMPANY=\$(COMPANY_NAME)\" \
-        -D\"JDK_DOTVER=\$(VERSION_NUMBER_FOUR_POSITIONS)\" \
-        -D\"HS_COPYRIGHT=Copyright $COPYRIGHT_YEAR\" \
-        -D\"HS_NAME=\$(PRODUCT_NAME) \$(VERSION_SHORT)\" \
-        -D\"JDK_VER=\$(subst .,\$(COMMA),\$(VERSION_NUMBER_FOUR_POSITIONS))\" \
-        -D\"HS_FNAME=jvm.dll\" \
-        -D\"HS_INTERNAL_NAME=jvm\""
-  fi
-  AC_SUBST(RC_FLAGS)
-  AC_SUBST(JVM_RCFLAGS)
-
-  if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
-    # silence copyright notice and other headers.
-    COMMON_CCXXFLAGS="$COMMON_CCXXFLAGS -nologo"
-  fi
-])
-
-AC_DEFUN([FLAGS_SETUP_COMPILER_FLAGS_FOR_LIBS],
-[
-  ###############################################################################
-  #
-  # How to compile shared libraries.
-  #
-
-  if test "x$TOOLCHAIN_TYPE" = xgcc; then
-    PICFLAG="-fPIC"
-    C_FLAG_REORDER=''
-    CXX_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 $PICFLAG"
-        JVM_CFLAGS="$JVM_CFLAGS $PICFLAG"
-      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 $PICFLAG"
-      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'
-
-      if test "x$STATIC_BUILD" = xfalse; then
-        JVM_CFLAGS="$JVM_CFLAGS -fPIC"
-      fi
-    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'
-      SET_SHARED_LIBRARY_MAPFILE='-Wl,-version-script=[$]1'
-
-      # arm specific settings
-      if test "x$OPENJDK_TARGET_CPU" = "xarm"; then
-        # '-Wl,-z,origin' isn't used on arm.
-        SET_SHARED_LIBRARY_ORIGIN='-Wl,-rpath,\$$$$ORIGIN[$]1'
-      else
-        SET_SHARED_LIBRARY_ORIGIN="-Wl,-z,origin $SET_EXECUTABLE_ORIGIN"
-      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"
-    JVM_CFLAGS="$JVM_CFLAGS $PICFLAG"
-    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=''
-    SET_SHARED_LIBRARY_NAME=''
-    SET_SHARED_LIBRARY_MAPFILE='-def:[$]1'
-  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)
-  AC_SUBST(SET_SHARED_LIBRARY_MAPFILE)
-  AC_SUBST(SHARED_LIBRARY_FLAGS)
-
-  # The (cross) compiler is now configured, we can now test capabilities
-  # of the target platform.
-])
-
-# Documentation on common flags used for solstudio in HIGHEST.
-#
-# WARNING: Use of OPTIMIZATION_LEVEL=HIGHEST in your Makefile needs to be
-#          done with care, there are some assumptions below that need to
-#          be understood about the use of pointers, and IEEE behavior.
-#
-# -fns: Use non-standard floating point mode (not IEEE 754)
-# -fsimple: Do some simplification of floating point arithmetic (not IEEE 754)
-# -fsingle: Use single precision floating point with 'float'
-# -xalias_level=basic: Assume memory references via basic pointer types do not alias
-#   (Source with excessing pointer casting and data access with mixed
-#    pointer types are not recommended)
-# -xbuiltin=%all: Use intrinsic or inline versions for math/std functions
-#   (If you expect perfect errno behavior, do not use this)
-# -xdepend: Loop data dependency optimizations (need -xO3 or higher)
-# -xrestrict: Pointer parameters to functions do not overlap
-#   (Similar to -xalias_level=basic usage, but less obvious sometimes.
-#    If you pass in multiple pointers to the same data, do not use this)
-# -xlibmil: Inline some library routines
-#   (If you expect perfect errno behavior, do not use this)
-# -xlibmopt: Use optimized math routines (CURRENTLY DISABLED)
-#   (If you expect perfect errno behavior, do not use this)
-#  Can cause undefined external on Solaris 8 X86 on __sincos, removing for now
-
-    # FIXME: this will never happen since sparc != sparcv9, ie 32 bit, which we don't build anymore.
-    # Bug?
-    #if test "x$OPENJDK_TARGET_CPU" = xsparc; then
-    #  CFLAGS_JDK="${CFLAGS_JDK} -xmemalign=4s"
-    #  CXXFLAGS_JDK="${CXXFLAGS_JDK} -xmemalign=4s"
-    #fi
-
-AC_DEFUN_ONCE([FLAGS_SETUP_COMPILER_FLAGS_FOR_OPTIMIZATION],
-[
-
-  ###############################################################################
-  #
-  # Setup the opt flags for different compilers
-  # and different operating systems.
-  #
-
-  # FIXME: this was indirectly the old default, but just inherited.
-  # if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
-  #   C_FLAG_DEPS="-MMD -MF"
-  # fi
-
   # Generate make dependency files
   if test "x$TOOLCHAIN_TYPE" = xgcc; then
     C_FLAG_DEPS="-MMD -MF"
@@ -516,887 +353,46 @@
   CXX_FLAG_DEPS="$C_FLAG_DEPS"
   AC_SUBST(C_FLAG_DEPS)
   AC_SUBST(CXX_FLAG_DEPS)
+])
 
-  # Debug symbols
-  if test "x$TOOLCHAIN_TYPE" = xgcc; then
-    if test "x$OPENJDK_TARGET_CPU_BITS" = "x64" && test "x$DEBUG_LEVEL" = "xfastdebug"; then
-      # reduce from default "-g2" option to save space
-      CFLAGS_DEBUG_SYMBOLS="-g1"
-      CXXFLAGS_DEBUG_SYMBOLS="-g1"
-    else
-      CFLAGS_DEBUG_SYMBOLS="-g"
-      CXXFLAGS_DEBUG_SYMBOLS="-g"
-    fi
-  elif test "x$TOOLCHAIN_TYPE" = xclang; then
-    CFLAGS_DEBUG_SYMBOLS="-g"
-    CXXFLAGS_DEBUG_SYMBOLS="-g"
-  elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
-    CFLAGS_DEBUG_SYMBOLS="-g -xs"
-    # -g0 enables debug symbols without disabling inlining.
-    CXXFLAGS_DEBUG_SYMBOLS="-g0 -xs"
-  elif test "x$TOOLCHAIN_TYPE" = xxlc; then
-    CFLAGS_DEBUG_SYMBOLS="-g"
-    CXXFLAGS_DEBUG_SYMBOLS="-g"
-  elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
-    CFLAGS_DEBUG_SYMBOLS="-Zi"
-    CXXFLAGS_DEBUG_SYMBOLS="-Zi"
-  fi
-  AC_SUBST(CFLAGS_DEBUG_SYMBOLS)
-  AC_SUBST(CXXFLAGS_DEBUG_SYMBOLS)
+AC_DEFUN_ONCE([FLAGS_POST_TOOLCHAIN],
+[
+  FLAGS_SETUP_TOOLCHAIN_CONTROL
 
-  # Debug symbols for JVM_CFLAGS
-  if test "x$TOOLCHAIN_TYPE" = xsolstudio; then
-    JVM_CFLAGS_SYMBOLS="$JVM_CFLAGS_SYMBOLS -xs"
-    if test "x$DEBUG_LEVEL" = xslowdebug; then
-      JVM_CFLAGS_SYMBOLS="$JVM_CFLAGS_SYMBOLS -g"
-    else
-      # -g0 does not disable inlining, which -g does.
-      JVM_CFLAGS_SYMBOLS="$JVM_CFLAGS_SYMBOLS -g0"
-    fi
-  elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
-    JVM_CFLAGS_SYMBOLS="$JVM_CFLAGS_SYMBOLS -Z7 -d2Zi+"
+  if test "x$BUILD_SYSROOT" != x; then
+    FLAGS_SETUP_SYSROOT_FLAGS([BUILD_])
   else
-    JVM_CFLAGS_SYMBOLS="$JVM_CFLAGS_SYMBOLS -g"
-  fi
-  AC_SUBST(JVM_CFLAGS_SYMBOLS)
-
-  # bounds, memory and behavior checking options
-  if test "x$TOOLCHAIN_TYPE" = xgcc; then
-    case $DEBUG_LEVEL in
-    release )
-      # no adjustment
-      ;;
-    fastdebug )
-      # no adjustment
-      ;;
-    slowdebug )
-      # FIXME: By adding this to C(XX)FLAGS_DEBUG_OPTIONS/JVM_CFLAGS_SYMBOLS it
-      # get's added conditionally on whether we produce debug symbols or not.
-      # This is most likely not really correct.
-
-      # 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=""])
-
-      CFLAGS_DEBUG_OPTIONS="$STACK_PROTECTOR_CFLAG --param ssp-buffer-size=1"
-      CXXFLAGS_DEBUG_OPTIONS="$STACK_PROTECTOR_CFLAG --param ssp-buffer-size=1"
-      if test "x$STACK_PROTECTOR_CFLAG" != x; then
-        JVM_CFLAGS_SYMBOLS="$JVM_CFLAGS_SYMBOLS $STACK_PROTECTOR_CFLAG --param ssp-buffer-size=1"
-      fi
-      ;;
-    esac
-  fi
-
-  if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
-    if test "x$DEBUG_LEVEL" != xrelease; then
-      if test "x$OPENJDK_TARGET_CPU" = xx86_64; then
-        JVM_CFLAGS="$JVM_CFLAGS -homeparams"
-      fi
+    if test "x$COMPILE_TYPE" != "xcross"; then
+      BUILD_SYSROOT_CFLAGS="$SYSROOT_CFLAGS"
+      BUILD_SYSROOT_LDFLAGS="$SYSROOT_LDFLAGS"
     fi
   fi
-
-  # Optimization levels
-  if test "x$TOOLCHAIN_TYPE" = xsolstudio; then
-    CC_HIGHEST="$CC_HIGHEST -fns -fsimple -fsingle -xbuiltin=%all -xdepend -xrestrict -xlibmil"
-
-    if test "x$OPENJDK_TARGET_CPU_ARCH" = "xx86"; then
-      # FIXME: seems we always set -xregs=no%frameptr; put it elsewhere more global?
-      C_O_FLAG_HIGHEST_JVM="-xO4"
-      C_O_FLAG_HIGHEST="-xO4 -Wu,-O4~yz $CC_HIGHEST -xalias_level=basic -xregs=no%frameptr"
-      C_O_FLAG_HI="-xO4 -Wu,-O4~yz -xregs=no%frameptr"
-      C_O_FLAG_NORM="-xO2 -Wu,-O2~yz -xregs=no%frameptr"
-      C_O_FLAG_DEBUG="-xregs=no%frameptr"
-      C_O_FLAG_DEBUG_JVM=""
-      C_O_FLAG_NONE="-xregs=no%frameptr"
-      CXX_O_FLAG_HIGHEST_JVM="-xO4"
-      CXX_O_FLAG_HIGHEST="-xO4 -Qoption ube -O4~yz $CC_HIGHEST -xregs=no%frameptr"
-      CXX_O_FLAG_HI="-xO4 -Qoption ube -O4~yz -xregs=no%frameptr"
-      CXX_O_FLAG_NORM="-xO2 -Qoption ube -O2~yz -xregs=no%frameptr"
-      CXX_O_FLAG_DEBUG="-xregs=no%frameptr"
-      CXX_O_FLAG_DEBUG_JVM=""
-      CXX_O_FLAG_NONE="-xregs=no%frameptr"
-      if test "x$OPENJDK_TARGET_CPU_BITS" = "x32"; then
-        C_O_FLAG_HIGHEST="$C_O_FLAG_HIGHEST -xchip=pentium"
-        CXX_O_FLAG_HIGHEST="$CXX_O_FLAG_HIGHEST -xchip=pentium"
-      fi
-    elif test "x$OPENJDK_TARGET_CPU_ARCH" = "xsparc"; then
-      C_O_FLAG_HIGHEST_JVM="-xO4"
-      C_O_FLAG_HIGHEST="-xO4 -Wc,-Qrm-s -Wc,-Qiselect-T0 $CC_HIGHEST -xalias_level=basic -xprefetch=auto,explicit -xchip=ultra"
-      C_O_FLAG_HI="-xO4 -Wc,-Qrm-s -Wc,-Qiselect-T0"
-      C_O_FLAG_NORM="-xO2 -Wc,-Qrm-s -Wc,-Qiselect-T0"
-      C_O_FLAG_DEBUG=""
-      C_O_FLAG_DEBUG_JVM=""
-      C_O_FLAG_NONE=""
-      CXX_O_FLAG_HIGHEST_JVM="-xO4"
-      CXX_O_FLAG_HIGHEST="-xO4 -Qoption cg -Qrm-s -Qoption cg -Qiselect-T0 $CC_HIGHEST -xprefetch=auto,explicit -xchip=ultra"
-      CXX_O_FLAG_HI="-xO4 -Qoption cg -Qrm-s -Qoption cg -Qiselect-T0"
-      CXX_O_FLAG_NORM="-xO2 -Qoption cg -Qrm-s -Qoption cg -Qiselect-T0"
-      CXX_O_FLAG_DEBUG=""
-      CXX_O_FLAG_DEBUG_JVM=""
-      CXX_O_FLAG_NONE=""
-    fi
-  else
-    # The remaining toolchains share opt flags between CC and CXX;
-    # setup for C and duplicate afterwards.
-    if test "x$TOOLCHAIN_TYPE" = xgcc; then
-      if test "x$OPENJDK_TARGET_OS" = xmacosx; then
-        # On MacOSX we optimize for size, something
-        # we should do for all platforms?
-        C_O_FLAG_HIGHEST_JVM="-Os"
-        C_O_FLAG_HIGHEST="-Os"
-        C_O_FLAG_HI="-Os"
-        C_O_FLAG_NORM="-Os"
-        C_O_FLAG_SIZE="-Os"
-      else
-        C_O_FLAG_HIGHEST_JVM="-O3"
-        C_O_FLAG_HIGHEST="-O3"
-        C_O_FLAG_HI="-O3"
-        C_O_FLAG_NORM="-O2"
-        C_O_FLAG_SIZE="-Os"
-      fi
-      C_O_FLAG_DEBUG="-O0"
-      if test "x$OPENJDK_TARGET_OS" = xmacosx; then
-        C_O_FLAG_DEBUG_JVM=""
-      elif test "x$OPENJDK_TARGET_OS" = xlinux; then
-        C_O_FLAG_DEBUG_JVM="-O0"
-      fi
-      C_O_FLAG_NONE="-O0"
-    elif test "x$TOOLCHAIN_TYPE" = xclang; then
-      if test "x$OPENJDK_TARGET_OS" = xmacosx; then
-        # On MacOSX we optimize for size, something
-        # we should do for all platforms?
-        C_O_FLAG_HIGHEST_JVM="-Os"
-        C_O_FLAG_HIGHEST="-Os"
-        C_O_FLAG_HI="-Os"
-        C_O_FLAG_NORM="-Os"
-        C_O_FLAG_SIZE="-Os"
-      else
-        C_O_FLAG_HIGHEST_JVM="-O3"
-        C_O_FLAG_HIGHEST="-O3"
-        C_O_FLAG_HI="-O3"
-        C_O_FLAG_NORM="-O2"
-        C_O_FLAG_SIZE="-Os"
-      fi
-      C_O_FLAG_DEBUG="-O0"
-      if test "x$OPENJDK_TARGET_OS" = xmacosx; then
-        C_O_FLAG_DEBUG_JVM=""
-      elif test "x$OPENJDK_TARGET_OS" = xlinux; then
-        C_O_FLAG_DEBUG_JVM="-O0"
-      fi
-      C_O_FLAG_NONE="-O0"
-    elif test "x$TOOLCHAIN_TYPE" = xxlc; then
-      C_O_FLAG_HIGHEST_JVM="-O3 -qhot=level=1 -qinline -qinlglue"
-      C_O_FLAG_HIGHEST="-O3 -qhot=level=1 -qinline -qinlglue"
-      C_O_FLAG_HI="-O3 -qinline -qinlglue"
-      C_O_FLAG_NORM="-O2"
-      C_O_FLAG_DEBUG="-qnoopt"
-      # FIXME: Value below not verified.
-      C_O_FLAG_DEBUG_JVM=""
-      C_O_FLAG_NONE="-qnoopt"
-    elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
-      C_O_FLAG_HIGHEST_JVM="-O2 -Oy-"
-      C_O_FLAG_HIGHEST="-O2"
-      C_O_FLAG_HI="-O1"
-      C_O_FLAG_NORM="-O1"
-      C_O_FLAG_DEBUG="-Od"
-      C_O_FLAG_DEBUG_JVM=""
-      C_O_FLAG_NONE="-Od"
-      C_O_FLAG_SIZE="-Os"
-    fi
-    CXX_O_FLAG_HIGHEST_JVM="$C_O_FLAG_HIGHEST_JVM"
-    CXX_O_FLAG_HIGHEST="$C_O_FLAG_HIGHEST"
-    CXX_O_FLAG_HI="$C_O_FLAG_HI"
-    CXX_O_FLAG_NORM="$C_O_FLAG_NORM"
-    CXX_O_FLAG_DEBUG="$C_O_FLAG_DEBUG"
-    CXX_O_FLAG_DEBUG_JVM="$C_O_FLAG_DEBUG_JVM"
-    CXX_O_FLAG_NONE="$C_O_FLAG_NONE"
-    CXX_O_FLAG_SIZE="$C_O_FLAG_SIZE"
-  fi
-
-  # Adjust optimization flags according to debug level.
-  case $DEBUG_LEVEL in
-    release )
-      # no adjustment
-      ;;
-    fastdebug )
-      # Not quite so much optimization
-      C_O_FLAG_HI="$C_O_FLAG_NORM"
-      CXX_O_FLAG_HI="$CXX_O_FLAG_NORM"
-      ;;
-    slowdebug )
-      # Disable optimization
-      C_O_FLAG_HIGHEST_JVM="$C_O_FLAG_DEBUG_JVM"
-      C_O_FLAG_HIGHEST="$C_O_FLAG_DEBUG"
-      C_O_FLAG_HI="$C_O_FLAG_DEBUG"
-      C_O_FLAG_NORM="$C_O_FLAG_DEBUG"
-      C_O_FLAG_SIZE="$C_O_FLAG_DEBUG"
-      CXX_O_FLAG_HIGHEST_JVM="$CXX_O_FLAG_DEBUG_JVM"
-      CXX_O_FLAG_HIGHEST="$CXX_O_FLAG_DEBUG"
-      CXX_O_FLAG_HI="$CXX_O_FLAG_DEBUG"
-      CXX_O_FLAG_NORM="$CXX_O_FLAG_DEBUG"
-      CXX_O_FLAG_SIZE="$CXX_O_FLAG_DEBUG"
-      ;;
-  esac
-
-  AC_SUBST(C_O_FLAG_HIGHEST_JVM)
-  AC_SUBST(C_O_FLAG_HIGHEST)
-  AC_SUBST(C_O_FLAG_HI)
-  AC_SUBST(C_O_FLAG_NORM)
-  AC_SUBST(C_O_FLAG_DEBUG)
-  AC_SUBST(C_O_FLAG_NONE)
-  AC_SUBST(C_O_FLAG_SIZE)
-  AC_SUBST(CXX_O_FLAG_HIGHEST_JVM)
-  AC_SUBST(CXX_O_FLAG_HIGHEST)
-  AC_SUBST(CXX_O_FLAG_HI)
-  AC_SUBST(CXX_O_FLAG_NORM)
-  AC_SUBST(CXX_O_FLAG_DEBUG)
-  AC_SUBST(CXX_O_FLAG_NONE)
-  AC_SUBST(CXX_O_FLAG_SIZE)
-])
-
-
-AC_DEFUN([FLAGS_SETUP_COMPILER_FLAGS_FOR_JDK],
-[
-
-  FLAGS_SETUP_ABI_PROFILE
-
-  # Optional POSIX functionality needed by the JVM
-  #
-  # Check if clock_gettime is available and in which library. This indicates
-  # availability of CLOCK_MONOTONIC for hotspot. But we don't need to link, so
-  # don't let it update LIBS.
-  save_LIBS="$LIBS"
-  AC_SEARCH_LIBS(clock_gettime, rt, [HAS_CLOCK_GETTIME=true], [])
-  if test "x$LIBS" = "x-lrt "; then
-    CLOCK_GETTIME_IN_LIBRT=true
-  fi
-  LIBS="$save_LIBS"
-
-  FLAGS_SETUP_COMPILER_FLAGS_FOR_JDK_HELPER([TARGET])
-  FLAGS_SETUP_COMPILER_FLAGS_FOR_JDK_HELPER([BUILD], [OPENJDK_BUILD_])
-
-  # Tests are only ever compiled for TARGET
-  # Flags for compiling test libraries
-  CFLAGS_TESTLIB="$COMMON_CCXXFLAGS_JDK $CFLAGS_JDK $PICFLAG $CFLAGS_JDKLIB_EXTRA"
-  CXXFLAGS_TESTLIB="$COMMON_CCXXFLAGS_JDK $CXXFLAGS_JDK $PICFLAG $CXXFLAGS_JDKLIB_EXTRA"
-
-  # Flags for compiling test executables
-  CFLAGS_TESTEXE="$COMMON_CCXXFLAGS_JDK $CFLAGS_JDK"
-  CXXFLAGS_TESTEXE="$COMMON_CCXXFLAGS_JDK $CXXFLAGS_JDK"
-
-  AC_SUBST(CFLAGS_TESTLIB)
-  AC_SUBST(CFLAGS_TESTEXE)
-  AC_SUBST(CXXFLAGS_TESTLIB)
-  AC_SUBST(CXXFLAGS_TESTEXE)
-
-  LDFLAGS_TESTLIB="$LDFLAGS_JDKLIB"
-  LDFLAGS_TESTEXE="$LDFLAGS_JDKEXE $JAVA_BASE_LDFLAGS"
-
-  AC_SUBST(LDFLAGS_TESTLIB)
-  AC_SUBST(LDFLAGS_TESTEXE)
+  AC_SUBST(BUILD_SYSROOT_CFLAGS)
+  AC_SUBST(BUILD_SYSROOT_LDFLAGS)
 
 ])
 
-################################################################################
-# $1 - Either BUILD or TARGET to pick the correct OS/CPU variables to check
-#      conditionals against.
-# $2 - Optional prefix for each variable defined.
-AC_DEFUN([FLAGS_SETUP_COMPILER_FLAGS_FOR_JDK_HELPER],
+AC_DEFUN([FLAGS_SETUP_FLAGS],
 [
-  # Special extras...
-  if test "x$TOOLCHAIN_TYPE" = xsolstudio; then
-    if test "x$OPENJDK_$1_CPU_ARCH" = "xsparc"; then
-      $2CFLAGS_JDKLIB_EXTRA="${$2CFLAGS_JDKLIB_EXTRA} -xregs=no%appl"
-      $2CXXFLAGS_JDKLIB_EXTRA="${$2CXXFLAGS_JDKLIB_EXTRA} -xregs=no%appl"
-    fi
-    $2CFLAGS_JDKLIB_EXTRA="${$2CFLAGS_JDKLIB_EXTRA} -errtags=yes -errfmt"
-    $2CXXFLAGS_JDKLIB_EXTRA="${$2CXXFLAGS_JDKLIB_EXTRA} -errtags=yes -errfmt"
-  elif test "x$TOOLCHAIN_TYPE" = xxlc; then
-    $2CFLAGS_JDK="${$2CFLAGS_JDK} -qchars=signed -qfullpath -qsaveopt"
-    $2CXXFLAGS_JDK="${$2CXXFLAGS_JDK} -qchars=signed -qfullpath -qsaveopt"
-  elif test "x$TOOLCHAIN_TYPE" = xgcc; then
-    $2CXXSTD_CXXFLAG="-std=gnu++98"
-    FLAGS_CXX_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [[$]$2CXXSTD_CXXFLAG -Werror],
-    						 IF_FALSE: [$2CXXSTD_CXXFLAG=""])
-    $2CXXFLAGS_JDK="${$2CXXFLAGS_JDK} ${$2CXXSTD_CXXFLAG}"
-    $2JVM_CFLAGS="${$2JVM_CFLAGS} ${$2CXXSTD_CXXFLAG}"
-    AC_SUBST($2CXXSTD_CXXFLAG)
-  fi
-  if test "x$OPENJDK_TARGET_OS" = xsolaris; then
-    $2CFLAGS_JDK="${$2CFLAGS_JDK} -D__solaris__"
-    $2CXXFLAGS_JDK="${$2CXXFLAGS_JDK} -D__solaris__"
-  fi
+  FLAGS_SETUP_MACOSX_VERSION
+  FLAGS_SETUP_ABI_PROFILE
 
-  $2CFLAGS_JDK="${$2CFLAGS_JDK} ${$2EXTRA_CFLAGS}"
-  $2CXXFLAGS_JDK="${$2CXXFLAGS_JDK} ${$2EXTRA_CXXFLAGS}"
-  $2LDFLAGS_JDK="${$2LDFLAGS_JDK} ${$2EXTRA_LDFLAGS}"
+  FLAGS_SETUP_SHARED_LIBS
+  FLAGS_SETUP_DEBUG_SYMBOLS
+  FLAGS_SETUP_WARNINGS
+  FLAGS_SETUP_QUALITY_CHECKS
+  FLAGS_SETUP_OPTIMIZATION
 
-  ###############################################################################
-  #
-  # Now setup the CFLAGS and LDFLAGS for the JDK build.
-  # Later we will also have CFLAGS and LDFLAGS for the hotspot subrepo build.
-  #
+  FLAGS_SETUP_CFLAGS
+  FLAGS_SETUP_LDFLAGS
 
-  # Setup compiler/platform specific flags into
-  #    $2CFLAGS_JDK    - C Compiler flags
-  #    $2CXXFLAGS_JDK  - C++ Compiler flags
-  #    $2COMMON_CCXXFLAGS_JDK - common to C and C++
-  if test "x$TOOLCHAIN_TYPE" = xgcc; then
-    $2JVM_CFLAGS="[$]$2JVM_CFLAGS -D_GNU_SOURCE"
-    $2JVM_CFLAGS="[$]$2JVM_CFLAGS -D_REENTRANT"
-    $2JVM_CFLAGS="[$]$2JVM_CFLAGS -fcheck-new"
-    if test "x$OPENJDK_$1_CPU" = xx86; then
-      # Force compatibility with i586 on 32 bit intel platforms.
-      $2COMMON_CCXXFLAGS="${$2COMMON_CCXXFLAGS} -march=i586"
-      $2JVM_CFLAGS="[$]$2JVM_CFLAGS -march=i586"
-    fi
-    $2COMMON_CCXXFLAGS_JDK="[$]$2COMMON_CCXXFLAGS [$]$2COMMON_CCXXFLAGS_JDK -Wall -Wextra -Wno-unused -Wno-unused-parameter -Wformat=2 \
-        -pipe -D_GNU_SOURCE -D_REENTRANT -D_LARGEFILE64_SOURCE"
-    case $OPENJDK_$1_CPU_ARCH in
-      arm )
-        # on arm we don't prevent gcc to omit frame pointer but do prevent strict aliasing
-        $2CFLAGS_JDK="${$2CFLAGS_JDK} -fno-strict-aliasing"
-        $2COMMON_CCXXFLAGS_JDK="${$2COMMON_CCXXFLAGS_JDK} -fsigned-char"
-        ;;
-      ppc )
-        # on ppc we don't prevent gcc to omit frame pointer but do prevent strict aliasing
-        $2CFLAGS_JDK="${$2CFLAGS_JDK} -fno-strict-aliasing"
-        ;;
-      s390 )
-        $2COMMON_CCXXFLAGS_JDK="[$]$2COMMON_CCXXFLAGS_JDK -fno-omit-frame-pointer -mbackchain -march=z10"
-        $2CFLAGS_JDK="${$2CFLAGS_JDK} -fno-strict-aliasing"
-        ;;
-      * )
-        $2COMMON_CCXXFLAGS_JDK="[$]$2COMMON_CCXXFLAGS_JDK -fno-omit-frame-pointer"
-        $2CFLAGS_JDK="${$2CFLAGS_JDK} -fno-strict-aliasing"
-        ;;
-    esac
-    TOOLCHAIN_CHECK_COMPILER_VERSION(VERSION: 6, PREFIX: $2, IF_AT_LEAST: FLAGS_SETUP_GCC6_COMPILER_FLAGS($2))
-  elif test "x$TOOLCHAIN_TYPE" = xclang; then
-    $2JVM_CFLAGS="[$]$2JVM_CFLAGS -D_GNU_SOURCE"
+  FLAGS_SETUP_ARFLAGS
+  FLAGS_SETUP_STRIPFLAGS
+  FLAGS_SETUP_RCFLAGS
 
-    # Restrict the debug information created by Clang to avoid
-    # too big object files and speed the build up a little bit
-    # (see http://llvm.org/bugs/show_bug.cgi?id=7554)
-    $2JVM_CFLAGS="[$]$2JVM_CFLAGS -flimit-debug-info"
-    if test "x$OPENJDK_$1_OS" = xlinux; then
-      if test "x$OPENJDK_$1_CPU" = xx86; then
-        # Force compatibility with i586 on 32 bit intel platforms.
-        $2COMMON_CCXXFLAGS="${$2COMMON_CCXXFLAGS} -march=i586"
-        $2JVM_CFLAGS="[$]$2JVM_CFLAGS -march=i586"
-      fi
-      $2JVM_CFLAGS="[$]$2JVM_CFLAGS -Wno-sometimes-uninitialized"
-      $2COMMON_CCXXFLAGS_JDK="[$]$2COMMON_CCXXFLAGS [$]$2COMMON_CCXXFLAGS_JDK -Wall -Wextra -Wno-unused -Wno-unused-parameter -Wformat=2 \
-          -pipe -D_GNU_SOURCE -D_REENTRANT -D_LARGEFILE64_SOURCE"
-      case $OPENJDK_$1_CPU_ARCH in
-        ppc )
-          # on ppc we don't prevent gcc to omit frame pointer but do prevent strict aliasing
-          $2CFLAGS_JDK="${$2CFLAGS_JDK} -fno-strict-aliasing"
-          ;;
-        * )
-          $2COMMON_CCXXFLAGS_JDK="[$]$2COMMON_CCXXFLAGS_JDK -fno-omit-frame-pointer"
-          $2CFLAGS_JDK="${$2CFLAGS_JDK} -fno-strict-aliasing"
-          ;;
-      esac
-    fi
-  elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
-    $2JVM_CFLAGS="[$]$2JVM_CFLAGS -DSPARC_WORKS"
-    $2COMMON_CCXXFLAGS_JDK="[$]$2COMMON_CCXXFLAGS [$]$2COMMON_CCXXFLAGS_JDK -DTRACING -DMACRO_MEMSYS_OPS -DBREAKPTS"
-    if test "x$OPENJDK_$1_CPU_ARCH" = xx86; then
-      $2COMMON_CCXXFLAGS_JDK="[$]$2COMMON_CCXXFLAGS_JDK -DcpuIntel -Di586 -D$OPENJDK_$1_CPU_LEGACY_LIB"
-    fi
-
-    $2CFLAGS_JDK="[$]$2CFLAGS_JDK -xc99=%none -xCC -errshort=tags -Xa -v -mt -W0,-noglobal"
-    $2CXXFLAGS_JDK="[$]$2CXXFLAGS_JDK -errtags=yes +w -mt -features=no%except -DCC_NOEX -norunpath -xnolib"
-  elif test "x$TOOLCHAIN_TYPE" = xxlc; then
-    $2JVM_CFLAGS="[$]$2JVM_CFLAGS -D_REENTRANT"
-    $2CFLAGS_JDK="[$]$2CFLAGS_JDK -D_GNU_SOURCE -D_REENTRANT -D_LARGEFILE64_SOURCE -DSTDC"
-    $2CXXFLAGS_JDK="[$]$2CXXFLAGS_JDK -D_GNU_SOURCE -D_REENTRANT -D_LARGEFILE64_SOURCE -DSTDC"
-  elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
-    $2COMMON_CCXXFLAGS_JDK="[$]$2COMMON_CCXXFLAGS [$]$2COMMON_CCXXFLAGS_JDK \
-        -MD -Zc:wchar_t- -W3 -wd4800 \
-        -DWIN32_LEAN_AND_MEAN \
-        -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE \
-        -DWIN32 -DIAL"
-    if test "x$OPENJDK_$1_CPU" = xx86_64; then
-      $2COMMON_CCXXFLAGS_JDK="[$]$2COMMON_CCXXFLAGS_JDK -D_AMD64_ -Damd64"
-    else
-      $2COMMON_CCXXFLAGS_JDK="[$]$2COMMON_CCXXFLAGS_JDK -D_X86_ -Dx86"
-    fi
-    # If building with Visual Studio 2010, we can still use _STATIC_CPPLIB to
-    # avoid bundling msvcpNNN.dll. Doesn't work with newer versions of visual
-    # studio.
-    if test "x$TOOLCHAIN_VERSION" = "x2010"; then
-      STATIC_CPPLIB_FLAGS="-D_STATIC_CPPLIB -D_DISABLE_DEPRECATE_STATIC_CPPLIB"
-      $2COMMON_CCXXFLAGS_JDK="[$]$2COMMON_CCXXFLAGS_JDK $STATIC_CPPLIB_FLAGS"
-      $2JVM_CFLAGS="[$]$2JVM_CFLAGS $STATIC_CPPLIB_FLAGS"
-    fi
-  fi
-
-  ###############################################################################
-
-  # Adjust flags according to debug level.
-  case $DEBUG_LEVEL in
-    fastdebug | slowdebug )
-      $2CFLAGS_JDK="[$]$2CFLAGS_JDK $CFLAGS_DEBUG_SYMBOLS $CFLAGS_DEBUG_OPTIONS"
-      $2CXXFLAGS_JDK="[$]$2CXXFLAGS_JDK $CXXFLAGS_DEBUG_SYMBOLS $CXXFLAGS_DEBUG_OPTIONS"
-      ;;
-    release )
-      ;;
-    * )
-      AC_MSG_ERROR([Unrecognized \$DEBUG_LEVEL: $DEBUG_LEVEL])
-      ;;
-  esac
-
-  # Set some common defines. These works for all compilers, but assume
-  # -D is universally accepted.
-
-  # Setup endianness
-  if test "x$OPENJDK_$1_CPU_ENDIAN" = xlittle; then
-    # The macro _LITTLE_ENDIAN needs to be defined the same to avoid the
-    #   Sun C compiler warning message: warning: macro redefined: _LITTLE_ENDIAN
-    #   (The Solaris X86 system defines this in file /usr/include/sys/isa_defs.h).
-    #   Note: -Dmacro         is the same as    #define macro 1
-    #         -Dmacro=        is the same as    #define macro
-    if test "x$OPENJDK_$1_OS" = xsolaris; then
-      $2COMMON_CCXXFLAGS_JDK="[$]$2COMMON_CCXXFLAGS_JDK -D_LITTLE_ENDIAN="
-    else
-      $2COMMON_CCXXFLAGS_JDK="[$]$2COMMON_CCXXFLAGS_JDK -D_LITTLE_ENDIAN"
-    fi
-  else
-    # Same goes for _BIG_ENDIAN. Do we really need to set *ENDIAN on Solaris if they
-    # are defined in the system?
-    if test "x$OPENJDK_$1_OS" = xsolaris; then
-      $2COMMON_CCXXFLAGS_JDK="[$]$2COMMON_CCXXFLAGS_JDK -D_BIG_ENDIAN="
-    else
-      $2COMMON_CCXXFLAGS_JDK="[$]$2COMMON_CCXXFLAGS_JDK -D_BIG_ENDIAN"
-    fi
-  fi
-
-  # Always enable optional macros for VM.
-  $2JVM_CFLAGS="[$]$2JVM_CFLAGS -D__STDC_FORMAT_MACROS"
-  $2JVM_CFLAGS="[$]$2JVM_CFLAGS -D__STDC_LIMIT_MACROS"
-  $2JVM_CFLAGS="[$]$2JVM_CFLAGS -D__STDC_CONSTANT_MACROS"
-
-  # Setup target OS define. Use OS target name but in upper case.
-  OPENJDK_$1_OS_UPPERCASE=`$ECHO $OPENJDK_$1_OS | $TR 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
-  $2COMMON_CCXXFLAGS_JDK="[$]$2COMMON_CCXXFLAGS_JDK -D$OPENJDK_$1_OS_UPPERCASE"
-
-  # Setup target CPU
-  $2COMMON_CCXXFLAGS_JDK="[$]$2COMMON_CCXXFLAGS_JDK \
-      $OPENJDK_$1_ADD_LP64 \
-      -DARCH='\"$OPENJDK_$1_CPU_LEGACY\"' -D$OPENJDK_$1_CPU_LEGACY"
-
-  # Setup debug/release defines
-  if test "x$DEBUG_LEVEL" = xrelease; then
-    $2COMMON_CCXXFLAGS_JDK="[$]$2COMMON_CCXXFLAGS_JDK -DNDEBUG"
-    if test "x$OPENJDK_$1_OS" = xsolaris; then
-      $2COMMON_CCXXFLAGS_JDK="[$]$2COMMON_CCXXFLAGS_JDK -DTRIMMED"
-    fi
-  else
-    $2COMMON_CCXXFLAGS_JDK="[$]$2COMMON_CCXXFLAGS_JDK -DDEBUG"
-  fi
-
-  # Optional POSIX functionality needed by the VM
-
-  if test "x$HAS_CLOCK_GETTIME" = "xtrue"; then
-    $2JVM_CFLAGS="[$]$2JVM_CFLAGS -DSUPPORTS_CLOCK_MONOTONIC"
-    if test "x$CLOCK_GETTIME_IN_LIBRT" = "xtrue"; then
-      $2JVM_CFLAGS="[$]$2JVM_CFLAGS -DNEEDS_LIBRT"
-    fi
-  fi
-
-
-  # Set some additional per-OS defines.
-  if test "x$OPENJDK_$1_OS" = xlinux; then
-    $2JVM_CFLAGS="[$]$2JVM_CFLAGS -DLINUX"
-    $2JVM_CFLAGS="[$]$2JVM_CFLAGS -pipe $PICFLAG -fno-rtti -fno-exceptions \
-        -fvisibility=hidden -fno-strict-aliasing -fno-omit-frame-pointer"
-  elif test "x$OPENJDK_$1_OS" = xsolaris; then
-    $2JVM_CFLAGS="[$]$2JVM_CFLAGS -DSOLARIS"
-    $2JVM_CFLAGS="[$]$2JVM_CFLAGS -template=no%extdef -features=no%split_init \
-        -D_Crun_inline_placement -library=stlport4 $PICFLAG -mt -features=no%except"
-  elif test "x$OPENJDK_$1_OS" = xmacosx; then
-    $2COMMON_CCXXFLAGS_JDK="[$]$2COMMON_CCXXFLAGS_JDK -D_ALLBSD_SOURCE -D_DARWIN_UNLIMITED_SELECT"
-    $2JVM_CFLAGS="[$]$2JVM_CFLAGS -D_ALLBSD_SOURCE"
-    $2JVM_CFLAGS="[$]$2JVM_CFLAGS -D_DARWIN_C_SOURCE -D_XOPEN_SOURCE"
-    $2JVM_CFLAGS="[$]$2JVM_CFLAGS -fno-rtti -fno-exceptions -fvisibility=hidden \
-        -mno-omit-leaf-frame-pointer -mstack-alignment=16 -pipe -fno-strict-aliasing \
-        -fno-omit-frame-pointer"
-  elif test "x$OPENJDK_$1_OS" = xaix; then
-    $2JVM_CFLAGS="[$]$2JVM_CFLAGS -DAIX"
-    $2JVM_CFLAGS="[$]$2JVM_CFLAGS -qtune=balanced \
-        -qalias=noansi -qstrict -qtls=default -qlanglvl=c99vla \
-        -qlanglvl=noredefmac -qnortti -qnoeh -qignerrno"
-    # We need '-qminimaltoc' or '-qpic=large -bbigtoc' if the TOC overflows.
-    # Hotspot now overflows its 64K TOC (currently only for debug),
-    # so for debug we build with '-qpic=large -bbigtoc'.
-    if test "x$DEBUG_LEVEL" = xslowdebug || test "x$DEBUG_LEVEL" = xfastdebug; then
-      $2JVM_CFLAGS="[$]$2JVM_CFLAGS -qpic=large"
-    fi
-  elif test "x$OPENJDK_$1_OS" = xbsd; then
-    $2COMMON_CCXXFLAGS_JDK="[$]$2COMMON_CCXXFLAGS_JDK -D_ALLBSD_SOURCE"
-  elif test "x$OPENJDK_$1_OS" = xwindows; then
-    $2JVM_CFLAGS="[$]$2JVM_CFLAGS -D_WINDOWS -DWIN32 -D_JNI_IMPLEMENTATION_"
-    $2JVM_CFLAGS="[$]$2JVM_CFLAGS -nologo -W3 -MD -MP"
-  fi
-
-  # Set some additional per-CPU defines.
-  if test "x$OPENJDK_$1_OS-$OPENJDK_$1_CPU" = xwindows-x86; then
-    $2JVM_CFLAGS="[$]$2JVM_CFLAGS -arch:IA32"
-  elif test "x$OPENJDK_$1_OS-$OPENJDK_$1_CPU" = xsolaris-sparcv9; then
-    $2JVM_CFLAGS="[$]$2JVM_CFLAGS -xarch=sparc"
-  elif test "x$OPENJDK_$1_CPU" = xppc64; then
-    if test "x$OPENJDK_$1_OS" = xlinux; then
-      $2JVM_CFLAGS="[$]$2JVM_CFLAGS -minsert-sched-nops=regroup_exact -mno-multiple -mno-string"
-      # fixes `relocation truncated to fit' error for gcc 4.1.
-      $2JVM_CFLAGS="[$]$2JVM_CFLAGS -mminimal-toc"
-      # Use ppc64 instructions, but schedule for power5
-      $2JVM_CFLAGS="[$]$2JVM_CFLAGS -mcpu=powerpc64 -mtune=power5"
-    elif test "x$OPENJDK_$1_OS" = xaix; then
-      $2JVM_CFLAGS="[$]$2JVM_CFLAGS -qarch=ppc64"
-    fi
-  elif test "x$OPENJDK_$1_CPU" = xppc64le; then
-    if test "x$OPENJDK_$1_OS" = xlinux; then
-      $2JVM_CFLAGS="[$]$2JVM_CFLAGS -minsert-sched-nops=regroup_exact -mno-multiple -mno-string"
-      # Little endian machine uses ELFv2 ABI.
-      $2JVM_CFLAGS="[$]$2JVM_CFLAGS -DABI_ELFv2"
-      # Use Power8, this is the first CPU to support PPC64 LE with ELFv2 ABI.
-      $2JVM_CFLAGS="[$]$2JVM_CFLAGS -mcpu=power8 -mtune=power8"
-    fi
-  elif test "x$OPENJDK_$1_CPU" = xs390x; then
-    if test "x$OPENJDK_$1_OS" = xlinux; then
-      $2JVM_CFLAGS="[$]$2JVM_CFLAGS -mbackchain -march=z10"
-    fi
-  fi
-
-  if test "x$OPENJDK_$1_CPU_ENDIAN" = xlittle; then
-    $2JVM_CFLAGS="[$]$2JVM_CFLAGS -DVM_LITTLE_ENDIAN"
-  fi
-
-  if test "x$OPENJDK_$1_CPU_BITS" = x64; then
-    if test "x$OPENJDK_$1_OS" != xsolaris && test "x$OPENJDK_$1_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.
-      $2JVM_CFLAGS="[$]$2JVM_CFLAGS -D_LP64=1"
-    fi
-  fi
-
-  # Set $2JVM_CFLAGS warning handling
-  if test "x$OPENJDK_$1_OS" = xlinux; then
-    $2JVM_CFLAGS="[$]$2JVM_CFLAGS -Wpointer-arith -Wsign-compare -Wunused-function \
-        -Wunused-value -Woverloaded-virtual"
-
-    if test "x$TOOLCHAIN_TYPE" = xgcc; then
-      TOOLCHAIN_CHECK_COMPILER_VERSION(VERSION: [4.8], PREFIX: $2,
-          IF_AT_LEAST: [
-            # These flags either do not work or give spurious warnings prior to gcc 4.8.
-            $2JVM_CFLAGS="[$]$2JVM_CFLAGS -Wno-format-zero-length -Wtype-limits -Wuninitialized"
-          ]
-      )
-    fi
-    if ! HOTSPOT_CHECK_JVM_VARIANT(zero); then
-      # Non-zero builds have stricter warnings
-      $2JVM_CFLAGS="[$]$2JVM_CFLAGS -Wreturn-type -Wundef -Wformat=2"
-    else
-      if test "x$TOOLCHAIN_TYPE" = xclang; then
-        # Some versions of llvm do not like -Wundef
-        $2JVM_CFLAGS="[$]$2JVM_CFLAGS -Wno-undef"
-      fi
-    fi
-  elif test "x$OPENJDK_$1_OS" = xmacosx; then
-    $2JVM_CFLAGS="[$]$2JVM_CFLAGS -Wno-deprecated -Wpointer-arith \
-        -Wsign-compare -Wundef -Wunused-function -Wformat=2"
-  fi
-
-  # Additional macosx handling
-  if test "x$OPENJDK_$1_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)"
-    $2ARFLAGS="$2$ARFLAGS -mmacosx-version-min=\$(MACOSX_VERSION_MIN)"
-
-    if test -n "$MACOSX_VERSION_MAX"; then
-        $2COMMON_CCXXFLAGS_JDK="[$]$2COMMON_CCXXFLAGS_JDK \
-            -DMAC_OS_X_VERSION_MAX_ALLOWED=\$(subst .,,\$(MACOSX_VERSION_MAX))"
-        $2JVM_CFLAGS="[$]$2JVM_CFLAGS \
-            -DMAC_OS_X_VERSION_MAX_ALLOWED=\$(subst .,,\$(MACOSX_VERSION_MAX))"
-    fi
-  fi
-
-  # Setup some hard coded includes
-  $2COMMON_CCXXFLAGS_JDK="[$]$2COMMON_CCXXFLAGS_JDK \
-      -I\$(SUPPORT_OUTPUTDIR)/modules_include/java.base \
-      -I\$(SUPPORT_OUTPUTDIR)/modules_include/java.base/\$(OPENJDK_TARGET_OS_INCLUDE_SUBDIR) \
-      -I${TOPDIR}/src/java.base/share/native/libjava \
-      -I${TOPDIR}/src/java.base/$OPENJDK_$1_OS_TYPE/native/libjava \
-      -I${TOPDIR}/src/hotspot/share/include \
-      -I${TOPDIR}/src/hotspot/os/${HOTSPOT_$1_OS_TYPE}/include"
-
-  # The shared libraries are compiled using the picflag.
-  $2CFLAGS_JDKLIB="[$]$2COMMON_CCXXFLAGS_JDK \
-      [$]$2CFLAGS_JDK [$]$2EXTRA_CFLAGS_JDK $PICFLAG [$]$2CFLAGS_JDKLIB_EXTRA"
-  $2CXXFLAGS_JDKLIB="[$]$2COMMON_CCXXFLAGS_JDK \
-      [$]$2CXXFLAGS_JDK [$]$2EXTRA_CXXFLAGS_JDK $PICFLAG [$]$2CXXFLAGS_JDKLIB_EXTRA"
-
-  # Executable flags
-  $2CFLAGS_JDKEXE="[$]$2COMMON_CCXXFLAGS_JDK [$]$2CFLAGS_JDK [$]$2EXTRA_CFLAGS_JDK"
-  $2CXXFLAGS_JDKEXE="[$]$2COMMON_CCXXFLAGS_JDK [$]$2CXXFLAGS_JDK [$]$2EXTRA_CXXFLAGS_JDK"
-
-  AC_SUBST($2CFLAGS_JDKLIB)
-  AC_SUBST($2CFLAGS_JDKEXE)
-  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$OPENJDK_$1_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$OPENJDK_$1_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$OPENJDK_$1_OS" = xmacosx; then
-        $2JVM_LDFLAGS="[$]$2JVM_LDFLAGS -Wl,-rpath,@loader_path/. -Wl,-rpath,@loader_path/.."
-    fi
-    if test "x$OPENJDK_$1_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$OPENJDK_$1_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$OPENJDK_$1_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$OPENJDK_$1_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$OPENJDK_$1_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$OPENJDK_$1_OS" = xlinux; then
-    $2JVM_LIBS="[$]$2JVM_LIBS -lm -ldl -lpthread"
-  elif test "x$OPENJDK_$1_OS" = xsolaris; then
-    # FIXME: This hard-coded path is not really proper.
-    if test "x$OPENJDK_$1_CPU" = xx86_64; then
-      $2SOLARIS_LIBM_LIBS="/usr/lib/amd64/libm.so.1"
-    elif test "x$OPENJDK_$1_CPU" = xsparcv9; then
-      $2SOLARIS_LIBM_LIBS="/usr/lib/sparcv9/libm.so.1"
-    fi
-    $2JVM_LIBS="[$]$2JVM_LIBS -lsocket -lsched -ldl $SOLARIS_LIBM_LIBS -lCrun \
-        -lthread -ldoor -lc -ldemangle -lnsl -lrt"
-  elif test "x$OPENJDK_$1_OS" = xmacosx; then
-    $2JVM_LIBS="[$]$2JVM_LIBS -lm"
-  elif test "x$OPENJDK_$1_OS" = xaix; then
-    $2JVM_LIBS="[$]$2JVM_LIBS -Wl,-lC_r -lm -ldl -lpthread"
-  elif test "x$OPENJDK_$1_OS" = xbsd; then
-    $2JVM_LIBS="[$]$2JVM_LIBS -lm"
-  elif test "x$OPENJDK_$1_OS" = xwindows; then
-    $2JVM_LIBS="[$]$2JVM_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"
-    fi
-
-  # Set $2JVM_ASFLAGS
-  if test "x$OPENJDK_$1_OS" = xlinux; then
-    if test "x$OPENJDK_$1_CPU" = xx86; then
-      $2JVM_ASFLAGS="[$]$2JVM_ASFLAGS -march=i586"
-    fi
-  elif test "x$OPENJDK_$1_OS" = xmacosx; then
-    $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)
-  AC_SUBST($2JDKEXE_LIBS)
-  AC_SUBST($2LDFLAGS_CXX_JDK)
-  AC_SUBST($2LDFLAGS_HASH_STYLE)
-  AC_SUBST($2LDFLAGS_NO_EXEC_STACK)
-
-  AC_SUBST($2JVM_CFLAGS)
-  AC_SUBST($2JVM_LDFLAGS)
-  AC_SUBST($2JVM_ASFLAGS)
-  AC_SUBST($2JVM_LIBS)
-
+  FLAGS_SETUP_ASFLAGS
+  FLAGS_SETUP_ASFLAGS_CPU_DEP([TARGET])
+  FLAGS_SETUP_ASFLAGS_CPU_DEP([BUILD], [OPENJDK_BUILD_])
 ])
 
 # FLAGS_C_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [ARGUMENT], IF_TRUE: [RUN-IF-TRUE],
@@ -1510,110 +506,3 @@
     ARG_IF_FALSE
   fi
 ])
-
-AC_DEFUN_ONCE([FLAGS_SETUP_COMPILER_FLAGS_MISC],
-[
-  # Check that the compiler supports -mX (or -qX on AIX) flags
-  # Set COMPILER_SUPPORTS_TARGET_BITS_FLAG to 'true' if it does
-  FLAGS_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [${COMPILER_TARGET_BITS_FLAG}${OPENJDK_TARGET_CPU_BITS}],
-      IF_TRUE: [COMPILER_SUPPORTS_TARGET_BITS_FLAG=true],
-      IF_FALSE: [COMPILER_SUPPORTS_TARGET_BITS_FLAG=false])
-  AC_SUBST(COMPILER_SUPPORTS_TARGET_BITS_FLAG)
-
-  AC_ARG_ENABLE([warnings-as-errors], [AS_HELP_STRING([--disable-warnings-as-errors],
-      [do not consider native warnings to be an error @<:@enabled@:>@])])
-
-  AC_MSG_CHECKING([if native warnings are errors])
-  if test "x$enable_warnings_as_errors" = "xyes"; then
-    AC_MSG_RESULT([yes (explicitly set)])
-    WARNINGS_AS_ERRORS=true
-  elif test "x$enable_warnings_as_errors" = "xno"; then
-    AC_MSG_RESULT([no])
-    WARNINGS_AS_ERRORS=false
-  elif test "x$enable_warnings_as_errors" = "x"; then
-    AC_MSG_RESULT([yes (default)])
-    WARNINGS_AS_ERRORS=true
-  else
-    AC_MSG_ERROR([--enable-warnings-as-errors accepts no argument])
-  fi
-
-  AC_SUBST(WARNINGS_AS_ERRORS)
-
-  case "${TOOLCHAIN_TYPE}" in
-    microsoft)
-      DISABLE_WARNING_PREFIX="-wd"
-      CFLAGS_WARNINGS_ARE_ERRORS="-WX"
-      ;;
-    solstudio)
-      DISABLE_WARNING_PREFIX="-erroff="
-      CFLAGS_WARNINGS_ARE_ERRORS="-errtags -errwarn=%all"
-      ;;
-    gcc)
-      # Prior to gcc 4.4, a -Wno-X where X is unknown for that version of gcc will cause an error
-      FLAGS_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [-Wno-this-is-a-warning-that-do-not-exist],
-          IF_TRUE: [GCC_CAN_DISABLE_WARNINGS=true],
-          IF_FALSE: [GCC_CAN_DISABLE_WARNINGS=false]
-      )
-      if test "x$GCC_CAN_DISABLE_WARNINGS" = "xtrue"; then
-        DISABLE_WARNING_PREFIX="-Wno-"
-      else
-        DISABLE_WARNING_PREFIX=
-      fi
-      CFLAGS_WARNINGS_ARE_ERRORS="-Werror"
-      # Repeate the check for the BUILD_CC and BUILD_CXX. Need to also reset
-      # CFLAGS since any target specific flags will likely not work with the
-      # build compiler
-      CC_OLD="$CC"
-      CXX_OLD="$CXX"
-      CC="$BUILD_CC"
-      CXX="$BUILD_CXX"
-      CFLAGS_OLD="$CFLAGS"
-      CFLAGS=""
-      FLAGS_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [-Wno-this-is-a-warning-that-do-not-exist],
-          IF_TRUE: [BUILD_CC_CAN_DISABLE_WARNINGS=true],
-          IF_FALSE: [BUILD_CC_CAN_DISABLE_WARNINGS=false]
-      )
-      if test "x$BUILD_CC_CAN_DISABLE_WARNINGS" = "xtrue"; then
-        BUILD_CC_DISABLE_WARNING_PREFIX="-Wno-"
-      else
-        BUILD_CC_DISABLE_WARNING_PREFIX=
-      fi
-      CC="$CC_OLD"
-      CXX="$CXX_OLD"
-      CFLAGS="$CFLAGS_OLD"
-      ;;
-    clang)
-      DISABLE_WARNING_PREFIX="-Wno-"
-      CFLAGS_WARNINGS_ARE_ERRORS="-Werror"
-      ;;
-    xlc)
-      DISABLE_WARNING_PREFIX="-qsuppress="
-      CFLAGS_WARNINGS_ARE_ERRORS="-qhalt=w"
-      ;;
-  esac
-  AC_SUBST(DISABLE_WARNING_PREFIX)
-  AC_SUBST(BUILD_CC_DISABLE_WARNING_PREFIX)
-  AC_SUBST(CFLAGS_WARNINGS_ARE_ERRORS)
-])
-
-# FLAGS_SETUP_GCC6_COMPILER_FLAGS([PREFIX])
-# Arguments:
-# $1 - Optional prefix for each variable defined.
-AC_DEFUN([FLAGS_SETUP_GCC6_COMPILER_FLAGS],
-[
-  # These flags are required for GCC 6 builds as undefined behaviour in OpenJDK code
-  # runs afoul of the more aggressive versions of these optimisations.
-  # Notably, value range propagation now assumes that the this pointer of C++
-  # member functions is non-null.
-  NO_DELETE_NULL_POINTER_CHECKS_CFLAG="-fno-delete-null-pointer-checks"
-  dnl Argument check is disabled until FLAGS_COMPILER_CHECK_ARGUMENTS handles cross-compilation
-  dnl FLAGS_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [$NO_DELETE_NULL_POINTER_CHECKS_CFLAG -Werror],
-  dnl					     IF_FALSE: [NO_DELETE_NULL_POINTER_CHECKS_CFLAG=""])
-  NO_LIFETIME_DSE_CFLAG="-fno-lifetime-dse"
-  dnl Argument check is disabled until FLAGS_COMPILER_CHECK_ARGUMENTS handles cross-compilation
-  dnl FLAGS_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [$NO_LIFETIME_DSE_CFLAG -Werror],
-  dnl					     IF_FALSE: [NO_LIFETIME_DSE_CFLAG=""])
-  AC_MSG_NOTICE([GCC >= 6 detected; adding ${NO_DELETE_NULL_POINTER_CHECKS_CFLAG} and ${NO_LIFETIME_DSE_CFLAG}])
-  $1CFLAGS_JDK="[$]$1CFLAGS_JDK ${NO_DELETE_NULL_POINTER_CHECKS_CFLAG} ${NO_LIFETIME_DSE_CFLAG}"
-  $1JVM_CFLAGS="[$]$1JVM_CFLAGS ${NO_DELETE_NULL_POINTER_CHECKS_CFLAG} ${NO_LIFETIME_DSE_CFLAG}"
-])
--- a/make/autoconf/help.m4	Wed Mar 21 10:35:21 2018 -0300
+++ b/make/autoconf/help.m4	Tue Apr 10 18:20:45 2018 +0100
@@ -31,7 +31,7 @@
 AC_DEFUN([HELP_MSG_MISSING_DEPENDENCY],
 [
   # Print a helpful message on how to acquire the necessary build dependency.
-  # $1 is the help tag: freetype, cups, alsa etc
+  # $1 is the help tag: cups, alsa etc
   MISSING_DEPENDENCY=$1
 
   if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then
@@ -76,24 +76,6 @@
       PKGHANDLER_COMMAND="( cd <location of cygwin setup.exe> && cmd /c setup -q -P make )"
       HELP_MSG="You might be able to fix this by running '$PKGHANDLER_COMMAND'."
       ;;
-    freetype)
-      HELP_MSG="
-The freetype library can now be build during the configure process.
-Download the freetype sources and unpack them into an arbitrary directory:
-
-wget http://download.savannah.gnu.org/releases/freetype/freetype-2.5.3.tar.gz
-tar -xzf freetype-2.5.3.tar.gz
-
-Then run configure with '--with-freetype-src=<freetype_src>'. This will
-automatically build the freetype library into '<freetype_src>/lib64' for 64-bit
-builds or into '<freetype_src>/lib32' for 32-bit builds.
-Afterwards you can always use '--with-freetype-include=<freetype_src>/include'
-and '--with-freetype-lib=<freetype_src>/lib[32|64]' for other builds.
-
-Alternatively you can unpack the sources like this to use the default directory:
-
-tar --one-top-level=$HOME/freetype --strip-components=1 -xzf freetype-2.5.3.tar.gz"
-      ;;
   esac
 }
 
--- a/make/autoconf/hotspot.m4	Wed Mar 21 10:35:21 2018 -0300
+++ b/make/autoconf/hotspot.m4	Tue Apr 10 18:20:45 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/lib-freetype.m4	Wed Mar 21 10:35:21 2018 -0300
+++ b/make/autoconf/lib-freetype.m4	Tue Apr 10 18:20:45 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
@@ -24,91 +24,6 @@
 #
 
 ################################################################################
-# Build the freetype lib from source
-################################################################################
-AC_DEFUN([LIB_BUILD_FREETYPE],
-[
-  FREETYPE_SRC_PATH="$1"
-  BUILD_FREETYPE=yes
-
-  # Check if the freetype sources are acessible..
-  if ! test -d $FREETYPE_SRC_PATH; then
-    AC_MSG_WARN([--with-freetype-src specified, but can not find path "$FREETYPE_SRC_PATH" - ignoring --with-freetype-src])
-    BUILD_FREETYPE=no
-  fi
-  # ..and contain a vc2010 project file
-  vcxproj_path="$FREETYPE_SRC_PATH/builds/windows/vc2010/freetype.vcxproj"
-  if test "x$BUILD_FREETYPE" = xyes && ! test -s $vcxproj_path; then
-    AC_MSG_WARN([Can not find project file $vcxproj_path (you may try a newer freetype version) - ignoring --with-freetype-src])
-    BUILD_FREETYPE=no
-  fi
-  # Now check if configure found a version of 'msbuild.exe'
-  if test "x$BUILD_FREETYPE" = xyes && test "x$MSBUILD" == x ; then
-    AC_MSG_WARN([Can not find an msbuild.exe executable (you may try to install .NET 4.0) - ignoring --with-freetype-src])
-    BUILD_FREETYPE=no
-  fi
-
-  # Ready to go..
-  if test "x$BUILD_FREETYPE" = xyes; then
-    # msbuild requires trailing slashes for output directories
-    freetype_lib_path="$FREETYPE_SRC_PATH/lib$OPENJDK_TARGET_CPU_BITS/"
-    freetype_lib_path_unix="$freetype_lib_path"
-    freetype_obj_path="$FREETYPE_SRC_PATH/obj$OPENJDK_TARGET_CPU_BITS/"
-    BASIC_WINDOWS_REWRITE_AS_WINDOWS_MIXED_PATH(vcxproj_path)
-    BASIC_WINDOWS_REWRITE_AS_WINDOWS_MIXED_PATH(freetype_lib_path)
-    BASIC_WINDOWS_REWRITE_AS_WINDOWS_MIXED_PATH(freetype_obj_path)
-    if test "x$OPENJDK_TARGET_CPU_BITS" = x64; then
-      freetype_platform=x64
-    else
-      freetype_platform=win32
-    fi
-
-    # The original freetype project file is for VS 2010 (i.e. 'v100'),
-    # so we have to adapt the toolset if building with any other toolsed (i.e. SDK).
-    # Currently 'PLATFORM_TOOLSET' is set in 'TOOLCHAIN_CHECK_POSSIBLE_VISUAL_STUDIO_ROOT'/
-    # 'TOOLCHAIN_CHECK_POSSIBLE_WIN_SDK_ROOT' in toolchain_windows.m4
-    AC_MSG_NOTICE([Trying to compile freetype sources with PlatformToolset=$PLATFORM_TOOLSET to $freetype_lib_path_unix ...])
-
-    # First we try to build the freetype.dll
-    $ECHO -e "@echo off\n"\
-        "$MSBUILD $vcxproj_path "\
-        "/p:PlatformToolset=$PLATFORM_TOOLSET "\
-        "/p:Configuration=\"Release Multithreaded\" "\
-        "/p:Platform=$freetype_platform "\
-        "/p:ConfigurationType=DynamicLibrary "\
-        "/p:TargetName=freetype "\
-        "/p:OutDir=\"$freetype_lib_path\" "\
-        "/p:IntDir=\"$freetype_obj_path\" > freetype.log" > freetype.bat
-    cmd /c freetype.bat
-
-    if test -s "$freetype_lib_path_unix/freetype.dll"; then
-      # If that succeeds we also build freetype.lib
-      $ECHO -e "@echo off\n"\
-          "$MSBUILD $vcxproj_path "\
-          "/p:PlatformToolset=$PLATFORM_TOOLSET "\
-          "/p:Configuration=\"Release Multithreaded\" "\
-          "/p:Platform=$freetype_platform "\
-          "/p:ConfigurationType=StaticLibrary "\
-          "/p:TargetName=freetype "\
-          "/p:OutDir=\"$freetype_lib_path\" "\
-          "/p:IntDir=\"$freetype_obj_path\" >> freetype.log" > freetype.bat
-      cmd /c freetype.bat
-
-      if test -s "$freetype_lib_path_unix/freetype.lib"; then
-        # Once we build both, lib and dll, set freetype lib and include path appropriately
-        POTENTIAL_FREETYPE_INCLUDE_PATH="$FREETYPE_SRC_PATH/include"
-        POTENTIAL_FREETYPE_LIB_PATH="$freetype_lib_path_unix"
-        AC_MSG_NOTICE([Compiling freetype sources succeeded! (see freetype.log for build results)])
-      else
-        BUILD_FREETYPE=no
-      fi
-    else
-      BUILD_FREETYPE=no
-    fi
-  fi
-])
-
-################################################################################
 # Check if a potential freeype library match is correct and usable
 ################################################################################
 AC_DEFUN([LIB_CHECK_POTENTIAL_FREETYPE],
@@ -122,7 +37,7 @@
 
   # First look for the canonical freetype main include file ft2build.h.
   if ! test -s "$POTENTIAL_FREETYPE_INCLUDE_PATH/ft2build.h"; then
-    # Oh no! Let's try in the freetype2 directory. This is needed at least at Mac OS X Yosemite.
+    # Oh no! Let's try in the freetype2 directory.
     POTENTIAL_FREETYPE_INCLUDE_PATH="$POTENTIAL_FREETYPE_INCLUDE_PATH/freetype2"
     if ! test -s "$POTENTIAL_FREETYPE_INCLUDE_PATH/ft2build.h"; then
       # Fail.
@@ -130,33 +45,16 @@
     fi
   fi
 
-  if test "x$FOUND_FREETYPE" = xyes; then
+  if test "x$FOUND_FREETYPE" = "xyes"; then
     # Include file found, let's continue the sanity check.
     AC_MSG_NOTICE([Found freetype include files at $POTENTIAL_FREETYPE_INCLUDE_PATH using $METHOD])
 
-    # Reset to default value
-    FREETYPE_BASE_NAME=freetype
     FREETYPE_LIB_NAME="${LIBRARY_PREFIX}${FREETYPE_BASE_NAME}${SHARED_LIBRARY_SUFFIX}"
     if ! test -s "$POTENTIAL_FREETYPE_LIB_PATH/$FREETYPE_LIB_NAME"; then
-      if test "x$OPENJDK_TARGET_OS" = xmacosx \
-          && test -s "$POTENTIAL_FREETYPE_LIB_PATH/${LIBRARY_PREFIX}freetype.6${SHARED_LIBRARY_SUFFIX}"; then
-        # On Mac OS X Yosemite, the symlink from libfreetype.dylib to libfreetype.6.dylib disappeared. Check
-        # for the .6 version explicitly.
-        FREETYPE_BASE_NAME=freetype.6
-        FREETYPE_LIB_NAME="${LIBRARY_PREFIX}${FREETYPE_BASE_NAME}${SHARED_LIBRARY_SUFFIX}"
-        AC_MSG_NOTICE([Compensating for missing symlink by using version 6 explicitly])
-      else
-        AC_MSG_NOTICE([Could not find $POTENTIAL_FREETYPE_LIB_PATH/$FREETYPE_LIB_NAME. Ignoring location.])
-        FOUND_FREETYPE=no
-      fi
+      AC_MSG_NOTICE([Could not find $POTENTIAL_FREETYPE_LIB_PATH/$FREETYPE_LIB_NAME. Ignoring location.])
+      FOUND_FREETYPE=no
     else
-      if test "x$OPENJDK_TARGET_OS" = xwindows; then
-        # On Windows, we will need both .lib and .dll file.
-        if ! test -s "$POTENTIAL_FREETYPE_LIB_PATH/${FREETYPE_BASE_NAME}.lib"; then
-          AC_MSG_NOTICE([Could not find $POTENTIAL_FREETYPE_LIB_PATH/${FREETYPE_BASE_NAME}.lib. Ignoring location.])
-          FOUND_FREETYPE=no
-        fi
-      elif test "x$OPENJDK_TARGET_OS" = xsolaris \
+      if test "x$OPENJDK_TARGET_OS" = "xsolaris" \
           && test -s "$POTENTIAL_FREETYPE_LIB_PATH$OPENJDK_TARGET_CPU_ISADIR/$FREETYPE_LIB_NAME"; then
         # Found lib in isa dir, use that instead.
         POTENTIAL_FREETYPE_LIB_PATH="$POTENTIAL_FREETYPE_LIB_PATH$OPENJDK_TARGET_CPU_ISADIR"
@@ -165,10 +63,7 @@
     fi
   fi
 
-  if test "x$FOUND_FREETYPE" = xyes; then
-    BASIC_FIXUP_PATH(POTENTIAL_FREETYPE_INCLUDE_PATH)
-    BASIC_FIXUP_PATH(POTENTIAL_FREETYPE_LIB_PATH)
-
+  if test "x$FOUND_FREETYPE" = "xyes"; then
     FREETYPE_INCLUDE_PATH="$POTENTIAL_FREETYPE_INCLUDE_PATH"
     AC_MSG_CHECKING([for freetype includes])
     AC_MSG_RESULT([$FREETYPE_INCLUDE_PATH])
@@ -184,293 +79,147 @@
 AC_DEFUN_ONCE([LIB_SETUP_FREETYPE],
 [
   AC_ARG_WITH(freetype, [AS_HELP_STRING([--with-freetype],
-      [specify prefix directory for the freetype package
-      (expecting the libraries under PATH/lib and the headers under PATH/include)])])
+      [specify whether to use 'system' or 'bundled' freetype. Other values are errors.
+       The selected option applies to both build time and run time.
+       The default behaviour can be platform dependent.
+       If using 'system' and either the include files or libraries cannot be
+       located automatically, then additionally specify both using
+       --with-freetype-include and --with-freetype-lib.])])
   AC_ARG_WITH(freetype-include, [AS_HELP_STRING([--with-freetype-include],
       [specify directory for the freetype include files])])
   AC_ARG_WITH(freetype-lib, [AS_HELP_STRING([--with-freetype-lib],
       [specify directory for the freetype library])])
-  AC_ARG_WITH(freetype-src, [AS_HELP_STRING([--with-freetype-src],
-      [specify directory with freetype sources to automatically build the library (experimental, Windows-only)])])
-  AC_ARG_ENABLE(freetype-bundling, [AS_HELP_STRING([--disable-freetype-bundling],
-      [disable bundling of the freetype library with the build result @<:@enabled on Windows or when using --with-freetype, disabled otherwise@:>@])])
-  AC_ARG_WITH(freetype-license, [AS_HELP_STRING([--with-freetype-license],
-      [if bundling freetype, also bundle this license file])])
 
-  # Need to specify explicitly since it needs to be overridden on some versions of macosx
+  # This setup is to verify access to system installed freetype header and libraries.
+  # On Windows and MacOS this does not apply and using these options will report an error.
+  # On other platforms (Linux, Solaris, and perhaps AIX), they will default to using
+  # the system libraries. If they are found automatically, nothing need be done.
+  # If they are not found, the configure "--with-freetype-*" options may be used to fix that.
+  # If the preference is to bundle on these platforms then use --with-freetype=bundled
   FREETYPE_BASE_NAME=freetype
   FREETYPE_CFLAGS=
   FREETYPE_LIBS=
-  FREETYPE_BUNDLE_LIB_PATH=
 
-  if test "x$NEEDS_LIB_FREETYPE" = xfalse; then
-    if (test "x$with_freetype" != x  && test "x$with_freetype" != xno) || \
-        (test "x$with_freetype_include" != x && test "x$with_freetype_include" != xno) || \
-        (test "x$with_freetype_lib" != x && test "x$with_freetype_lib" != xno) || \
-        (test "x$with_freetype_src" != x && test "x$with_freetype_src" != xno); then
-      AC_MSG_WARN([[freetype not used, so --with-freetype[-*] is ignored]])
-    fi
-    if (test "x$enable_freetype_bundling" != x && test "x$enable_freetype_bundling" != xno); then
-      AC_MSG_WARN([freetype not used, so --enable-freetype-bundling is ignored])
-    fi
-  else
-    # freetype is needed to build; go get it!
+  if (test "x$with_freetype_include" = "x"  && test "x$with_freetype_lib" != "x") || \
+     (test "x$with_freetype_include" != "x"  && test "x$with_freetype_lib" = "x"); then
+       AC_MSG_ERROR(['must specify both or neither of --with_freetype_include and --with_freetype_lib])
+  fi
 
-    BUNDLE_FREETYPE="$enable_freetype_bundling"
-
-    if  test "x$with_freetype_src" != x; then
-      if test "x$OPENJDK_TARGET_OS" = xwindows; then
-        # Try to build freetype if --with-freetype-src was given on Windows
-        LIB_BUILD_FREETYPE([$with_freetype_src])
-        if test "x$BUILD_FREETYPE" = xyes; then
-          # Okay, we built it. Check that it works.
-          LIB_CHECK_POTENTIAL_FREETYPE($POTENTIAL_FREETYPE_INCLUDE_PATH, $POTENTIAL_FREETYPE_LIB_PATH, [--with-freetype-src])
-          if test "x$FOUND_FREETYPE" != xyes; then
-            AC_MSG_ERROR([Can not use the built freetype at location given by --with-freetype-src])
-          fi
-        else
-          AC_MSG_NOTICE([User specified --with-freetype-src but building freetype failed. (see freetype.log for build results)])
-          AC_MSG_ERROR([Consider building freetype manually and using --with-freetype instead.])
-        fi
-      else
-        AC_MSG_WARN([--with-freetype-src is currently only supported on Windows - ignoring])
-      fi
-    fi
-
-    if test "x$with_freetype" != x || test "x$with_freetype_include" != x || test "x$with_freetype_lib" != x; then
-      # User has specified settings
-
-      if test "x$BUNDLE_FREETYPE" = x; then
-        # If not specified, default is to bundle freetype
-        BUNDLE_FREETYPE=yes
-      fi
-
-      if test "x$with_freetype" != x; then
-        POTENTIAL_FREETYPE_INCLUDE_PATH="$with_freetype/include"
-        POTENTIAL_FREETYPE_LIB_PATH="$with_freetype/lib"
-      fi
-
-      # Allow --with-freetype-lib and --with-freetype-include to override
-      if test "x$with_freetype_include" != x; then
-        POTENTIAL_FREETYPE_INCLUDE_PATH="$with_freetype_include"
-      fi
-      if test "x$with_freetype_lib" != x; then
-        POTENTIAL_FREETYPE_LIB_PATH="$with_freetype_lib"
-      fi
-
-      if test "x$POTENTIAL_FREETYPE_INCLUDE_PATH" != x && test "x$POTENTIAL_FREETYPE_LIB_PATH" != x; then
-        # Okay, we got it. Check that it works.
-        LIB_CHECK_POTENTIAL_FREETYPE($POTENTIAL_FREETYPE_INCLUDE_PATH, $POTENTIAL_FREETYPE_LIB_PATH, [--with-freetype])
-        if test "x$FOUND_FREETYPE" != xyes; then
-          AC_MSG_ERROR([Can not find or use freetype at location given by --with-freetype])
-        fi
-      else
-        # User specified only one of lib or include. This is an error.
-        if test "x$POTENTIAL_FREETYPE_INCLUDE_PATH" = x ; then
-          AC_MSG_NOTICE([User specified --with-freetype-lib but not --with-freetype-include])
-          AC_MSG_ERROR([Need both freetype lib and include paths. Consider using --with-freetype instead.])
-        else
-          AC_MSG_NOTICE([User specified --with-freetype-include but not --with-freetype-lib])
-          AC_MSG_ERROR([Need both freetype lib and include paths. Consider using --with-freetype instead.])
-        fi
+  FREETYPE_TO_USE=bundled
+  if (test "x$OPENJDK_TARGET_OS" != "xwindows" && test "x$OPENJDK_TARGET_OS" != "xmacosx"); then
+    FREETYPE_TO_USE=system
+  fi
+  if (test "x$with_freetype" != "x"); then
+    if (test "x$with_freetype" = "xsystem"); then
+      FREETYPE_TO_USE=system
+    elif (test "x$with_freetype" = "xbundled"); then
+      FREETYPE_TO_USE=bundled
+      if (test "x$with_freetype_include" != "x"  || test "x$with_freetype_lib" != "x"); then
+        AC_MSG_ERROR(['bundled' cannot be specified with --with_freetype_include and --with_freetype_lib])
       fi
     else
-      # User did not specify settings, but we need freetype. Try to locate it.
+       AC_MSG_ERROR(['valid values for --with-freetype are 'system' and 'bundled'])
+    fi
+  fi
 
-      if test "x$BUNDLE_FREETYPE" = x; then
-        # If not specified, default is to bundle freetype only on windows
-        if test "x$OPENJDK_TARGET_OS" = xwindows; then
-          BUNDLE_FREETYPE=yes
-        else
-          BUNDLE_FREETYPE=no
-        fi
+  if (test "x$with_freetype_include" != "x"  && test "x$with_freetype_lib" != "x"); then 
+      FREETYPE_TO_USE=system
+  fi
+
+  if (test "x$FREETYPE_TO_USE" = "xsystem") && \
+     (test "x$OPENJDK_TARGET_OS" = "xwindows" || test "x$OPENJDK_TARGET_OS" = "xmacosx"); then
+       AC_MSG_ERROR([Only bundled freetype can be specified on Mac and Windows])
+  fi
+
+  if (test "x$with_freetype_include" != "x"); then
+    POTENTIAL_FREETYPE_INCLUDE_PATH="$with_freetype_include"
+  fi
+  if (test "x$with_freetype_lib" != "x"); then
+    POTENTIAL_FREETYPE_LIB_PATH="$with_freetype_lib"
+  fi
+
+  if (test "x$FREETYPE_TO_USE" = "xsystem"); then
+    if (test "x$POTENTIAL_FREETYPE_INCLUDE_PATH" != "x" && test "x$POTENTIAL_FREETYPE_LIB_PATH" != "x"); then
+      # Okay, we got it. Check that it works.
+      LIB_CHECK_POTENTIAL_FREETYPE($POTENTIAL_FREETYPE_INCLUDE_PATH, $POTENTIAL_FREETYPE_LIB_PATH, [--with-freetype])
+      if (test "x$FOUND_FREETYPE" != "xyes"); then
+        AC_MSG_ERROR([Can not find or use freetype at location given by --with-freetype-lib|include])
       fi
+    else
+      # User did not specify a location, but asked for system freetype. Try to locate it.
 
       # If we have a sysroot, assume that's where we are supposed to look and skip pkg-config.
-      if test "x$SYSROOT" = x; then
-        if test "x$FOUND_FREETYPE" != xyes; then
+      if (test "x$SYSROOT" = "x"); then
+        if (test "x$FOUND_FREETYPE" != "xyes"); then
           # Check modules using pkg-config, but only if we have it (ugly output results otherwise)
-          if test "x$PKG_CONFIG" != x; then
+          if (test "x$PKG_CONFIG" != "x"); then
             PKG_CHECK_MODULES(FREETYPE, freetype2, [FOUND_FREETYPE=yes], [FOUND_FREETYPE=no])
-            if test "x$FOUND_FREETYPE" = xyes; then
+            if (test "x$FOUND_FREETYPE" = "xyes"); then
               # On solaris, pkg_check adds -lz to freetype libs, which isn't necessary for us.
               FREETYPE_LIBS=`$ECHO $FREETYPE_LIBS | $SED 's/-lz//g'`
               # 64-bit libs for Solaris x86 are installed in the amd64 subdirectory, change lib to lib/amd64
-              if test "x$OPENJDK_TARGET_OS" = xsolaris && test "x$OPENJDK_TARGET_CPU" = xx86_64; then
+              if (test "x$OPENJDK_TARGET_OS" = "xsolaris" && test "x$OPENJDK_TARGET_CPU" = "xx86_64"); then
                 FREETYPE_LIBS=`$ECHO $FREETYPE_LIBS | $SED 's?/lib?/lib/amd64?g'`
               fi
-              # PKG_CHECK_MODULES will set FREETYPE_CFLAGS and _LIBS, but we don't get a lib path for bundling.
-              if test "x$BUNDLE_FREETYPE" = xyes; then
-                AC_MSG_NOTICE([Found freetype using pkg-config, but ignoring since we can not bundle that])
-                FOUND_FREETYPE=no
-              else
-                AC_MSG_CHECKING([for freetype])
-                AC_MSG_RESULT([yes (using pkg-config)])
-              fi
+              AC_MSG_CHECKING([for freetype])
+              AC_MSG_RESULT([yes (using pkg-config)])
             fi
           fi
         fi
       fi
 
-      if test "x$FOUND_FREETYPE" != xyes; then
+      if (test "x$FOUND_FREETYPE" != "xyes"); then
         # Check in well-known locations
-        if test "x$OPENJDK_TARGET_OS" = xwindows; then
-          FREETYPE_BASE_DIR="$PROGRAMFILES/GnuWin32"
-          BASIC_WINDOWS_REWRITE_AS_UNIX_PATH(FREETYPE_BASE_DIR)
+        FREETYPE_BASE_DIR="$SYSROOT/usr"
+        LIB_CHECK_POTENTIAL_FREETYPE([$FREETYPE_BASE_DIR/include], [$FREETYPE_BASE_DIR/lib], [well-known location])
+
+        if (test "x$FOUND_FREETYPE" != "xyes"); then
+          FREETYPE_BASE_DIR="$SYSROOT/usr/X11"
           LIB_CHECK_POTENTIAL_FREETYPE([$FREETYPE_BASE_DIR/include], [$FREETYPE_BASE_DIR/lib], [well-known location])
-          if test "x$FOUND_FREETYPE" != xyes; then
-            FREETYPE_BASE_DIR="$ProgramW6432/GnuWin32"
-            BASIC_WINDOWS_REWRITE_AS_UNIX_PATH(FREETYPE_BASE_DIR)
-            LIB_CHECK_POTENTIAL_FREETYPE([$FREETYPE_BASE_DIR/include], [$FREETYPE_BASE_DIR/lib], [well-known location])
-          fi
-          if test "x$FOUND_FREETYPE" != xyes; then
-            FREETYPE_BASE_DIR="$HOME/freetype"
-            BASIC_WINDOWS_REWRITE_AS_UNIX_PATH(FREETYPE_BASE_DIR)
-            if test "x$OPENJDK_TARGET_CPU_BITS" = x64; then
-              LIB_CHECK_POTENTIAL_FREETYPE([$FREETYPE_BASE_DIR/include], [$FREETYPE_BASE_DIR/lib64], [well-known location])
-            else
+        fi
+        if (test "x$FOUND_FREETYPE" != "xyes"); then
+          FREETYPE_BASE_DIR="$SYSROOT/usr/local"
+          LIB_CHECK_POTENTIAL_FREETYPE([$FREETYPE_BASE_DIR/include], [$FREETYPE_BASE_DIR/lib], [well-known location])
+        fi
+
+        if (test "x$FOUND_FREETYPE" != "xyes"); then
+          FREETYPE_BASE_DIR="$SYSROOT/usr"
+          if (test "x$OPENJDK_TARGET_CPU_BITS" = "x64"); then
+            LIB_CHECK_POTENTIAL_FREETYPE([$FREETYPE_BASE_DIR/include], [$FREETYPE_BASE_DIR/lib/$OPENJDK_TARGET_CPU-linux-gnu], [well-known location])
+          else
+            LIB_CHECK_POTENTIAL_FREETYPE([$FREETYPE_BASE_DIR/include], [$FREETYPE_BASE_DIR/lib/i386-linux-gnu], [well-known location])
+            if (test "x$FOUND_FREETYPE" != "xyes"); then
               LIB_CHECK_POTENTIAL_FREETYPE([$FREETYPE_BASE_DIR/include], [$FREETYPE_BASE_DIR/lib32], [well-known location])
             fi
-            if test "x$FOUND_FREETYPE" != xyes && test -d $FREETYPE_BASE_DIR \
-                && test -s "$FREETYPE_BASE_DIR/builds/windows/vc2010/freetype.vcxproj" && test "x$MSBUILD" != x; then
-              # Source is available, as a last resort try to build freetype in default location
-              LIB_BUILD_FREETYPE($FREETYPE_BASE_DIR)
-              if test "x$OPENJDK_TARGET_CPU_BITS" = x64; then
-                LIB_CHECK_POTENTIAL_FREETYPE([$FREETYPE_BASE_DIR/include], [$FREETYPE_BASE_DIR/lib64], [well-known location])
-              else
-                LIB_CHECK_POTENTIAL_FREETYPE([$FREETYPE_BASE_DIR/include], [$FREETYPE_BASE_DIR/lib32], [well-known location])
-              fi
-            fi
-          fi
-        else
-          FREETYPE_BASE_DIR="$SYSROOT/usr"
-          LIB_CHECK_POTENTIAL_FREETYPE([$FREETYPE_BASE_DIR/include], [$FREETYPE_BASE_DIR/lib], [well-known location])
-
-          if test "x$FOUND_FREETYPE" != xyes; then
-            FREETYPE_BASE_DIR="$SYSROOT/usr/X11"
-            LIB_CHECK_POTENTIAL_FREETYPE([$FREETYPE_BASE_DIR/include], [$FREETYPE_BASE_DIR/lib], [well-known location])
-          fi
-          if test "x$FOUND_FREETYPE" != xyes; then
-            FREETYPE_BASE_DIR="$SYSROOT/usr/local"
-            LIB_CHECK_POTENTIAL_FREETYPE([$FREETYPE_BASE_DIR/include], [$FREETYPE_BASE_DIR/lib], [well-known location])
-          fi
-
-          if test "x$OPENJDK_TARGET_OS" = xmacosx; then
-            if test "x$FOUND_FREETYPE" != xyes; then
-              # Due to changes in OSX 10.11 XQuartz now installs to /opt/X11
-              FREETYPE_BASE_DIR="$SYSROOT/opt/X11"
-              LIB_CHECK_POTENTIAL_FREETYPE([$FREETYPE_BASE_DIR/include], [$FREETYPE_BASE_DIR/lib], [well-known location])
-            fi
-          fi
-
-          if test "x$FOUND_FREETYPE" != xyes; then
-            FREETYPE_BASE_DIR="$SYSROOT/usr"
-            if test "x$OPENJDK_TARGET_CPU_BITS" = x64; then
-              LIB_CHECK_POTENTIAL_FREETYPE([$FREETYPE_BASE_DIR/include], [$FREETYPE_BASE_DIR/lib/$OPENJDK_TARGET_CPU-linux-gnu], [well-known location])
-            else
-              LIB_CHECK_POTENTIAL_FREETYPE([$FREETYPE_BASE_DIR/include], [$FREETYPE_BASE_DIR/lib/i386-linux-gnu], [well-known location])
-              if test "x$FOUND_FREETYPE" != xyes; then