diff options
-rw-r--r-- | doc/install.html | 57 | ||||
-rw-r--r-- | doc/luajit.html | 8 | ||||
-rw-r--r-- | src/host/buildvm_asm.c | 2 | ||||
-rw-r--r-- | src/lib_io.c | 2 | ||||
-rw-r--r-- | src/lib_os.c | 11 | ||||
-rw-r--r-- | src/lj_arch.h | 5 | ||||
-rw-r--r-- | src/lj_def.h | 8 | ||||
-rw-r--r-- | src/psvitabuild.bat | 93 |
8 files changed, 158 insertions, 28 deletions
diff --git a/doc/install.html b/doc/install.html index bff8d280..2ad60c32 100644 --- a/doc/install.html +++ b/doc/install.html | |||
@@ -129,7 +129,7 @@ operating systems, CPUs and compilers: | |||
129 | <tr class="odd"> | 129 | <tr class="odd"> |
130 | <td class="compatcpu"><a href="#cross2">ARMv5+<br>ARM9E+</a></td> | 130 | <td class="compatcpu"><a href="#cross2">ARMv5+<br>ARM9E+</a></td> |
131 | <td class="compatos">GCC 4.2+</td> | 131 | <td class="compatos">GCC 4.2+</td> |
132 | <td class="compatos">GCC 4.2+</td> | 132 | <td class="compatos">GCC 4.2+<br>PSP2 (<a href="#psvita">PS VITA</a>)</td> |
133 | <td class="compatos">GCC 4.2+</td> | 133 | <td class="compatos">GCC 4.2+</td> |
134 | <td class="compatos compatno"> </td> | 134 | <td class="compatos compatno"> </td> |
135 | </tr> | 135 | </tr> |
@@ -460,41 +460,56 @@ ISDKF="-arch armv7 -isysroot $ISDK/SDKs/$ISDKVER" | |||
460 | make HOST_CC="gcc -m32 -arch i386" CROSS=$ISDKP TARGET_FLAGS="$ISDKF" \ | 460 | make HOST_CC="gcc -m32 -arch i386" CROSS=$ISDKP TARGET_FLAGS="$ISDKF" \ |
461 | TARGET_SYS=iOS | 461 | TARGET_SYS=iOS |
462 | </pre> | 462 | </pre> |
463 | |||
464 | <h3 id="consoles">Cross-compiling for consoles</h3> | ||
463 | <p> | 465 | <p> |
464 | You can cross-compile for <b id="ps3">PS3</b> using the PS3 SDK from | 466 | Building LuaJIT for consoles requires both a supported host compiler |
465 | a Linux host or a Windows host (requires 32 bit MinGW (GCC) on the host, | 467 | (x86 or x64) and a cross-compiler (to PPC or ARM) from the official |
466 | too). Due to restrictions on consoles, the JIT compiler is disabled and | 468 | console SDK. |
467 | only the fast interpreter is built: | ||
468 | </p> | 469 | </p> |
469 | <pre class="code"> | ||
470 | make HOST_CC="gcc -m32" CROSS=ppu-lv2- | ||
471 | </pre> | ||
472 | <p> | 470 | <p> |
473 | You can cross-compile for <b id="ps4">PS4</b> from a Windows host using | 471 | Due to restrictions on consoles, the JIT compiler is disabled and only |
474 | the PS4 SDK (ORBIS) plus 64 bit MSVC. Due to restrictions on | 472 | the fast interpreter is built. This is still faster than plain Lua, |
475 | consoles, the JIT compiler is disabled and only the fast interpreter | 473 | but much slower than the JIT compiler. The FFI is disabled, too, since |
476 | is built. | 474 | it's not very useful in such an environment. |
477 | </p> | 475 | </p> |
478 | <p> | 476 | <p> |
479 | Open a "Visual Studio .NET Command Prompt" (64 bit host compiler), | 477 | The following commands build a static library <tt>libluajit.a</tt>, |
480 | <tt>cd</tt> to the directory where you've unpacked the sources and run | ||
481 | the following commands. This builds a static library <tt>libluajit.a</tt>, | ||
482 | which can be linked against your game, just like the Lua library. | 478 | which can be linked against your game, just like the Lua library. |
483 | </p> | 479 | </p> |
480 | <p> | ||
481 | To cross-compile for <b id="ps3">PS3</b> from a Linux host (requires | ||
482 | 32 bit GCC, i.e. multilib Linux/x64) or a Windows host (requires | ||
483 | 32 bit MinGW), run this command: | ||
484 | </p> | ||
485 | <pre class="code"> | ||
486 | make HOST_CC="gcc -m32" CROSS=ppu-lv2- | ||
487 | </pre> | ||
488 | <p> | ||
489 | To cross-compile for <b id="ps4">PS4</b> from a Windows host, | ||
490 | open a "Visual Studio .NET Command Prompt" (64 bit host compiler), | ||
491 | <tt>cd</tt> to the directory where you've unpacked the sources and | ||
492 | run the following commands: | ||
493 | </p> | ||
484 | <pre class="code"> | 494 | <pre class="code"> |
485 | cd src | 495 | cd src |
486 | ps4build | 496 | ps4build |
487 | </pre> | 497 | </pre> |
488 | <p> | 498 | <p> |
489 | You can cross-compile for <b id="xbox360">Xbox 360</b> using the | 499 | To cross-compile for <b id="psvita">PS Vita</b> from a Windows host, |
490 | Xbox 360 SDK (MSVC + XEDK). Due to restrictions on consoles, the | 500 | open a "Visual Studio .NET Command Prompt" (32 bit host compiler), |
491 | JIT compiler is disabled and only the fast interpreter is built. | 501 | <tt>cd</tt> to the directory where you've unpacked the sources and |
502 | run the following commands: | ||
492 | </p> | 503 | </p> |
504 | <pre class="code"> | ||
505 | cd src | ||
506 | psvitabuild | ||
507 | </pre> | ||
493 | <p> | 508 | <p> |
494 | Open a "Visual Studio .NET Command Prompt" (32 bit host compiler), | 509 | To cross-compile for <b id="xbox360">Xbox 360</b> from a Windows host, |
510 | open a "Visual Studio .NET Command Prompt" (32 bit host compiler), | ||
495 | <tt>cd</tt> to the directory where you've unpacked the sources and run | 511 | <tt>cd</tt> to the directory where you've unpacked the sources and run |
496 | the following commands. This builds a static library <tt>luajit20.lib</tt>, | 512 | the following commands: |
497 | which can be linked against your game, just like the Lua library. | ||
498 | </p> | 513 | </p> |
499 | <pre class="code"> | 514 | <pre class="code"> |
500 | cd src | 515 | cd src |
diff --git a/doc/luajit.html b/doc/luajit.html index 15c5f12e..1a85f033 100644 --- a/doc/luajit.html +++ b/doc/luajit.html | |||
@@ -38,6 +38,9 @@ table.os1 td { | |||
38 | table.os2 td { | 38 | table.os2 td { |
39 | color: #ffa040; | 39 | color: #ffa040; |
40 | } | 40 | } |
41 | table.os3 td { | ||
42 | color: #40ffff; | ||
43 | } | ||
41 | table.compiler td { | 44 | table.compiler td { |
42 | color: #2080ff; | 45 | color: #2080ff; |
43 | background: #62bf41; | 46 | background: #62bf41; |
@@ -160,7 +163,10 @@ LuaJIT is Copyright © 2005-2014 Mike Pall, released under the | |||
160 | <tr><td>Windows</td><td>Linux</td><td>BSD</td><td>OSX</td><td>POSIX</td></tr> | 163 | <tr><td>Windows</td><td>Linux</td><td>BSD</td><td>OSX</td><td>POSIX</td></tr> |
161 | </table> | 164 | </table> |
162 | <table class="feature os os2"> | 165 | <table class="feature os os2"> |
163 | <tr><td><span style="font-size:90%;">Embedded</span></td><td>Android</td><td>iOS</td><td>PS3</td><td>PS4</td><td>Xbox 360</td></tr> | 166 | <tr><td><span style="font-size:90%;">Embedded</span></td><td>Android</td><td>iOS</td></tr> |
167 | </table> | ||
168 | <table class="feature os os3"> | ||
169 | <tr><td>PS3</td><td>PS4</td><td>PS Vita</td><td>Xbox 360</td></tr> | ||
164 | </table> | 170 | </table> |
165 | <table class="feature compiler"> | 171 | <table class="feature compiler"> |
166 | <tr><td>GCC</td><td>CLANG<br>LLVM</td><td>MSVC</td></tr> | 172 | <tr><td>GCC</td><td>CLANG<br>LLVM</td><td>MSVC</td></tr> |
diff --git a/src/host/buildvm_asm.c b/src/host/buildvm_asm.c index 9b28b3b3..079e9a80 100644 --- a/src/host/buildvm_asm.c +++ b/src/host/buildvm_asm.c | |||
@@ -286,7 +286,7 @@ void emit_asm(BuildCtx *ctx) | |||
286 | fprintf(ctx->fp, "\n"); | 286 | fprintf(ctx->fp, "\n"); |
287 | switch (ctx->mode) { | 287 | switch (ctx->mode) { |
288 | case BUILD_elfasm: | 288 | case BUILD_elfasm: |
289 | #if !LJ_TARGET_PS3 | 289 | #if !(LJ_TARGET_PS3 || LJ_TARGET_PSVITA) |
290 | fprintf(ctx->fp, "\t.section .note.GNU-stack,\"\"," ELFASM_PX "progbits\n"); | 290 | fprintf(ctx->fp, "\t.section .note.GNU-stack,\"\"," ELFASM_PX "progbits\n"); |
291 | #endif | 291 | #endif |
292 | #if LJ_TARGET_PPCSPE | 292 | #if LJ_TARGET_PPCSPE |
diff --git a/src/lib_io.c b/src/lib_io.c index 586709d6..07a9b476 100644 --- a/src/lib_io.c +++ b/src/lib_io.c | |||
@@ -421,7 +421,7 @@ LJLIB_CF(io_popen) | |||
421 | LJLIB_CF(io_tmpfile) | 421 | LJLIB_CF(io_tmpfile) |
422 | { | 422 | { |
423 | IOFileUD *iof = io_file_new(L); | 423 | IOFileUD *iof = io_file_new(L); |
424 | #if LJ_TARGET_PS3 || LJ_TARGET_PS4 | 424 | #if LJ_TARGET_PS3 || LJ_TARGET_PS4 || LJ_TARGET_PSVITA |
425 | iof->fp = NULL; errno = ENOSYS; | 425 | iof->fp = NULL; errno = ENOSYS; |
426 | #else | 426 | #else |
427 | iof->fp = tmpfile(); | 427 | iof->fp = tmpfile(); |
diff --git a/src/lib_os.c b/src/lib_os.c index 76ffcaa8..68678492 100644 --- a/src/lib_os.c +++ b/src/lib_os.c | |||
@@ -7,7 +7,6 @@ | |||
7 | */ | 7 | */ |
8 | 8 | ||
9 | #include <errno.h> | 9 | #include <errno.h> |
10 | #include <locale.h> | ||
11 | #include <time.h> | 10 | #include <time.h> |
12 | 11 | ||
13 | #define lib_os_c | 12 | #define lib_os_c |
@@ -30,6 +29,10 @@ | |||
30 | #include <stdio.h> | 29 | #include <stdio.h> |
31 | #endif | 30 | #endif |
32 | 31 | ||
32 | #if !LJ_TARGET_PSVITA | ||
33 | #include <locale.h> | ||
34 | #endif | ||
35 | |||
33 | /* ------------------------------------------------------------------------ */ | 36 | /* ------------------------------------------------------------------------ */ |
34 | 37 | ||
35 | #define LJLIB_MODULE_os | 38 | #define LJLIB_MODULE_os |
@@ -73,7 +76,7 @@ LJLIB_CF(os_rename) | |||
73 | 76 | ||
74 | LJLIB_CF(os_tmpname) | 77 | LJLIB_CF(os_tmpname) |
75 | { | 78 | { |
76 | #if LJ_TARGET_PS3 || LJ_TARGET_PS4 | 79 | #if LJ_TARGET_PS3 || LJ_TARGET_PS4 || LJ_TARGET_PSVITA |
77 | lj_err_caller(L, LJ_ERR_OSUNIQF); | 80 | lj_err_caller(L, LJ_ERR_OSUNIQF); |
78 | return 0; | 81 | return 0; |
79 | #else | 82 | #else |
@@ -259,6 +262,9 @@ LJLIB_CF(os_difftime) | |||
259 | 262 | ||
260 | LJLIB_CF(os_setlocale) | 263 | LJLIB_CF(os_setlocale) |
261 | { | 264 | { |
265 | #if LJ_TARGET_PSVITA | ||
266 | lua_pushliteral(L, "C"); | ||
267 | #else | ||
262 | GCstr *s = lj_lib_optstr(L, 1); | 268 | GCstr *s = lj_lib_optstr(L, 1); |
263 | const char *str = s ? strdata(s) : NULL; | 269 | const char *str = s ? strdata(s) : NULL; |
264 | int opt = lj_lib_checkopt(L, 2, 6, | 270 | int opt = lj_lib_checkopt(L, 2, 6, |
@@ -270,6 +276,7 @@ LJLIB_CF(os_setlocale) | |||
270 | else if (opt == 4) opt = LC_MONETARY; | 276 | else if (opt == 4) opt = LC_MONETARY; |
271 | else if (opt == 6) opt = LC_ALL; | 277 | else if (opt == 6) opt = LC_ALL; |
272 | lua_pushstring(L, setlocale(opt, str)); | 278 | lua_pushstring(L, setlocale(opt, str)); |
279 | #endif | ||
273 | return 1; | 280 | return 1; |
274 | } | 281 | } |
275 | 282 | ||
diff --git a/src/lj_arch.h b/src/lj_arch.h index acdfe18b..10ff5529 100644 --- a/src/lj_arch.h +++ b/src/lj_arch.h | |||
@@ -111,6 +111,11 @@ | |||
111 | #define NULL ((void*)0) | 111 | #define NULL ((void*)0) |
112 | #endif | 112 | #endif |
113 | 113 | ||
114 | #ifdef __psp2__ | ||
115 | #define LJ_TARGET_PSVITA 1 | ||
116 | #define LJ_TARGET_CONSOLE 1 | ||
117 | #endif | ||
118 | |||
114 | #if _XBOX_VER >= 200 | 119 | #if _XBOX_VER >= 200 |
115 | #define LJ_TARGET_XBOX360 1 | 120 | #define LJ_TARGET_XBOX360 1 |
116 | #define LJ_TARGET_CONSOLE 1 | 121 | #define LJ_TARGET_CONSOLE 1 |
diff --git a/src/lj_def.h b/src/lj_def.h index 3c43be78..8624aed2 100644 --- a/src/lj_def.h +++ b/src/lj_def.h | |||
@@ -111,7 +111,7 @@ typedef uintptr_t BloomFilter; | |||
111 | #define bloomset(b, x) ((b) |= bloombit((x))) | 111 | #define bloomset(b, x) ((b) |= bloombit((x))) |
112 | #define bloomtest(b, x) ((b) & bloombit((x))) | 112 | #define bloomtest(b, x) ((b) & bloombit((x))) |
113 | 113 | ||
114 | #if defined(__GNUC__) | 114 | #if defined(__GNUC__) || defined(__psp2__) |
115 | 115 | ||
116 | #define LJ_NORET __attribute__((noreturn)) | 116 | #define LJ_NORET __attribute__((noreturn)) |
117 | #define LJ_ALIGN(n) __attribute__((aligned(n))) | 117 | #define LJ_ALIGN(n) __attribute__((aligned(n))) |
@@ -119,7 +119,7 @@ typedef uintptr_t BloomFilter; | |||
119 | #define LJ_AINLINE inline __attribute__((always_inline)) | 119 | #define LJ_AINLINE inline __attribute__((always_inline)) |
120 | #define LJ_NOINLINE __attribute__((noinline)) | 120 | #define LJ_NOINLINE __attribute__((noinline)) |
121 | 121 | ||
122 | #if defined(__ELF__) || defined(__MACH__) | 122 | #if defined(__ELF__) || defined(__MACH__) || defined(__psp2__) |
123 | #if !((defined(__sun__) && defined(__svr4__)) || defined(__CELLOS_LV2__)) | 123 | #if !((defined(__sun__) && defined(__svr4__)) || defined(__CELLOS_LV2__)) |
124 | #define LJ_NOAPI extern __attribute__((visibility("hidden"))) | 124 | #define LJ_NOAPI extern __attribute__((visibility("hidden"))) |
125 | #endif | 125 | #endif |
@@ -150,6 +150,9 @@ static LJ_AINLINE uint32_t lj_fls(uint32_t x) | |||
150 | #if defined(__arm__) | 150 | #if defined(__arm__) |
151 | static LJ_AINLINE uint32_t lj_bswap(uint32_t x) | 151 | static LJ_AINLINE uint32_t lj_bswap(uint32_t x) |
152 | { | 152 | { |
153 | #if defined(__psp2__) | ||
154 | return __builtin_rev(x); | ||
155 | #else | ||
153 | uint32_t r; | 156 | uint32_t r; |
154 | #if __ARM_ARCH_6__ || __ARM_ARCH_6J__ || __ARM_ARCH_6T2__ || __ARM_ARCH_6Z__ ||\ | 157 | #if __ARM_ARCH_6__ || __ARM_ARCH_6J__ || __ARM_ARCH_6T2__ || __ARM_ARCH_6Z__ ||\ |
155 | __ARM_ARCH_6ZK__ || __ARM_ARCH_7__ || __ARM_ARCH_7A__ || __ARM_ARCH_7R__ | 158 | __ARM_ARCH_6ZK__ || __ARM_ARCH_7__ || __ARM_ARCH_7A__ || __ARM_ARCH_7R__ |
@@ -163,6 +166,7 @@ static LJ_AINLINE uint32_t lj_bswap(uint32_t x) | |||
163 | #endif | 166 | #endif |
164 | return ((r & 0xff00ffffu) >> 8) ^ lj_ror(x, 8); | 167 | return ((r & 0xff00ffffu) >> 8) ^ lj_ror(x, 8); |
165 | #endif | 168 | #endif |
169 | #endif | ||
166 | } | 170 | } |
167 | 171 | ||
168 | static LJ_AINLINE uint64_t lj_bswap64(uint64_t x) | 172 | static LJ_AINLINE uint64_t lj_bswap64(uint64_t x) |
diff --git a/src/psvitabuild.bat b/src/psvitabuild.bat new file mode 100644 index 00000000..3991dc65 --- /dev/null +++ b/src/psvitabuild.bat | |||
@@ -0,0 +1,93 @@ | |||
1 | @rem Script to build LuaJIT with the PS Vita SDK. | ||
2 | @rem Donated to the public domain. | ||
3 | @rem | ||
4 | @rem Open a "Visual Studio .NET Command Prompt" (32 bit host compiler) | ||
5 | @rem Then cd to this directory and run this script. | ||
6 | |||
7 | @if not defined INCLUDE goto :FAIL | ||
8 | @if not defined SCE_PSP2_SDK_DIR goto :FAIL | ||
9 | |||
10 | @setlocal | ||
11 | @rem ---- Host compiler ---- | ||
12 | @set LJCOMPILE=cl /nologo /c /MD /O2 /W3 /D_CRT_SECURE_NO_DEPRECATE | ||
13 | @set LJLINK=link /nologo | ||
14 | @set LJMT=mt /nologo | ||
15 | @set DASMDIR=..\dynasm | ||
16 | @set DASM=%DASMDIR%\dynasm.lua | ||
17 | @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 | ||
18 | |||
19 | %LJCOMPILE% host\minilua.c | ||
20 | @if errorlevel 1 goto :BAD | ||
21 | %LJLINK% /out:minilua.exe minilua.obj | ||
22 | @if errorlevel 1 goto :BAD | ||
23 | if exist minilua.exe.manifest^ | ||
24 | %LJMT% -manifest minilua.exe.manifest -outputresource:minilua.exe | ||
25 | |||
26 | @rem Check for 32 bit host compiler. | ||
27 | @minilua | ||
28 | @if errorlevel 8 goto :FAIL | ||
29 | |||
30 | @set DASMFLAGS=-D FPU -D HFABI | ||
31 | minilua %DASM% -LN %DASMFLAGS% -o host\buildvm_arch.h vm_arm.dasc | ||
32 | @if errorlevel 1 goto :BAD | ||
33 | |||
34 | %LJCOMPILE% /I "." /I %DASMDIR% -DLUAJIT_TARGET=LUAJIT_ARCH_ARM -DLUAJIT_OS=LUAJIT_OS_OTHER -DLUAJIT_DISABLE_JIT -DLUAJIT_DISABLE_FFI -DLJ_TARGET_PSVITA=1 host\buildvm*.c | ||
35 | @if errorlevel 1 goto :BAD | ||
36 | %LJLINK% /out:buildvm.exe buildvm*.obj | ||
37 | @if errorlevel 1 goto :BAD | ||
38 | if exist buildvm.exe.manifest^ | ||
39 | %LJMT% -manifest buildvm.exe.manifest -outputresource:buildvm.exe | ||
40 | |||
41 | buildvm -m elfasm -o lj_vm.s | ||
42 | @if errorlevel 1 goto :BAD | ||
43 | buildvm -m bcdef -o lj_bcdef.h %ALL_LIB% | ||
44 | @if errorlevel 1 goto :BAD | ||
45 | buildvm -m ffdef -o lj_ffdef.h %ALL_LIB% | ||
46 | @if errorlevel 1 goto :BAD | ||
47 | buildvm -m libdef -o lj_libdef.h %ALL_LIB% | ||
48 | @if errorlevel 1 goto :BAD | ||
49 | buildvm -m recdef -o lj_recdef.h %ALL_LIB% | ||
50 | @if errorlevel 1 goto :BAD | ||
51 | buildvm -m vmdef -o jit\vmdef.lua %ALL_LIB% | ||
52 | @if errorlevel 1 goto :BAD | ||
53 | buildvm -m folddef -o lj_folddef.h lj_opt_fold.c | ||
54 | @if errorlevel 1 goto :BAD | ||
55 | |||
56 | @rem ---- Cross compiler ---- | ||
57 | @set LJCOMPILE="%SCE_PSP2_SDK_DIR%\host_tools\build\bin\psp2snc" -c -w -DLUAJIT_DISABLE_FFI -DLUAJIT_USE_SYSMALLOC | ||
58 | @set LJLIB="%SCE_PSP2_SDK_DIR%\host_tools\build\bin\psp2ld32" -r --output= | ||
59 | @set INCLUDE="" | ||
60 | |||
61 | "%SCE_PSP2_SDK_DIR%\host_tools\build\bin\psp2as" -o lj_vm.o lj_vm.s | ||
62 | |||
63 | @if "%1" neq "debug" goto :NODEBUG | ||
64 | @shift | ||
65 | @set LJCOMPILE=%LJCOMPILE% -g -O0 | ||
66 | @set TARGETLIB=libluajitD.a | ||
67 | goto :BUILD | ||
68 | :NODEBUG | ||
69 | @set LJCOMPILE=%LJCOMPILE% -O2 | ||
70 | @set TARGETLIB=libluajit.a | ||
71 | :BUILD | ||
72 | del %TARGETLIB% | ||
73 | |||
74 | %LJCOMPILE% ljamalg.c | ||
75 | @if errorlevel 1 goto :BAD | ||
76 | %LJLIB%%TARGETLIB% ljamalg.o lj_vm.o | ||
77 | @if errorlevel 1 goto :BAD | ||
78 | |||
79 | @del *.o *.obj *.manifest minilua.exe buildvm.exe | ||
80 | @echo. | ||
81 | @echo === Successfully built LuaJIT for PS Vita === | ||
82 | |||
83 | @goto :END | ||
84 | :BAD | ||
85 | @echo. | ||
86 | @echo ******************************************************* | ||
87 | @echo *** Build FAILED -- Please check the error messages *** | ||
88 | @echo ******************************************************* | ||
89 | @goto :END | ||
90 | :FAIL | ||
91 | @echo To run this script you must open a "Visual Studio .NET Command Prompt" | ||
92 | @echo (32 bit host compiler). The PS Vita SDK must be installed, too. | ||
93 | :END | ||