Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LuaJIT could actually be multi-arch somewhat easily #2

Closed
awilfox opened this issue Feb 4, 2024 · 5 comments
Closed

LuaJIT could actually be multi-arch somewhat easily #2

awilfox opened this issue Feb 4, 2024 · 5 comments

Comments

@awilfox
Copy link

awilfox commented Feb 4, 2024

As far as I know there's no way to build luajit as a universal binary since it includes hand crafted assembly.

But, maybe we could include an x86 and am64 version of luajit and detect which interpreter to call in the shebang startup script…

Apple have some documentation on this very subject. Just build the different versions you want, and then combine them using the lipo command.

Hope this info helps you!

@CosmicToast
Copy link

Just to test, I did a quick build, and it seems to work fine (though I have no way to test the darwin-x86 version in the universal build, I did run the binary via rosetta).
To make things a little easier...

To cross-compile the x86 variant:
MACOSX_DEPLOYMENT_TARGET=14 make HOST_CC='clang -target arm64-apple-macos14' STATIC_CC='clang -target x86_64-apple-macos14' DYNAMIC_CC='clang -target x86_64-apple-macos14 -fPIC' TARGET_LD='clang -target x86_64-apple-macos14' TARGET_AR='ar -r'

Then simply lipo -create -output luajit-universal luajit-x86_64 luajit-arm64 as per the abovementioned docs (presuming you have luajit-x86_64 and luajit-arm64).

Here's an example build:
luajit.zip

@mogenson
Copy link
Owner

mogenson commented Feb 4, 2024

Thanks, I'll give it a try!

@mogenson
Copy link
Owner

mogenson commented Feb 4, 2024

Tested out your build instructions and tried the app on an M1 and Intel macbook. They both work! I updated the committed app with a universal luajit binary and added your build instructions to the readme. Thanks!

@mogenson mogenson closed this as completed Feb 4, 2024
@CosmicToast
Copy link

Just to note, the conclusion still needs updating.

@mogenson
Copy link
Owner

mogenson commented Feb 5, 2024

D'oh! Thanks. I added a note about both of you in an acknowledgements section. I hope you don't mind.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants