-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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
cmd/link: libraries are not resolved with cgo_import_dynamic #39257
Comments
Why is your code using a |
If you want to shell out |
@ianlancetaylor @cherrymui - the back story is that I'm working on issue #36435, which means using If I use I can workaround the issue by using |
On GNU/Linux systems the SONAME of libc never changes, exactly to avoid the kinds of problems you mention. It's always |
@ianlancetaylor - no, this is not the case on OpenBSD. The |
Ah, well. That is what symbol versioning is for. I guess OpenBSD systems have lots of different .so files, one for each soname? If we need to support this for internal linking, then I think we'll need to use a special string in the Or, we could require external linking on OpenBSD, which would not be so bad. |
Change https://golang.org/cl/249978 mentions this issue: |
On Go -tip (bcda684), building the following two files:
Results in a DT_NEEDED entry being created for
libc.so
, rather thanlibc.so
being resolved to the current available library version (with major/minor included), as is done by a typical linker. This leads to various issues - under Linux (ubuntu/focal) runningldd
on the binary (or attempting to execute the binary) results in:This is due to the fact that
/usr/lib/x86_64-linux-gnu/libc.so
is a linker script containing:Under both Linux and OpenBSD, we end up with what are effectively duplicate DT_NEEDED entries:
This results in warnings/failures, at least on OpenBSD, as it attempts to load the library twice, triggering initialisation that cannot be repeated.
The issue can be worked around by specifying the full library version in the
cgo_import_dynamic
statement, however this then means that the source has to be updated each time a library major or minor version bump occurs.The fix is likely to either implement an equivalent of ld(1)'s library resolution or somehow extracting this information from ld(1) (which I suspect would be the better option).
The text was updated successfully, but these errors were encountered: