Browse Source

FFI: Add define to disable the FFI library.

Mike Pall 15 years ago
parent
commit
0ffd06aba8
2 changed files with 13 additions and 0 deletions
  1. 6 0
      src/Makefile
  2. 7 0
      src/lj_arch.h

+ 6 - 0
src/Makefile

@@ -88,6 +88,12 @@ BUILDMODE= mixed
 # recompile with "make clean", followed by "make".
 XCFLAGS=
 #
+# Permanently disable the FFI extension to reduce the size of the LuaJIT
+# executable. But please consider that the FFI library is compiled-in,
+# but NOT loaded by default. It only allocates any memory, if you actually
+# make use of it.
+#XCFLAGS+= -DLUAJIT_DISABLE_FFI
+#
 # Enable some upwards-compatible features from Lua 5.2 that are unlikely
 # to break existing code (e.g. __pairs). Note that this does not provide
 # full compatibility with Lua 5.2 at this time.

+ 7 - 0
src/lj_arch.h

@@ -183,6 +183,13 @@
 #define LJ_HASJIT		1
 #endif
 
+/* Disable or enable the FFI extension. */
+#if defined(LUAJIT_DISABLE_FFI) || defined(LJ_ARCH_NOFFI)
+#define LJ_HASFFI		0
+#else
+#define LJ_HASFFI		1
+#endif
+
 #if LJ_ARCH_ENDIAN == LUAJIT_BE
 #define LJ_LE			0
 #define LJ_BE			1