[Tarantool-patches] [PATCH luajit 2/3] OSX/iOS: Handle iOS simulator and ARM64 Macs.

Igor Munkin imun at tarantool.org
Tue May 11 01:09:06 MSK 2021


From: Mike Pall <mike>

(cherry picked from commit 2e2fb8f6b5118e1a7996b76600c6ee98bfd5f203)

After Apple released Macs working on ARM64, the previous recipe in
lj_arch.h for detecting various Apple platforms is not valid anymore.
Fortunately, there is a system header (i.e. TargetConditionals.h),
provided by SDK with the proper defines to be set. Starting from this
patch, LuaJIT identifies Apple hosts via this header.

Since testing machinery assumes that LuaJIT is built with JIT support
being enabled unconditionally, a smoke test for it is also added
alongside with this patch.

Igor Munkin:
* added the description and the test for the problem
* backported the original patch to tarantool/luajit repo

Part of tarantool/tarantool#5629
Relates to tarantool/tarantool#5983

Signed-off-by: Igor Munkin <imun at tarantool.org>
---
 src/lj_arch.h                                         |  8 +++++++-
 .../gh-5983-jit-library-smoke-tests.test.lua          | 11 +++++++++++
 2 files changed, 18 insertions(+), 1 deletion(-)
 create mode 100644 test/tarantool-tests/gh-5983-jit-library-smoke-tests.test.lua

diff --git a/src/lj_arch.h b/src/lj_arch.h
index d8676e92..5bf0afb8 100644
--- a/src/lj_arch.h
+++ b/src/lj_arch.h
@@ -69,6 +69,7 @@
 #elif defined(__linux__)
 #define LUAJIT_OS	LUAJIT_OS_LINUX
 #elif defined(__MACH__) && defined(__APPLE__)
+#include "TargetConditionals.h"
 #define LUAJIT_OS	LUAJIT_OS_OSX
 #elif (defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || \
        defined(__NetBSD__) || defined(__OpenBSD__) || \
@@ -103,10 +104,15 @@
 #define LJ_TARGET_WINDOWS	(LUAJIT_OS == LUAJIT_OS_WINDOWS)
 #define LJ_TARGET_LINUX		(LUAJIT_OS == LUAJIT_OS_LINUX)
 #define LJ_TARGET_OSX		(LUAJIT_OS == LUAJIT_OS_OSX)
-#define LJ_TARGET_IOS		(LJ_TARGET_OSX && (LUAJIT_TARGET == LUAJIT_ARCH_ARM || LUAJIT_TARGET == LUAJIT_ARCH_ARM64))
 #define LJ_TARGET_POSIX		(LUAJIT_OS > LUAJIT_OS_WINDOWS)
 #define LJ_TARGET_DLOPEN	LJ_TARGET_POSIX
 
+#if TARGET_OS_IPHONE
+#define LJ_TARGET_IOS		1
+#else
+#define LJ_TARGET_IOS		0
+#endif
+
 #ifdef __CELLOS_LV2__
 #define LJ_TARGET_PS3		1
 #define LJ_TARGET_CONSOLE	1
diff --git a/test/tarantool-tests/gh-5983-jit-library-smoke-tests.test.lua b/test/tarantool-tests/gh-5983-jit-library-smoke-tests.test.lua
new file mode 100644
index 00000000..b23dd712
--- /dev/null
+++ b/test/tarantool-tests/gh-5983-jit-library-smoke-tests.test.lua
@@ -0,0 +1,11 @@
+local tap = require('tap')
+
+local test = tap.test('gh-5983-jit-library-smoke-tests')
+test:plan(1)
+
+-- Just check whether LuaJIT is built with JIT support. Otherwise,
+-- <jit.on> raises an error that is handled via <pcall> and passed
+-- as a second argument to the assertion.
+test:ok(pcall(jit.on))
+
+os.exit(test:check() and 0 or 1)
-- 
2.25.0



More information about the Tarantool-patches mailing list