summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSeth Flynn <[email protected]>2025-03-06 06:50:33 -0500
committerSeth Flynn <[email protected]>2025-03-23 19:31:27 -0400
commitc3ff5407ef46dac4a53610a321e39f20a5d4864e (patch)
treeffce27b884e563dc79c40568d552590b971fbb1c
parent8529c2d55a31291ef2eb8627e926b729422e7fbe (diff)
add lwjgl v3.3.3
-rw-r--r--lwjgl.nix5
-rw-r--r--pkgs/lwjgl/default.nix37
-rw-r--r--pkgs/lwjgl/patches/3.3.3/0001-build-use-pkg-config-for-linux-dependencies.patch87
-rw-r--r--pkgs/lwjgl/patches/3.3.3/0002-build-add-support-for-Linux-RISC-V-64.patch657
-rw-r--r--pkgs/lwjgl/patches/3.3.3/0003-build-rpmalloc-get_thread_id-support-on-riscv64.patch28
-rw-r--r--pkgs/lwjgl/patches/3.3.3/0004-build-core-fix-warnings-errors-on-GCC-14.patch104
-rw-r--r--pkgs/lwjgl/patches/3.3.4/0001-build-use-pkg-config-for-linux-dependencies.patch (renamed from pkgs/lwjgl/0001-build-use-pkg-config-for-linux-dependencies.patch)2
-rw-r--r--pkgs/lwjgl/patches/3.3.4/0002-build-allow-local-kotlin.patch (renamed from pkgs/lwjgl/0002-build-allow-local-kotlin.patch)8
-rw-r--r--pkgs/lwjgl/patches/3.3.4/0003-build-allow-linking-against-system-libffi.patch (renamed from pkgs/lwjgl/0003-build-allow-linking-against-system-libffi.patch)2
-rw-r--r--pkgs/lwjgl/patches/3.3.4/0004-build-add-dbus-as-dependency-for-nfd_portal.patch (renamed from pkgs/lwjgl/0004-build-add-dbus-as-dependency-for-nfd_portal.patch)2
-rw-r--r--pkgs/lwjgl/patches/3.3.4/0005-build-allow-setting-pkg-config-prefix-suffix.patch (renamed from pkgs/lwjgl/0005-build-allow-setting-pkg-config-prefix-suffix.patch)2
11 files changed, 917 insertions, 17 deletions
diff --git a/lwjgl.nix b/lwjgl.nix
index 1d633d7..15a6100 100644
--- a/lwjgl.nix
+++ b/lwjgl.nix
@@ -11,6 +11,11 @@
# Versions we're building
versions = {
+ "3.3.3" = {
+ hash = "sha256-5Zyl1UmfWGdxLWfQwdCO04pVcRUZh6QpV/ND5u4CYx8=";
+ antHash = "sha256-wh15d3DPaIegkaA/AWvuGIxPFSOHmGA9iADy4B45IAs=";
+ };
+
"3.3.4" = {
hash = "sha256-U0pPeTqVoruqqhhMrBrczy0qt83a8atr8DyRcGgX/yI=";
antHash = "sha256-BE2sSPgYELCkww8aJV5DYTgHy4LT14RTVh6gRXA64+Q=";
diff --git a/pkgs/lwjgl/default.nix b/pkgs/lwjgl/default.nix
index 4afb03d..33b560f 100644
--- a/pkgs/lwjgl/default.nix
+++ b/pkgs/lwjgl/default.nix
@@ -31,13 +31,29 @@ stdenv.mkDerivation (finalAttrs: {
inherit hash;
};
- patches = [
- ./0001-build-use-pkg-config-for-linux-dependencies.patch
- ./0002-build-allow-local-kotlin.patch
- ./0003-build-allow-linking-against-system-libffi.patch
- ./0004-build-add-dbus-as-dependency-for-nfd_portal.patch
- ./0005-build-allow-setting-pkg-config-prefix-suffix.patch
- ];
+ patches =
+ lib.optionals (lib.versionOlder finalAttrs.version "3.3.4") (
+ [
+ ./patches/3.3.3/0001-build-use-pkg-config-for-linux-dependencies.patch
+ ./patches/3.3.3/0002-build-add-support-for-Linux-RISC-V-64.patch
+ ./patches/3.3.3/0003-build-rpmalloc-get_thread_id-support-on-riscv64.patch
+ ]
+ # Fix building on GCC 14
+ ++ lib.optional (
+ stdenv.cc.isGNU && lib.versionAtLeast stdenv.cc.version "14"
+ ) ./patches/3.3.3/0004-build-core-fix-warnings-errors-on-GCC-14.patch
+ )
+
+ ++ lib.optionals (lib.versionAtLeast finalAttrs.version "3.3.4") [
+ ./patches/3.3.4/0001-build-use-pkg-config-for-linux-dependencies.patch
+ ]
+
+ ++ [
+ ./patches/3.3.4/0002-build-allow-local-kotlin.patch
+ ./patches/3.3.4/0003-build-allow-linking-against-system-libffi.patch
+ ./patches/3.3.4/0004-build-add-dbus-as-dependency-for-nfd_portal.patch
+ ./patches/3.3.4/0005-build-allow-setting-pkg-config-prefix-suffix.patch
+ ];
antJdk = buildPackages.jdk_headless;
antDeps = fetchAntDeps {
@@ -70,6 +86,11 @@ stdenv.mkDerivation (finalAttrs: {
xorg.libXt
];
+ # Fixes building against GCC 14
+ hardeningDisable = lib.optionals (
+ stdenv.hostPlatform.isRiscV64 && (stdenv.cc.isGNU && lib.versionAtLeast stdenv.cc.version "14")
+ ) [ "fortify" ];
+
antFlags =
[
"-Dgcc.libpath.opengl=${libglvnd}/lib"
@@ -85,8 +106,6 @@ stdenv.mkDerivation (finalAttrs: {
];
env = {
- NIX_LDFLAGS = "-lffi";
-
JAVA_HOME = finalAttrs.antJdk.home;
JAVA8_HOME = buildPackages.jdk8_headless.home;
diff --git a/pkgs/lwjgl/patches/3.3.3/0001-build-use-pkg-config-for-linux-dependencies.patch b/pkgs/lwjgl/patches/3.3.3/0001-build-use-pkg-config-for-linux-dependencies.patch
new file mode 100644
index 0000000..ac3fed9
--- /dev/null
+++ b/pkgs/lwjgl/patches/3.3.3/0001-build-use-pkg-config-for-linux-dependencies.patch
@@ -0,0 +1,87 @@
+From 79cfa341e15c6d986614e41750ec769cee19a7ba Mon Sep 17 00:00:00 2001
+From: Seth Flynn <[email protected]>
+Date: Wed, 5 Mar 2025 16:20:59 -0500
+Subject: [PATCH 1/4] build: use pkg-config for linux dependencies
+
+Adapted from https://cgit.freebsd.org/ports/commit/?id=680dc7bb031d0f708c2dd38f055ec8d63ee68b8a
+
+Backported from a 3.3.4 patchset
+
+(cherry picked from commit 44e2d7fdaf32809e9b50d63834fc834dccb7752d)
+---
+ config/linux/build.xml | 39 ++++++++++++++++++++++-----------------
+ 1 file changed, 22 insertions(+), 17 deletions(-)
+
+diff --git a/config/linux/build.xml b/config/linux/build.xml
+index 67a5d0685..0c14b7866 100644
+--- a/config/linux/build.xml
++++ b/config/linux/build.xml
+@@ -262,13 +262,17 @@
+ <!-- NativeFileDialog -->
+ <build module="nfd" simple="true" linker="g++" if:true="${binding.nfd}">
+ <beforeCompile>
+- <local name="linux.triplet"/>
+- <condition property="linux.triplet" value="x86_64-linux-gnu"><not><isset property="build.arch.arm"/></not></condition>
+- <condition property="linux.triplet" value="arm-linux-gnueabihf"><isset property="build.arch.arm32"/></condition>
+- <condition property="linux.triplet" value="aarch64-linux-gnu"><isset property="build.arch.arm64"/></condition>
+-
++ <local name="gtk3-cflags"/>
++ <local name="gtk3-libflags"/>
++ <local name="stderr"/>
++ <exec outputproperty="gtk3-cflags" errorproperty="stderr" executable="pkg-config" failonerror="true" taskname="gtk-3.0-cflags">
++ <arg line="--cflags gtk+-3.0"/>
++ </exec>
++ <exec outputproperty="gtk3-libflags" errorproperty="stderr" executable="pkg-config" failonerror="true" taskname="gtk-3.0-libflags">
++ <arg line="--libs gtk+-3.0"/>
++ </exec>
+ <compile lang="c++">
+- <arg line="-I/usr/include/gtk-3.0 -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/lib/${linux.triplet}/glib-2.0/include -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/cairo -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/atk-1.0"/>
++ <arg line="${gtk3-cflags}"/>
+ <arg value="-I${src.main.rel}/include"/>
+ <fileset dir="." includes="${src.main}/nfd_gtk.cpp"/>
+ </compile>
+@@ -277,21 +281,22 @@
+ <arg value="-I${src.main.rel}/include"/>
+ </source>
+ <link>
+- <arg value="-lglib-2.0"/>
+- <arg value="-lgobject-2.0"/>
+- <arg value="-lgtk-3"/>
+- <arg value="-lgdk-3"/>
++ <arg line="${gtk3-libflags}"/>
+ </link>
+ </build>
+ <build module="nfd" suffix="_portal" simple="true" linker="g++" if:true="${binding.nfd}">
+ <beforeCompile>
+- <local name="linux.triplet"/>
+- <condition property="linux.triplet" value="x86_64-linux-gnu"><not><isset property="build.arch.arm"/></not></condition>
+- <condition property="linux.triplet" value="arm-linux-gnueabihf"><isset property="build.arch.arm32"/></condition>
+- <condition property="linux.triplet" value="aarch64-linux-gnu"><isset property="build.arch.arm64"/></condition>
+-
++ <local name="glib-cflags"/>
++ <local name="glib-libflags"/>
++ <local name="stderr"/>
++ <exec outputproperty="glib-cflags" errorproperty="stderr" executable="pkg-config" failonerror="true" taskname="glib-cflags">
++ <arg line="--cflags glib-2.0"/>
++ </exec>
++ <exec outputproperty="glib-libflags" errorproperty="stderr" executable="pkg-config" failonerror="true" taskname="glib-libflags">
++ <arg line="--libs glib-2.0"/>
++ </exec>
+ <compile lang="c++">
+- <arg line="-I/usr/include/dbus-1.0 -I/usr/lib64/dbus-1.0/include -I/usr/lib/${linux.triplet}/dbus-1.0/include"/>
++ <arg line="${glib-cflags}"/>
+ <arg value="-I${src.main.rel}/include"/>
+ <fileset dir="." includes="${src.main}/nfd_portal.cpp"/>
+ </compile>
+@@ -300,7 +305,7 @@
+ <arg value="-I${src.main.rel}/include"/>
+ </source>
+ <link>
+- <arg value="-ldbus-1"/>
++ <arg line="${glib-libflags}"/>
+ </link>
+ </build>
+
+--
+2.48.1
+
diff --git a/pkgs/lwjgl/patches/3.3.3/0002-build-add-support-for-Linux-RISC-V-64.patch b/pkgs/lwjgl/patches/3.3.3/0002-build-add-support-for-Linux-RISC-V-64.patch
new file mode 100644
index 0000000..be25bf4
--- /dev/null
+++ b/pkgs/lwjgl/patches/3.3.3/0002-build-add-support-for-Linux-RISC-V-64.patch
@@ -0,0 +1,657 @@
+From 428742a24616448a1453a21b2431373089b892e0 Mon Sep 17 00:00:00 2001
+From: Glavo <[email protected]>
+Date: Fri, 26 May 2023 20:14:13 +0800
+Subject: [PATCH 2/4] build: add support for Linux RISC-V 64
+
+Backport of https://github.com/LWJGL/lwjgl3/pull/890
+
+(cherry picked from commit 437a4ad56feaf358f611c87c1cf470352df42bbd)
+---
+ README.md | 1 +
+ build.gradle.kts | 9 +-
+ build.xml | 30 ++++++-
+ config/build-bindings.xml | 10 +--
+ config/build-definitions.xml | 28 +++++--
+ config/linux/build.xml | 13 +--
+ config/macos/build.xml | 2 +-
+ config/windows/build.xml | 2 +-
+ .../core/src/main/c/libffi/arm/ffitarget.h | 6 +-
+ modules/lwjgl/core/src/main/c/libffi/ffi.h | 22 +++--
+ .../src/main/c/libffi/riscv64/ffitarget.h | 82 +++++++++++++++++++
+ .../core/src/main/c/libffi/x86/ffitarget.h | 3 +
+ .../main/java/org/lwjgl/system/Platform.java | 16 +++-
+ .../c/org_lwjgl_util_xxhash_XXHash.c | 8 +-
+ .../kotlin/xxhash/templates/xxhash.kt | 8 +-
+ 15 files changed, 189 insertions(+), 51 deletions(-)
+ create mode 100644 modules/lwjgl/core/src/main/c/libffi/riscv64/ffitarget.h
+
+diff --git a/README.md b/README.md
+index 8007f292d..fdab7c8aa 100644
+--- a/README.md
++++ b/README.md
+@@ -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
+diff --git a/build.gradle.kts b/build.gradle.kts
+index bf8f96ae6..7f7461374 100644
+--- a/build.gradle.kts
++++ b/build.gradle.kts
+@@ -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"),
+@@ -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
+ ),
+@@ -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
+ ),
+@@ -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(
+@@ -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
+ ),
+diff --git a/build.xml b/build.xml
+index d0fad8224..7490b210f 100644
+--- a/build.xml
++++ b/build.xml
+@@ -900,7 +900,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"/>
+@@ -1176,6 +1176,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"/>
+@@ -1206,6 +1207,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"/>
+
+@@ -1273,6 +1277,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>
+@@ -1301,6 +1308,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"/>
+@@ -1328,6 +1336,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>
+@@ -1538,6 +1547,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"/>
+@@ -1572,6 +1585,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"/>
+
+@@ -1610,6 +1626,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"/>
+@@ -1649,6 +1668,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"/>
+@@ -1693,6 +1713,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>
+
+@@ -1714,6 +1735,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"/>
+
+@@ -1773,6 +1797,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"/>
+
+@@ -1804,6 +1831,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"/>
+diff --git a/config/build-bindings.xml b/config/build-bindings.xml
+index 16316c159..90461d07e 100644
+--- a/config/build-bindings.xml
++++ b/config/build-bindings.xml
+@@ -37,7 +37,7 @@ This script is included in /config/build-definitions.xml.
+ <property name="binding.lz4" value="true"/>
+ <condition property="binding.meow" value="true" else="false">
+ <or>
+- <not><isset property="build.arch.arm"/></not>
++ <isset property="build.arch.x64|x86"/>
+ <isset property="build.arch.arm64"/>
+ </or>
+ </condition>
+@@ -50,7 +50,7 @@ This script is included in /config/build-definitions.xml.
+ <property name="binding.opencl" value="true"/>
+ <property name="binding.opengl" value="true"/>
+ <property name="binding.opengles" value="true"/>
+- <condition property="binding.openvr" value="false" else="true"><isset property="build.arch.arm"/></condition>
++ <condition property="binding.openvr" value="true" else="false"><isset property="build.arch.x64|x86"/></condition>
+ <property name="binding.openxr" value="true"/>
+ <property name="binding.opus" value="true"/>
+ <property name="binding.par" value="true"/>
+@@ -63,11 +63,11 @@ This script is included in /config/build-definitions.xml.
+ <property name="binding.rpmalloc" value="true"/>
+ <property name="binding.shaderc" value="true"/>
+ <property name="binding.spvc" value="true"/>
+- <condition property="binding.sse" value="false" else="true"><isset property="build.arch.arm"/></condition>
++ <condition property="binding.sse" value="true" else="false"><isset property="build.arch.x64|x86"/></condition>
+ <property name="binding.stb" value="true"/>
+ <property name="binding.tinyexr" value="true"/>
+ <property name="binding.tinyfd" value="true"/>
+- <condition property="binding.tootle" value="false" else="true"><isset property="build.arch.arm"/></condition>
++ <condition property="binding.tootle" value="true" else="false"><isset property="build.arch.x64|x86"/></condition>
+ <property name="binding.vulkan" value="true"/>
+ <condition property="binding.vma" value="true" else="false"><istrue value="${binding.vulkan}"/></condition>
+ <property name="binding.xxhash" value="true"/>
+@@ -89,7 +89,7 @@ This script is included in /config/build-definitions.xml.
+ <and>
+ <isset property="OCULUS_SDK_PATH"/>
+ <available file="${OCULUS_SDK_PATH}/LibOVR/Include/OVR_CAPI.h"/>
+- <not><isset property="build.arch.arm"/></not>
++ <isset property="build.arch.x64|x86"/>
+ </and>
+ </condition>
+
+diff --git a/config/build-definitions.xml b/config/build-definitions.xml
+index 6fc879679..04a9ddbea 100644
+--- a/config/build-definitions.xml
++++ b/config/build-definitions.xml
+@@ -34,15 +34,29 @@ This script is included in /build.xml and /config/update-dependencies.xml.
+ <contains string="${os.arch}" substring="aarch64"/>
+ </or>
+ </condition>
++ <condition property="build.arch.riscv" value="true">
++ <or>
++ <contains string="${build.arch}" substring="riscv"/>
++ <contains string="${os.arch}" substring="riscv"/>
++ </or>
++ </condition>
++ <condition property="build.arch.x64|x86" value="true">
++ <and>
++ <not><isset property="build.arch.arm"/></not>
++ <not><isset property="build.arch.riscv"/></not>
++ </and>
++ </condition>
+
+ <!-- Normalize os.arch -->
+- <condition property="build.arch" value="arm64" unless:set="build.arch"><and> <isset property="build.arch.arm"/> <istrue value="${is64Bit}"/></and></condition>
+- <condition property="build.arch" value="arm32" unless:set="build.arch"><and> <isset property="build.arch.arm"/> <isfalse value="${is64Bit}"/></and></condition>
+- <condition property="build.arch" value="x64" unless:set="build.arch"><and><not><isset property="build.arch.arm"/></not><istrue value="${is64Bit}"/></and></condition>
+- <condition property="build.arch" value="x86" unless:set="build.arch"><and><not><isset property="build.arch.arm"/></not><isfalse value="${is64Bit}"/></and></condition>
+-
+- <fail message="Invalid or unsupported build architecture: ${build.arch}. Supported: x64, x86, arm64, arm32">
+- <condition><not><matches string="${build.arch}" pattern="^(x64|x86|arm64|arm32)$"/></not></condition>
++ <condition property="build.arch" value="arm64" unless:set="build.arch"><and><isset property="build.arch.arm"/> <istrue value="${is64Bit}"/></and></condition>
++ <condition property="build.arch" value="arm32" unless:set="build.arch"><and><isset property="build.arch.arm"/> <isfalse value="${is64Bit}"/></and></condition>
++ <condition property="build.arch" value="riscv64" unless:set="build.arch"><and><isset property="build.arch.riscv"/> <istrue value="${is64Bit}"/></and></condition>
++ <condition property="build.arch" value="x64" unless:set="build.arch"><and><isset property="build.arch.x64|x86"/><istrue value="${is64Bit}"/></and></condition>
++ <condition property="build.arch" value="x86" unless:set="build.arch"><and><isset property="build.arch.x64|x86"/><isfalse value="${is64Bit}"/></and></condition>
++ <property name="build.arch" value="${os.arch}" unless:set="build.arch"/>
++
++ <fail message="Invalid or unsupported build architecture: ${build.arch}. Supported: x64, x86, arm64, arm32, riscv64">
++ <condition><not><matches string="${build.arch}" pattern="^(x64|x86|arm64|arm32|riscv64)$"/></not></condition>
+ </fail>
+
+ <property name="build.arch.${build.arch}" value="true"/>
+diff --git a/config/linux/build.xml b/config/linux/build.xml
+index 0c14b7866..217ab784b 100644
+--- a/config/linux/build.xml
++++ b/config/linux/build.xml
+@@ -7,6 +7,7 @@
+
+ <property name="gcc.prefix" value="aarch64-linux-gnu-" if:set="build.arch.arm64"/>
+ <property name="gcc.prefix" value="arm-linux-gnueabihf-" if:set="build.arch.arm32"/>
++ <property name="gcc.prefix" value="riscv64-linux-gnu-" if:set="build.arch.riscv64"/>
+
+ <condition property="gcc.prefix" value="${gcc.prefix}" else="">
+ <isset property="gcc.prefix"/>
+@@ -38,6 +39,7 @@
+ <arg line="-c -std=gnu++14" if:set="cpp"/>
+ <arg line="-m64" if:set="build.arch.x64"/>
+ <arg line="-m32 -mfpmath=sse -msse -msse2" if:set="build.arch.x86"/>
++ <arg line="-march=rv64g" if:set="build.arch.riscv64"/>
+ <arg line="-O3 @{lto} -fPIC @{flags} -pthread -DNDEBUG -DLWJGL_LINUX -DLWJGL_${build.arch}"/>
+ <arg line="-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0 -D_GNU_SOURCE"/>
+ <arg line="-D_FILE_OFFSET_BITS=64"/>
+@@ -177,7 +179,8 @@
+ <arg value="-I${src.main.rel}/libffi"/>
+ <arg value="-I${src.main.rel}/libffi/aarch64" if:set="build.arch.arm64"/>
+ <arg value="-I${src.main.rel}/libffi/arm" if:set="build.arch.arm32"/>
+- <arg value="-I${src.main.rel}/libffi/x86" unless:set="build.arch.arm"/>
++ <arg value="-I${src.main.rel}/libffi/riscv64" if:set="build.arch.riscv64"/>
++ <arg value="-I${src.main.rel}/libffi/x86" if:set="build.arch.x64|x86"/>
+ <arg value="-DX86_64" if:set="build.arch.x64"/> <!-- for libffi/x86/ffitarget.h -->
+ <arg value="-I${src.main.rel}/${platform}/liburing"/>
+ <arg value="-I${src.main.rel}/${platform}/liburing/include"/>
+@@ -233,9 +236,9 @@
+ <!-- Meow -->
+ <sequential if:true="${binding.meow}">
+ <local name="meow.flags"/>
+- <condition property="meow.flags" value="-march=armv8-a+crypto" else="-maes -msse4.2">
+- <isset property="build.arch.arm"/>
+- </condition>
++ <condition property="meow.flags" value="-march=armv8-a+crypto"><isset property="build.arch.arm"/></condition>
++ <condition property="meow.flags" value="-maes -msse4.2"><isset property="build.arch.x64|x86"/></condition>
++
+ <build module="meow" simple="true" flags="-Werror -Wfatal-errors ${meow.flags}"/>
+ </sequential>
+
+@@ -460,7 +463,7 @@
+ <fileset dir="." includes="${src.main}/common/*.c"/>
+ <fileset dir="." includes="${src.main}/compress/*.c"/>
+ <fileset dir="." includes="${src.main}/decompress/*.c"/>
+- <fileset dir="." includes="${src.main}/decompress/*.S" unless:set="build.arch.arm"/>
++ <fileset dir="." includes="${src.main}/decompress/*.S" if:set="build.arch.x64|x86"/>
+ <fileset dir="." includes="${src.main}/dictBuilder/*.c"/>
+ <fileset dir="." includes="${module.lwjgl}/xxhash/src/main/c/xxhash.c"/>
+ </compile>
+diff --git a/config/macos/build.xml b/config/macos/build.xml
+index df22e3ef6..79ccd34fc 100644
+--- a/config/macos/build.xml
++++ b/config/macos/build.xml
+@@ -141,7 +141,7 @@
+ <arg value="-I${src.main.rel}/libffi"/>
+ <arg value="-I${src.main.rel}/libffi/aarch64" if:set="build.arch.arm64"/>
+ <arg value="-I${src.main.rel}/libffi/arm" if:set="build.arch.arm32"/>
+- <arg value="-I${src.main.rel}/libffi/x86" unless:set="build.arch.arm"/>
++ <arg value="-I${src.main.rel}/libffi/x86" if:set="build.arch.x64|x86"/>
+ <!-- for libffi/x86/ffitarget.h -->
+ <arg value="-DX86_64" if:set="build.arch.x64"/>
+ <fileset dir=".">
+diff --git a/config/windows/build.xml b/config/windows/build.xml
+index fc1476c9e..6aa67c5ea 100644
+--- a/config/windows/build.xml
++++ b/config/windows/build.xml
+@@ -150,7 +150,7 @@ EXPORTS
+ <arg value="/I${src.main}\libffi"/>
+ <arg value="/I${src.main}\libffi\aarch64" if:set="build.arch.arm64"/>
+ <arg value="/I${src.main}\libffi\arm" if:set="build.arch.arm32"/>
+- <arg value="/I${src.main}\libffi\x86" unless:set="build.arch.arm"/>
++ <arg value="/I${src.main}\libffi\x86" if:set="build.arch.x64|x86"/>
+ <!-- for libffi/x86/ffitarget.h -->
+ <arg value="/DX86_WIN32" if:set="build.arch.x86"/>
+ <arg value="/DX86_WIN64" if:set="build.arch.x64"/>
+diff --git a/modules/lwjgl/core/src/main/c/libffi/arm/ffitarget.h b/modules/lwjgl/core/src/main/c/libffi/arm/ffitarget.h
+index 0f505888f..ffaf1b898 100644
+--- a/modules/lwjgl/core/src/main/c/libffi/arm/ffitarget.h
++++ b/modules/lwjgl/core/src/main/c/libffi/arm/ffitarget.h
+@@ -43,7 +43,7 @@ typedef enum ffi_abi {
+ FFI_SYSV,
+ FFI_VFP,
+ FFI_LAST_ABI,
+-#if defined(__ARM_PCS_VFP) || defined(_M_ARM)
++#if defined(__ARM_PCS_VFP) || defined(_WIN32)
+ FFI_DEFAULT_ABI = FFI_VFP,
+ #else
+ FFI_DEFAULT_ABI = FFI_SYSV,
+@@ -71,7 +71,7 @@ typedef enum ffi_abi {
+ signed char vfp_args[16] \
+
+ #define FFI_TARGET_SPECIFIC_VARIADIC
+-#ifndef _M_ARM
++#ifndef _WIN32
+ #define FFI_TARGET_HAS_COMPLEX_TYPE
+ #endif
+
+@@ -91,7 +91,7 @@ typedef enum ffi_abi {
+ #endif
+
+ #else
+-#ifdef _MSC_VER
++#ifdef _WIN32
+ #define FFI_TRAMPOLINE_SIZE 16
+ #define FFI_TRAMPOLINE_CLOSURE_FUNCTION 12
+ #else
+diff --git a/modules/lwjgl/core/src/main/c/libffi/ffi.h b/modules/lwjgl/core/src/main/c/libffi/ffi.h
+index 6c16184a7..117f4eaa0 100644
+--- a/modules/lwjgl/core/src/main/c/libffi/ffi.h
++++ b/modules/lwjgl/core/src/main/c/libffi/ffi.h
+@@ -147,7 +147,7 @@ typedef struct _ffi_type
+ when using the static version of the library.
+ Besides, as a workaround, they can define FFI_BUILDING if they
+ *know* they are going to link with the static library. */
+-#if defined _MSC_VER
++#if defined _MSC_VER && !defined(FFI_STATIC_BUILD)
+ # if defined FFI_BUILDING_DLL /* Building libffi.DLL with msvcc.sh */
+ # define FFI_API __declspec(dllexport)
+ # elif !defined FFI_BUILDING /* Importing libffi.DLL */
+@@ -370,14 +370,6 @@ typedef struct {
+ FFI_API void *ffi_closure_alloc (size_t size, void **code);
+ FFI_API void ffi_closure_free (void *);
+
+-#if defined(PA_LINUX) || defined(PA_HPUX)
+-#define FFI_CLOSURE_PTR(X) ((void *)((unsigned int)(X) | 2))
+-#define FFI_RESTORE_PTR(X) ((void *)((unsigned int)(X) & ~3))
+-#else
+-#define FFI_CLOSURE_PTR(X) (X)
+-#define FFI_RESTORE_PTR(X) (X)
+-#endif
+-
+ FFI_API ffi_status
+ ffi_prep_closure (ffi_closure*,
+ ffi_cif *,
+@@ -413,7 +405,7 @@ typedef struct {
+
+ /* If this is enabled, then a raw closure has the same layout
+ as a regular closure. We use this to install an intermediate
+- handler to do the transaltion, void** -> ffi_raw*. */
++ handler to do the translation, void** -> ffi_raw*. */
+
+ void (*translate_args)(ffi_cif*,void*,void**,void*);
+ void *this_closure;
+@@ -481,7 +473,7 @@ ffi_prep_java_raw_closure_loc (ffi_java_raw_closure*,
+
+ #endif /* FFI_CLOSURES */
+
+-#if FFI_GO_CLOSURES
++#ifdef FFI_GO_CLOSURES
+
+ typedef struct {
+ void *tramp;
+@@ -524,8 +516,14 @@ FFI_API
+ ffi_status ffi_get_struct_offsets (ffi_abi abi, ffi_type *struct_type,
+ size_t *offsets);
+
+-/* Useful for eliminating compiler warnings. */
++/* Convert between closure and function pointers. */
++#if defined(PA_LINUX) || defined(PA_HPUX)
++#define FFI_FN(f) ((void (*)(void))((unsigned int)(f) | 2))
++#define FFI_CL(f) ((void *)((unsigned int)(f) & ~3))
++#else
+ #define FFI_FN(f) ((void (*)(void))f)
++#define FFI_CL(f) ((void *)(f))
++#endif
+
+ /* ---- Definitions shared with assembly code ---------------------------- */
+
+diff --git a/modules/lwjgl/core/src/main/c/libffi/riscv64/ffitarget.h b/modules/lwjgl/core/src/main/c/libffi/riscv64/ffitarget.h
+new file mode 100644
+index 000000000..bb7acc16b
+--- /dev/null
++++ b/modules/lwjgl/core/src/main/c/libffi/riscv64/ffitarget.h
+@@ -0,0 +1,82 @@
++/* -----------------------------------------------------------------*-C-*-
++ ffitarget.h - 2014 Michael Knyszek
++
++ Target configuration macros for RISC-V.
++
++ Permission is hereby granted, free of charge, to any person obtaining
++ a copy of this software and associated documentation files (the
++ ``Software''), to deal in the Software without restriction, including
++ without limitation the rights to use, copy, modify, merge, publish,
++ distribute, sublicense, and/or sell copies of the Software, and to
++ permit persons to whom the Software is furnished to do so, subject to
++ the following conditions:
++
++ The above copyright notice and this permission notice shall be included
++ in all copies or substantial portions of the Software.
++
++ THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
++ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
++ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
++ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
++ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
++ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
++ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
++ DEALINGS IN THE SOFTWARE.
++
++ ----------------------------------------------------------------------- */
++
++#ifndef LIBFFI_TARGET_H
++#define LIBFFI_TARGET_H
++
++#ifndef LIBFFI_H
++#error "Please do not include ffitarget.h directly into your source. Use ffi.h instead."
++#endif
++
++#ifndef __riscv
++#error "libffi was configured for a RISC-V target but this does not appear to be a RISC-V compiler."
++#endif
++
++#ifndef LIBFFI_ASM
++
++typedef unsigned long ffi_arg;
++typedef signed long ffi_sarg;
++
++/* FFI_UNUSED_NN and riscv_unused are to maintain ABI compatibility with a
++ distributed Berkeley patch from 2014, and can be removed at SONAME bump */
++typedef enum ffi_abi {
++ FFI_FIRST_ABI = 0,
++ FFI_SYSV,
++ FFI_UNUSED_1,
++ FFI_UNUSED_2,
++ FFI_UNUSED_3,
++ FFI_LAST_ABI,
++
++ FFI_DEFAULT_ABI = FFI_SYSV,
++// LWJGL
++ FFI_WIN64 = -1,
++ FFI_GNUW64 = -1,
++ FFI_UNIX64 = -1,
++ FFI_EFI64 = -1,
++//FFI_SYSV = -1,
++ FFI_STDCALL = -1,
++ FFI_THISCALL = -1,
++ FFI_FASTCALL = -1,
++ FFI_MS_CDECL = -1,
++ FFI_PASCAL = -1,
++ FFI_REGISTER = -1,
++ FFI_VFP = -1
++} ffi_abi;
++
++#endif /* LIBFFI_ASM */
++
++/* ---- Definitions for closures ----------------------------------------- */
++
++#define FFI_CLOSURES 1
++#define FFI_GO_CLOSURES 1
++#define FFI_TRAMPOLINE_SIZE 24
++#define FFI_NATIVE_RAW_API 0
++#define FFI_EXTRA_CIF_FIELDS unsigned riscv_nfixedargs; unsigned riscv_unused;
++#define FFI_TARGET_SPECIFIC_VARIADIC
++
++#endif
++
+diff --git a/modules/lwjgl/core/src/main/c/libffi/x86/ffitarget.h b/modules/lwjgl/core/src/main/c/libffi/x86/ffitarget.h
+index 3cc1b29b4..2cbab9abf 100644
+--- a/modules/lwjgl/core/src/main/c/libffi/x86/ffitarget.h
++++ b/modules/lwjgl/core/src/main/c/libffi/x86/ffitarget.h
+@@ -41,6 +41,9 @@
+
+ #if defined (X86_64) && defined (__i386__)
+ #undef X86_64
++#warning ******************************************************
++#warning ********** X86 IS DEFINED ****************************
++#warning ******************************************************
+ #define X86
+ #endif
+
+diff --git a/modules/lwjgl/core/src/main/java/org/lwjgl/system/Platform.java b/modules/lwjgl/core/src/main/java/org/lwjgl/system/Platform.java
+index 1babac919..cca52a058 100644
+--- a/modules/lwjgl/core/src/main/java/org/lwjgl/system/Platform.java
++++ b/modules/lwjgl/core/src/main/java/org/lwjgl/system/Platform.java
+@@ -54,7 +54,8 @@ public enum Platform {
+ X64(true),
+ X86(false),
+ ARM64(true),
+- ARM32(false);
++ ARM32(false),
++ RISCV64(true);
+
+ static final Architecture current;
+
+@@ -64,9 +65,16 @@ public enum Platform {
+ String osArch = System.getProperty("os.arch");
+ boolean is64Bit = osArch.contains("64") || osArch.startsWith("armv8");
+
+- current = osArch.startsWith("arm") || osArch.startsWith("aarch64")
+- ? (is64Bit ? Architecture.ARM64 : Architecture.ARM32)
+- : (is64Bit ? Architecture.X64 : Architecture.X86);
++ if (osArch.startsWith("arm") || osArch.startsWith("aarch")) {
++ current = is64Bit ? Architecture.ARM64 : Architecture.ARM32;
++ } else if (osArch.startsWith("riscv")) {
++ if (!"riscv64".equals(osArch)) {
++ throw new UnsupportedOperationException("Only RISC-V 64 is supported.");
++ }
++ current = Architecture.RISCV64;
++ } else {
++ current = is64Bit ? Architecture.X64 : Architecture.X86;
++ }
+ }
+
+ Architecture(boolean is64Bit) {
+diff --git a/modules/lwjgl/xxhash/src/generated/c/org_lwjgl_util_xxhash_XXHash.c b/modules/lwjgl/xxhash/src/generated/c/org_lwjgl_util_xxhash_XXHash.c
+index 98f2b3d78..b16210daf 100644
+--- a/modules/lwjgl/xxhash/src/generated/c/org_lwjgl_util_xxhash_XXHash.c
++++ b/modules/lwjgl/xxhash/src/generated/c/org_lwjgl_util_xxhash_XXHash.c
+@@ -6,12 +6,12 @@
+ #include "common_tools.h"
+ DISABLE_WARNINGS()
+ #include "lwjgl_malloc.h"
+-#if defined(LWJGL_arm64) || defined(LWJGL_arm32)
+- #define XXH_INLINE_ALL
+- #include "xxhash.h"
+-#else
++#if defined(LWJGL_x86) || defined(LWJGL_x64)
+ #include "xxh_x86dispatch.c"
+ #include "xxh_x86dispatch.h"
++#else
++ #define XXH_INLINE_ALL
++ #include "xxhash.h"
+ #endif
+ ENABLE_WARNINGS()
+
+diff --git a/modules/lwjgl/xxhash/src/templates/kotlin/xxhash/templates/xxhash.kt b/modules/lwjgl/xxhash/src/templates/kotlin/xxhash/templates/xxhash.kt
+index 470a389b9..5506b01bf 100644
+--- a/modules/lwjgl/xxhash/src/templates/kotlin/xxhash/templates/xxhash.kt
++++ b/modules/lwjgl/xxhash/src/templates/kotlin/xxhash/templates/xxhash.kt
+@@ -11,12 +11,12 @@ val xxhash = "XXHash".nativeClass(Module.XXHASH, prefix = "XXH", prefixMethod =
+ nativeDirective(
+ """DISABLE_WARNINGS()
+ #include "lwjgl_malloc.h"
+-#if defined(LWJGL_arm64) || defined(LWJGL_arm32)
+- #define XXH_INLINE_ALL
+- #include "xxhash.h"
+-#else
++#if defined(LWJGL_x86) || defined(LWJGL_x64)
+ #include "xxh_x86dispatch.c"
+ #include "xxh_x86dispatch.h"
++#else
++ #define XXH_INLINE_ALL
++ #include "xxhash.h"
+ #endif
+ ENABLE_WARNINGS()""")
+
+--
+2.48.1
+
diff --git a/pkgs/lwjgl/patches/3.3.3/0003-build-rpmalloc-get_thread_id-support-on-riscv64.patch b/pkgs/lwjgl/patches/3.3.3/0003-build-rpmalloc-get_thread_id-support-on-riscv64.patch
new file mode 100644
index 0000000..414e43a
--- /dev/null
+++ b/pkgs/lwjgl/patches/3.3.3/0003-build-rpmalloc-get_thread_id-support-on-riscv64.patch
@@ -0,0 +1,28 @@
+From 6e3048e9f0e4fb13a72c219337f2908736efc8ff Mon Sep 17 00:00:00 2001
+From: Jackson Huff <[email protected]>
+Date: Sat, 7 Oct 2023 08:37:11 +0000
+Subject: [PATCH 3/4] build(rpmalloc) get_thread_id support on riscv64
+
+Backport of https://github.com/LWJGL/lwjgl3/pull/890
+
+(cherry picked from commit 924b295fd7e7fde3cbe19ea30d6b115e6dd0ef15)
+---
+ modules/lwjgl/rpmalloc/src/main/c/rpmalloc.c | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/modules/lwjgl/rpmalloc/src/main/c/rpmalloc.c b/modules/lwjgl/rpmalloc/src/main/c/rpmalloc.c
+index 755127d9f..317242721 100644
+--- a/modules/lwjgl/rpmalloc/src/main/c/rpmalloc.c
++++ b/modules/lwjgl/rpmalloc/src/main/c/rpmalloc.c
+@@ -808,6 +808,8 @@ get_thread_id(void) {
+ # else
+ __asm__ volatile ("mrs %0, tpidr_el0" : "=r" (tid));
+ # endif
++# elif defined(__riscv)
++ __asm__ volatile ("mv %0, tp" : "=r" (tid));
+ # else
+ # error This platform needs implementation of get_thread_id()
+ # endif
+--
+2.48.1
+
diff --git a/pkgs/lwjgl/patches/3.3.3/0004-build-core-fix-warnings-errors-on-GCC-14.patch b/pkgs/lwjgl/patches/3.3.3/0004-build-core-fix-warnings-errors-on-GCC-14.patch
new file mode 100644
index 0000000..4959d26
--- /dev/null
+++ b/pkgs/lwjgl/patches/3.3.3/0004-build-core-fix-warnings-errors-on-GCC-14.patch
@@ -0,0 +1,104 @@
+From e505a0af3154bbfdbce7506be14604e0b1973f4b Mon Sep 17 00:00:00 2001
+From: Ioannis Tsakpinis <[email protected]>
+Date: Fri, 7 Jun 2024 19:28:12 +0300
+Subject: [PATCH 4/4] build(core) fix warnings & errors on GCC 14
+
+Backport of https://github.com/LWJGL/lwjgl3/commit/2923ace9dc239d64db1cf3c55238a2af9d6ce7e4
+
+(cherry picked from commit 2923ace9dc239d64db1cf3c55238a2af9d6ce7e4)
+---
+ config/linux/build.xml | 4 ++--
+ config/macos/build.xml | 8 +++++---
+ modules/lwjgl/core/src/main/c/common_tools.c | 2 +-
+ modules/lwjgl/stb/src/generated/c/org_lwjgl_stb_STBDXT.c | 1 +
+ .../stb/src/templates/kotlin/stb/templates/stb_dxt.kt | 1 +
+ 5 files changed, 10 insertions(+), 6 deletions(-)
+
+diff --git a/config/linux/build.xml b/config/linux/build.xml
+index 217ab784b..a5b7a1799 100644
+--- a/config/linux/build.xml
++++ b/config/linux/build.xml
+@@ -40,7 +40,7 @@
+ <arg line="-m64" if:set="build.arch.x64"/>
+ <arg line="-m32 -mfpmath=sse -msse -msse2" if:set="build.arch.x86"/>
+ <arg line="-march=rv64g" if:set="build.arch.riscv64"/>
+- <arg line="-O3 @{lto} -fPIC @{flags} -pthread -DNDEBUG -DLWJGL_LINUX -DLWJGL_${build.arch}"/>
++ <arg line="-O3 -flto=auto -fPIC @{flags} -pthread -DNDEBUG -DLWJGL_LINUX -DLWJGL_${build.arch}"/>
+ <arg line="-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0 -D_GNU_SOURCE"/>
+ <arg line="-D_FILE_OFFSET_BITS=64"/>
+
+@@ -131,7 +131,7 @@
+ <arg value="-m32" if:set="build.arch.x86"/>
+
+ <arg line="-z noexecstack"/>
+- <arg line="-O3 -flto -fPIC -pthread -o ${lib.arch}/lib${name}.so"/>
++ <arg line="-O3 -flto=auto -fPIC -pthread -o ${lib.arch}/lib${name}.so"/>
+
+ <arg line="-Wl,--no-undefined"/>
+ <arg line="-Wl,--version-script,${version.script}"/>
+diff --git a/config/macos/build.xml b/config/macos/build.xml
+index 79ccd34fc..e604e5ac1 100644
+--- a/config/macos/build.xml
++++ b/config/macos/build.xml
+@@ -32,8 +32,9 @@
+ <mkdir dir="@{dest}"/>
+ <apply dir="@{dest}" executable="${clang}" dest="@{dest}" skipemptyfilesets="true" failonerror="true" parallel="true" taskname="Compiler">
+ <arg line="-c -ObjC" unless:set="cpp"/>
+- <arg line="-c -std=c++14" if:set="cpp"/>
+- <arg line="-O3 -flto -fPIC @{flags} -DNDEBUG -DLWJGL_MACOS -DLWJGL_${build.arch} -isysroot ${sdkroot} -mmacosx-version-min=${macosx-version-min}"/>
++ <arg line="-c -std=c++20" if:set="cpp"/>
++ <arg line="-O3 -flto=auto -fPIC @{flags} -DNDEBUG -DLWJGL_MACOS -DLWJGL_${build.arch} -isysroot ${sdkroot} -mmacosx-version-min=@{macos}"/>
++ <arg line="-target x64-apple-darwin -arch x86_64" unless:set="build.arch.arm"/>
+ <arg line="-target aarch64-apple-darwin -arch arm64" if:set="build.arch.arm"/>
+
+ <arg value="-I${jni.headers}"/>
+@@ -108,7 +109,8 @@
+ <beforeLink unless:set="lib-uptodate"/>
+ <apply executable="${clang}" failonerror="true" parallel="true" taskname="Linker" unless:set="lib-uptodate">
+ <srcfile/>
+- <arg line='-dynamiclib -Wl,-no_compact_unwind -mmacosx-version-min=${macosx-version-min} -o ${lib.arch}/lib${name}.dylib -O3 -flto -fPIC'/>
++ <arg line='-dynamiclib -Wl,-no_compact_unwind -mmacosx-version-min=@{macos} -o ${lib.arch}/lib${name}.dylib -O3 -flto=auto -fPIC'/>
++ <arg line="-target x64-apple-darwin -arch x86_64" unless:set="build.arch.arm"/>
+ <arg line="-target aarch64-apple-darwin -arch arm64" if:set="build.arch.arm"/>
+ <fileset dir="${dest}" includes="*.o"/>
+ <link/>
+diff --git a/modules/lwjgl/core/src/main/c/common_tools.c b/modules/lwjgl/core/src/main/c/common_tools.c
+index 73cc3972d..4911a8159 100644
+--- a/modules/lwjgl/core/src/main/c/common_tools.c
++++ b/modules/lwjgl/core/src/main/c/common_tools.c
+@@ -36,7 +36,7 @@ static inline void detachCurrentThread(void) {
+ }
+
+ static inline EnvData* createEnvData(jboolean async, JNIEnv* env) {
+- EnvData* data = (EnvData*)calloc(sizeof(EnvData), 1);
++ EnvData* data = (EnvData*)calloc(1, sizeof(EnvData));
+
+ data->async = async;
+ data->env = env;
+diff --git a/modules/lwjgl/stb/src/generated/c/org_lwjgl_stb_STBDXT.c b/modules/lwjgl/stb/src/generated/c/org_lwjgl_stb_STBDXT.c
+index 54e20d48a..3aa6b3ee2 100644
+--- a/modules/lwjgl/stb/src/generated/c/org_lwjgl_stb_STBDXT.c
++++ b/modules/lwjgl/stb/src/generated/c/org_lwjgl_stb_STBDXT.c
+@@ -7,6 +7,7 @@
+ DISABLE_WARNINGS()
+ #define STB_DXT_IMPLEMENTATION
+ #define STB_DXT_STATIC
++#include <string.h>
+ #include "stb_dxt.h"
+ ENABLE_WARNINGS()
+
+diff --git a/modules/lwjgl/stb/src/templates/kotlin/stb/templates/stb_dxt.kt b/modules/lwjgl/stb/src/templates/kotlin/stb/templates/stb_dxt.kt
+index e49031d47..28bff9352 100644
+--- a/modules/lwjgl/stb/src/templates/kotlin/stb/templates/stb_dxt.kt
++++ b/modules/lwjgl/stb/src/templates/kotlin/stb/templates/stb_dxt.kt
+@@ -11,6 +11,7 @@ val stb_dxt = "STBDXT".nativeClass(Module.STB, prefix = "STB", prefixMethod = "s
+ includeSTBAPI(
+ """#define STB_DXT_IMPLEMENTATION
+ #define STB_DXT_STATIC
++#include <string.h>
+ #include "stb_dxt.h"""")
+
+ documentation =
+--
+2.48.1
+
diff --git a/pkgs/lwjgl/0001-build-use-pkg-config-for-linux-dependencies.patch b/pkgs/lwjgl/patches/3.3.4/0001-build-use-pkg-config-for-linux-dependencies.patch
index 38c3878..092cf1d 100644
--- a/pkgs/lwjgl/0001-build-use-pkg-config-for-linux-dependencies.patch
+++ b/pkgs/lwjgl/patches/3.3.4/0001-build-use-pkg-config-for-linux-dependencies.patch
@@ -1,4 +1,4 @@
-From cee6a98721d8417802fcd394df0215312be9a7ea Mon Sep 17 00:00:00 2001
+From 44e2d7fdaf32809e9b50d63834fc834dccb7752d Mon Sep 17 00:00:00 2001
From: Seth Flynn <[email protected]>
Date: Wed, 5 Mar 2025 16:20:59 -0500
Subject: [PATCH 1/5] build: use pkg-config for linux dependencies
diff --git a/pkgs/lwjgl/0002-build-allow-local-kotlin.patch b/pkgs/lwjgl/patches/3.3.4/0002-build-allow-local-kotlin.patch
index 7b7a4a2..3d230ce 100644
--- a/pkgs/lwjgl/0002-build-allow-local-kotlin.patch
+++ b/pkgs/lwjgl/patches/3.3.4/0002-build-allow-local-kotlin.patch
@@ -1,4 +1,4 @@
-From 05573f96ed4b73591679bdf2c17a83f57acfd171 Mon Sep 17 00:00:00 2001
+From 36e6e8bb83e94c92f29ef94c59fc3119b8ba425d Mon Sep 17 00:00:00 2001
From: Seth Flynn <[email protected]>
Date: Wed, 5 Mar 2025 16:34:50 -0500
Subject: [PATCH 2/5] build: allow local kotlin
@@ -10,10 +10,10 @@ Adapted from https://cgit.freebsd.org/ports/commit/?id=680dc7bb031d0f708c2dd38f0
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/config/build-definitions.xml b/config/build-definitions.xml
-index 407195ff7..4026a057c 100644
+index fdba3a476..7a3cace54 100644
--- a/config/build-definitions.xml
+++ b/config/build-definitions.xml
-@@ -121,7 +121,8 @@ This script is included in /build.xml and /config/update-dependencies.xml.
+@@ -100,7 +100,8 @@ This script is included in /build.xml and /config/update-dependencies.xml.
<property name="lib" location="bin/libs" relative="true"/>
@@ -24,7 +24,7 @@ index 407195ff7..4026a057c 100644
<property name="module.lwjgl" location="modules/lwjgl" relative="true"/>
diff --git a/update-dependencies.xml b/update-dependencies.xml
-index 98fd77b19..39501492a 100644
+index 87b110045..10a9da19d 100644
--- a/update-dependencies.xml
+++ b/update-dependencies.xml
@@ -27,7 +27,7 @@
diff --git a/pkgs/lwjgl/0003-build-allow-linking-against-system-libffi.patch b/pkgs/lwjgl/patches/3.3.4/0003-build-allow-linking-against-system-libffi.patch
index e212bfa..2271e5f 100644
--- a/pkgs/lwjgl/0003-build-allow-linking-against-system-libffi.patch
+++ b/pkgs/lwjgl/patches/3.3.4/0003-build-allow-linking-against-system-libffi.patch
@@ -1,4 +1,4 @@
-From f79338f70f72e5d4606b8d99c2f49f85b486be3e Mon Sep 17 00:00:00 2001
+From ff06851e13461c0b9e2f258caf6a2ead16bad700 Mon Sep 17 00:00:00 2001
From: Seth Flynn <[email protected]>
Date: Wed, 5 Mar 2025 16:43:57 -0500
Subject: [PATCH 3/5] build: allow linking against system libffi
diff --git a/pkgs/lwjgl/0004-build-add-dbus-as-dependency-for-nfd_portal.patch b/pkgs/lwjgl/patches/3.3.4/0004-build-add-dbus-as-dependency-for-nfd_portal.patch
index 0f6eb87..77a673a 100644
--- a/pkgs/lwjgl/0004-build-add-dbus-as-dependency-for-nfd_portal.patch
+++ b/pkgs/lwjgl/patches/3.3.4/0004-build-add-dbus-as-dependency-for-nfd_portal.patch
@@ -1,4 +1,4 @@
-From 3aa1fc52ef6a72c99f1224e4c8ba2aedeb515277 Mon Sep 17 00:00:00 2001
+From 258c919591e2aa16fded26c637c8130a27c9feab Mon Sep 17 00:00:00 2001
From: Seth Flynn <[email protected]>
Date: Wed, 5 Mar 2025 17:10:20 -0500
Subject: [PATCH 4/5] build: add dbus as dependency for nfd_portal
diff --git a/pkgs/lwjgl/0005-build-allow-setting-pkg-config-prefix-suffix.patch b/pkgs/lwjgl/patches/3.3.4/0005-build-allow-setting-pkg-config-prefix-suffix.patch
index ff39bec..2ef60d8 100644
--- a/pkgs/lwjgl/0005-build-allow-setting-pkg-config-prefix-suffix.patch
+++ b/pkgs/lwjgl/patches/3.3.4/0005-build-allow-setting-pkg-config-prefix-suffix.patch
@@ -1,4 +1,4 @@
-From 57db58f899e99bc37cbc98b6403ab9aa2f04862f Mon Sep 17 00:00:00 2001
+From 508b031f7edf480f6a8966c8779e395658d206c5 Mon Sep 17 00:00:00 2001
From: Seth Flynn <[email protected]>
Date: Thu, 6 Mar 2025 02:31:35 -0500
Subject: [PATCH 5/5] build: allow setting pkg-config prefix & suffix