Answering my own question, as I had a breakthrough!
Changing the CFLAGS and LDFLAGS to be “TARGET_” fixed it 😊
make amalg 'MACOSX_DEPLOYMENT_TARGET=11.0' 'TARGET_CFLAGS=-arch arm64
-DLUAJIT_ENABLE_GC64 -DLUAJIT_ENABLE_LUA52COMPAT' 'TARGET_LDFLAGS=-arch arm64'
'-j' '10' 'HOST_CC=clang' 'CROSS='
Hope this helps someone else in the future.
From: Chris Apple <chrisa@xxxxxxxxxxxxxx>
Date: Sunday, March 19, 2023 at 4:47 PM
To: luajit@xxxxxxxxxxxxx <luajit@xxxxxxxxxxxxx>
Subject: Re: Building universal libraries (x86_64 and arm64) for osx
How about in the reverse direction? Building arm64 from an intel machine?
The issue I’m seeing here is very similar, but in this case the intel machine
CANNOT run the arm code, while the arm code technically can run the x86 code
via rosetta
% make amalg 'MACOSX_DEPLOYMENT_TARGET=11.0' 'CFLAGS=-arch arm64
-DLUAJIT_ENABLE_GC64 -DLUAJIT_ENABLE_LUA52COMPAT' 'LDFLAGS=-arch arm64' '-j'
'10' 'HOST_CC=clang' 'CROSS='
Building LuaJIT 2.1.0-beta3
/Library/Developer/CommandLineTools/usr/bin/make -C src amalg
+--------------------------------------------------------------------------+
| WARNING: Compiling the
amalgamation needs a lot of virtual memory |
| (around 300 MB with GCC 4.x)! If you don't have enough physical memory |
| your machine will start swapping to disk and the compile will not finish |
| within a reasonable amount of time. |
| So either compile on a bigger machine or use the non-amalgamated build. |
+--------------------------------------------------------------------------+
/Library/Developer/CommandLineTools/usr/bin/make all "LJCORE_O=ljamalg.o"
DYNASM host/buildvm_arch.h
make[2]: host/minilua: Bad CPU type in executable
make[2]: *** [host/buildvm_arch.h] Error 1
make[1]: *** [amalg] Error 2
make: *** [amalg] Error 2
From: Chris Apple <chrisa@xxxxxxxxxxxxxx>
Date: Sunday, March 19, 2023 at 1:32 PM
To: luajit@xxxxxxxxxxxxx <luajit@xxxxxxxxxxxxx>
Subject: Re: Building universal libraries (x86_64 and arm64) for osx
Works perfectly! Thank you so much for your help.
From: luajit-bounce@xxxxxxxxxxxxx <luajit-bounce@xxxxxxxxxxxxx> on behalf of
madigest i <madigest@xxxxxxxxxxxxx>
Date: Sunday, March 19, 2023 at 12:05 PM
To: luajit@xxxxxxxxxxxxx <luajit@xxxxxxxxxxxxx>
Subject: Re: Building universal libraries (x86_64 and arm64) for osx
Hello.
I'm using:
export MACOSX_DEPLOYMENT_TARGET=10.14
make clean
LDFLAGS="-arch x86_64" CFLAGS="-arch x86_64 -DLUAJIT_ENABLE_LUA52COMPAT" make
amalg
- stuta
On 19. Mar 2023, at 18.03, Chris Apple <chrisa@xxxxxxxxxxxxxx> wrote:
Hi,
I’m attempting to build a universal or “fat” library for luajit for osx. This
process is described in detail here [1]. The sparknotes is “build a binary with
arch x86_64, then build a binary with arch arm64, then glue them together using
the lipo tool”.
In attempting to do so with luajit, I try to build on my arm64 machine with the
command:
make CFLAGS="-DLUAJIT_ENABLE_GC64 -DLUAJIT_ENABLE_LUA52COMPAT"==== Building LuaJIT 2.1.0-beta3 ====
TARGET_CFLAGS="-arch x86_64"