Release statically linked protoc for Linux #5904
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was some interest in a statically linked protoc in #5053. Statically linked binaries can prevent loader issues when running protoc such as in the linked issues while making the build process simpler, as not as much care has to be taken in using dependencies outside of system dependencies. This means that modern OS distributions can be used to build protoc instead of intentionally using an old one to link to old versions of libc.
Pros of static link
Cons of static link
I didn't see any strong objection to statically linking in #5053 and it seemed to get closed since the immediate issue at hand was solved. But as we've seen with
libatomic
, these issues will continue to crop up as long as the binaries are dynamically linked. Hopefully this PR makes sense - if there is a reason to avoid statically linking though, feel free to close it. Merging and using it will fix thelibatomic
issue though :) The best part of it, IMO, is that the same process is used to build all the targets - currently, aarch64 and ppc64 are built on the Kokoro debian host and others built in a CentOS docker container. This discrepancy doesn't seem intuitive or ideal. I suspect thelibatomic
release issues happened in the first place since developers use debian, which includeslibatomic
automatically when installing a build chain, and not centos.Changes
--static
toLDFLAGS
on linux, ensuring resulting binary is not a dynamic executableTesting
I ran all builds using the changed
Dockerfile
using something likeAll the built binaries ran fine. The aarch / ppcle ones I think have the qemu runtime layer statically linked in, but the binaries seem to not be much larger as a result so hopefully this is fine.
Fixes #5875