-
-
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
zig ld: support LTO #8680
Comments
Potentially related #8552 |
I wanted to verify this but it's probably that wanting to link with a c file makes the zip compilation unit compile with LTO, and so the .o file is a llvm ir and not a 'normal' object file. |
Correct, |
not sure if it is related but I noticed a similar error when using on an Intel Mac:
and on a M1 Mac:
|
@wojtekmach actually, your issue is related to #8317. |
@wojtekmach when linking natively on arm64, you could fallback to the system linker for the time being btw until |
I tried that too but I'm unfortunately getting the same error:
|
oh I'm sorry, I was cross-compiling from a x64 host. linker hack works from the arm64 host. Thanks and sorry for the noise! |
@kubkon I saw in #8317 that some zig ld preliminary work landed so just in case I gave it another shot here but I see the same result. I was wondering if this problem will be solved by this issue, #8317, or some other one. Just wondering which issue I should track is all :) In any case, thank you and the team for the work on this, I'm really keen on using Zig for this use case in particular. And again sorry for hijacking this issue!
|
not sure what changed but
still can't cross-compile from an x86_64 host though.
|
I have now renamed this issue to better reflect the root issue, namely, lack of support for LTO in |
@kubkon - I think I managed to hit the same error without (to my knowledge) having LTO enabled. Here is the smalest reproduction case I could come up with:
The same reproduction steps seem to work when using the MacOS system linker instead:
Finally, the same reproduction steps also seem to work when targeting
For context, I understand that the reproduction case is a bit "weird" on its own as putting the
Source: https://google.github.io/googletest/primer.html#writing-the-main-function I am not an expert in the C/C++ world so it is very possible that the two issues are completely unrelated. However, my searches in Google and GitHub issues kept bringing me here so I thought I would share it in case it is relevant and/or you can provide guidance/advice. |
That's unrelated to LTO. The error happens because |
@alloveras issue extracted into #15103. Thanks for filing it! |
Thanks to you for the super fast response and for extracting it into a separate issue 🙇 |
Try to resolve error: error: LTO is not yet supported with the Mach-O object format. More details: ziglang/zig#8680 Error: execution of an external compiler program 'zigcc -c -w -ferror-limit=3 -pthread -target aarch64-macos-none -flto -Os -I/home/runner/work/configlet/configlet/nimdir/lib -I/home/runner/work/configlet/configlet/src -o /home/runner/.cache/nim/configlet_r/@m..@snimdir@slib@ssystem@sctypes.nim.c.o /home/runner/.cache/nim/configlet_r/@m..@snimdir@slib@ssystem@sctypes.nim.c' failed with exit code: 1
This reverts commit d0e67f6. It produced the error: error: LTO is not yet supported with the Mach-O object format. More details: ziglang/zig#8680
It is currently not supported by zig. See ziglang/zig#8680
It is currently not supported by zig. See ziglang/zig#8680
It is currently not supported by zig. See ziglang/zig#8680
It is currently not supported by zig. See ziglang/zig#8680
It is currently not supported by zig. See ziglang/zig#8680
main.zig:
--> ok.
--> error: MissingMainEntrypoint
--> ok
The text was updated successfully, but these errors were encountered: