diff options
author | Mike Pall <mike> | 2022-04-17 23:41:39 +0200 |
---|---|---|
committer | Mike Pall <mike> | 2022-04-17 23:41:39 +0200 |
commit | 34a62c7f738347e4981e7882bbf4f7a4f706dc5d (patch) | |
tree | 8528f19d8ffda9ccaddcae82f942538ffeb7f5b8 | |
parent | ddb955376457461bbcc62d4c7fee86669adad20c (diff) | |
download | luajit2-34a62c7f738347e4981e7882bbf4f7a4f706dc5d.tar.gz |
Add PS5 port.
-rw-r--r-- | doc/install.html | 12 | ||||
-rw-r--r-- | doc/luajit.html | 2 | ||||
-rw-r--r-- | src/lib_io.c | 2 | ||||
-rw-r--r-- | src/lib_os.c | 2 | ||||
-rw-r--r-- | src/lj_alloc.c | 2 | ||||
-rw-r--r-- | src/lj_arch.h | 11 | ||||
-rw-r--r-- | src/lj_prng.c | 4 | ||||
-rw-r--r-- | src/ps5build.bat | 123 |
8 files changed, 149 insertions, 9 deletions
diff --git a/doc/install.html b/doc/install.html index 90f76bf8..a38bdb5f 100644 --- a/doc/install.html +++ b/doc/install.html @@ -118,7 +118,7 @@ operating systems, CPUs and compilers: <tr class="even"> <td class="compatcpu">x64 (64 bit)</td> <td class="compatos">GCC 4.2+</td> -<td class="compatos">GCC 4.2+<br>ORBIS (<a href="#ps4">PS4</a>)</td> +<td class="compatos">GCC 4.2+<br>ORBIS (<a href="#ps4">PS4</a>)<br>PROSPERO (<a href="#ps5">PS5</a>)</td> <td class="compatos">XCode 5.0+<br>Clang</td> <td class="compatos">MSVC<br>Durango (<a href="#xboxone">Xbox One</a>)</td> </tr> @@ -478,6 +478,16 @@ cd src ps4build </pre> <p> +To cross-compile for <b id="ps5">PS5</b> from a Windows host, +open a "Visual Studio .NET Command Prompt" (64 bit host compiler), +<tt>cd</tt> to the directory where you've unpacked the sources and +run the following commands: +</p> +<pre class="code"> +cd src +ps5build +</pre> +<p> To cross-compile for <b id="psvita">PS Vita</b> from a Windows host, open a "Visual Studio .NET Command Prompt" (32 bit host compiler), <tt>cd</tt> to the directory where you've unpacked the sources and diff --git a/doc/luajit.html b/doc/luajit.html index 2aa143ae..06774ddf 100644 --- a/doc/luajit.html +++ b/doc/luajit.html @@ -162,7 +162,7 @@ LuaJIT is Copyright © 2005-2022 Mike Pall, released under the <tr><td><span style="font-size:90%;">Embedded</span></td><td>Android</td><td>iOS</td></tr> </table> <table class="feature os os3"> -<tr><td>PS3</td><td>PS4</td><td>PS Vita</td><td>Xbox 360</td><td>Xbox One</td></tr> +<tr><td>PS3</td><td>PS4</td><td>PS5</td><td>PS Vita</td><td>Xbox 360</td><td>Xbox One</td></tr> </table> <table class="feature compiler"> <tr><td>GCC</td><td>Clang<br>LLVM</td><td>MSVC</td></tr> diff --git a/src/lib_io.c b/src/lib_io.c index a3278ab2..7f218e49 100644 --- a/src/lib_io.c +++ b/src/lib_io.c @@ -439,7 +439,7 @@ LJLIB_CF(io_popen) LJLIB_CF(io_tmpfile) { IOFileUD *iof = io_file_new(L); -#if LJ_TARGET_PS3 || LJ_TARGET_PS4 || LJ_TARGET_PSVITA +#if LJ_TARGET_PS3 || LJ_TARGET_PS4 || LJ_TARGET_PS5 || LJ_TARGET_PSVITA iof->fp = NULL; errno = ENOSYS; #else iof->fp = tmpfile(); diff --git a/src/lib_os.c b/src/lib_os.c index a61ded40..eb8704cf 100644 --- a/src/lib_os.c +++ b/src/lib_os.c @@ -76,7 +76,7 @@ LJLIB_CF(os_rename) LJLIB_CF(os_tmpname) { -#if LJ_TARGET_PS3 || LJ_TARGET_PS4 || LJ_TARGET_PSVITA +#if LJ_TARGET_PS3 || LJ_TARGET_PS4 || LJ_TARGET_PS5 || LJ_TARGET_PSVITA lj_err_caller(L, LJ_ERR_OSUNIQF); return 0; #else diff --git a/src/lj_alloc.c b/src/lj_alloc.c index 165203fa..20e60493 100644 --- a/src/lj_alloc.c +++ b/src/lj_alloc.c @@ -330,7 +330,7 @@ static void *mmap_plain(size_t size) #define CALL_MMAP(prng, size) mmap_plain(size) #endif -#if LJ_64 && !LJ_GC64 && ((defined(__FreeBSD__) && __FreeBSD__ < 10) || defined(__FreeBSD_kernel__)) && !LJ_TARGET_PS4 +#if LJ_64 && !LJ_GC64 && ((defined(__FreeBSD__) && __FreeBSD__ < 10) || defined(__FreeBSD_kernel__)) && !LJ_TARGET_PS4 && !LJ_TARGET_PS5 #include <sys/resource.h> diff --git a/src/lj_arch.h b/src/lj_arch.h index cc4eae72..1852c497 100644 --- a/src/lj_arch.h +++ b/src/lj_arch.h @@ -83,7 +83,7 @@ #define LUAJIT_OS LUAJIT_OS_OSX #elif (defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || \ defined(__NetBSD__) || defined(__OpenBSD__) || \ - defined(__DragonFly__)) && !defined(__ORBIS__) + defined(__DragonFly__)) && !defined(__ORBIS__) && !defined(__PROSPERO__) #define LUAJIT_OS LUAJIT_OS_BSD #elif (defined(__sun__) && defined(__svr4__)) #define LJ_TARGET_SOLARIS 1 @@ -139,6 +139,13 @@ #define NULL ((void*)0) #endif +#ifdef __PROSPERO__ +#define LJ_TARGET_PS5 1 +#define LJ_TARGET_CONSOLE 1 +#undef NULL +#define NULL ((void*)0) +#endif + #ifdef __psp2__ #define LJ_TARGET_PSVITA 1 #define LJ_TARGET_CONSOLE 1 @@ -634,7 +641,7 @@ extern void *LJ_WIN_LOADLIBA(const char *path); #endif #endif -#if defined(LUAJIT_NO_UNWIND) || __GNU_COMPACT_EH__ || defined(__symbian__) || LJ_TARGET_IOS || LJ_TARGET_PS3 || LJ_TARGET_PS4 +#if defined(LUAJIT_NO_UNWIND) || __GNU_COMPACT_EH__ || defined(__symbian__) || LJ_TARGET_IOS || LJ_TARGET_PS3 || LJ_TARGET_PS4 || LJ_TARGET_PS5 #define LJ_NO_UNWIND 1 #endif diff --git a/src/lj_prng.c b/src/lj_prng.c index fff155a1..fd8219de 100644 --- a/src/lj_prng.c +++ b/src/lj_prng.c @@ -83,7 +83,7 @@ extern int XNetRandom(void *buf, unsigned int len); extern int sys_get_random_number(void *buf, uint64_t len); -#elif LJ_TARGET_PS4 || LJ_TARGET_PSVITA +#elif LJ_TARGET_PS4 || LJ_TARGET_PS5 || LJ_TARGET_PSVITA extern int sceRandomGetRandomNumber(void *buf, size_t len); @@ -171,7 +171,7 @@ int LJ_FASTCALL lj_prng_seed_secure(PRNGState *rs) if (sys_get_random_number(rs->u, sizeof(rs->u)) == 0) goto ok; -#elif LJ_TARGET_PS4 || LJ_TARGET_PSVITA +#elif LJ_TARGET_PS4 || LJ_TARGET_PS5 || LJ_TARGET_PSVITA if (sceRandomGetRandomNumber(rs->u, sizeof(rs->u)) == 0) goto ok; diff --git a/src/ps5build.bat b/src/ps5build.bat new file mode 100644 index 00000000..0b1ebd5b --- /dev/null +++ b/src/ps5build.bat @@ -0,0 +1,123 @@ +@rem Script to build LuaJIT with the PS5 SDK.
+@rem Donated to the public domain.
+@rem
+@rem Open a "Visual Studio .NET Command Prompt" (64 bit host compiler)
+@rem or "VS20xx x64 Native Tools Command Prompt".
+@rem
+@rem Then cd to this directory and run this script.
+@rem
+@rem Recommended invocation:
+@rem
+@rem ps5build release build, amalgamated, 64-bit GC
+@rem ps5build debug debug build, amalgamated, 64-bit GC
+@rem
+@rem Additional command-line options (not generally recommended):
+@rem
+@rem gc32 (before debug) 32-bit GC
+@rem noamalg (after debug) non-amalgamated build
+
+@if not defined INCLUDE goto :FAIL
+@if not defined SCE_PROSPERO_SDK_DIR goto :FAIL
+
+@setlocal
+@rem ---- Host compiler ----
+@set LJCOMPILE=cl /nologo /c /MD /O2 /W3 /D_CRT_SECURE_NO_DEPRECATE
+@set LJLINK=link /nologo
+@set LJMT=mt /nologo
+@set DASMDIR=..\dynasm
+@set DASM=%DASMDIR%\dynasm.lua
+@set ALL_LIB=lib_base.c lib_math.c lib_bit.c lib_string.c lib_table.c lib_io.c lib_os.c lib_package.c lib_debug.c lib_jit.c lib_ffi.c lib_buffer.c
+@set GC64=
+@set DASC=vm_x64.dasc
+
+@if "%1" neq "gc32" goto :NOGC32
+@shift
+@set GC64=-DLUAJIT_DISABLE_GC64
+@set DASC=vm_x86.dasc
+:NOGC32
+
+%LJCOMPILE% host\minilua.c
+@if errorlevel 1 goto :BAD
+%LJLINK% /out:minilua.exe minilua.obj
+@if errorlevel 1 goto :BAD
+if exist minilua.exe.manifest^
+ %LJMT% -manifest minilua.exe.manifest -outputresource:minilua.exe
+
+@rem Check for 64 bit host compiler.
+@minilua
+@if not errorlevel 8 goto :FAIL
+
+@set DASMFLAGS=-D P64 -D NO_UNWIND
+minilua %DASM% -LN %DASMFLAGS% -o host\buildvm_arch.h %DASC%
+@if errorlevel 1 goto :BAD
+
+%LJCOMPILE% /I "." /I %DASMDIR% %GC64% -DLUAJIT_TARGET=LUAJIT_ARCH_X64 -DLUAJIT_OS=LUAJIT_OS_OTHER -DLUAJIT_DISABLE_JIT -DLUAJIT_DISABLE_FFI -DLUAJIT_NO_UNWIND host\buildvm*.c
+@if errorlevel 1 goto :BAD
+%LJLINK% /out:buildvm.exe buildvm*.obj
+@if errorlevel 1 goto :BAD
+if exist buildvm.exe.manifest^
+ %LJMT% -manifest buildvm.exe.manifest -outputresource:buildvm.exe
+
+buildvm -m elfasm -o lj_vm.s
+@if errorlevel 1 goto :BAD
+buildvm -m bcdef -o lj_bcdef.h %ALL_LIB%
+@if errorlevel 1 goto :BAD
+buildvm -m ffdef -o lj_ffdef.h %ALL_LIB%
+@if errorlevel 1 goto :BAD
+buildvm -m libdef -o lj_libdef.h %ALL_LIB%
+@if errorlevel 1 goto :BAD
+buildvm -m recdef -o lj_recdef.h %ALL_LIB%
+@if errorlevel 1 goto :BAD
+buildvm -m vmdef -o jit\vmdef.lua %ALL_LIB%
+@if errorlevel 1 goto :BAD
+buildvm -m folddef -o lj_folddef.h lj_opt_fold.c
+@if errorlevel 1 goto :BAD
+
+@rem ---- Cross compiler ----
+@set LJCOMPILE="%SCE_PROSPERO_SDK_DIR%\host_tools\bin\prospero-clang" -c -Wall -DLUAJIT_DISABLE_FFI %GC64%
+@set LJLIB="%SCE_PROSPERO_SDK_DIR%\host_tools\bin\prospero-llvm-ar" rcus
+@set INCLUDE=""
+
+%SCE_PROSPERO_SDK_DIR%\host_tools\bin\prospero-llvm-as -o lj_vm.o lj_vm.s
+
+@if "%1" neq "debug" goto :NODEBUG
+@shift
+@set LJCOMPILE=%LJCOMPILE% -g -O0
+@set TARGETLIB=libluajitD_ps5.a
+goto :BUILD
+:NODEBUG
+@set LJCOMPILE=%LJCOMPILE% -O2
+@set TARGETLIB=libluajit_ps5.a
+:BUILD
+del %TARGETLIB%
+@if "%1" neq "noamalg" goto :AMALG
+for %%f in (lj_*.c lib_*.c) do (
+ %LJCOMPILE% %%f
+ @if errorlevel 1 goto :BAD
+)
+
+%LJLIB% %TARGETLIB% lj_*.o lib_*.o
+@if errorlevel 1 goto :BAD
+@goto :NOAMALG
+:AMALG
+%LJCOMPILE% ljamalg.c
+@if errorlevel 1 goto :BAD
+%LJLIB% %TARGETLIB% ljamalg.o lj_vm.o
+@if errorlevel 1 goto :BAD
+:NOAMALG
+
+@del *.o *.obj *.manifest minilua.exe buildvm.exe
+@echo.
+@echo === Successfully built LuaJIT for PS5 ===
+
+@goto :END
+:BAD
+@echo.
+@echo *******************************************************
+@echo *** Build FAILED -- Please check the error messages ***
+@echo *******************************************************
+@goto :END
+:FAIL
+@echo To run this script you must open a "Visual Studio .NET Command Prompt"
+@echo (64 bit host compiler). The PS5 Prospero SDK must be installed, too.
+:END
|