-
-
Notifications
You must be signed in to change notification settings - Fork 8
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
Luax compile on M1 detects arch incorrectly for Zig. #1
Comments
After overcoming this, I found that ZIG doesn't compile any further on this architecture due to LTO issues. 11 fails with the error: 12-dev fails with the error The offer for the PR is still open, I can't build luax at the moment due to the above issue. I began looking at the build.lua however at the moment it is above my skills. Thanks again. |
I've no mac to test luax so it would be great if you can submit a pull request (I guess a quick fix in LTO is disabled for mac binaries but not for temporary tools (such as lua). So this works on Linux to cross compile for mac but not on mac. I can disable LTO for these tools (no effect on the luax binaries, only the execution of the tests using a plain lua interpreter may take a few more milliseconds (no difference on my Linux PC)). |
I've disabled LTO (for |
Tried it on 11 and 12, getting similiar errors. info: zig can provide libc for related target aarch64-macos.11-none `[2/673] CC ext/c/lz4/lib/lz4.c [3/673] CC ext/c/lz4/lib/lz4hc.c [4/673] CC ext/c/lz4/lib/lz4file.c [5/673] CC ext/c/lz4/lib/lz4frame.c [6/673] CC ext/c/lz4/lib/xxhash.c [7/673] CC ext/c/lz4/programs/bench.c I'll try again (its late/early here) maybe i'll be able to understand a bit more when i'm more awake. |
Ok got past those errors, the LIBC has to be set to none in the tools/build_env.sh for mac os.. now a new error...
However the file .build/tmp/luax_config.lua does exist and has contents.. working on that now. |
The |
The OSX stat doesn't support -c, I had to use 'gstat' which is coreutils port renamed to gstat.
For completion, the contents are:
|
When i run the command by hand, and i know it exists: It still throws the error:
This is the current tree : |
ok, so Can you also confirm that |
I updated build_env.sh but not sys.lua |
I installed gstat via brew.. is that part of the problem ? stat that ships with OSX is the second command above
|
no, the problem is that |
Needed an additional patch to tools/build_env.sh See https://github.com/wmealing/luax/blob/dev/tools/build_env.sh#L39 The check for the LIBC. Otherwise the build fails with the comment in #1 (comment) Now with the patch and the build:
./luax from here is :
However it crashes on execution.
Thanks for taking the time on this, i know how hard this kind of debugging is. |
Do you have the same problem with the executable I've cross-compiled from Linux? |
Same problem:
I had thought it might be some executable protection on OSX, but i have no evidence to back that up. |
This seems to work though: bash-3.2$ ./aarch64-macos-none/bin/luax-lua |
If So if |
Ah, that'll do it then, i need to go afk for a while. I will test any further suggestions you have overnight. |
I'm afraid |
To validate the hypothesis, can you run this test?
#include <stdio.h>
int main(int argc, char *argv[])
{
printf("executable: %s\n", argv[0]);
char buf[1024*1024];
FILE *f = fopen(argv[0], "rb");
size_t n = fread(&buf, 1, sizeof(buf), f);
fclose(f);
printf("size : %zu\n", n);
} Compiling and running this program prints this on Linux:
(should also work with Do you get a segmentation fault on macos? |
I'm testing a simplified design for LuaX:
This is in the e.g.:
|
➜ ~ gcc readmyself.c -o readmyself && ./readmyself Oddly no crash. ➜ ~ clang readmyself.c -o readmyself && ./readmyself No segmentation faults on either. |
I followed your above steps in the luax3 branch.
|
Thanks for the test on macos! |
The |
Was able to build master. It looks as though not all of the LTO fixes were pulled into master branch. There was something funky going on. When I would try to build :
I traced (or think i did) this down to build.lua
Now when i run
The luax binary is built and works.
|
i realise the fix probably wont be in this location, because you likely want flto in clang on non osx systems. |
It looks like you are running the ninja file for Linux ( Did you run |
|
I'll close this issue. Feel free to reopen it if necessary. The master branch should now have everything to compile LuaX on MacOS. |
Tried doing an install on the M1 macs, which detect uname -m as an arm64 instead of the arch that zig uses download uses (aarch64).
Do you want me to submit a pull request with the fix ?
The text was updated successfully, but these errors were encountered: