Compiled for OSX PPC

  • From: D B <buckyballreaction@xxxxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Fri, 19 Dec 2014 09:26:23 -0700

Hi,

I'd just like to share my success in compiling LuaJIT 2.0.3 on OSX
PPC.  Note that I did a cross-compile from OSX 10.6 using the 10.5 SDK
(my goal is to get an application with 10.4 PPC compatibility to run).

The resultant 'luajit' executable works fine under Rosetta and can run
Lua code, but my application that is linked to the static lib crashes.
I suspect that's just because I'm running too many emulation layers...
or, more likely, that there's a memory error somewhere (I am using the
C API heavily, but there's no issue on x86 or x86_64).

Anyways, to get to it compile, I did the following:

1. Apply the attached patch, luajit-osx_ppc.diff.  This fixes two problems:
   a. Allow compiling with older GCC (4.2 in my case)
   b. Fix 'Invalid Mnemonic' errors when compiling with ASM symbols
ending with '@plt'.  I'm somewhat ignorant of ASM programming, but I
read somewhere that the '@plt' is used for Linux ELF creation only.

2.  Run 'make' with the following options:
   CC="gcc-4.2 -arch ppc -mmacosx-version-min=10.4 -isysroot
/Developer/SDKs/MacOSX10.5.sdk/" make amalg

Just FYI:  The OSX 10.4 SDK with gcc-4.0 almost compiled but failed at
linking with missing symbols: __floatundidf, __floatundisf.  The
shared library was compiled (but linked to libgcc_s) but not the
static library.  Switching to the 10.5 SDK fixed this.

Now I just need to test my binary on a PPC native machine to determine
if it is Rosetta to blame for the crashes.  Then perhaps I'll try the
dynamic lib next, if that fails...

Thanks for LuaJIT!
David
diff -r e96b630d33e3 lua/luajit/src/host/buildvm.c
--- a/lua/luajit/src/host/buildvm.c     Sat Dec 13 23:45:04 2014 -0700
+++ b/lua/luajit/src/host/buildvm.c     Fri Dec 19 09:00:55 2014 -0700
@@ -113,7 +113,7 @@
       name[0] = '@';
     else
       *p = '\0';
-#elif (LJ_TARGET_PPC  || LJ_TARGET_PPCSPE) && !LJ_TARGET_CONSOLE
+#elif ((LJ_TARGET_PPC && !LJ_TARGET_OSX) || LJ_TARGET_PPCSPE) && 
!LJ_TARGET_CONSOLE
     /* Keep @plt. */
 #else
     *p = '\0';
diff -r e96b630d33e3 lua/luajit/src/lj_arch.h
--- a/lua/luajit/src/lj_arch.h  Sat Dec 13 23:45:04 2014 -0700
+++ b/lua/luajit/src/lj_arch.h  Fri Dec 19 09:00:55 2014 -0700
@@ -297,7 +297,7 @@
 #if (__GNUC__ < 4) || ((__GNUC__ == 4) && __GNUC_MINOR__ < 2)
 #error "Need at least GCC 4.2 or newer"
 #endif
-#elif !LJ_TARGET_PS3
+#elif !LJ_TARGET_PS3 && !LJ_TARGET_PPC
 #if (__GNUC__ < 4) || ((__GNUC__ == 4) && __GNUC_MINOR__ < 3)
 #error "Need at least GCC 4.3 or newer"
 #endif

Other related posts:

  • » Compiled for OSX PPC - D B