forked from openjdk/jdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
building.html
2300 lines (2295 loc) · 111 KB
/
building.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="" xml:lang="">
<head>
<meta charset="utf-8" />
<meta name="generator" content="pandoc" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
<title>Building the JDK</title>
<style>
code{white-space: pre-wrap;}
span.smallcaps{font-variant: small-caps;}
div.columns{display: flex; gap: min(4vw, 1.5em);}
div.column{flex: auto; overflow-x: auto;}
div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}
ul.task-list{list-style: none;}
ul.task-list li input[type="checkbox"] {
width: 0.8em;
margin: 0 0.8em 0.2em -1.6em;
vertical-align: middle;
}
.display.math{display: block; text-align: center; margin: 0.5rem auto;}
</style>
<link rel="stylesheet" href="../make/data/docs-resources/resources/jdk-default.css" />
<style type="text/css">pre, code, tt { color: #1d6ae5; }</style>
<!--[if lt IE 9]>
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>
<![endif]-->
</head>
<body>
<header id="title-block-header">
<h1 class="title">Building the JDK</h1>
</header>
<nav id="TOC" role="doc-toc">
<ul>
<li><a href="#tldr-instructions-for-the-impatient"
id="toc-tldr-instructions-for-the-impatient">TL;DR (Instructions for the
Impatient)</a></li>
<li><a href="#introduction" id="toc-introduction">Introduction</a></li>
<li><a href="#getting-the-source-code"
id="toc-getting-the-source-code">Getting the Source Code</a>
<ul>
<li><a href="#special-considerations"
id="toc-special-considerations">Special Considerations</a></li>
</ul></li>
<li><a href="#build-hardware-requirements"
id="toc-build-hardware-requirements">Build Hardware Requirements</a>
<ul>
<li><a href="#building-on-x86" id="toc-building-on-x86">Building on
x86</a></li>
<li><a href="#building-on-aarch64" id="toc-building-on-aarch64">Building
on aarch64</a></li>
<li><a href="#building-on-32-bit-arm"
id="toc-building-on-32-bit-arm">Building on 32-bit arm</a></li>
</ul></li>
<li><a href="#operating-system-requirements"
id="toc-operating-system-requirements">Operating System Requirements</a>
<ul>
<li><a href="#windows" id="toc-windows">Windows</a></li>
<li><a href="#macos" id="toc-macos">macOS</a></li>
<li><a href="#linux" id="toc-linux">Linux</a></li>
<li><a href="#aix" id="toc-aix">AIX</a></li>
</ul></li>
<li><a href="#native-compiler-toolchain-requirements"
id="toc-native-compiler-toolchain-requirements">Native Compiler
(Toolchain) Requirements</a>
<ul>
<li><a href="#gcc" id="toc-gcc">gcc</a></li>
<li><a href="#clang" id="toc-clang">clang</a></li>
<li><a href="#apple-xcode" id="toc-apple-xcode">Apple Xcode</a></li>
<li><a href="#microsoft-visual-studio"
id="toc-microsoft-visual-studio">Microsoft Visual Studio</a></li>
<li><a href="#ibm-xl-cc" id="toc-ibm-xl-cc">IBM XL C/C++</a></li>
</ul></li>
<li><a href="#boot-jdk-requirements" id="toc-boot-jdk-requirements">Boot
JDK Requirements</a>
<ul>
<li><a href="#getting-jdk-binaries"
id="toc-getting-jdk-binaries">Getting JDK binaries</a></li>
</ul></li>
<li><a href="#external-library-requirements"
id="toc-external-library-requirements">External Library Requirements</a>
<ul>
<li><a href="#freetype" id="toc-freetype">FreeType</a></li>
<li><a href="#fontconfig" id="toc-fontconfig">Fontconfig</a></li>
<li><a href="#cups" id="toc-cups">CUPS</a></li>
<li><a href="#x11" id="toc-x11">X11</a></li>
<li><a href="#alsa" id="toc-alsa">ALSA</a></li>
<li><a href="#libffi" id="toc-libffi">libffi</a></li>
</ul></li>
<li><a href="#build-tools-requirements"
id="toc-build-tools-requirements">Build Tools Requirements</a>
<ul>
<li><a href="#autoconf" id="toc-autoconf">Autoconf</a></li>
<li><a href="#gnu-make" id="toc-gnu-make">GNU Make</a></li>
<li><a href="#gnu-bash" id="toc-gnu-bash">GNU Bash</a></li>
</ul></li>
<li><a href="#running-configure" id="toc-running-configure">Running
Configure</a>
<ul>
<li><a href="#common-configure-arguments"
id="toc-common-configure-arguments">Common Configure Arguments</a></li>
<li><a href="#configure-control-variables"
id="toc-configure-control-variables">Configure Control
Variables</a></li>
</ul></li>
<li><a href="#running-make" id="toc-running-make">Running Make</a>
<ul>
<li><a href="#common-make-targets" id="toc-common-make-targets">Common
Make Targets</a></li>
<li><a href="#make-control-variables"
id="toc-make-control-variables">Make Control Variables</a></li>
</ul></li>
<li><a href="#running-tests" id="toc-running-tests">Running
Tests</a></li>
<li><a href="#signing" id="toc-signing">Signing</a>
<ul>
<li><a href="#macos-1" id="toc-macos-1">macOS</a></li>
</ul></li>
<li><a href="#cross-compiling"
id="toc-cross-compiling">Cross-compiling</a>
<ul>
<li><a href="#cross-compiling-the-easy-way-with-openjdk-devkits"
id="toc-cross-compiling-the-easy-way-with-openjdk-devkits">Cross
compiling the easy way with OpenJDK devkits</a></li>
<li><a href="#boot-jdk-and-build-jdk"
id="toc-boot-jdk-and-build-jdk">Boot JDK and Build JDK</a></li>
<li><a href="#specifying-the-target-platform"
id="toc-specifying-the-target-platform">Specifying the Target
Platform</a></li>
<li><a href="#toolchain-considerations"
id="toc-toolchain-considerations">Toolchain Considerations</a></li>
<li><a href="#native-libraries" id="toc-native-libraries">Native
Libraries</a></li>
<li><a href="#cross-compiling-with-debian-sysroots"
id="toc-cross-compiling-with-debian-sysroots">Cross compiling with
Debian sysroots</a></li>
<li><a href="#building-for-armaarch64"
id="toc-building-for-armaarch64">Building for ARM/aarch64</a></li>
<li><a href="#building-for-risc-v" id="toc-building-for-risc-v">Building
for RISC-V</a></li>
<li><a href="#building-for-musl" id="toc-building-for-musl">Building for
musl</a></li>
<li><a href="#verifying-the-build"
id="toc-verifying-the-build">Verifying the Build</a></li>
</ul></li>
<li><a href="#build-performance" id="toc-build-performance">Build
Performance</a>
<ul>
<li><a href="#disk-speed" id="toc-disk-speed">Disk Speed</a></li>
<li><a href="#virus-checking" id="toc-virus-checking">Virus
Checking</a></li>
<li><a href="#ccache" id="toc-ccache">Ccache</a></li>
<li><a href="#precompiled-headers"
id="toc-precompiled-headers">Precompiled Headers</a></li>
<li><a href="#icecc-icecream" id="toc-icecc-icecream">Icecc /
icecream</a></li>
<li><a href="#using-the-javac-server"
id="toc-using-the-javac-server">Using the javac server</a></li>
<li><a href="#building-the-right-target"
id="toc-building-the-right-target">Building the Right Target</a></li>
</ul></li>
<li><a href="#troubleshooting"
id="toc-troubleshooting">Troubleshooting</a>
<ul>
<li><a href="#locating-the-source-of-the-error"
id="toc-locating-the-source-of-the-error">Locating the Source of the
Error</a></li>
<li><a href="#fixing-unexpected-build-failures"
id="toc-fixing-unexpected-build-failures">Fixing Unexpected Build
Failures</a></li>
<li><a href="#specific-build-issues"
id="toc-specific-build-issues">Specific Build Issues</a></li>
<li><a href="#getting-help" id="toc-getting-help">Getting Help</a></li>
</ul></li>
<li><a href="#reproducible-builds"
id="toc-reproducible-builds">Reproducible Builds</a></li>
<li><a href="#hints-and-suggestions-for-advanced-users"
id="toc-hints-and-suggestions-for-advanced-users">Hints and Suggestions
for Advanced Users</a>
<ul>
<li><a href="#bash-completion" id="toc-bash-completion">Bash
Completion</a></li>
<li><a href="#using-multiple-configurations"
id="toc-using-multiple-configurations">Using Multiple
Configurations</a></li>
<li><a href="#handling-reconfigurations"
id="toc-handling-reconfigurations">Handling Reconfigurations</a></li>
<li><a href="#using-fine-grained-make-targets"
id="toc-using-fine-grained-make-targets">Using Fine-Grained Make
Targets</a></li>
</ul></li>
<li><a href="#understanding-the-build-system"
id="toc-understanding-the-build-system">Understanding the Build
System</a>
<ul>
<li><a href="#configurations"
id="toc-configurations">Configurations</a></li>
<li><a href="#build-output-structure"
id="toc-build-output-structure">Build Output Structure</a></li>
<li><a href="#fixpath" id="toc-fixpath">Fixpath</a></li>
<li><a href="#native-debug-symbols" id="toc-native-debug-symbols">Native
Debug Symbols</a></li>
<li><a href="#autoconf-details" id="toc-autoconf-details">Autoconf
Details</a></li>
<li><a href="#developing-the-build-system-itself"
id="toc-developing-the-build-system-itself">Developing the Build System
Itself</a></li>
</ul></li>
<li><a href="#contributing-to-the-jdk"
id="toc-contributing-to-the-jdk">Contributing to the JDK</a></li>
<li><a href="#editing-this-document"
id="toc-editing-this-document">Editing this document</a></li>
</ul>
</nav>
<h2 id="tldr-instructions-for-the-impatient">TL;DR (Instructions for the
Impatient)</h2>
<p>If you are eager to try out building the JDK, these simple steps
works most of the time. They assume that you have installed Git (and
Cygwin if running on Windows) and cloned the top-level JDK repository
that you want to build.</p>
<ol type="1">
<li><p><a href="#getting-the-source-code">Get the complete source
code</a>:<br />
<code>git clone https://git.openjdk.org/jdk/</code></p></li>
<li><p><a href="#running-configure">Run configure</a>:<br />
<code>bash configure</code></p>
<p>If <code>configure</code> fails due to missing dependencies (to
either the <a
href="#native-compiler-toolchain-requirements">toolchain</a>, <a
href="#build-tools-requirements">build tools</a>, <a
href="#external-library-requirements">external libraries</a> or the <a
href="#boot-jdk-requirements">boot JDK</a>), most of the time it prints
a suggestion on how to resolve the situation on your platform. Follow
the instructions, and try running <code>bash configure</code>
again.</p></li>
<li><p><a href="#running-make">Run make</a>:<br />
<code>make images</code></p></li>
<li><p>Verify your newly built JDK:<br />
<code>./build/*/images/jdk/bin/java -version</code></p></li>
<li><p><a href="##running-tests">Run basic tests</a>:<br />
<code>make run-test-tier1</code></p></li>
</ol>
<p>If any of these steps failed, or if you want to know more about build
requirements or build functionality, please continue reading this
document.</p>
<h2 id="introduction">Introduction</h2>
<p>The JDK is a complex software project. Building it requires a certain
amount of technical expertise, a fair number of dependencies on external
software, and reasonably powerful hardware.</p>
<p>If you just want to use the JDK and not build it yourself, this
document is not for you. See for instance <a
href="http://openjdk.org/install">OpenJDK installation</a> for some
methods of installing a prebuilt JDK.</p>
<h2 id="getting-the-source-code">Getting the Source Code</h2>
<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="https://git.openjdk.org/">OpenJDK Git site</a> you can see a list
of all available repositories. If you want to build an older version,
e.g. JDK 11, it is recommended that you get the <code>jdk11u</code>
repo, which contains incremental updates, instead of the
<code>jdk11</code> repo, which was frozen at JDK 11 GA.</p>
<p>If you are new to Git, a good place to start is the book <a
href="https://git-scm.com/book/en/v2">Pro Git</a>. The rest of this
document assumes a working knowledge of Git.</p>
<h3 id="special-considerations">Special Considerations</h3>
<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>
<ul>
<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>
<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>
<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>
<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>
<ul>
<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>
<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>
<li><p>You need to install a git client. You have two choices, Cygwin
git or Git for Windows. Unfortunately there are pros and cons with each
choice.</p>
<ul>
<li><p>The Cygwin <code>git</code> client has no line ending issues and
understands Cygwin paths (which are used throughout the JDK build
system). However, it does not currently work well with the Skara CLI
tooling. Please see the <a
href="https://wiki.openjdk.org/display/SKARA/Skara#Skara-Git">Skara wiki
on Git clients</a> for up-to-date information about the Skara git client
support.</p></li>
<li><p>The <a href="https://gitforwindows.org">Git for Windows</a>
client has issues with line endings, and do not understand Cygwin paths.
It does work well with the Skara CLI tooling, however. To alleviate the
line ending problems, make sure you set <code>core.autocrlf</code> to
<code>false</code> (this is asked during installation).</p></li>
</ul></li>
</ul>
<p>Failure to follow this procedure might result in hard-to-debug build
problems.</p></li>
</ul>
<h2 id="build-hardware-requirements">Build Hardware Requirements</h2>
<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>
<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>
<h3 id="building-on-x86">Building on x86</h3>
<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>
<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>
<p>Note: The Windows 32-bit x86 port is deprecated and may be removed in
a future release.</p>
<h3 id="building-on-aarch64">Building on aarch64</h3>
<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>
<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>
<h4 id="branch-protection">Branch Protection</h4>
<p>In order to use Branch Protection features in the VM,
<code>--enable-branch-protection</code> must be used. This option
requires C++ compiler support (GCC 9.1.0+ or Clang 10+). The resulting
build can be run on both machines with and without support for branch
protection in hardware. Branch Protection is only supported for Linux
targets.</p>
<h3 id="building-on-32-bit-arm">Building on 32-bit arm</h3>
<p>This is not recommended. Instead, see the section on <a
href="#cross-compiling">Cross-compiling</a>.</p>
<h2 id="operating-system-requirements">Operating System
Requirements</h2>
<p>The mainline JDK project supports Linux, macOS, AIX and Windows.
Support for other operating system, e.g. BSD, exists in separate "port"
projects.</p>
<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>
<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>
<table>
<thead>
<tr class="header">
<th>Operating system</th>
<th>Vendor/version used</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td>Linux</td>
<td>Oracle Enterprise Linux 6.4 / 7.6</td>
</tr>
<tr class="even">
<td>macOS</td>
<td>macOS 13 (Ventura)</td>
</tr>
<tr class="odd">
<td>Windows</td>
<td>Windows Server 2012 R2</td>
</tr>
</tbody>
</table>
<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>
<p>The Build Group has a wiki page with <a
href="https://wiki.openjdk.org/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>
<h3 id="windows">Windows</h3>
<p>Windows XP is not a supported platform, but all newer Windows should
be able to build the JDK.</p>
<p>On Windows, it is important that you pay attention to the
instructions in the <a href="#special-considerations">Special
Considerations</a>.</p>
<p>Windows is the only non-POSIX OS supported by 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, Windows
Subsystem for Linux (WSL), and MSYS2. (MSYS is no longer supported due
to an outdated bash; While OpenJDK can be built with MSYS2, support for
it is still experimental, so build failures and unusual errors are not
uncommon.)</p>
<p>Internally in the build system, all paths are represented as
Unix-style paths, e.g. <code>/cygdrive/c/git/jdk/Makefile</code> rather
than <code>C:\git\jdk\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>
<p>Note: The Windows 32-bit x86 port is deprecated and may be removed in
a future release.</p>
<h4 id="cygwin">Cygwin</h4>
<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>
<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>
<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>
<p>Apart from the basic Cygwin installation, the following packages must
also be installed:</p>
<ul>
<li><code>autoconf</code></li>
<li><code>make</code></li>
<li><code>zip</code></li>
<li><code>unzip</code></li>
</ul>
<p>Often, you can install these packages using the following command
line:</p>
<pre><code><path to Cygwin setup>/setup-x86_64 -q -P autoconf -P make -P unzip -P zip</code></pre>
<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">"BLODA" list</a>
and the section on <a
href="https://cygwin.com/faq/faq.html#faq.using.fixing-fork-failures">fork()
failures</a>.</p>
<h4 id="windows-subsystem-for-linux-wsl">Windows Subsystem for Linux
(WSL)</h4>
<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>
<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 --openjdk-target=x86_64-unknown-linux-gnu</code>
to <code>configure</code>.</p>
<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>
<p>Note that while it's possible to build on WSL, testing is still not
fully supported.</p>
<h3 id="macos">macOS</h3>
<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>
<p>It is recommended that you use at least macOS 13 (Ventura) and Xcode
14, but earlier versions may also work.</p>
<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>
<h3 id="linux">Linux</h3>
<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>
<p>The basic tooling is provided as part of the core operating system,
but you will most likely need to install developer packages.</p>
<p>For apt-based distributions (Debian, Ubuntu, etc), try this:</p>
<pre><code>sudo apt-get install build-essential</code></pre>
<p>For rpm-based distributions (Fedora, Red Hat, etc), try this:</p>
<pre><code>sudo yum groupinstall "Development Tools"</code></pre>
<p>For Alpine Linux, aside from basic tooling, install the GNU versions
of some programs:</p>
<pre><code>sudo apk add build-base bash grep zip</code></pre>
<h3 id="aix">AIX</h3>
<p>Please consult the AIX section of the <a
href="https://wiki.openjdk.org/display/Build/Supported+Build+Platforms">Supported
Build Platforms</a> OpenJDK Build Wiki page for details about which
versions of AIX are supported.</p>
<h2 id="native-compiler-toolchain-requirements">Native Compiler
(Toolchain) Requirements</h2>
<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. There are ongoing efforts to loosen this strict
coupling between compiler and operating system (see <a
href="https://bugs.openjdk.org/browse/JDK-8288293">JDK-8288293</a>) but
it will likely be a very long time before this goal can be realized.</p>
<table>
<thead>
<tr class="header">
<th>Operating system</th>
<th>Supported toolchain</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td>Linux</td>
<td>gcc, clang</td>
</tr>
<tr class="even">
<td>macOS</td>
<td>Apple Xcode (using clang)</td>
</tr>
<tr class="odd">
<td>AIX</td>
<td>IBM XL C/C++</td>
</tr>
<tr class="even">
<td>Windows</td>
<td>Microsoft Visual Studio</td>
</tr>
</tbody>
</table>
<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>
<table>
<thead>
<tr class="header">
<th>Operating system</th>
<th>Toolchain version</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td>Linux</td>
<td>gcc 11.2.0</td>
</tr>
<tr class="even">
<td>macOS</td>
<td>Apple Xcode 14.3.1 (using clang 14.0.3)</td>
</tr>
<tr class="odd">
<td>Windows</td>
<td>Microsoft Visual Studio 2022 update 17.1.0</td>
</tr>
</tbody>
</table>
<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>
<h3 id="gcc">gcc</h3>
<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>
<p>The JDK is currently known to be able to compile with at least
version 11.2 of gcc.</p>
<p>In general, any version between these two should be usable.</p>
<h3 id="clang">clang</h3>
<p>The minimum accepted version of clang is 3.5. Older versions will not
be accepted by <code>configure</code>.</p>
<p>To use clang instead of gcc on Linux, use
<code>--with-toolchain-type=clang</code>.</p>
<h3 id="apple-xcode">Apple Xcode</h3>
<p>The oldest supported version of Xcode is 8.</p>
<p>You will need the Xcode command line developer tools to be able to
build the JDK. (Actually, <em>only</em> the command line tools are
needed, not the IDE.) The simplest way to install these is to run:</p>
<pre><code>xcode-select --install</code></pre>
<p>When updating Xcode, it is advisable to keep an older version for
building the JDK. To use a specific version of Xcode you have multiple
options:</p>
<ul>
<li>Use <code>xcode-select -s</code> before running
<code>configure</code>, e.g.
<code>xcode-select -s /Applications/Xcode13.1.app</code>. The drawback
is that the setting is system wide and you may have to revert it after
an OpenJDK build.</li>
<li>Use configure option <code>--with-xcode-path</code>, e.g.
<code>configure --with-xcode-path=/Applications/Xcode13.1.app</code>
This allows using a specific Xcode version for an OpenJDK build,
independently of the active Xcode version by
<code>xcode-select</code>.</li>
</ul>
<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>
<h3 id="microsoft-visual-studio">Microsoft Visual Studio</h3>
<p>The minimum accepted version is Visual Studio 2019 version 16.8.
(Note that this version is often presented as "MSVC 14.28", and reported
by cl.exe as 19.28.) Older versions will not be accepted by
<code>configure</code> and will not work. The maximum accepted version
of Visual Studio is 2022.</p>
<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=2022</code>.</p>
<p>If you have Visual Studio installed but <code>configure</code> fails
to detect it, it may be because of <a href="#spaces-in-path">spaces in
path</a>.</p>
<h3 id="ibm-xl-cc">IBM XL C/C++</h3>
<p>Please consult the AIX section of the <a
href="https://wiki.openjdk.org/display/Build/Supported+Build+Platforms">Supported
Build Platforms</a> OpenJDK Build Wiki page for details about which
versions of XLC are supported.</p>
<h2 id="boot-jdk-requirements">Boot JDK Requirements</h2>
<p>Paradoxically, building the JDK requires a pre-existing JDK. This is
called the "boot JDK". 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>
<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 "build itself", 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>
<p>Early in the release cycle, version <em>N-1</em> may not yet have
been released. In that case, the preferred boot JDK will be version
<em>N-2</em> until version <em>N-1</em> is available.</p>
<p>If the boot JDK is not automatically detected, or the wrong JDK is
picked, use <code>--with-boot-jdk</code> to point to the JDK to use.</p>
<h3 id="getting-jdk-binaries">Getting JDK binaries</h3>
<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>
<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-<VERSION>-jdk</code> is
typically enough to install a JDK <VERSION>. On rpm-based distros
(like Fedora and Red Hat), try
<code>sudo yum install java-<VERSION>-openjdk-devel</code>.</p>
<h2 id="external-library-requirements">External Library
Requirements</h2>
<p>Different platforms require different external libraries. In general,
libraries are not optional - that is, they are either required or not
used.</p>
<p>If a required library is not detected by <code>configure</code>, you
need to provide the path to it. There are two forms of the
<code>configure</code> arguments to point to an external library:
<code>--with-<LIB>=<path></code> or
<code>--with-<LIB>-include=<path to include> --with-<LIB>-lib=<path to lib></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>
<p>As a fallback, the second version allows you to point to the include
directory and the lib directory separately.</p>
<h3 id="freetype">FreeType</h3>
<p>FreeType2 from <a href="http://www.freetype.org/">The FreeType
Project</a> is 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>
<ul>
<li>To install on an apt-based Linux, try running
<code>sudo apt-get install libfreetype6-dev</code>.</li>
<li>To install on an rpm-based Linux, try running
<code>sudo yum install freetype-devel</code>.</li>
<li>To install on Alpine Linux, try running
<code>sudo apk add freetype-dev</code>.</li>
<li>To install on macOS, try running
<code>brew install freetype</code>.</li>
</ul>
<p>Use <code>--with-freetype-include=<path></code> and
<code>--with-freetype-lib=<path></code> if <code>configure</code>
does not automatically locate the platform FreeType files.</p>
<h3 id="fontconfig">Fontconfig</h3>
<p>Fontconfig from <a href="http://fontconfig.org">freedesktop.org
Fontconfig</a> is required on all platforms except Windows and
macOS.</p>
<ul>
<li>To install on an apt-based Linux, try running
<code>sudo apt-get install libfontconfig-dev</code>.</li>
<li>To install on an rpm-based Linux, try running
<code>sudo yum install fontconfig-devel</code>.</li>
</ul>
<p>Use <code>--with-fontconfig-include=<path></code> and
<code>--with-fontconfig=<path></code> if <code>configure</code>
does not automatically locate the platform Fontconfig files.</p>
<h3 id="cups">CUPS</h3>
<p>CUPS, <a href="http://www.cups.org">Common UNIX Printing System</a>
header files are required on all platforms, except Windows. Often these
files are provided by your operating system.</p>
<ul>
<li>To install on an apt-based Linux, try running
<code>sudo apt-get install libcups2-dev</code>.</li>
<li>To install on an rpm-based Linux, try running
<code>sudo yum install cups-devel</code>.</li>
<li>To install on Alpine Linux, try running
<code>sudo apk add cups-dev</code>.</li>
</ul>
<p>Use <code>--with-cups=<path></code> if <code>configure</code>
does not properly locate your CUPS files.</p>
<h3 id="x11">X11</h3>
<p>Certain <a href="http://www.x.org/">X11</a> libraries and include
files are required on Linux.</p>
<ul>
<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>
<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>
<li>To install on Alpine Linux, try running
<code>sudo apk add libx11-dev libxext-dev libxrender-dev libxrandr-dev libxtst-dev libxt-dev</code>.</li>
</ul>
<p>Use <code>--with-x=<path></code> if <code>configure</code> does
not properly locate your X11 files.</p>
<h3 id="alsa">ALSA</h3>
<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>
<ul>
<li>To install on an apt-based Linux, try running
<code>sudo apt-get install libasound2-dev</code>.</li>
<li>To install on an rpm-based Linux, try running
<code>sudo yum install alsa-lib-devel</code>.</li>
<li>To install on Alpine Linux, try running
<code>sudo apk add alsa-lib-dev</code>.</li>
</ul>
<p>Use <code>--with-alsa=<path></code> if <code>configure</code>
does not properly locate your ALSA files.</p>
<h3 id="libffi">libffi</h3>
<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>
<ul>
<li>To install on an apt-based Linux, try running
<code>sudo apt-get install libffi-dev</code>.</li>
<li>To install on an rpm-based Linux, try running
<code>sudo yum install libffi-devel</code>.</li>
<li>To install on Alpine Linux, try running
<code>sudo apk add libffi-dev</code>.</li>
</ul>
<p>Use <code>--with-libffi=<path></code> if <code>configure</code>
does not properly locate your libffi files.</p>
<h2 id="build-tools-requirements">Build Tools Requirements</h2>
<h3 id="autoconf">Autoconf</h3>
<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>
<ul>
<li>To install on an apt-based Linux, try running
<code>sudo apt-get install autoconf</code>.</li>
<li>To install on an rpm-based Linux, try running
<code>sudo yum install autoconf</code>.</li>
<li>To install on Alpine Linux, try running
<code>sudo apk add autoconf</code>.</li>
<li>To install on macOS, try running
<code>brew install autoconf</code>.</li>
<li>To install on Windows, try running
<code><path to Cygwin setup>/setup-x86_64 -q -P autoconf</code>.</li>
</ul>
<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>
<pre><code>AUTOCONF=<path to autoconf> configure ...</code></pre>
<h3 id="gnu-make">GNU Make</h3>
<p>The JDK requires <a href="http://www.gnu.org/software/make">GNU
Make</a>. No other flavors of make are supported.</p>
<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>
<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 "bootstrap make", 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>
<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>
<h3 id="gnu-bash">GNU Bash</h3>
<p>The JDK requires <a href="http://www.gnu.org/software/bash">GNU
Bash</a>. No other shells are supported.</p>
<p>At least version 3.2 of GNU Bash must be used.</p>
<h2 id="running-configure">Running Configure</h2>
<p>To build the JDK, you need a "configuration", 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>
<p>The configuration is created by the <code>configure</code> script.
The basic invocation of the <code>configure</code> script looks like
this:</p>
<pre><code>bash configure [options]</code></pre>
<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>
<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>
<p>Some command line examples:</p>
<ul>
<li><p>Create a 32-bit build for Windows with FreeType2 in
<code>C:\freetype-i586</code>:</p>
<pre><code>bash configure --with-freetype=/cygdrive/c/freetype-i586 --with-target-bits=32</code></pre></li>
<li><p>Create a debug build with the <code>server</code> JVM and DTrace
enabled:</p>
<pre><code>bash configure --enable-debug --with-jvm-variants=server --enable-dtrace</code></pre></li>
</ul>
<h3 id="common-configure-arguments">Common Configure Arguments</h3>
<p>Here follows some of the most common and important
<code>configure</code> argument.</p>
<p>To get up-to-date information on <em>all</em> available
<code>configure</code> argument, please run:</p>
<pre><code>bash configure --help</code></pre>
<p>(Note that this help text also include general autoconf options, like
<code>--dvidir</code>, that is not relevant to the JDK. To list only
JDK-specific features, use <code>bash configure --help=short</code>
instead.)</p>
<h4 id="configure-arguments-for-tailoring-the-build">Configure Arguments
for Tailoring the Build</h4>
<ul>
<li><code>--enable-debug</code> - Set the debug level to
<code>fastdebug</code> (this is a shorthand for
<code>--with-debug-level=fastdebug</code>)</li>
<li><code>--with-debug-level=<level></code> - Set the debug level,
which can be <code>release</code>, <code>fastdebug</code>,
<code>slowdebug</code> or <code>optimized</code>. Default is
<code>release</code>. <code>optimized</code> is variant of
<code>release</code> with additional Hotspot debug code.</li>
<li><code>--with-native-debug-symbols=<method></code> - Specify if
and how native debug symbols should be built. Available methods are
<code>none</code>, <code>internal</code>, <code>external</code>,
<code>zipped</code>. Default behavior depends on platform. See <a
href="#native-debug-symbols">Native Debug Symbols</a> for more
details.</li>
<li><code>--with-version-string=<string></code> - Specify the
version string this build will be identified with.</li>
<li><code>--with-version-<part>=<value></code> - A group of
options, where <code><part></code> can be any of <code>pre</code>,
<code>opt</code>, <code>build</code>, <code>major</code>,
<code>minor</code>, <code>security</code> or <code>patch</code>. Use
these options to modify just the corresponding part of the version
string from the default, or the value provided by
<code>--with-version-string</code>.</li>
<li><code>--with-jvm-variants=<variant>[,<variant>...]</code>
- Build the specified variant (or variants) of Hotspot. Valid variants
are: <code>server</code>, <code>client</code>, <code>minimal</code>,
<code>core</code>, <code>zero</code>, <code>custom</code>. Note that not
all variants are possible to combine in a single build.</li>
<li><code>--enable-jvm-feature-<feature></code> or
<code>--disable-jvm-feature-<feature></code> - Include (or
exclude) <code><feature></code> as a JVM feature in Hotspot. You
can also specify a list of features to be enabled, separated by space or
comma, as
<code>--with-jvm-features=<feature>[,<feature>...]</code>.
If you prefix <code><feature></code> with a <code>-</code>, it
will be disabled. These options will modify the default list of features
for the JVM variant(s) you are building. For the <code>custom</code> JVM
variant, the default list is empty. A complete list of valid JVM
features can be found using <code>bash configure --help</code>.</li>
<li><code>--with-target-bits=<bits></code> - Create a target
binary suitable for running on a <code><bits></code> platform. Use
this to create 32-bit output on a 64-bit build platform, instead of
doing a full cross-compile. (This is known as a <em>reduced</em>
build.)</li>
</ul>
<p>On Linux, BSD and AIX, it is possible to override where Java by
default searches for runtime/JNI libraries. This can be useful in
situations where there is a special shared directory for system JNI
libraries. This setting can in turn be overridden at runtime by setting
the <code>java.library.path</code> property.</p>
<ul>
<li><code>--with-jni-libpath=<path></code> - Use the specified
path as a default when searching for runtime libraries.</li>
</ul>
<h4 id="configure-arguments-for-native-compilation">Configure Arguments
for Native Compilation</h4>
<ul>
<li><code>--with-devkit=<path></code> - Use this devkit for
compilers, tools and resources</li>
<li><code>--with-sysroot=<path></code> - Use this directory as
sysroot</li>
<li><code>--with-extra-path=<path>[;<path>]</code> - Prepend
these directories to the default path when searching for all kinds of
binaries</li>
<li><code>--with-toolchain-path=<path>[;<path>]</code> -
Prepend these directories when searching for toolchain binaries
(compilers etc)</li>
<li><code>--with-extra-cflags=<flags></code> - Append these flags
when compiling JDK C files</li>
<li><code>--with-extra-cxxflags=<flags></code> - Append these
flags when compiling JDK C++ files</li>
<li><code>--with-extra-ldflags=<flags></code> - Append these flags
when linking JDK libraries</li>
</ul>
<h4 id="configure-arguments-for-external-dependencies">Configure
Arguments for External Dependencies</h4>
<ul>
<li><code>--with-boot-jdk=<path></code> - Set the path to the <a
href="#boot-jdk-requirements">Boot JDK</a></li>
<li><code>--with-freetype=<path></code> - Set the path to <a
href="#freetype">FreeType</a></li>
<li><code>--with-cups=<path></code> - Set the path to <a
href="#cups">CUPS</a></li>
<li><code>--with-x=<path></code> - Set the path to <a
href="#x11">X11</a></li>
<li><code>--with-alsa=<path></code> - Set the path to <a
href="#alsa">ALSA</a></li>
<li><code>--with-libffi=<path></code> - Set the path to <a
href="#libffi">libffi</a></li>
<li><code>--with-jtreg=<path></code> - Set the path to JTReg. See
<a href="#running-tests">Running Tests</a></li>
</ul>
<p>Certain third-party libraries used by the JDK (libjpeg, giflib,
libpng, lcms and zlib) are included in the JDK repository. The default
behavior of the JDK build is to use the included ("bundled") versions of
libjpeg, giflib, libpng and lcms. For zlib, the system lib (if present)
is used except on Windows and AIX. However the bundled libraries may be
replaced by an external version. To do so, specify <code>system</code>
as the <code><source></code> option in these arguments. (The
default is <code>bundled</code>).</p>
<ul>
<li><code>--with-libjpeg=<source></code> - Use the specified
source for libjpeg</li>
<li><code>--with-giflib=<source></code> - Use the specified source
for giflib</li>
<li><code>--with-libpng=<source></code> - Use the specified source
for libpng</li>
<li><code>--with-lcms=<source></code> - Use the specified source
for lcms</li>
<li><code>--with-zlib=<source></code> - Use the specified source
for zlib</li>
</ul>
<p>On Linux, it is possible to select either static or dynamic linking
of the C++ runtime. The default is static linking, with dynamic linking
as fallback if the static library is not found.</p>
<ul>
<li><code>--with-stdc++lib=<method></code> - Use the specified
method (<code>static</code>, <code>dynamic</code> or
<code>default</code>) for linking the C++ runtime.</li>
</ul>
<h3 id="configure-control-variables">Configure Control Variables</h3>
<p>It is possible to control certain aspects of <code>configure</code>
by overriding the value of <code>configure</code> variables, either on
the command line or in the environment.</p>
<p>Normally, this is <strong>not recommended</strong>. If used
improperly, it can lead to a broken configuration. Unless you're well
versed in the build system, this is hard to use properly. Therefore,
<code>configure</code> will print a warning if this is detected.</p>
<p>However, there are a few <code>configure</code> variables, known as
<em>control variables</em> that are supposed to be overridden on the
command line. These are variables that describe the location of tools
needed by the build, like <code>MAKE</code> or <code>GREP</code>. If any
such variable is specified, <code>configure</code> will use that value
instead of trying to autodetect the tool. For instance,
<code>bash configure MAKE=/opt/gnumake4.0/bin/make</code>.</p>
<p>If a configure argument exists, use that instead, e.g. use
<code>--with-jtreg</code> instead of setting <code>JTREGEXE</code>.</p>
<p>Also note that, despite what autoconf claims, setting
<code>CFLAGS</code> will not accomplish anything. Instead use
<code>--with-extra-cflags</code> (and similar for <code>cxxflags</code>
and <code>ldflags</code>).</p>
<h2 id="running-make">Running Make</h2>
<p>When you have a proper configuration, all you need to do to build the
JDK is to run <code>make</code>. (But see the warning at <a
href="#gnu-make">GNU Make</a> about running the correct version of
make.)</p>
<p>When running <code>make</code> without any arguments, the default
target is used, which is the same as running <code>make default</code>
or <code>make jdk</code>. This will build a minimal (or roughly minimal)
set of compiled output (known as an "exploded image") needed for a
developer to actually execute the newly built JDK. The idea is that in
an incremental development fashion, when doing a normal make, you should
only spend time recompiling what's changed (making it purely
incremental) and only do the work that's needed to actually run and test
your code.</p>
<p>The output of the exploded image resides in <code>$BUILD/jdk</code>.
You can test the newly built JDK like this:
<code>$BUILD/jdk/bin/java -version</code>.</p>
<h3 id="common-make-targets">Common Make Targets</h3>
<p>Apart from the default target, here are some common make targets:</p>