You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
And probably the new linker doesn't know how to deal with it.
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.
And probably the new linker doesn't know how to deal with it.
Correct, zig ld is not advanced enough just yet, but it's defo on the roadmap. Thanks for filing the issue!
not sure if it is related but I noticed a similar error when using zig cc -shared. Targeting x86_64 works perfectly but I'm getting this error for aarch64.
on an Intel Mac:
~% uname -a
Darwin imac.local 20.4.0 Darwin Kernel Version 20.4.0: Thu Apr 22 21:46:47 PDT 2021; root:xnu-7195.101.2~1/RELEASE_X86_64 x86_64
~% cat hello.c
int hello() {
return 0;
}
~% zig cc hello.c -shared
~% zig cc hello.c -shared -target aarch64-macos
error: MissingMainEntrypoint
and on a M1 Mac:
~% uname -a
Darwin m1.local 20.4.0 Darwin Kernel Version 20.4.0: Thu Apr 22 21:46:41 PDT 2021; root:xnu-7195.101.2~1/RELEASE_ARM64_T8101 arm64
~% zig cc hello.c -shared -target x86_64-macos
~% zig cc hello.c -shared
error: MissingMainEntrypoint
@wojtekmach actually, your issue is related to #8317. zig ld is not yet able to link nor produce a shared library and on x64 we fallback to LLD hence why it works on a native host. On arm64, we always use zig ld however hence why the deceptive error message which I should really tweak!
@wojtekmach when linking natively on arm64, you could fallback to the system linker for the time being btw until zig ld gains the missing abilities to link and produce shared libs: see #8728
@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!
~% uname -a
Darwin m1.local 20.4.0 Darwin Kernel Version 20.4.0: Thu Apr 22 21:46:41 PDT 2021; root:xnu-7195.101.2~1/RELEASE_ARM64_T8101 arm64
~% zig version
0.8.0-dev.2305+d228d8605
~% cat hello.c
int hello() {
return 0;
}
~% zig cc hello.c -shared
error: MissingMainEntrypoint
Activity
kubkon commentedon May 5, 2021
Potentially related #8552
xxxbxxx commentedon May 5, 2021
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.
And probably the new linker doesn't know how to deal with it.
kubkon commentedon May 5, 2021
Correct,
zig ldis not advanced enough just yet, but it's defo on the roadmap. Thanks for filing the issue!wojtekmach commentedon May 13, 2021
not sure if it is related but I noticed a similar error when using
zig cc -shared. Targeting x86_64 works perfectly but I'm getting this error for aarch64.on an Intel Mac:
and on a M1 Mac:
kubkon commentedon May 13, 2021
@wojtekmach actually, your issue is related to #8317.
zig ldis not yet able to link nor produce a shared library and on x64 we fallback to LLD hence why it works on a native host. On arm64, we always usezig ldhowever hence why the deceptive error message which I should really tweak!kubkon commentedon May 13, 2021
@wojtekmach when linking natively on arm64, you could fallback to the system linker for the time being btw until
zig ldgains the missing abilities to link and produce shared libs: see #8728wojtekmach commentedon May 13, 2021
I tried that too but I'm unfortunately getting the same error:
wojtekmach commentedon May 13, 2021
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!
wojtekmach commentedon May 20, 2021
@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!
5 remaining items
kubkon commentedon Mar 28, 2023
@alloveras issue extracted into #15103. Thanks for filing it!
alloveras commentedon Mar 28, 2023
Thanks to you for the super fast response and for extracting it into a separate issue 🙇
config: disable LTO for zig + macos
Revert ".github(cross-compile): try enabling -flto on macOS"
Disable LTO for macos
Disable LTO for macos
Disable LTO for macos
Disable LTO for macos
Disable LTO for macos
p7r0x7 commentedon Aug 25, 2025
No love for this issue?
andrewrk commentedon Aug 25, 2025
This is not planned.