-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
panic: index out of bounds in link.MachO.ZldAtom.resolveRelocsArm64 #14559
Comments
@kubkon would you mind taking a look at this? It is reported against 0.10.1 but I believe the issue may still be present in master branch. @winterqt is working on packaging zig 0.10.1 for nixpkgs and has run into this problem. It would behoove us and our users if we could provide a workaround patch for nixpkgs to carry to resolve this issue until they can update to 0.11.0. |
This comment was marked as resolved.
This comment was marked as resolved.
Sure, but I need more than just a panic stack trace :-) Are there any steps I could follow to even try and repro the issue locally? Otherwise, it's not much to go on sadly. |
Here's my hunch at what is happening. Packaging for nixpgks generates an object file with a funky looking symtab which is then packaged into archive and put on the linker link as per #14558. This manifests itself as an alignment panic, which if circumvented (downgraded to |
(Oops, apologies for accidentally closing the issue!) |
@kubkon You can reproduce this by installing Nix, cloning Nixpkgs, and running If you'd rather not install Nix, let me know -- I have a machine I can give you access to that has it installed. If there's anything that you need further clarification on, let me know, and thank you both for helping us out. |
Nice, thank you so much for the repro! I'll get right on it! |
Is there any trick into getting nix to find the includes? I am getting this currently:
Perhaps an env var I need to set or something? |
Hmm, I haven't run into that. What modifications did you make, if any, or is this a clean tree? Also, just to be sure, this is on aarch64, and not x86_64, right? |
A clean tree on |
Hm, my hunch without being able to look at anything else at the moment would be to try and enable the sandbox (though I have no idea why this would be the case, it really shouldn't do anything). Can you add That would be the only difference between our machines... 😕 and if that is the issue, then we have a problem on our hands. If that doesn't fix it, I can try to repro, though I have no clue how I'd even begin doing that (since I never ran into this). |
Thanks, that was it! Woohoo, got a repro! |
@winterqt just to keep you in the loop, fixed it today. Will now clean it up, submit a PR, and afterwards, will submit a patch against 0.10.1 to nixpkgs. This should make 0.10.1 available in nix on darwin before 0.11 release. |
I will also make sure that nix is capable of building |
@kubkon Thanks, much appreciated. I can confirm that master works fine already. I guess something about the WASI bootstrap makes this issue not occur, as it fails before the merge, but succeeds afterwards. Weird, but who knows. |
Well, it was a genuine bug on my part as I made certain assumptions about the compiler behaviour I shouldn't have (i.e., assumptions about the relocations order in the object file in case you are interested). |
Also, thanks for confirming master works. Btw, I have noticed we don't pass either |
We also don't pass this in our 0.9.1 derivation (which works fine on macOS and Linux). Should we be doing that for both 0.9.1 and 0.10.1 even if it just happens to work? (Why would it work without it... luck?) If you think this is the case, feel free to do it in a separate commit in your PR. |
Detecting this at runtime by Zig has been a recent change (0.10 onwards) and yes, if it was working so far then it was luck in the way |
Relevant upstream issue: ziglang/zig#14559 The patch is a backport of fixes that landed in zig-master and can be removed with zig-0.11 release. Additionally, make sure we link statically against LLVM to avoid unpleasant runtime surprises originating from mixing static and dynamic LLVM libraries. Finally, unbreak Zig 0.10.1 on macOS.
Zig Version
0.10.1
Steps to Reproduce and Observed Behavior
After fixing the
@alignCast
issue in #14558, stage3 fails to build on aarch64-darwin with a different error:Expected Behavior
For it to link correctly :)
The text was updated successfully, but these errors were encountered: