Skip to content

Zig ld undefined reference to symbol 'dyld_stub_binder' #15437

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

Closed
Tengs-Fan opened this issue Apr 24, 2023 · 2 comments · Fixed by #16553
Closed

Zig ld undefined reference to symbol 'dyld_stub_binder' #15437

Tengs-Fan opened this issue Apr 24, 2023 · 2 comments · Fixed by #16553
Assignees
Labels
bug Observed behavior contradicts documented or intended behavior linking os-macos
Milestone

Comments

@Tengs-Fan
Copy link

Tengs-Fan commented Apr 24, 2023

Zig Version

0.10.1

Mac system Version

> uname -a
Darwin Tengs-MacBook-Air.local 22.4.0 Darwin Kernel Version 22.4.0: Mon Mar  6 21:00:41 PST 2023; root:xnu-8796.101.5~3/RELEASE_ARM64_T8103 arm64

Steps to Reproduce and Observed Behavior

on a Mac system, we have a print.c file

#include <stdio.h>
#include <stdlib.h>

int main() {
  printf("test\n");
}

if we compile it with zig cc

>  zig cc ./print.c   
MachO Flush... 
zig ld -dynamic -syslibroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk /Users/tengs/.cache/zig/o/a282a2b2f004d1a6c4095183135c31bc/print.o /Users/tengs/.cache/zig/o/bf53f4d720ea68b15d14cc2ce86370af/libcompiler_rt.a -o a.out -lSystem -lc -L/usr/lib -F/System/Library/Frameworks
error(link): undefined reference to symbol 'dyld_stub_binder'
error: UndefinedSymbolReference

the problem lies in zig ld, because if we compile print.o and link it with the system provided ld with the parameters untouched

ld -dynamic -syslibroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk print.o /Users/tengs/.cache/zig/o/bf53f4d720ea68b15d14cc2ce86370af/libcompiler_rt.a -o a.out -lSystem -lc -L/usr/lib -F/System/Library/Frameworks

it just work

Expected Behavior

zig ld should work as system provided ld and as it on my Linux system

@Tengs-Fan Tengs-Fan added the bug Observed behavior contradicts documented or intended behavior label Apr 24, 2023
@Tengs-Fan
Copy link
Author

some related issues
#11896
#3575

@andrewrk
Copy link
Member

cc @kubkon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Observed behavior contradicts documented or intended behavior linking os-macos
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants