Skip to content
Draft
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
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ LWJGL is open source software and freely available at no charge.
Useful links:

- [Wiki](https://github.com/LWJGL/lwjgl3-wiki/wiki)
- [Release Notes](https://github.com/LWJGL/lwjgl3/tree/master/doc/notes)
- [Release Notes](https://github.com/LWJGL/lwjgl3/tree/master/doc/notes)
- [JavaDoc](https://javadoc.lwjgl.org)
- [Blog](https://blog.lwjgl.org)

Expand Down Expand Up @@ -74,6 +74,7 @@ following platforms/architectures:
- Linux arm32 (ARMv7/armhf)
- Linux ppc64le
- Linux riscv64
- Linux loongarch64
- macOS x64
- macOS arm64
- Windows x64
Expand Down Expand Up @@ -198,4 +199,4 @@ LWJGL exists thanks to [all the people](https://github.com/LWJGL/lwjgl3/blob/mas

<a href="https://opencollective.com/lwjgl/donate" target="_blank">
<img src="https://opencollective.com/lwjgl/donate/button@2x.png?color=white" width=300 />
</a>
</a>
11 changes: 6 additions & 5 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_ARM32("linux-arm32"),
LINUX_PPC64LE("linux-ppc64le"),
LINUX_RISCV64("linux-riscv64"),
LINUX_LOONGARCH64("linux-loongarch64"),
MACOS("macos"),
MACOS_ARM64("macos-arm64"),
WINDOWS("windows"),
Expand Down Expand Up @@ -89,7 +90,7 @@ enum class Artifacts(
"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.FREEBSD,
Platforms.LINUX, Platforms.LINUX_ARM64, Platforms.LINUX_ARM32, Platforms.LINUX_PPC64LE, Platforms.LINUX_RISCV64,
Platforms.LINUX, Platforms.LINUX_ARM64, Platforms.LINUX_ARM32, Platforms.LINUX_PPC64LE, Platforms.LINUX_RISCV64, Platforms.LINUX_LOONGARCH64,
Platforms.MACOS, Platforms.MACOS_ARM64,
Platforms.WINDOWS, Platforms.WINDOWS_X86
),
Expand Down Expand Up @@ -134,7 +135,7 @@ enum class Artifacts(
"lwjgl-ktx", "LWJGL - KTX (Khronos Texture) bindings",
"A lightweight container for textures for OpenGL®, Vulkan® and other GPU APIs.",
Platforms.FREEBSD,
Platforms.LINUX, Platforms.LINUX_ARM64, Platforms.LINUX_ARM32, Platforms.LINUX_PPC64LE, Platforms.LINUX_RISCV64,
Platforms.LINUX, Platforms.LINUX_ARM64, Platforms.LINUX_ARM32, Platforms.LINUX_PPC64LE, Platforms.LINUX_RISCV64, Platforms.LINUX_LOONGARCH64,
Platforms.MACOS, Platforms.MACOS_ARM64,
Platforms.WINDOWS, Platforms.WINDOWS_ARM64
),
Expand Down Expand Up @@ -205,7 +206,7 @@ enum class Artifacts(
"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.FREEBSD,
Platforms.LINUX, Platforms.LINUX_ARM64, Platforms.LINUX_ARM32, Platforms.LINUX_PPC64LE, Platforms.LINUX_RISCV64,
Platforms.LINUX, Platforms.LINUX_ARM64, Platforms.LINUX_ARM32, Platforms.LINUX_PPC64LE, Platforms.LINUX_RISCV64, Platforms.LINUX_LOONGARCH64,
Platforms.WINDOWS, Platforms.WINDOWS_X86, Platforms.WINDOWS_ARM64
),
OPUS(
Expand All @@ -222,7 +223,7 @@ enum class Artifacts(
"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.FREEBSD,
Platforms.LINUX, Platforms.LINUX_ARM64, Platforms.LINUX_ARM32, Platforms.LINUX_PPC64LE, Platforms.LINUX_RISCV64,
Platforms.LINUX, Platforms.LINUX_ARM64, Platforms.LINUX_ARM32, Platforms.LINUX_PPC64LE, Platforms.LINUX_RISCV64, Platforms.LINUX_LOONGARCH64,
Platforms.MACOS, Platforms.MACOS_ARM64,
Platforms.WINDOWS, Platforms.WINDOWS_X86
),
Expand Down Expand Up @@ -484,4 +485,4 @@ dependencies {
api("org.lwjgl:${module.artifact}:$version")
}
}
}
}
28 changes: 28 additions & 0 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1172,6 +1172,7 @@
<element name="linux-arm32-content" optional="true"/>
<element name="linux-ppc64le-content" optional="true"/>
<element name="linux-riscv64-content" optional="true"/>
<element name="linux-loongarch64-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 @@ -1211,6 +1212,9 @@
<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="linux" arch="loongarch64" file="lib@{native-library}.so" if:set="auto-natives"/>
<get-release platform="linux" arch="loongarch64" 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 @@ -1287,6 +1291,9 @@
<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="linux-loongarch64" path="linux/loongarch64" type="so">
<linux-loongarch64-content/>
</natives-jar>
<natives-jar name="@{name}" title="@{title}" platform="macos" path="macos/x64" type="dylib">
<macos-content/>
</natives-jar>
Expand Down Expand Up @@ -1318,6 +1325,7 @@
<element name="linux-arm32" optional="true"/>
<element name="linux-ppc64le" optional="true"/>
<element name="linux-riscv64" optional="true"/>
<element name="linux-loongarch64" optional="true"/>
<element name="macos" optional="true"/>
<element name="macos-arm64" optional="true"/>
<element name="windows" optional="true"/>
Expand Down Expand Up @@ -1348,6 +1356,7 @@
<linux-arm32-content><linux-arm32/></linux-arm32-content>
<linux-ppc64le-content><linux-ppc64le/></linux-ppc64le-content>
<linux-riscv64-content><linux-riscv64/></linux-riscv64-content>
<linux-loongarch64-content><linux-loongarch64/></linux-loongarch64-content>
<macos-content><macos/></macos-content>
<macos-arm64-content><macos-arm64/></macos-arm64-content>
<windows-content><windows/></windows-content>
Expand Down Expand Up @@ -1562,6 +1571,10 @@
<get-release platform="linux" arch="riscv64" file="libassimp.so.git"/>
<get-release platform="linux" arch="riscv64" file="libdraco.so"/>

<get-release platform="linux" arch="loongarch64" file="libassimp.so"/>
<get-release platform="linux" arch="loongarch64" file="libassimp.so.git"/>
<get-release platform="linux" arch="loongarch64" 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 @@ -1605,6 +1618,9 @@
<get-release platform="linux" arch="riscv64" file="libbgfx.so"/>
<get-release platform="linux" arch="riscv64" file="libbgfx.so.git"/>

<get-release platform="linux" arch="loongarch64" file="libbgfx.so"/>
<get-release platform="linux" arch="loongarch64" 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 @@ -1649,6 +1665,9 @@
<get-release platform="linux" arch="riscv64" file="libglfw.so"/>
<get-release platform="linux" arch="riscv64" file="libglfw.so.git"/>

<get-release platform="linux" arch="loongarch64" file="libglfw.so"/>
<get-release platform="linux" arch="loongarch64" 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 @@ -1692,6 +1711,7 @@
<get-release platform="linux" arch="arm32" file="libktx.so"/>
<get-release platform="linux" arch="ppc64le" file="libktx.so"/>
<get-release platform="linux" arch="riscv64" file="libktx.so"/>
<get-release platform="linux" arch="loongarch64" file="libktx.so"/>

<get-release platform="macos" arch="x64" file="libktx.dylib"/>
<get-release platform="macos" arch="arm64" file="libktx.dylib"/>
Expand Down Expand Up @@ -1729,6 +1749,7 @@
<get-release platform="linux" arch="arm32" file="liblwjgl_nfd_portal.so"/>
<get-release platform="linux" arch="ppc64le" file="liblwjgl_nfd_portal.so"/>
<get-release platform="linux" arch="riscv64" file="liblwjgl_nfd_portal.so"/>
<get-release platform="linux" arch="loongarch64" file="liblwjgl_nfd_portal.so"/>
</natives>
</release-module>

Expand Down Expand Up @@ -1759,6 +1780,9 @@
<get-release platform="linux" arch="riscv64" file="libopenal.so"/>
<get-release platform="linux" arch="riscv64" file="libopenal.so.git"/>

<get-release platform="linux" arch="loongarch64" file="libopenal.so"/>
<get-release platform="linux" arch="loongarch64" 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 @@ -1806,6 +1830,9 @@
<get-release platform="linux" arch="riscv64" file="libopenxr_loader.so"/>
<get-release platform="linux" arch="riscv64" file="libopenxr_loader.so.git"/>

<get-release platform="linux" arch="loongarch64" file="libopenxr_loader.so"/>
<get-release platform="linux" arch="loongarch64" 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 @@ -1833,6 +1860,7 @@
<get-release platform="linux" arch="arm32" file="liblwjgl_remotery.so"/>
<get-release platform="linux" arch="ppc64le" file="liblwjgl_remotery.so"/>
<get-release platform="linux" arch="riscv64" file="liblwjgl_remotery.so"/>
<get-release platform="linux" arch="loongarch64" 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
14 changes: 11 additions & 3 deletions config/build-definitions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ This script is included in /build.xml and /config/update-dependencies.xml.

By default, os.arch of the JVM that runs ANT is used, but this can be overridden for cross-compiling to another architecture.

Valid values: x64, x86, arm64, arm32
Valid values: x64, x86, arm64, arm32, loongarch64
-->
<property name="build.arch" value="${env.LWJGL_BUILD_ARCH}" if:set="env.LWJGL_BUILD_ARCH"/>

Expand Down Expand Up @@ -67,11 +67,18 @@ This script is included in /build.xml and /config/update-dependencies.xml.
<contains string="${os.arch}" substring="riscv"/>
</or>
</condition>
<condition property="build.arch.loongarch" value="true">
<or>
<contains string="${build.arch}" substring="loongarch"/>
<contains string="${os.arch}" substring="loongarch"/>
</or>
</condition>
<condition property="build.arch.x64|x86" value="true">
<and>
<not><isset property="build.arch.arm"/></not>
<not><isset property="build.arch.ppc"/></not>
<not><isset property="build.arch.riscv"/></not>
<not><isset property="build.arch.loongarch"/></not>
</and>
</condition>

Expand All @@ -80,12 +87,13 @@ This script is included in /build.xml and /config/update-dependencies.xml.
<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="ppc64le" unless:set="build.arch"><and><isset property="build.arch.ppc"/> <istrue 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="loongarch64" unless:set="build.arch"><and><isset property="build.arch.loongarch64"/> <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, ppc64le, riscv64">
<condition><not><matches string="${build.arch}" pattern="^(x64|x86|arm64|arm32|ppc64le|riscv64)$"/></not></condition>
<fail message="Invalid or unsupported build architecture: ${build.arch}. Supported: x64, x86, arm64, arm32, ppc64le, riscv64, loongarch64">
<condition><not><matches string="${build.arch}" pattern="^(x64|x86|arm64|arm32|ppc64le|riscv64|loongarch64)$"/></not></condition>
</fail>

<property name="build.arch.${build.arch}" value="true"/>
Expand Down
5 changes: 4 additions & 1 deletion config/linux/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<condition property="linux.triplet" value="aarch64-linux-gnu"><isset property="build.arch.arm64"/></condition>
<condition property="linux.triplet" value="powerpc64le-linux-gnu"><isset property="build.arch.ppc64le"/></condition>
<condition property="linux.triplet" value="riscv64-linux-gnu"><isset property="build.arch.riscv64"/></condition>
<condition property="linux.triplet" value="loongarch64-unknown-linux-gnu"><isset property="build.arch.loongarch64"/></condition>
<condition property="linux.triplet" value="x86_64-linux-gnu"><isset property="build.arch.x64|x86"/></condition>

<condition property="gcc.prefix" value="" else="${linux.triplet}-">
Expand Down Expand Up @@ -42,6 +43,7 @@
<arg line="-m32 -mfpmath=sse -msse -msse2" if:set="build.arch.x86"/>
<arg line="-mcpu=powerpc64le" if:set="build.arch.ppc64le"/>
<arg line="-march=rv64g" if:set="build.arch.riscv64"/>
<arg line="-march=la64v1.1" if:set="build.arch.loongarch64"/>
<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"/>
Expand Down Expand Up @@ -183,6 +185,7 @@
<arg value="-I${src.main.rel}/libffi/arm" if:set="build.arch.arm32"/>
<arg value="-I${src.main.rel}/libffi/ppc64le" if:set="build.arch.ppc64le"/>
<arg value="-I${src.main.rel}/libffi/riscv64" if:set="build.arch.riscv64"/>
<arg value="-I${src.main.rel}/libffi/loongarch64" if:set="build.arch.loongarch64"/>
<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"/>
Expand Down Expand Up @@ -475,4 +478,4 @@
<touch file="${lib.native}/touch.txt" verbose="false"/>
</sequential>
</target>
</project>
</project>
82 changes: 82 additions & 0 deletions modules/lwjgl/core/src/main/c/libffi/loongarch64/ffitarget.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
/* -----------------------------------------------------------------*-C-*-
ffitarget.h - Copyright (c) 2022 Xu Chenghua <xuchenghua@loongson.cn>
2022 Cheng Lulu <chenglulu@loongson.cn>

Target configuration macros for LoongArch.

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 __loongarch__
#error \
"libffi was configured for a LoongArch target but this does not appear to be a LoongArch compiler."
#endif

#ifndef LIBFFI_ASM

typedef unsigned long ffi_arg;
typedef signed long ffi_sarg;

typedef enum ffi_abi
{
FFI_FIRST_ABI = 0,
FFI_LP64S,
FFI_LP64F,
FFI_LP64D,
FFI_LAST_ABI,

#if defined(__loongarch64)
#if defined(__loongarch_soft_float)
FFI_DEFAULT_ABI = FFI_LP64S
#elif defined(__loongarch_single_float)
FFI_DEFAULT_ABI = FFI_LP64F
#elif defined(__loongarch_double_float)
FFI_DEFAULT_ABI = FFI_LP64D
#else
#error unsupported LoongArch floating-point ABI
#endif
#else
#error unsupported LoongArch base architecture
#endif
} 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 loongarch_nfixedargs; \
unsigned loongarch_unused;
#define FFI_TARGET_SPECIFIC_VARIADIC
#endif
10 changes: 8 additions & 2 deletions modules/lwjgl/core/src/main/java/org/lwjgl/system/Platform.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ public enum Architecture {
ARM64(true),
ARM32(false),
PPC64LE(true),
RISCV64(true);
RISCV64(true),
LOONGARCH64(true);

static final Architecture current;

Expand All @@ -91,6 +92,11 @@ public enum Architecture {
throw new UnsupportedOperationException("Only RISC-V 64 is supported.");
}
current = Architecture.RISCV64;
} else if (osArch.startsWith("loong")) {
if (!"loongarch64".equals(osArch) && !"loong64".equals(osArch)) {
throw new UnsupportedOperationException("Only LoongArch 64 is supported.");
}
current = Architecture.LOONGARCH64;
} else {
current = is64Bit ? Architecture.X64 : Architecture.X86;
}
Expand Down Expand Up @@ -198,4 +204,4 @@ private static Function<String, String> getMapper(
}
}

}
}
Loading