michaeleisel/zld

Xcode 14 beta. Can not Not link _objc_msgSend

Closed this issue · 12 comments

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

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

Perhaps I'll just make that the default for now

keith commented

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

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

keith commented

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

👋, is there any progress regarding this issue? 👀

keith commented

Sorry to be clear I started working on this for LLD, tracked here llvm/llvm-project#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

i may just turn that flag on by default

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

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

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

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