diff options
Diffstat (limited to 'doc/install.html')
-rw-r--r-- | doc/install.html | 150 |
1 files changed, 114 insertions, 36 deletions
diff --git a/doc/install.html b/doc/install.html index 21866315..be721031 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-2023"> | 6 | <meta name="Copyright" content="Copyright (C) 2005-2023"> |
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">»</span></a> | 72 | <a href="https://luajit.org/status.html">Status <span class="ext">»</span></a> |
@@ -121,6 +125,13 @@ MSVC (Visual Studio).</li> | |||
121 | Please read the instructions given in these files, before changing | 125 | Please read the instructions given in these files, before changing |
122 | any settings. | 126 | any settings. |
123 | </p> | 127 | </p> |
128 | <p> | ||
129 | All LuaJIT 64 bit ports use 64 bit GC objects by default (<tt>LJ_GC64</tt>). | ||
130 | For x64, you can select the old 32-on-64 bit mode by adding | ||
131 | <tt>XCFLAGS=-DLUAJIT_DISABLE_GC64</tt> to the make command. | ||
132 | Please 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 | |||
154 | make PREFIX=/home/myself/lj2 | 165 | make PREFIX=/home/myself/lj2 |
155 | </pre> | 166 | </pre> |
156 | <p> | 167 | <p> |
157 | Please use the LuaJIT 2.1 branch to compile for | 168 | Note for macOS: you <b>must</b> set the <tt>MACOSX_DEPLOYMENT_TARGET</tt> |
158 | <b id="osx">macOS (OSX)</b>. | 169 | environment variable to a value supported by your toolchain: |
159 | </p> | 170 | </p> |
171 | <pre class="code"> | ||
172 | MACOSX_DEPLOYMENT_TARGET=XX.YY make | ||
173 | </pre> | ||
160 | <h3>Installing LuaJIT</h3> | 174 | <h3>Installing LuaJIT</h3> |
161 | <p> | 175 | <p> |
162 | The top-level Makefile installs LuaJIT by default under | 176 | The top-level Makefile installs LuaJIT by default under |
@@ -235,25 +249,36 @@ directory where <tt>luajit.exe</tt> is installed | |||
235 | 249 | ||
236 | <h2 id="cross">Cross-compiling LuaJIT</h2> | 250 | <h2 id="cross">Cross-compiling LuaJIT</h2> |
237 | <p> | 251 | <p> |
252 | First, let's clear up some terminology: | ||
253 | </p> | ||
254 | <ul> | ||
255 | <li>Host: This is your development system, usually based on a x64 or x86 CPU.</li> | ||
256 | <li>Target: This is the target system you want LuaJIT to run on, e.g. Android/ARM.</li> | ||
257 | <li>Toolchain: This comprises a C compiler, linker, assembler and a matching C library.</li> | ||
258 | <li>Host (or system) toolchain: This is the toolchain used to build native binaries for your host system.</li> | ||
259 | <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> | ||
260 | </ul> | ||
261 | <p> | ||
238 | The GNU Makefile-based build system allows cross-compiling on any host | 262 | The GNU Makefile-based build system allows cross-compiling on any host |
239 | for any supported target, as long as both architectures have the same | 263 | for any supported target: |
240 | pointer size. If you want to cross-compile to any 32 bit target on an | ||
241 | x64 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>). | ||
244 | </p> | 264 | </p> |
265 | <ul> | ||
266 | <li>Yes, you need a toolchain for both your host <em>and</em> your target!</li> | ||
267 | <li>Both host and target architectures must have the same pointer size.</li> | ||
268 | <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> | ||
269 | <li>64 bit targets always require compilation on a 64 bit host.</li> | ||
270 | </ul> | ||
245 | <p> | 271 | <p> |
246 | You need to specify <tt>TARGET_SYS</tt> whenever the host OS and the | 272 | You need to specify <tt>TARGET_SYS</tt> whenever the host OS and the |
247 | target OS differ, or you'll get assembler or linker errors. E.g. if | 273 | target OS differ, or you'll get assembler or linker errors: |
248 | you're compiling on a Windows or macOS host for embedded Linux or Android, | ||
249 | you need to add <tt>TARGET_SYS=Linux</tt> to the examples below. For a | ||
250 | minimal target OS, you may need to disable the built-in allocator in | ||
251 | <tt>src/Makefile</tt> and use <tt>TARGET_SYS=Other</tt>. Don't forget to | ||
252 | specify the same <tt>TARGET_SYS</tt> for the install step, too. | ||
253 | </p> | 274 | </p> |
275 | <ul> | ||
276 | <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> | ||
277 | <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> | ||
278 | <li>Don't forget to specify the same <tt>TARGET_SYS</tt> for the install step, too.</li> | ||
279 | </ul> | ||
254 | <p> | 280 | <p> |
255 | The examples below only show some popular targets — please check | 281 | Here are some examples where host and target have the same CPU: |
256 | the comments in <tt>src/Makefile</tt> for more details. | ||
257 | </p> | 282 | </p> |
258 | <pre class="code"> | 283 | <pre class="code"> |
259 | # Cross-compile to a 32 bit binary on a multilib x64 OS | 284 | # Cross-compile to a 32 bit binary on a multilib x64 OS |
@@ -271,34 +296,44 @@ use the canonical toolchain triplets for Linux. | |||
271 | </p> | 296 | </p> |
272 | <p> | 297 | <p> |
273 | Since there's often no easy way to detect CPU features at runtime, it's | 298 | Since there's often no easy way to detect CPU features at runtime, it's |
274 | important to compile with the proper CPU or architecture settings. You | 299 | important to compile with the proper CPU or architecture settings: |
275 | can specify these when building the toolchain yourself. Or add | 300 | </o> |
276 | <tt>-mcpu=...</tt> or <tt>-march=...</tt> to <tt>TARGET_CFLAGS</tt>. For | 301 | <ul> |
277 | ARM it's important to have the correct <tt>-mfloat-abi=...</tt> setting, | 302 | <li>The best way to get consistent results is to specify the correct settings when building the toolchain yourself.</li> |
278 | too. Otherwise, LuaJIT may not run at the full performance of your target | 303 | <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> |
279 | CPU. | 304 | <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> |
305 | <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> | ||
306 | </ul> | ||
307 | <p> | ||
308 | Here are some examples for targets with a different CPU than the host: | ||
280 | </p> | 309 | </p> |
281 | <pre class="code"> | 310 | <pre class="code"> |
282 | # ARM soft-float | 311 | # ARM soft-float |
283 | make HOST_CC="gcc -m32" CROSS=arm-linux-gnueabi- \ | 312 | make HOST_CC="gcc -m32" CROSS=arm-linux-gnueabi- \ |
284 | TARGET_CFLAGS="-mfloat-abi=soft" | 313 | TARGET_CFLAGS="-mfloat-abi=soft" |
285 | 314 | ||
286 | # ARM soft-float ABI with VFP (example for Cortex-A8) | 315 | # ARM soft-float ABI with VFP (example for Cortex-A9) |
287 | make HOST_CC="gcc -m32" CROSS=arm-linux-gnueabi- \ | 316 | make HOST_CC="gcc -m32" CROSS=arm-linux-gnueabi- \ |
288 | TARGET_CFLAGS="-mcpu=cortex-a8 -mfloat-abi=softfp" | 317 | TARGET_CFLAGS="-mcpu=cortex-a9 -mfloat-abi=softfp" |
289 | 318 | ||
290 | # ARM hard-float ABI with VFP (armhf, requires recent toolchain) | 319 | # ARM hard-float ABI with VFP (armhf, most modern toolchains) |
291 | make HOST_CC="gcc -m32" CROSS=arm-linux-gnueabihf- | 320 | make HOST_CC="gcc -m32" CROSS=arm-linux-gnueabihf- |
292 | 321 | ||
322 | # ARM64 | ||
323 | make CROSS=aarch64-linux-gnu- | ||
324 | |||
293 | # PPC | 325 | # PPC |
294 | make HOST_CC="gcc -m32" CROSS=powerpc-linux-gnu- | 326 | make HOST_CC="gcc -m32" CROSS=powerpc-linux-gnu- |
295 | # PPC/e500v2 (fast interpreter only) | ||
296 | make HOST_CC="gcc -m32" CROSS=powerpc-e500v2-linux-gnuspe- | ||
297 | 327 | ||
298 | # MIPS big-endian | 328 | # MIPS32 big-endian |
299 | make HOST_CC="gcc -m32" CROSS=mips-linux- | 329 | make HOST_CC="gcc -m32" CROSS=mips-linux-gnu- |
300 | # MIPS little-endian | 330 | # MIPS32 little-endian |
301 | make HOST_CC="gcc -m32" CROSS=mipsel-linux- | 331 | make HOST_CC="gcc -m32" CROSS=mipsel-linux-gnu- |
332 | |||
333 | # MIPS64 big-endian | ||
334 | make CROSS=mips-linux- TARGET_CFLAGS="-mips64r2 -mabi=64" | ||
335 | # MIPS64 little-endian | ||
336 | make CROSS=mipsel-linux- TARGET_CFLAGS="-mips64r2 -mabi=64" | ||
302 | </pre> | 337 | </pre> |
303 | <p> | 338 | <p> |
304 | You can cross-compile for <b id="android">Android</b> using the <a href="https://developer.android.com/ndk/"><span class="ext">»</span> Android NDK</a>. | 339 | You can cross-compile for <b id="android">Android</b> using the <a href="https://developer.android.com/ndk/"><span class="ext">»</span> Android NDK</a>. |
@@ -306,8 +341,17 @@ Please adapt the environment variables to match the install locations and the | |||
306 | desired target platform. E.g. Android 4.1 corresponds to ABI level 16. | 341 | desired target platform. E.g. Android 4.1 corresponds to ABI level 16. |
307 | </p> | 342 | </p> |
308 | <pre class="code"> | 343 | <pre class="code"> |
309 | # Android/ARM, armeabi-v7a (ARMv7 VFP), Android 4.1+ (JB) | 344 | # Android/ARM64, aarch64, Android 5.0+ (L) |
345 | NDKDIR=/opt/android/ndk | ||
346 | NDKBIN=$NDKDIR/toolchains/llvm/prebuilt/linux-x86_64/bin | ||
347 | NDKCROSS=$NDKBIN/aarch64-linux-android- | ||
348 | NDKCC=$NDKBIN/aarch64-linux-android21-clang | ||
349 | make CROSS=$NDKCROSS \ | ||
350 | STATIC_CC=$NDKCC DYNAMIC_CC="$NDKCC -fPIC" \ | ||
351 | TARGET_LD=$NDKCC TARGET_AR="$NDKBIN/llvm-ar rcus" \ | ||
352 | TARGET_STRIP=$NDKBIN/llvm-strip | ||
310 | 353 | ||
354 | # Android/ARM, armeabi-v7a (ARMv7 VFP), Android 4.1+ (JB) | ||
311 | NDKDIR=/opt/android/ndk | 355 | NDKDIR=/opt/android/ndk |
312 | NDKBIN=$NDKDIR/toolchains/llvm/prebuilt/linux-x86_64/bin | 356 | NDKBIN=$NDKDIR/toolchains/llvm/prebuilt/linux-x86_64/bin |
313 | NDKCROSS=$NDKBIN/arm-linux-androideabi- | 357 | NDKCROSS=$NDKBIN/arm-linux-androideabi- |
@@ -318,9 +362,23 @@ make HOST_CC="gcc -m32" CROSS=$NDKCROSS \ | |||
318 | TARGET_STRIP=$NDKBIN/llvm-strip | 362 | TARGET_STRIP=$NDKBIN/llvm-strip |
319 | </pre> | 363 | </pre> |
320 | <p> | 364 | <p> |
321 | Please use the LuaJIT 2.1 branch to compile for | 365 | You 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">»</span> iOS SDK</a>: |
322 | <b id="ios">iOS</b> (iPhone/iPad). | 366 | </p> |
367 | <p style="font-size: 8pt;"> | ||
368 | Note: <b>the JIT compiler is disabled for iOS</b>, because regular iOS Apps | ||
369 | are not allowed to generate code at runtime. You'll only get the performance | ||
370 | of the LuaJIT interpreter on iOS. This is still faster than plain Lua, but | ||
371 | much slower than the JIT compiler. Please complain to Apple, not me. | ||
372 | Or use Android. :-p | ||
323 | </p> | 373 | </p> |
374 | <pre class="code"> | ||
375 | # iOS/ARM64 | ||
376 | ISDKP=$(xcrun --sdk iphoneos --show-sdk-path) | ||
377 | ICC=$(xcrun --sdk iphoneos --find clang) | ||
378 | ISDKF="-arch arm64 -isysroot $ISDKP" | ||
379 | make DEFAULT_CC=clang CROSS="$(dirname $ICC)/" \ | ||
380 | TARGET_FLAGS="$ISDKF" TARGET_SYS=iOS | ||
381 | </pre> | ||
324 | 382 | ||
325 | <h3 id="consoles">Cross-compiling for consoles</h3> | 383 | <h3 id="consoles">Cross-compiling for consoles</h3> |
326 | <p> | 384 | <p> |
@@ -364,15 +422,35 @@ and run the build command given in the table: | |||
364 | <td class="compatx"><tt>ps4build</tt></td> | 422 | <td class="compatx"><tt>ps4build</tt></td> |
365 | </tr> | 423 | </tr> |
366 | <tr class="even"> | 424 | <tr class="even"> |
425 | <td class="compatname"><b id="ps5">PS5</b></td> | ||
426 | <td class="compatbits">64</td> | ||
427 | <td class="compatx"><tt>ps5build</tt></td> | ||
428 | </tr> | ||
429 | <tr class="odd"> | ||
367 | <td class="compatname"><b id="psvita">PS Vita</b></td> | 430 | <td class="compatname"><b id="psvita">PS Vita</b></td> |
368 | <td class="compatbits">32</td> | 431 | <td class="compatbits">32</td> |
369 | <td class="compatx"><tt>psvitabuild</tt></td> | 432 | <td class="compatx"><tt>psvitabuild</tt></td> |
370 | </tr> | 433 | </tr> |
371 | <tr class="odd"> | 434 | <tr class="even"> |
372 | <td class="compatname"><b id="xbox360">Xbox 360</b></td> | 435 | <td class="compatname"><b id="xbox360">Xbox 360</b></td> |
373 | <td class="compatbits">32</td> | 436 | <td class="compatbits">32</td> |
374 | <td class="compatx"><tt>xedkbuild</tt></td> | 437 | <td class="compatx"><tt>xedkbuild</tt></td> |
375 | </tr> | 438 | </tr> |
439 | <tr class="odd"> | ||
440 | <td class="compatname"><b id="xboxone">Xbox One</b></td> | ||
441 | <td class="compatbits">64</td> | ||
442 | <td class="compatx"><tt>xb1build</tt></td> | ||
443 | </tr> | ||
444 | <tr class="even"> | ||
445 | <td class="compatname"><b id="nx32">Nintendo Switch NX32</b></td> | ||
446 | <td class="compatbits">32</td> | ||
447 | <td class="compatx"><tt>nxbuild</tt></td> | ||
448 | </tr> | ||
449 | <tr class="odd"> | ||
450 | <td class="compatname"><b id="nx64">Nintendo Switch NX64</b></td> | ||
451 | <td class="compatbits">64</td> | ||
452 | <td class="compatx"><tt>nxbuild</tt></td> | ||
453 | </tr> | ||
376 | </table> | 454 | </table> |
377 | <p> | 455 | <p> |
378 | Please check out the comments in the corresponding <tt>*.bat</tt> | 456 | Please check out the comments in the corresponding <tt>*.bat</tt> |