Skip to content

Commit

Permalink
build: add support for Linux RISC-V 64
Browse files Browse the repository at this point in the history
  • Loading branch information
Glavo authored and Spasi committed Nov 9, 2023
1 parent 924b295 commit 437a4ad
Show file tree
Hide file tree
Showing 17 changed files with 226 additions and 78 deletions.
56 changes: 31 additions & 25 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ jobs:
ARCH: [x64]
include:
- ARCH: x64
PACKAGES: libX11-devel libXt-devel gtk3-devel libdbus-1-dev
defaults:
run:
shell: bash
steps:
- name: Upgrade git
run: |
Expand All @@ -72,7 +74,7 @@ jobs:
yum -y install ant awscli zstd
- name: Install LWJGL dependencies
run: |
yum -y install ${{matrix.PACKAGES}}
yum -y install libX11-devel libXt-devel gtk3-devel libdbus-1-dev
mkdir jdk8
curl -L https://cdn.azul.com/zulu/bin/zulu8.72.0.17-ca-fx-jdk8.0.382-linux_x64.tar.gz | tar xz -C jdk8 --strip-components 1
- name: Restore kotlinc output
Expand Down Expand Up @@ -126,24 +128,29 @@ jobs:
needs: cache-kotlinc
runs-on: ubuntu-latest
container:
image: ubuntu:18.04
image: ${{matrix.CONTAINER}}
strategy:
fail-fast: false
matrix:
ARCH: [arm32, arm64]
ARCH: [arm32, arm64, riscv64]
include:
- ARCH: arm32
PACKAGES: gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf libc6-dev-armhf-cross
CROSS_ARCH: armhf
CROSS_PACKAGES: libgtk-3-dev:armhf libatk-bridge2.0-dev:armhf libgdk-pixbuf2.0-dev:armhf libglu-dev:armhf libgl1-mesa-glx:armhf libx11-dev:armhf libxt-dev:armhf libdbus-1-dev:armhf
NATIVE_PARAMS: -Dgcc.libpath.opengl=/usr/lib/arm-linux-gnueabihf/mesa
CONTAINER: ubuntu:18.04
TRIPLET: arm-linux-gnueabihf
- ARCH: arm64
PACKAGES: gcc-aarch64-linux-gnu g++-aarch64-linux-gnu libc6-dev-arm64-cross
CROSS_ARCH: arm64
CROSS_PACKAGES: libgtk-3-dev:arm64 libatk-bridge2.0-dev:arm64 libgdk-pixbuf2.0-dev:arm64 libglu-dev:arm64 libgl1-mesa-glx:arm64 libx11-dev:arm64 libxt-dev:arm64 libdbus-1-dev:arm64
NATIVE_PARAMS: -Dgcc.libpath.opengl=/usr/lib/aarch64-linux-gnu/mesa
CONTAINER: ubuntu:18.04
TRIPLET: aarch64-linux-gnu
- ARCH: riscv64
CROSS_ARCH: riscv64
CONTAINER: ubuntu:20.04
TRIPLET: riscv64-linux-gnu
env:
LWJGL_BUILD_ARCH: ${{matrix.ARCH}}
defaults:
run:
shell: bash
steps:
- name: Upgrade git
run: |
Expand All @@ -153,6 +160,8 @@ jobs:
apt-get -y update
apt-get -y upgrade
add-apt-repository -y ppa:git-core/ppa
if: ${{ matrix.CONTAINER == 'ubuntu:18.04' }}
- run: |
apt-get -y update
apt-get install -y git
- name: Checkout repository
Expand All @@ -162,20 +171,20 @@ jobs:
- name: Install dependencies
run: |
git config --global --add safe.directory $(pwd)
DEBIAN_FRONTEND=noninteractive apt-get -yq install ant awscli curl zstd ${{matrix.PACKAGES}}
DEBIAN_FRONTEND=noninteractive apt-get -yq install ant awscli curl zstd gcc-${{matrix.TRIPLET}} g++-${{matrix.TRIPLET}} libc6-dev-${{matrix.CROSS_ARCH}}-cross
mkdir jdk8
curl -L https://cdn.azul.com/zulu/bin/zulu8.72.0.17-ca-fx-jdk8.0.382-linux_x64.tar.gz | tar xz -C jdk8 --strip-components 1
- name: Prepare cross-compilation
- name: Prepare cross-compilation for $${matrix.CROSS_ARCH}}
run: |
sed -i 's/deb http/deb [arch=amd64,i386] http/' /etc/apt/sources.list
grep "ubuntu.com/ubuntu" /etc/apt/sources.list | tee /etc/apt/sources.list.d/ports.list
sed -i 's/amd64,i386/armhf,arm64/' /etc/apt/sources.list.d/ports.list
sed -i 's/amd64,i386/${{matrix.CROSS_ARCH}}/' /etc/apt/sources.list.d/ports.list
sed -i 's#http://.*/ubuntu#http://ports.ubuntu.com/ubuntu-ports#' /etc/apt/sources.list.d/ports.list
dpkg --add-architecture ${{matrix.CROSS_ARCH}}
apt-get clean
apt-get update || true
- name: Install cross-compilation dependencies
run: apt-get -yq -f --allow-unauthenticated --no-install-suggests --no-install-recommends install ${{matrix.CROSS_PACKAGES}} -o Dpkg::Options::="--force-overwrite"
run: apt-get -yq -f --allow-unauthenticated --no-install-suggests --no-install-recommends install libgtk-3-dev:${{matrix.CROSS_ARCH}} libatk-bridge2.0-dev:${{matrix.CROSS_ARCH}} libgdk-pixbuf2.0-dev:${{matrix.CROSS_ARCH}} libglu-dev:${{matrix.CROSS_ARCH}} libgl1-mesa-glx:${{matrix.CROSS_ARCH}} libx11-dev:${{matrix.CROSS_ARCH}} libxt-dev:${{matrix.CROSS_ARCH}} libdbus-1-dev:${{matrix.CROSS_ARCH}} -o Dpkg::Options::="--force-overwrite"
- name: Restore kotlinc output
uses: actions/cache/restore@v3
with:
Expand All @@ -190,7 +199,7 @@ jobs:
- name: Build Java
run: ant -emacs compile
- name: Build native
run: ant -emacs compile-native ${{matrix.NATIVE_PARAMS}}
run: ant -emacs compile-native -Dgcc.libpath.opengl=/usr/lib/${{matrix.TRIPLET}}/mesa

