ARM VFP + hard-float ABI support in git HEAD

  • From: Mike Pall <mike-1208@xxxxxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Thu, 9 Aug 2012 13:49:34 +0200

The extensions to the LuaJIT ARM port for VFP and hard-float support
are now available from LuaJIT git HEAD.

The ARM port of LuaJIT can now be built for three different
CPU/ABI combinations:

* ARMv5+, soft-float EABI, soft-float FP operations
* ARMv6+, soft-float EABI, VFPv2+ FP operations
* ARMv6+, hard-float EABI, VFPv2+ FP operations (e.g. Debian armhf)

The JIT compiler can take advantage of extra features in ARMv7 and
VFPv3, too. However you need to properly compile LuaJIT for your
target CPU, since runtime feature detection is problematic on ARM.

Most ARM toolchains are either generic or underspecify the minimum
CPU or ARM architecture required. To unlock the full performance
of your target CPU, you may need to give extra compiler options:

  -mcpu=...           the (minimum) target CPU, alternatively
  -march=...          the (minimum) ARM architecture version
  -mfloat-abi=soft    soft-float ABI, soft-float computations
  -mfloat-abi=softfp  soft-float ABI, VFP FPU
  -mfloat-abi=hard    hard-float ABI, VFP FPU

Add these to TARGET_CFLAGS on the make invocation.

Here are some cross-compilation examples. More details can be
found in: doc/install.html#cross

# ARM soft-float
make HOST_CC="gcc -m32" CROSS=arm-linux-gnueabi- \
     TARGET_CFLAGS="-mfloat-abi=soft"

# ARM soft-float ABI with VFP (example for Cortex-a8)
make HOST_CC="gcc -m32" CROSS=arm-linux-gnueabi- \
     TARGET_CFLAGS="-mcpu=cortex-a8 -mfloat-abi=softfp"

# ARM hard-float ABI with VFP (armhf, requires recent toolchain)
make HOST_CC="gcc -m32" CROSS=arm-linux-gnueabihf-

Note that the hard-float ABI is incompatible with the soft-float
ABI (with or without VFP) and requires a rebuild of the whole
system with a relatively recent GCC etc. Debian armhf or Raspbian
provide such an environment. Note this does *not* give you a
substantial speedup with LuaJIT itself, compared to soft-float ABI
plus VFP. The major speed difference that people see with armhf
installs is due to the newer GCC versions with different default
settings that enable ARMv7, Thumb-2 and VFP. The modified ABI
itself has only a minor influence.

If you already have a soft-float ABI system (e.g. Debian armel),
then it's much easier to keep this environment and build LuaJIT
with the proper CPU/arch and float-abi settings.

On a related note, this update should also fix the issues with
XCode for iOS. See: doc/install.html#ios


I cannot possibly test all combinations of ARM CPUs and OS
versions that are out there. Please report any issues you may
find. Thank you!

--Mike

Other related posts: