If %t1.o has a weak reference, %t2.so has a non-weak reference.
ld.lld %t1.o %t2.so -o %t
The reference in %t should be weak.
This fixes an (-z defs) error when linking libLLVMCore.so with lld after D63974.
ld.lld: error: undefined symbol: pthread_once, but is currently non-weak because we
fail to ignore the reference from a shared object. Fix this by checking
if Other.File is from a SharedFile.
libstdc++ std::call_once creates a weak reference of pthread_once.This fixes the binding of pthread_once when the program links against
This is its hack to avoid a dependency onboth librt.so and libpthread.so
* Object files withlibstdc++ std::call_once calls have suchreates a weak referencese of pthread_once.
* libLLVMSupport.so.9svn has a non-weak reference that changes theThis is its hack to avoid a dependency on libpthread.so
binding. It should be ignored instead.
(TheObject files with std::call_once calls have such weak reference should be weaks.
When these objects, but due to the very bug, the binding islibrt.so and libpthread.so are linked together,
non-weak because librt.so has a non-the final binding should be weak reference).
When these objects and libLLVMSupport.so.9svn are linked together to. It is currently non-weak because
create a shared object (note there is no -lpthread),librt.so has a non-weak reference. the final bindingThe reference from librt.so should be
will be non-weak and an "undefined symbol" error will be issuedignored in this case.
We happened to workcreate a weak undef before D63974 because libgcc_s.so.1 was linked the
was linked the last and it changed the binding again to weak.