From 1a499d88d08a2da3592f07b4d23585ff862a234c Mon Sep 17 00:00:00 2001
From: Luigi Scarso <luigi.scarso@gmail.com>
Date: Tue, 6 Feb 2018 15:03:44 +0000
Subject: [PATCH] (trunk) fix building vm for luajit

---
 source/libs/luajit/configure       |  9 +++++++++
 source/libs/luajit/m4/lj-system.m4 | 11 +++++++++--
 2 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/source/libs/luajit/configure b/source/libs/luajit/configure
index b8a59596a..086a2fc6e 100755
--- a/source/libs/luajit/configure
+++ b/source/libs/luajit/configure
@@ -14206,6 +14206,10 @@ elif grep 'LJ_TARGET_ARM64 ' conftest.i >/dev/null 2>&1; then :
          if test "x$LJHOST" = xiOS; then :
   LUAJIT_CFLAGS='-fno-omit-frame-pointer'
 fi
+         if grep '__AARCH64EB__' conftest.i >/dev/null 2>&1; then :
+  echo '-D__AARCH64EB__=1' >>native_flags
+fi
+
 elif grep 'LJ_TARGET_PPC ' conftest.i >/dev/null 2>&1; then :
   LJARCH=ppc
          if grep 'LJ_LE 1' conftest.i >/dev/null 2>&1; then :
@@ -14231,6 +14235,11 @@ if grep 'LJ_NO_UNWIND 1' conftest.i >/dev/null 2>&1; then :
          echo '-DLUAJIT_NO_UNWIND' >>native_flags
 fi
 echo "-DLUAJIT_TARGET=LUAJIT_ARCH_$LJARCH" >>native_flags
+if grep 'LJ_LE' conftest.i >/dev/null 2>&1; then :
+  echo '-D ENDIAN_LE' >>dynasm_flags
+else
+  echo '-D ENDIAN_BE' >>dynasm_flags
+fi
 if grep 'LJ_ARCH_BITS 64' conftest.i >/dev/null 2>&1; then :
   echo '-D P64' >>dynasm_flags
          if test "x$LJHOST" = xLinux; then :
diff --git a/source/libs/luajit/m4/lj-system.m4 b/source/libs/luajit/m4/lj-system.m4
index cd2fc9a2e..73ba282af 100644
--- a/source/libs/luajit/m4/lj-system.m4
+++ b/source/libs/luajit/m4/lj-system.m4
@@ -5,6 +5,7 @@
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
 
+
 # _LJ_ARCH
 # --------
 # Internal subroutine.
@@ -22,9 +23,12 @@ AS_IF([grep 'LJ_TARGET_X64 ' conftest.i >/dev/null 2>&1],
       [grep 'LJ_TARGET_ARM ' conftest.i >/dev/null 2>&1],
         [LJARCH=arm],
       [grep 'LJ_TARGET_ARM64 ' conftest.i >/dev/null 2>&1],
-        [LJARCH=arm64
+        [LJARCH=arm64 
          AS_IF([test "x$LJHOST" = xiOS],
-               [LUAJIT_CFLAGS='-fno-omit-frame-pointer'])],
+               [LUAJIT_CFLAGS='-fno-omit-frame-pointer'])
+         AS_IF([grep '__AARCH64EB__' conftest.i >/dev/null 2>&1],
+                 [echo '-D__AARCH64EB__=1' >>native_flags])
+        ],
       [grep 'LJ_TARGET_PPC ' conftest.i >/dev/null 2>&1],
         [LJARCH=ppc
          AS_IF([grep 'LJ_LE 1' conftest.i >/dev/null 2>&1],
@@ -43,6 +47,9 @@ AS_IF([grep 'LJ_NO_UNWIND 1' conftest.i >/dev/null 2>&1],
         [echo '-D NO_UNWIND' >>dynasm_flags
          echo '-DLUAJIT_NO_UNWIND' >>native_flags])
 echo "-DLUAJIT_TARGET=LUAJIT_ARCH_$LJARCH" >>native_flags
+AS_IF([grep 'LJ_LE' conftest.i >/dev/null 2>&1],
+       [echo '-D ENDIAN_LE' >>dynasm_flags],
+       [echo '-D ENDIAN_BE' >>dynasm_flags])
 AS_IF([grep 'LJ_ARCH_BITS 64' conftest.i >/dev/null 2>&1],
         [echo '-D P64' >>dynasm_flags
          AS_IF([test "x$LJHOST" = xLinux],
-- 
GitLab