< prev index next >

doc/building.html

Print this page
rev 59102 : imported patch build


  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>
  42 <li><a href="#aix">AIX</a></li>
  43 </ul></li>
  44 <li><a href="#native-compiler-toolchain-requirements">Native Compiler (Toolchain) Requirements</a><ul>
  45 <li><a href="#gcc">gcc</a></li>
  46 <li><a href="#clang">clang</a></li>
  47 <li><a href="#apple-xcode">Apple Xcode</a></li>
  48 <li><a href="#oracle-solaris-studio">Oracle Solaris Studio</a></li>
  49 <li><a href="#microsoft-visual-studio">Microsoft Visual Studio</a></li>
  50 <li><a href="#ibm-xl-cc">IBM XL C/C++</a></li>
  51 </ul></li>
  52 <li><a href="#boot-jdk-requirements">Boot JDK Requirements</a><ul>
  53 <li><a href="#getting-jdk-binaries">Getting JDK binaries</a></li>
  54 </ul></li>
  55 <li><a href="#external-library-requirements">External Library Requirements</a><ul>
  56 <li><a href="#freetype">FreeType</a></li>
  57 <li><a href="#cups">CUPS</a></li>
  58 <li><a href="#x11">X11</a></li>
  59 <li><a href="#alsa">ALSA</a></li>
  60 <li><a href="#libffi">libffi</a></li>
  61 </ul></li>
  62 <li><a href="#build-tools-requirements">Build Tools Requirements</a><ul>
  63 <li><a href="#autoconf">Autoconf</a></li>
  64 <li><a href="#gnu-make">GNU Make</a></li>
  65 <li><a href="#gnu-bash">GNU Bash</a></li>
  66 </ul></li>
  67 <li><a href="#running-configure">Running Configure</a><ul>
  68 <li><a href="#common-configure-arguments">Common Configure Arguments</a></li>


 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 <p>Note: The sparc port is deprecated.</p>
 165 <h3 id="building-on-aarch64">Building on aarch64</h3>
 166 <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>
 167 <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>
 168 <h3 id="building-on-32-bit-arm">Building on 32-bit arm</h3>
 169 <p>This is not recommended. Instead, see the section on <a href="#cross-compiling">Cross-compiling</a>.</p>
 170 <h2 id="operating-system-requirements">Operating System Requirements</h2>
 171 <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>
 172 <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>
 173 <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>
 174 <table>
 175 <thead>
 176 <tr class="header">
 177 <th style="text-align: left;">Operating system</th>
 178 <th style="text-align: left;">Vendor/version used</th>
 179 </tr>
 180 </thead>
 181 <tbody>
 182 <tr class="odd">
 183 <td style="text-align: left;">Linux</td>
 184 <td style="text-align: left;">Oracle Enterprise Linux 6.4 / 7.6</td>
 185 </tr>
 186 <tr class="even">
 187 <td style="text-align: left;">Solaris</td>
 188 <td style="text-align: left;">Solaris 11.3 SRU 20</td>
 189 </tr>
 190 <tr class="odd">
 191 <td style="text-align: left;">macOS</td>
 192 <td style="text-align: left;">Mac OS X 10.13 (High Sierra)</td>
 193 </tr>
 194 <tr class="even">
 195 <td style="text-align: left;">Windows</td>
 196 <td style="text-align: left;">Windows Server 2012 R2</td>
 197 </tr>
 198 </tbody>
 199 </table>
 200 <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>
 201 <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>
 202 <h3 id="windows">Windows</h3>
 203 <p>Windows XP is not a supported platform, but all newer Windows should be able to build the JDK.</p>
 204 <p>On Windows, it is important that you pay attention to the instructions in the <a href="#special-considerations">Special Considerations</a>.</p>
 205 <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>
 206 <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>
 207 <h4 id="cygwin">Cygwin</h4>
 208 <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>
 209 <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>
 210 <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>
 211 <p>Apart from the basic Cygwin installation, the following packages must also be installed:</p>
 212 <ul>
 213 <li><code>autoconf</code></li>
 214 <li><code>make</code></li>
 215 <li><code>zip</code></li>
 216 <li><code>unzip</code></li>
 217 </ul>
 218 <p>Often, you can install these packages using the following command line:</p>
 219 <pre><code>&lt;path to Cygwin setup&gt;/setup-x86_64 -q -P autoconf -P make -P unzip -P zip</code></pre>
 220 <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>
 221 <h4 id="windows-subsystem-for-linux-wsl">Windows Subsystem for Linux (WSL)</h4>
 222 <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>
 223 <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>
 224 <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>
 225 <p>Note that while it's possible to build on WSL, testing is still not fully supported.</p>
 226 <h3 id="solaris">Solaris</h3>
 227 <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>
 228 <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>
 229 <p>Note: The Solaris port is deprecated.</p>
 230 <h3 id="macos">macOS</h3>
 231 <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>
 232 <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>
 233 <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>
 234 <h3 id="linux">Linux</h3>
 235 <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>
 236 <p>The basic tooling is provided as part of the core operating system, but you will most likely need to install developer packages.</p>
 237 <p>For apt-based distributions (Debian, Ubuntu, etc), try this:</p>
 238 <pre><code>sudo apt-get install build-essential</code></pre>
 239 <p>For rpm-based distributions (Fedora, Red Hat, etc), try this:</p>
 240 <pre><code>sudo yum groupinstall &quot;Development Tools&quot;</code></pre>
 241 <h3 id="aix">AIX</h3>
 242 <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>
 243 <h2 id="native-compiler-toolchain-requirements">Native Compiler (Toolchain) Requirements</h2>
 244 <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>
 245 <table>
 246 <thead>
 247 <tr class="header">
 248 <th style="text-align: left;">Operating system</th>
 249 <th style="text-align: left;">Supported toolchain</th>
 250 </tr>
 251 </thead>
 252 <tbody>
 253 <tr class="odd">
 254 <td style="text-align: left;">Linux</td>
 255 <td style="text-align: left;">gcc, clang</td>
 256 </tr>
 257 <tr class="even">
 258 <td style="text-align: left;">macOS</td>
 259 <td style="text-align: left;">Apple Xcode (using clang)</td>
 260 </tr>
 261 <tr class="odd">
 262 <td style="text-align: left;">Solaris</td>
 263 <td style="text-align: left;">Oracle Solaris Studio</td>
 264 </tr>
 265 <tr class="even">
 266 <td style="text-align: left;">AIX</td>
 267 <td style="text-align: left;">IBM XL C/C++</td>
 268 </tr>
 269 <tr class="odd">
 270 <td style="text-align: left;">Windows</td>
 271 <td style="text-align: left;">Microsoft Visual Studio</td>
 272 </tr>
 273 </tbody>
 274 </table>
 275 <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>
 276 <table>
 277 <thead>
 278 <tr class="header">
 279 <th style="text-align: left;">Operating system</th>
 280 <th style="text-align: left;">Toolchain version</th>
 281 </tr>
 282 </thead>
 283 <tbody>
 284 <tr class="odd">
 285 <td style="text-align: left;">Linux</td>
 286 <td style="text-align: left;">gcc 9.2.0</td>
 287 </tr>
 288 <tr class="even">
 289 <td style="text-align: left;">macOS</td>
 290 <td style="text-align: left;">Apple Xcode 10.1 (using clang 10.0.0)</td>
 291 </tr>
 292 <tr class="odd">
 293 <td style="text-align: left;">Solaris</td>
 294 <td style="text-align: left;">Oracle Solaris Studio 12.6 (with compiler version 5.15)</td>
 295 </tr>
 296 <tr class="even">
 297 <td style="text-align: left;">Windows</td>
 298 <td style="text-align: left;">Microsoft Visual Studio 2017 update 15.9.16</td>
 299 </tr>
 300 </tbody>
 301 </table>
 302 <p>All compilers are expected to be able to compile to the C99 language standard, as some C99 features are used in the source code. Microsoft Visual Studio doesn't fully support C99 so in practice shared code is limited to using C99 features that it does support.</p>
 303 <h3 id="gcc">gcc</h3>
 304 <p>The minimum accepted version of gcc is 5.0. Older versions will generate a warning by <code>configure</code> and are unlikely to work.</p>
 305 <p>The JDK is currently known to be able to compile with at least version 9.2 of gcc.</p>
 306 <p>In general, any version between these two should be usable.</p>
 307 <h3 id="clang">clang</h3>
 308 <p>The minimum accepted version of clang is 3.2. Older versions will not be accepted by <code>configure</code>.</p>
 309 <p>To use clang instead of gcc on Linux, use <code>--with-toolchain-type=clang</code>.</p>
 310 <h3 id="apple-xcode">Apple Xcode</h3>
 311 <p>The oldest supported version of Xcode is 8.</p>
 312 <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>
 313 <pre><code>xcode-select --install</code></pre>
 314 <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>
 315 <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>
 316 <h3 id="oracle-solaris-studio">Oracle Solaris Studio</h3>
 317 <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>
 318 <p>The Solaris Studio installation should contain at least these packages:</p>
 319 <table>
 320 <thead>
 321 <tr class="header">
 322 <th style="text-align: left;">Package</th>
 323 <th style="text-align: left;">Version</th>
 324 </tr>
 325 </thead>
 326 <tbody>
 327 <tr class="odd">
 328 <td style="text-align: left;">developer/solarisstudio-124/backend</td>
 329 <td style="text-align: left;">12.4-1.0.6.0</td>
 330 </tr>
 331 <tr class="even">
 332 <td style="text-align: left;">developer/solarisstudio-124/c++</td>
 333 <td style="text-align: left;">12.4-1.0.10.0</td>
 334 </tr>
 335 <tr class="odd">
 336 <td style="text-align: left;">developer/solarisstudio-124/cc</td>
 337 <td style="text-align: left;">12.4-1.0.4.0</td>
 338 </tr>
 339 <tr class="even">
 340 <td style="text-align: left;">developer/solarisstudio-124/library/c++-libs</td>
 341 <td style="text-align: left;">12.4-1.0.10.0</td>
 342 </tr>
 343 <tr class="odd">
 344 <td style="text-align: left;">developer/solarisstudio-124/library/math-libs</td>
 345 <td style="text-align: left;">12.4-1.0.0.1</td>
 346 </tr>
 347 <tr class="even">
 348 <td style="text-align: left;">developer/solarisstudio-124/library/studio-gccrt</td>
 349 <td style="text-align: left;">12.4-1.0.0.1</td>
 350 </tr>
 351 <tr class="odd">
 352 <td style="text-align: left;">developer/solarisstudio-124/studio-common</td>
 353 <td style="text-align: left;">12.4-1.0.0.1</td>
 354 </tr>
 355 <tr class="even">
 356 <td style="text-align: left;">developer/solarisstudio-124/studio-ja</td>
 357 <td style="text-align: left;">12.4-1.0.0.1</td>
 358 </tr>
 359 <tr class="odd">
 360 <td style="text-align: left;">developer/solarisstudio-124/studio-legal</td>
 361 <td style="text-align: left;">12.4-1.0.0.1</td>
 362 </tr>
 363 <tr class="even">
 364 <td style="text-align: left;">developer/solarisstudio-124/studio-zhCN</td>
 365 <td style="text-align: left;">12.4-1.0.0.1</td>
 366 </tr>
 367 </tbody>
 368 </table>
 369 <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>
 370 <pre><code>$ cc -V
 371 cc: Sun C 5.13 SunOS_i386 2014/10/20
 372 $ CC -V
 373 CC: Sun C++ 5.13 SunOS_i386 151846-10 2015/10/30</code></pre>
 374 <h3 id="microsoft-visual-studio">Microsoft Visual Studio</h3>
 375 <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>
 376 <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>
 377 <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>
 378 <h3 id="ibm-xl-cc">IBM XL C/C++</h3>
 379 <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>
 380 <h2 id="boot-jdk-requirements">Boot JDK Requirements</h2>
 381 <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>
 382 <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>
 383 <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>
 384 <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>
 385 <h3 id="getting-jdk-binaries">Getting JDK binaries</h3>
 386 <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>
 387 <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>
 388 <h2 id="external-library-requirements">External Library Requirements</h2>
 389 <p>Different platforms require different external libraries. In general, libraries are not optional - that is, they are either required or not used.</p>
 390 <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 and library files to reside in a default hierarchy under this directory. In most cases, it works fine.</p>
 391 <p>As a fallback, the second version allows you to point to the include directory and the lib directory separately.</p>
 392 <h3 id="freetype">FreeType</h3>
 393 <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>
 394 <ul>
 395 <li>To install on an apt-based Linux, try running <code>sudo apt-get install libfreetype6-dev</code>.</li>
 396 <li>To install on an rpm-based Linux, try running <code>sudo yum install freetype-devel</code>.</li>
 397 <li>To install on Solaris, try running <code>pkg install system/library/freetype-2</code>.</li>
 398 </ul>
 399 <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>
 400 <h3 id="cups">CUPS</h3>
 401 <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>
 402 <ul>
 403 <li>To install on an apt-based Linux, try running <code>sudo apt-get install libcups2-dev</code>.</li>
 404 <li>To install on an rpm-based Linux, try running <code>sudo yum install cups-devel</code>.</li>
 405 <li>To install on Solaris, try running <code>pkg install print/cups</code>.</li>
 406 </ul>
 407 <p>Use <code>--with-cups=&lt;path&gt;</code> if <code>configure</code> does not properly locate your CUPS files.</p>
 408 <h3 id="x11">X11</h3>
 409 <p>Certain <a href="http://www.x.org/">X11</a> libraries and include files are required on Linux and Solaris.</p>
 410 <ul>
 411 <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>
 412 <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>
 413 <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>
 414 </ul>
 415 <p>Use <code>--with-x=&lt;path&gt;</code> if <code>configure</code> does not properly locate your X11 files.</p>
 416 <h3 id="alsa">ALSA</h3>
 417 <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>
 418 <ul>
 419 <li>To install on an apt-based Linux, try running <code>sudo apt-get install libasound2-dev</code>.</li>
 420 <li>To install on an rpm-based Linux, try running <code>sudo yum install alsa-lib-devel</code>.</li>
 421 </ul>
 422 <p>Use <code>--with-alsa=&lt;path&gt;</code> if <code>configure</code> does not properly locate your ALSA files.</p>
 423 <h3 id="libffi">libffi</h3>
 424 <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>
 425 <ul>
 426 <li>To install on an apt-based Linux, try running <code>sudo apt-get install libffi-dev</code>.</li>
 427 <li>To install on an rpm-based Linux, try running <code>sudo yum install libffi-devel</code>.</li>
 428 </ul>
 429 <p>Use <code>--with-libffi=&lt;path&gt;</code> if <code>configure</code> does not properly locate your libffi files.</p>
 430 <h2 id="build-tools-requirements">Build Tools Requirements</h2>
 431 <h3 id="autoconf">Autoconf</h3>
 432 <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>
 433 <ul>
 434 <li>To install on an apt-based Linux, try running <code>sudo apt-get install autoconf</code>.</li>
 435 <li>To install on an rpm-based Linux, try running <code>sudo yum install autoconf</code>.</li>
 436 <li>To install on macOS, try running <code>brew install autoconf</code>.</li>
 437 <li>To install on Windows, try running <code>&lt;path to Cygwin setup&gt;/setup-x86_64 -q -P autoconf</code>.</li>
 438 </ul>
 439 <p>If <code>configure</code> has problems locating your installation of autoconf, you can specify it using the <code>AUTOCONF</code> environment variable, like this:</p>
 440 <pre><code>AUTOCONF=&lt;path to autoconf&gt; configure ...</code></pre>
 441 <h3 id="gnu-make">GNU Make</h3>
 442 <p>The JDK requires <a href="http://www.gnu.org/software/make">GNU Make</a>. No other flavors of make are supported.</p>
 443 <p>At least version 3.81 of GNU Make must be used. For distributions supporting GNU Make 4.0 or above, we strongly recommend it. GNU Make 4.0 contains useful functionality to handle parallel building (supported by <code>--with-output-sync</code>) and speed and stability improvements.</p>
 444 <p>Note that <code>configure</code> locates and verifies a properly functioning version of <code>make</code> and stores the path to this <code>make</code> binary in the configuration. If you start a build using <code>make</code> on the command line, you will be using the version of make found first in your <code>PATH</code>, and not necessarily the one stored in the configuration. This initial make will be used as &quot;bootstrap make&quot;, and in a second stage, the make located by <code>configure</code> will be called. Normally, this will present no issues, but if you have a very old <code>make</code>, or a non-GNU Make <code>make</code> in your path, this might cause issues.</p>
 445 <p>If you want to override the default make found by <code>configure</code>, use the <code>MAKE</code> configure variable, e.g. <code>configure MAKE=/opt/gnu/make</code>.</p>
 446 <p>On Solaris, it is common to call the GNU version of make by using <code>gmake</code>.</p>
 447 <h3 id="gnu-bash">GNU Bash</h3>
 448 <p>The JDK requires <a href="http://www.gnu.org/software/bash">GNU Bash</a>. No other shells are supported.</p>
 449 <p>At least version 3.2 of GNU Bash must be used.</p>
 450 <h2 id="running-configure">Running Configure</h2>
 451 <p>To build the JDK, you need a &quot;configuration&quot;, which consists of a directory where to store the build output, coupled with information about the platform, the specific build machine, and choices that affect how the JDK is built.</p>
 452 <p>The configuration is created by the <code>configure</code> script. The basic invocation of the <code>configure</code> script looks like this:</p>
 453 <pre><code>bash configure [options]</code></pre>
 454 <p>This will create an output directory containing the configuration and setup an area for the build result. This directory typically looks like <code>build/linux-x64-server-release</code>, but the actual name depends on your specific configuration. (It can also be set directly, see <a href="#using-multiple-configurations">Using Multiple Configurations</a>). This directory is referred to as <code>$BUILD</code> in this documentation.</p>
 455 <p><code>configure</code> will try to figure out what system you are running on and where all necessary build components are. If you have all prerequisites for building installed, it should find everything. If it fails to detect any component automatically, it will exit and inform you about the problem.</p>
 456 <p>Some command line examples:</p>
 457 <ul>
 458 <li><p>Create a 32-bit build for Windows with FreeType2 in <code>C:\freetype-i586</code>:</p>
 459 <pre><code>bash configure --with-freetype=/cygdrive/c/freetype-i586 --with-target-bits=32</code></pre></li>
 460 <li><p>Create a debug build with the <code>server</code> JVM and DTrace enabled:</p>
 461 <pre><code>bash configure --enable-debug --with-jvm-variants=server --enable-dtrace</code></pre></li>
 462 </ul>
 463 <h3 id="common-configure-arguments">Common Configure Arguments</h3>
 464 <p>Here follows some of the most common and important <code>configure</code> argument.</p>
 465 <p>To get up-to-date information on <em>all</em> available <code>configure</code> argument, please run:</p>
 466 <pre><code>bash configure --help</code></pre>


 848 <p>Run <code>hg pull -u</code> to make sure you have the latest changes.</p></li>
 849 <li><p>Clean build results</p>
 850 <p>The simplest way to fix incremental rebuild issues is to run <code>make clean</code>. This will remove all build results, but not the configuration or any build system support artifacts. In most cases, this will solve build errors resulting from incremental build mismatches.</p></li>
 851 <li><p>Completely clean the build directory.</p>
 852 <p>If this does not work, the next step is to run <code>make dist-clean</code>, or removing the build output directory (<code>$BUILD</code>). This will clean all generated output, including your configuration. You will need to re-run <code>configure</code> after this step. A good idea is to run <code>make print-configuration</code> before running <code>make dist-clean</code>, as this will print your current <code>configure</code> command line. Here's a way to do this:</p>
 853 <pre><code>make print-configuration &gt; current-configuration
 854 make dist-clean
 855 bash configure $(cat current-configuration)
 856 make</code></pre></li>
 857 <li><p>Re-clone the Mercurial repository</p>
 858 <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>
 859 </ol>
 860 <h3 id="specific-build-issues">Specific Build Issues</h3>
 861 <h4 id="clock-skew">Clock Skew</h4>
 862 <p>If you get an error message like this:</p>
 863 <pre><code>File 'xxx' has modification time in the future.
 864 Clock skew detected. Your build may be incomplete.</code></pre>
 865 <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>
 866 <p>If you see these warnings, reset the clock on the build machine, run <code>make clean</code> and restart the build.</p>
 867 <h4 id="out-of-memory-errors">Out of Memory Errors</h4>
 868 <p>On Solaris, you might get an error message like this:</p>
 869 <pre><code>Trouble writing out table to disk</code></pre>
 870 <p>To solve this, increase the amount of swap space on your build machine.</p>
 871 <p>On Windows, you might get error messages like this:</p>
 872 <pre><code>fatal error - couldn't allocate heap
 873 cannot create ... Permission denied
 874 spawn failed</code></pre>
 875 <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>
 876 <h3 id="getting-help">Getting Help</h3>
 877 <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>
 878 <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>
 879 <h2 id="hints-and-suggestions-for-advanced-users">Hints and Suggestions for Advanced Users</h2>
 880 <h3 id="setting-up-a-repository-for-pushing-changes-defpath">Setting Up a Repository for Pushing Changes (defpath)</h3>
 881 <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>
 882 <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>
 883 <pre><code>cd ~
 884 mkdir hg-ext
 885 cd hg-ext
 886 hg clone http://hg.openjdk.java.net/code-tools/defpath
 887 cat &lt;&lt; EOT &gt;&gt; ~/.hgrc
 888 [extensions]
 889 defpath=~/hg-ext/defpath/defpath.py
 890 EOT</code></pre>


 902 fi
 903 
 904 bash \$PWD/configure &quot;\$@&quot;
 905 EOT
 906 chmod +x /tmp/configure
 907 sudo mv /tmp/configure /usr/local/bin</code></pre>
 908 <p>Now <code>configure --en&lt;tab&gt;-dt&lt;tab&gt;</code> will result in <code>configure --enable-dtrace</code>.</p>
 909 <h3 id="using-multiple-configurations">Using Multiple Configurations</h3>
 910 <p>You can have multiple configurations for a single source repository. When you create a new configuration, run <code>configure --with-conf-name=&lt;name&gt;</code> to create a configuration with the name <code>&lt;name&gt;</code>. Alternatively, you can create a directory under <code>build</code> and run <code>configure</code> from there, e.g. <code>mkdir build/&lt;name&gt; &amp;&amp; cd build/&lt;name&gt; &amp;&amp; bash ../../configure</code>.</p>
 911 <p>Then you can build that configuration using <code>make CONF_NAME=&lt;name&gt;</code> or <code>make CONF=&lt;pattern&gt;</code>, where <code>&lt;pattern&gt;</code> is a substring matching one or several configurations, e.g. <code>CONF=debug</code>. The special empty pattern (<code>CONF=</code>) will match <em>all</em> available configuration, so <code>make CONF= hotspot</code> will build the <code>hotspot</code> target for all configurations. Alternatively, you can execute <code>make</code> in the configuration directory, e.g. <code>cd build/&lt;name&gt; &amp;&amp; make</code>.</p>
 912 <h3 id="handling-reconfigurations">Handling Reconfigurations</h3>
 913 <p>If you update the repository and part of the configure script has changed, the build system will force you to re-run <code>configure</code>.</p>
 914 <p>Most of the time, you will be fine by running <code>configure</code> again with the same arguments as the last time, which can easily be performed by <code>make reconfigure</code>. To simplify this, you can use the <code>CONF_CHECK</code> make control variable, either as <code>make CONF_CHECK=auto</code>, or by setting an environment variable. For instance, if you add <code>export CONF_CHECK=auto</code> to your <code>.bashrc</code> file, <code>make</code> will always run <code>reconfigure</code> automatically whenever the configure script has changed.</p>
 915 <p>You can also use <code>CONF_CHECK=ignore</code> to skip the check for a needed configure update. This might speed up the build, but comes at the risk of an incorrect build result. This is only recommended if you know what you're doing.</p>
 916 <p>From time to time, you will also need to modify the command line to <code>configure</code> due to changes. Use <code>make print-configure</code> to show the command line used for your current configuration.</p>
 917 <h3 id="using-fine-grained-make-targets">Using Fine-Grained Make Targets</h3>
 918 <p>The default behavior for make is to create consistent and correct output, at the expense of build speed, if necessary.</p>
 919 <p>If you are prepared to take some risk of an incorrect build, and know enough of the system to understand how things build and interact, you can speed up the build process considerably by instructing make to only build a portion of the product.</p>
 920 <h4 id="building-individual-modules">Building Individual Modules</h4>
 921 <p>The safe way to use fine-grained make targets is to use the module specific make targets. All source code in the JDK is organized so it belongs to a module, e.g. <code>java.base</code> or <code>jdk.jdwp.agent</code>. You can build only a specific module, by giving it as make target: <code>make jdk.jdwp.agent</code>. If the specified module depends on other modules (e.g. <code>java.base</code>), those modules will be built first.</p>
 922 <p>You can also specify a set of modules, just as you can always specify a set of make targets: <code>make jdk.crypto.cryptoki jdk.crypto.ec jdk.crypto.mscapi jdk.crypto.ucrypto</code></p>
 923 <h4 id="building-individual-module-phases">Building Individual Module Phases</h4>
 924 <p>The build process for each module is divided into separate phases. Not all modules need all phases. Which are needed depends on what kind of source code and other artifact the module consists of. The phases are:</p>
 925 <ul>
 926 <li><code>gensrc</code> (Generate source code to compile)</li>
 927 <li><code>gendata</code> (Generate non-source code artifacts)</li>
 928 <li><code>copy</code> (Copy resource artifacts)</li>
 929 <li><code>java</code> (Compile Java code)</li>
 930 <li><code>launchers</code> (Compile native executables)</li>
 931 <li><code>libs</code> (Compile native libraries)</li>
 932 </ul>
 933 <p>You can build only a single phase for a module by using the notation <code>$MODULE-$PHASE</code>. For instance, to build the <code>gensrc</code> phase for <code>java.base</code>, use <code>make java.base-gensrc</code>.</p>
 934 <p>Note that some phases may depend on others, e.g. <code>java</code> depends on <code>gensrc</code> (if present). Make will build all needed prerequisites before building the requested phase.</p>
 935 <h4 id="skipping-the-dependency-check">Skipping the Dependency Check</h4>
 936 <p>When using an iterative development style with frequent quick rebuilds, the dependency check made by make can take up a significant portion of the time spent on the rebuild. In such cases, it can be useful to bypass the dependency check in make.</p>
 937 <blockquote>
 938 <p><strong>Note that if used incorrectly, this can lead to a broken build!</strong></p>
 939 </blockquote>
 940 <p>To achieve this, append <code>-only</code> to the build target. For instance, <code>make jdk.jdwp.agent-java-only</code> will <em>only</em> build the <code>java</code> phase of the <code>jdk.jdwp.agent</code> module. If the required dependencies are not present, the build can fail. On the other hand, the execution time measures in milliseconds.</p>
 941 <p>A useful pattern is to build the first time normally (e.g. <code>make jdk.jdwp.agent</code>) and then on subsequent builds, use the <code>-only</code> make target.</p>
 942 <h4 id="rebuilding-part-of-java.base-jdk_filter">Rebuilding Part of java.base (JDK_FILTER)</h4>




  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-aarch64">Building on aarch64</a></li>
  34 <li><a href="#building-on-32-bit-arm">Building on 32-bit arm</a></li>
  35 </ul></li>
  36 <li><a href="#operating-system-requirements">Operating System Requirements</a><ul>
  37 <li><a href="#windows">Windows</a></li>

  38 <li><a href="#macos">macOS</a></li>
  39 <li><a href="#linux">Linux</a></li>
  40 <li><a href="#aix">AIX</a></li>
  41 </ul></li>
  42 <li><a href="#native-compiler-toolchain-requirements">Native Compiler (Toolchain) Requirements</a><ul>
  43 <li><a href="#gcc">gcc</a></li>
  44 <li><a href="#clang">clang</a></li>
  45 <li><a href="#apple-xcode">Apple Xcode</a></li>

  46 <li><a href="#microsoft-visual-studio">Microsoft Visual Studio</a></li>
  47 <li><a href="#ibm-xl-cc">IBM XL C/C++</a></li>
  48 </ul></li>
  49 <li><a href="#boot-jdk-requirements">Boot JDK Requirements</a><ul>
  50 <li><a href="#getting-jdk-binaries">Getting JDK binaries</a></li>
  51 </ul></li>
  52 <li><a href="#external-library-requirements">External Library Requirements</a><ul>
  53 <li><a href="#freetype">FreeType</a></li>
  54 <li><a href="#cups">CUPS</a></li>
  55 <li><a href="#x11">X11</a></li>
  56 <li><a href="#alsa">ALSA</a></li>
  57 <li><a href="#libffi">libffi</a></li>
  58 </ul></li>
  59 <li><a href="#build-tools-requirements">Build Tools Requirements</a><ul>
  60 <li><a href="#autoconf">Autoconf</a></li>
  61 <li><a href="#gnu-make">GNU Make</a></li>
  62 <li><a href="#gnu-bash">GNU Bash</a></li>
  63 </ul></li>
  64 <li><a href="#running-configure">Running Configure</a><ul>
  65 <li><a href="#common-configure-arguments">Common Configure Arguments</a></li>


 137 <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>
 138 <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>
 139 <h3 id="special-considerations">Special Considerations</h3>
 140 <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>
 141 <ul>
 142 <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>
 143 <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>
 144 <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>
 145 <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>
 146 <ul>
 147 <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>
 148 <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>
 149 <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>
 150 </ul>
 151 <p>Failure to follow this procedure might result in hard-to-debug build problems.</p></li>
 152 </ul>
 153 <h2 id="build-hardware-requirements">Build Hardware Requirements</h2>
 154 <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>
 155 <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>
 156 <h3 id="building-on-x86">Building on x86</h3>
 157 <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.</p>
 158 <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>



 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, 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.6</td>
 179 </tr>
 180 <tr class="even">




 181 <td style="text-align: left;">macOS</td>
 182 <td style="text-align: left;">Mac OS X 10.13 (High Sierra)</td>
 183 </tr>
 184 <tr class="odd">
 185 <td style="text-align: left;">Windows</td>
 186 <td style="text-align: left;">Windows Server 2012 R2</td>
 187 </tr>
 188 </tbody>
 189 </table>
 190 <p>The double version numbers for Linux 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>
 191 <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>
 192 <h3 id="windows">Windows</h3>
 193 <p>Windows XP is not a supported platform, but all newer Windows should be able to build the JDK.</p>
 194 <p>On Windows, it is important that you pay attention to the instructions in the <a href="#special-considerations">Special Considerations</a>.</p>
 195 <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>
 196 <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>
 197 <h4 id="cygwin">Cygwin</h4>
 198 <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>
 199 <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>
 200 <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>
 201 <p>Apart from the basic Cygwin installation, the following packages must also be installed:</p>
 202 <ul>
 203 <li><code>autoconf</code></li>
 204 <li><code>make</code></li>
 205 <li><code>zip</code></li>
 206 <li><code>unzip</code></li>
 207 </ul>
 208 <p>Often, you can install these packages using the following command line:</p>
 209 <pre><code>&lt;path to Cygwin setup&gt;/setup-x86_64 -q -P autoconf -P make -P unzip -P zip</code></pre>
 210 <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>
 211 <h4 id="windows-subsystem-for-linux-wsl">Windows Subsystem for Linux (WSL)</h4>
 212 <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>
 213 <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>
 214 <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>
 215 <p>Note that while it's possible to build on WSL, testing is still not fully supported.</p>




 216 <h3 id="macos">macOS</h3>
 217 <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>
 218 <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>
 219 <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>
 220 <h3 id="linux">Linux</h3>
 221 <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>
 222 <p>The basic tooling is provided as part of the core operating system, but you will most likely need to install developer packages.</p>
 223 <p>For apt-based distributions (Debian, Ubuntu, etc), try this:</p>
 224 <pre><code>sudo apt-get install build-essential</code></pre>
 225 <p>For rpm-based distributions (Fedora, Red Hat, etc), try this:</p>
 226 <pre><code>sudo yum groupinstall &quot;Development Tools&quot;</code></pre>
 227 <h3 id="aix">AIX</h3>
 228 <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>
 229 <h2 id="native-compiler-toolchain-requirements">Native Compiler (Toolchain) Requirements</h2>
 230 <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>
 231 <table>
 232 <thead>
 233 <tr class="header">
 234 <th style="text-align: left;">Operating system</th>
 235 <th style="text-align: left;">Supported toolchain</th>
 236 </tr>
 237 </thead>
 238 <tbody>
 239 <tr class="odd">
 240 <td style="text-align: left;">Linux</td>
 241 <td style="text-align: left;">gcc, clang</td>
 242 </tr>
 243 <tr class="even">
 244 <td style="text-align: left;">macOS</td>
 245 <td style="text-align: left;">Apple Xcode (using clang)</td>
 246 </tr>
 247 <tr class="odd">




 248 <td style="text-align: left;">AIX</td>
 249 <td style="text-align: left;">IBM XL C/C++</td>
 250 </tr>
 251 <tr class="even">
 252 <td style="text-align: left;">Windows</td>
 253 <td style="text-align: left;">Microsoft Visual Studio</td>
 254 </tr>
 255 </tbody>
 256 </table>
 257 <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>
 258 <table>
 259 <thead>
 260 <tr class="header">
 261 <th style="text-align: left;">Operating system</th>
 262 <th style="text-align: left;">Toolchain version</th>
 263 </tr>
 264 </thead>
 265 <tbody>
 266 <tr class="odd">
 267 <td style="text-align: left;">Linux</td>
 268 <td style="text-align: left;">gcc 9.2.0</td>
 269 </tr>
 270 <tr class="even">
 271 <td style="text-align: left;">macOS</td>
 272 <td style="text-align: left;">Apple Xcode 10.1 (using clang 10.0.0)</td>
 273 </tr>
 274 <tr class="odd">




 275 <td style="text-align: left;">Windows</td>
 276 <td style="text-align: left;">Microsoft Visual Studio 2017 update 15.9.16</td>
 277 </tr>
 278 </tbody>
 279 </table>
 280 <p>All compilers are expected to be able to compile to the C99 language standard, as some C99 features are used in the source code. Microsoft Visual Studio doesn't fully support C99 so in practice shared code is limited to using C99 features that it does support.</p>
 281 <h3 id="gcc">gcc</h3>
 282 <p>The minimum accepted version of gcc is 5.0. Older versions will generate a warning by <code>configure</code> and are unlikely to work.</p>
 283 <p>The JDK is currently known to be able to compile with at least version 9.2 of gcc.</p>
 284 <p>In general, any version between these two should be usable.</p>
 285 <h3 id="clang">clang</h3>
 286 <p>The minimum accepted version of clang is 3.2. Older versions will not be accepted by <code>configure</code>.</p>
 287 <p>To use clang instead of gcc on Linux, use <code>--with-toolchain-type=clang</code>.</p>
 288 <h3 id="apple-xcode">Apple Xcode</h3>
 289 <p>The oldest supported version of Xcode is 8.</p>
 290 <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>
 291 <pre><code>xcode-select --install</code></pre>
 292 <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>
 293 <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>


























































 294 <h3 id="microsoft-visual-studio">Microsoft Visual Studio</h3>
 295 <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>
 296 <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>
 297 <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>
 298 <h3 id="ibm-xl-cc">IBM XL C/C++</h3>
 299 <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>
 300 <h2 id="boot-jdk-requirements">Boot JDK Requirements</h2>
 301 <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>
 302 <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>
 303 <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>
 304 <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>
 305 <h3 id="getting-jdk-binaries">Getting JDK binaries</h3>
 306 <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>
 307 <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>
 308 <h2 id="external-library-requirements">External Library Requirements</h2>
 309 <p>Different platforms require different external libraries. In general, libraries are not optional - that is, they are either required or not used.</p>
 310 <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 and library files to reside in a default hierarchy under this directory. In most cases, it works fine.</p>
 311 <p>As a fallback, the second version allows you to point to the include directory and the lib directory separately.</p>
 312 <h3 id="freetype">FreeType</h3>
 313 <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>
 314 <ul>
 315 <li>To install on an apt-based Linux, try running <code>sudo apt-get install libfreetype6-dev</code>.</li>
 316 <li>To install on an rpm-based Linux, try running <code>sudo yum install freetype-devel</code>.</li>

 317 </ul>
 318 <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>
 319 <h3 id="cups">CUPS</h3>
 320 <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>
 321 <ul>
 322 <li>To install on an apt-based Linux, try running <code>sudo apt-get install libcups2-dev</code>.</li>
 323 <li>To install on an rpm-based Linux, try running <code>sudo yum install cups-devel</code>.</li>

 324 </ul>
 325 <p>Use <code>--with-cups=&lt;path&gt;</code> if <code>configure</code> does not properly locate your CUPS files.</p>
 326 <h3 id="x11">X11</h3>
 327 <p>Certain <a href="http://www.x.org/">X11</a> libraries and include files are required on Linux.</p>
 328 <ul>
 329 <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>
 330 <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>

 331 </ul>
 332 <p>Use <code>--with-x=&lt;path&gt;</code> if <code>configure</code> does not properly locate your X11 files.</p>
 333 <h3 id="alsa">ALSA</h3>
 334 <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>
 335 <ul>
 336 <li>To install on an apt-based Linux, try running <code>sudo apt-get install libasound2-dev</code>.</li>
 337 <li>To install on an rpm-based Linux, try running <code>sudo yum install alsa-lib-devel</code>.</li>
 338 </ul>
 339 <p>Use <code>--with-alsa=&lt;path&gt;</code> if <code>configure</code> does not properly locate your ALSA files.</p>
 340 <h3 id="libffi">libffi</h3>
 341 <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>
 342 <ul>
 343 <li>To install on an apt-based Linux, try running <code>sudo apt-get install libffi-dev</code>.</li>
 344 <li>To install on an rpm-based Linux, try running <code>sudo yum install libffi-devel</code>.</li>
 345 </ul>
 346 <p>Use <code>--with-libffi=&lt;path&gt;</code> if <code>configure</code> does not properly locate your libffi files.</p>
 347 <h2 id="build-tools-requirements">Build Tools Requirements</h2>
 348 <h3 id="autoconf">Autoconf</h3>
 349 <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>
 350 <ul>
 351 <li>To install on an apt-based Linux, try running <code>sudo apt-get install autoconf</code>.</li>
 352 <li>To install on an rpm-based Linux, try running <code>sudo yum install autoconf</code>.</li>
 353 <li>To install on macOS, try running <code>brew install autoconf</code>.</li>
 354 <li>To install on Windows, try running <code>&lt;path to Cygwin setup&gt;/setup-x86_64 -q -P autoconf</code>.</li>
 355 </ul>
 356 <p>If <code>configure</code> has problems locating your installation of autoconf, you can specify it using the <code>AUTOCONF</code> environment variable, like this:</p>
 357 <pre><code>AUTOCONF=&lt;path to autoconf&gt; configure ...</code></pre>
 358 <h3 id="gnu-make">GNU Make</h3>
 359 <p>The JDK requires <a href="http://www.gnu.org/software/make">GNU Make</a>. No other flavors of make are supported.</p>
 360 <p>At least version 3.81 of GNU Make must be used. For distributions supporting GNU Make 4.0 or above, we strongly recommend it. GNU Make 4.0 contains useful functionality to handle parallel building (supported by <code>--with-output-sync</code>) and speed and stability improvements.</p>
 361 <p>Note that <code>configure</code> locates and verifies a properly functioning version of <code>make</code> and stores the path to this <code>make</code> binary in the configuration. If you start a build using <code>make</code> on the command line, you will be using the version of make found first in your <code>PATH</code>, and not necessarily the one stored in the configuration. This initial make will be used as &quot;bootstrap make&quot;, and in a second stage, the make located by <code>configure</code> will be called. Normally, this will present no issues, but if you have a very old <code>make</code>, or a non-GNU Make <code>make</code> in your path, this might cause issues.</p>
 362 <p>If you want to override the default make found by <code>configure</code>, use the <code>MAKE</code> configure variable, e.g. <code>configure MAKE=/opt/gnu/make</code>.</p>

 363 <h3 id="gnu-bash">GNU Bash</h3>
 364 <p>The JDK requires <a href="http://www.gnu.org/software/bash">GNU Bash</a>. No other shells are supported.</p>
 365 <p>At least version 3.2 of GNU Bash must be used.</p>
 366 <h2 id="running-configure">Running Configure</h2>
 367 <p>To build the JDK, you need a &quot;configuration&quot;, which consists of a directory where to store the build output, coupled with information about the platform, the specific build machine, and choices that affect how the JDK is built.</p>
 368 <p>The configuration is created by the <code>configure</code> script. The basic invocation of the <code>configure</code> script looks like this:</p>
 369 <pre><code>bash configure [options]</code></pre>
 370 <p>This will create an output directory containing the configuration and setup an area for the build result. This directory typically looks like <code>build/linux-x64-server-release</code>, but the actual name depends on your specific configuration. (It can also be set directly, see <a href="#using-multiple-configurations">Using Multiple Configurations</a>). This directory is referred to as <code>$BUILD</code> in this documentation.</p>
 371 <p><code>configure</code> will try to figure out what system you are running on and where all necessary build components are. If you have all prerequisites for building installed, it should find everything. If it fails to detect any component automatically, it will exit and inform you about the problem.</p>
 372 <p>Some command line examples:</p>
 373 <ul>
 374 <li><p>Create a 32-bit build for Windows with FreeType2 in <code>C:\freetype-i586</code>:</p>
 375 <pre><code>bash configure --with-freetype=/cygdrive/c/freetype-i586 --with-target-bits=32</code></pre></li>
 376 <li><p>Create a debug build with the <code>server</code> JVM and DTrace enabled:</p>
 377 <pre><code>bash configure --enable-debug --with-jvm-variants=server --enable-dtrace</code></pre></li>
 378 </ul>
 379 <h3 id="common-configure-arguments">Common Configure Arguments</h3>
 380 <p>Here follows some of the most common and important <code>configure</code> argument.</p>
 381 <p>To get up-to-date information on <em>all</em> available <code>configure</code> argument, please run:</p>
 382 <pre><code>bash configure --help</code></pre>


 764 <p>Run <code>hg pull -u</code> to make sure you have the latest changes.</p></li>
 765 <li><p>Clean build results</p>
 766 <p>The simplest way to fix incremental rebuild issues is to run <code>make clean</code>. This will remove all build results, but not the configuration or any build system support artifacts. In most cases, this will solve build errors resulting from incremental build mismatches.</p></li>
 767 <li><p>Completely clean the build directory.</p>
 768 <p>If this does not work, the next step is to run <code>make dist-clean</code>, or removing the build output directory (<code>$BUILD</code>). This will clean all generated output, including your configuration. You will need to re-run <code>configure</code> after this step. A good idea is to run <code>make print-configuration</code> before running <code>make dist-clean</code>, as this will print your current <code>configure</code> command line. Here's a way to do this:</p>
 769 <pre><code>make print-configuration &gt; current-configuration
 770 make dist-clean
 771 bash configure $(cat current-configuration)
 772 make</code></pre></li>
 773 <li><p>Re-clone the Mercurial repository</p>
 774 <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>
 775 </ol>
 776 <h3 id="specific-build-issues">Specific Build Issues</h3>
 777 <h4 id="clock-skew">Clock Skew</h4>
 778 <p>If you get an error message like this:</p>
 779 <pre><code>File 'xxx' has modification time in the future.
 780 Clock skew detected. Your build may be incomplete.</code></pre>
 781 <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>
 782 <p>If you see these warnings, reset the clock on the build machine, run <code>make clean</code> and restart the build.</p>
 783 <h4 id="out-of-memory-errors">Out of Memory Errors</h4>



 784 <p>On Windows, you might get error messages like this:</p>
 785 <pre><code>fatal error - couldn't allocate heap
 786 cannot create ... Permission denied
 787 spawn failed</code></pre>
 788 <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>
 789 <h3 id="getting-help">Getting Help</h3>
 790 <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>
 791 <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>
 792 <h2 id="hints-and-suggestions-for-advanced-users">Hints and Suggestions for Advanced Users</h2>
 793 <h3 id="setting-up-a-repository-for-pushing-changes-defpath">Setting Up a Repository for Pushing Changes (defpath)</h3>
 794 <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>
 795 <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>
 796 <pre><code>cd ~
 797 mkdir hg-ext
 798 cd hg-ext
 799 hg clone http://hg.openjdk.java.net/code-tools/defpath
 800 cat &lt;&lt; EOT &gt;&gt; ~/.hgrc
 801 [extensions]
 802 defpath=~/hg-ext/defpath/defpath.py
 803 EOT</code></pre>


 815 fi
 816 
 817 bash \$PWD/configure &quot;\$@&quot;
 818 EOT
 819 chmod +x /tmp/configure
 820 sudo mv /tmp/configure /usr/local/bin</code></pre>
 821 <p>Now <code>configure --en&lt;tab&gt;-dt&lt;tab&gt;</code> will result in <code>configure --enable-dtrace</code>.</p>
 822 <h3 id="using-multiple-configurations">Using Multiple Configurations</h3>
 823 <p>You can have multiple configurations for a single source repository. When you create a new configuration, run <code>configure --with-conf-name=&lt;name&gt;</code> to create a configuration with the name <code>&lt;name&gt;</code>. Alternatively, you can create a directory under <code>build</code> and run <code>configure</code> from there, e.g. <code>mkdir build/&lt;name&gt; &amp;&amp; cd build/&lt;name&gt; &amp;&amp; bash ../../configure</code>.</p>
 824 <p>Then you can build that configuration using <code>make CONF_NAME=&lt;name&gt;</code> or <code>make CONF=&lt;pattern&gt;</code>, where <code>&lt;pattern&gt;</code> is a substring matching one or several configurations, e.g. <code>CONF=debug</code>. The special empty pattern (<code>CONF=</code>) will match <em>all</em> available configuration, so <code>make CONF= hotspot</code> will build the <code>hotspot</code> target for all configurations. Alternatively, you can execute <code>make</code> in the configuration directory, e.g. <code>cd build/&lt;name&gt; &amp;&amp; make</code>.</p>
 825 <h3 id="handling-reconfigurations">Handling Reconfigurations</h3>
 826 <p>If you update the repository and part of the configure script has changed, the build system will force you to re-run <code>configure</code>.</p>
 827 <p>Most of the time, you will be fine by running <code>configure</code> again with the same arguments as the last time, which can easily be performed by <code>make reconfigure</code>. To simplify this, you can use the <code>CONF_CHECK</code> make control variable, either as <code>make CONF_CHECK=auto</code>, or by setting an environment variable. For instance, if you add <code>export CONF_CHECK=auto</code> to your <code>.bashrc</code> file, <code>make</code> will always run <code>reconfigure</code> automatically whenever the configure script has changed.</p>
 828 <p>You can also use <code>CONF_CHECK=ignore</code> to skip the check for a needed configure update. This might speed up the build, but comes at the risk of an incorrect build result. This is only recommended if you know what you're doing.</p>
 829 <p>From time to time, you will also need to modify the command line to <code>configure</code> due to changes. Use <code>make print-configure</code> to show the command line used for your current configuration.</p>
 830 <h3 id="using-fine-grained-make-targets">Using Fine-Grained Make Targets</h3>
 831 <p>The default behavior for make is to create consistent and correct output, at the expense of build speed, if necessary.</p>
 832 <p>If you are prepared to take some risk of an incorrect build, and know enough of the system to understand how things build and interact, you can speed up the build process considerably by instructing make to only build a portion of the product.</p>
 833 <h4 id="building-individual-modules">Building Individual Modules</h4>
 834 <p>The safe way to use fine-grained make targets is to use the module specific make targets. All source code in the JDK is organized so it belongs to a module, e.g. <code>java.base</code> or <code>jdk.jdwp.agent</code>. You can build only a specific module, by giving it as make target: <code>make jdk.jdwp.agent</code>. If the specified module depends on other modules (e.g. <code>java.base</code>), those modules will be built first.</p>
 835 <p>You can also specify a set of modules, just as you can always specify a set of make targets: <code>make jdk.crypto.cryptoki jdk.crypto.ec jdk.crypto.mscapi</code></p>
 836 <h4 id="building-individual-module-phases">Building Individual Module Phases</h4>
 837 <p>The build process for each module is divided into separate phases. Not all modules need all phases. Which are needed depends on what kind of source code and other artifact the module consists of. The phases are:</p>
 838 <ul>
 839 <li><code>gensrc</code> (Generate source code to compile)</li>
 840 <li><code>gendata</code> (Generate non-source code artifacts)</li>
 841 <li><code>copy</code> (Copy resource artifacts)</li>
 842 <li><code>java</code> (Compile Java code)</li>
 843 <li><code>launchers</code> (Compile native executables)</li>
 844 <li><code>libs</code> (Compile native libraries)</li>
 845 </ul>
 846 <p>You can build only a single phase for a module by using the notation <code>$MODULE-$PHASE</code>. For instance, to build the <code>gensrc</code> phase for <code>java.base</code>, use <code>make java.base-gensrc</code>.</p>
 847 <p>Note that some phases may depend on others, e.g. <code>java</code> depends on <code>gensrc</code> (if present). Make will build all needed prerequisites before building the requested phase.</p>
 848 <h4 id="skipping-the-dependency-check">Skipping the Dependency Check</h4>
 849 <p>When using an iterative development style with frequent quick rebuilds, the dependency check made by make can take up a significant portion of the time spent on the rebuild. In such cases, it can be useful to bypass the dependency check in make.</p>
 850 <blockquote>
 851 <p><strong>Note that if used incorrectly, this can lead to a broken build!</strong></p>
 852 </blockquote>
 853 <p>To achieve this, append <code>-only</code> to the build target. For instance, <code>make jdk.jdwp.agent-java-only</code> will <em>only</em> build the <code>java</code> phase of the <code>jdk.jdwp.agent</code> module. If the required dependencies are not present, the build can fail. On the other hand, the execution time measures in milliseconds.</p>
 854 <p>A useful pattern is to build the first time normally (e.g. <code>make jdk.jdwp.agent</code>) and then on subsequent builds, use the <code>-only</code> make target.</p>
 855 <h4 id="rebuilding-part-of-java.base-jdk_filter">Rebuilding Part of java.base (JDK_FILTER)</h4>


< prev index next >