macos:
name: macOS
Expand Down Expand Up @@ -268,6 +277,9 @@ jobs:
MSVC_ARCH: amd64
- ARCH: arm64
MSVC_ARCH: amd64_arm64
defaults:
run:
shell: cmd
steps:
- name: Checkout repository
uses: actions/checkout@v3
Expand All @@ -285,6 +297,7 @@ jobs:
Invoke-WebRequest https://cdn.azul.com/zulu/bin/zulu8.72.0.17-ca-fx-jdk8.0.382-win_x64.zip -OutFile jdk.zip
Expand-Archive -Path jdk.zip -DestinationPath .\
Rename-Item zulu8.72.0.17-ca-fx-jdk8.0.382-win_x64 jdk8
shell: pwsh
- name: Restore kotlinc output
uses: actions/cache/restore@v3
with:
Expand All @@ -296,39 +309,35 @@ jobs:
fail-on-cache-miss: true
- name: Generate bindings
run: ant -emacs clean-generated generate
shell: cmd
- name: Build Java
run: ant -emacs compile
shell: cmd
- name: Switch to x86 JDK
run: |
Remove-Item -Recurse jdk8
Invoke-WebRequest https://cdn.azul.com/zulu/bin/zulu8.72.0.17-ca-fx-jdk8.0.382-win_i686.zip -OutFile jdk.zip
Expand-Archive -Path jdk.zip -DestinationPath .\
Rename-Item zulu8.72.0.17-ca-fx-jdk8.0.382-win_i686 jdk8
shell: pwsh
if: matrix.ARCH == 'x86'
- name: Build native
run: |
set LWJGL_BUILD_ARCH=${{matrix.ARCH}}
ant -emacs compile-native
shell: cmd
- name: Run tests
run: ant -emacs tests
shell: cmd
if: contains(matrix.ARCH, 'arm') != true
- name: Print test results
run: type bin\test\testng-results.xml
shell: cmd
if: failure()
- name: Run demo with OpenJDK
run: ant demo -Dclass=org.lwjgl.demo.util.lz4.HelloLZ4
shell: cmd
if: matrix.ARCH == 'x64'
- name: Download GraalVM
run: |
Invoke-WebRequest https://download.oracle.com/graalvm/21/latest/graalvm-jdk-21_windows-x64_bin.zip -OutFile jdk-graalvm.zip
Expand-Archive -Path jdk-graalvm.zip -DestinationPath .\
Get-ChildItem graalvm-jdk-21* | Rename-Item -newname jdk-graalvm-21
shell: pwsh
if: matrix.ARCH == 'x64'
- name: Build GraalVM Native Image
run: |
Expand All @@ -341,15 +350,12 @@ jobs:
bin/libs/native;^
config/native-image ^
org.lwjgl.demo.util.lz4.HelloLZ4 --verbose --no-fallback
shell: cmd
if: matrix.ARCH == 'x64'
- name: Run demo with GraalVM JIT
run: |
set JAVA_HOME=jdk-graalvm-21
ant demo -Dclass=org.lwjgl.demo.util.lz4.HelloLZ4
shell: cmd
if: matrix.ARCH == 'x64'
- name: Run demo with GraalVM Native Image
run: org.lwjgl.demo.util.lz4.hellolz4.exe
shell: cmd
if: matrix.ARCH == 'x64'
if: matrix.ARCH == 'x64'
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ following platforms/architectures:
- Linux x64
- Linux arm64 (ARMv8/AArch64)
- Linux arm32 (ARMv7/armhf)
- Linux riscv64
- macOS x64
- macOS arm64
- Windows x64
Expand Down
9 changes: 5 additions & 4 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ enum class Platforms(val classifier: String) {
LINUX("linux"),
LINUX_ARM64("linux-arm64"),
LINUX_ARM32("linux-arm32"),
LINUX_RISCV64("linux-riscv64"),
MACOS("macos"),
MACOS_ARM64("macos-arm64"),
WINDOWS("windows"),
Expand All @@ -88,7 +89,7 @@ enum class Artifacts(
BGFX(
"lwjgl-bgfx", "LWJGL - bgfx bindings",
"A cross-platform, graphics API agnostic rendering library. It provides a high performance, low level abstraction for common platform graphics APIs like OpenGL, Direct3D and Apple Metal.",
Platforms.LINUX, Platforms.LINUX_ARM64, Platforms.LINUX_ARM32,
Platforms.LINUX, Platforms.LINUX_ARM64, Platforms.LINUX_ARM32, Platforms.LINUX_RISCV64,
Platforms.MACOS, Platforms.MACOS_ARM64,
Platforms.WINDOWS, Platforms.WINDOWS_X86
),
Expand Down Expand Up @@ -136,7 +137,7 @@ enum class Artifacts(
KTX(
"lwjgl-ktx", "LWJGL - KTX (Khronos Texture) bindings",
"A lightweight container for textures for OpenGL®, Vulkan® and other GPU APIs.",
Platforms.LINUX, Platforms.LINUX_ARM64, Platforms.LINUX_ARM32,
Platforms.LINUX, Platforms.LINUX_ARM64, Platforms.LINUX_ARM32, Platforms.LINUX_RISCV64,
Platforms.MACOS, Platforms.MACOS_ARM64,
Platforms.WINDOWS, Platforms.WINDOWS_ARM64
),
Expand Down Expand Up @@ -218,7 +219,7 @@ enum class Artifacts(
OPENXR(
"lwjgl-openxr", "LWJGL - OpenXR bindings",
"A royalty-free, open standard that provides high-performance access to Augmented Reality (AR) and Virtual Reality (VR)—collectively known as XR—platforms and devices.",
Platforms.LINUX, Platforms.LINUX_ARM64, Platforms.LINUX_ARM32,
Platforms.LINUX, Platforms.LINUX_ARM64, Platforms.LINUX_ARM32, Platforms.LINUX_RISCV64,
Platforms.WINDOWS, Platforms.WINDOWS_X86, Platforms.WINDOWS_ARM64
),
OPUS(
Expand All @@ -239,7 +240,7 @@ enum class Artifacts(
REMOTERY(
"lwjgl-remotery", "LWJGL - Remotery bindings",
"A realtime CPU/GPU profiler hosted in a single C file with a viewer that runs in a web browser.",
Platforms.LINUX, Platforms.LINUX_ARM64, Platforms.LINUX_ARM32,
Platforms.LINUX, Platforms.LINUX_ARM64, Platforms.LINUX_ARM32, Platforms.LINUX_RISCV64,
Platforms.MACOS, Platforms.MACOS_ARM64,
Platforms.WINDOWS, Platforms.WINDOWS_X86
),
Expand Down
30 changes: 29 additions & 1 deletion build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -901,7 +901,7 @@
<jvmarg value="-Dorg.lwjgl.util.Debug=true"/>
<jvmarg value="-Dorg.lwjgl.util.DebugAllocator=true"/>
<jvmarg value="-XstartOnFirstThread" if:set="platform.macos"/>
<jvmarg value="-Xss256k" unless:set="build.arch.arm"/> <!-- for StackTest::testSOE -->
<jvmarg value="-Xss256k" if:set="build.arch.x64|x86"/> <!-- for StackTest::testSOE -->
<jvmarg line="${jvmargs}" if:set="jvmargs"/>

<xmlfileset dir="${config}" includes="tests.xml,tests_${platform}.xml"/>
Expand Down Expand Up @@ -1177,6 +1177,7 @@
<element name="linux-content" optional="true"/>
<element name="linux-arm64-content" optional="true"/>
<element name="linux-arm32-content" optional="true"/>
<element name="linux-riscv64-content" optional="true"/>
<element name="macos-content" optional="true"/>
<element name="macos-arm64-content" optional="true"/>
<element name="windows-content" optional="true"/>
Expand Down Expand Up @@ -1207,6 +1208,9 @@
<get-release platform="linux" arch="arm32" file="lib@{native-library}.so" if:set="auto-natives"/>
<get-release platform="linux" arch="arm32" file="lib@{native-library}.so.git" if:set="git-revision"/>

<get-release platform="linux" arch="riscv64" file="lib@{native-library}.so" if:set="auto-natives"/>
<get-release platform="linux" arch="riscv64" file="lib@{native-library}.so.git" if:set="git-revision"/>

<get-release platform="macos" arch="x64" file="lib@{native-library}.dylib" if:set="auto-natives"/>
<get-release platform="macos" arch="x64" file="lib@{native-library}.dylib.git" if:set="git-revision"/>

Expand Down Expand Up @@ -1274,6 +1278,9 @@
<natives-jar name="@{name}" title="@{title}" platform="linux-arm32" path="linux/arm32" type="so">
<linux-arm32-content/>
</natives-jar>
<natives-jar name="@{name}" title="@{title}" platform="linux-riscv64" path="linux/riscv64" type="so">
<linux-riscv64-content/>
</natives-jar>
<natives-jar name="@{name}" title="@{title}" platform="macos" path="macos/x64" type="dylib">
<macos-content/>
</natives-jar>
Expand Down Expand Up @@ -1302,6 +1309,7 @@
<element name="linux" optional="true"/>
<element name="linux-arm64" optional="true"/>
<element name="linux-arm32" optional="true"/>
<element name="linux-riscv64" optional="true"/>
<element name="macos" optional="true"/>
<element name="macos-arm64" optional="true"/>
<element name="windows" optional="true"/>
Expand Down Expand Up @@ -1329,6 +1337,7 @@
<linux-content><linux/></linux-content>
<linux-arm64-content><linux-arm64/></linux-arm64-content>
<linux-arm32-content><linux-arm32/></linux-arm32-content>
<linux-riscv64-content><linux-riscv64/></linux-riscv64-content>
<macos-content><macos/></macos-content>
<macos-arm64-content><macos-arm64/></macos-arm64-content>
<windows-content><windows/></windows-content>
Expand Down Expand Up @@ -1539,6 +1548,10 @@
<get-release platform="linux" arch="arm32" file="libassimp.so.git"/>
<get-release platform="linux" arch="arm32" file="libdraco.so"/>

<get-release platform="linux" arch="riscv64" file="libassimp.so"/>
<get-release platform="linux" arch="riscv64" file="libassimp.so.git"/>
<get-release platform="linux" arch="riscv64" file="libdraco.so"/>

<get-release platform="macos" arch="x64" file="libassimp.dylib"/>
<get-release platform="macos" arch="x64" file="libassimp.dylib.git"/>
<get-release platform="macos" arch="x64" file="libdraco.dylib"/>
Expand Down Expand Up @@ -1573,6 +1586,9 @@
<get-release platform="linux" arch="arm32" file="libbgfx.so"/>
<get-release platform="linux" arch="arm32" file="libbgfx.so.git"/>

<get-release platform="linux" arch="riscv64" file="libbgfx.so"/>
<get-release platform="linux" arch="riscv64" file="libbgfx.so.git"/>

<get-release platform="macos" arch="x64" file="libbgfx.dylib"/>
<get-release platform="macos" arch="x64" file="libbgfx.dylib.git"/>

Expand Down Expand Up @@ -1611,6 +1627,9 @@
<get-release platform="linux" arch="arm32" file="libglfw.so"/>
<get-release platform="linux" arch="arm32" file="libglfw.so.git"/>

<get-release platform="linux" arch="riscv64" file="libglfw.so"/>
<get-release platform="linux" arch="riscv64" file="libglfw.so.git"/>

<get-release platform="macos" arch="x64" file="libglfw.dylib"/>
<get-release platform="macos" arch="x64" file="libglfw.dylib.git"/>
<get-release platform="macos" arch="x64" file="libglfw_async.dylib"/>
Expand Down Expand Up @@ -1650,6 +1669,7 @@
<get-release platform="linux" arch="x64" file="libktx.so"/>
<get-release platform="linux" arch="arm64" file="libktx.so"/>
<get-release platform="linux" arch="arm32" file="libktx.so"/>
<get-release platform="linux" arch="riscv64" file="libktx.so"/>
<get-release platform="macos" arch="x64" file="libktx.dylib"/>
<get-release platform="macos" arch="arm64" file="libktx.dylib"/>
<get-release platform="windows" arch="x64" file="ktx.dll"/>
Expand Down Expand Up @@ -1694,6 +1714,7 @@
<get-release platform="linux" arch="x64" file="liblwjgl_nfd_portal.so"/>
<get-release platform="linux" arch="arm64" file="liblwjgl_nfd_portal.so"/>
<get-release platform="linux" arch="arm32" file="liblwjgl_nfd_portal.so"/>
<get-release platform="linux" arch="riscv64" file="liblwjgl_nfd_portal.so"/>
</natives>
</release-module>

Expand All @@ -1715,6 +1736,9 @@
<get-release platform="linux" arch="arm32" file="libopenal.so"/>
<get-release platform="linux" arch="arm32" file="libopenal.so.git"/>

<get-release platform="linux" arch="riscv64" file="libopenal.so"/>
<get-release platform="linux" arch="riscv64" file="libopenal.so.git"/>

<get-release platform="macos" arch="x64" file="libopenal.dylib"/>
<get-release platform="macos" arch="x64" file="libopenal.dylib.git"/>

Expand Down Expand Up @@ -1774,6 +1798,9 @@
<get-release platform="linux" arch="arm32" file="libopenxr_loader.so"/>
<get-release platform="linux" arch="arm32" file="libopenxr_loader.so.git"/>

<get-release platform="linux" arch="riscv64" file="libopenxr_loader.so"/>
<get-release platform="linux" arch="riscv64" file="libopenxr_loader.so.git"/>

<get-release platform="windows" arch="x64" file="openxr-loader.dll"/>
<get-release platform="windows" arch="x64" file="openxr-loader.dll.git"/>

Expand Down Expand Up @@ -1805,6 +1832,7 @@
<get-release platform="linux" arch="x64" file="liblwjgl_remotery.so"/>
<get-release platform="linux" arch="arm64" file="liblwjgl_remotery.so"/>
<get-release platform="linux" arch="arm32" file="liblwjgl_remotery.so"/>
<get-release platform="linux" arch="riscv64" file="liblwjgl_remotery.so"/>

<get-release platform="macos" arch="x64" file="liblwjgl_remotery.dylib"/>
<get-release platform="macos" arch="arm64" file="liblwjgl_remotery.dylib"/>
Expand Down
Loading

0 comments on commit 437a4ad

Please sign in to comment.