aboutsummaryrefslogtreecommitdiff
path: root/doc/install.html
diff options
context:
space:
mode:
Diffstat (limited to 'doc/install.html')
-rw-r--r--doc/install.html190
1 files changed, 137 insertions, 53 deletions
diff --git a/doc/install.html b/doc/install.html
index f9c326d8..0fdde485 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-2026"> 6<meta name="Copyright" content="Copyright (C) 2005-2026">
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">
@@ -60,9 +60,13 @@ td.compatx {
60<a href="ext_ffi_semantics.html">FFI Semantics</a> 60<a href="ext_ffi_semantics.html">FFI Semantics</a>
61</li></ul> 61</li></ul>
62</li><li> 62</li><li>
63<a href="ext_buffer.html">String Buffers</a>
64</li><li>
63<a href="ext_jit.html">jit.* Library</a> 65<a href="ext_jit.html">jit.* Library</a>
64</li><li> 66</li><li>
65<a href="ext_c_api.html">Lua/C API</a> 67<a href="ext_c_api.html">Lua/C API</a>
68</li><li>
69<a href="ext_profiler.html">Profiler</a>
66</li></ul> 70</li></ul>
67</li><li> 71</li><li>
68<a href="https://luajit.org/status.html">Status <span class="ext">&raquo;</span></a> 72<a href="https://luajit.org/status.html">Status <span class="ext">&raquo;</span></a>
@@ -113,7 +117,7 @@ hold all user-configurable settings:
113<li><tt>Makefile</tt> has settings for <b>installing</b> LuaJIT (POSIX 117<li><tt>Makefile</tt> has settings for <b>installing</b> LuaJIT (POSIX
114only).</li> 118only).</li>
115<li><tt>src/Makefile</tt> has settings for <b>compiling</b> LuaJIT 119<li><tt>src/Makefile</tt> has settings for <b>compiling</b> LuaJIT
116under POSIX, MinGW or Cygwin.</li> 120under POSIX or MinGW.</li>
117<li><tt>src/msvcbuild.bat</tt> has settings for compiling LuaJIT with 121<li><tt>src/msvcbuild.bat</tt> has settings for compiling LuaJIT with
118MSVC (Visual Studio).</li> 122MSVC (Visual Studio).</li>
119</ul> 123</ul>
@@ -121,6 +125,13 @@ MSVC (Visual Studio).</li>
121Please read the instructions given in these files, before changing 125Please read the instructions given in these files, before changing
122any settings. 126any settings.
123</p> 127</p>
128<p>
129All LuaJIT 64 bit ports use 64 bit GC objects by default (<tt>LJ_GC64</tt>).
130For x64, you can select the old 32-on-64 bit mode by adding
131<tt>XCFLAGS=-DLUAJIT_DISABLE_GC64</tt> to the make command.
132Please check the note about the
133<a href="extensions.html#string_dump">bytecode format</a> differences, too.
134</p>
124 135
125<h2 id="posix">POSIX Systems (Linux, macOS, *BSD etc.)</h2> 136<h2 id="posix">POSIX Systems (Linux, macOS, *BSD etc.)</h2>
126<h3>Prerequisites</h3> 137<h3>Prerequisites</h3>
@@ -154,9 +165,12 @@ You can add an extra prefix to the search paths by appending the
154make PREFIX=/home/myself/lj2 165make PREFIX=/home/myself/lj2
155</pre> 166</pre>
156<p> 167<p>
157Please use the LuaJIT 2.1 branch to compile for 168Note for macOS: you <b>must</b> set the <tt>MACOSX_DEPLOYMENT_TARGET</tt>
158<b id="osx">macOS (OSX)</b>. 169environment variable to a value supported by your toolchain:
159</p> 170</p>
171<pre class="code">
172MACOSX_DEPLOYMENT_TARGET=XX.YY make
173</pre>
160<h3>Installing LuaJIT</h3> 174<h3>Installing LuaJIT</h3>
161<p> 175<p>
162The top-level Makefile installs LuaJIT by default under 176The top-level Makefile installs LuaJIT by default under
@@ -181,15 +195,13 @@ Obviously the prefixes given during build and installation need to be the same.
181<h2 id="windows">Windows Systems</h2> 195<h2 id="windows">Windows Systems</h2>
182<h3>Prerequisites</h3> 196<h3>Prerequisites</h3>
183<p> 197<p>
184Either install one of the open source SDKs 198Either install the open source SDK <a href="http://mingw.org/"><span class="ext">&raquo;</span>&nbsp;MinGW</a>,
185(<a href="http://mingw.org/"><span class="ext">&raquo;</span>&nbsp;MinGW</a> or 199which comes with a modified GCC plus the required development headers.
186<a href="https://www.cygwin.com/"><span class="ext">&raquo;</span>&nbsp;Cygwin</a>), which come with a modified
187GCC plus the required development headers.
188Or install Microsoft's Visual Studio (MSVC). 200Or install Microsoft's Visual Studio (MSVC).
189</p> 201</p>
190<h3>Building with MSVC</h3> 202<h3>Building with MSVC</h3>
191<p> 203<p>
192Open a "Visual Studio Command Prompt" (either x86 or x64), <tt>cd</tt> to the 204Open a "Visual Studio Command Prompt" (x86, x64 or ARM64), <tt>cd</tt> to the
193directory with the source code and run these commands: 205directory with the source code and run these commands:
194</p> 206</p>
195<pre class="code"> 207<pre class="code">
@@ -200,9 +212,12 @@ msvcbuild
200Check the <tt>msvcbuild.bat</tt> file for more options. 212Check the <tt>msvcbuild.bat</tt> file for more options.
201Then follow the installation instructions below. 213Then follow the installation instructions below.
202</p> 214</p>
203<h3>Building with MinGW or Cygwin</h3>
204<p> 215<p>
205Open a command prompt window and make sure the MinGW or Cygwin programs 216For an x64 to ARM64 cross-build run this first: <tt>vcvarsall.bat x64_arm64</tt>
217</p>
218<h3>Building with MinGW</h3>
219<p>
220Open a command prompt window and make sure the MinGW programs
206are in your path. Then <tt>cd</tt> to the directory of the git repository. 221are in your path. Then <tt>cd</tt> to the directory of the git repository.
207Then run this command for MinGW: 222Then run this command for MinGW:
208</p> 223</p>
@@ -210,12 +225,6 @@ Then run this command for MinGW:
210mingw32-make 225mingw32-make
211</pre> 226</pre>
212<p> 227<p>
213Or this command for Cygwin:
214</p>
215<pre class="code">
216make
217</pre>
218<p>
219Then follow the installation instructions below. 228Then follow the installation instructions below.
220</p> 229</p>
221<h3>Installing LuaJIT</h3> 230<h3>Installing LuaJIT</h3>
@@ -232,31 +241,53 @@ absolute path names &mdash; all modules are loaded relative to the
232directory where <tt>luajit.exe</tt> is installed 241directory where <tt>luajit.exe</tt> is installed
233(see <tt>src/luaconf.h</tt>). 242(see <tt>src/luaconf.h</tt>).
234</p> 243</p>
244<p>
245The final directory layout should look like this:
246</p>
247<pre class="code">
248├── luajit.exe
249├── lua51.dll
250├── <- put your own classic Lua/C API modules (*.dll) here
251└── lua
252 ├── <- put your own Lua modules (*.lua) here
253 └── jit
254 ├── bc.lua
255 └── (etc …)
256</pre>
235 257
236<h2 id="cross">Cross-compiling LuaJIT</h2> 258<h2 id="cross">Cross-compiling LuaJIT</h2>
237<p> 259<p>
260First, let's clear up some terminology:
261</p>
262<ul>
263<li>Host: This is your development system, usually based on a x64 or x86 CPU.</li>
264<li>Target: This is the target system you want LuaJIT to run on, e.g. Android/ARM.</li>
265<li>Toolchain: This comprises a C compiler, linker, assembler and a matching C library.</li>
266<li>Host (or system) toolchain: This is the toolchain used to build native binaries for your host system.</li>
267<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>
268</ul>
269<p>
238The GNU Makefile-based build system allows cross-compiling on any host 270The GNU Makefile-based build system allows cross-compiling on any host
239for any supported target, as long as both architectures have the same 271for any supported target:
240pointer size. If you want to cross-compile to any 32 bit target on an
241x64 OS, you need to install the multilib development package (e.g.
242<tt>libc6-dev-i386</tt> on Debian/Ubuntu) and build a 32 bit host part
243(<tt>HOST_CC="gcc -m32"</tt>). On some distro versions, multilib conflicts
244with cross-compilers. The workaround is to install the x86 cross-compiler
245package <tt>gcc-i686-linux-gnu</tt> and use it to build the host part
246(<tt>HOST_CC=i686-linux-gnu-gcc</tt>).
247</p> 272</p>
273<ul>
274<li>Yes, you need a toolchain for both your host <em>and</em> your target!</li>
275<li>Both host and target architectures must have the same pointer size.</li>
276<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>
277<li>On some distro versions, multilib conflicts with cross-compilers. The workaround is to install the x86 cross-compiler package <tt>gcc-i686-linux-gnu</tt> and use it to build the host part (<tt>HOST_CC=i686-linux-gnu-gcc</tt>).</li>
278<li>64 bit targets always require compilation on a 64 bit host.</li>
279</ul>
248<p> 280<p>
249You need to specify <tt>TARGET_SYS</tt> whenever the host OS and the 281You need to specify <tt>TARGET_SYS</tt> whenever the host OS and the
250target OS differ, or you'll get assembler or linker errors. E.g. if 282target OS differ, or you'll get assembler or linker errors:
251you're compiling on a Windows or macOS host for embedded Linux or Android,
252you need to add <tt>TARGET_SYS=Linux</tt> to the examples below. For a
253minimal target OS, you may need to disable the built-in allocator in
254<tt>src/Makefile</tt> and use <tt>TARGET_SYS=Other</tt>. Don't forget to
255specify the same <tt>TARGET_SYS</tt> for the install step, too.
256</p> 283</p>
284<ul>
285<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>
286<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>
287<li>Don't forget to specify the same <tt>TARGET_SYS</tt> for the install step, too.</li>
288</ul>
257<p> 289<p>
258The examples below only show some popular targets &mdash; please check 290Here are some examples where host and target have the same CPU:
259the comments in <tt>src/Makefile</tt> for more details.
260</p> 291</p>
261<pre class="code"> 292<pre class="code">
262# Cross-compile to a 32 bit binary on a multilib x64 OS 293# Cross-compile to a 32 bit binary on a multilib x64 OS
@@ -274,34 +305,44 @@ use the canonical toolchain triplets for Linux.
274</p> 305</p>
275<p> 306<p>
276Since there's often no easy way to detect CPU features at runtime, it's 307Since there's often no easy way to detect CPU features at runtime, it's
277important to compile with the proper CPU or architecture settings. You 308important to compile with the proper CPU or architecture settings:
278can specify these when building the toolchain yourself. Or add 309</o>
279<tt>-mcpu=...</tt> or <tt>-march=...</tt> to <tt>TARGET_CFLAGS</tt>. For 310<ul>
280ARM it's important to have the correct <tt>-mfloat-abi=...</tt> setting, 311<li>The best way to get consistent results is to specify the correct settings when building the toolchain yourself.</li>
281too. Otherwise, LuaJIT may not run at the full performance of your target 312<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>
282CPU. 313<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>
314<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>
315</ul>
316<p>
317Here are some examples for targets with a different CPU than the host:
283</p> 318</p>
284<pre class="code"> 319<pre class="code">
285# ARM soft-float 320# ARM soft-float
286make HOST_CC="gcc -m32" CROSS=arm-linux-gnueabi- \ 321make HOST_CC="gcc -m32" CROSS=arm-linux-gnueabi- \
287 TARGET_CFLAGS="-mfloat-abi=soft" 322 TARGET_CFLAGS="-mfloat-abi=soft"
288 323
289# ARM soft-float ABI with VFP (example for Cortex-A8) 324# ARM soft-float ABI with VFP (example for Cortex-A9)
290make HOST_CC="gcc -m32" CROSS=arm-linux-gnueabi- \ 325make HOST_CC="gcc -m32" CROSS=arm-linux-gnueabi- \
291 TARGET_CFLAGS="-mcpu=cortex-a8 -mfloat-abi=softfp" 326 TARGET_CFLAGS="-mcpu=cortex-a9 -mfloat-abi=softfp"
292 327
293# ARM hard-float ABI with VFP (armhf, requires recent toolchain) 328# ARM hard-float ABI with VFP (armhf, most modern toolchains)
294make HOST_CC="gcc -m32" CROSS=arm-linux-gnueabihf- 329make HOST_CC="gcc -m32" CROSS=arm-linux-gnueabihf-
295 330
331# ARM64
332make CROSS=aarch64-linux-gnu-
333
296# PPC 334# PPC
297make HOST_CC="gcc -m32" CROSS=powerpc-linux-gnu- 335make HOST_CC="gcc -m32" CROSS=powerpc-linux-gnu-
298# PPC/e500v2 (fast interpreter only)
299make HOST_CC="gcc -m32" CROSS=powerpc-e500v2-linux-gnuspe-
300 336
301# MIPS big-endian 337# MIPS32 big-endian
302make HOST_CC="gcc -m32" CROSS=mips-linux- 338make HOST_CC="gcc -m32" CROSS=mips-linux-gnu-
303# MIPS little-endian 339# MIPS32 little-endian
304make HOST_CC="gcc -m32" CROSS=mipsel-linux- 340make HOST_CC="gcc -m32" CROSS=mipsel-linux-gnu-
341
342# MIPS64 big-endian
343make CROSS=mips-linux- TARGET_CFLAGS="-mips64r2 -mabi=64"
344# MIPS64 little-endian
345make CROSS=mipsel-linux- TARGET_CFLAGS="-mips64r2 -mabi=64"
305</pre> 346</pre>
306<p> 347<p>
307You 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>. 348You 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>.
@@ -309,8 +350,17 @@ Please adapt the environment variables to match the install locations and the
309desired target platform. E.g. Android&nbsp;4.1 corresponds to ABI level&nbsp;16. 350desired target platform. E.g. Android&nbsp;4.1 corresponds to ABI level&nbsp;16.
310</p> 351</p>
311<pre class="code"> 352<pre class="code">
312# Android/ARM, armeabi-v7a (ARMv7 VFP), Android 4.1+ (JB) 353# Android/ARM64, aarch64, Android 5.0+ (L)
354NDKDIR=/opt/android/ndk
355NDKBIN=$NDKDIR/toolchains/llvm/prebuilt/linux-x86_64/bin
356NDKCROSS=$NDKBIN/aarch64-linux-android-
357NDKCC=$NDKBIN/aarch64-linux-android21-clang
358make CROSS=$NDKCROSS \
359 STATIC_CC=$NDKCC DYNAMIC_CC="$NDKCC -fPIC" \
360 TARGET_LD=$NDKCC TARGET_AR="$NDKBIN/llvm-ar rcus" \
361 TARGET_STRIP=$NDKBIN/llvm-strip
313 362
363# Android/ARM, armeabi-v7a (ARMv7 VFP), Android 4.1+ (JB)
314NDKDIR=/opt/android/ndk 364NDKDIR=/opt/android/ndk
315NDKBIN=$NDKDIR/toolchains/llvm/prebuilt/linux-x86_64/bin 365NDKBIN=$NDKDIR/toolchains/llvm/prebuilt/linux-x86_64/bin
316NDKCROSS=$NDKBIN/arm-linux-androideabi- 366NDKCROSS=$NDKBIN/arm-linux-androideabi-
@@ -321,9 +371,23 @@ make HOST_CC="gcc -m32" CROSS=$NDKCROSS \
321 TARGET_STRIP=$NDKBIN/llvm-strip 371 TARGET_STRIP=$NDKBIN/llvm-strip
322</pre> 372</pre>
323<p> 373<p>
324Please use the LuaJIT 2.1 branch to compile for 374You 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>:
325<b id="ios">iOS</b> (iPhone/iPad). 375</p>
376<p style="font-size: 8pt;">
377Note: <b>the JIT compiler is disabled for iOS</b>, because regular iOS Apps
378are not allowed to generate code at runtime. You'll only get the performance
379of the LuaJIT interpreter on iOS. This is still faster than plain Lua, but
380much slower than the JIT compiler. Please complain to Apple, not me.
381Or use Android. :-p
326</p> 382</p>
383<pre class="code">
384# iOS/ARM64
385ISDKP=$(xcrun --sdk iphoneos --show-sdk-path)
386ICC=$(xcrun --sdk iphoneos --find clang)
387ISDKF="-arch arm64 -isysroot $ISDKP"
388make DEFAULT_CC=clang CROSS="$(dirname $ICC)/" \
389 TARGET_FLAGS="$ISDKF" TARGET_SYS=iOS
390</pre>
327 391
328<h3 id="consoles">Cross-compiling for consoles</h3> 392<h3 id="consoles">Cross-compiling for consoles</h3>
329<p> 393<p>
@@ -367,15 +431,35 @@ and run the build command given in the table:
367<td class="compatx"><tt>ps4build</tt></td> 431<td class="compatx"><tt>ps4build</tt></td>
368</tr> 432</tr>
369<tr class="even"> 433<tr class="even">
434<td class="compatname"><b id="ps5">PS5</b></td>
435<td class="compatbits">64</td>
436<td class="compatx"><tt>ps5build</tt></td>
437</tr>
438<tr class="odd">
370<td class="compatname"><b id="psvita">PS Vita</b></td> 439<td class="compatname"><b id="psvita">PS Vita</b></td>
371<td class="compatbits">32</td> 440<td class="compatbits">32</td>
372<td class="compatx"><tt>psvitabuild</tt></td> 441<td class="compatx"><tt>psvitabuild</tt></td>
373</tr> 442</tr>
374<tr class="odd"> 443<tr class="even">
375<td class="compatname"><b id="xbox360">Xbox 360</b></td> 444<td class="compatname"><b id="xbox360">Xbox 360</b></td>
376<td class="compatbits">32</td> 445<td class="compatbits">32</td>
377<td class="compatx"><tt>xedkbuild</tt></td> 446<td class="compatx"><tt>xedkbuild</tt></td>
378</tr> 447</tr>
448<tr class="odd">
449<td class="compatname"><b id="xboxone">Xbox One</b></td>
450<td class="compatbits">64</td>
451<td class="compatx"><tt>xb1build</tt></td>
452</tr>
453<tr class="even">
454<td class="compatname"><b id="nx32">Nintendo Switch NX32</b></td>
455<td class="compatbits">32</td>
456<td class="compatx"><tt>nxbuild</tt></td>
457</tr>
458<tr class="odd">
459<td class="compatname"><b id="nx64">Nintendo Switch NX64</b></td>
460<td class="compatbits">64</td>
461<td class="compatx"><tt>nxbuild</tt></td>
462</tr>
379</table> 463</table>
380<p> 464<p>
381Please check out the comments in the corresponding <tt>*.bat</tt> 465Please check out the comments in the corresponding <tt>*.bat</tt>