1% Building the JDK
2
3## TL;DR (Instructions for the Impatient)
4
5If you are eager to try out building the JDK, these simple steps works most of
6the time. They assume that you have installed Git (and Cygwin if running
7on Windows) and cloned the top-level JDK repository that you want to build.
8
9 1. [Get the complete source code](#getting-the-source-code): \
10    `git clone https://git.openjdk.java.net/jdk/`
11
12 2. [Run configure](#running-configure): \
13    `bash configure`
14
15    If `configure` fails due to missing dependencies (to either the
16    [toolchain](#native-compiler-toolchain-requirements), [build tools](
17    #build-tools-requirements), [external libraries](
18    #external-library-requirements) or the [boot JDK](#boot-jdk-requirements)),
19    most of the time it prints a suggestion on how to resolve the situation on
20    your platform. Follow the instructions, and try running `bash configure`
21    again.
22
23 3. [Run make](#running-make): \
24    `make images`
25
26 4. Verify your newly built JDK: \
27    `./build/*/images/jdk/bin/java -version`
28
29 5. [Run basic tests](##running-tests): \
30    `make run-test-tier1`
31
32If any of these steps failed, or if you want to know more about build
33requirements or build functionality, please continue reading this document.
34
35## Introduction
36
37The JDK is a complex software project. Building it requires a certain amount of
38technical expertise, a fair number of dependencies on external software, and
39reasonably powerful hardware.
40
41If you just want to use the JDK and not build it yourself, this document is not
42for you. See for instance [OpenJDK installation](
43http://openjdk.java.net/install) for some methods of installing a prebuilt
44JDK.
45
46## Getting the Source Code
47
48Make sure you are getting the correct version. As of JDK 10, the source is no
49longer split into separate repositories so you only need to clone one single
50repository. At the [OpenJDK Git site](https://git.openjdk.java.net/) you
51can see a list of all available repositories. If you want to build an older version,
52e.g. JDK 11, it is recommended that you get the `jdk11u` repo, which contains
53incremental updates, instead of the `jdk11` repo, which was frozen at JDK 11 GA.
54
55If you are new to Git, a good place to start is the book [Pro
56Git](https://git-scm.com/book/en/v2). The rest of this document
57assumes a working knowledge of Git.
58
59### Special Considerations
60
61For a smooth building experience, it is recommended that you follow these rules
62on where and how to check out the source code.
63
64  * Do not check out the source code in a path which contains spaces. Chances
65    are the build will not work. This is most likely to be an issue on Windows
66    systems.
67
68  * Do not check out the source code in a path which has a very long name or is
69    nested many levels deep. Chances are you will hit an OS limitation during
70    the build.
71
72  * Put the source code on a local disk, not a network share. If possible, use
73    an SSD. The build process is very disk intensive, and having slow disk
74    access will significantly increase build times. If you need to use a
75    network share for the source code, see below for suggestions on how to keep
76    the build artifacts on a local disk.
77
78  * On Windows, if using [Cygwin](#cygwin), extra care must be taken to make sure
79    the environment is consistent. It is recommended that you follow this
80    procedure:
81
82      * Create the directory that is going to contain the top directory of the
83        JDK clone by using the `mkdir` command in the Cygwin bash shell.
84        That is, do *not* create it using Windows Explorer. This will ensure
85        that it will have proper Cygwin attributes, and that it's children will
86        inherit those attributes.
87
88      * Do not put the JDK clone in a path under your Cygwin home
89        directory. This is especially important if your user name contains
90        spaces and/or mixed upper and lower case letters.
91
92      * You need to install a git client. You have two choices, Cygwin git or
93        Git for Windows. Unfortunately there are pros and cons with each choice.
94
95        * The Cygwin `git` client has no line ending issues and understands
96          Cygwin paths (which are used throughout the JDK build system).
97          However, it does not currently work well with the Skara CLI tooling.
98          Please see the [Skara wiki on Git clients](
99          https://wiki.openjdk.java.net/display/SKARA/Skara#Skara-Git) for
100          up-to-date information about the Skara git client support.
101
102        * The [Git for Windows](https://gitforwindows.org) client has issues
103          with line endings, and do not understand Cygwin paths. It does work
104          well with the Skara CLI tooling, however. To alleviate the line ending
105          problems, make sure you set `core.autocrlf` to `false` (this is asked
106          during installation).
107
108    Failure to follow this procedure might result in hard-to-debug build
109    problems.
110
111## Build Hardware Requirements
112
113The JDK is a massive project, and require machines ranging from decent to
114powerful to be able to build in a reasonable amount of time, or to be able to
115complete a build at all.
116
117We *strongly* recommend usage of an SSD disk for the build, since disk speed is
118one of the limiting factors for build performance.
119
120### Building on x86
121
122At a minimum, a machine with 2-4 cores is advisable, as well as 2-4 GB of RAM.
123(The more cores to use, the more memory you need.) At least 6 GB of free disk
124space is required (8 GB minimum for building on Solaris).
125
126Even for 32-bit builds, it is recommended to use a 64-bit build machine, and
127instead create a 32-bit target using `--with-target-bits=32`.
128
129### Building on sparc
130
131At a minimum, a machine with 4 cores is advisable, as well as 4 GB of RAM. (The
132more cores to use, the more memory you need.) At least 8 GB of free disk space
133is required.
134
135### Building on aarch64
136
137At a minimum, a machine with 8 cores is advisable, as well as 8 GB of RAM.
138(The more cores to use, the more memory you need.) At least 6 GB of free disk
139space is required.
140
141If you do not have access to sufficiently powerful hardware, it is also
142possible to use [cross-compiling](#cross-compiling).
143
144### Building on 32-bit arm
145
146This is not recommended. Instead, see the section on [Cross-compiling](
147#cross-compiling).
148
149## Operating System Requirements
150
151The mainline JDK project supports Linux, Solaris, macOS, AIX and Windows.
152Support for other operating system, e.g. BSD, exists in separate "port"
153projects.
154
155In general, the JDK can be built on a wide range of versions of these operating
156systems, but the further you deviate from what is tested on a daily basis, the
157more likely you are to run into problems.
158
159This table lists the OS versions used by Oracle when building the JDK. Such
160information is always subject to change, but this table is up to date at the
161time of writing.
162
163 Operating system   Vendor/version used
164 -----------------  -------------------------------------------------------
165 Linux              Oracle Enterprise Linux 6.4 / 7.6
166 Solaris            Solaris 11.3 SRU 20
167 macOS              Mac OS X 10.13 (High Sierra)
168 Windows            Windows Server 2012 R2
169
170The double version numbers for Linux and Solaris are due to the hybrid model
171used at Oracle, where header files and external libraries from an older version
172are used when building on a more modern version of the OS.
173
174The Build Group has a wiki page with [Supported Build Platforms](
175https://wiki.openjdk.java.net/display/Build/Supported+Build+Platforms). From
176time to time, this is updated by contributors to list successes or failures of
177building on different platforms.
178
179### Windows
180
181Windows XP is not a supported platform, but all newer Windows should be able to
182build the JDK.
183
184On Windows, it is important that you pay attention to the instructions in the
185[Special Considerations](#special-considerations).
186
187Windows is the only non-POSIX OS supported by the JDK, and as such, requires
188some extra care. A POSIX support layer is required to build on Windows.
189Currently, the only supported such layers are Cygwin and Windows Subsystem for
190Linux (WSL). (Msys is no longer supported due to a too old bash; msys2 would
191likely be possible to support in a future version but that would require effort
192to implement.)
193
194Internally in the build system, all paths are represented as Unix-style paths,
195e.g. `/cygdrive/c/git/jdk/Makefile` rather than `C:\git\jdk\Makefile`. This
196rule also applies to input to the build system, e.g. in arguments to
197`configure`. So, use `--with-msvcr-dll=/cygdrive/c/msvcr100.dll` rather than
198`--with-msvcr-dll=c:\msvcr100.dll`. For details on this conversion, see the section
199on [Fixpath](#fixpath).
200
201#### Cygwin
202
203A functioning [Cygwin](http://www.cygwin.com/) environment is required for
204building the JDK on Windows. If you have a 64-bit OS, we strongly recommend
205using the 64-bit version of Cygwin.
206
207**Note:** Cygwin has a model of continuously updating all packages without any
208easy way to install or revert to a specific version of a package. This means
209that whenever you add or update a package in Cygwin, you might (inadvertently)
210update tools that are used by the JDK build process, and that can cause
211unexpected build problems.
212
213The JDK requires GNU Make 4.0 or greater in Cygwin. This is usually not a
214problem, since Cygwin currently only distributes GNU Make at a version above
2154.0.
216
217Apart from the basic Cygwin installation, the following packages must also be
218installed:
219
220  * `autoconf`
221  * `make`
222  * `zip`
223  * `unzip`
224
225Often, you can install these packages using the following command line:
226```
227<path to Cygwin setup>/setup-x86_64 -q -P autoconf -P make -P unzip -P zip
228```
229
230Unfortunately, Cygwin can be unreliable in certain circumstances. If you
231experience build tool crashes or strange issues when building on Windows,
232please check the Cygwin FAQ on the ["BLODA" list](
233https://cygwin.com/faq/faq.html#faq.using.bloda) and the section on [fork()
234failures](https://cygwin.com/faq/faq.html#faq.using.fixing-fork-failures).
235
236#### Windows Subsystem for Linux (WSL)
237
238Windows 10 1809 or newer is supported due to a dependency on the wslpath utility
239and support for environment variable sharing through WSLENV. Version 1803 can
240work but intermittent build failures have been observed.
241
242It's possible to build both Windows and Linux binaries from WSL. To build
243Windows binaries, you must use a Windows boot JDK (located in a
244Windows-accessible directory). To build Linux binaries, you must use a Linux
245boot JDK. The default behavior is to build for Windows. To build for Linux, pass
246`--build=x86_64-unknown-linux-gnu --host=x86_64-unknown-linux-gnu` to
247`configure`.
248
249If building Windows binaries, the source code must be located in a Windows-
250accessible directory. This is because Windows executables (such as Visual Studio
251and the boot JDK) must be able to access the source code. Also, the drive where
252the source is stored must be mounted as case-insensitive by changing either
253/etc/fstab or /etc/wsl.conf in WSL. Individual directories may be corrected
254using the fsutil tool in case the source was cloned before changing the mount
255options.
256
257Note that while it's possible to build on WSL, testing is still not fully
258supported.
259
260### Solaris
261
262See `make/devkit/solaris11.1-package-list.txt` for a list of recommended
263packages to install when building on Solaris. The versions specified in this
264list is the versions used by the daily builds at Oracle, and is likely to work
265properly.
266
267Older versions of Solaris shipped a broken version of `objcopy`. At least
268version 2.21.1 is needed, which is provided by Solaris 11 Update 1. Objcopy is
269needed if you want to have external debug symbols. Please make sure you are
270using at least version 2.21.1 of objcopy, or that you disable external debug
271symbols.
272
273### macOS
274
275Apple is using a quite aggressive scheme of pushing OS updates, and coupling
276these updates with required updates of Xcode. Unfortunately, this makes it
277difficult for a project such as the JDK to keep pace with a continuously updated
278machine running macOS. See the section on [Apple Xcode](#apple-xcode) on some
279strategies to deal with this.
280
281It is recommended that you use at least Mac OS X 10.13 (High Sierra). At the time
282of writing, the JDK has been successfully compiled on macOS 10.12 (Sierra).
283
284The standard macOS environment contains the basic tooling needed to build, but
285for external libraries a package manager is recommended. The JDK uses
286[homebrew](https://brew.sh/) in the examples, but feel free to use whatever
287manager you want (or none).
288
289### Linux
290
291It is often not much problem to build the JDK on Linux. The only general advice
292is to try to use the compilers, external libraries and header files as provided
293by your distribution.
294
295The basic tooling is provided as part of the core operating system, but you
296will most likely need to install developer packages.
297
298For apt-based distributions (Debian, Ubuntu, etc), try this:
299```
300sudo apt-get install build-essential
301```
302
303For rpm-based distributions (Fedora, Red Hat, etc), try this:
304```
305sudo yum groupinstall "Development Tools"
306```
307
308### AIX
309
310Please consult the AIX section of the [Supported Build Platforms](
311https://wiki.openjdk.java.net/display/Build/Supported+Build+Platforms) OpenJDK
312Build Wiki page for details about which versions of AIX are supported.
313
314## Native Compiler (Toolchain) Requirements
315
316Large portions of the JDK consists of native code, that needs to be compiled to
317be able to run on the target platform. In theory, toolchain and operating
318system should be independent factors, but in practice there's more or less a
319one-to-one correlation between target operating system and toolchain.
320
321 Operating system   Supported toolchain
322 ------------------ -------------------------
323 Linux              gcc, clang
324 macOS              Apple Xcode (using clang)
325 Solaris            Oracle Solaris Studio
326 AIX                IBM XL C/C++
327 Windows            Microsoft Visual Studio
328
329Please see the individual sections on the toolchains for version
330recommendations. As a reference, these versions of the toolchains are used, at
331the time of writing, by Oracle for the daily builds of the JDK. It should be
332possible to compile the JDK with both older and newer versions, but the closer
333you stay to this list, the more likely you are to compile successfully without
334issues.
335
336 Operating system   Toolchain version
337 ------------------ -------------------------------------------------------
338 Linux              gcc 8.2.0
339 macOS              Apple Xcode 10.1 (using clang 10.0.0)
340 Solaris            Oracle Solaris Studio 12.6 (with compiler version 5.15)
341 Windows            Microsoft Visual Studio 2017 update 15.9.6
342
343All compilers are expected to be able to compile to the C99 language standard,
344as some C99 features are used in the source code. Microsoft Visual Studio
345doesn't fully support C99 so in practice shared code is limited to using C99
346features that it does support.
347
348### gcc
349
350The minimum accepted version of gcc is 4.8. Older versions will generate a warning
351by `configure` and are unlikely to work.
352
353The JDK is currently known to be able to compile with at least version 7.4 of
354gcc.
355
356In general, any version between these two should be usable.
357
358### clang
359
360The minimum accepted version of clang is 3.2. Older versions will not be
361accepted by `configure`.
362
363To use clang instead of gcc on Linux, use `--with-toolchain-type=clang`.
364
365### Apple Xcode
366
367The oldest supported version of Xcode is 8.
368
369You will need the Xcode command lines developers tools to be able to build
370the JDK. (Actually, *only* the command lines tools are needed, not the IDE.)
371The simplest way to install these is to run:
372```
373xcode-select --install
374```
375
376It is advisable to keep an older version of Xcode for building the JDK when
377updating Xcode. This [blog page](
378http://iosdevelopertips.com/xcode/install-multiple-versions-of-xcode.html) has
379good suggestions on managing multiple Xcode versions. To use a specific version
380of Xcode, use `xcode-select -s` before running `configure`, or use
381`--with-toolchain-path` to point to the version of Xcode to use, e.g.
382`configure --with-toolchain-path=/Applications/Xcode8.app/Contents/Developer/usr/bin`
383
384If you have recently (inadvertently) updated your OS and/or Xcode version, and
385the JDK can no longer be built, please see the section on [Problems with the
386Build Environment](#problems-with-the-build-environment), and [Getting
387Help](#getting-help) to find out if there are any recent, non-merged patches
388available for this update.
389
390### Oracle Solaris Studio
391
392The minimum accepted version of the Solaris Studio compilers is 5.13
393(corresponding to Solaris Studio 12.4). Older versions will not be accepted by
394configure.
395
396The Solaris Studio installation should contain at least these packages:
397
398 Package                                            Version
399 -------------------------------------------------- -------------
400 developer/solarisstudio-124/backend                12.4-1.0.6.0
401 developer/solarisstudio-124/c++                    12.4-1.0.10.0
402 developer/solarisstudio-124/cc                     12.4-1.0.4.0
403 developer/solarisstudio-124/library/c++-libs       12.4-1.0.10.0
404 developer/solarisstudio-124/library/math-libs      12.4-1.0.0.1
405 developer/solarisstudio-124/library/studio-gccrt   12.4-1.0.0.1
406 developer/solarisstudio-124/studio-common          12.4-1.0.0.1
407 developer/solarisstudio-124/studio-ja              12.4-1.0.0.1
408 developer/solarisstudio-124/studio-legal           12.4-1.0.0.1
409 developer/solarisstudio-124/studio-zhCN            12.4-1.0.0.1
410
411Compiling with Solaris Studio can sometimes be finicky. This is the exact
412version used by Oracle, which worked correctly at the time of writing:
413```
414$ cc -V
415cc: Sun C 5.13 SunOS_i386 2014/10/20
416$ CC -V
417CC: Sun C++ 5.13 SunOS_i386 151846-10 2015/10/30
418```
419
420### Microsoft Visual Studio
421
422The minimum accepted version of Visual Studio is 2010. Older versions will not
423be accepted by `configure`. The maximum accepted version of Visual Studio is
4242019. Versions older than 2017 are unlikely to continue working for long.
425
426If you have multiple versions of Visual Studio installed, `configure` will by
427default pick the latest. You can request a specific version to be used by
428setting `--with-toolchain-version`, e.g. `--with-toolchain-version=2015`.
429
430If you get `LINK: fatal error LNK1123: failure during conversion to COFF: file
431invalid` when building using Visual Studio 2010, you have encountered
432[KB2757355](http://support.microsoft.com/kb/2757355), a bug triggered by a
433specific installation order. However, the solution suggested by the KB article
434does not always resolve the problem. See [this stackoverflow discussion](
435https://stackoverflow.com/questions/10888391) for other suggestions.
436
437### IBM XL C/C++
438
439Please consult the AIX section of the [Supported Build Platforms](
440https://wiki.openjdk.java.net/display/Build/Supported+Build+Platforms) OpenJDK
441Build Wiki page for details about which versions of XLC are supported.
442
443
444## Boot JDK Requirements
445
446Paradoxically, building the JDK requires a pre-existing JDK. This is called the
447"boot JDK". The boot JDK does not, however, have to be a JDK built directly from
448the source code available in the OpenJDK Community.  If you are porting the JDK
449to a new platform, chances are that there already exists another JDK for that
450platform that is usable as boot JDK.
451
452The rule of thumb is that the boot JDK for building JDK major version *N*
453should be a JDK of major version *N-1*, so for building JDK 9 a JDK 8 would be
454suitable as boot JDK. However, the JDK should be able to "build itself", so an
455up-to-date build of the current JDK source is an acceptable alternative. If
456you are following the *N-1* rule, make sure you've got the latest update
457version, since JDK 8 GA might not be able to build JDK 9 on all platforms.
458
459Early in the release cycle, version *N-1* may not yet have been released. In
460that case, the preferred boot JDK will be version *N-2* until version *N-1*
461is available.
462
463If the boot JDK is not automatically detected, or the wrong JDK is picked, use
464`--with-boot-jdk` to point to the JDK to use.
465
466### Getting JDK binaries
467
468JDK binaries for Linux, Windows and macOS can be downloaded from
469[jdk.java.net](http://jdk.java.net). An alternative is to download the
470[Oracle JDK](http://www.oracle.com/technetwork/java/javase/downloads). Another
471is the [Adopt OpenJDK Project](https://adoptopenjdk.net/), which publishes
472experimental prebuilt binaries for various platforms.
473
474On Linux you can also get a JDK from the Linux distribution. On apt-based
475distros (like Debian and Ubuntu), `sudo apt-get install openjdk-<VERSION>-jdk`
476is typically enough to install a JDK \<VERSION\>. On rpm-based distros (like
477Fedora and Red Hat), try `sudo yum install java-<VERSION>-openjdk-devel`.
478
479## External Library Requirements
480
481Different platforms require different external libraries. In general, libraries
482are not optional - that is, they are either required or not used.
483
484If a required library is not detected by `configure`, you need to provide the
485path to it. There are two forms of the `configure` arguments to point to an
486external library: `--with-<LIB>=<path>` or `--with-<LIB>-include=<path to
487include> --with-<LIB>-lib=<path to lib>`. The first variant is more concise,
488but require the include files and library files to reside in a default
489hierarchy under this directory. In most cases, it works fine.
490
491As a fallback, the second version allows you to point to the include directory
492and the lib directory separately.
493
494### FreeType
495
496FreeType2 from [The FreeType Project](http://www.freetype.org/) is not required
497on any platform. The exception is on Unix-based platforms when configuring such
498that the build artifacts will reference a system installed library,
499rather than bundling the JDK's own copy.
500
501  * To install on an apt-based Linux, try running `sudo apt-get install
502    libfreetype6-dev`.
503  * To install on an rpm-based Linux, try running `sudo yum install
504    freetype-devel`.
505  * To install on Solaris, try running `pkg install system/library/freetype-2`.
506
507Use `--with-freetype-include=<path>` and `--with-freetype-lib=<path>`
508if `configure` does not automatically locate the platform FreeType files.
509
510### CUPS
511
512CUPS, [Common UNIX Printing System](http://www.cups.org) header files are
513required on all platforms, except Windows. Often these files are provided by
514your operating system.
515
516  * To install on an apt-based Linux, try running `sudo apt-get install
517    libcups2-dev`.
518  * To install on an rpm-based Linux, try running `sudo yum install
519    cups-devel`.
520  * To install on Solaris, try running `pkg install print/cups`.
521
522Use `--with-cups=<path>` if `configure` does not properly locate your CUPS
523files.
524
525### X11
526
527Certain [X11](http://www.x.org/) libraries and include files are required on
528Linux and Solaris.
529
530  * To install on an apt-based Linux, try running `sudo apt-get install
531    libx11-dev libxext-dev libxrender-dev libxrandr-dev libxtst-dev libxt-dev`.
532  * To install on an rpm-based Linux, try running `sudo yum install
533    libXtst-devel libXt-devel libXrender-devel libXrandr-devel libXi-devel`.
534  * To install on Solaris, try running `pkg install x11/header/x11-protocols
535    x11/library/libice x11/library/libpthread-stubs x11/library/libsm
536    x11/library/libx11 x11/library/libxau x11/library/libxcb
537    x11/library/libxdmcp x11/library/libxevie x11/library/libxext
538    x11/library/libxrender x11/library/libxrandr x11/library/libxscrnsaver
539    x11/library/libxtst x11/library/toolkit/libxt`.
540
541Use `--with-x=<path>` if `configure` does not properly locate your X11 files.
542
543### ALSA
544
545ALSA, [Advanced Linux Sound Architecture](https://www.alsa-project.org/) is
546required on Linux. At least version 0.9.1 of ALSA is required.
547
548  * To install on an apt-based Linux, try running `sudo apt-get install
549    libasound2-dev`.
550  * To install on an rpm-based Linux, try running `sudo yum install
551    alsa-lib-devel`.
552
553Use `--with-alsa=<path>` if `configure` does not properly locate your ALSA
554files.
555
556### libffi
557
558libffi, the [Portable Foreign Function Interface Library](
559http://sourceware.org/libffi) is required when building the Zero version of
560Hotspot.
561
562  * To install on an apt-based Linux, try running `sudo apt-get install
563    libffi-dev`.
564  * To install on an rpm-based Linux, try running `sudo yum install
565    libffi-devel`.
566
567Use `--with-libffi=<path>` if `configure` does not properly locate your libffi
568files.
569
570## Build Tools Requirements
571
572### Autoconf
573
574The JDK requires [Autoconf](http://www.gnu.org/software/autoconf) on all
575platforms. At least version 2.69 is required.
576
577  * To install on an apt-based Linux, try running `sudo apt-get install
578    autoconf`.
579  * To install on an rpm-based Linux, try running `sudo yum install
580    autoconf`.
581  * To install on macOS, try running `brew install autoconf`.
582  * To install on Windows, try running `<path to Cygwin setup>/setup-x86_64 -q
583    -P autoconf`.
584
585If `configure` has problems locating your installation of autoconf, you can
586specify it using the `AUTOCONF` environment variable, like this:
587
588```
589AUTOCONF=<path to autoconf> configure ...
590```
591
592### GNU Make
593
594The JDK requires [GNU Make](http://www.gnu.org/software/make). No other flavors
595of make are supported.
596
597At least version 3.81 of GNU Make must be used. For distributions supporting
598GNU Make 4.0 or above, we strongly recommend it. GNU Make 4.0 contains useful
599functionality to handle parallel building (supported by `--with-output-sync`)
600and speed and stability improvements.
601
602Note that `configure` locates and verifies a properly functioning version of
603`make` and stores the path to this `make` binary in the configuration. If you
604start a build using `make` on the command line, you will be using the version
605of make found first in your `PATH`, and not necessarily the one stored in the
606configuration. This initial make will be used as "bootstrap make", and in a
607second stage, the make located by `configure` will be called. Normally, this
608will present no issues, but if you have a very old `make`, or a non-GNU Make
609`make` in your path, this might cause issues.
610
611If you want to override the default make found by `configure`, use the `MAKE`
612configure variable, e.g. `configure MAKE=/opt/gnu/make`.
613
614On Solaris, it is common to call the GNU version of make by using `gmake`.
615
616### GNU Bash
617
618The JDK requires [GNU Bash](http://www.gnu.org/software/bash). No other shells
619are supported.
620
621At least version 3.2 of GNU Bash must be used.
622
623## Running Configure
624
625To build the JDK, you need a "configuration", which consists of a directory
626where to store the build output, coupled with information about the platform,
627the specific build machine, and choices that affect how the JDK is built.
628
629The configuration is created by the `configure` script. The basic invocation of
630the `configure` script looks like this:
631
632```
633bash configure [options]
634```
635
636This will create an output directory containing the configuration and setup an
637area for the build result. This directory typically looks like
638`build/linux-x64-server-release`, but the actual name depends on your specific
639configuration. (It can also be set directly, see [Using Multiple
640Configurations](#using-multiple-configurations)). This directory is referred to
641as `$BUILD` in this documentation.
642
643`configure` will try to figure out what system you are running on and where all
644necessary build components are. If you have all prerequisites for building
645installed, it should find everything. If it fails to detect any component
646automatically, it will exit and inform you about the problem.
647
648Some command line examples:
649
650  * Create a 32-bit build for Windows with FreeType2 in `C:\freetype-i586`:
651    ```
652    bash configure --with-freetype=/cygdrive/c/freetype-i586 --with-target-bits=32
653    ```
654
655  * Create a debug build with the `server` JVM and DTrace enabled:
656    ```
657    bash configure --enable-debug --with-jvm-variants=server --enable-dtrace
658    ```
659
660### Common Configure Arguments
661
662Here follows some of the most common and important `configure` argument.
663
664To get up-to-date information on *all* available `configure` argument, please
665run:
666```
667bash configure --help
668```
669
670(Note that this help text also include general autoconf options, like
671`--dvidir`, that is not relevant to the JDK. To list only JDK-specific
672features, use `bash configure --help=short` instead.)
673
674#### Configure Arguments for Tailoring the Build
675
676  * `--enable-debug` - Set the debug level to `fastdebug` (this is a shorthand
677    for `--with-debug-level=fastdebug`)
678  * `--with-debug-level=<level>` - Set the debug level, which can be `release`,
679    `fastdebug`, `slowdebug` or `optimized`. Default is `release`. `optimized`
680    is variant of `release` with additional Hotspot debug code.
681  * `--with-native-debug-symbols=<method>` - Specify if and how native debug
682    symbols should be built. Available methods are `none`, `internal`,
683    `external`, `zipped`. Default behavior depends on platform. See [Native
684    Debug Symbols](#native-debug-symbols) for more details.
685  * `--with-version-string=<string>` - Specify the version string this build
686    will be identified with.
687  * `--with-version-<part>=<value>` - A group of options, where `<part>` can be
688    any of `pre`, `opt`, `build`, `major`, `minor`, `security` or `patch`. Use
689    these options to modify just the corresponding part of the version string
690    from the default, or the value provided by `--with-version-string`.
691  * `--with-jvm-variants=<variant>[,<variant>...]` - Build the specified variant
692    (or variants) of Hotspot. Valid variants are: `server`, `client`,
693    `minimal`, `core`, `zero`, `custom`. Note that not all
694    variants are possible to combine in a single build.
695  * `--with-jvm-features=<feature>[,<feature>...]` - Use the specified JVM
696    features when building Hotspot. The list of features will be enabled on top
697    of the default list. For the `custom` JVM variant, this default list is
698    empty. A complete list of available JVM features can be found using `bash
699    configure --help`.
700  * `--with-target-bits=<bits>` - Create a target binary suitable for running
701    on a `<bits>` platform. Use this to create 32-bit output on a 64-bit build
702    platform, instead of doing a full cross-compile. (This is known as a
703    *reduced* build.)
704
705On Linux, BSD and AIX, it is possible to override where Java by default
706searches for runtime/JNI libraries. This can be useful in situations where
707there is a special shared directory for system JNI libraries. This setting
708can in turn be overriden at runtime by setting the `java.library.path` property.
709
710  * `--with-jni-libpath=<path>` - Use the specified path as a default
711  when searching for runtime libraries.
712
713#### Configure Arguments for Native Compilation
714
715  * `--with-devkit=<path>` - Use this devkit for compilers, tools and resources
716  * `--with-sysroot=<path>` - Use this directory as sysroot
717  * `--with-extra-path=<path>[;<path>]` - Prepend these directories to the
718    default path when searching for all kinds of binaries
719  * `--with-toolchain-path=<path>[;<path>]` - Prepend these directories when
720    searching for toolchain binaries (compilers etc)
721  * `--with-extra-cflags=<flags>` - Append these flags when compiling JDK C
722    files
723  * `--with-extra-cxxflags=<flags>` - Append these flags when compiling JDK C++
724    files
725  * `--with-extra-ldflags=<flags>` - Append these flags when linking JDK
726    libraries
727
728#### Configure Arguments for External Dependencies
729
730  * `--with-boot-jdk=<path>` - Set the path to the [Boot JDK](
731    #boot-jdk-requirements)
732  * `--with-freetype=<path>` - Set the path to [FreeType](#freetype)
733  * `--with-cups=<path>` - Set the path to [CUPS](#cups)
734  * `--with-x=<path>` - Set the path to [X11](#x11)
735  * `--with-alsa=<path>` - Set the path to [ALSA](#alsa)
736  * `--with-libffi=<path>` - Set the path to [libffi](#libffi)
737  * `--with-jtreg=<path>` - Set the path to JTReg. See [Running Tests](
738    #running-tests)
739
740Certain third-party libraries used by the JDK (libjpeg, giflib, libpng, lcms
741and zlib) are included in the JDK repository. The default behavior of the
742JDK build is to use the included ("bundled") versions of libjpeg, giflib,
743libpng and lcms.
744For zlib, the system lib (if present) is used except on Windows and AIX.
745However the bundled libraries may be replaced by an external version.
746To do so, specify `system` as the `<source>` option in these arguments.
747(The default is `bundled`).
748
749  * `--with-libjpeg=<source>` - Use the specified source for libjpeg
750  * `--with-giflib=<source>` - Use the specified source for giflib
751  * `--with-libpng=<source>` - Use the specified source for libpng
752  * `--with-lcms=<source>` - Use the specified source for lcms
753  * `--with-zlib=<source>` - Use the specified source for zlib
754
755On Linux, it is possible to select either static or dynamic linking of the C++
756runtime. The default is static linking, with dynamic linking as fallback if the
757static library is not found.
758
759  * `--with-stdc++lib=<method>` - Use the specified method (`static`, `dynamic`
760    or `default`) for linking the C++ runtime.
761
762### Configure Control Variables
763
764It is possible to control certain aspects of `configure` by overriding the
765value of `configure` variables, either on the command line or in the
766environment.
767
768Normally, this is **not recommended**. If used improperly, it can lead to a
769broken configuration. Unless you're well versed in the build system, this is
770hard to use properly. Therefore, `configure` will print a warning if this is
771detected.
772
773However, there are a few `configure` variables, known as *control variables*
774that are supposed to be overriden on the command line. These are variables that
775describe the location of tools needed by the build, like `MAKE` or `GREP`. If
776any such variable is specified, `configure` will use that value instead of
777trying to autodetect the tool. For instance, `bash configure
778MAKE=/opt/gnumake4.0/bin/make`.
779
780If a configure argument exists, use that instead, e.g. use `--with-jtreg`
781instead of setting `JTREGEXE`.
782
783Also note that, despite what autoconf claims, setting `CFLAGS` will not
784accomplish anything. Instead use `--with-extra-cflags` (and similar for
785`cxxflags` and `ldflags`).
786
787## Running Make
788
789When you have a proper configuration, all you need to do to build the JDK is to
790run `make`. (But see the warning at [GNU Make](#gnu-make) about running the
791correct version of make.)
792
793When running `make` without any arguments, the default target is used, which is
794the same as running `make default` or `make jdk`. This will build a minimal (or
795roughly minimal) set of compiled output (known as an "exploded image") needed
796for a developer to actually execute the newly built JDK. The idea is that in an
797incremental development fashion, when doing a normal make, you should only
798spend time recompiling what's changed (making it purely incremental) and only
799do the work that's needed to actually run and test your code.
800
801The output of the exploded image resides in `$BUILD/jdk`. You can test the
802newly built JDK like this: `$BUILD/jdk/bin/java -version`.
803
804### Common Make Targets
805
806Apart from the default target, here are some common make targets:
807
808  * `hotspot` - Build all of hotspot (but only hotspot)
809  * `hotspot-<variant>` - Build just the specified jvm variant
810  * `images` or `product-images` - Build the JDK image
811  * `docs` or `docs-image` - Build the documentation image
812  * `test-image` - Build the test image
813  * `all` or `all-images` - Build all images (product, docs and test)
814  * `bootcycle-images` - Build images twice, second time with newly built JDK
815    (good for testing)
816  * `clean` - Remove all files generated by make, but not those generated by
817    configure
818  * `dist-clean` - Remove all files, including configuration
819
820Run `make help` to get an up-to-date list of important make targets and make
821control variables.
822
823It is possible to build just a single module, a single phase, or a single phase
824of a single module, by creating make targets according to these followin
825patterns. A phase can be either of `gensrc`, `gendata`, `copy`, `java`,
826`launchers`, `libs` or `rmic`. See [Using Fine-Grained Make Targets](
827#using-fine-grained-make-targets) for more details about this functionality.
828
829  * `<phase>` - Build the specified phase and everything it depends on
830  * `<module>` - Build the specified module and everything it depends on
831  * `<module>-<phase>` - Compile the specified phase for the specified module
832    and everything it depends on
833
834Similarly, it is possible to clean just a part of the build by creating make
835targets according to these patterns:
836
837  * `clean-<outputdir>` - Remove the subdir in the output dir with the name
838  * `clean-<phase>` - Remove all build results related to a certain build
839    phase
840  * `clean-<module>` - Remove all build results related to a certain module
841  * `clean-<module>-<phase>` - Remove all build results related to a certain
842    module and phase
843
844### Make Control Variables
845
846It is possible to control `make` behavior by overriding the value of `make`
847variables, either on the command line or in the environment.
848
849Normally, this is **not recommended**. If used improperly, it can lead to a
850broken build. Unless you're well versed in the build system, this is hard to
851use properly. Therefore, `make` will print a warning if this is detected.
852
853However, there are a few `make` variables, known as *control variables* that
854are supposed to be overriden on the command line. These make up the "make time"
855configuration, as opposed to the "configure time" configuration.
856
857#### General Make Control Variables
858
859  * `JOBS` - Specify the number of jobs to build with. See [Build
860    Performance](#build-performance).
861  * `LOG` - Specify the logging level and functionality. See [Checking the
862    Build Log File](#checking-the-build-log-file)
863  * `CONF` and `CONF_NAME` - Selecting the configuration(s) to use. See [Using
864    Multiple Configurations](#using-multiple-configurations)
865
866#### Test Make Control Variables
867
868These make control variables only make sense when running tests. Please see
869[Testing the JDK](testing.html) for details.
870
871  * `TEST`
872  * `TEST_JOBS`
873  * `JTREG`
874  * `GTEST`
875
876#### Advanced Make Control Variables
877
878These advanced make control variables can be potentially unsafe. See [Hints and
879Suggestions for Advanced Users](#hints-and-suggestions-for-advanced-users) and
880[Understanding the Build System](#understanding-the-build-system) for details.
881
882  * `SPEC`
883  * `CONF_CHECK`
884  * `COMPARE_BUILD`
885  * `JDK_FILTER`
886
887## Running Tests
888
889Most of the JDK tests are using the [JTReg](http://openjdk.java.net/jtreg)
890test framework. Make sure that your configuration knows where to find your
891installation of JTReg. If this is not picked up automatically, use the
892`--with-jtreg=<path to jtreg home>` option to point to the JTReg framework.
893Note that this option should point to the JTReg home, i.e. the top directory,
894containing `lib/jtreg.jar` etc.
895
896The [Adoption Group](https://wiki.openjdk.java.net/display/Adoption) provides
897recent builds of jtreg [here](
898https://adopt-openjdk.ci.cloudbees.com/job/jtreg/lastSuccessfulBuild/artifact).
899Download the latest `.tar.gz` file, unpack it, and point `--with-jtreg` to the
900`jtreg` directory that you just unpacked.
901
902To execute the most basic tests (tier 1), use:
903```
904make run-test-tier1
905```
906
907For more details on how to run tests, please see the [Testing
908the JDK](testing.html) document.
909
910## Cross-compiling
911
912Cross-compiling means using one platform (the *build* platform) to generate
913output that can ran on another platform (the *target* platform).
914
915The typical reason for cross-compiling is that the build is performed on a more
916powerful desktop computer, but the resulting binaries will be able to run on a
917different, typically low-performing system. Most of the complications that
918arise when building for embedded is due to this separation of *build* and
919*target* systems.
920
921This requires a more complex setup and build procedure. This section assumes
922you are familiar with cross-compiling in general, and will only deal with the
923particularities of cross-compiling the JDK. If you are new to cross-compiling,
924please see the [external links at Wikipedia](
925https://en.wikipedia.org/wiki/Cross_compiler#External_links) for a good start
926on reading materials.
927
928Cross-compiling the JDK requires you to be able to build both for the build
929platform and for the target platform. The reason for the former is that we need
930to build and execute tools during the build process, both native tools and Java
931tools.
932
933If all you want to do is to compile a 32-bit version, for the same OS, on a
93464-bit machine, consider using `--with-target-bits=32` instead of doing a
935full-blown cross-compilation. (While this surely is possible, it's a lot more
936work and will take much longer to build.)
937
938### Cross compiling the easy way with OpenJDK devkits
939
940The OpenJDK build system provides out-of-the box support for creating and using
941so called devkits. A `devkit` is basically a collection of a cross-compiling
942toolchain and a sysroot environment which can easily be used together with the
943`--with-devkit` configure option to cross compile the OpenJDK. On Linux/x86_64,
944the following command:
945```
946bash configure --with-devkit=<devkit-path> --openjdk-target=ppc64-linux-gnu && make
947```
948
949will configure and build OpenJDK for Linux/ppc64 assuming that `<devkit-path>`
950points to a Linux/x86_64 to Linux/ppc64 devkit.
951
952Devkits can be created from the `make/devkit` directory by executing:
953```
954make [ TARGETS="<TARGET_TRIPLET>+" ] [ BASE_OS=<OS> ] [ BASE_OS_VERSION=<VER> ]
955```
956
957where `TARGETS` contains one or more `TARGET_TRIPLET`s of the form
958described in [section 3.4 of the GNU Autobook](
959https://sourceware.org/autobook/autobook/autobook_17.html). If no
960targets are given, a native toolchain for the current platform will be
961created. Currently, at least the following targets are known to work:
962
963 Supported devkit targets
964 -------------------------
965 x86_64-linux-gnu
966 aarch64-linux-gnu
967 arm-linux-gnueabihf
968 ppc64-linux-gnu
969 ppc64le-linux-gnu
970 s390x-linux-gnu
971
972`BASE_OS` must be one of "OEL6" for Oracle Enterprise Linux 6 or
973"Fedora" (if not specified "OEL6" will be the default). If the base OS
974is "Fedora" the corresponding Fedora release can be specified with the
975help of the `BASE_OS_VERSION` option (with "27" as default version).
976If the build is successful, the new devkits can be found in the
977`build/devkit/result` subdirectory:
978```
979cd make/devkit
980make TARGETS="ppc64le-linux-gnu aarch64-linux-gnu" BASE_OS=Fedora BASE_OS_VERSION=21
981ls -1 ../../build/devkit/result/
982x86_64-linux-gnu-to-aarch64-linux-gnu
983x86_64-linux-gnu-to-ppc64le-linux-gnu
984```
985
986Notice that devkits are not only useful for targeting different build
987platforms. Because they contain the full build dependencies for a
988system (i.e. compiler and root file system), they can easily be used
989to build well-known, reliable and reproducible build environments. You
990can for example create and use a devkit with GCC 7.3 and a Fedora 12
991sysroot environment (with glibc 2.11) on Ubuntu 14.04 (which doesn't
992have GCC 7.3 by default) to produce OpenJDK binaries which will run on
993all Linux systems with runtime libraries newer than the ones from
994Fedora 12 (e.g. Ubuntu 16.04, SLES 11 or RHEL 6).
995
996### Boot JDK and Build JDK
997
998When cross-compiling, make sure you use a boot JDK that runs on the *build*
999system, and not on the *target* system.
1000
1001To be able to build, we need a "Build JDK", which is a JDK built from the
1002current sources (that is, the same as the end result of the entire build
1003process), but able to run on the *build* system, and not the *target* system.
1004(In contrast, the Boot JDK should be from an older release, e.g. JDK 8 when
1005building JDK 9.)
1006
1007The build process will create a minimal Build JDK for you, as part of building.
1008To speed up the build, you can use `--with-build-jdk` to `configure` to point
1009to a pre-built Build JDK. Please note that the build result is unpredictable,
1010and can possibly break in subtle ways, if the Build JDK does not **exactly**
1011match the current sources.
1012
1013### Specifying the Target Platform
1014
1015You *must* specify the target platform when cross-compiling. Doing so will also
1016automatically turn the build into a cross-compiling mode. The simplest way to
1017do this is to use the `--openjdk-target` argument, e.g.
1018`--openjdk-target=arm-linux-gnueabihf`. or `--openjdk-target=aarch64-oe-linux`.
1019This will automatically set the `--build`, `--host` and `--target` options for
1020autoconf, which can otherwise be confusing. (In autoconf terminology, the
1021"target" is known as "host", and "target" is used for building a Canadian
1022cross-compiler.)
1023
1024### Toolchain Considerations
1025
1026You will need two copies of your toolchain, one which generates output that can
1027run on the target system (the normal, or *target*, toolchain), and one that
1028generates output that can run on the build system (the *build* toolchain). Note
1029that cross-compiling is only supported for gcc at the time being. The gcc
1030standard is to prefix cross-compiling toolchains with the target denominator.
1031If you follow this standard, `configure` is likely to pick up the toolchain
1032correctly.
1033
1034The *build* toolchain will be autodetected just the same way the normal
1035*build*/*target* toolchain will be autodetected when not cross-compiling. If
1036this is not what you want, or if the autodetection fails, you can specify a
1037devkit containing the *build* toolchain using `--with-build-devkit` to
1038`configure`, or by giving `BUILD_CC` and `BUILD_CXX` arguments.
1039
1040It is often helpful to locate the cross-compilation tools, headers and
1041libraries in a separate directory, outside the normal path, and point out that
1042directory to `configure`. Do this by setting the sysroot (`--with-sysroot`) and
1043appending the directory when searching for cross-compilations tools
1044(`--with-toolchain-path`). As a compact form, you can also use `--with-devkit`
1045to point to a single directory, if it is correctly setup. (See `basics.m4` for
1046details.)
1047
1048If you are unsure what toolchain and versions to use, these have been proved
1049working at the time of writing:
1050
1051  * [aarch64](
1052https://releases.linaro.org/archive/13.11/components/toolchain/binaries/gcc-linaro-aarch64-linux-gnu-4.8-2013.11_linux.tar.xz)
1053  * [arm 32-bit hardware floating  point](
1054https://launchpad.net/linaro-toolchain-unsupported/trunk/2012.09/+download/gcc-linaro-arm-linux-gnueabihf-raspbian-2012.09-20120921_linux.tar.bz2)
1055
1056### Native Libraries
1057
1058You will need copies of external native libraries for the *target* system,
1059present on the *build* machine while building.
1060
1061Take care not to replace the *build* system's version of these libraries by
1062mistake, since that can render the *build* machine unusable.
1063
1064Make sure that the libraries you point to (ALSA, X11, etc) are for the
1065*target*, not the *build*, platform.
1066
1067#### ALSA
1068
1069You will need alsa libraries suitable for your *target* system. For most cases,
1070using Debian's pre-built libraries work fine.
1071
1072Note that alsa is needed even if you only want to build a headless JDK.
1073
1074  * Go to [Debian Package Search](https://www.debian.org/distrib/packages) and
1075    search for the `libasound2` and `libasound2-dev` packages for your *target*
1076    system. Download them to /tmp.
1077
1078  * Install the libraries into the cross-compilation toolchain. For instance:
1079```
1080cd /tools/gcc-linaro-arm-linux-gnueabihf-raspbian-2012.09-20120921_linux/arm-linux-gnueabihf/libc
1081dpkg-deb -x /tmp/libasound2_1.0.25-4_armhf.deb .
1082dpkg-deb -x /tmp/libasound2-dev_1.0.25-4_armhf.deb .
1083```
1084
1085  * If alsa is not properly detected by `configure`, you can point it out by
1086    `--with-alsa`.
1087
1088#### X11
1089
1090You will need X11 libraries suitable for your *target* system. For most cases,
1091using Debian's pre-built libraries work fine.
1092
1093Note that X11 is needed even if you only want to build a headless JDK.
1094
1095  * Go to [Debian Package Search](https://www.debian.org/distrib/packages),
1096    search for the following packages for your *target* system, and download them
1097    to /tmp/target-x11:
1098      * libxi
1099      * libxi-dev
1100      * x11proto-core-dev
1101      * x11proto-input-dev
1102      * x11proto-kb-dev
1103      * x11proto-render-dev
1104      * x11proto-xext-dev
1105      * libice-dev
1106      * libxrender
1107      * libxrender-dev
1108      * libxrandr-dev
1109      * libsm-dev
1110      * libxt-dev
1111      * libx11
1112      * libx11-dev
1113      * libxtst
1114      * libxtst-dev
1115      * libxext
1116      * libxext-dev
1117
1118  * Install the libraries into the cross-compilation toolchain. For instance:
1119    ```
1120    cd /tools/gcc-linaro-arm-linux-gnueabihf-raspbian-2012.09-20120921_linux/arm-linux-gnueabihf/libc/usr
1121    mkdir X11R6
1122    cd X11R6
1123    for deb in /tmp/target-x11/*.deb ; do dpkg-deb -x $deb . ; done
1124    mv usr/* .
1125    cd lib
1126    cp arm-linux-gnueabihf/* .
1127    ```
1128
1129    You can ignore the following messages. These libraries are not needed to
1130    successfully complete a full JDK build.
1131    ```
1132    cp: cannot stat `arm-linux-gnueabihf/libICE.so': No such file or directory
1133    cp: cannot stat `arm-linux-gnueabihf/libSM.so': No such file or directory
1134    cp: cannot stat `arm-linux-gnueabihf/libXt.so': No such file or directory
1135    ```
1136
1137  * If the X11 libraries are not properly detected by `configure`, you can
1138    point them out by `--with-x`.
1139
1140### Creating And Using Sysroots With qemu-deboostrap
1141
1142Fortunately, you can create sysroots for foreign architectures with tools
1143provided by your OS. On Debian/Ubuntu systems, one could use `qemu-deboostrap` to
1144create the *target* system chroot, which would have the native libraries and headers
1145specific to that *target* system. After that, we can use the cross-compiler on the *build*
1146system, pointing into chroot to get the build dependencies right. This allows building
1147for foreign architectures with native compilation speed.
1148
1149For example, cross-compiling to AArch64 from x86_64 could be done like this:
1150
1151  * Install cross-compiler on the *build* system:
1152```
1153apt install g++-aarch64-linux-gnu gcc-aarch64-linux-gnu
1154```
1155
1156  * Create chroot on the *build* system, configuring it for *target* system:
1157```
1158sudo qemu-debootstrap --arch=arm64 --verbose \
1159       --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 \
1160       --resolve-deps jessie /chroots/arm64 http://httpredir.debian.org/debian/
1161```
1162
1163  * Configure and build with newly created chroot as sysroot/toolchain-path:
1164```
1165CC=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/
1166make images
1167ls build/linux-aarch64-normal-server-release/
1168```
1169
1170The build does not create new files in that chroot, so it can be reused for multiple builds
1171without additional cleanup.
1172
1173Architectures that are known to successfully cross-compile like this are:
1174
1175  Target        `CC`                      `CXX`                       `--arch=...`  `--openjdk-target=...`
1176  ------------  ------------------------- --------------------------- ------------- -----------------------
1177  x86           default                   default                     i386          i386-linux-gnu
1178  armhf         gcc-arm-linux-gnueabihf   g++-arm-linux-gnueabihf     armhf         arm-linux-gnueabihf
1179  aarch64       gcc-aarch64-linux-gnu     g++-aarch64-linux-gnu       arm64         aarch64-linux-gnu
1180  ppc64el       gcc-powerpc64le-linux-gnu g++-powerpc64le-linux-gnu   ppc64el       powerpc64le-linux-gnu
1181  s390x         gcc-s390x-linux-gnu       g++-s390x-linux-gnu         s390x         s390x-linux-gnu
1182
1183Additional architectures might be supported by Debian/Ubuntu Ports.
1184
1185### Building for ARM/aarch64
1186
1187A common cross-compilation target is the ARM CPU. When building for ARM, it is
1188useful to set the ABI profile. A number of pre-defined ABI profiles are
1189available using `--with-abi-profile`: arm-vfp-sflt, arm-vfp-hflt, arm-sflt,
1190armv5-vfp-sflt, armv6-vfp-hflt. Note that soft-float ABIs are no longer
1191properly supported by the JDK.
1192
1193### Verifying the Build
1194
1195The build will end up in a directory named like
1196`build/linux-arm-normal-server-release`.
1197
1198Inside this build output directory, the `images/jdk` will contain the newly
1199built JDK, for your *target* system.
1200
1201Copy these folders to your *target* system. Then you can run e.g.
1202`images/jdk/bin/java -version`.
1203
1204## Build Performance
1205
1206Building the JDK requires a lot of horsepower. Some of the build tools can be
1207adjusted to utilize more or less of resources such as parallel threads and
1208memory. The `configure` script analyzes your system and selects reasonable
1209values for such options based on your hardware. If you encounter resource
1210problems, such as out of memory conditions, you can modify the detected values
1211with:
1212
1213  * `--with-num-cores` -- number of cores in the build system, e.g.
1214    `--with-num-cores=8`.
1215
1216  * `--with-memory-size` -- memory (in MB) available in the build system, e.g.
1217    `--with-memory-size=1024`
1218
1219You can also specify directly the number of build jobs to use with
1220`--with-jobs=N` to `configure`, or `JOBS=N` to `make`. Do not use the `-j` flag
1221to `make`. In most cases it will be ignored by the makefiles, but it can cause
1222problems for some make targets.
1223
1224It might also be necessary to specify the JVM arguments passed to the Boot JDK,
1225using e.g. `--with-boot-jdk-jvmargs="-Xmx8G"`. Doing so will override the
1226default JVM arguments passed to the Boot JDK.
1227
1228At the end of a successful execution of `configure`, you will get a performance
1229summary, indicating how well the build will perform. Here you will also get
1230performance hints. If you want to build fast, pay attention to those!
1231
1232If you want to tweak build performance, run with `make LOG=info` to get a build
1233time summary at the end of the build process.
1234
1235### Disk Speed
1236
1237If you are using network shares, e.g. via NFS, for your source code, make sure
1238the build directory is situated on local disk (e.g. by `ln -s
1239/localdisk/jdk-build $JDK-SHARE/build`). The performance penalty is extremely
1240high for building on a network share; close to unusable.
1241
1242Also, make sure that your build tools (including Boot JDK and toolchain) is
1243located on a local disk and not a network share.
1244
1245As has been stressed elsewhere, do use SSD for source code and build directory,
1246as well as (if possible) the build tools.
1247
1248### Virus Checking
1249
1250The use of virus checking software, especially on Windows, can *significantly*
1251slow down building of the JDK. If possible, turn off such software, or exclude
1252the directory containing the JDK source code from on-the-fly checking.
1253
1254### Ccache
1255
1256The JDK build supports building with ccache when using gcc or clang. Using
1257ccache can radically speed up compilation of native code if you often rebuild
1258the same sources. Your milage may vary however, so we recommend evaluating it
1259for yourself. To enable it, make sure it's on the path and configure with
1260`--enable-ccache`.
1261
1262### Precompiled Headers
1263
1264By default, the Hotspot build uses preccompiled headers (PCH) on the toolchains
1265were it is properly supported (clang, gcc, and Visual Studio). Normally, this
1266speeds up the build process, but in some circumstances, it can actually slow
1267things down.
1268
1269You can experiment by disabling precompiled headers using
1270`--disable-precompiled-headers`.
1271
1272### Icecc / icecream
1273
1274[icecc/icecream](http://github.com/icecc/icecream) is a simple way to setup a
1275distributed compiler network. If you have multiple machines available for
1276building the JDK, you can drastically cut individual build times by utilizing
1277it.
1278
1279To use, setup an icecc network, and install icecc on the build machine. Then
1280run `configure` using `--enable-icecc`.
1281
1282### Using sjavac
1283
1284To speed up Java compilation, especially incremental compilations, you can try
1285the experimental sjavac compiler by using `--enable-sjavac`.
1286
1287### Building the Right Target
1288
1289Selecting the proper target to build can have dramatic impact on build time.
1290For normal usage, `jdk` or the default target is just fine. You only need to
1291build `images` for shipping, or if your tests require it.
1292
1293See also [Using Fine-Grained Make Targets](#using-fine-grained-make-targets) on
1294how to build an even smaller subset of the product.
1295
1296## Troubleshooting
1297
1298If your build fails, it can sometimes be difficult to pinpoint the problem or
1299find a proper solution.
1300
1301### Locating the Source of the Error
1302
1303When a build fails, it can be hard to pinpoint the actual cause of the error.
1304In a typical build process, different parts of the product build in parallel,
1305with the output interlaced.
1306
1307#### Build Failure Summary
1308
1309To help you, the build system will print a failure summary at the end. It looks
1310like this:
1311
1312```
1313ERROR: Build failed for target 'hotspot' in configuration 'linux-x64' (exit code 2)
1314
1315=== Output from failing command(s) repeated here ===
1316* For target hotspot_variant-server_libjvm_objs_psMemoryPool.o:
1317/localhome/git/jdk-sandbox/hotspot/src/share/vm/services/psMemoryPool.cpp:1:1: error: 'failhere' does not name a type
1318   ... (rest of output omitted)
1319
1320* All command lines available in /localhome/git/jdk-sandbox/build/linux-x64/make-support/failure-logs.
1321=== End of repeated output ===
1322
1323=== Make failed targets repeated here ===
1324lib/CompileJvm.gmk:207: recipe for target '/localhome/git/jdk-sandbox/build/linux-x64/hotspot/variant-server/libjvm/objs/psMemoryPool.o' failed
1325make/Main.gmk:263: recipe for target 'hotspot-server-libs' failed
1326=== End of repeated output ===
1327
1328Hint: Try searching the build log for the name of the first failed target.
1329Hint: If caused by a warning, try configure --disable-warnings-as-errors.
1330```
1331
1332Let's break it down! First, the selected configuration, and the top-level
1333target you entered on the command line that caused the failure is printed.
1334
1335Then, between the `Output from failing command(s) repeated here` and `End of
1336repeated output` the first lines of output (stdout and stderr) from the actual
1337failing command is repeated. In most cases, this is the error message that
1338caused the build to fail. If multiple commands were failing (this can happen in
1339a parallel build), output from all failed commands will be printed here.
1340
1341The path to the `failure-logs` directory is printed. In this file you will find
1342a `<target>.log` file that contains the output from this command in its
1343entirety, and also a `<target>.cmd`, which contain the complete command line
1344used for running this command. You can re-run the failing command by executing
1345`. <path to failure-logs>/<target>.cmd` in your shell.
1346
1347Another way to trace the failure is to follow the chain of make targets, from
1348top-level targets to individual file targets. Between `Make failed targets
1349repeated here` and `End of repeated output` the output from make showing this
1350chain is repeated. The first failed recipe will typically contain the full path
1351to the file in question that failed to compile. Following lines will show a
1352trace of make targets why we ended up trying to compile that file.
1353
1354Finally, some hints are given on how to locate the error in the complete log.
1355In this example, we would try searching the log file for "`psMemoryPool.o`".
1356Another way to quickly locate make errors in the log is to search for "`]
1357Error`" or "`***`".
1358
1359Note that the build failure summary will only help you if the issue was a
1360compilation failure or similar. If the problem is more esoteric, or is due to
1361errors in the build machinery, you will likely get empty output logs, and `No
1362indication of failed target found` instead of the make target chain.
1363
1364#### Checking the Build Log File
1365
1366The output (stdout and stderr) from the latest build is always stored in
1367`$BUILD/build.log`. The previous build log is stored as `build.log.old`. This
1368means that it is not necessary to redirect the build output yourself if you
1369want to process it.
1370
1371You can increase the verbosity of the log file, by the `LOG` control variable
1372to `make`. If you want to see the command lines used in compilations, use
1373`LOG=cmdlines`. To increase the general verbosity, use `LOG=info`, `LOG=debug`
1374or `LOG=trace`. Both of these can be combined with `cmdlines`, e.g.
1375`LOG=info,cmdlines`. The `debug` log level will show most shell commands
1376executed by make, and `trace` will show all. Beware that both these log levels
1377will produce a massive build log!
1378
1379### Fixing Unexpected Build Failures
1380
1381Most of the time, the build will fail due to incorrect changes in the source
1382code.
1383
1384Sometimes the build can fail with no apparent changes that have caused the
1385failure. If this is the first time you are building the JDK on this particular
1386computer, and the build fails, the problem is likely with your build
1387environment. But even if you have previously built the JDK with success, and it
1388now fails, your build environment might have changed (perhaps due to OS
1389upgrades or similar). But most likely, such failures are due to problems with
1390the incremental rebuild.
1391
1392#### Problems with the Build Environment
1393
1394Make sure your configuration is correct. Re-run `configure`, and look for any
1395warnings. Warnings that appear in the middle of the `configure` output is also
1396repeated at the end, after the summary. The entire log is stored in
1397`$BUILD/configure.log`.
1398
1399Verify that the summary at the end looks correct. Are you indeed using the Boot
1400JDK and native toolchain that you expect?
1401
1402By default, the JDK has a strict approach where warnings from the compiler is
1403considered errors which fail the build. For very new or very old compiler
1404versions, this can trigger new classes of warnings, which thus fails the build.
1405Run `configure` with `--disable-warnings-as-errors` to turn of this behavior.
1406(The warnings will still show, but not make the build fail.)
1407
1408#### Problems with Incremental Rebuilds
1409
1410Incremental rebuilds mean that when you modify part of the product, only the
1411affected parts get rebuilt. While this works great in most cases, and
1412significantly speed up the development process, from time to time complex
1413interdependencies will result in an incorrect build result. This is the most
1414common cause for unexpected build problems.
1415
1416Here are a suggested list of things to try if you are having unexpected build
1417problems. Each step requires more time than the one before, so try them in
1418order. Most issues will be solved at step 1 or 2.
1419
1420 1. Make sure your repository is up-to-date
1421
1422    Run `git pull origin master` to make sure you have the latest changes.
1423
1424 2. Clean build results
1425
1426    The simplest way to fix incremental rebuild issues is to run `make clean`.
1427    This will remove all build results, but not the configuration or any build
1428    system support artifacts. In most cases, this will solve build errors
1429    resulting from incremental build mismatches.
1430
1431 3. Completely clean the build directory.
1432
1433    If this does not work, the next step is to run `make dist-clean`, or
1434    removing the build output directory (`$BUILD`). This will clean all
1435    generated output, including your configuration. You will need to re-run
1436    `configure` after this step. A good idea is to run `make
1437    print-configuration` before running `make dist-clean`, as this will print
1438    your current `configure` command line. Here's a way to do this:
1439
1440    ```
1441    make print-configuration > current-configuration
1442    make dist-clean
1443    bash configure $(cat current-configuration)
1444    make
1445    ```
1446
1447 4. Re-clone the Git repository
1448
1449    Sometimes the Git repository gets in a state that causes the product
1450    to be un-buildable. In such a case, the simplest solution is often the
1451    "sledgehammer approach": delete the entire repository, and re-clone it.
1452    If you have local changes, save them first to a different location using
1453    `git format-patch`.
1454
1455### Specific Build Issues
1456
1457#### Clock Skew
1458
1459If you get an error message like this:
1460```
1461File 'xxx' has modification time in the future.
1462Clock skew detected. Your build may be incomplete.
1463```
1464then the clock on your build machine is out of sync with the timestamps on the
1465source files. Other errors, apparently unrelated but in fact caused by the
1466clock skew, can occur along with the clock skew warnings. These secondary
1467errors may tend to obscure the fact that the true root cause of the problem is
1468an out-of-sync clock.
1469
1470If you see these warnings, reset the clock on the build machine, run `make
1471clean` and restart the build.
1472
1473#### Out of Memory Errors
1474
1475On Solaris, you might get an error message like this:
1476```
1477Trouble writing out table to disk
1478```
1479To solve this, increase the amount of swap space on your build machine.
1480
1481On Windows, you might get error messages like this:
1482```
1483fatal error - couldn't allocate heap
1484cannot create ... Permission denied
1485spawn failed
1486```
1487This can be a sign of a Cygwin problem. See the information about solving
1488problems in the [Cygwin](#cygwin) section. Rebooting the computer might help
1489temporarily.
1490
1491### Getting Help
1492
1493If none of the suggestions in this document helps you, or if you find what you
1494believe is a bug in the build system, please contact the Build Group by sending
1495a mail to [build-dev@openjdk.java.net](mailto:build-dev@openjdk.java.net).
1496Please include the relevant parts of the configure and/or build log.
1497
1498If you need general help or advice about developing for the JDK, you can also
1499contact the Adoption Group. See the section on [Contributing to OpenJDK](
1500#contributing-to-openjdk) for more information.
1501
1502## Hints and Suggestions for Advanced Users
1503
1504### Bash Completion
1505
1506The `configure` and `make` commands tries to play nice with bash command-line
1507completion (using `<tab>` or `<tab><tab>`). To use this functionality, make
1508sure you enable completion in your `~/.bashrc` (see instructions for bash in
1509your operating system).
1510
1511Make completion will work out of the box, and will complete valid make targets.
1512For instance, typing `make jdk-i<tab>` will complete to `make jdk-image`.
1513
1514The `configure` script can get completion for options, but for this to work you
1515need to help `bash` on the way. The standard way of running the script, `bash
1516configure`, will not be understood by bash completion. You need `configure` to
1517be the command to run. One way to achieve this is to add a simple helper script
1518to your path:
1519
1520```
1521cat << EOT > /tmp/configure
1522#!/bin/bash
1523if [ \$(pwd) = \$(cd \$(dirname \$0); pwd) ] ; then
1524  echo >&2 "Abort: Trying to call configure helper recursively"
1525  exit 1
1526fi
1527
1528bash \$PWD/configure "\$@"
1529EOT
1530chmod +x /tmp/configure
1531sudo mv /tmp/configure /usr/local/bin
1532```
1533
1534Now `configure --en<tab>-dt<tab>` will result in `configure --enable-dtrace`.
1535
1536### Using Multiple Configurations
1537
1538You can have multiple configurations for a single source repository. When you
1539create a new configuration, run `configure --with-conf-name=<name>` to create a
1540configuration with the name `<name>`. Alternatively, you can create a directory
1541under `build` and run `configure` from there, e.g. `mkdir build/<name> && cd
1542build/<name> && bash ../../configure`.
1543
1544Then you can build that configuration using `make CONF_NAME=<name>` or `make
1545CONF=<pattern>`, where `<pattern>` is a substring matching one or several
1546configurations, e.g. `CONF=debug`. The special empty pattern (`CONF=`) will
1547match *all* available configuration, so `make CONF= hotspot` will build the
1548`hotspot` target for all configurations. Alternatively, you can execute `make`
1549in the configuration directory, e.g. `cd build/<name> && make`.
1550
1551### Handling Reconfigurations
1552
1553If you update the repository and part of the configure script has changed, the
1554build system will force you to re-run `configure`.
1555
1556Most of the time, you will be fine by running `configure` again with the same
1557arguments as the last time, which can easily be performed by `make
1558reconfigure`. To simplify this, you can use the `CONF_CHECK` make control
1559variable, either as `make CONF_CHECK=auto`, or by setting an environment
1560variable. For instance, if you add `export CONF_CHECK=auto` to your `.bashrc`
1561file, `make` will always run `reconfigure` automatically whenever the configure
1562script has changed.
1563
1564You can also use `CONF_CHECK=ignore` to skip the check for a needed configure
1565update. This might speed up the build, but comes at the risk of an incorrect
1566build result. This is only recommended if you know what you're doing.
1567
1568From time to time, you will also need to modify the command line to `configure`
1569due to changes. Use `make print-configure` to show the command line used for
1570your current configuration.
1571
1572### Using Fine-Grained Make Targets
1573
1574The default behavior for make is to create consistent and correct output, at
1575the expense of build speed, if necessary.
1576
1577If you are prepared to take some risk of an incorrect build, and know enough of
1578the system to understand how things build and interact, you can speed up the
1579build process considerably by instructing make to only build a portion of the
1580product.
1581
1582#### Building Individual Modules
1583
1584The safe way to use fine-grained make targets is to use the module specific
1585make targets. All source code in the JDK is organized so it belongs to a
1586module, e.g. `java.base` or `jdk.jdwp.agent`. You can build only a specific
1587module, by giving it as make target: `make jdk.jdwp.agent`. If the specified
1588module depends on other modules (e.g. `java.base`), those modules will be built
1589first.
1590
1591You can also specify a set of modules, just as you can always specify a set of
1592make targets: `make jdk.crypto.cryptoki jdk.crypto.ec jdk.crypto.mscapi
1593jdk.crypto.ucrypto`
1594
1595#### Building Individual Module Phases
1596
1597The build process for each module is divided into separate phases. Not all
1598modules need all phases. Which are needed depends on what kind of source code
1599and other artifact the module consists of. The phases are:
1600
1601  * `gensrc` (Generate source code to compile)
1602  * `gendata` (Generate non-source code artifacts)
1603  * `copy` (Copy resource artifacts)
1604  * `java` (Compile Java code)
1605  * `launchers` (Compile native executables)
1606  * `libs` (Compile native libraries)
1607  * `rmic` (Run the `rmic` tool)
1608
1609You can build only a single phase for a module by using the notation
1610`$MODULE-$PHASE`. For instance, to build the `gensrc` phase for `java.base`,
1611use `make java.base-gensrc`.
1612
1613Note that some phases may depend on others, e.g. `java` depends on `gensrc` (if
1614present). Make will build all needed prerequisites before building the
1615requested phase.
1616
1617#### Skipping the Dependency Check
1618
1619When using an iterative development style with frequent quick rebuilds, the
1620dependency check made by make can take up a significant portion of the time
1621spent on the rebuild. In such cases, it can be useful to bypass the dependency
1622check in make.
1623
1624> **Note that if used incorrectly, this can lead to a broken build!**
1625
1626To achieve this, append `-only` to the build target. For instance, `make
1627jdk.jdwp.agent-java-only` will *only* build the `java` phase of the
1628`jdk.jdwp.agent` module. If the required dependencies are not present, the
1629build can fail. On the other hand, the execution time measures in milliseconds.
1630
1631A useful pattern is to build the first time normally (e.g. `make
1632jdk.jdwp.agent`) and then on subsequent builds, use the `-only` make target.
1633
1634#### Rebuilding Part of java.base (JDK\_FILTER)
1635
1636If you are modifying files in `java.base`, which is the by far largest module
1637in the JDK, then you need to rebuild all those files whenever a single file has
1638changed. (This inefficiency will hopefully be addressed in JDK 10.)
1639
1640As a hack, you can use the make control variable `JDK_FILTER` to specify a
1641pattern that will be used to limit the set of files being recompiled. For
1642instance, `make java.base JDK_FILTER=javax/crypto` (or, to combine methods,
1643`make java.base-java-only JDK_FILTER=javax/crypto`) will limit the compilation
1644to files in the `javax.crypto` package.
1645
1646## Understanding the Build System
1647
1648This section will give you a more technical description on the details of the
1649build system.
1650
1651### Configurations
1652
1653The build system expects to find one or more configuration. These are
1654technically defined by the `spec.gmk` in a subdirectory to the `build`
1655subdirectory. The `spec.gmk` file is generated by `configure`, and contains in
1656principle the configuration (directly or by files included by `spec.gmk`).
1657
1658You can, in fact, select a configuration to build by pointing to the `spec.gmk`
1659file with the `SPEC` make control variable, e.g. `make SPEC=$BUILD/spec.gmk`.
1660While this is not the recommended way to call `make` as a user, it is what is
1661used under the hood by the build system.
1662
1663### Build Output Structure
1664
1665The build output for a configuration will end up in `build/<configuration
1666name>`, which we refer to as `$BUILD` in this document. The `$BUILD` directory
1667contains the following important directories:
1668
1669```
1670buildtools/
1671configure-support/
1672hotspot/
1673images/
1674jdk/
1675make-support/
1676support/
1677test-results/
1678test-support/
1679```
1680
1681This is what they are used for:
1682
1683  * `images`: This is the directory were the output of the `*-image` make
1684    targets end up. For instance, `make jdk-image` ends up in `images/jdk`.
1685
1686  * `jdk`: This is the "exploded image". After `make jdk`, you will be able to
1687    launch the newly built JDK by running `$BUILD/jdk/bin/java`.
1688
1689  * `test-results`: This directory contains the results from running tests.
1690
1691  * `support`: This is an area for intermediate files needed during the build,
1692    e.g. generated source code, object files and class files. Some noteworthy
1693    directories in `support` is `gensrc`, which contains the generated source
1694    code, and the `modules_*` directories, which contains the files in a
1695    per-module hierarchy that will later be collapsed into the `jdk` directory
1696    of the exploded image.
1697
1698  * `buildtools`: This is an area for tools compiled for the build platform
1699    that are used during the rest of the build.
1700
1701  * `hotspot`: This is an area for intermediate files needed when building
1702    hotspot.
1703
1704  * `configure-support`, `make-support` and `test-support`: These directories
1705    contain files that are needed by the build system for `configure`, `make`
1706    and for running tests.
1707
1708### Fixpath
1709
1710Windows path typically look like `C:\User\foo`, while Unix paths look like
1711`/home/foo`. Tools with roots from Unix often experience issues related to this
1712mismatch when running on Windows.
1713
1714In the JDK build, we always use Unix paths internally, and only just before
1715calling a tool that does not understand Unix paths do we convert them to
1716Windows paths.
1717
1718This conversion is done by the `fixpath` tool, which is a small wrapper that
1719modifies unix-style paths to Windows-style paths in command lines. Fixpath is
1720compiled automatically by `configure`.
1721
1722### Native Debug Symbols
1723
1724Native libraries and executables can have debug symbol (and other debug
1725information) associated with them. How this works is very much platform
1726dependent, but a common problem is that debug symbol information takes a lot of
1727disk space, but is rarely needed by the end user.
1728
1729The JDK supports different methods on how to handle debug symbols. The
1730method used is selected by `--with-native-debug-symbols`, and available methods
1731are `none`, `internal`, `external`, `zipped`.
1732
1733  * `none` means that no debug symbols will be generated during the build.
1734
1735  * `internal` means that debug symbols will be generated during the build, and
1736    they will be stored in the generated binary.
1737
1738  * `external` means that debug symbols will be generated during the build, and
1739    after the compilation, they will be moved into a separate `.debuginfo` file.
1740    (This was previously known as FDS, Full Debug Symbols).
1741
1742  * `zipped` is like `external`, but the .debuginfo file will also be zipped
1743    into a `.diz` file.
1744
1745When building for distribution, `zipped` is a good solution. Binaries built
1746with `internal` is suitable for use by developers, since they facilitate
1747debugging, but should be stripped before distributed to end users.
1748
1749### Autoconf Details
1750
1751The `configure` script is based on the autoconf framework, but in some details
1752deviate from a normal autoconf `configure` script.
1753
1754The `configure` script in the top level directory of the JDK is just a thin
1755wrapper that calls `make/autoconf/configure`. This in turn will run `autoconf`
1756to create the runnable (generated) configure script, as
1757`.build/generated-configure.sh`. Apart from being responsible for the
1758generation of the runnable script, the `configure` script also provides
1759functionality that is not easily expressed in the normal Autoconf framework. As
1760part of this functionality, the generated script is called.
1761
1762The build system will detect if the Autoconf source files have changed, and
1763will trigger a regeneration of the generated script if needed. You can also
1764manually request such an update by `bash configure autogen`.
1765
1766In previous versions of the JDK, the generated script was checked in at
1767`make/autoconf/generated-configure.sh`. This is no longer the case.
1768
1769### Developing the Build System Itself
1770
1771This section contains a few remarks about how to develop for the build system
1772itself. It is not relevant if you are only making changes in the product source
1773code.
1774
1775While technically using `make`, the make source files of the JDK does not
1776resemble most other Makefiles. Instead of listing specific targets and actions
1777(perhaps using patterns), the basic modus operandi is to call a high-level
1778function (or properly, macro) from the API in `make/common`. For instance, to
1779compile all classes in the `jdk.internal.foo` package in the `jdk.foo` module,
1780a call like this would be made:
1781
1782```
1783$(eval $(call SetupJavaCompilation, BUILD_FOO_CLASSES, \
1784    SETUP := GENERATE_OLDBYTECODE, \
1785    SRC := $(TOPDIR)/src/jkd.foo/share/classes, \
1786    INCLUDES := jdk/internal/foo, \
1787    BIN := $(SUPPORT_OUTPUTDIR)/foo_classes, \
1788))
1789```
1790
1791By encapsulating and expressing the high-level knowledge of *what* should be
1792done, rather than *how* it should be done (as is normal in Makefiles), we can
1793build a much more powerful and flexible build system.
1794
1795Correct dependency tracking is paramount. Sloppy dependency tracking will lead
1796to improper parallelization, or worse, race conditions.
1797
1798To test for/debug race conditions, try running `make JOBS=1` and `make
1799JOBS=100` and see if it makes any difference. (It shouldn't).
1800
1801To compare the output of two different builds and see if, and how, they differ,
1802run `$BUILD1/compare.sh -o $BUILD2`, where `$BUILD1` and `$BUILD2` are the two
1803builds you want to compare.
1804
1805To automatically build two consecutive versions and compare them, use
1806`COMPARE_BUILD`. The value of `COMPARE_BUILD` is a set of variable=value
1807assignments, like this:
1808```
1809make COMPARE_BUILD=CONF=--enable-new-hotspot-feature:MAKE=hotspot
1810```
1811See `make/InitSupport.gmk` for details on how to use `COMPARE_BUILD`.
1812
1813To analyze build performance, run with `LOG=trace` and check `$BUILD/build-trace-time.log`.
1814Use `JOBS=1` to avoid parallelism.
1815
1816Please check that you adhere to the [Code Conventions for the Build System](
1817http://openjdk.java.net/groups/build/doc/code-conventions.html) before
1818submitting patches.
1819
1820## Contributing to the JDK
1821
1822So, now you've built your JDK, and made your first patch, and want to
1823contribute it back to the OpenJDK Community.
1824
1825First of all: Thank you! We gladly welcome your contribution.
1826However, please bear in mind that the JDK is a massive project, and we must ask
1827you to follow our rules and guidelines to be able to accept your contribution.
1828
1829The official place to start is the ['How to contribute' page](
1830http://openjdk.java.net/contribute/). There is also an official (but somewhat
1831outdated and skimpy on details) [Developer's Guide](
1832http://openjdk.java.net/guide/).
1833
1834If this seems overwhelming to you, the Adoption Group is there to help you! A
1835good place to start is their ['New Contributor' page](
1836https://wiki.openjdk.java.net/display/Adoption/New+Contributor), or start
1837reading the comprehensive [Getting Started Kit](
1838https://adoptopenjdk.gitbooks.io/adoptopenjdk-getting-started-kit/en/). The
1839Adoption Group will also happily answer any questions you have about
1840contributing. Contact them by [mail](
1841http://mail.openjdk.java.net/mailman/listinfo/adoption-discuss) or [IRC](
1842http://openjdk.java.net/irc/).
1843
1844---
1845# Override styles from the base CSS file that are not ideal for this document.
1846header-includes:
1847 - '<style type="text/css">pre, code, tt { color: #1d6ae5; }</style>'
1848---
1849