Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for FreeBSD aarch64 (it's now a Tier 1 arch). #1581

Merged
merged 2 commits into from
Dec 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Next Release (5.15.0)

Features
--------
* [#1578](https://github.com/java-native-access/jna/pull/1578): Add support for FreeBSD aarch64 - [@alexdupre](https://github.com/alexdupre).

Bug Fixes
---------
Expand Down
6 changes: 6 additions & 0 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,8 @@ com/sun/jna/freebsd-x86/libjnidispatch.so;
processor=x86;osname=freebsd,
com/sun/jna/freebsd-x86-64/libjnidispatch.so;
processor=x86-64;osname=freebsd,
com/sun/jna/freebsd-aarch64/libjnidispatch.so;
processor=aarch64;osname=freebsd,

com/sun/jna/openbsd-x86/libjnidispatch.so;
processor=x86;osname=openbsd,
Expand Down Expand Up @@ -532,6 +534,9 @@ osname=macosx;processor=aarch64
<zipfileset src="${lib.native}/freebsd-x86-64.jar"
includes="*jnidispatch*"
prefix="com/sun/jna/freebsd-x86-64"/>
<zipfileset src="${lib.native}/freebsd-aarch64.jar"
includes="*jnidispatch*"
prefix="com/sun/jna/freebsd-aarch64"/>
<zipfileset src="${lib.native}/openbsd-x86.jar"
includes="*jnidispatch*"
prefix="com/sun/jna/openbsd-x86"/>
Expand Down Expand Up @@ -720,6 +725,7 @@ osname=macosx;processor=aarch64
<copy file="${lib.native}/out-of-date.jar" tofile="${lib.native}/linux-riscv64.jar" overwrite="true"/>
<copy file="${lib.native}/out-of-date.jar" tofile="${lib.native}/freebsd-x86.jar" overwrite="true"/>
<copy file="${lib.native}/out-of-date.jar" tofile="${lib.native}/freebsd-x86-64.jar" overwrite="true"/>
<copy file="${lib.native}/out-of-date.jar" tofile="${lib.native}/freebsd-aarch64.jar" overwrite="true"/>
<copy file="${lib.native}/out-of-date.jar" tofile="${lib.native}/openbsd-x86.jar" overwrite="true"/>
<copy file="${lib.native}/out-of-date.jar" tofile="${lib.native}/openbsd-x86-64.jar" overwrite="true"/>
<copy file="${lib.native}/out-of-date.jar" tofile="${lib.native}/sunos-x86.jar" overwrite="true"/>
Expand Down
Binary file added lib/native/freebsd-aarch64.jar
Binary file not shown.
3 changes: 2 additions & 1 deletion native/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
# Linux (i386/amd64/ppc/arm)
# Solaris (i386/amd64/sparc/sparcv9)
# AIX (ppc/ppc64)
# FreeBSD/OpenBSD/NetBSD (i386/amd64)
# FreeBSD (i386/amd64/aarch64)
# OpenBSD/NetBSD (i386/amd64)
# Android (arm/armv7/aarch64/x86/x86-64/mipsel/mips64el)
#
# Built, but with outstanding bugs (not necessarily within JNA):
Expand Down
60 changes: 60 additions & 0 deletions www/FreeBSD.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
Building JNA for FreeBSD
========================

This recipe was used to build the FreeBSD aarch64 native library on amd64:

```
# Fetch FreeBSD 13.2 image and extract it
wget https://download.freebsd.org/snapshots/VM-IMAGES/13.2-STABLE/aarch64/20231216/FreeBSD-13.2-STABLE-arm64-aarch64-20231216-9986fd59d855-256898.qcow2.xz
xz -d FreeBSD-13.2-STABLE-arm64-aarch64-20231216-9986fd59d855-256898.qcow2.xz

# Ensure there is enough space in the image
qemu-img resize FreeBSD-13.2-STABLE-arm64-aarch64-20231216-9986fd59d855-256898.qcow2 +5G

# Launch aarch64 emulator with downloaded image
qemu-system-aarch64 -m 4096M -cpu cortex-a57 -M virt \
-bios /usr/lib/u-boot/qemu_arm64/u-boot.bin \
-serial telnet::4444,server -nographic \
-drive if=none,file=PATH_TO_IMAGE/FreeBSD-13.2-STABLE-arm64-aarch64-20231216-9986fd59d855-256898.qcow2,id=hd0 \
-device virtio-blk-device,drive=hd0 \
-device virtio-net-device,netdev=net0 \
-netdev user,id=net0

# Connect to terminal for emulated system and boot into single user mode with default shell
telnet localhost 4444

# Resize partitions
gpart show /dev/vtbd0
gpart recover /dev/vtbd0
gpart show /dev/vtbd0
gpart resize -i 3 /dev/vtbd0
growfs /

# Exit single user mode (BSD boots to multi-user)
exit

# Login as root

# Install prerequisites - part 1 - java, build system, rsync
pkg install openjdk17 wget automake rsync gmake gcc
# Adjust fstab (optional, only needed if reboot is planned)
# fdesc /dev/fd fdescfs rw 0 0
# proc /proc procfs rw 0 0

# Install prerequisites - part 2 - ant
wget https://dlcdn.apache.org//ant/binaries/apache-ant-1.10.14-bin.zip
unzip apache-ant-1.10.14-bin.zip

# Transfer JNA source code to build environment
rsync -a --exclude=.git USER@BUILD_HOST:src/jnalib/ jnalib/

# Set current date and time (YYYYMMDDHHMM)
date 202312231627

# Build JNA and run unittests
cd jnalib
/root/apache-ant-1.10.14/bin/ant

# Copy jna native library back to host system

```