Skip to content

Commit

Permalink
8256182: Update qemu-debootstrap cross-compilation recipe
Browse files Browse the repository at this point in the history
Reviewed-by: sgehwolf
Backport-of: 421a7c3
  • Loading branch information
shipilev committed Nov 8, 2021
1 parent 3a35158 commit 299e6c8
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 17 deletions.
21 changes: 17 additions & 4 deletions doc/building.html
Original file line number Diff line number Diff line change
Expand Up @@ -686,11 +686,24 @@ <h3 id="creating-and-using-sysroots-with-qemu-deboostrap">Creating And Using Sys
<li><p>Install cross-compiler on the <em>build</em> system:</p>
<pre><code>apt install g++-aarch64-linux-gnu gcc-aarch64-linux-gnu</code></pre></li>
<li><p>Create chroot on the <em>build</em> system, configuring it for <em>target</em> system:</p>
<pre><code>sudo qemu-debootstrap --arch=arm64 --verbose \
--include=fakeroot,build-essential,libx11-dev,libxext-dev,libxrender-dev,libxtst-dev,libxt-dev,libcups2-dev,libfontconfig1-dev,libasound2-dev,libfreetype6-dev,libpng12-dev \
--resolve-deps jessie /chroots/arm64 http://httpredir.debian.org/debian/</code></pre></li>
<pre><code>sudo qemu-debootstrap \
--arch=arm64 \
--verbose \
--include=fakeroot,symlinks,build-essential,libx11-dev,libxext-dev,libxrender-dev,libxrandr-dev,libxtst-dev,libxt-dev,libcups2-dev,libfontconfig1-dev,libasound2-dev,libfreetype6-dev,libpng-dev \
--resolve-deps \
buster \
~/sysroot-arm64 \
http://httpredir.debian.org/debian/</code></pre></li>
<li><p>Make sure the symlinks inside the newly created chroot point to proper locations:</p>
<pre><code>sudo chroot ~/sysroot-arm64 symlinks -cr .</code></pre></li>
<li><p>Configure and build with newly created chroot as sysroot/toolchain-path:</p>
<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/
<pre><code>CC=aarch64-linux-gnu-gcc CXX=aarch64-linux-gnu-g++ sh ./configure \
--openjdk-target=aarch64-linux-gnu \
--with-sysroot=~/sysroot-arm64 \
--with-toolchain-path=~/sysroot-arm64 \
--with-freetype-lib=~/sysroot-arm64/usr/lib/aarch64-linux-gnu/ \
--with-freetype-include=~/sysroot-arm64/usr/include/freetype2/ \
--x-libraries=~/sysroot-arm64/usr/lib/aarch64-linux-gnu/
make images
ls build/linux-aarch64-normal-server-release/</code></pre></li>
</ul>
Expand Down
42 changes: 29 additions & 13 deletions doc/building.md
Original file line number Diff line number Diff line change
Expand Up @@ -1100,23 +1100,39 @@ for foreign architectures with native compilation speed.
For example, cross-compiling to AArch64 from x86_64 could be done like this:

* Install cross-compiler on the *build* system:
```
apt install g++-aarch64-linux-gnu gcc-aarch64-linux-gnu
```
```
apt install g++-aarch64-linux-gnu gcc-aarch64-linux-gnu
```

* Create chroot on the *build* system, configuring it for *target* system:
```
sudo qemu-debootstrap --arch=arm64 --verbose \
--include=fakeroot,build-essential,libx11-dev,libxext-dev,libxrender-dev,libxtst-dev,libxt-dev,libcups2-dev,libfontconfig1-dev,libasound2-dev,libfreetype6-dev,libpng12-dev \
--resolve-deps jessie /chroots/arm64 http://httpredir.debian.org/debian/
```
```
sudo qemu-debootstrap \
--arch=arm64 \
--verbose \
--include=fakeroot,symlinks,build-essential,libx11-dev,libxext-dev,libxrender-dev,libxrandr-dev,libxtst-dev,libxt-dev,libcups2-dev,libfontconfig1-dev,libasound2-dev,libfreetype6-dev,libpng-dev \
--resolve-deps \
buster \
~/sysroot-arm64 \
http://httpredir.debian.org/debian/
```

* Make sure the symlinks inside the newly created chroot point to proper locations:
```
sudo chroot ~/sysroot-arm64 symlinks -cr .
```

* Configure and build with newly created chroot as sysroot/toolchain-path:
```
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/
make images
ls build/linux-aarch64-normal-server-release/
```
```
CC=aarch64-linux-gnu-gcc CXX=aarch64-linux-gnu-g++ sh ./configure \
--openjdk-target=aarch64-linux-gnu \
--with-sysroot=~/sysroot-arm64 \
--with-toolchain-path=~/sysroot-arm64 \
--with-freetype-lib=~/sysroot-arm64/usr/lib/aarch64-linux-gnu/ \
--with-freetype-include=~/sysroot-arm64/usr/include/freetype2/ \
--x-libraries=~/sysroot-arm64/usr/lib/aarch64-linux-gnu/
make images
ls build/linux-aarch64-normal-server-release/
```

The build does not create new files in that chroot, so it can be reused for multiple builds
without additional cleanup.
Expand Down

1 comment on commit 299e6c8

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.