luajit2 icon indicating copy to clipboard operation
luajit2 copied to clipboard

need ppc64le support

Open edmondsw opened this issue 5 years ago • 3 comments

There is a PR to add ppc64le support but it has been sitting without review for a long time. Please review and merge this. Thanks!

https://github.com/openresty/luajit2/pull/77

edmondsw avatar Apr 22 '20 14:04 edmondsw

yeah, we'll look into it. Thanks for the reminder.

agentzh avatar Apr 22 '20 19:04 agentzh

@agentzh I have responded to your queries on https://github.com/openresty/luajit2/pull/77 , could you please have a look ? Thank you!

seth-priya avatar Apr 28 '20 16:04 seth-priya

@agentzh what's the current state with ppc64 support in LuaJIT2?

The recent code (v2.1-20190507-206-gfe08842) fails to build on ppc64le without the following patch:

diff --git a/src/lib_jit.c b/src/lib_jit.c
index e60ccac..1bf67a7 100644
--- a/src/lib_jit.c
+++ b/src/lib_jit.c
@@ -150,10 +150,10 @@ LJLIB_CF(jit_attach)
 
 LJLIB_CF(jit_prngstate)
 {
+  int i;
   GCtab *cur = lj_tab_new(L, 8, 0);
 
 #if LJ_HASJIT
-  int i;
   jit_State *J = L2J(L);
 
   /* The old state. */
@@ -201,7 +201,7 @@ LJLIB_CF(jit_prngstate)
     J->prng = prng;
   }
 #else
-  for (int i = 1; i <= 8; i++)
+  for (i = 1; i <= 8; i++)
     setintV(lj_tab_setint(L, cur, i), 0);
 #endif
   settabV(L, L->top++, cur);
diff --git a/src/lj_ccallback.c b/src/lj_ccallback.c
index 3dbf1e9..aaf3934 100644
--- a/src/lj_ccallback.c
+++ b/src/lj_ccallback.c
@@ -226,7 +226,7 @@ static void *callback_mcode_init(global_State *g, uint32_t *page)
   MSize slot;
 #if LJ_ARCH_PPC_ELFV2
   // Needs to be in sync with lj_vm_ffi_callback.
-  lua_assert(CALLBACK_MCODE_SIZE == 4096);
+  lj_assertG(CALLBACK_MCODE_SIZE == 4096);
   for (slot = 0; slot < CALLBACK_MAX_SLOT; slot++) {
     *p = PPCI_B | (((page+CALLBACK_MAX_SLOT-p) & 0x00ffffffu) << 2);
     p++;

But even when it builds without issues, luajit fails to start occasionally:

-bash-4.2$ luajit
LuaJIT 2.1.0-beta3 -- Copyright (C) 2005-2021 Mike Pall. https://luajit.org/
JIT: OFF
> 
-bash-4.2$ luajit
luajit: cannot create state: not enough memory
-bash-4.2$ luajit
LuaJIT 2.1.0-beta3 -- Copyright (C) 2005-2021 Mike Pall. https://luajit.org/
JIT: OFF
> 
-bash-4.2$ luajit
luajit: cannot create state: not enough memory
-bash-4.2$ luajit
LuaJIT 2.1.0-beta3 -- Copyright (C) 2005-2021 Mike Pall. https://luajit.org/
JIT: OFF
> 
-bash-4.2$ luajit
luajit: cannot create state: not enough memory

Plenty of memory available though:

-bash-4.2$ head -3 /proc/meminfo 
MemTotal:       33504576 kB
MemFree:        27553024 kB
MemAvailable:   30952256 kB

(ipcs also doesn't show anything meaningful)

Target system is RHEL 7.4 (Linux 3.10.0-693.21.1.el7.ppc64le), gcc 4.8.5 20150623 (Red Hat 4.8.5-16).

defanator avatar Mar 11 '21 14:03 defanator