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/go: optimize CGO caching and dead code removal #38886
Comments
One C file is generated for each Go file that uses |
Related #9887 Currently, I think we cache the generated We should have a separate action for each |
Note that proper caching of C object files require detecting whether any included .h files change. This does arise when people update to a newer version of some C dependency. |
Good point. We should be incorporating hashes of included .h files into the cache keys for compiled .a files at least. I don't believe we currently are. |
Maybe we could only run the C compiler when the package is actually being compiled in order to get the values of C constants and make sure C functions are called properly. |
We run the C linker, rather than using only the Go linker, because the Go linker doesn't support C++ global constructors or C++ exception handling or a few other cases that the C linker handles. We could support those things in the Go linker, but it's not trivial. |
I'm writing this with the assumption that each CGO-generated wrapper for each C function is stored in its own C file.
Editing and compiling a CGO package can take a minute or 2, even for one little change.
It should be possible to cache the generated .o files and only recompile them if the code for that function changes.
When linking the CGO wrappers, Go should avoid linking unused wrappers to reduce size.
The text was updated successfully, but these errors were encountered: