1 <!DOCTYPE html> |
1 <!DOCTYPE html> |
2 <html> |
2 <html xmlns="http://www.w3.org/1999/xhtml" lang="" xml:lang=""> |
3 <head> |
3 <head> |
4 <meta charset="utf-8"> |
4 <meta charset="utf-8" /> |
5 <meta name="generator" content="pandoc"> |
5 <meta name="generator" content="pandoc" /> |
6 <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes"> |
6 <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" /> |
7 <title>Building the JDK</title> |
7 <title>Building the JDK</title> |
8 <style type="text/css">code{white-space: pre;}</style> |
8 <style type="text/css"> |
9 <link rel="stylesheet" href="../make/data/docs-resources/resources/jdk-default.css"> |
9 code{white-space: pre-wrap;} |
|
10 span.smallcaps{font-variant: small-caps;} |
|
11 span.underline{text-decoration: underline;} |
|
12 div.column{display: inline-block; vertical-align: top; width: 50%;} |
|
13 </style> |
|
14 <link rel="stylesheet" href="../make/data/docs-resources/resources/jdk-default.css" /> |
10 <!--[if lt IE 9]> |
15 <!--[if lt IE 9]> |
11 <script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script> |
16 <script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script> |
12 <![endif]--> |
17 <![endif]--> |
13 <style type="text/css">pre, code, tt { color: #1d6ae5; }</style> |
18 <style type="text/css">pre, code, tt { color: #1d6ae5; }</style> |
14 </head> |
19 </head> |
15 <body> |
20 <body> |
16 <header> |
21 <header id="title-block-header"> |
17 <h1 class="title">Building the JDK</h1> |
22 <h1 class="title">Building the JDK</h1> |
18 </header> |
23 </header> |
19 <nav id="TOC"> |
24 <nav id="TOC"> |
20 <ul> |
25 <ul> |
21 <li><a href="#tldr-instructions-for-the-impatient">TL;DR (Instructions for the Impatient)</a></li> |
26 <li><a href="#tldr-instructions-for-the-impatient">TL;DR (Instructions for the Impatient)</a></li> |
638 <h4 id="alsa-1">ALSA</h4> |
643 <h4 id="alsa-1">ALSA</h4> |
639 <p>You will need alsa libraries suitable for your <em>target</em> system. For most cases, using Debian's pre-built libraries work fine.</p> |
644 <p>You will need alsa libraries suitable for your <em>target</em> system. For most cases, using Debian's pre-built libraries work fine.</p> |
640 <p>Note that alsa is needed even if you only want to build a headless JDK.</p> |
645 <p>Note that alsa is needed even if you only want to build a headless JDK.</p> |
641 <ul> |
646 <ul> |
642 <li><p>Go to <a href="https://www.debian.org/distrib/packages">Debian Package Search</a> and search for the <code>libasound2</code> and <code>libasound2-dev</code> packages for your <em>target</em> system. Download them to /tmp.</p></li> |
647 <li><p>Go to <a href="https://www.debian.org/distrib/packages">Debian Package Search</a> and search for the <code>libasound2</code> and <code>libasound2-dev</code> packages for your <em>target</em> system. Download them to /tmp.</p></li> |
643 <li><p>Install the libraries into the cross-compilation toolchain. For instance:</p> |
648 <li>Install the libraries into the cross-compilation toolchain. For instance:</li> |
|
649 </ul> |
644 <pre><code>cd /tools/gcc-linaro-arm-linux-gnueabihf-raspbian-2012.09-20120921_linux/arm-linux-gnueabihf/libc |
650 <pre><code>cd /tools/gcc-linaro-arm-linux-gnueabihf-raspbian-2012.09-20120921_linux/arm-linux-gnueabihf/libc |
645 dpkg-deb -x /tmp/libasound2_1.0.25-4_armhf.deb . |
651 dpkg-deb -x /tmp/libasound2_1.0.25-4_armhf.deb . |
646 dpkg-deb -x /tmp/libasound2-dev_1.0.25-4_armhf.deb .</code></pre></li> |
652 dpkg-deb -x /tmp/libasound2-dev_1.0.25-4_armhf.deb .</code></pre> |
647 <li><p>If alsa is not properly detected by <code>configure</code>, you can point it out by <code>--with-alsa</code>.</p></li> |
653 <ul> |
|
654 <li>If alsa is not properly detected by <code>configure</code>, you can point it out by <code>--with-alsa</code>.</li> |
648 </ul> |
655 </ul> |
649 <h4 id="x11-1">X11</h4> |
656 <h4 id="x11-1">X11</h4> |
650 <p>You will need X11 libraries suitable for your <em>target</em> system. For most cases, using Debian's pre-built libraries work fine.</p> |
657 <p>You will need X11 libraries suitable for your <em>target</em> system. For most cases, using Debian's pre-built libraries work fine.</p> |
651 <p>Note that X11 is needed even if you only want to build a headless JDK.</p> |
658 <p>Note that X11 is needed even if you only want to build a headless JDK.</p> |
652 <ul> |
659 <ul> |
688 </ul> |
695 </ul> |
689 <h3 id="creating-and-using-sysroots-with-qemu-deboostrap">Creating And Using Sysroots With qemu-deboostrap</h3> |
696 <h3 id="creating-and-using-sysroots-with-qemu-deboostrap">Creating And Using Sysroots With qemu-deboostrap</h3> |
690 <p>Fortunately, you can create sysroots for foreign architectures with tools provided by your OS. On Debian/Ubuntu systems, one could use <code>qemu-deboostrap</code> to create the <em>target</em> system chroot, which would have the native libraries and headers specific to that <em>target</em> system. After that, we can use the cross-compiler on the <em>build</em> system, pointing into chroot to get the build dependencies right. This allows building for foreign architectures with native compilation speed.</p> |
697 <p>Fortunately, you can create sysroots for foreign architectures with tools provided by your OS. On Debian/Ubuntu systems, one could use <code>qemu-deboostrap</code> to create the <em>target</em> system chroot, which would have the native libraries and headers specific to that <em>target</em> system. After that, we can use the cross-compiler on the <em>build</em> system, pointing into chroot to get the build dependencies right. This allows building for foreign architectures with native compilation speed.</p> |
691 <p>For example, cross-compiling to AArch64 from x86_64 could be done like this:</p> |
698 <p>For example, cross-compiling to AArch64 from x86_64 could be done like this:</p> |
692 <ul> |
699 <ul> |
693 <li><p>Install cross-compiler on the <em>build</em> system:</p> |
700 <li>Install cross-compiler on the <em>build</em> system:</li> |
694 <pre><code>apt install g++-aarch64-linux-gnu gcc-aarch64-linux-gnu</code></pre></li> |
701 </ul> |
695 <li><p>Create chroot on the <em>build</em> system, configuring it for <em>target</em> system:</p> |
702 <pre><code>apt install g++-aarch64-linux-gnu gcc-aarch64-linux-gnu</code></pre> |
|
703 <ul> |
|
704 <li>Create chroot on the <em>build</em> system, configuring it for <em>target</em> system:</li> |
|
705 </ul> |
696 <pre><code>sudo qemu-debootstrap --arch=arm64 --verbose \ |
706 <pre><code>sudo qemu-debootstrap --arch=arm64 --verbose \ |
697 --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 \ |
707 --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 \ |
698 --resolve-deps jessie /chroots/arm64 http://httpredir.debian.org/debian/</code></pre></li> |
708 --resolve-deps jessie /chroots/arm64 http://httpredir.debian.org/debian/</code></pre> |
699 <li><p>Configure and build with newly created chroot as sysroot/toolchain-path:</p> |
709 <ul> |
|
710 <li>Configure and build with newly created chroot as sysroot/toolchain-path:</li> |
|
711 </ul> |
700 <pre><code>CC=aarch64-linux-gnu-gcc CXX=aarch64-linux-gnu-g++ sh ./configure --openjdk-target=aarch64-linux-gnu --with-sysroot=/chroots/arm64/ --with-toolchain-path=/chroots/arm64/ |
712 <pre><code>CC=aarch64-linux-gnu-gcc CXX=aarch64-linux-gnu-g++ sh ./configure --openjdk-target=aarch64-linux-gnu --with-sysroot=/chroots/arm64/ --with-toolchain-path=/chroots/arm64/ |
701 make images |
713 make images |
702 ls build/linux-aarch64-normal-server-release/</code></pre></li> |
714 ls build/linux-aarch64-normal-server-release/</code></pre> |
703 </ul> |
|
704 <p>The build does not create new files in that chroot, so it can be reused for multiple builds without additional cleanup.</p> |
715 <p>The build does not create new files in that chroot, so it can be reused for multiple builds without additional cleanup.</p> |
705 <p>Architectures that are known to successfully cross-compile like this are:</p> |
716 <p>Architectures that are known to successfully cross-compile like this are:</p> |
706 <table> |
717 <table> |
707 <thead> |
718 <thead> |
708 <tr class="header"> |
719 <tr class="header"> |
858 <pre><code>fatal error - couldn't allocate heap |
869 <pre><code>fatal error - couldn't allocate heap |
859 cannot create ... Permission denied |
870 cannot create ... Permission denied |
860 spawn failed</code></pre> |
871 spawn failed</code></pre> |
861 <p>This can be a sign of a Cygwin problem. See the information about solving problems in the <a href="#cygwin">Cygwin</a> section. Rebooting the computer might help temporarily.</p> |
872 <p>This can be a sign of a Cygwin problem. See the information about solving problems in the <a href="#cygwin">Cygwin</a> section. Rebooting the computer might help temporarily.</p> |
862 <h3 id="getting-help">Getting Help</h3> |
873 <h3 id="getting-help">Getting Help</h3> |
863 <p>If none of the suggestions in this document helps you, or if you find what you believe is a bug in the build system, please contact the Build Group by sending a mail to <script type="text/javascript"> |
874 <p>If none of the suggestions in this document helps you, or if you find what you believe is a bug in the build system, please contact the Build Group by sending a mail to <a href="mailto:build-dev@openjdk.java.net">build-dev@openjdk.java.net</a>. Please include the relevant parts of the configure and/or build log.</p> |
864 <!-- |
|
865 h='openjdk.java.net';a='@';n='build-dev';e=n+a+h; |
|
866 document.write('<a h'+'ref'+'="ma'+'ilto'+':'+e+'" clas'+'s="em' + 'ail">'+e+'<\/'+'a'+'>'); |
|
867 // --> |
|
868 </script><noscript>build-dev at openjdk dot java dot net</noscript>. Please include the relevant parts of the configure and/or build log.</p> |
|
869 <p>If you need general help or advice about developing for the JDK, you can also contact the Adoption Group. See the section on <a href="#contributing-to-openjdk">Contributing to OpenJDK</a> for more information.</p> |
875 <p>If you need general help or advice about developing for the JDK, you can also contact the Adoption Group. See the section on <a href="#contributing-to-openjdk">Contributing to OpenJDK</a> for more information.</p> |
870 <h2 id="hints-and-suggestions-for-advanced-users">Hints and Suggestions for Advanced Users</h2> |
876 <h2 id="hints-and-suggestions-for-advanced-users">Hints and Suggestions for Advanced Users</h2> |
871 <h3 id="setting-up-a-repository-for-pushing-changes-defpath">Setting Up a Repository for Pushing Changes (defpath)</h3> |
877 <h3 id="setting-up-a-repository-for-pushing-changes-defpath">Setting Up a Repository for Pushing Changes (defpath)</h3> |
872 <p>To help you prepare a proper push path for a Mercurial repository, there exists a useful tool known as <a href="http://openjdk.java.net/projects/code-tools/defpath">defpath</a>. It will help you setup a proper push path for pushing changes to the JDK.</p> |
878 <p>To help you prepare a proper push path for a Mercurial repository, there exists a useful tool known as <a href="http://openjdk.java.net/projects/code-tools/defpath">defpath</a>. It will help you setup a proper push path for pushing changes to the JDK.</p> |
873 <p>Install the extension by cloning <code>http://hg.openjdk.java.net/code-tools/defpath</code> and updating your <code>.hgrc</code> file. Here's one way to do this:</p> |
879 <p>Install the extension by cloning <code>http://hg.openjdk.java.net/code-tools/defpath</code> and updating your <code>.hgrc</code> file. Here's one way to do this:</p> |