Skip to content

Commit 508c8a9

Browse files
Aleksei VoitylovAlexander Scherbatiy
authored andcommitted
8247591: Document Alpine Linux build steps in OpenJDK build guide
Co-authored-by: Aleksei Voitylov <avoitylov@openjdk.org> Reviewed-by: erikj
1 parent 63009f9 commit 508c8a9

File tree

2 files changed

+51
-0
lines changed

2 files changed

+51
-0
lines changed

doc/building.html

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ <h1 class="title">Building the JDK</h1>
7878
<li><a href="#native-libraries">Native Libraries</a></li>
7979
<li><a href="#creating-and-using-sysroots-with-qemu-deboostrap">Creating And Using Sysroots With qemu-deboostrap</a></li>
8080
<li><a href="#building-for-armaarch64">Building for ARM/aarch64</a></li>
81+
<li><a href="#building-for-musl">Building for musl</a></li>
8182
<li><a href="#verifying-the-build">Verifying the Build</a></li>
8283
</ul></li>
8384
<li><a href="#build-performance">Build Performance</a><ul>
@@ -224,6 +225,8 @@ <h3 id="linux">Linux</h3>
224225
<pre><code>sudo apt-get install build-essential</code></pre>
225226
<p>For rpm-based distributions (Fedora, Red Hat, etc), try this:</p>
226227
<pre><code>sudo yum groupinstall &quot;Development Tools&quot;</code></pre>
228+
<p>For Alpine Linux, aside from basic tooling, install the GNU versions of some programs:</p>
229+
<pre><code>sudo apk add build-base bash grep zip</code></pre>
227230
<h3 id="aix">AIX</h3>
228231
<p>Please consult the AIX section of the <a href="https://wiki.openjdk.java.net/display/Build/Supported+Build+Platforms">Supported Build Platforms</a> OpenJDK Build Wiki page for details about which versions of AIX are supported.</p>
229232
<h2 id="native-compiler-toolchain-requirements">Native Compiler (Toolchain) Requirements</h2>
@@ -313,34 +316,39 @@ <h3 id="freetype">FreeType</h3>
313316
<ul>
314317
<li>To install on an apt-based Linux, try running <code>sudo apt-get install libfreetype6-dev</code>.</li>
315318
<li>To install on an rpm-based Linux, try running <code>sudo yum install freetype-devel</code>.</li>
319+
<li>To install on Alpine Linux, try running <code>sudo apk add freetype-dev</code>.</li>
316320
</ul>
317321
<p>Use <code>--with-freetype-include=&lt;path&gt;</code> and <code>--with-freetype-lib=&lt;path&gt;</code> if <code>configure</code> does not automatically locate the platform FreeType files.</p>
318322
<h3 id="cups">CUPS</h3>
319323
<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>
320324
<ul>
321325
<li>To install on an apt-based Linux, try running <code>sudo apt-get install libcups2-dev</code>.</li>
322326
<li>To install on an rpm-based Linux, try running <code>sudo yum install cups-devel</code>.</li>
327+
<li>To install on Alpine Linux, try running <code>sudo apk add cups-dev</code>.</li>
323328
</ul>
324329
<p>Use <code>--with-cups=&lt;path&gt;</code> if <code>configure</code> does not properly locate your CUPS files.</p>
325330
<h3 id="x11">X11</h3>
326331
<p>Certain <a href="http://www.x.org/">X11</a> libraries and include files are required on Linux.</p>
327332
<ul>
328333
<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>
329334
<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>
335+
<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>
330336
</ul>
331337
<p>Use <code>--with-x=&lt;path&gt;</code> if <code>configure</code> does not properly locate your X11 files.</p>
332338
<h3 id="alsa">ALSA</h3>
333339
<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>
334340
<ul>
335341
<li>To install on an apt-based Linux, try running <code>sudo apt-get install libasound2-dev</code>.</li>
336342
<li>To install on an rpm-based Linux, try running <code>sudo yum install alsa-lib-devel</code>.</li>
343+
<li>To install on Alpine Linux, try running <code>sudo apk add alsa-lib-dev</code>.</li>
337344
</ul>
338345
<p>Use <code>--with-alsa=&lt;path&gt;</code> if <code>configure</code> does not properly locate your ALSA files.</p>
339346
<h3 id="libffi">libffi</h3>
340347
<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>
341348
<ul>
342349
<li>To install on an apt-based Linux, try running <code>sudo apt-get install libffi-dev</code>.</li>
343350
<li>To install on an rpm-based Linux, try running <code>sudo yum install libffi-devel</code>.</li>
351+
<li>To install on Alpine Linux, try running <code>sudo apk add libffi-dev</code>.</li>
344352
</ul>
345353
<p>Use <code>--with-libffi=&lt;path&gt;</code> if <code>configure</code> does not properly locate your libffi files.</p>
346354
<h2 id="build-tools-requirements">Build Tools Requirements</h2>
@@ -349,6 +357,7 @@ <h3 id="autoconf">Autoconf</h3>
349357
<ul>
350358
<li>To install on an apt-based Linux, try running <code>sudo apt-get install autoconf</code>.</li>
351359
<li>To install on an rpm-based Linux, try running <code>sudo yum install autoconf</code>.</li>
360+
<li>To install on Alpine Linux, try running <code>sudo apk add autoconf</code>.</li>
352361
<li>To install on macOS, try running <code>brew install autoconf</code>.</li>
353362
<li>To install on Windows, try running <code>&lt;path to Cygwin setup&gt;/setup-x86_64 -q -P autoconf</code>.</li>
354363
</ul>
@@ -688,6 +697,15 @@ <h3 id="creating-and-using-sysroots-with-qemu-deboostrap">Creating And Using Sys
688697
<p>Additional architectures might be supported by Debian/Ubuntu Ports.</p>
689698
<h3 id="building-for-armaarch64">Building for ARM/aarch64</h3>
690699
<p>A common cross-compilation target is the ARM CPU. When building for ARM, it is useful to set the ABI profile. A number of pre-defined ABI profiles are available using <code>--with-abi-profile</code>: arm-vfp-sflt, arm-vfp-hflt, arm-sflt, armv5-vfp-sflt, armv6-vfp-hflt. Note that soft-float ABIs are no longer properly supported by the JDK.</p>
700+
<h3 id="building-for-musl">Building for musl</h3>
701+
<p>Just like it's possible to cross-compile for a different CPU, it's possible to cross-compile for musl libc on a glibc-based <em>build</em> system. A devkit suitable for most target CPU architectures can be obtained from <a href="https://musl.cc">musl.cc</a>. After installing the required packages in the sysroot, configure the build with <code>--openjdk-target</code>:</p>
702+
<pre><code>sh ./configure --with-jvm-variants=server \
703+
--with-boot-jdk=$BOOT_JDK \
704+
--with-build-jdk=$BUILD_JDK \
705+
--openjdk-target=x86_64-unknown-linux-musl \
706+
--with-devkit=$DEVKIT \
707+
--with-sysroot=$SYSROOT</code></pre>
708+
<p>and run <code>make</code> normally.</p>
691709
<h3 id="verifying-the-build">Verifying the Build</h3>
692710
<p>The build will end up in a directory named like <code>build/linux-arm-normal-server-release</code>.</p>
693711
<p>Inside this build output directory, the <code>images/jdk</code> will contain the newly built JDK, for your <em>target</em> system.</p>

