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"
/Applications/Xcode.app/Contents/Developer/usr/bin/make -C src
LINK luajit
ld: warning: Linking with PIE, -image_base will be ignored
ld: warning: ignoring file luajit.o, building for macOS-arm64 but attempting
to link with file built for unknown-x86_64
ld: warning: ignoring file libluajit.a, building for macOS-arm64 but
attempting to link with file built for macOS-x86_64
Undefined symbols for architecture arm64:
"_main", referenced from:
implicit entry/start for main executable
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see
invocation)
make[1]: *** [luajit] Error 1
make: *** [default] Error 2
Essentially, everything passes until the very end where it attempts to link
the binary. No arm64 main is found (as expected) so it dies.
I’m wondering a few things:
Is there something I’m missing to compile for x86 on my arm64 machine for OSX?
If not, is there a way to run make, such that I only build the libraries, and
not the binary? I have confirmed that the library is built as expected in the
correct arch, so linking the binary is unnecessary for me.
Really appreciate the help. I have been trying different combos of the cross
build opts [2] with no luck.
Thanks,
Chris
[1]
https://developer.apple.com/documentation/apple-silicon/building-a-universal-macos-binary
[2] https://luajit.org/install.html