aboutsummaryrefslogtreecommitdiff
path: root/doc/install.html
diff options
context:
space:
mode:
Diffstat (limited to 'doc/install.html')
-rw-r--r--doc/install.html167
1 files changed, 111 insertions, 56 deletions
diff --git a/doc/install.html b/doc/install.html
index 6de31846..3231e268 100644
--- a/doc/install.html
+++ b/doc/install.html
@@ -1,8 +1,8 @@
1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> 1<!DOCTYPE html>
2<html> 2<html>
3<head> 3<head>
4<title>Installation</title> 4<title>Installation</title>
5<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> 5<meta charset="utf-8">
6<meta name="Copyright" content="Copyright (C) 2005-2022"> 6<meta name="Copyright" content="Copyright (C) 2005-2022">
7<meta name="Language" content="en"> 7<meta name="Language" content="en">
8<link rel="stylesheet" type="text/css" href="bluequad.css" media="screen"> 8<link rel="stylesheet" type="text/css" href="bluequad.css" media="screen">
@@ -65,9 +65,13 @@ td.compatno {
65<a href="ext_ffi_semantics.html">FFI Semantics</a> 65<a href="ext_ffi_semantics.html">FFI Semantics</a>
66</li></ul> 66</li></ul>
67</li><li> 67</li><li>
68<a href="ext_buffer.html">String Buffers</a>
69</li><li>
68<a href="ext_jit.html">jit.* Library</a> 70<a href="ext_jit.html">jit.* Library</a>
69</li><li> 71</li><li>
70<a href="ext_c_api.html">Lua/C API</a> 72<a href="ext_c_api.html">Lua/C API</a>
73</li><li>
74<a href="ext_profiler.html">Profiler</a>
71</li></ul> 75</li></ul>
72</li><li> 76</li><li>
73<a href="status.html">Status</a> 77<a href="status.html">Status</a>
@@ -102,21 +106,21 @@ operating systems, CPUs and compilers:
102<td class="compatos"><a href="#posix">Linux</a> or<br><a href="#android">Android</a></td> 106<td class="compatos"><a href="#posix">Linux</a> or<br><a href="#android">Android</a></td>
103<td class="compatos"><a href="#posix">*BSD, Other</a></td> 107<td class="compatos"><a href="#posix">*BSD, Other</a></td>
104<td class="compatos"><a href="#posix">macOS 10.4+</a> or<br><a href="#ios">iOS 3.0+</a></td> 108<td class="compatos"><a href="#posix">macOS 10.4+</a> or<br><a href="#ios">iOS 3.0+</a></td>
105<td class="compatos"><a href="#windows">Windows XP<br>or later</a></td> 109<td class="compatos"><a href="#windows">Windows 7<br>or later</a></td>
106</tr> 110</tr>
107<tr class="odd separate"> 111<tr class="odd separate">
108<td class="compatcpu">x86 (32 bit)</td> 112<td class="compatcpu">x86 (32 bit)</td>
109<td class="compatos">GCC 4.x+<br>GCC 3.4</td> 113<td class="compatos">GCC 4.2+</td>
110<td class="compatos">GCC 4.x+<br>GCC 3.4</td> 114<td class="compatos">GCC 4.2+</td>
111<td class="compatos">XCode 5.0+<br>Clang</td> 115<td class="compatos">XCode 5.0+<br>Clang</td>
112<td class="compatos">MSVC<br>MinGW, Cygwin</td> 116<td class="compatos">MSVC<br>MinGW, Cygwin</td>
113</tr> 117</tr>
114<tr class="even"> 118<tr class="even">
115<td class="compatcpu">x64 (64 bit)</td> 119<td class="compatcpu">x64 (64 bit)</td>
116<td class="compatos">GCC 4.x+</td> 120<td class="compatos">GCC 4.2+</td>
117<td class="compatos">ORBIS (<a href="#ps4">PS4</a>)</td> 121<td class="compatos">GCC 4.2+<br>ORBIS (<a href="#ps4">PS4</a>)</td>
118<td class="compatos">XCode 5.0+<br>Clang</td> 122<td class="compatos">XCode 5.0+<br>Clang</td>
119<td class="compatos">MSVC</td> 123<td class="compatos">MSVC<br>Durango (<a href="#xboxone">Xbox One</a>)</td>
120</tr> 124</tr>
121<tr class="odd"> 125<tr class="odd">
122<td class="compatcpu"><a href="#cross2">ARMv5+<br>ARM9E+</a></td> 126<td class="compatcpu"><a href="#cross2">ARMv5+<br>ARM9E+</a></td>
@@ -126,21 +130,21 @@ operating systems, CPUs and compilers:
126<td class="compatos compatno">&nbsp;</td> 130<td class="compatos compatno">&nbsp;</td>
127</tr> 131</tr>
128<tr class="even"> 132<tr class="even">
129<td class="compatcpu"><a href="#cross2">PPC</a></td> 133<td class="compatcpu"><a href="#cross2">ARM64<br>ARM64be</a></td>
130<td class="compatos">GCC 4.3+</td> 134<td class="compatos">GCC 4.8+</td>
131<td class="compatos">GCC 4.3+<br>GCC 4.1 (<a href="#ps3">PS3</a>)</td> 135<td class="compatos compatno">&nbsp;</td>
136<td class="compatos">XCode 6.0+<br>Clang 3.5+</td>
132<td class="compatos compatno">&nbsp;</td> 137<td class="compatos compatno">&nbsp;</td>
133<td class="compatos">XEDK (<a href="#xbox360">Xbox 360</a>)</td>
134</tr> 138</tr>
135<tr class="odd"> 139<tr class="odd">
136<td class="compatcpu"><a href="#cross2">PPC/e500v2</a></td> 140<td class="compatcpu"><a href="#cross2">PPC</a></td>
137<td class="compatos">GCC 4.3+</td>
138<td class="compatos">GCC 4.3+</td> 141<td class="compatos">GCC 4.3+</td>
142<td class="compatos">GCC 4.3+<br>GCC 4.1 (<a href="#ps3">PS3</a>)</td>
139<td class="compatos compatno">&nbsp;</td> 143<td class="compatos compatno">&nbsp;</td>
140<td class="compatos compatno">&nbsp;</td> 144<td class="compatos">XEDK (<a href="#xbox360">Xbox 360</a>)</td>
141</tr> 145</tr>
142<tr class="even"> 146<tr class="even">
143<td class="compatcpu"><a href="#cross2">MIPS</a></td> 147<td class="compatcpu"><a href="#cross2">MIPS32<br>MIPS64<br>MIPS64r6</a></td>
144<td class="compatos">GCC 4.3+</td> 148<td class="compatos">GCC 4.3+</td>
145<td class="compatos">GCC 4.3+</td> 149<td class="compatos">GCC 4.3+</td>
146<td class="compatos compatno">&nbsp;</td> 150<td class="compatos compatno">&nbsp;</td>
@@ -167,6 +171,13 @@ MSVC (Visual Studio).</li>
167Please read the instructions given in these files, before changing 171Please read the instructions given in these files, before changing
168any settings. 172any settings.
169</p> 173</p>
174<p>
175All LuaJIT 64 bit ports use 64 bit GC objects by default (<tt>LJ_GC64</tt>).
176For x64, you can select the old 32-on-64 bit mode by adding
177<tt>XCFLAGS=-DLUAJIT_DISABLE_GC64</tt> to the make command.
178Please check the note about the
179<a href="extensions.html#string_dump">bytecode format</a> differences, too.
180</p>
170 181
171<h2 id="posix">POSIX Systems (Linux, macOS, *BSD etc.)</h2> 182<h2 id="posix">POSIX Systems (Linux, macOS, *BSD etc.)</h2>
172<h3>Prerequisites</h3> 183<h3>Prerequisites</h3>
@@ -199,7 +210,7 @@ which is probably the default on your system, anyway. Simply run:
199make 210make
200</pre> 211</pre>
201<p> 212<p>
202This always builds a native x86, x64 or PPC binary, depending on the host OS 213This always builds a native binary, depending on the host OS
203you're running this command on. Check the section on 214you're running this command on. Check the section on
204<a href="#cross">cross-compilation</a> for more options. 215<a href="#cross">cross-compilation</a> for more options.
205</p> 216</p>
@@ -301,25 +312,36 @@ directory where <tt>luajit.exe</tt> is installed
301 312
302<h2 id="cross">Cross-compiling LuaJIT</h2> 313<h2 id="cross">Cross-compiling LuaJIT</h2>
303<p> 314<p>
315First, let's clear up some terminology:
316</p>
317<ul>
318<li>Host: This is your development system, usually based on a x64 or x86 CPU.</li>
319<li>Target: This is the target system you want LuaJIT to run on, e.g. Android/ARM.</li>
320<li>Toolchain: This comprises a C compiler, linker, assembler and a matching C library.</li>
321<li>Host (or system) toolchain: This is the toolchain used to build native binaries for your host system.</li>
322<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>
323</ul>
324<p>
304The GNU Makefile-based build system allows cross-compiling on any host 325The GNU Makefile-based build system allows cross-compiling on any host
305for any supported target, as long as both architectures have the same 326for any supported target:
306pointer size. If you want to cross-compile to any 32 bit target on an
307x64 OS, you need to install the multilib development package (e.g.
308<tt>libc6-dev-i386</tt> on Debian/Ubuntu) and build a 32 bit host part
309(<tt>HOST_CC="gcc -m32"</tt>).
310</p> 327</p>
328<ul>
329<li>Yes, you need a toolchain for both your host <em>and</em> your target!</li>
330<li>Both host and target architectures must have the same pointer size.</li>
331<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>
332<li>64 bit targets always require compilation on a 64 bit host.</li>
333</ul>
311<p> 334<p>
312You need to specify <tt>TARGET_SYS</tt> whenever the host OS and the 335You need to specify <tt>TARGET_SYS</tt> whenever the host OS and the
313target OS differ, or you'll get assembler or linker errors. E.g. if 336target OS differ, or you'll get assembler or linker errors:
314you're compiling on a Windows or macOS host for embedded Linux or Android,
315you need to add <tt>TARGET_SYS=Linux</tt> to the examples below. For a
316minimal target OS, you may need to disable the built-in allocator in
317<tt>src/Makefile</tt> and use <tt>TARGET_SYS=Other</tt>. Don't forget to
318specify the same <tt>TARGET_SYS</tt> for the install step, too.
319</p> 337</p>
338<ul>
339<li>E.g. if you're compiling on a Windows or macOS host for embedded Linux or Android, you need to add <tt>TARGET_SYS=Linux</tt> to the examples below.</li>
340<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>
341<li>Don't forget to specify the same <tt>TARGET_SYS</tt> for the install step, too.</li>
342</ul>
320<p> 343<p>
321The examples below only show some popular targets &mdash; please check 344Here are some examples where host and target have the same CPU:
322the comments in <tt>src/Makefile</tt> for more details.
323</p> 345</p>
324<pre class="code"> 346<pre class="code">
325# Cross-compile to a 32 bit binary on a multilib x64 OS 347# Cross-compile to a 32 bit binary on a multilib x64 OS
@@ -337,34 +359,44 @@ use the canonical toolchain triplets for Linux.
337</p> 359</p>
338<p> 360<p>
339Since there's often no easy way to detect CPU features at runtime, it's 361Since there's often no easy way to detect CPU features at runtime, it's
340important to compile with the proper CPU or architecture settings. You 362important to compile with the proper CPU or architecture settings:
341can specify these when building the toolchain yourself. Or add 363</o>
342<tt>-mcpu=...</tt> or <tt>-march=...</tt> to <tt>TARGET_CFLAGS</tt>. For 364<ul>
343ARM it's important to have the correct <tt>-mfloat-abi=...</tt> setting, 365<li>The best way to get consistent results is to specify the correct settings when building the toolchain yourself.</li>
344too. Otherwise LuaJIT may not run at the full performance of your target 366<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>
345CPU. 367<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>
368<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>
369</ul>
370<p>
371Here are some examples for targets with a different CPU than the host:
346</p> 372</p>
347<pre class="code"> 373<pre class="code">
348# ARM soft-float 374# ARM soft-float
349make HOST_CC="gcc -m32" CROSS=arm-linux-gnueabi- \ 375make HOST_CC="gcc -m32" CROSS=arm-linux-gnueabi- \
350 TARGET_CFLAGS="-mfloat-abi=soft" 376 TARGET_CFLAGS="-mfloat-abi=soft"
351 377
352# ARM soft-float ABI with VFP (example for Cortex-A8) 378# ARM soft-float ABI with VFP (example for Cortex-A9)
353make HOST_CC="gcc -m32" CROSS=arm-linux-gnueabi- \ 379make HOST_CC="gcc -m32" CROSS=arm-linux-gnueabi- \
354 TARGET_CFLAGS="-mcpu=cortex-a8 -mfloat-abi=softfp" 380 TARGET_CFLAGS="-mcpu=cortex-a9 -mfloat-abi=softfp"
355 381
356# ARM hard-float ABI with VFP (armhf, requires recent toolchain) 382# ARM hard-float ABI with VFP (armhf, most modern toolchains)
357make HOST_CC="gcc -m32" CROSS=arm-linux-gnueabihf- 383make HOST_CC="gcc -m32" CROSS=arm-linux-gnueabihf-
358 384
385# ARM64
386make CROSS=aarch64-linux-
387
359# PPC 388# PPC
360make HOST_CC="gcc -m32" CROSS=powerpc-linux-gnu- 389make HOST_CC="gcc -m32" CROSS=powerpc-linux-gnu-
361# PPC/e500v2 (fast interpreter only)
362make HOST_CC="gcc -m32" CROSS=powerpc-e500v2-linux-gnuspe-
363 390
364# MIPS big-endian 391# MIPS32 big-endian
365make HOST_CC="gcc -m32" CROSS=mips-linux- 392make HOST_CC="gcc -m32" CROSS=mips-linux-
366# MIPS little-endian 393# MIPS32 little-endian
367make HOST_CC="gcc -m32" CROSS=mipsel-linux- 394make HOST_CC="gcc -m32" CROSS=mipsel-linux-
395
396# MIPS64 big-endian
397make CROSS=mips-linux- TARGET_CFLAGS="-mips64r2 -mabi=64"
398# MIPS64 little-endian
399make CROSS=mipsel-linux- TARGET_CFLAGS="-mips64r2 -mabi=64"
368</pre> 400</pre>
369<p> 401<p>
370You can cross-compile for <b id="android">Android</b> using the <a href="https://developer.android.com/ndk/"><span class="ext">&raquo;</span>&nbsp;Android NDK</a>. 402You can cross-compile for <b id="android">Android</b> using the <a href="https://developer.android.com/ndk/"><span class="ext">&raquo;</span>&nbsp;Android NDK</a>.
@@ -372,8 +404,17 @@ Please adapt the environment variables to match the install locations and the
372desired target platform. E.g. Android&nbsp;4.1 corresponds to ABI level&nbsp;16. 404desired target platform. E.g. Android&nbsp;4.1 corresponds to ABI level&nbsp;16.
373</p> 405</p>
374<pre class="code"> 406<pre class="code">
375# Android/ARM, armeabi-v7a (ARMv7 VFP), Android 4.1+ (JB) 407# Android/ARM64, aarch64, Android 5.0+ (L)
408NDKDIR=/opt/android/ndk
409NDKBIN=$NDKDIR/toolchains/llvm/prebuilt/linux-x86_64/bin
410NDKCROSS=$NDKBIN/aarch64-linux-android-
411NDKCC=$NDKBIN/aarch64-linux-android21-clang
412make CROSS=$NDKCROSS \
413 STATIC_CC=$NDKCC DYNAMIC_CC="$NDKCC -fPIC" \
414 TARGET_LD=$NDKCC TARGET_AR=$NDKBIN/llvm-ar
415 TARGET_STRIP=$NDKBIN/llvm-strip
376 416
417# Android/ARM, armeabi-v7a (ARMv7 VFP), Android 4.1+ (JB)
377NDKDIR=/opt/android/ndk 418NDKDIR=/opt/android/ndk
378NDKBIN=$NDKDIR/toolchains/llvm/prebuilt/linux-x86_64/bin 419NDKBIN=$NDKDIR/toolchains/llvm/prebuilt/linux-x86_64/bin
379NDKCROSS=$NDKBIN/arm-linux-androideabi- 420NDKCROSS=$NDKBIN/arm-linux-androideabi-
@@ -384,9 +425,23 @@ make HOST_CC="gcc -m32" CROSS=$NDKCROSS \
384 TARGET_STRIP=$NDKBIN/llvm-strip 425 TARGET_STRIP=$NDKBIN/llvm-strip
385</pre> 426</pre>
386<p> 427<p>
387Please use the LuaJIT 2.1 branch to compile for 428You can cross-compile for <b id="ios">iOS 3.0+</b> (iPhone/iPad) using the <a href="https://developer.apple.com/ios/"><span class="ext">&raquo;</span>&nbsp;iOS SDK</a>:
388<b id="ios">iOS</b> (iPhone/iPad). 429</p>
430<p style="font-size: 8pt;">
431Note: <b>the JIT compiler is disabled for iOS</b>, because regular iOS Apps
432are not allowed to generate code at runtime. You'll only get the performance
433of the LuaJIT interpreter on iOS. This is still faster than plain Lua, but
434much slower than the JIT compiler. Please complain to Apple, not me.
435Or use Android. :-p
389</p> 436</p>
437<pre class="code">
438# iOS/ARM64
439ISDKP=$(xcrun --sdk iphoneos --show-sdk-path)
440ICC=$(xcrun --sdk iphoneos --find clang)
441ISDKF="-arch arm64 -isysroot $ISDKP"
442make DEFAULT_CC=clang CROSS="$(dirname $ICC)/" \
443 TARGET_FLAGS="$ISDKF" TARGET_SYS=iOS
444</pre>
390 445
391<h3 id="consoles">Cross-compiling for consoles</h3> 446<h3 id="consoles">Cross-compiling for consoles</h3>
392<p> 447<p>
@@ -442,6 +497,16 @@ the following commands:
442cd src 497cd src
443xedkbuild 498xedkbuild
444</pre> 499</pre>
500<p>
501To cross-compile for <b id="xboxone">Xbox One</b> from a Windows host,
502open a "Visual Studio .NET Command Prompt" (64&nbsp;bit host compiler),
503<tt>cd</tt> to the directory where you've unpacked the sources and run
504the following commands:
505</p>
506<pre class="code">
507cd src
508xb1build
509</pre>
445 510
446<h2 id="embed">Embedding LuaJIT</h2> 511<h2 id="embed">Embedding LuaJIT</h2>
447<p> 512<p>
@@ -470,16 +535,6 @@ the DLL). You may link LuaJIT statically on Windows only if you don't
470intend to load Lua/C modules at runtime. 535intend to load Lua/C modules at runtime.
471</li></ul> 536</li></ul>
472</li> 537</li>
473<li>
474<i>Important: this relates to LuaJIT 2.0 only &mdash; use LuaJIT 2.1 to
475avoid these complications.</i><br>
476If you're building a 64 bit application on macOS which links directly or
477indirectly against LuaJIT, you need to link your main executable
478with these flags:
479<pre class="code">
480-pagezero_size 10000 -image_base 100000000
481</pre>
482</li>
483</ul> 538</ul>
484<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>
485<ul> 540<ul>