doc/building.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,13 @@ For rpm-based distributions (Fedora, Red Hat, etc), try this:
273273
sudo yum groupinstall "Development Tools"
274274
```
275275

276+
For Alpine Linux, aside from basic tooling, install the GNU versions of some
277+
programs:
278+
279+
```
280+
sudo apk add build-base bash grep zip
281+
```
282+
276283
### AIX
277284

278285
Please consult the AIX section of the [Supported Build Platforms](
@@ -431,6 +438,7 @@ rather than bundling the JDK's own copy.
431438
libfreetype6-dev`.
432439
* To install on an rpm-based Linux, try running `sudo yum install
433440
freetype-devel`.
441+
* To install on Alpine Linux, try running `sudo apk add freetype-dev`.
434442

435443
Use `--with-freetype-include=<path>` and `--with-freetype-lib=<path>`
436444
if `configure` does not automatically locate the platform FreeType files.
@@ -445,6 +453,7 @@ your operating system.
445453
libcups2-dev`.
446454
* To install on an rpm-based Linux, try running `sudo yum install
447455
cups-devel`.
456+
* To install on Alpine Linux, try running `sudo apk add cups-dev`.
448457

449458
Use `--with-cups=<path>` if `configure` does not properly locate your CUPS
450459
files.
@@ -458,6 +467,8 @@ Linux.
458467
libx11-dev libxext-dev libxrender-dev libxrandr-dev libxtst-dev libxt-dev`.
459468
* To install on an rpm-based Linux, try running `sudo yum install
460469
libXtst-devel libXt-devel libXrender-devel libXrandr-devel libXi-devel`.
470+
* To install on Alpine Linux, try running `sudo apk add libx11-dev
471+
libxext-dev libxrender-dev libxrandr-dev libxtst-dev libxt-dev`.
461472

462473
Use `--with-x=<path>` if `configure` does not properly locate your X11 files.
463474

@@ -470,6 +481,7 @@ required on Linux. At least version 0.9.1 of ALSA is required.
470481
libasound2-dev`.
471482
* To install on an rpm-based Linux, try running `sudo yum install
472483
alsa-lib-devel`.
484+
* To install on Alpine Linux, try running `sudo apk add alsa-lib-dev`.
473485

474486
Use `--with-alsa=<path>` if `configure` does not properly locate your ALSA
475487
files.
@@ -484,6 +496,7 @@ Hotspot.
484496
libffi-dev`.
485497
* To install on an rpm-based Linux, try running `sudo yum install
486498
libffi-devel`.
499+
* To install on Alpine Linux, try running `sudo apk add libffi-dev`.
487500

488501
Use `--with-libffi=<path>` if `configure` does not properly locate your libffi
489502
files.
@@ -499,6 +512,7 @@ platforms. At least version 2.69 is required.
499512
autoconf`.
500513
* To install on an rpm-based Linux, try running `sudo yum install
501514
autoconf`.
515+
* To install on Alpine Linux, try running `sudo apk add autoconf`.
502516
* To install on macOS, try running `brew install autoconf`.
503517
* To install on Windows, try running `<path to Cygwin setup>/setup-x86_64 -q
504518
-P autoconf`.
@@ -1113,6 +1127,25 @@ available using `--with-abi-profile`: arm-vfp-sflt, arm-vfp-hflt, arm-sflt,
11131127
armv5-vfp-sflt, armv6-vfp-hflt. Note that soft-float ABIs are no longer
11141128
properly supported by the JDK.
11151129
1130+
### Building for musl
1131+
1132+
Just like it's possible to cross-compile for a different CPU, it's possible to
1133+
cross-compile for musl libc on a glibc-based *build* system.
1134+
A devkit suitable for most target CPU architectures can be obtained from
1135+
[musl.cc](https://musl.cc). After installing the required packages in the
1136+
sysroot, configure the build with `--openjdk-target`:
1137+
1138+
```
1139+
sh ./configure --with-jvm-variants=server \
1140+
--with-boot-jdk=$BOOT_JDK \
1141+
--with-build-jdk=$BUILD_JDK \
1142+
--openjdk-target=x86_64-unknown-linux-musl \
1143+
--with-devkit=$DEVKIT \
1144+
--with-sysroot=$SYSROOT
1145+
```
1146+
1147+
and run `make` normally.
1148+
11161149
### Verifying the Build
11171150
11181151
The build will end up in a directory named like

0 commit comments

Comments
 (0)