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