-
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: ABI hash of a shared library changes if any inlineable function changes #23405
Comments
/cc @mwhudson |
We don't have any mechanism for preventing inlining of a package that is put into a shared library. The problem is that inlining is done by the compiler, but determination of which packages will be pulled from a shared library is determined by the linker. Any fix we make here would have to address that somehow. |
Related to #21510. |
As I said in point 1 above, when the compiler is invoked with -dynlink, it can omit the inlineable functions from a package's export data. This will ensure that any other package the imports it will not be able to inline its functions. I do realize that this will hurt the performance of multi-package shared libraries, but multi-package shared libraries are not common outside of libstd.so, and we could try to come up with a special case for the latter. |
That doesn't sound precisely right. |
You're right, I made a mistake when I said |
Taking a look at this issue again, we found that merely moving code in a package and inserting blank lines would change the export data, because the export data records file names and line numbers for all exported functions (even ones that are not inlineable). This seems unnecessarily restrictive. |
Obsoleted by #47788 |
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (
go version
)?Tip.
Does this issue reproduce with the latest release?
Yes.
What operating system and processor architecture are you using (
go env
)?linux_amd64
What did you do?
You can reproduce this easily with the makefile in my example:
https://github.com/bryanpkc/pkgdef-example
What did you expect to see?
Correct execution of the main executable.
What did you see instead?
Proposed solution
The ABI hash of a shared library (or Go plugin) is computed as a SHA1 sum of the package hashes of all packages included in the shared library, which are in turn computed from the export data of the packages (i.e. the contents of __.PKGDEF in the corresponding package archives). Currently the export data of a package includes the ASTs of all inlineable exported functions in the package. Doing this allows cross-package inlining in the usual static compilation scenario, but also makes the ABI hashes of shared libraries unnecessarily unstable.
This can be fixed by:
The text was updated successfully, but these errors were encountered: