aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/install.html57
-rw-r--r--doc/luajit.html8
-rw-r--r--src/host/buildvm_asm.c2
-rw-r--r--src/lib_io.c2
-rw-r--r--src/lib_os.c11
-rw-r--r--src/lj_arch.h5
-rw-r--r--src/lj_def.h8
-rw-r--r--src/psvitabuild.bat93
8 files changed, 158 insertions, 28 deletions
diff --git a/doc/install.html b/doc/install.html
index 2388ff33..f8163153 100644
--- a/doc/install.html
+++ b/doc/install.html
@@ -127,7 +127,7 @@ operating systems, CPUs and compilers:
127<tr class="odd"> 127<tr class="odd">
128<td class="compatcpu"><a href="#cross2">ARMv5+<br>ARM9E+</a></td> 128<td class="compatcpu"><a href="#cross2">ARMv5+<br>ARM9E+</a></td>
129<td class="compatos">GCC 4.2+</td> 129<td class="compatos">GCC 4.2+</td>
130<td class="compatos">GCC 4.2+</td> 130<td class="compatos">GCC 4.2+<br>PSP2 (<a href="#psvita">PS VITA</a>)</td>
131<td class="compatos">GCC 4.2+</td> 131<td class="compatos">GCC 4.2+</td>
132<td class="compatos compatno">&nbsp;</td> 132<td class="compatos compatno">&nbsp;</td>
133</tr> 133</tr>
@@ -458,41 +458,56 @@ ISDKF="-arch armv7 -isysroot $ISDK/SDKs/$ISDKVER"
458make HOST_CC="gcc -m32 -arch i386" CROSS=$ISDKP TARGET_FLAGS="$ISDKF" \ 458make HOST_CC="gcc -m32 -arch i386" CROSS=$ISDKP TARGET_FLAGS="$ISDKF" \
459 TARGET_SYS=iOS 459 TARGET_SYS=iOS
460</pre> 460</pre>
461
462<h3 id="consoles">Cross-compiling for consoles</h3>
461<p> 463<p>
462You can cross-compile for <b id="ps3">PS3</b> using the PS3&nbsp;SDK from 464Building LuaJIT for consoles requires both a supported host compiler
463a Linux host or a Windows host (requires 32&nbsp;bit MinGW (GCC) on the host, 465(x86 or x64) and a cross-compiler (to PPC or ARM) from the official
464too). Due to restrictions on consoles, the JIT compiler is disabled and 466console SDK.
465only the fast interpreter is built:
466</p> 467</p>
467<pre class="code">
468make HOST_CC="gcc -m32" CROSS=ppu-lv2-
469</pre>
470<p> 468<p>
471You can cross-compile for <b id="ps4">PS4</b> from a Windows host using 469Due to restrictions on consoles, the JIT compiler is disabled and only
472the PS4&nbsp;SDK (ORBIS) plus 64&nbsp;bit MSVC. Due to restrictions on 470the fast interpreter is built. This is still faster than plain Lua,
473consoles, the JIT compiler is disabled and only the fast interpreter 471but much slower than the JIT compiler. The FFI is disabled, too, since
474is built. 472it's not very useful in such an environment.
475</p> 473</p>
476<p> 474<p>
477Open a "Visual Studio .NET Command Prompt" (64&nbsp;bit host compiler), 475The following commands build a static library <tt>libluajit.a</tt>,
478<tt>cd</tt> to the directory where you've unpacked the sources and run
479the following commands. This builds a static library <tt>libluajit.a</tt>,
480which can be linked against your game, just like the Lua library. 476which can be linked against your game, just like the Lua library.
481</p> 477</p>
478<p>
479To cross-compile for <b id="ps3">PS3</b> from a Linux host (requires
48032&nbsp;bit GCC, i.e. multilib Linux/x64) or a Windows host (requires
48132&nbsp;bit MinGW), run this command:
482</p>
483<pre class="code">
484make HOST_CC="gcc -m32" CROSS=ppu-lv2-
485</pre>
486<p>
487To cross-compile for <b id="ps4">PS4</b> from a Windows host,
488open a "Visual Studio .NET Command Prompt" (64&nbsp;bit host compiler),
489<tt>cd</tt> to the directory where you've unpacked the sources and
490run the following commands:
491</p>
482<pre class="code"> 492<pre class="code">
483cd src 493cd src
484ps4build 494ps4build
485</pre> 495</pre>
486<p> 496<p>
487You can cross-compile for <b id="xbox360">Xbox 360</b> using the 497To cross-compile for <b id="psvita">PS Vita</b> from a Windows host,
488Xbox&nbsp;360 SDK (MSVC + XEDK). Due to restrictions on consoles, the 498open a "Visual Studio .NET Command Prompt" (32&nbsp;bit host compiler),
489JIT compiler is disabled and only the fast interpreter is built. 499<tt>cd</tt> to the directory where you've unpacked the sources and
500run the following commands:
490</p> 501</p>
502<pre class="code">
503cd src
504psvitabuild
505</pre>
491<p> 506<p>
492Open a "Visual Studio .NET Command Prompt" (32&nbsp;bit host compiler), 507To cross-compile for <b id="xbox360">Xbox 360</b> from a Windows host,
508open a "Visual Studio .NET Command Prompt" (32&nbsp;bit host compiler),
493<tt>cd</tt> to the directory where you've unpacked the sources and run 509<tt>cd</tt> to the directory where you've unpacked the sources and run
494the following commands. This builds a static library <tt>luajit20.lib</tt>, 510the following commands:
495which can be linked against your game, just like the Lua library.
496</p> 511</p>
497<pre class="code"> 512<pre class="code">
498cd src 513cd src
diff --git a/doc/luajit.html b/doc/luajit.html
index 43af69c9..ddbc0164 100644
--- a/doc/luajit.html
+++ b/doc/luajit.html
@@ -38,6 +38,9 @@ table.os1 td {
38table.os2 td { 38table.os2 td {
39 color: #ffa040; 39 color: #ffa040;
40} 40}
41table.os3 td {
42 color: #40ffff;
43}
41table.compiler td { 44table.compiler td {
42 color: #2080ff; 45 color: #2080ff;
43 background: #62bf41; 46 background: #62bf41;
@@ -158,7 +161,10 @@ LuaJIT is Copyright &copy; 2005-2014 Mike Pall, released under the
158<tr><td>Windows</td><td>Linux</td><td>BSD</td><td>OSX</td><td>POSIX</td></tr> 161<tr><td>Windows</td><td>Linux</td><td>BSD</td><td>OSX</td><td>POSIX</td></tr>
159</table> 162</table>
160<table class="feature os os2"> 163<table class="feature os os2">
161<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> 164<tr><td><span style="font-size:90%;">Embedded</span></td><td>Android</td><td>iOS</td></tr>
165</table>
166<table class="feature os os3">
167<tr><td>PS3</td><td>PS4</td><td>PS Vita</td><td>Xbox 360</td></tr>
162</table> 168</table>
163<table class="feature compiler"> 169<table class="feature compiler">
164<tr><td>GCC</td><td>CLANG<br>LLVM</td><td>MSVC</td></tr> 170<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 04f0f739..90f310bb 100644
--- a/src/lib_io.c
+++ b/src/lib_io.c
@@ -426,7 +426,7 @@ LJLIB_CF(io_popen)
426LJLIB_CF(io_tmpfile) 426LJLIB_CF(io_tmpfile)
427{ 427{
428 IOFileUD *iof = io_file_new(L); 428 IOFileUD *iof = io_file_new(L);
429#if LJ_TARGET_PS3 || LJ_TARGET_PS4 429#if LJ_TARGET_PS3 || LJ_TARGET_PS4 || LJ_TARGET_PSVITA
430 iof->fp = NULL; errno = ENOSYS; 430 iof->fp = NULL; errno = ENOSYS;
431#else 431#else
432 iof->fp = tmpfile(); 432 iof->fp = tmpfile();
diff --git a/src/lib_os.c b/src/lib_os.c
index f62e8c8b..713ec935 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
@@ -27,6 +26,10 @@
27#include <stdio.h> 26#include <stdio.h>
28#endif 27#endif
29 28
29#if !LJ_TARGET_PSVITA
30#include <locale.h>
31#endif
32
30/* ------------------------------------------------------------------------ */ 33/* ------------------------------------------------------------------------ */
31 34
32#define LJLIB_MODULE_os 35#define LJLIB_MODULE_os
@@ -70,7 +73,7 @@ LJLIB_CF(os_rename)
70 73
71LJLIB_CF(os_tmpname) 74LJLIB_CF(os_tmpname)
72{ 75{
73#if LJ_TARGET_PS3 || LJ_TARGET_PS4 76#if LJ_TARGET_PS3 || LJ_TARGET_PS4 || LJ_TARGET_PSVITA
74 lj_err_caller(L, LJ_ERR_OSUNIQF); 77 lj_err_caller(L, LJ_ERR_OSUNIQF);
75 return 0; 78 return 0;
76#else 79#else
@@ -254,6 +257,9 @@ LJLIB_CF(os_difftime)
254 257
255LJLIB_CF(os_setlocale) 258LJLIB_CF(os_setlocale)
256{ 259{
260#if LJ_TARGET_PSVITA
261 lua_pushliteral(L, "C");
262#else
257 GCstr *s = lj_lib_optstr(L, 1); 263 GCstr *s = lj_lib_optstr(L, 1);
258 const char *str = s ? strdata(s) : NULL; 264 const char *str = s ? strdata(s) : NULL;
259 int opt = lj_lib_checkopt(L, 2, 6, 265 int opt = lj_lib_checkopt(L, 2, 6,
@@ -265,6 +271,7 @@ LJLIB_CF(os_setlocale)
265 else if (opt == 4) opt = LC_MONETARY; 271 else if (opt == 4) opt = LC_MONETARY;
266 else if (opt == 6) opt = LC_ALL; 272 else if (opt == 6) opt = LC_ALL;
267 lua_pushstring(L, setlocale(opt, str)); 273 lua_pushstring(L, setlocale(opt, str));
274#endif
268 return 1; 275 return 1;
269} 276}
270 277
diff --git a/src/lj_arch.h b/src/lj_arch.h
index 0196eedc..f04da3bf 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__)
151static LJ_AINLINE uint32_t lj_bswap(uint32_t x) 151static 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
168static LJ_AINLINE uint64_t lj_bswap64(uint64_t x) 172static 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
23if 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
31minilua %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
38if exist buildvm.exe.manifest^
39 %LJMT% -manifest buildvm.exe.manifest -outputresource:buildvm.exe
40
41buildvm -m elfasm -o lj_vm.s
42@if errorlevel 1 goto :BAD
43buildvm -m bcdef -o lj_bcdef.h %ALL_LIB%
44@if errorlevel 1 goto :BAD
45buildvm -m ffdef -o lj_ffdef.h %ALL_LIB%
46@if errorlevel 1 goto :BAD
47buildvm -m libdef -o lj_libdef.h %ALL_LIB%
48@if errorlevel 1 goto :BAD
49buildvm -m recdef -o lj_recdef.h %ALL_LIB%
50@if errorlevel 1 goto :BAD
51buildvm -m vmdef -o jit\vmdef.lua %ALL_LIB%
52@if errorlevel 1 goto :BAD
53buildvm -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
67goto :BUILD
68:NODEBUG
69@set LJCOMPILE=%LJCOMPILE% -O2
70@set TARGETLIB=libluajit.a
71:BUILD
72del %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