This page describes the steps necessary to perform a cros compile build for aarch64 and how to run the resultant images under the Foundation model (ARM's freely available aarc64 simulator).
The steps basically comprise the following
The sysroots directory contains all the cross compilation tools, aarch64 libraries and headers you will need to perform a cross compile build of OpenJDK for aarch64.
For convenience I have provided a pre-built sysroots at http://people.linaro.org/~edward.nevill/aarch64/sysroots.tar.gz
Note that the above sysroots will only work if you are building on a 64-bit x86 linux machine. If you are using anything else you will need to rebuild the sysroots as the cross compilation tools will not work on your macine.
Download the sysroots.tar.gz file above and untar it into the directory containing the jdk8 repository so that the jdk8 directory and sysroots directory are at the same level.
cd <directory containing jdk8>
tar xfz sysroots.tar.gz
ls
jdk8 sysroots sysroots.tar.gz
Two shell scripts have been provided to allow you to quickstart building OpenJDK.
In theory all that should be necessary is
cd jdk8
sh ./cross_configure
sh ./cross_compile 2>&1 | tee compile.log
This should build a client compiler (C1) release version of OpenJDK which may be found in build/linux-aarch64-normal-client-release/images/j2sdk-image
Note: At the end of the build you may see an warning like
WARNING: You have the following ALT_ variables set: ALT_SDT_H=/home/ed/work/aa64/sysroots/genericarmv8/usr/include/sys/sdt.h ALT_ variables are deprecated and will be ignored. Please clean your environment.
This warning may be ignored. The ALT_SDT_H is required and is not ignored!
To build a debug version edit the cross_configure file and change --with-debug-level=release to one of --with-debug-level=fastdebug or --with-debug-level=slowdebug
To build a Zero release change --with-jvm-variants=client to --with-jvm-variants=zero. You can also specify --with-jvm-variants=server, however the server (C2) compiler is still under development at the time of writing.
If you specify a new configuration such as --with-debug-level=slowdebug you may get the following error when you run the cross_compile script.
No CONF given, but more than one configuration found in /home/ed/work/aarch64_tip/jdk8//build. Available configurations: * linux-aarch64-normal-client-slowdebug * linux-aarch64-normal-client-release Please retry building with CONF=(or SPEC= )
To select which configuation you wish to build specify CONF=... before the cross_compile script. For example:
CONF=linux-aarch64-normal-client-slowdebug sh ./cross_compile 2>&1 | tee compile.log
Some other useful options you can specify to configure are:
At the bottom of the page under Get started with Foundation Models click on download now. You will be asked to login. If you have prevously registered for an ARM account login, otherwise you will need to check the license terms, ensure that you are happy with them and register for an ARM account.
After logging in above, on the right hand side of the next page under ARM V8 Foundation Model click Download Now.
The name of the file I downloaded was FM000-KT-00035-r0p8-48rel5.tgz. Obviously the name of the file you download may differ depending on the version number you download, but if you want to download exactly the same version number you can look for it under "Display older versions".
Untar this archive. It will create a directory 'Foundation_v8pkg'. cd to this directory
tar xfz FM000-KT-00035-r0p8-48rel5.tgz
cd Foundation_v8pkg
For convenience I have provided a pre-built kernel and pre-populated rootfs at
Download both these files into the Foundation_v8pkg directory created above and decompress the rootfs.ext2.gz
gzip -d rootfs.ext2.gz
First of all you must mount the root file system. Then copy the OpenJDK image into the home directory of root. Then unmount the filesystem.
sudo mount -o loop rootfs.ext2 /mnt
sudo cp -r .../jdk8/build/linux-aarch64-normal-client-release/images/j2sdk-image /mnt/home/root
sudo umount /mnt
To boot the Foundation model enter
./models/Linux64_GCC-4.1/Foundation_v8 --image kernel.axf --block-device rootfs.ext2 --network nat
An xterm window will open and Linux will boot in the aarch64 simulator. After a short while you will get the root '#' prompt. In the root directory you should find the j2sdk-image directory you copied earlier in addition to a JavaApps directory which contains some sample Java applications.
ls
JavaApps j2sdk-image
The following are brief instructions on running each of the provided sample applications. In each case you can specify the following options.
cd JavaApps/LinPack
../../../j2sdk-image/bin/java Linpack
Mflops/s: 5.012 Time: 0.14 secs Norm Res: 1.43 Precision: 2.220446049250313E-16
cd JavaApps/bm-1.1
../../j2sdk-image/bin/java -classpath dist/fullset/bench1.jar org.eembc.grinderbench.CmdlineWrapper -r 1 -m 1
Copyright (c) 2003-2005, EDN Embedded Microprocessor Benchmark Consortium (EEMBC), Inc.
Parallel.....................8019
kXML.........................4451
PNG decoding.................8928
Chess........................3564
Crypto.......................4330
---------------------------------
cd JavaApps/dry
../../j2sdk-image/bin/java dhry
dhrystone (static): 10 iterations of 30000 executions..........
total time: 3310ms
Result: 90634 dhrystone/sec.
cd JavaApps/ecm
../../j2sdk-image/bin/java CaffeineMarkEmbeddedApp
Sieve score = 1574 (98)
Loop score = 2413 (2017)
Logic score = 4102 (0)
String score = 1135 (708)
Float score = 1609 (185)
Method score = 1905 (166650)
Overall score = 1945
The following programs require you to set the DISPLAY variable within the simulator to the IP address of your X server. For example
export DISPLAY=192.168.1.249:0.0
You will also need to ensure that your X server is capable of accepting a remote connection. Also note that if you want to specify the -X options on the appletviewer command you will need to precede them with -J. For example "-J-Xcomp -J-XX:+PrintCompilation"
cd JavaApps/galaxians
../../j2sdk-image/bin/appletviewer Galaxians.html
cd JavaApps/scared
../../j2sdk-image/bin/appletviewer game.html
cd JavaApps/cm3
../../j2sdk-image/bin/appletviewer CaffeineMark30.html