michaeleisel / zld

A faster version of Apple's linker
MIT License
1.19k stars 50 forks source link

Xcode 14 beta. Can not Not link _objc_msgSend #113

Closed william52328 closed 2 years ago

william52328 commented 2 years ago

I compiled my project with Xcode14 beta and found that the.a static library could not link to its own library symbols。

Example Like This: Undefined symbols for architecture arm64: "_objc_msgSend$setOffsetFromCenter:", referenced from: +[SVProgressHUD setOffsetFromCenter:] in libSVProgressHUD.a(SVProgressHUD.o) +[SVProgressHUD resetOffsetFromCenter] in libSVProgressHUD.a(SVProgressHUD.o) "_objc_msgSend$unreachableBlock", referenced from: -[Reachability reachabilityChanged:] in libReachability.a(Reachability.o)

SetOffsetFromCenter is a symbol in the SVProgressHUD library, but cannot be linked using ZLD。

keith commented 2 years ago

You can pass -fno-objc-msgsend-selector-stubs to your compiles to avoid this

michaeleisel commented 2 years ago

Perhaps I'll just make that the default for now

keith commented 2 years ago

You have to do that to clang for each object compile, not ld unfortunately

michaeleisel commented 2 years ago

Do you know if lld has a plan for fixing this?

keith commented 2 years ago

I started looking at it this morning, not sure how far i'll get

aleksandergrzyb commented 2 years ago

👋, is there any progress regarding this issue? 👀

keith commented 2 years ago

Sorry to be clear I started working on this for LLD, tracked here https://github.com/llvm/llvm-project/issues/56034, for zld to get this it would either require @michaeleisel to implement it entirely, or apple to update their open source dump of ld64 and zld rebase on it. I would suggest disabling it with -fno-objc-msgsend-selector-stubs in the meantime

michaeleisel commented 2 years ago

i may just turn that flag on by default

michaeleisel commented 2 years ago

oh wait, right, it's a clang flag, not an ld one

PhilCai1993 commented 2 years ago

I noticed that even if you put -fno-objc-msgsend-selector-stubs for all clang invocations, if -miphoneos-version-min=8.0 is presented in the linker command, the _objc_msgSend issue will happen too.

The linker passes after changing the flag to -miphoneos-version-min=10.0

michaeleisel commented 2 years ago

so, my plan is that i will not be fixing this bug. instead, i will detect when it occurs, and in the error message tell the user either to add the -fno-objc-msgsend-selector-stubs flag to their compilations, or else switch to lld. i am working with the lld people to make user-friendly lld install docs to send people to

michaeleisel commented 2 years ago

1.3.6 has a better error message for this, including a link to the new mach-o lld docs