< prev index next >

doc/building.html

Print this page


   1 <!DOCTYPE html>
   2 <html xmlns="http://www.w3.org/1999/xhtml" lang="" xml:lang="">
   3 <head>
   4   <meta charset="utf-8" />
   5   <meta name="generator" content="pandoc" />
   6   <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
   7   <title>Building the JDK</title>
   8   <style type="text/css">
   9       code{white-space: pre-wrap;}
  10       span.smallcaps{font-variant: small-caps;}
  11       span.underline{text-decoration: underline;}
  12       div.column{display: inline-block; vertical-align: top; width: 50%;}
  13   </style>
  14   <link rel="stylesheet" href="../make/data/docs-resources/resources/jdk-default.css" />
  15   <!--[if lt IE 9]>
  16     <script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>
  17   <![endif]-->
  18   <style type="text/css">pre, code, tt { color: #1d6ae5; }</style>
  19 </head>
  20 <body>
  21 <header id="title-block-header">
  22 <h1 class="title">Building the JDK</h1>
  23 </header>
  24 <nav id="TOC">
  25 <ul>
  26 <li><a href="#tldr-instructions-for-the-impatient">TL;DR (Instructions for the Impatient)</a></li>
  27 <li><a href="#introduction">Introduction</a></li>
  28 <li><a href="#getting-the-source-code">Getting the Source Code</a><ul>
  29 <li><a href="#special-considerations">Special Considerations</a></li>
  30 </ul></li>
  31 <li><a href="#build-hardware-requirements">Build Hardware Requirements</a><ul>
  32 <li><a href="#building-on-x86">Building on x86</a></li>
  33 <li><a href="#building-on-sparc">Building on sparc</a></li>
  34 <li><a href="#building-on-aarch64">Building on aarch64</a></li>
  35 <li><a href="#building-on-32-bit-arm">Building on 32-bit arm</a></li>
  36 </ul></li>
  37 <li><a href="#operating-system-requirements">Operating System Requirements</a><ul>
  38 <li><a href="#windows">Windows</a></li>
  39 <li><a href="#solaris">Solaris</a></li>
  40 <li><a href="#macos">macOS</a></li>
  41 <li><a href="#linux">Linux</a></li>


 128 <li><p><a href="#running-make">Run make</a>:<br />
 129 <code>make images</code></p></li>
 130 <li><p>Verify your newly built JDK:<br />
 131 <code>./build/*/images/jdk/bin/java -version</code></p></li>
 132 <li><p><a href="##running-tests">Run basic tests</a>:<br />
 133 <code>make run-test-tier1</code></p></li>
 134 </ol>
 135 <p>If any of these steps failed, or if you want to know more about build requirements or build functionality, please continue reading this document.</p>
 136 <h2 id="introduction">Introduction</h2>
 137 <p>The JDK is a complex software project. Building it requires a certain amount of technical expertise, a fair number of dependencies on external software, and reasonably powerful hardware.</p>
 138 <p>If you just want to use the JDK and not build it yourself, this document is not for you. See for instance <a href="http://openjdk.java.net/install">OpenJDK installation</a> for some methods of installing a prebuilt JDK.</p>
 139 <h2 id="getting-the-source-code">Getting the Source Code</h2>
 140 <p>Make sure you are getting the correct version. As of JDK 10, the source is no longer split into separate repositories so you only need to clone one single repository. At the <a href="http://hg.openjdk.java.net/">OpenJDK Mercurial server</a> you can see a list of all available repositories. If you want to build an older version, e.g. JDK 8, it is recommended that you get the <code>jdk8u</code> forest, which contains incremental updates, instead of the <code>jdk8</code> forest, which was frozen at JDK 8 GA.</p>
 141 <p>If you are new to Mercurial, a good place to start is the <a href="http://www.mercurial-scm.org/guide">Mercurial Beginner's Guide</a>. The rest of this document assumes a working knowledge of Mercurial.</p>
 142 <h3 id="special-considerations">Special Considerations</h3>
 143 <p>For a smooth building experience, it is recommended that you follow these rules on where and how to check out the source code.</p>
 144 <ul>
 145 <li><p>Do not check out the source code in a path which contains spaces. Chances are the build will not work. This is most likely to be an issue on Windows systems.</p></li>
 146 <li><p>Do not check out the source code in a path which has a very long name or is nested many levels deep. Chances are you will hit an OS limitation during the build.</p></li>
 147 <li><p>Put the source code on a local disk, not a network share. If possible, use an SSD. The build process is very disk intensive, and having slow disk access will significantly increase build times. If you need to use a network share for the source code, see below for suggestions on how to keep the build artifacts on a local disk.</p></li>
 148 <li><p>On Windows, if using <a href="#cygwin">Cygwin</a>, extra care must be taken to make sure the environment is consistent. It is recommended that you follow this procedure:</p>
 149 <ul>
 150 <li><p>Create the directory that is going to contain the top directory of the JDK clone by using the <code>mkdir</code> command in the Cygwin bash shell. That is, do <em>not</em> create it using Windows Explorer. This will ensure that it will have proper Cygwin attributes, and that it's children will inherit those attributes.</p></li>
 151 <li><p>Do not put the JDK clone in a path under your Cygwin home directory. This is especially important if your user name contains spaces and/or mixed upper and lower case letters.</p></li>
 152 <li><p>Clone the JDK repository using the Cygwin command line <code>hg</code> client as instructed in this document. That is, do <em>not</em> use another Mercurial client such as TortoiseHg.</p></li>
 153 </ul>
 154 <p>Failure to follow this procedure might result in hard-to-debug build problems.</p></li>
 155 </ul>
 156 <h2 id="build-hardware-requirements">Build Hardware Requirements</h2>
 157 <p>The JDK is a massive project, and require machines ranging from decent to powerful to be able to build in a reasonable amount of time, or to be able to complete a build at all.</p>
 158 <p>We <em>strongly</em> recommend usage of an SSD disk for the build, since disk speed is one of the limiting factors for build performance.</p>
 159 <h3 id="building-on-x86">Building on x86</h3>
 160 <p>At a minimum, a machine with 2-4 cores is advisable, as well as 2-4 GB of RAM. (The more cores to use, the more memory you need.) At least 6 GB of free disk space is required (8 GB minimum for building on Solaris).</p>
 161 <p>Even for 32-bit builds, it is recommended to use a 64-bit build machine, and instead create a 32-bit target using <code>--with-target-bits=32</code>.</p>
 162 <h3 id="building-on-sparc">Building on sparc</h3>
 163 <p>At a minimum, a machine with 4 cores is advisable, as well as 4 GB of RAM. (The more cores to use, the more memory you need.) At least 8 GB of free disk space is required.</p>
 164 <h3 id="building-on-aarch64">Building on aarch64</h3>
 165 <p>At a minimum, a machine with 8 cores is advisable, as well as 8 GB of RAM. (The more cores to use, the more memory you need.) At least 6 GB of free disk space is required.</p>
 166 <p>If you do not have access to sufficiently powerful hardware, it is also possible to use <a href="#cross-compiling">cross-compiling</a>.</p>
 167 <h3 id="building-on-32-bit-arm">Building on 32-bit arm</h3>
 168 <p>This is not recommended. Instead, see the section on <a href="#cross-compiling">Cross-compiling</a>.</p>
 169 <h2 id="operating-system-requirements">Operating System Requirements</h2>
 170 <p>The mainline JDK project supports Linux, Solaris, macOS, AIX and Windows. Support for other operating system, e.g. BSD, exists in separate &quot;port&quot; projects.</p>
 171 <p>In general, the JDK can be built on a wide range of versions of these operating systems, but the further you deviate from what is tested on a daily basis, the more likely you are to run into problems.</p>
 172 <p>This table lists the OS versions used by Oracle when building the JDK. Such information is always subject to change, but this table is up to date at the time of writing.</p>
 173 <table>
 174 <thead>
 175 <tr class="header">
 176 <th style="text-align: left;">Operating system</th>
 177 <th style="text-align: left;">Vendor/version used</th>
 178 </tr>
 179 </thead>
 180 <tbody>
 181 <tr class="odd">
 182 <td style="text-align: left;">Linux</td>
 183 <td style="text-align: left;">Oracle Enterprise Linux 6.4 / 7.6</td>
 184 </tr>
 185 <tr class="even">
 186 <td style="text-align: left;">Solaris</td>
 187 <td style="text-align: left;">Solaris 11.3 SRU 20</td>
 188 </tr>
 189 <tr class="odd">
 190 <td style="text-align: left;">macOS</td>
 191 <td style="text-align: left;">Mac OS X 10.13 (High Sierra)</td>
 192 </tr>
 193 <tr class="even">
 194 <td style="text-align: left;">Windows</td>
 195 <td style="text-align: left;">Windows Server 2012 R2</td>
 196 </tr>
 197 </tbody>
 198 </table>
 199 <p>The double version numbers for Linux and Solaris are due to the hybrid model used at Oracle, where header files and external libraries from an older version are used when building on a more modern version of the OS.</p>
 200 <p>The Build Group has a wiki page with <a href="https://wiki.openjdk.java.net/display/Build/Supported+Build+Platforms">Supported Build Platforms</a>. From time to time, this is updated by contributors to list successes or failures of building on different platforms.</p>
 201 <h3 id="windows">Windows</h3>
 202 <p>Windows XP is not a supported platform, but all newer Windows should be able to build the JDK.</p>
 203 <p>On Windows, it is important that you pay attention to the instructions in the <a href="#special-considerations">Special Considerations</a>.</p>
 204 <p>Windows is the only non-POSIX OS supported by the JDK, and as such, requires some extra care. A POSIX support layer is required to build on Windows. Currently, the only supported such layers are Cygwin and Windows Subsystem for Linux (WSL). (Msys is no longer supported due to a too old bash; msys2 would likely be possible to support in a future version but that would require effort to implement.)</p>
 205 <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>
 206 <h4 id="cygwin">Cygwin</h4>
 207 <p>A functioning <a href="http://www.cygwin.com/">Cygwin</a> environment is required for building the JDK on Windows. If you have a 64-bit OS, we strongly recommend using the 64-bit version of Cygwin.</p>
 208 <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 JDK build process, and that can cause unexpected build problems.</p>
 209 <p>The JDK requires GNU Make 4.0 or greater in Cygwin. This is usually not a problem, since Cygwin currently only distributes GNU Make at a version above 4.0.</p>
 210 <p>Apart from the basic Cygwin installation, the following packages must also be installed:</p>
 211 <ul>
 212 <li><code>autoconf</code></li>
 213 <li><code>make</code></li>
 214 <li><code>zip</code></li>
 215 <li><code>unzip</code></li>
 216 </ul>
 217 <p>Often, you can install these packages using the following command line:</p>
 218 <pre><code>&lt;path to Cygwin setup&gt;/setup-x86_64 -q -P autoconf -P make -P unzip -P zip</code></pre>
 219 <p>Unfortunately, Cygwin can be unreliable in certain circumstances. If you experience build tool crashes or strange issues when building on Windows, please check the Cygwin FAQ on the <a href="https://cygwin.com/faq/faq.html#faq.using.bloda">&quot;BLODA&quot; list</a> and the section on <a href="https://cygwin.com/faq/faq.html#faq.using.fixing-fork-failures">fork() failures</a>.</p>
 220 <h4 id="windows-subsystem-for-linux-wsl">Windows Subsystem for Linux (WSL)</h4>
 221 <p>Windows 10 1809 or newer is supported due to a dependency on the wslpath utility and support for environment variable sharing through WSLENV. Version 1803 can work but intermittent build failures have been observed.</p>
 222 <p>It's possible to build both Windows and Linux binaries from WSL. To build Windows binaries, you must use a Windows boot JDK (located in a Windows-accessible directory). To build Linux binaries, you must use a Linux boot JDK. The default behavior is to build for Windows. To build for Linux, pass <code>--build=x86_64-unknown-linux-gnu --host=x86_64-unknown-linux-gnu</code> to <code>configure</code>.</p>
 223 <p>If building Windows binaries, the source code must be located in a Windows- accessible directory. This is because Windows executables (such as Visual Studio and the boot JDK) must be able to access the source code. Also, the drive where the source is stored must be mounted as case-insensitive by changing either /etc/fstab or /etc/wsl.conf in WSL. Individual directories may be corrected using the fsutil tool in case the source was cloned before changing the mount options.</p>
 224 <p>Note that while it's possible to build on WSL, testing is still not fully supported.</p>
 225 <h3 id="solaris">Solaris</h3>
 226 <p>See <code>make/devkit/solaris11.1-package-list.txt</code> for a list of recommended packages to install when building on Solaris. The versions specified in this list is the versions used by the daily builds at Oracle, and is likely to work properly.</p>
 227 <p>Older versions of Solaris shipped a broken version of <code>objcopy</code>. At least version 2.21.1 is needed, which is provided by Solaris 11 Update 1. Objcopy is needed if you want to have external debug symbols. Please make sure you are using at least version 2.21.1 of objcopy, or that you disable external debug symbols.</p>
 228 <h3 id="macos">macOS</h3>
 229 <p>Apple is using a quite aggressive scheme of pushing OS updates, and coupling these updates with required updates of Xcode. Unfortunately, this makes it difficult for a project such as the JDK to keep pace with a continuously updated machine running macOS. See the section on <a href="#apple-xcode">Apple Xcode</a> on some strategies to deal with this.</p>
 230 <p>It is recommended that you use at least Mac OS X 10.13 (High Sierra). At the time of writing, the JDK has been successfully compiled on macOS 10.12 (Sierra).</p>
 231 <p>The standard macOS environment contains the basic tooling needed to build, but for external libraries a package manager is recommended. The JDK uses <a href="https://brew.sh/">homebrew</a> in the examples, but feel free to use whatever manager you want (or none).</p>
 232 <h3 id="linux">Linux</h3>
 233 <p>It is often not much problem to build the JDK on Linux. The only general advice is to try to use the compilers, external libraries and header files as provided by your distribution.</p>
 234 <p>The basic tooling is provided as part of the core operating system, but you will most likely need to install developer packages.</p>
 235 <p>For apt-based distributions (Debian, Ubuntu, etc), try this:</p>
 236 <pre><code>sudo apt-get install build-essential</code></pre>
 237 <p>For rpm-based distributions (Fedora, Red Hat, etc), try this:</p>
 238 <pre><code>sudo yum groupinstall &quot;Development Tools&quot;</code></pre>
 239 <h3 id="aix">AIX</h3>
 240 <p>Please consult the AIX section of the <a href="https://wiki.openjdk.java.net/display/Build/Supported+Build+Platforms">Supported Build Platforms</a> OpenJDK Build Wiki page for details about which versions of AIX are supported.</p>
 241 <h2 id="native-compiler-toolchain-requirements">Native Compiler (Toolchain) Requirements</h2>
 242 <p>Large portions of the JDK consists of native code, that needs to be compiled to be able to run on the target platform. In theory, toolchain and operating system should be independent factors, but in practice there's more or less a one-to-one correlation between target operating system and toolchain.</p>
 243 <table>
 244 <thead>
 245 <tr class="header">
 246 <th style="text-align: left;">Operating system</th>
 247 <th style="text-align: left;">Supported toolchain</th>
 248 </tr>
 249 </thead>
 250 <tbody>
 251 <tr class="odd">
 252 <td style="text-align: left;">Linux</td>
 253 <td style="text-align: left;">gcc, clang</td>
 254 </tr>
 255 <tr class="even">
 256 <td style="text-align: left;">macOS</td>
 257 <td style="text-align: left;">Apple Xcode (using clang)</td>
 258 </tr>
 259 <tr class="odd">
 260 <td style="text-align: left;">Solaris</td>


 264 <td style="text-align: left;">AIX</td>
 265 <td style="text-align: left;">IBM XL C/C++</td>
 266 </tr>
 267 <tr class="odd">
 268 <td style="text-align: left;">Windows</td>
 269 <td style="text-align: left;">Microsoft Visual Studio</td>
 270 </tr>
 271 </tbody>
 272 </table>
 273 <p>Please see the individual sections on the toolchains for version recommendations. As a reference, these versions of the toolchains are used, at the time of writing, by Oracle for the daily builds of the JDK. It should be possible to compile the JDK with both older and newer versions, but the closer you stay to this list, the more likely you are to compile successfully without issues.</p>
 274 <table>
 275 <thead>
 276 <tr class="header">
 277 <th style="text-align: left;">Operating system</th>
 278 <th style="text-align: left;">Toolchain version</th>
 279 </tr>
 280 </thead>
 281 <tbody>
 282 <tr class="odd">
 283 <td style="text-align: left;">Linux</td>
 284 <td style="text-align: left;">gcc 8.2.0</td>
 285 </tr>
 286 <tr class="even">
 287 <td style="text-align: left;">macOS</td>
 288 <td style="text-align: left;">Apple Xcode 10.1 (using clang 10.0.0)</td>
 289 </tr>
 290 <tr class="odd">
 291 <td style="text-align: left;">Solaris</td>
 292 <td style="text-align: left;">Oracle Solaris Studio 12.6 (with compiler version 5.15)</td>
 293 </tr>
 294 <tr class="even">
 295 <td style="text-align: left;">Windows</td>
 296 <td style="text-align: left;">Microsoft Visual Studio 2017 update 15.9.6</td>
 297 </tr>
 298 </tbody>
 299 </table>
 300 <p>All compilers are expected to be able to compile to the C99 language standard,
 301 as some C99 features are used in the source code. Microsoft Visual Studio
 302 doesn't fully support C99 so in practice shared code is limited to using C99
 303 features that it does support.</p>
 304 <h3 id="gcc">gcc</h3>
 305 <p>The minimum accepted version of gcc is 4.8. Older versions will generate a warning by <code>configure</code> and are unlikely to work.</p>
 306 <p>The JDK is currently known to be able to compile with at least version 7.4 of gcc.</p>
 307 <p>In general, any version between these two should be usable.</p>
 308 <h3 id="clang">clang</h3>
 309 <p>The minimum accepted version of clang is 3.2. Older versions will not be accepted by <code>configure</code>.</p>
 310 <p>To use clang instead of gcc on Linux, use <code>--with-toolchain-type=clang</code>.</p>
 311 <h3 id="apple-xcode">Apple Xcode</h3>
 312 <p>The oldest supported version of Xcode is 8.</p>
 313 <p>You will need the Xcode command lines developers tools to be able to build the JDK. (Actually, <em>only</em> the command lines tools are needed, not the IDE.) The simplest way to install these is to run:</p>
 314 <pre><code>xcode-select --install</code></pre>
 315 <p>It is advisable to keep an older version of Xcode for building the JDK when updating Xcode. This <a href="http://iosdevelopertips.com/xcode/install-multiple-versions-of-xcode.html">blog page</a> has good suggestions on managing multiple Xcode versions. To use a specific version of Xcode, use <code>xcode-select -s</code> before running <code>configure</code>, or use <code>--with-toolchain-path</code> to point to the version of Xcode to use, e.g. <code>configure --with-toolchain-path=/Applications/Xcode8.app/Contents/Developer/usr/bin</code></p>
 316 <p>If you have recently (inadvertently) updated your OS and/or Xcode version, and the JDK can no longer be built, please see the section on <a href="#problems-with-the-build-environment">Problems with the Build Environment</a>, and <a href="#getting-help">Getting Help</a> to find out if there are any recent, non-merged patches available for this update.</p>
 317 <h3 id="oracle-solaris-studio">Oracle Solaris Studio</h3>
 318 <p>The minimum accepted version of the Solaris Studio compilers is 5.13 (corresponding to Solaris Studio 12.4). Older versions will not be accepted by configure.</p>
 319 <p>The Solaris Studio installation should contain at least these packages:</p>
 320 <table>
 321 <thead>
 322 <tr class="header">
 323 <th style="text-align: left;">Package</th>


 356 <tr class="even">
 357 <td style="text-align: left;">developer/solarisstudio-124/studio-ja</td>
 358 <td style="text-align: left;">12.4-1.0.0.1</td>
 359 </tr>
 360 <tr class="odd">
 361 <td style="text-align: left;">developer/solarisstudio-124/studio-legal</td>
 362 <td style="text-align: left;">12.4-1.0.0.1</td>
 363 </tr>
 364 <tr class="even">
 365 <td style="text-align: left;">developer/solarisstudio-124/studio-zhCN</td>
 366 <td style="text-align: left;">12.4-1.0.0.1</td>
 367 </tr>
 368 </tbody>
 369 </table>
 370 <p>Compiling with Solaris Studio can sometimes be finicky. This is the exact version used by Oracle, which worked correctly at the time of writing:</p>
 371 <pre><code>$ cc -V
 372 cc: Sun C 5.13 SunOS_i386 2014/10/20
 373 $ CC -V
 374 CC: Sun C++ 5.13 SunOS_i386 151846-10 2015/10/30</code></pre>
 375 <h3 id="microsoft-visual-studio">Microsoft Visual Studio</h3>
 376 <p>The minimum accepted version of Visual Studio is 2010. Older versions will not be accepted by <code>configure</code>. The maximum accepted version of Visual Studio is 2019. Versions older than 2017 are unlikely to continue working for long.</p>
 377 <p>If you have multiple versions of Visual Studio installed, <code>configure</code> will by default pick the latest. You can request a specific version to be used by setting <code>--with-toolchain-version</code>, e.g. <code>--with-toolchain-version=2015</code>.</p>
 378 <p>If you get <code>LINK: fatal error LNK1123: failure during conversion to COFF: file invalid</code> when building using Visual Studio 2010, you have encountered <a href="http://support.microsoft.com/kb/2757355">KB2757355</a>, a bug triggered by a specific installation order. However, the solution suggested by the KB article does not always resolve the problem. See <a href="https://stackoverflow.com/questions/10888391">this stackoverflow discussion</a> for other suggestions.</p>
 379 <h3 id="ibm-xl-cc">IBM XL C/C++</h3>
 380 <p>Please consult the AIX section of the <a href="https://wiki.openjdk.java.net/display/Build/Supported+Build+Platforms">Supported Build Platforms</a> OpenJDK Build Wiki page for details about which versions of XLC are supported.</p>

 381 <h2 id="boot-jdk-requirements">Boot JDK Requirements</h2>
 382 <p>Paradoxically, building the JDK requires a pre-existing JDK. This is called the &quot;boot JDK&quot;. The boot JDK does not, however, have to be a JDK built directly from the source code available in the OpenJDK Community. If you are porting the JDK to a new platform, chances are that there already exists another JDK for that platform that is usable as boot JDK.</p>
 383 <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, the JDK should be able to &quot;build itself&quot;, so an up-to-date build of the current JDK 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>
 384 <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>
 385 <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>
 386 <h3 id="getting-jdk-binaries">Getting JDK binaries</h3>
 387 <p>JDK 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>
 388 <p>On Linux you can also get a JDK 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 a JDK &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>
 389 <h2 id="external-library-requirements">External Library Requirements</h2>
 390 <p>Different platforms require different external libraries. In general, libraries are not optional - that is, they are either required or not used.</p>
 391 <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>
 392 <p>As a fallback, the second version allows you to point to the include directory and the lib directory separately.</p>
 393 <h3 id="freetype">FreeType</h3>
 394 <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 the JDK’s own copy.</p>
 395 <ul>
 396 <li>To install on an apt-based Linux, try running <code>sudo apt-get install libfreetype6-dev</code>.</li>
 397 <li>To install on an rpm-based Linux, try running <code>sudo yum install freetype-devel</code>.</li>
 398 <li>To install on Solaris, try running <code>pkg install system/library/freetype-2</code>.</li>
 399 </ul>
 400 <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>
 401 <h3 id="cups">CUPS</h3>
 402 <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>
 403 <ul>
 404 <li>To install on an apt-based Linux, try running <code>sudo apt-get install libcups2-dev</code>.</li>
 405 <li>To install on an rpm-based Linux, try running <code>sudo yum install cups-devel</code>.</li>
 406 <li>To install on Solaris, try running <code>pkg install print/cups</code>.</li>
 407 </ul>
 408 <p>Use <code>--with-cups=&lt;path&gt;</code> if <code>configure</code> does not properly locate your CUPS files.</p>
 409 <h3 id="x11">X11</h3>
 410 <p>Certain <a href="http://www.x.org/">X11</a> libraries and include files are required on Linux and Solaris.</p>
 411 <ul>
 412 <li>To install on an apt-based Linux, try running <code>sudo apt-get install libx11-dev libxext-dev libxrender-dev libxrandr-dev libxtst-dev libxt-dev</code>.</li>
 413 <li>To install on an rpm-based Linux, try running <code>sudo yum install libXtst-devel libXt-devel libXrender-devel libXrandr-devel libXi-devel</code>.</li>
 414 <li>To install on Solaris, try running <code>pkg install x11/header/x11-protocols x11/library/libice x11/library/libpthread-stubs x11/library/libsm x11/library/libx11 x11/library/libxau x11/library/libxcb x11/library/libxdmcp x11/library/libxevie x11/library/libxext x11/library/libxrender x11/library/libxrandr x11/library/libxscrnsaver x11/library/libxtst x11/library/toolkit/libxt</code>.</li>
 415 </ul>
 416 <p>Use <code>--with-x=&lt;path&gt;</code> if <code>configure</code> does not properly locate your X11 files.</p>
 417 <h3 id="alsa">ALSA</h3>
 418 <p>ALSA, <a href="https://www.alsa-project.org/">Advanced Linux Sound Architecture</a> is required on Linux. At least version 0.9.1 of ALSA is required.</p>
 419 <ul>
 420 <li>To install on an apt-based Linux, try running <code>sudo apt-get install libasound2-dev</code>.</li>
 421 <li>To install on an rpm-based Linux, try running <code>sudo yum install alsa-lib-devel</code>.</li>
 422 </ul>
 423 <p>Use <code>--with-alsa=&lt;path&gt;</code> if <code>configure</code> does not properly locate your ALSA files.</p>
 424 <h3 id="libffi">libffi</h3>
 425 <p>libffi, the <a href="http://sourceware.org/libffi">Portable Foreign Function Interface Library</a> is required when building the Zero version of Hotspot.</p>
 426 <ul>
 427 <li>To install on an apt-based Linux, try running <code>sudo apt-get install libffi-dev</code>.</li>
 428 <li>To install on an rpm-based Linux, try running <code>sudo yum install libffi-devel</code>.</li>
 429 </ul>
 430 <p>Use <code>--with-libffi=&lt;path&gt;</code> if <code>configure</code> does not properly locate your libffi files.</p>
 431 <h2 id="build-tools-requirements">Build Tools Requirements</h2>
 432 <h3 id="autoconf">Autoconf</h3>
 433 <p>The JDK requires <a href="http://www.gnu.org/software/autoconf">Autoconf</a> on all platforms. At least version 2.69 is required.</p>
 434 <ul>


 460 <pre><code>bash configure --with-freetype=/cygdrive/c/freetype-i586 --with-target-bits=32</code></pre></li>
 461 <li><p>Create a debug build with the <code>server</code> JVM and DTrace enabled:</p>
 462 <pre><code>bash configure --enable-debug --with-jvm-variants=server --enable-dtrace</code></pre></li>
 463 </ul>
 464 <h3 id="common-configure-arguments">Common Configure Arguments</h3>
 465 <p>Here follows some of the most common and important <code>configure</code> argument.</p>
 466 <p>To get up-to-date information on <em>all</em> available <code>configure</code> argument, please run:</p>
 467 <pre><code>bash configure --help</code></pre>
 468 <p>(Note that this help text also include general autoconf options, like <code>--dvidir</code>, that is not relevant to the JDK. To list only JDK-specific features, use <code>bash configure --help=short</code> instead.)</p>
 469 <h4 id="configure-arguments-for-tailoring-the-build">Configure Arguments for Tailoring the Build</h4>
 470 <ul>
 471 <li><code>--enable-debug</code> - Set the debug level to <code>fastdebug</code> (this is a shorthand for <code>--with-debug-level=fastdebug</code>)</li>
 472 <li><code>--with-debug-level=&lt;level&gt;</code> - Set the debug level, which can be <code>release</code>, <code>fastdebug</code>, <code>slowdebug</code> or <code>optimized</code>. Default is <code>release</code>. <code>optimized</code> is variant of <code>release</code> with additional Hotspot debug code.</li>
 473 <li><code>--with-native-debug-symbols=&lt;method&gt;</code> - Specify if and how native debug symbols should be built. Available methods are <code>none</code>, <code>internal</code>, <code>external</code>, <code>zipped</code>. Default behavior depends on platform. See <a href="#native-debug-symbols">Native Debug Symbols</a> for more details.</li>
 474 <li><code>--with-version-string=&lt;string&gt;</code> - Specify the version string this build will be identified with.</li>
 475 <li><code>--with-version-&lt;part&gt;=&lt;value&gt;</code> - A group of options, where <code>&lt;part&gt;</code> can be any of <code>pre</code>, <code>opt</code>, <code>build</code>, <code>major</code>, <code>minor</code>, <code>security</code> or <code>patch</code>. Use these options to modify just the corresponding part of the version string from the default, or the value provided by <code>--with-version-string</code>.</li>
 476 <li><code>--with-jvm-variants=&lt;variant&gt;[,&lt;variant&gt;...]</code> - Build the specified variant (or variants) of Hotspot. Valid variants are: <code>server</code>, <code>client</code>, <code>minimal</code>, <code>core</code>, <code>zero</code>, <code>custom</code>. Note that not all variants are possible to combine in a single build.</li>
 477 <li><code>--with-jvm-features=&lt;feature&gt;[,&lt;feature&gt;...]</code> - Use the specified JVM features when building Hotspot. The list of features will be enabled on top of the default list. For the <code>custom</code> JVM variant, this default list is empty. A complete list of available JVM features can be found using <code>bash configure --help</code>.</li>
 478 <li><code>--with-target-bits=&lt;bits&gt;</code> - Create a target binary suitable for running on a <code>&lt;bits&gt;</code> platform. Use this to create 32-bit output on a 64-bit build platform, instead of doing a full cross-compile. (This is known as a <em>reduced</em> build.)</li>
 479 </ul>
 480 <p>On Linux, BSD and AIX, it is possible to override where Java by default searches for runtime/JNI libraries. This can be useful in situations where there is a special shared directory for system JNI libraries. This setting can in turn be overriden at runtime by setting the <code>java.library.path</code> property.</p>
 481 <ul>
 482 <li><code>--with-jni-libpath=&lt;path&gt;</code> - Use the specified path as a default when searching for runtime libraries.</li>
 483 </ul>
 484 <h4 id="configure-arguments-for-native-compilation">Configure Arguments for Native Compilation</h4>
 485 <ul>
 486 <li><code>--with-devkit=&lt;path&gt;</code> - Use this devkit for compilers, tools and resources</li>
 487 <li><code>--with-sysroot=&lt;path&gt;</code> - Use this directory as sysroot</li>
 488 <li><code>--with-extra-path=&lt;path&gt;[;&lt;path&gt;]</code> - Prepend these directories to the default path when searching for all kinds of binaries</li>
 489 <li><code>--with-toolchain-path=&lt;path&gt;[;&lt;path&gt;]</code> - Prepend these directories when searching for toolchain binaries (compilers etc)</li>
 490 <li><code>--with-extra-cflags=&lt;flags&gt;</code> - Append these flags when compiling JDK C files</li>
 491 <li><code>--with-extra-cxxflags=&lt;flags&gt;</code> - Append these flags when compiling JDK C++ files</li>
 492 <li><code>--with-extra-ldflags=&lt;flags&gt;</code> - Append these flags when linking JDK libraries</li>
 493 </ul>
 494 <h4 id="configure-arguments-for-external-dependencies">Configure Arguments for External Dependencies</h4>
 495 <ul>
 496 <li><code>--with-boot-jdk=&lt;path&gt;</code> - Set the path to the <a href="#boot-jdk-requirements">Boot JDK</a></li>
 497 <li><code>--with-freetype=&lt;path&gt;</code> - Set the path to <a href="#freetype">FreeType</a></li>
 498 <li><code>--with-cups=&lt;path&gt;</code> - Set the path to <a href="#cups">CUPS</a></li>
 499 <li><code>--with-x=&lt;path&gt;</code> - Set the path to <a href="#x11">X11</a></li>
 500 <li><code>--with-alsa=&lt;path&gt;</code> - Set the path to <a href="#alsa">ALSA</a></li>
 501 <li><code>--with-libffi=&lt;path&gt;</code> - Set the path to <a href="#libffi">libffi</a></li>
 502 <li><code>--with-jtreg=&lt;path&gt;</code> - Set the path to JTReg. See <a href="#running-tests">Running Tests</a></li>
 503 </ul>
 504 <p>Certain third-party libraries used by the JDK (libjpeg, giflib, libpng, lcms and zlib) are included in the JDK repository. The default behavior of the JDK build is to use the included (&quot;bundled&quot;) versions of libjpeg, giflib, libpng and lcms. For zlib, the system lib (if present) is used except on Windows and AIX. However the bundled libraries may be replaced by an external version. To do so, specify <code>system</code> as the <code>&lt;source&gt;</code> option in these arguments. (The default is <code>bundled</code>).</p>
 505 <ul>
 506 <li><code>--with-libjpeg=&lt;source&gt;</code> - Use the specified source for libjpeg</li>
 507 <li><code>--with-giflib=&lt;source&gt;</code> - Use the specified source for giflib</li>
 508 <li><code>--with-libpng=&lt;source&gt;</code> - Use the specified source for libpng</li>
 509 <li><code>--with-lcms=&lt;source&gt;</code> - Use the specified source for lcms</li>
 510 <li><code>--with-zlib=&lt;source&gt;</code> - Use the specified source for zlib</li>
 511 </ul>
 512 <p>On Linux, it is possible to select either static or dynamic linking of the C++ runtime. The default is static linking, with dynamic linking as fallback if the static library is not found.</p>
 513 <ul>
 514 <li><code>--with-stdc++lib=&lt;method&gt;</code> - Use the specified method (<code>static</code>, <code>dynamic</code> or <code>default</code>) for linking the C++ runtime.</li>
 515 </ul>
 516 <h3 id="configure-control-variables">Configure Control Variables</h3>
 517 <p>It is possible to control certain aspects of <code>configure</code> by overriding the value of <code>configure</code> variables, either on the command line or in the environment.</p>
 518 <p>Normally, this is <strong>not recommended</strong>. If used improperly, it can lead to a broken configuration. Unless you're well versed in the build system, this is hard to use properly. Therefore, <code>configure</code> will print a warning if this is detected.</p>
 519 <p>However, there are a few <code>configure</code> variables, known as <em>control variables</em> that are supposed to be overriden on the command line. These are variables that describe the location of tools needed by the build, like <code>MAKE</code> or <code>GREP</code>. If any such variable is specified, <code>configure</code> will use that value instead of trying to autodetect the tool. For instance, <code>bash configure MAKE=/opt/gnumake4.0/bin/make</code>.</p>
 520 <p>If a configure argument exists, use that instead, e.g. use <code>--with-jtreg</code> instead of setting <code>JTREGEXE</code>.</p>
 521 <p>Also note that, despite what autoconf claims, setting <code>CFLAGS</code> will not accomplish anything. Instead use <code>--with-extra-cflags</code> (and similar for <code>cxxflags</code> and <code>ldflags</code>).</p>
 522 <h2 id="running-make">Running Make</h2>
 523 <p>When you have a proper configuration, all you need to do to build the JDK is to run <code>make</code>. (But see the warning at <a href="#gnu-make">GNU Make</a> about running the correct version of make.)</p>
 524 <p>When running <code>make</code> without any arguments, the default target is used, which is the same as running <code>make default</code> or <code>make jdk</code>. This will build a minimal (or roughly minimal) set of compiled output (known as an &quot;exploded image&quot;) needed for a developer to actually execute the newly built JDK. The idea is that in an incremental development fashion, when doing a normal make, you should only spend time recompiling what's changed (making it purely incremental) and only do the work that's needed to actually run and test your code.</p>


 636 <h3 id="specifying-the-target-platform">Specifying the Target Platform</h3>
 637 <p>You <em>must</em> specify the target platform when cross-compiling. Doing so will also automatically turn the build into a cross-compiling mode. The simplest way to do this is to use the <code>--openjdk-target</code> argument, e.g. <code>--openjdk-target=arm-linux-gnueabihf</code>. or <code>--openjdk-target=aarch64-oe-linux</code>. This will automatically set the <code>--build</code>, <code>--host</code> and <code>--target</code> options for autoconf, which can otherwise be confusing. (In autoconf terminology, the &quot;target&quot; is known as &quot;host&quot;, and &quot;target&quot; is used for building a Canadian cross-compiler.)</p>
 638 <h3 id="toolchain-considerations">Toolchain Considerations</h3>
 639 <p>You will need two copies of your toolchain, one which generates output that can run on the target system (the normal, or <em>target</em>, toolchain), and one that generates output that can run on the build system (the <em>build</em> toolchain). Note that cross-compiling is only supported for gcc at the time being. The gcc standard is to prefix cross-compiling toolchains with the target denominator. If you follow this standard, <code>configure</code> is likely to pick up the toolchain correctly.</p>
 640 <p>The <em>build</em> toolchain will be autodetected just the same way the normal <em>build</em>/<em>target</em> toolchain will be autodetected when not cross-compiling. If this is not what you want, or if the autodetection fails, you can specify a devkit containing the <em>build</em> toolchain using <code>--with-build-devkit</code> to <code>configure</code>, or by giving <code>BUILD_CC</code> and <code>BUILD_CXX</code> arguments.</p>
 641 <p>It is often helpful to locate the cross-compilation tools, headers and libraries in a separate directory, outside the normal path, and point out that directory to <code>configure</code>. Do this by setting the sysroot (<code>--with-sysroot</code>) and appending the directory when searching for cross-compilations tools (<code>--with-toolchain-path</code>). As a compact form, you can also use <code>--with-devkit</code> to point to a single directory, if it is correctly setup. (See <code>basics.m4</code> for details.)</p>
 642 <p>If you are unsure what toolchain and versions to use, these have been proved working at the time of writing:</p>
 643 <ul>
 644 <li><a href="https://releases.linaro.org/archive/13.11/components/toolchain/binaries/gcc-linaro-aarch64-linux-gnu-4.8-2013.11_linux.tar.xz">aarch64</a></li>
 645 <li><a href="https://launchpad.net/linaro-toolchain-unsupported/trunk/2012.09/+download/gcc-linaro-arm-linux-gnueabihf-raspbian-2012.09-20120921_linux.tar.bz2">arm 32-bit hardware floating point</a></li>
 646 </ul>
 647 <h3 id="native-libraries">Native Libraries</h3>
 648 <p>You will need copies of external native libraries for the <em>target</em> system, present on the <em>build</em> machine while building.</p>
 649 <p>Take care not to replace the <em>build</em> system's version of these libraries by mistake, since that can render the <em>build</em> machine unusable.</p>
 650 <p>Make sure that the libraries you point to (ALSA, X11, etc) are for the <em>target</em>, not the <em>build</em>, platform.</p>
 651 <h4 id="alsa-1">ALSA</h4>
 652 <p>You will need alsa libraries suitable for your <em>target</em> system. For most cases, using Debian's pre-built libraries work fine.</p>
 653 <p>Note that alsa is needed even if you only want to build a headless JDK.</p>
 654 <ul>
 655 <li><p>Go to <a href="https://www.debian.org/distrib/packages">Debian Package Search</a> and search for the <code>libasound2</code> and <code>libasound2-dev</code> packages for your <em>target</em> system. Download them to /tmp.</p></li>
 656 <li>Install the libraries into the cross-compilation toolchain. For instance:</li>
 657 </ul>
 658 <pre><code>cd /tools/gcc-linaro-arm-linux-gnueabihf-raspbian-2012.09-20120921_linux/arm-linux-gnueabihf/libc
 659 dpkg-deb -x /tmp/libasound2_1.0.25-4_armhf.deb .
 660 dpkg-deb -x /tmp/libasound2-dev_1.0.25-4_armhf.deb .</code></pre>
 661 <ul>
 662 <li>If alsa is not properly detected by <code>configure</code>, you can point it out by <code>--with-alsa</code>.</li>
 663 </ul>
 664 <h4 id="x11-1">X11</h4>
 665 <p>You will need X11 libraries suitable for your <em>target</em> system. For most cases, using Debian's pre-built libraries work fine.</p>
 666 <p>Note that X11 is needed even if you only want to build a headless JDK.</p>
 667 <ul>
 668 <li>Go to <a href="https://www.debian.org/distrib/packages">Debian Package Search</a>, search for the following packages for your <em>target</em> system, and download them to /tmp/target-x11:
 669 <ul>
 670 <li>libxi</li>
 671 <li>libxi-dev</li>
 672 <li>x11proto-core-dev</li>
 673 <li>x11proto-input-dev</li>
 674 <li>x11proto-kb-dev</li>
 675 <li>x11proto-render-dev</li>
 676 <li>x11proto-xext-dev</li>
 677 <li>libice-dev</li>
 678 <li>libxrender</li>
 679 <li>libxrender-dev</li>
 680 <li>libxrandr-dev</li>
 681 <li>libsm-dev</li>
 682 <li>libxt-dev</li>
 683 <li>libx11</li>
 684 <li>libx11-dev</li>
 685 <li>libxtst</li>
 686 <li>libxtst-dev</li>
 687 <li>libxext</li>
 688 <li>libxext-dev</li>
 689 </ul></li>
 690 <li><p>Install the libraries into the cross-compilation toolchain. For instance:</p>
 691 <pre><code>cd /tools/gcc-linaro-arm-linux-gnueabihf-raspbian-2012.09-20120921_linux/arm-linux-gnueabihf/libc/usr
 692 mkdir X11R6
 693 cd X11R6
 694 for deb in /tmp/target-x11/*.deb ; do dpkg-deb -x $deb . ; done
 695 mv usr/* .
 696 cd lib
 697 cp arm-linux-gnueabihf/* .</code></pre>
 698 <p>You can ignore the following messages. These libraries are not needed to successfully complete a full JDK build.</p>
 699 <pre><code>cp: cannot stat `arm-linux-gnueabihf/libICE.so': No such file or directory
 700 cp: cannot stat `arm-linux-gnueabihf/libSM.so': No such file or directory
 701 cp: cannot stat `arm-linux-gnueabihf/libXt.so': No such file or directory</code></pre></li>
 702 <li><p>If the X11 libraries are not properly detected by <code>configure</code>, you can point them out by <code>--with-x</code>.</p></li>
 703 </ul>
 704 <h3 id="creating-and-using-sysroots-with-qemu-deboostrap">Creating And Using Sysroots With qemu-deboostrap</h3>
 705 <p>Fortunately, you can create sysroots for foreign architectures with tools provided by your OS. On Debian/Ubuntu systems, one could use <code>qemu-deboostrap</code> to create the <em>target</em> system chroot, which would have the native libraries and headers specific to that <em>target</em> system. After that, we can use the cross-compiler on the <em>build</em> system, pointing into chroot to get the build dependencies right. This allows building for foreign architectures with native compilation speed.</p>
 706 <p>For example, cross-compiling to AArch64 from x86_64 could be done like this:</p>
 707 <ul>
 708 <li>Install cross-compiler on the <em>build</em> system:</li>
 709 </ul>
 710 <pre><code>apt install g++-aarch64-linux-gnu gcc-aarch64-linux-gnu</code></pre>
 711 <ul>
 712 <li>Create chroot on the <em>build</em> system, configuring it for <em>target</em> system:</li>
 713 </ul>
 714 <pre><code>sudo qemu-debootstrap --arch=arm64 --verbose \
 715        --include=fakeroot,build-essential,libx11-dev,libxext-dev,libxrender-dev,libxrandr-dev,libxtst-dev,libxt-dev,libcups2-dev,libfontconfig1-dev,libasound2-dev,libfreetype6-dev,libpng12-dev \
 716        --resolve-deps jessie /chroots/arm64 http://httpredir.debian.org/debian/</code></pre>
 717 <ul>
 718 <li>Configure and build with newly created chroot as sysroot/toolchain-path:</li>
 719 </ul>
 720 <pre><code>CC=aarch64-linux-gnu-gcc CXX=aarch64-linux-gnu-g++ sh ./configure --openjdk-target=aarch64-linux-gnu --with-sysroot=/chroots/arm64/ --with-toolchain-path=/chroots/arm64/
 721 make images
 722 ls build/linux-aarch64-normal-server-release/</code></pre>

 723 <p>The build does not create new files in that chroot, so it can be reused for multiple builds without additional cleanup.</p>
 724 <p>Architectures that are known to successfully cross-compile like this are:</p>
 725 <table>
 726 <thead>
 727 <tr class="header">
 728 <th style="text-align: left;">Target</th>
 729 <th style="text-align: left;"><code>CC</code></th>
 730 <th style="text-align: left;"><code>CXX</code></th>
 731 <th style="text-align: left;"><code>--arch=...</code></th>
 732 <th style="text-align: left;"><code>--openjdk-target=...</code></th>
 733 </tr>
 734 </thead>
 735 <tbody>
 736 <tr class="odd">
 737 <td style="text-align: left;">x86</td>
 738 <td style="text-align: left;">default</td>
 739 <td style="text-align: left;">default</td>
 740 <td style="text-align: left;">i386</td>
 741 <td style="text-align: left;">i386-linux-gnu</td>
 742 </tr>


 862 <li><p>Re-clone the Mercurial repository</p>
 863 <p>Sometimes the Mercurial repository gets in a state that causes the product to be un-buildable. In such a case, the simplest solution is often the &quot;sledgehammer approach&quot;: delete the entire repository, and re-clone it. If you have local changes, save them first to a different location using <code>hg export</code>.</p></li>
 864 </ol>
 865 <h3 id="specific-build-issues">Specific Build Issues</h3>
 866 <h4 id="clock-skew">Clock Skew</h4>
 867 <p>If you get an error message like this:</p>
 868 <pre><code>File 'xxx' has modification time in the future.
 869 Clock skew detected. Your build may be incomplete.</code></pre>
 870 <p>then the clock on your build machine is out of sync with the timestamps on the source files. Other errors, apparently unrelated but in fact caused by the clock skew, can occur along with the clock skew warnings. These secondary errors may tend to obscure the fact that the true root cause of the problem is an out-of-sync clock.</p>
 871 <p>If you see these warnings, reset the clock on the build machine, run <code>make clean</code> and restart the build.</p>
 872 <h4 id="out-of-memory-errors">Out of Memory Errors</h4>
 873 <p>On Solaris, you might get an error message like this:</p>
 874 <pre><code>Trouble writing out table to disk</code></pre>
 875 <p>To solve this, increase the amount of swap space on your build machine.</p>
 876 <p>On Windows, you might get error messages like this:</p>
 877 <pre><code>fatal error - couldn't allocate heap
 878 cannot create ... Permission denied
 879 spawn failed</code></pre>
 880 <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>
 881 <h3 id="getting-help">Getting Help</h3>
 882 <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>





 883 <p>If you need general help or advice about developing for the JDK, you can also contact the Adoption Group. See the section on <a href="#contributing-to-openjdk">Contributing to OpenJDK</a> for more information.</p>
 884 <h2 id="hints-and-suggestions-for-advanced-users">Hints and Suggestions for Advanced Users</h2>
 885 <h3 id="setting-up-a-repository-for-pushing-changes-defpath">Setting Up a Repository for Pushing Changes (defpath)</h3>
 886 <p>To help you prepare a proper push path for a Mercurial repository, there exists a useful tool known as <a href="http://openjdk.java.net/projects/code-tools/defpath">defpath</a>. It will help you setup a proper push path for pushing changes to the JDK.</p>
 887 <p>Install the extension by cloning <code>http://hg.openjdk.java.net/code-tools/defpath</code> and updating your <code>.hgrc</code> file. Here's one way to do this:</p>
 888 <pre><code>cd ~
 889 mkdir hg-ext
 890 cd hg-ext
 891 hg clone http://hg.openjdk.java.net/code-tools/defpath
 892 cat &lt;&lt; EOT &gt;&gt; ~/.hgrc
 893 [extensions]
 894 defpath=~/hg-ext/defpath/defpath.py
 895 EOT</code></pre>
 896 <p>You can now setup a proper push path using:</p>
 897 <pre><code>hg defpath -d -u &lt;your OpenJDK username&gt;</code></pre>
 898 <h3 id="bash-completion">Bash Completion</h3>
 899 <p>The <code>configure</code> and <code>make</code> commands tries to play nice with bash command-line completion (using <code>&lt;tab&gt;</code> or <code>&lt;tab&gt;&lt;tab&gt;</code>). To use this functionality, make sure you enable completion in your <code>~/.bashrc</code> (see instructions for bash in your operating system).</p>
 900 <p>Make completion will work out of the box, and will complete valid make targets. For instance, typing <code>make jdk-i&lt;tab&gt;</code> will complete to <code>make jdk-image</code>.</p>
 901 <p>The <code>configure</code> script can get completion for options, but for this to work you need to help <code>bash</code> on the way. The standard way of running the script, <code>bash configure</code>, will not be understood by bash completion. You need <code>configure</code> to be the command to run. One way to achieve this is to add a simple helper script to your path:</p>
 902 <pre><code>cat &lt;&lt; EOT &gt; /tmp/configure


   1 <!DOCTYPE html>
   2 <html>
   3 <head>
   4   <meta charset="utf-8">
   5   <meta name="generator" content="pandoc">
   6   <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
   7   <title>Building the JDK</title>
   8   <style type="text/css">code{white-space: pre;}</style>
   9   <link rel="stylesheet" href="../make/data/docs-resources/resources/jdk-default.css">





  10   <!--[if lt IE 9]>
  11     <script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>
  12   <![endif]-->
  13   <style type="text/css">pre, code, tt { color: #1d6ae5; }</style>
  14 </head>
  15 <body>
  16 <header>
  17 <h1 class="title">Building the JDK</h1>
  18 </header>
  19 <nav id="TOC">
  20 <ul>
  21 <li><a href="#tldr-instructions-for-the-impatient">TL;DR (Instructions for the Impatient)</a></li>
  22 <li><a href="#introduction">Introduction</a></li>
  23 <li><a href="#getting-the-source-code">Getting the Source Code</a><ul>
  24 <li><a href="#special-considerations">Special Considerations</a></li>
  25 </ul></li>
  26 <li><a href="#build-hardware-requirements">Build Hardware Requirements</a><ul>
  27 <li><a href="#building-on-x86">Building on x86</a></li>
  28 <li><a href="#building-on-sparc">Building on sparc</a></li>
  29 <li><a href="#building-on-aarch64">Building on aarch64</a></li>
  30 <li><a href="#building-on-32-bit-arm">Building on 32-bit arm</a></li>
  31 </ul></li>
  32 <li><a href="#operating-system-requirements">Operating System Requirements</a><ul>
  33 <li><a href="#windows">Windows</a></li>
  34 <li><a href="#solaris">Solaris</a></li>
  35 <li><a href="#macos">macOS</a></li>
  36 <li><a href="#linux">Linux</a></li>


 123 <li><p><a href="#running-make">Run make</a>:<br />
 124 <code>make images</code></p></li>
 125 <li><p>Verify your newly built JDK:<br />
 126 <code>./build/*/images/jdk/bin/java -version</code></p></li>
 127 <li><p><a href="##running-tests">Run basic tests</a>:<br />
 128 <code>make run-test-tier1</code></p></li>
 129 </ol>
 130 <p>If any of these steps failed, or if you want to know more about build requirements or build functionality, please continue reading this document.</p>
 131 <h2 id="introduction">Introduction</h2>
 132 <p>The JDK is a complex software project. Building it requires a certain amount of technical expertise, a fair number of dependencies on external software, and reasonably powerful hardware.</p>
 133 <p>If you just want to use the JDK and not build it yourself, this document is not for you. See for instance <a href="http://openjdk.java.net/install">OpenJDK installation</a> for some methods of installing a prebuilt JDK.</p>
 134 <h2 id="getting-the-source-code">Getting the Source Code</h2>
 135 <p>Make sure you are getting the correct version. As of JDK 10, the source is no longer split into separate repositories so you only need to clone one single repository. At the <a href="http://hg.openjdk.java.net/">OpenJDK Mercurial server</a> you can see a list of all available repositories. If you want to build an older version, e.g. JDK 8, it is recommended that you get the <code>jdk8u</code> forest, which contains incremental updates, instead of the <code>jdk8</code> forest, which was frozen at JDK 8 GA.</p>
 136 <p>If you are new to Mercurial, a good place to start is the <a href="http://www.mercurial-scm.org/guide">Mercurial Beginner's Guide</a>. The rest of this document assumes a working knowledge of Mercurial.</p>
 137 <h3 id="special-considerations">Special Considerations</h3>
 138 <p>For a smooth building experience, it is recommended that you follow these rules on where and how to check out the source code.</p>
 139 <ul>
 140 <li><p>Do not check out the source code in a path which contains spaces. Chances are the build will not work. This is most likely to be an issue on Windows systems.</p></li>
 141 <li><p>Do not check out the source code in a path which has a very long name or is nested many levels deep. Chances are you will hit an OS limitation during the build.</p></li>
 142 <li><p>Put the source code on a local disk, not a network share. If possible, use an SSD. The build process is very disk intensive, and having slow disk access will significantly increase build times. If you need to use a network share for the source code, see below for suggestions on how to keep the build artifacts on a local disk.</p></li>
 143 <li><p>On Windows, extra care must be taken to make sure the <a href="#cygwin">Cygwin</a> environment is consistent. It is recommended that you follow this procedure:</p>
 144 <ul>
 145 <li><p>Create the directory that is going to contain the top directory of the JDK clone by using the <code>mkdir</code> command in the Cygwin bash shell. That is, do <em>not</em> create it using Windows Explorer. This will ensure that it will have proper Cygwin attributes, and that it's children will inherit those attributes.</p></li>
 146 <li><p>Do not put the JDK clone in a path under your Cygwin home directory. This is especially important if your user name contains spaces and/or mixed upper and lower case letters.</p></li>
 147 <li><p>Clone the JDK repository using the Cygwin command line <code>hg</code> client as instructed in this document. That is, do <em>not</em> use another Mercurial client such as TortoiseHg.</p></li>
 148 </ul>
 149 <p>Failure to follow this procedure might result in hard-to-debug build problems.</p></li>
 150 </ul>
 151 <h2 id="build-hardware-requirements">Build Hardware Requirements</h2>
 152 <p>The JDK is a massive project, and require machines ranging from decent to powerful to be able to build in a reasonable amount of time, or to be able to complete a build at all.</p>
 153 <p>We <em>strongly</em> recommend usage of an SSD disk for the build, since disk speed is one of the limiting factors for build performance.</p>
 154 <h3 id="building-on-x86">Building on x86</h3>
 155 <p>At a minimum, a machine with 2-4 cores is advisable, as well as 2-4 GB of RAM. (The more cores to use, the more memory you need.) At least 6 GB of free disk space is required (8 GB minimum for building on Solaris).</p>
 156 <p>Even for 32-bit builds, it is recommended to use a 64-bit build machine, and instead create a 32-bit target using <code>--with-target-bits=32</code>.</p>
 157 <h3 id="building-on-sparc">Building on sparc</h3>
 158 <p>At a minimum, a machine with 4 cores is advisable, as well as 4 GB of RAM. (The more cores to use, the more memory you need.) At least 8 GB of free disk space is required.</p>
 159 <h3 id="building-on-aarch64">Building on aarch64</h3>
 160 <p>At a minimum, a machine with 8 cores is advisable, as well as 8 GB of RAM. (The more cores to use, the more memory you need.) At least 6 GB of free disk space is required.</p>
 161 <p>If you do not have access to sufficiently powerful hardware, it is also possible to use <a href="#cross-compiling">cross-compiling</a>.</p>
 162 <h3 id="building-on-32-bit-arm">Building on 32-bit arm</h3>
 163 <p>This is not recommended. Instead, see the section on <a href="#cross-compiling">Cross-compiling</a>.</p>
 164 <h2 id="operating-system-requirements">Operating System Requirements</h2>
 165 <p>The mainline JDK project supports Linux, Solaris, macOS, AIX and Windows. Support for other operating system, e.g. BSD, exists in separate &quot;port&quot; projects.</p>
 166 <p>In general, the JDK can be built on a wide range of versions of these operating systems, but the further you deviate from what is tested on a daily basis, the more likely you are to run into problems.</p>
 167 <p>This table lists the OS versions used by Oracle when building the JDK. Such information is always subject to change, but this table is up to date at the time of writing.</p>
 168 <table>
 169 <thead>
 170 <tr class="header">
 171 <th style="text-align: left;">Operating system</th>
 172 <th style="text-align: left;">Vendor/version used</th>
 173 </tr>
 174 </thead>
 175 <tbody>
 176 <tr class="odd">
 177 <td style="text-align: left;">Linux</td>
 178 <td style="text-align: left;">Oracle Enterprise Linux 6.4 / 7.1 (using kernel 3.8.13)</td>
 179 </tr>
 180 <tr class="even">
 181 <td style="text-align: left;">Solaris</td>
 182 <td style="text-align: left;">Solaris 11.1 SRU 21.4.1 / 11.2 SRU 5.5</td>
 183 </tr>
 184 <tr class="odd">
 185 <td style="text-align: left;">macOS</td>
 186 <td style="text-align: left;">Mac OS X 10.9 (Mavericks) / 10.10 (Yosemite)</td>
 187 </tr>
 188 <tr class="even">
 189 <td style="text-align: left;">Windows</td>
 190 <td style="text-align: left;">Windows Server 2012 R2</td>
 191 </tr>
 192 </tbody>
 193 </table>
 194 <p>The double version numbers for Linux, Solaris and macOS is due to the hybrid model used at Oracle, where header files and external libraries from an older version are used when building on a more modern version of the OS.</p>
 195 <p>The Build Group has a wiki page with <a href="https://wiki.openjdk.java.net/display/Build/Supported+Build+Platforms">Supported Build Platforms</a>. From time to time, this is updated by contributors to list successes or failures of building on different platforms.</p>
 196 <h3 id="windows">Windows</h3>
 197 <p>Windows XP is not a supported platform, but all newer Windows should be able to build the JDK.</p>
 198 <p>On Windows, it is important that you pay attention to the instructions in the <a href="#special-considerations">Special Considerations</a>.</p>
 199 <p>Windows is the only non-POSIX OS supported by the JDK, and as such, requires some extra care. A POSIX support layer is required to build on Windows. Currently, 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 effort to implement.)</p>
 200 <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>
 201 <h4 id="cygwin">Cygwin</h4>
 202 <p>A functioning <a href="http://www.cygwin.com/">Cygwin</a> environment is thus required for building the JDK on Windows. If you have a 64-bit OS, we strongly recommend using the 64-bit version of Cygwin.</p>
 203 <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 JDK build process, and that can cause unexpected build problems.</p>
 204 <p>The JDK requires GNU Make 4.0 or greater on Windows. This is usually not a problem, since Cygwin currently only distributes GNU Make at a version above 4.0.</p>
 205 <p>Apart from the basic Cygwin installation, the following packages must also be installed:</p>
 206 <ul>
 207 <li><code>autoconf</code></li>
 208 <li><code>make</code></li>
 209 <li><code>zip</code></li>
 210 <li><code>unzip</code></li>
 211 </ul>
 212 <p>Often, you can install these packages using the following command line:</p>
 213 <pre><code>&lt;path to Cygwin setup&gt;/setup-x86_64 -q -P autoconf -P make -P unzip -P zip</code></pre>
 214 <p>Unfortunately, Cygwin can be unreliable in certain circumstances. If you experience build tool crashes or strange issues when building on Windows, please check the Cygwin FAQ on the <a href="https://cygwin.com/faq/faq.html#faq.using.bloda">&quot;BLODA&quot; list</a> and the section on <a href="https://cygwin.com/faq/faq.html#faq.using.fixing-fork-failures">fork() failures</a>.</p>





 215 <h3 id="solaris">Solaris</h3>
 216 <p>See <code>make/devkit/solaris11.1-package-list.txt</code> for a list of recommended packages to install when building on Solaris. The versions specified in this list is the versions used by the daily builds at Oracle, and is likely to work properly.</p>
 217 <p>Older versions of Solaris shipped a broken version of <code>objcopy</code>. At least version 2.21.1 is needed, which is provided by Solaris 11 Update 1. Objcopy is needed if you want to have external debug symbols. Please make sure you are using at least version 2.21.1 of objcopy, or that you disable external debug symbols.</p>
 218 <h3 id="macos">macOS</h3>
 219 <p>Apple is using a quite aggressive scheme of pushing OS updates, and coupling these updates with required updates of Xcode. Unfortunately, this makes it difficult for a project such as the JDK to keep pace with a continuously updated machine running macOS. See the section on <a href="#apple-xcode">Apple Xcode</a> on some strategies to deal with this.</p>
 220 <p>It is recommended that you use at least Mac OS X 10.13 (High Sierra). At the time of writing, the JDK has been successfully compiled on macOS 10.12 (Sierra).</p>
 221 <p>The standard macOS environment contains the basic tooling needed to build, but for external libraries a package manager is recommended. The JDK uses <a href="https://brew.sh/">homebrew</a> in the examples, but feel free to use whatever manager you want (or none).</p>
 222 <h3 id="linux">Linux</h3>
 223 <p>It is often not much problem to build the JDK on Linux. The only general advice is to try to use the compilers, external libraries and header files as provided by your distribution.</p>
 224 <p>The basic tooling is provided as part of the core operating system, but you will most likely need to install developer packages.</p>
 225 <p>For apt-based distributions (Debian, Ubuntu, etc), try this:</p>
 226 <pre><code>sudo apt-get install build-essential</code></pre>
 227 <p>For rpm-based distributions (Fedora, Red Hat, etc), try this:</p>
 228 <pre><code>sudo yum groupinstall &quot;Development Tools&quot;</code></pre>
 229 <h3 id="aix">AIX</h3>
 230 <p>The regular builds by SAP is using AIX version 7.1, but AIX 5.3 is also supported. See the <a href="http://cr.openjdk.java.net/~simonis/ppc-aix-port">OpenJDK PowerPC Port Status Page</a> for details.</p>
 231 <h2 id="native-compiler-toolchain-requirements">Native Compiler (Toolchain) Requirements</h2>
 232 <p>Large portions of the JDK consists of native code, that needs to be compiled to be able to run on the target platform. In theory, toolchain and operating system should be independent factors, but in practice there's more or less a one-to-one correlation between target operating system and toolchain.</p>
 233 <table>
 234 <thead>
 235 <tr class="header">
 236 <th style="text-align: left;">Operating system</th>
 237 <th style="text-align: left;">Supported toolchain</th>
 238 </tr>
 239 </thead>
 240 <tbody>
 241 <tr class="odd">
 242 <td style="text-align: left;">Linux</td>
 243 <td style="text-align: left;">gcc, clang</td>
 244 </tr>
 245 <tr class="even">
 246 <td style="text-align: left;">macOS</td>
 247 <td style="text-align: left;">Apple Xcode (using clang)</td>
 248 </tr>
 249 <tr class="odd">
 250 <td style="text-align: left;">Solaris</td>


 254 <td style="text-align: left;">AIX</td>
 255 <td style="text-align: left;">IBM XL C/C++</td>
 256 </tr>
 257 <tr class="odd">
 258 <td style="text-align: left;">Windows</td>
 259 <td style="text-align: left;">Microsoft Visual Studio</td>
 260 </tr>
 261 </tbody>
 262 </table>
 263 <p>Please see the individual sections on the toolchains for version recommendations. As a reference, these versions of the toolchains are used, at the time of writing, by Oracle for the daily builds of the JDK. It should be possible to compile the JDK with both older and newer versions, but the closer you stay to this list, the more likely you are to compile successfully without issues.</p>
 264 <table>
 265 <thead>
 266 <tr class="header">
 267 <th style="text-align: left;">Operating system</th>
 268 <th style="text-align: left;">Toolchain version</th>
 269 </tr>
 270 </thead>
 271 <tbody>
 272 <tr class="odd">
 273 <td style="text-align: left;">Linux</td>
 274 <td style="text-align: left;">gcc 7.3.0</td>
 275 </tr>
 276 <tr class="even">
 277 <td style="text-align: left;">macOS</td>
 278 <td style="text-align: left;">Apple Xcode 9.4 (using clang 9.1.0)</td>
 279 </tr>
 280 <tr class="odd">
 281 <td style="text-align: left;">Solaris</td>
 282 <td style="text-align: left;">Oracle Solaris Studio 12.4 (with compiler version 5.13)</td>
 283 </tr>
 284 <tr class="even">
 285 <td style="text-align: left;">Windows</td>
 286 <td style="text-align: left;">Microsoft Visual Studio 2017 update 15.5.5</td>
 287 </tr>
 288 </tbody>
 289 </table>




 290 <h3 id="gcc">gcc</h3>
 291 <p>The minimum accepted version of gcc is 4.8. Older versions will generate a warning by <code>configure</code> and are unlikely to work.</p>
 292 <p>The JDK is currently known to be able to compile with at least version 7.4 of gcc.</p>
 293 <p>In general, any version between these two should be usable.</p>
 294 <h3 id="clang">clang</h3>
 295 <p>The minimum accepted version of clang is 3.2. Older versions will not be accepted by <code>configure</code>.</p>
 296 <p>To use clang instead of gcc on Linux, use <code>--with-toolchain-type=clang</code>.</p>
 297 <h3 id="apple-xcode">Apple Xcode</h3>
 298 <p>The oldest supported version of Xcode is 8.</p>
 299 <p>You will need the Xcode command lines developers tools to be able to build the JDK. (Actually, <em>only</em> the command lines tools are needed, not the IDE.) The simplest way to install these is to run:</p>
 300 <pre><code>xcode-select --install</code></pre>
 301 <p>It is advisable to keep an older version of Xcode for building the JDK when updating Xcode. This <a href="http://iosdevelopertips.com/xcode/install-multiple-versions-of-xcode.html">blog page</a> has good suggestions on managing multiple Xcode versions. To use a specific version of Xcode, use <code>xcode-select -s</code> before running <code>configure</code>, or use <code>--with-toolchain-path</code> to point to the version of Xcode to use, e.g. <code>configure --with-toolchain-path=/Applications/Xcode8.app/Contents/Developer/usr/bin</code></p>
 302 <p>If you have recently (inadvertently) updated your OS and/or Xcode version, and the JDK can no longer be built, please see the section on <a href="#problems-with-the-build-environment">Problems with the Build Environment</a>, and <a href="#getting-help">Getting Help</a> to find out if there are any recent, non-merged patches available for this update.</p>
 303 <h3 id="oracle-solaris-studio">Oracle Solaris Studio</h3>
 304 <p>The minimum accepted version of the Solaris Studio compilers is 5.13 (corresponding to Solaris Studio 12.4). Older versions will not be accepted by configure.</p>
 305 <p>The Solaris Studio installation should contain at least these packages:</p>
 306 <table>
 307 <thead>
 308 <tr class="header">
 309 <th style="text-align: left;">Package</th>


 342 <tr class="even">
 343 <td style="text-align: left;">developer/solarisstudio-124/studio-ja</td>
 344 <td style="text-align: left;">12.4-1.0.0.1</td>
 345 </tr>
 346 <tr class="odd">
 347 <td style="text-align: left;">developer/solarisstudio-124/studio-legal</td>
 348 <td style="text-align: left;">12.4-1.0.0.1</td>
 349 </tr>
 350 <tr class="even">
 351 <td style="text-align: left;">developer/solarisstudio-124/studio-zhCN</td>
 352 <td style="text-align: left;">12.4-1.0.0.1</td>
 353 </tr>
 354 </tbody>
 355 </table>
 356 <p>Compiling with Solaris Studio can sometimes be finicky. This is the exact version used by Oracle, which worked correctly at the time of writing:</p>
 357 <pre><code>$ cc -V
 358 cc: Sun C 5.13 SunOS_i386 2014/10/20
 359 $ CC -V
 360 CC: Sun C++ 5.13 SunOS_i386 151846-10 2015/10/30</code></pre>
 361 <h3 id="microsoft-visual-studio">Microsoft Visual Studio</h3>
 362 <p>The minimum accepted version of Visual Studio is 2010. Older versions will not be accepted by <code>configure</code>. The maximum accepted version of Visual Studio is 2017. Versions older than 2017 are unlikely to continue working for long.</p>
 363 <p>If you have multiple versions of Visual Studio installed, <code>configure</code> will by default pick the latest. You can request a specific version to be used by setting <code>--with-toolchain-version</code>, e.g. <code>--with-toolchain-version=2015</code>.</p>
 364 <p>If you get <code>LINK: fatal error LNK1123: failure during conversion to COFF: file invalid</code> when building using Visual Studio 2010, you have encountered <a href="http://support.microsoft.com/kb/2757355">KB2757355</a>, a bug triggered by a specific installation order. However, the solution suggested by the KB article does not always resolve the problem. See <a href="https://stackoverflow.com/questions/10888391">this stackoverflow discussion</a> for other suggestions.</p>
 365 <h3 id="ibm-xl-cc">IBM XL C/C++</h3>
 366 <p>The regular builds by SAP is using version 12.1, described as <code>IBM XL C/C++ for AIX, V12.1 (5765-J02, 5725-C72) Version: 12.01.0000.0017</code>.</p>
 367 <p>See the <a href="http://cr.openjdk.java.net/~simonis/ppc-aix-port">OpenJDK PowerPC Port Status Page</a> for details.</p>
 368 <h2 id="boot-jdk-requirements">Boot JDK Requirements</h2>
 369 <p>Paradoxically, building the JDK requires a pre-existing JDK. This is called the &quot;boot JDK&quot;. The boot JDK does not, however, have to be a JDK built directly from the source code available in the OpenJDK Community. If you are porting the JDK to a new platform, chances are that there already exists another JDK for that platform that is usable as boot JDK.</p>
 370 <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, the JDK should be able to &quot;build itself&quot;, so an up-to-date build of the current JDK 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>
 371 <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>
 372 <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>
 373 <h3 id="getting-jdk-binaries">Getting JDK binaries</h3>
 374 <p>JDK 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>
 375 <p>On Linux you can also get a JDK 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 a JDK &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>
 376 <h2 id="external-library-requirements">External Library Requirements</h2>
 377 <p>Different platforms require different external libraries. In general, libraries are not optional - that is, they are either required or not used.</p>
 378 <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>
 379 <p>As a fallback, the second version allows you to point to the include directory and the lib directory separately.</p>
 380 <h3 id="freetype">FreeType</h3>
 381 <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 the JDK’s own copy.</p>
 382 <ul>
 383 <li>To install on an apt-based Linux, try running <code>sudo apt-get install libfreetype6-dev</code>.</li>
 384 <li>To install on an rpm-based Linux, try running <code>sudo yum install freetype-devel</code>.</li>
 385 <li>To install on Solaris, try running <code>pkg install system/library/freetype-2</code>.</li>
 386 </ul>
 387 <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>
 388 <h3 id="cups">CUPS</h3>
 389 <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>
 390 <ul>
 391 <li>To install on an apt-based Linux, try running <code>sudo apt-get install libcups2-dev</code>.</li>
 392 <li>To install on an rpm-based Linux, try running <code>sudo yum install cups-devel</code>.</li>
 393 <li>To install on Solaris, try running <code>pkg install print/cups</code>.</li>
 394 </ul>
 395 <p>Use <code>--with-cups=&lt;path&gt;</code> if <code>configure</code> does not properly locate your CUPS files.</p>
 396 <h3 id="x11">X11</h3>
 397 <p>Certain <a href="http://www.x.org/">X11</a> libraries and include files are required on Linux and Solaris.</p>
 398 <ul>
 399 <li>To install on an apt-based Linux, try running <code>sudo apt-get install libx11-dev libxext-dev libxrender-dev libxtst-dev libxt-dev</code>.</li>
 400 <li>To install on an rpm-based Linux, try running <code>sudo yum install libXtst-devel libXt-devel libXrender-devel libXi-devel</code>.</li>
 401 <li>To install on Solaris, try running <code>pkg install x11/header/x11-protocols x11/library/libice x11/library/libpthread-stubs x11/library/libsm x11/library/libx11 x11/library/libxau x11/library/libxcb x11/library/libxdmcp x11/library/libxevie x11/library/libxext x11/library/libxrender x11/library/libxscrnsaver x11/library/libxtst x11/library/toolkit/libxt</code>.</li>
 402 </ul>
 403 <p>Use <code>--with-x=&lt;path&gt;</code> if <code>configure</code> does not properly locate your X11 files.</p>
 404 <h3 id="alsa">ALSA</h3>
 405 <p>ALSA, <a href="https://www.alsa-project.org/">Advanced Linux Sound Architecture</a> is required on Linux. At least version 0.9.1 of ALSA is required.</p>
 406 <ul>
 407 <li>To install on an apt-based Linux, try running <code>sudo apt-get install libasound2-dev</code>.</li>
 408 <li>To install on an rpm-based Linux, try running <code>sudo yum install alsa-lib-devel</code>.</li>
 409 </ul>
 410 <p>Use <code>--with-alsa=&lt;path&gt;</code> if <code>configure</code> does not properly locate your ALSA files.</p>
 411 <h3 id="libffi">libffi</h3>
 412 <p>libffi, the <a href="http://sourceware.org/libffi">Portable Foreign Function Interface Library</a> is required when building the Zero version of Hotspot.</p>
 413 <ul>
 414 <li>To install on an apt-based Linux, try running <code>sudo apt-get install libffi-dev</code>.</li>
 415 <li>To install on an rpm-based Linux, try running <code>sudo yum install libffi-devel</code>.</li>
 416 </ul>
 417 <p>Use <code>--with-libffi=&lt;path&gt;</code> if <code>configure</code> does not properly locate your libffi files.</p>
 418 <h2 id="build-tools-requirements">Build Tools Requirements</h2>
 419 <h3 id="autoconf">Autoconf</h3>
 420 <p>The JDK requires <a href="http://www.gnu.org/software/autoconf">Autoconf</a> on all platforms. At least version 2.69 is required.</p>
 421 <ul>


 447 <pre><code>bash configure --with-freetype=/cygdrive/c/freetype-i586 --with-target-bits=32</code></pre></li>
 448 <li><p>Create a debug build with the <code>server</code> JVM and DTrace enabled:</p>
 449 <pre><code>bash configure --enable-debug --with-jvm-variants=server --enable-dtrace</code></pre></li>
 450 </ul>
 451 <h3 id="common-configure-arguments">Common Configure Arguments</h3>
 452 <p>Here follows some of the most common and important <code>configure</code> argument.</p>
 453 <p>To get up-to-date information on <em>all</em> available <code>configure</code> argument, please run:</p>
 454 <pre><code>bash configure --help</code></pre>
 455 <p>(Note that this help text also include general autoconf options, like <code>--dvidir</code>, that is not relevant to the JDK. To list only JDK-specific features, use <code>bash configure --help=short</code> instead.)</p>
 456 <h4 id="configure-arguments-for-tailoring-the-build">Configure Arguments for Tailoring the Build</h4>
 457 <ul>
 458 <li><code>--enable-debug</code> - Set the debug level to <code>fastdebug</code> (this is a shorthand for <code>--with-debug-level=fastdebug</code>)</li>
 459 <li><code>--with-debug-level=&lt;level&gt;</code> - Set the debug level, which can be <code>release</code>, <code>fastdebug</code>, <code>slowdebug</code> or <code>optimized</code>. Default is <code>release</code>. <code>optimized</code> is variant of <code>release</code> with additional Hotspot debug code.</li>
 460 <li><code>--with-native-debug-symbols=&lt;method&gt;</code> - Specify if and how native debug symbols should be built. Available methods are <code>none</code>, <code>internal</code>, <code>external</code>, <code>zipped</code>. Default behavior depends on platform. See <a href="#native-debug-symbols">Native Debug Symbols</a> for more details.</li>
 461 <li><code>--with-version-string=&lt;string&gt;</code> - Specify the version string this build will be identified with.</li>
 462 <li><code>--with-version-&lt;part&gt;=&lt;value&gt;</code> - A group of options, where <code>&lt;part&gt;</code> can be any of <code>pre</code>, <code>opt</code>, <code>build</code>, <code>major</code>, <code>minor</code>, <code>security</code> or <code>patch</code>. Use these options to modify just the corresponding part of the version string from the default, or the value provided by <code>--with-version-string</code>.</li>
 463 <li><code>--with-jvm-variants=&lt;variant&gt;[,&lt;variant&gt;...]</code> - Build the specified variant (or variants) of Hotspot. Valid variants are: <code>server</code>, <code>client</code>, <code>minimal</code>, <code>core</code>, <code>zero</code>, <code>custom</code>. Note that not all variants are possible to combine in a single build.</li>
 464 <li><code>--with-jvm-features=&lt;feature&gt;[,&lt;feature&gt;...]</code> - Use the specified JVM features when building Hotspot. The list of features will be enabled on top of the default list. For the <code>custom</code> JVM variant, this default list is empty. A complete list of available JVM features can be found using <code>bash configure --help</code>.</li>
 465 <li><code>--with-target-bits=&lt;bits&gt;</code> - Create a target binary suitable for running on a <code>&lt;bits&gt;</code> platform. Use this to create 32-bit output on a 64-bit build platform, instead of doing a full cross-compile. (This is known as a <em>reduced</em> build.)</li>
 466 </ul>




 467 <h4 id="configure-arguments-for-native-compilation">Configure Arguments for Native Compilation</h4>
 468 <ul>
 469 <li><code>--with-devkit=&lt;path&gt;</code> - Use this devkit for compilers, tools and resources</li>
 470 <li><code>--with-sysroot=&lt;path&gt;</code> - Use this directory as sysroot</li>
 471 <li><code>--with-extra-path=&lt;path&gt;[;&lt;path&gt;]</code> - Prepend these directories to the default path when searching for all kinds of binaries</li>
 472 <li><code>--with-toolchain-path=&lt;path&gt;[;&lt;path&gt;]</code> - Prepend these directories when searching for toolchain binaries (compilers etc)</li>
 473 <li><code>--with-extra-cflags=&lt;flags&gt;</code> - Append these flags when compiling JDK C files</li>
 474 <li><code>--with-extra-cxxflags=&lt;flags&gt;</code> - Append these flags when compiling JDK C++ files</li>
 475 <li><code>--with-extra-ldflags=&lt;flags&gt;</code> - Append these flags when linking JDK libraries</li>
 476 </ul>
 477 <h4 id="configure-arguments-for-external-dependencies">Configure Arguments for External Dependencies</h4>
 478 <ul>
 479 <li><code>--with-boot-jdk=&lt;path&gt;</code> - Set the path to the <a href="#boot-jdk-requirements">Boot JDK</a></li>
 480 <li><code>--with-freetype=&lt;path&gt;</code> - Set the path to <a href="#freetype">FreeType</a></li>
 481 <li><code>--with-cups=&lt;path&gt;</code> - Set the path to <a href="#cups">CUPS</a></li>
 482 <li><code>--with-x=&lt;path&gt;</code> - Set the path to <a href="#x11">X11</a></li>
 483 <li><code>--with-alsa=&lt;path&gt;</code> - Set the path to <a href="#alsa">ALSA</a></li>
 484 <li><code>--with-libffi=&lt;path&gt;</code> - Set the path to <a href="#libffi">libffi</a></li>
 485 <li><code>--with-jtreg=&lt;path&gt;</code> - Set the path to JTReg. See <a href="#running-tests">Running Tests</a></li>
 486 </ul>
 487 <p>Certain third-party libraries used by the JDK (libjpeg, giflib, libpng, lcms and zlib) are included in the JDK repository. The default behavior of the JDK build is to use this version of these libraries, but they might be replaced by an external version. To do so, specify <code>system</code> as the <code>&lt;source&gt;</code> option in these arguments. (The default is <code>bundled</code>).</p>
 488 <ul>
 489 <li><code>--with-libjpeg=&lt;source&gt;</code> - Use the specified source for libjpeg</li>
 490 <li><code>--with-giflib=&lt;source&gt;</code> - Use the specified source for giflib</li>
 491 <li><code>--with-libpng=&lt;source&gt;</code> - Use the specified source for libpng</li>
 492 <li><code>--with-lcms=&lt;source&gt;</code> - Use the specified source for lcms</li>
 493 <li><code>--with-zlib=&lt;source&gt;</code> - Use the specified source for zlib</li>
 494 </ul>
 495 <p>On Linux, it is possible to select either static or dynamic linking of the C++ runtime. The default is static linking, with dynamic linking as fallback if the static library is not found.</p>
 496 <ul>
 497 <li><code>--with-stdc++lib=&lt;method&gt;</code> - Use the specified method (<code>static</code>, <code>dynamic</code> or <code>default</code>) for linking the C++ runtime.</li>
 498 </ul>
 499 <h3 id="configure-control-variables">Configure Control Variables</h3>
 500 <p>It is possible to control certain aspects of <code>configure</code> by overriding the value of <code>configure</code> variables, either on the command line or in the environment.</p>
 501 <p>Normally, this is <strong>not recommended</strong>. If used improperly, it can lead to a broken configuration. Unless you're well versed in the build system, this is hard to use properly. Therefore, <code>configure</code> will print a warning if this is detected.</p>
 502 <p>However, there are a few <code>configure</code> variables, known as <em>control variables</em> that are supposed to be overriden on the command line. These are variables that describe the location of tools needed by the build, like <code>MAKE</code> or <code>GREP</code>. If any such variable is specified, <code>configure</code> will use that value instead of trying to autodetect the tool. For instance, <code>bash configure MAKE=/opt/gnumake4.0/bin/make</code>.</p>
 503 <p>If a configure argument exists, use that instead, e.g. use <code>--with-jtreg</code> instead of setting <code>JTREGEXE</code>.</p>
 504 <p>Also note that, despite what autoconf claims, setting <code>CFLAGS</code> will not accomplish anything. Instead use <code>--with-extra-cflags</code> (and similar for <code>cxxflags</code> and <code>ldflags</code>).</p>
 505 <h2 id="running-make">Running Make</h2>
 506 <p>When you have a proper configuration, all you need to do to build the JDK is to run <code>make</code>. (But see the warning at <a href="#gnu-make">GNU Make</a> about running the correct version of make.)</p>
 507 <p>When running <code>make</code> without any arguments, the default target is used, which is the same as running <code>make default</code> or <code>make jdk</code>. This will build a minimal (or roughly minimal) set of compiled output (known as an &quot;exploded image&quot;) needed for a developer to actually execute the newly built JDK. The idea is that in an incremental development fashion, when doing a normal make, you should only spend time recompiling what's changed (making it purely incremental) and only do the work that's needed to actually run and test your code.</p>


 619 <h3 id="specifying-the-target-platform">Specifying the Target Platform</h3>
 620 <p>You <em>must</em> specify the target platform when cross-compiling. Doing so will also automatically turn the build into a cross-compiling mode. The simplest way to do this is to use the <code>--openjdk-target</code> argument, e.g. <code>--openjdk-target=arm-linux-gnueabihf</code>. or <code>--openjdk-target=aarch64-oe-linux</code>. This will automatically set the <code>--build</code>, <code>--host</code> and <code>--target</code> options for autoconf, which can otherwise be confusing. (In autoconf terminology, the &quot;target&quot; is known as &quot;host&quot;, and &quot;target&quot; is used for building a Canadian cross-compiler.)</p>
 621 <h3 id="toolchain-considerations">Toolchain Considerations</h3>
 622 <p>You will need two copies of your toolchain, one which generates output that can run on the target system (the normal, or <em>target</em>, toolchain), and one that generates output that can run on the build system (the <em>build</em> toolchain). Note that cross-compiling is only supported for gcc at the time being. The gcc standard is to prefix cross-compiling toolchains with the target denominator. If you follow this standard, <code>configure</code> is likely to pick up the toolchain correctly.</p>
 623 <p>The <em>build</em> toolchain will be autodetected just the same way the normal <em>build</em>/<em>target</em> toolchain will be autodetected when not cross-compiling. If this is not what you want, or if the autodetection fails, you can specify a devkit containing the <em>build</em> toolchain using <code>--with-build-devkit</code> to <code>configure</code>, or by giving <code>BUILD_CC</code> and <code>BUILD_CXX</code> arguments.</p>
 624 <p>It is often helpful to locate the cross-compilation tools, headers and libraries in a separate directory, outside the normal path, and point out that directory to <code>configure</code>. Do this by setting the sysroot (<code>--with-sysroot</code>) and appending the directory when searching for cross-compilations tools (<code>--with-toolchain-path</code>). As a compact form, you can also use <code>--with-devkit</code> to point to a single directory, if it is correctly setup. (See <code>basics.m4</code> for details.)</p>
 625 <p>If you are unsure what toolchain and versions to use, these have been proved working at the time of writing:</p>
 626 <ul>
 627 <li><a href="https://releases.linaro.org/archive/13.11/components/toolchain/binaries/gcc-linaro-aarch64-linux-gnu-4.8-2013.11_linux.tar.xz">aarch64</a></li>
 628 <li><a href="https://launchpad.net/linaro-toolchain-unsupported/trunk/2012.09/+download/gcc-linaro-arm-linux-gnueabihf-raspbian-2012.09-20120921_linux.tar.bz2">arm 32-bit hardware floating point</a></li>
 629 </ul>
 630 <h3 id="native-libraries">Native Libraries</h3>
 631 <p>You will need copies of external native libraries for the <em>target</em> system, present on the <em>build</em> machine while building.</p>
 632 <p>Take care not to replace the <em>build</em> system's version of these libraries by mistake, since that can render the <em>build</em> machine unusable.</p>
 633 <p>Make sure that the libraries you point to (ALSA, X11, etc) are for the <em>target</em>, not the <em>build</em>, platform.</p>
 634 <h4 id="alsa-1">ALSA</h4>
 635 <p>You will need alsa libraries suitable for your <em>target</em> system. For most cases, using Debian's pre-built libraries work fine.</p>
 636 <p>Note that alsa is needed even if you only want to build a headless JDK.</p>
 637 <ul>
 638 <li><p>Go to <a href="https://www.debian.org/distrib/packages">Debian Package Search</a> and search for the <code>libasound2</code> and <code>libasound2-dev</code> packages for your <em>target</em> system. Download them to /tmp.</p></li>
 639 <li><p>Install the libraries into the cross-compilation toolchain. For instance:</p>

 640 <pre><code>cd /tools/gcc-linaro-arm-linux-gnueabihf-raspbian-2012.09-20120921_linux/arm-linux-gnueabihf/libc
 641 dpkg-deb -x /tmp/libasound2_1.0.25-4_armhf.deb .
 642 dpkg-deb -x /tmp/libasound2-dev_1.0.25-4_armhf.deb .</code></pre></li>
 643 <li><p>If alsa is not properly detected by <code>configure</code>, you can point it out by <code>--with-alsa</code>.</p></li>

 644 </ul>
 645 <h4 id="x11-1">X11</h4>
 646 <p>You will need X11 libraries suitable for your <em>target</em> system. For most cases, using Debian's pre-built libraries work fine.</p>
 647 <p>Note that X11 is needed even if you only want to build a headless JDK.</p>
 648 <ul>
 649 <li>Go to <a href="https://www.debian.org/distrib/packages">Debian Package Search</a>, search for the following packages for your <em>target</em> system, and download them to /tmp/target-x11:
 650 <ul>
 651 <li>libxi</li>
 652 <li>libxi-dev</li>
 653 <li>x11proto-core-dev</li>
 654 <li>x11proto-input-dev</li>
 655 <li>x11proto-kb-dev</li>
 656 <li>x11proto-render-dev</li>
 657 <li>x11proto-xext-dev</li>
 658 <li>libice-dev</li>
 659 <li>libxrender</li>
 660 <li>libxrender-dev</li>

 661 <li>libsm-dev</li>
 662 <li>libxt-dev</li>
 663 <li>libx11</li>
 664 <li>libx11-dev</li>
 665 <li>libxtst</li>
 666 <li>libxtst-dev</li>
 667 <li>libxext</li>
 668 <li>libxext-dev</li>
 669 </ul></li>
 670 <li><p>Install the libraries into the cross-compilation toolchain. For instance:</p>
 671 <pre><code>cd /tools/gcc-linaro-arm-linux-gnueabihf-raspbian-2012.09-20120921_linux/arm-linux-gnueabihf/libc/usr
 672 mkdir X11R6
 673 cd X11R6
 674 for deb in /tmp/target-x11/*.deb ; do dpkg-deb -x $deb . ; done
 675 mv usr/* .
 676 cd lib
 677 cp arm-linux-gnueabihf/* .</code></pre>
 678 <p>You can ignore the following messages. These libraries are not needed to successfully complete a full JDK build.</p>
 679 <pre><code>cp: cannot stat `arm-linux-gnueabihf/libICE.so': No such file or directory
 680 cp: cannot stat `arm-linux-gnueabihf/libSM.so': No such file or directory
 681 cp: cannot stat `arm-linux-gnueabihf/libXt.so': No such file or directory</code></pre></li>
 682 <li><p>If the X11 libraries are not properly detected by <code>configure</code>, you can point them out by <code>--with-x</code>.</p></li>
 683 </ul>
 684 <h3 id="creating-and-using-sysroots-with-qemu-deboostrap">Creating And Using Sysroots With qemu-deboostrap</h3>
 685 <p>Fortunately, you can create sysroots for foreign architectures with tools provided by your OS. On Debian/Ubuntu systems, one could use <code>qemu-deboostrap</code> to create the <em>target</em> system chroot, which would have the native libraries and headers specific to that <em>target</em> system. After that, we can use the cross-compiler on the <em>build</em> system, pointing into chroot to get the build dependencies right. This allows building for foreign architectures with native compilation speed.</p>
 686 <p>For example, cross-compiling to AArch64 from x86_64 could be done like this:</p>
 687 <ul>
 688 <li><p>Install cross-compiler on the <em>build</em> system:</p>
 689 <pre><code>apt install g++-aarch64-linux-gnu gcc-aarch64-linux-gnu</code></pre></li>
 690 <li><p>Create chroot on the <em>build</em> system, configuring it for <em>target</em> system:</p>



 691 <pre><code>sudo qemu-debootstrap --arch=arm64 --verbose \
 692    --include=fakeroot,build-essential,libx11-dev,libxext-dev,libxrender-dev,libxtst-dev,libxt-dev,libcups2-dev,libfontconfig1-dev,libasound2-dev,libfreetype6-dev,libpng12-dev \
 693    --resolve-deps jessie /chroots/arm64 http://httpredir.debian.org/debian/</code></pre></li>
 694 <li><p>Configure and build with newly created chroot as sysroot/toolchain-path:</p>


 695 <pre><code>CC=aarch64-linux-gnu-gcc CXX=aarch64-linux-gnu-g++ sh ./configure --openjdk-target=aarch64-linux-gnu --with-sysroot=/chroots/arm64/ --with-toolchain-path=/chroots/arm64/
 696 make images
 697 ls build/linux-aarch64-normal-server-release/</code></pre></li>
 698 </ul>
 699 <p>The build does not create new files in that chroot, so it can be reused for multiple builds without additional cleanup.</p>
 700 <p>Architectures that are known to successfully cross-compile like this are:</p>
 701 <table>
 702 <thead>
 703 <tr class="header">
 704 <th style="text-align: left;">Target</th>
 705 <th style="text-align: left;"><code>CC</code></th>
 706 <th style="text-align: left;"><code>CXX</code></th>
 707 <th style="text-align: left;"><code>--arch=...</code></th>
 708 <th style="text-align: left;"><code>--openjdk-target=...</code></th>
 709 </tr>
 710 </thead>
 711 <tbody>
 712 <tr class="odd">
 713 <td style="text-align: left;">x86</td>
 714 <td style="text-align: left;">default</td>
 715 <td style="text-align: left;">default</td>
 716 <td style="text-align: left;">i386</td>
 717 <td style="text-align: left;">i386-linux-gnu</td>
 718 </tr>


 838 <li><p>Re-clone the Mercurial repository</p>
 839 <p>Sometimes the Mercurial repository gets in a state that causes the product to be un-buildable. In such a case, the simplest solution is often the &quot;sledgehammer approach&quot;: delete the entire repository, and re-clone it. If you have local changes, save them first to a different location using <code>hg export</code>.</p></li>
 840 </ol>
 841 <h3 id="specific-build-issues">Specific Build Issues</h3>
 842 <h4 id="clock-skew">Clock Skew</h4>
 843 <p>If you get an error message like this:</p>
 844 <pre><code>File 'xxx' has modification time in the future.
 845 Clock skew detected. Your build may be incomplete.</code></pre>
 846 <p>then the clock on your build machine is out of sync with the timestamps on the source files. Other errors, apparently unrelated but in fact caused by the clock skew, can occur along with the clock skew warnings. These secondary errors may tend to obscure the fact that the true root cause of the problem is an out-of-sync clock.</p>
 847 <p>If you see these warnings, reset the clock on the build machine, run <code>make clean</code> and restart the build.</p>
 848 <h4 id="out-of-memory-errors">Out of Memory Errors</h4>
 849 <p>On Solaris, you might get an error message like this:</p>
 850 <pre><code>Trouble writing out table to disk</code></pre>
 851 <p>To solve this, increase the amount of swap space on your build machine.</p>
 852 <p>On Windows, you might get error messages like this:</p>
 853 <pre><code>fatal error - couldn't allocate heap
 854 cannot create ... Permission denied
 855 spawn failed</code></pre>
 856 <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>
 857 <h3 id="getting-help">Getting Help</h3>
 858 <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">
 859 <!--
 860 h='openjdk.java.net';a='@';n='build-dev';e=n+a+h;
 861 document.write('<a h'+'ref'+'="ma'+'ilto'+':'+e+'" clas'+'s="em' + 'ail">'+e+'<\/'+'a'+'>');
 862 // -->
 863 </script><noscript>build-dev at openjdk dot java dot net</noscript>. Please include the relevant parts of the configure and/or build log.</p>
 864 <p>If you need general help or advice about developing for the JDK, you can also contact the Adoption Group. See the section on <a href="#contributing-to-openjdk">Contributing to OpenJDK</a> for more information.</p>
 865 <h2 id="hints-and-suggestions-for-advanced-users">Hints and Suggestions for Advanced Users</h2>
 866 <h3 id="setting-up-a-repository-for-pushing-changes-defpath">Setting Up a Repository for Pushing Changes (defpath)</h3>
 867 <p>To help you prepare a proper push path for a Mercurial repository, there exists a useful tool known as <a href="http://openjdk.java.net/projects/code-tools/defpath">defpath</a>. It will help you setup a proper push path for pushing changes to the JDK.</p>
 868 <p>Install the extension by cloning <code>http://hg.openjdk.java.net/code-tools/defpath</code> and updating your <code>.hgrc</code> file. Here's one way to do this:</p>
 869 <pre><code>cd ~
 870 mkdir hg-ext
 871 cd hg-ext
 872 hg clone http://hg.openjdk.java.net/code-tools/defpath
 873 cat &lt;&lt; EOT &gt;&gt; ~/.hgrc
 874 [extensions]
 875 defpath=~/hg-ext/defpath/defpath.py
 876 EOT</code></pre>
 877 <p>You can now setup a proper push path using:</p>
 878 <pre><code>hg defpath -d -u &lt;your OpenJDK username&gt;</code></pre>
 879 <h3 id="bash-completion">Bash Completion</h3>
 880 <p>The <code>configure</code> and <code>make</code> commands tries to play nice with bash command-line completion (using <code>&lt;tab&gt;</code> or <code>&lt;tab&gt;&lt;tab&gt;</code>). To use this functionality, make sure you enable completion in your <code>~/.bashrc</code> (see instructions for bash in your operating system).</p>
 881 <p>Make completion will work out of the box, and will complete valid make targets. For instance, typing <code>make jdk-i&lt;tab&gt;</code> will complete to <code>make jdk-image</code>.</p>
 882 <p>The <code>configure</code> script can get completion for options, but for this to work you need to help <code>bash</code> on the way. The standard way of running the script, <code>bash configure</code>, will not be understood by bash completion. You need <code>configure</code> to be the command to run. One way to achieve this is to add a simple helper script to your path:</p>
 883 <pre><code>cat &lt;&lt; EOT &gt; /tmp/configure


< prev index next >