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 | luajit-34a62c7f738347e4981e7882bbf4f7a4f706dc5d.tar.gz luajit-34a62c7f738347e4981e7882bbf4f7a4f706dc5d.tar.bz2 luajit-34a62c7f738347e4981e7882bbf4f7a4f706dc5d.zip | |
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: | |||
| 118 | <tr class="even"> | 118 | <tr class="even"> |
| 119 | <td class="compatcpu">x64 (64 bit)</td> | 119 | <td class="compatcpu">x64 (64 bit)</td> |
| 120 | <td class="compatos">GCC 4.2+</td> | 120 | <td class="compatos">GCC 4.2+</td> |
| 121 | <td class="compatos">GCC 4.2+<br>ORBIS (<a href="#ps4">PS4</a>)</td> | 121 | <td class="compatos">GCC 4.2+<br>ORBIS (<a href="#ps4">PS4</a>)<br>PROSPERO (<a href="#ps5">PS5</a>)</td> |
| 122 | <td class="compatos">XCode 5.0+<br>Clang</td> | 122 | <td class="compatos">XCode 5.0+<br>Clang</td> |
| 123 | <td class="compatos">MSVC<br>Durango (<a href="#xboxone">Xbox One</a>)</td> | 123 | <td class="compatos">MSVC<br>Durango (<a href="#xboxone">Xbox One</a>)</td> |
| 124 | </tr> | 124 | </tr> |
| @@ -478,6 +478,16 @@ cd src | |||
| 478 | ps4build | 478 | ps4build |
| 479 | </pre> | 479 | </pre> |
| 480 | <p> | 480 | <p> |
| 481 | To cross-compile for <b id="ps5">PS5</b> from a Windows host, | ||
| 482 | open a "Visual Studio .NET Command Prompt" (64 bit host compiler), | ||
| 483 | <tt>cd</tt> to the directory where you've unpacked the sources and | ||
| 484 | run the following commands: | ||
| 485 | </p> | ||
| 486 | <pre class="code"> | ||
| 487 | cd src | ||
| 488 | ps5build | ||
| 489 | </pre> | ||
| 490 | <p> | ||
| 481 | To cross-compile for <b id="psvita">PS Vita</b> from a Windows host, | 491 | To cross-compile for <b id="psvita">PS Vita</b> from a Windows host, |
| 482 | open a "Visual Studio .NET Command Prompt" (32 bit host compiler), | 492 | open a "Visual Studio .NET Command Prompt" (32 bit host compiler), |
| 483 | <tt>cd</tt> to the directory where you've unpacked the sources and | 493 | <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 | |||
| 162 | <tr><td><span style="font-size:90%;">Embedded</span></td><td>Android</td><td>iOS</td></tr> | 162 | <tr><td><span style="font-size:90%;">Embedded</span></td><td>Android</td><td>iOS</td></tr> |
| 163 | </table> | 163 | </table> |
| 164 | <table class="feature os os3"> | 164 | <table class="feature os os3"> |
| 165 | <tr><td>PS3</td><td>PS4</td><td>PS Vita</td><td>Xbox 360</td><td>Xbox One</td></tr> | 165 | <tr><td>PS3</td><td>PS4</td><td>PS5</td><td>PS Vita</td><td>Xbox 360</td><td>Xbox One</td></tr> |
| 166 | </table> | 166 | </table> |
| 167 | <table class="feature compiler"> | 167 | <table class="feature compiler"> |
| 168 | <tr><td>GCC</td><td>Clang<br>LLVM</td><td>MSVC</td></tr> | 168 | <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) | |||
| 439 | LJLIB_CF(io_tmpfile) | 439 | LJLIB_CF(io_tmpfile) |
| 440 | { | 440 | { |
| 441 | IOFileUD *iof = io_file_new(L); | 441 | IOFileUD *iof = io_file_new(L); |
| 442 | #if LJ_TARGET_PS3 || LJ_TARGET_PS4 || LJ_TARGET_PSVITA | 442 | #if LJ_TARGET_PS3 || LJ_TARGET_PS4 || LJ_TARGET_PS5 || LJ_TARGET_PSVITA |
| 443 | iof->fp = NULL; errno = ENOSYS; | 443 | iof->fp = NULL; errno = ENOSYS; |
| 444 | #else | 444 | #else |
| 445 | iof->fp = tmpfile(); | 445 | 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) | |||
| 76 | 76 | ||
| 77 | LJLIB_CF(os_tmpname) | 77 | LJLIB_CF(os_tmpname) |
| 78 | { | 78 | { |
| 79 | #if LJ_TARGET_PS3 || LJ_TARGET_PS4 || LJ_TARGET_PSVITA | 79 | #if LJ_TARGET_PS3 || LJ_TARGET_PS4 || LJ_TARGET_PS5 || LJ_TARGET_PSVITA |
| 80 | lj_err_caller(L, LJ_ERR_OSUNIQF); | 80 | lj_err_caller(L, LJ_ERR_OSUNIQF); |
| 81 | return 0; | 81 | return 0; |
| 82 | #else | 82 | #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) | |||
| 330 | #define CALL_MMAP(prng, size) mmap_plain(size) | 330 | #define CALL_MMAP(prng, size) mmap_plain(size) |
| 331 | #endif | 331 | #endif |
| 332 | 332 | ||
| 333 | #if LJ_64 && !LJ_GC64 && ((defined(__FreeBSD__) && __FreeBSD__ < 10) || defined(__FreeBSD_kernel__)) && !LJ_TARGET_PS4 | 333 | #if LJ_64 && !LJ_GC64 && ((defined(__FreeBSD__) && __FreeBSD__ < 10) || defined(__FreeBSD_kernel__)) && !LJ_TARGET_PS4 && !LJ_TARGET_PS5 |
| 334 | 334 | ||
| 335 | #include <sys/resource.h> | 335 | #include <sys/resource.h> |
| 336 | 336 | ||
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 @@ | |||
| 83 | #define LUAJIT_OS LUAJIT_OS_OSX | 83 | #define LUAJIT_OS LUAJIT_OS_OSX |
| 84 | #elif (defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || \ | 84 | #elif (defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || \ |
| 85 | defined(__NetBSD__) || defined(__OpenBSD__) || \ | 85 | defined(__NetBSD__) || defined(__OpenBSD__) || \ |
| 86 | defined(__DragonFly__)) && !defined(__ORBIS__) | 86 | defined(__DragonFly__)) && !defined(__ORBIS__) && !defined(__PROSPERO__) |
| 87 | #define LUAJIT_OS LUAJIT_OS_BSD | 87 | #define LUAJIT_OS LUAJIT_OS_BSD |
| 88 | #elif (defined(__sun__) && defined(__svr4__)) | 88 | #elif (defined(__sun__) && defined(__svr4__)) |
| 89 | #define LJ_TARGET_SOLARIS 1 | 89 | #define LJ_TARGET_SOLARIS 1 |
| @@ -139,6 +139,13 @@ | |||
| 139 | #define NULL ((void*)0) | 139 | #define NULL ((void*)0) |
| 140 | #endif | 140 | #endif |
| 141 | 141 | ||
| 142 | #ifdef __PROSPERO__ | ||
| 143 | #define LJ_TARGET_PS5 1 | ||
| 144 | #define LJ_TARGET_CONSOLE 1 | ||
| 145 | #undef NULL | ||
| 146 | #define NULL ((void*)0) | ||
| 147 | #endif | ||
| 148 | |||
| 142 | #ifdef __psp2__ | 149 | #ifdef __psp2__ |
| 143 | #define LJ_TARGET_PSVITA 1 | 150 | #define LJ_TARGET_PSVITA 1 |
| 144 | #define LJ_TARGET_CONSOLE 1 | 151 | #define LJ_TARGET_CONSOLE 1 |
| @@ -634,7 +641,7 @@ extern void *LJ_WIN_LOADLIBA(const char *path); | |||
| 634 | #endif | 641 | #endif |
| 635 | #endif | 642 | #endif |
| 636 | 643 | ||
| 637 | #if defined(LUAJIT_NO_UNWIND) || __GNU_COMPACT_EH__ || defined(__symbian__) || LJ_TARGET_IOS || LJ_TARGET_PS3 || LJ_TARGET_PS4 | 644 | #if defined(LUAJIT_NO_UNWIND) || __GNU_COMPACT_EH__ || defined(__symbian__) || LJ_TARGET_IOS || LJ_TARGET_PS3 || LJ_TARGET_PS4 || LJ_TARGET_PS5 |
| 638 | #define LJ_NO_UNWIND 1 | 645 | #define LJ_NO_UNWIND 1 |
| 639 | #endif | 646 | #endif |
| 640 | 647 | ||
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); | |||
| 83 | 83 | ||
| 84 | extern int sys_get_random_number(void *buf, uint64_t len); | 84 | extern int sys_get_random_number(void *buf, uint64_t len); |
| 85 | 85 | ||
| 86 | #elif LJ_TARGET_PS4 || LJ_TARGET_PSVITA | 86 | #elif LJ_TARGET_PS4 || LJ_TARGET_PS5 || LJ_TARGET_PSVITA |
| 87 | 87 | ||
| 88 | extern int sceRandomGetRandomNumber(void *buf, size_t len); | 88 | extern int sceRandomGetRandomNumber(void *buf, size_t len); |
| 89 | 89 | ||
| @@ -171,7 +171,7 @@ int LJ_FASTCALL lj_prng_seed_secure(PRNGState *rs) | |||
| 171 | if (sys_get_random_number(rs->u, sizeof(rs->u)) == 0) | 171 | if (sys_get_random_number(rs->u, sizeof(rs->u)) == 0) |
| 172 | goto ok; | 172 | goto ok; |
| 173 | 173 | ||
| 174 | #elif LJ_TARGET_PS4 || LJ_TARGET_PSVITA | 174 | #elif LJ_TARGET_PS4 || LJ_TARGET_PS5 || LJ_TARGET_PSVITA |
| 175 | 175 | ||
| 176 | if (sceRandomGetRandomNumber(rs->u, sizeof(rs->u)) == 0) | 176 | if (sceRandomGetRandomNumber(rs->u, sizeof(rs->u)) == 0) |
| 177 | goto ok; | 177 | 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 @@ | |||
| 1 | @rem Script to build LuaJIT with the PS5 SDK. | ||
| 2 | @rem Donated to the public domain. | ||
| 3 | @rem | ||
| 4 | @rem Open a "Visual Studio .NET Command Prompt" (64 bit host compiler) | ||
| 5 | @rem or "VS20xx x64 Native Tools Command Prompt". | ||
| 6 | @rem | ||
| 7 | @rem Then cd to this directory and run this script. | ||
| 8 | @rem | ||
| 9 | @rem Recommended invocation: | ||
| 10 | @rem | ||
| 11 | @rem ps5build release build, amalgamated, 64-bit GC | ||
| 12 | @rem ps5build debug debug build, amalgamated, 64-bit GC | ||
| 13 | @rem | ||
| 14 | @rem Additional command-line options (not generally recommended): | ||
| 15 | @rem | ||
| 16 | @rem gc32 (before debug) 32-bit GC | ||
| 17 | @rem noamalg (after debug) non-amalgamated build | ||
| 18 | |||
| 19 | @if not defined INCLUDE goto :FAIL | ||
| 20 | @if not defined SCE_PROSPERO_SDK_DIR goto :FAIL | ||
| 21 | |||
| 22 | @setlocal | ||
| 23 | @rem ---- Host compiler ---- | ||
| 24 | @set LJCOMPILE=cl /nologo /c /MD /O2 /W3 /D_CRT_SECURE_NO_DEPRECATE | ||
| 25 | @set LJLINK=link /nologo | ||
| 26 | @set LJMT=mt /nologo | ||
| 27 | @set DASMDIR=..\dynasm | ||
| 28 | @set DASM=%DASMDIR%\dynasm.lua | ||
| 29 | @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 | ||
| 30 | @set GC64= | ||
| 31 | @set DASC=vm_x64.dasc | ||
| 32 | |||
| 33 | @if "%1" neq "gc32" goto :NOGC32 | ||
| 34 | @shift | ||
| 35 | @set GC64=-DLUAJIT_DISABLE_GC64 | ||
| 36 | @set DASC=vm_x86.dasc | ||
| 37 | :NOGC32 | ||
| 38 | |||
| 39 | %LJCOMPILE% host\minilua.c | ||
| 40 | @if errorlevel 1 goto :BAD | ||
| 41 | %LJLINK% /out:minilua.exe minilua.obj | ||
| 42 | @if errorlevel 1 goto :BAD | ||
| 43 | if exist minilua.exe.manifest^ | ||
| 44 | %LJMT% -manifest minilua.exe.manifest -outputresource:minilua.exe | ||
| 45 | |||
| 46 | @rem Check for 64 bit host compiler. | ||
| 47 | @minilua | ||
| 48 | @if not errorlevel 8 goto :FAIL | ||
| 49 | |||
| 50 | @set DASMFLAGS=-D P64 -D NO_UNWIND | ||
| 51 | minilua %DASM% -LN %DASMFLAGS% -o host\buildvm_arch.h %DASC% | ||
| 52 | @if errorlevel 1 goto :BAD | ||
| 53 | |||
| 54 | %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 | ||
| 55 | @if errorlevel 1 goto :BAD | ||
| 56 | %LJLINK% /out:buildvm.exe buildvm*.obj | ||
| 57 | @if errorlevel 1 goto :BAD | ||
| 58 | if exist buildvm.exe.manifest^ | ||
| 59 | %LJMT% -manifest buildvm.exe.manifest -outputresource:buildvm.exe | ||
| 60 | |||
| 61 | buildvm -m elfasm -o lj_vm.s | ||
| 62 | @if errorlevel 1 goto :BAD | ||
| 63 | buildvm -m bcdef -o lj_bcdef.h %ALL_LIB% | ||
| 64 | @if errorlevel 1 goto :BAD | ||
| 65 | buildvm -m ffdef -o lj_ffdef.h %ALL_LIB% | ||
| 66 | @if errorlevel 1 goto :BAD | ||
| 67 | buildvm -m libdef -o lj_libdef.h %ALL_LIB% | ||
| 68 | @if errorlevel 1 goto :BAD | ||
| 69 | buildvm -m recdef -o lj_recdef.h %ALL_LIB% | ||
| 70 | @if errorlevel 1 goto :BAD | ||
| 71 | buildvm -m vmdef -o jit\vmdef.lua %ALL_LIB% | ||
| 72 | @if errorlevel 1 goto :BAD | ||
| 73 | buildvm -m folddef -o lj_folddef.h lj_opt_fold.c | ||
| 74 | @if errorlevel 1 goto :BAD | ||
| 75 | |||
| 76 | @rem ---- Cross compiler ---- | ||
| 77 | @set LJCOMPILE="%SCE_PROSPERO_SDK_DIR%\host_tools\bin\prospero-clang" -c -Wall -DLUAJIT_DISABLE_FFI %GC64% | ||
| 78 | @set LJLIB="%SCE_PROSPERO_SDK_DIR%\host_tools\bin\prospero-llvm-ar" rcus | ||
| 79 | @set INCLUDE="" | ||
| 80 | |||
| 81 | %SCE_PROSPERO_SDK_DIR%\host_tools\bin\prospero-llvm-as -o lj_vm.o lj_vm.s | ||
| 82 | |||
| 83 | @if "%1" neq "debug" goto :NODEBUG | ||
| 84 | @shift | ||
| 85 | @set LJCOMPILE=%LJCOMPILE% -g -O0 | ||
| 86 | @set TARGETLIB=libluajitD_ps5.a | ||
| 87 | goto :BUILD | ||
| 88 | :NODEBUG | ||
| 89 | @set LJCOMPILE=%LJCOMPILE% -O2 | ||
| 90 | @set TARGETLIB=libluajit_ps5.a | ||
| 91 | :BUILD | ||
| 92 | del %TARGETLIB% | ||
| 93 | @if "%1" neq "noamalg" goto :AMALG | ||
| 94 | for %%f in (lj_*.c lib_*.c) do ( | ||
| 95 | %LJCOMPILE% %%f | ||
| 96 | @if errorlevel 1 goto :BAD | ||
| 97 | ) | ||
| 98 | |||
| 99 | %LJLIB% %TARGETLIB% lj_*.o lib_*.o | ||
| 100 | @if errorlevel 1 goto :BAD | ||
| 101 | @goto :NOAMALG | ||
| 102 | :AMALG | ||
| 103 | %LJCOMPILE% ljamalg.c | ||
| 104 | @if errorlevel 1 goto :BAD | ||
| 105 | %LJLIB% %TARGETLIB% ljamalg.o lj_vm.o | ||
| 106 | @if errorlevel 1 goto :BAD | ||
| 107 | :NOAMALG | ||
| 108 | |||
| 109 | @del *.o *.obj *.manifest minilua.exe buildvm.exe | ||
| 110 | @echo. | ||
| 111 | @echo === Successfully built LuaJIT for PS5 === | ||
| 112 | |||
| 113 | @goto :END | ||
| 114 | :BAD | ||
| 115 | @echo. | ||
| 116 | @echo ******************************************************* | ||
| 117 | @echo *** Build FAILED -- Please check the error messages *** | ||
| 118 | @echo ******************************************************* | ||
| 119 | @goto :END | ||
| 120 | :FAIL | ||
| 121 | @echo To run this script you must open a "Visual Studio .NET Command Prompt" | ||
| 122 | @echo (64 bit host compiler). The PS5 Prospero SDK must be installed, too. | ||
| 123 | :END | ||
