mold
mold copied to clipboard
Allow shlib undefined attempt 2
This PR reverts 33494650fad94111e612a19295762aaf011f37c7 and implements the missing functionality required to fix #559 (also closes #526).
I also checked this bug out and it looks like the current behavior is the same as gold's and lld's.
Sorry for the belated response. I was thinking carefully as to what this patch is doing. My understanding is that in order to implement --allow-shlib-undefined properly, we need to resolve all transitive dependencies between shared libraries. So we need to handle $ORIGIN.
But I don't think that's still enough, because we don't really know what are the DSO search paths at runtime. The option doesn't seem useful in practice and too complicated.
So I think we should just ignore them. But that's what we are currently doing -- so I think we need to go back to the original issue to see why the original bug reporter wanted this option in the first place.
Sorry for the belated response.
No worries at all! I actually had some time to implement the remaining pieces.
My understanding is that in order to implement --allow-shlib-undefined properly, we need to resolve all transitive dependencies between shared libraries. So we need to handle $ORIGIN.
Yes, actually gold and lld only look at immediate dependencies, while bfd-ld goes to great lengths to check if all indirect dependencies satisfy the condition.
because we don't really know what are the DSO search paths at runtime
That was actually something I've started wondering about while implementing RPATH vs RUNPATH: we don't really know what LD_LIBRARY_PATH and friends will be set to at runtime...
I think we need to go back to the original issue to see why the original bug reporter wanted this option in the first place.
That's a great idea. I'll keep an eye on the issue and decide what to do with the PR afterwards -- I'll leave it up until then.
Closing for now. If you want to add support for this in the future, I will be more than happy to help out!