summaryrefslogtreecommitdiff
path: root/pkgs/lwjgl/patches/3.3.3/0002-build-add-support-for-Linux-RISC-V-64.patch
blob: be25bf4f94905b429463e0539250830fff832779 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
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