aboutsummaryrefslogtreecommitdiff
path: root/doc/install.html
diff options
context:
space:
mode:
Diffstat (limited to 'doc/install.html')
-rw-r--r--doc/install.html155
1 files changed, 107 insertions, 48 deletions
diff --git a/doc/install.html b/doc/install.html
index 68de0c10..9602831e 100644
--- a/doc/install.html
+++ b/doc/install.html
@@ -68,6 +68,8 @@ td.compatno {
68<a href="ext_jit.html">jit.* Library</a> 68<a href="ext_jit.html">jit.* Library</a>
69</li><li> 69</li><li>
70<a href="ext_c_api.html">Lua/C API</a> 70<a href="ext_c_api.html">Lua/C API</a>
71</li><li>
72<a href="ext_profiler.html">Profiler</a>
71</li></ul> 73</li></ul>
72</li><li> 74</li><li>
73<a href="status.html">Status</a> 75<a href="status.html">Status</a>
@@ -111,17 +113,17 @@ operating systems, CPUs and compilers:
111</tr> 113</tr>
112<tr class="odd separate"> 114<tr class="odd separate">
113<td class="compatcpu">x86 (32 bit)</td> 115<td class="compatcpu">x86 (32 bit)</td>
114<td class="compatos">GCC 4.x+<br>GCC 3.4</td> 116<td class="compatos">GCC 4.2+</td>
115<td class="compatos">GCC 4.x+<br>GCC 3.4</td> 117<td class="compatos">GCC 4.2+</td>
116<td class="compatos">XCode 5.0+<br>Clang</td> 118<td class="compatos">XCode 5.0+<br>Clang</td>
117<td class="compatos">MSVC<br>MinGW, Cygwin</td> 119<td class="compatos">MSVC<br>MinGW, Cygwin</td>
118</tr> 120</tr>
119<tr class="even"> 121<tr class="even">
120<td class="compatcpu">x64 (64 bit)</td> 122<td class="compatcpu">x64 (64 bit)</td>
121<td class="compatos">GCC 4.x+</td> 123<td class="compatos">GCC 4.2+</td>
122<td class="compatos">ORBIS (<a href="#ps4">PS4</a>)</td> 124<td class="compatos">GCC 4.2+<br>ORBIS (<a href="#ps4">PS4</a>)</td>
123<td class="compatos">XCode 5.0+<br>Clang</td> 125<td class="compatos">XCode 5.0+<br>Clang</td>
124<td class="compatos">MSVC</td> 126<td class="compatos">MSVC<br>Durango (<a href="#xboxone">Xbox One</a>)</td>
125</tr> 127</tr>
126<tr class="odd"> 128<tr class="odd">
127<td class="compatcpu"><a href="#cross2">ARMv5+<br>ARM9E+</a></td> 129<td class="compatcpu"><a href="#cross2">ARMv5+<br>ARM9E+</a></td>
@@ -131,21 +133,21 @@ operating systems, CPUs and compilers:
131<td class="compatos compatno">&nbsp;</td> 133<td class="compatos compatno">&nbsp;</td>
132</tr> 134</tr>
133<tr class="even"> 135<tr class="even">
134<td class="compatcpu"><a href="#cross2">PPC</a></td> 136<td class="compatcpu"><a href="#cross2">ARM64</a></td>
135<td class="compatos">GCC 4.3+</td> 137<td class="compatos">GCC 4.8+</td>
136<td class="compatos">GCC 4.3+<br>GCC 4.1 (<a href="#ps3">PS3</a>)</td> 138<td class="compatos compatno">&nbsp;</td>
139<td class="compatos">XCode 6.0+<br>Clang 3.5+</td>
137<td class="compatos compatno">&nbsp;</td> 140<td class="compatos compatno">&nbsp;</td>
138<td class="compatos">XEDK (<a href="#xbox360">Xbox 360</a>)</td>
139</tr> 141</tr>
140<tr class="odd"> 142<tr class="odd">
141<td class="compatcpu"><a href="#cross2">PPC/e500v2</a></td> 143<td class="compatcpu"><a href="#cross2">PPC</a></td>
142<td class="compatos">GCC 4.3+</td>
143<td class="compatos">GCC 4.3+</td> 144<td class="compatos">GCC 4.3+</td>
145<td class="compatos">GCC 4.3+<br>GCC 4.1 (<a href="#ps3">PS3</a>)</td>
144<td class="compatos compatno">&nbsp;</td> 146<td class="compatos compatno">&nbsp;</td>
145<td class="compatos compatno">&nbsp;</td> 147<td class="compatos">XEDK (<a href="#xbox360">Xbox 360</a>)</td>
146</tr> 148</tr>
147<tr class="even"> 149<tr class="even">
148<td class="compatcpu"><a href="#cross2">MIPS</a></td> 150<td class="compatcpu"><a href="#cross2">MIPS32<br>MIPS64</a></td>
149<td class="compatos">GCC 4.3+</td> 151<td class="compatos">GCC 4.3+</td>
150<td class="compatos">GCC 4.3+</td> 152<td class="compatos">GCC 4.3+</td>
151<td class="compatos compatno">&nbsp;</td> 153<td class="compatos compatno">&nbsp;</td>
@@ -172,6 +174,13 @@ MSVC (Visual Studio).</li>
172Please read the instructions given in these files, before changing 174Please read the instructions given in these files, before changing
173any settings. 175any settings.
174</p> 176</p>
177<p>
178All LuaJIT 64 bit ports use 64 bit GC objects by default (<tt>LJ_GC64</tt>).
179For x64, you can select the old 32-on-64 bit mode by adding
180<tt>XCFLAGS=-DLUAJIT_DISABLE_GC64</tt> to the make command.
181Please check the note about the
182<a href="extensions.html#string_dump">bytecode format</a> differences, too.
183</p>
175 184
176<h2 id="posix">POSIX Systems (Linux, OSX, *BSD etc.)</h2> 185<h2 id="posix">POSIX Systems (Linux, OSX, *BSD etc.)</h2>
177<h3>Prerequisites</h3> 186<h3>Prerequisites</h3>
@@ -199,7 +208,7 @@ which is probably the default on your system, anyway. Simply run:
199make 208make
200</pre> 209</pre>
201<p> 210<p>
202This always builds a native x86, x64 or PPC binary, depending on the host OS 211This always builds a native binary, depending on the host OS
203you're running this command on. Check the section on 212you're running this command on. Check the section on
204<a href="#cross">cross-compilation</a> for more options. 213<a href="#cross">cross-compilation</a> for more options.
205</p> 214</p>
@@ -297,25 +306,36 @@ directory where <tt>luajit.exe</tt> is installed
297 306
298<h2 id="cross">Cross-compiling LuaJIT</h2> 307<h2 id="cross">Cross-compiling LuaJIT</h2>
299<p> 308<p>
309First, let's clear up some terminology:
310</p>
311<ul>
312<li>Host: This is your development system, usually based on a x64 or x86 CPU.</li>
313<li>Target: This is the target system you want LuaJIT to run on, e.g. Android/ARM.</li>
314<li>Toolchain: This comprises a C compiler, linker, assembler and a matching C library.</li>
315<li>Host (or system) toolchain: This is the toolchain used to build native binaries for your host system.</li>
316<li>Cross-compile toolchain: This is the toolchain used to build binaries for the target system. They can only be run on the target system.</li>
317</ul>
318<p>
300The GNU Makefile-based build system allows cross-compiling on any host 319The GNU Makefile-based build system allows cross-compiling on any host
301for any supported target, as long as both architectures have the same 320for any supported target:
302pointer size. If you want to cross-compile to any 32 bit target on an
303x64 OS, you need to install the multilib development package (e.g.
304<tt>libc6-dev-i386</tt> on Debian/Ubuntu) and build a 32 bit host part
305(<tt>HOST_CC="gcc -m32"</tt>).
306</p> 321</p>
322<ul>
323<li>Yes, you need a toolchain for both your host <em>and</em> your target!</li>
324<li>Both host and target architectures must have the same pointer size.</li>
325<li>E.g. if you want to cross-compile to a 32 bit target on a 64 bit host, you need to install the multilib development package (e.g. <tt>libc6-dev-i386</tt> on Debian/Ubuntu) and build a 32 bit host part (<tt>HOST_CC="gcc -m32"</tt>).</li>
326<li>64 bit targets always require compilation on a 64 bit host.</li>
327</ul>
307<p> 328<p>
308You need to specify <tt>TARGET_SYS</tt> whenever the host OS and the 329You need to specify <tt>TARGET_SYS</tt> whenever the host OS and the
309target OS differ, or you'll get assembler or linker errors. E.g. if 330target OS differ, or you'll get assembler or linker errors:
310you're compiling on a Windows or OSX host for embedded Linux or Android,
311you need to add <tt>TARGET_SYS=Linux</tt> to the examples below. For a
312minimal target OS, you may need to disable the built-in allocator in
313<tt>src/Makefile</tt> and use <tt>TARGET_SYS=Other</tt>. Don't forget to
314specify the same <tt>TARGET_SYS</tt> for the install step, too.
315</p> 331</p>
332<ul>
333<li>E.g. if you're compiling on a Windows or OSX host for embedded Linux or Android, you need to add <tt>TARGET_SYS=Linux</tt> to the examples below.</li>
334<li>For a minimal target OS, you may need to disable the built-in allocator in <tt>src/Makefile</tt> and use <tt>TARGET_SYS=Other</tt>.</li>
335<li>Don't forget to specify the same <tt>TARGET_SYS</tt> for the install step, too.</li>
336</ul>
316<p> 337<p>
317The examples below only show some popular targets &mdash; please check 338Here are some examples where host and target have the same CPU:
318the comments in <tt>src/Makefile</tt> for more details.
319</p> 339</p>
320<pre class="code"> 340<pre class="code">
321# Cross-compile to a 32 bit binary on a multilib x64 OS 341# Cross-compile to a 32 bit binary on a multilib x64 OS
@@ -333,34 +353,44 @@ use the canonical toolchain triplets for Linux.
333</p> 353</p>
334<p> 354<p>
335Since there's often no easy way to detect CPU features at runtime, it's 355Since there's often no easy way to detect CPU features at runtime, it's
336important to compile with the proper CPU or architecture settings. You 356important to compile with the proper CPU or architecture settings:
337can specify these when building the toolchain yourself. Or add 357</o>
338<tt>-mcpu=...</tt> or <tt>-march=...</tt> to <tt>TARGET_CFLAGS</tt>. For 358<ul>
339ARM it's important to have the correct <tt>-mfloat-abi=...</tt> setting, 359<li>The best way to get consistent results is to specify the correct settings when building the toolchain yourself.</li>
340too. Otherwise LuaJIT may not run at the full performance of your target 360<li>For a pre-built, generic toolchain add <tt>-mcpu=...</tt> or <tt>-march=...</tt> and other necessary flags to <tt>TARGET_CFLAGS</tt>.</li>
341CPU. 361<li>For ARM it's important to have the correct <tt>-mfloat-abi=...</tt> setting, too. Otherwise LuaJIT may not run at the full performance of your target CPU.</li>
362<li>For MIPS it's important to select a supported ABI (o32 on MIPS32, n64 on MIPS64) and consistently compile your project either with hard-float or soft-float compiler settings.</li>
363</ul>
364<p>
365Here are some examples for targets with a different CPU than the host:
342</p> 366</p>
343<pre class="code"> 367<pre class="code">
344# ARM soft-float 368# ARM soft-float
345make HOST_CC="gcc -m32" CROSS=arm-linux-gnueabi- \ 369make HOST_CC="gcc -m32" CROSS=arm-linux-gnueabi- \
346 TARGET_CFLAGS="-mfloat-abi=soft" 370 TARGET_CFLAGS="-mfloat-abi=soft"
347 371
348# ARM soft-float ABI with VFP (example for Cortex-A8) 372# ARM soft-float ABI with VFP (example for Cortex-A9)
349make HOST_CC="gcc -m32" CROSS=arm-linux-gnueabi- \ 373make HOST_CC="gcc -m32" CROSS=arm-linux-gnueabi- \
350 TARGET_CFLAGS="-mcpu=cortex-a8 -mfloat-abi=softfp" 374 TARGET_CFLAGS="-mcpu=cortex-a9 -mfloat-abi=softfp"
351 375
352# ARM hard-float ABI with VFP (armhf, requires recent toolchain) 376# ARM hard-float ABI with VFP (armhf, most modern toolchains)
353make HOST_CC="gcc -m32" CROSS=arm-linux-gnueabihf- 377make HOST_CC="gcc -m32" CROSS=arm-linux-gnueabihf-
354 378
379# ARM64
380make CROSS=aarch64-linux-
381
355# PPC 382# PPC
356make HOST_CC="gcc -m32" CROSS=powerpc-linux-gnu- 383make HOST_CC="gcc -m32" CROSS=powerpc-linux-gnu-
357# PPC/e500v2 (fast interpreter only)
358make HOST_CC="gcc -m32" CROSS=powerpc-e500v2-linux-gnuspe-
359 384
360# MIPS big-endian 385# MIPS32 big-endian
361make HOST_CC="gcc -m32" CROSS=mips-linux- 386make HOST_CC="gcc -m32" CROSS=mips-linux-
362# MIPS little-endian 387# MIPS32 little-endian
363make HOST_CC="gcc -m32" CROSS=mipsel-linux- 388make HOST_CC="gcc -m32" CROSS=mipsel-linux-
389
390# MIPS64 big-endian
391make CROSS=mips-linux- TARGET_CFLAGS="-mips64r2 -mabi=64"
392# MIPS64 little-endian
393make CROSS=mipsel-linux- TARGET_CFLAGS="-mips64r2 -mabi=64"
364</pre> 394</pre>
365<p> 395<p>
366You can cross-compile for <b id="android">Android</b> using the <a href="http://developer.android.com/ndk/"><span class="ext">&raquo;</span>&nbsp;Android NDK</a>. 396You can cross-compile for <b id="android">Android</b> using the <a href="http://developer.android.com/ndk/"><span class="ext">&raquo;</span>&nbsp;Android NDK</a>.
@@ -368,8 +398,16 @@ Please adapt the environment variables to match the install locations and the
368desired target platform. E.g. Android&nbsp;4.1 corresponds to ABI level&nbsp;16. 398desired target platform. E.g. Android&nbsp;4.1 corresponds to ABI level&nbsp;16.
369</p> 399</p>
370<pre class="code"> 400<pre class="code">
371# Android/ARM, armeabi-v7a (ARMv7 VFP), Android 4.1+ (JB) 401# Android/ARM64, aarch64, Android 5.0+ (L)
402NDKDIR=/opt/android/ndk
403NDKBIN=$NDKDIR/toolchains/llvm/prebuilt/linux-x86_64/bin
404NDKCROSS=$NDKBIN/aarch64-linux-android-
405NDKCC=$NDKBIN/aarch64-linux-android21-clang
406make CROSS=$NDKCROSS \
407 STATIC_CC=$NDKCC DYNAMIC_CC="$NDKCC -fPIC" \
408 TARGET_LD=$NDKCC
372 409
410# Android/ARM, armeabi-v7a (ARMv7 VFP), Android 4.1+ (JB)
373NDKDIR=/opt/android/ndk 411NDKDIR=/opt/android/ndk
374NDKBIN=$NDKDIR/toolchains/llvm/prebuilt/linux-x86_64/bin 412NDKBIN=$NDKDIR/toolchains/llvm/prebuilt/linux-x86_64/bin
375NDKCROSS=$NDKBIN/arm-linux-androideabi- 413NDKCROSS=$NDKBIN/arm-linux-androideabi-
@@ -379,9 +417,23 @@ make HOST_CC="gcc -m32" CROSS=$NDKCROSS \
379 TARGET_LD=$NDKCC 417 TARGET_LD=$NDKCC
380</pre> 418</pre>
381<p> 419<p>
382Please use the LuaJIT 2.1 branch to compile for 420You can cross-compile for <b id="ios">iOS 3.0+</b> (iPhone/iPad) using the <a href="http://developer.apple.com/ios/"><span class="ext">&raquo;</span>&nbsp;iOS SDK</a>:
383<b id="ios">iOS</b> (iPhone/iPad).
384</p> 421</p>
422<p style="font-size: 8pt;">
423Note: <b>the JIT compiler is disabled for iOS</b>, because regular iOS Apps
424are not allowed to generate code at runtime. You'll only get the performance
425of the LuaJIT interpreter on iOS. This is still faster than plain Lua, but
426much slower than the JIT compiler. Please complain to Apple, not me.
427Or use Android. :-p
428</p>
429<pre class="code">
430# iOS/ARM64
431ISDKP=$(xcrun --sdk iphoneos --show-sdk-path)
432ICC=$(xcrun --sdk iphoneos --find clang)
433ISDKF="-arch arm64 -isysroot $ISDKP"
434make DEFAULT_CC=clang CROSS="$(dirname $ICC)/" \
435 TARGET_FLAGS="$ISDKF" TARGET_SYS=iOS
436</pre>
385 437
386<h3 id="consoles">Cross-compiling for consoles</h3> 438<h3 id="consoles">Cross-compiling for consoles</h3>
387<p> 439<p>
@@ -437,6 +489,16 @@ the following commands:
437cd src 489cd src
438xedkbuild 490xedkbuild
439</pre> 491</pre>
492<p>
493To cross-compile for <b id="xboxone">Xbox One</b> from a Windows host,
494open a "Visual Studio .NET Command Prompt" (64&nbsp;bit host compiler),
495<tt>cd</tt> to the directory where you've unpacked the sources and run
496the following commands:
497</p>
498<pre class="code">
499cd src
500xb1build
501</pre>
440 502
441<h2 id="embed">Embedding LuaJIT</h2> 503<h2 id="embed">Embedding LuaJIT</h2>
442<p> 504<p>
@@ -467,14 +529,11 @@ intend to load Lua/C modules at runtime.
467</li> 529</li>
468<li> 530<li>
469If you're building a 64 bit application on OSX which links directly or 531If you're building a 64 bit application on OSX which links directly or
470indirectly against LuaJIT, you need to link your main executable 532indirectly against LuaJIT which is not built for <tt>LJ_GC64</tt> mode,
471with these flags: 533you need to link your main executable with these flags:
472<pre class="code"> 534<pre class="code">
473-pagezero_size 10000 -image_base 100000000 535-pagezero_size 10000 -image_base 100000000
474</pre> 536</pre>
475Also, it's recommended to <tt>rebase</tt> all (self-compiled) shared libraries
476which are loaded at runtime on OSX/x64 (e.g. C extension modules for Lua).
477See: <tt>man rebase</tt>
478</li> 537</li>
479</ul> 538</ul>
480<p>Additional hints for initializing LuaJIT using the C API functions:</p> 539<p>Additional hints for initializing LuaJIT using the C API functions:</p>