Skip to content

Conversation

@xnox
Copy link

@xnox xnox commented Dec 5, 2025

When listeners.go APIs are not used by a given application, golang
doesn't automatically optimize them out. Add an opt-out build tag to
activation/listeners.go, such that one can build an application that
uses activation files without the listeners APIs.

For applications that do not already include any "crypto/tls" this can
be highly beneficial, for example runc can reduce it's total binary
size by 7.6%.

runc project already uses go mod vendor, and can just delete the listeners.go file:

But it would be preffered if this opt-out build-tag was available here
upstream for people to use in general.

When listeners.go APIs are not used by a given application, golang
doesn't automatically optimize them out. Add an opt-out build tag to
activation/listeners.go, such that one can build an application that
uses activation files without the listeners APIs.

For applications that do not already include any "crypto/tls" this can
be highly beneficial, for example runc can reduce it's total binary
size by 7.6%.

runc project already uses go mod vendor, and can just delete the listeners.go file:
- opencontainers/runc#5056

But it would be preffered if this opt-out build-tag was available here
upstream for people to use in general.
Copy link
Collaborator

@Luap99 Luap99 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am fine with a build tag, but the listeners_test.go should use the same tag so it doesn't fail with the tag.

And I guess it would be nice to documented that tag in the Readme so all library users are aware.

cc @kolyshkin

// See the License for the specific language governing permissions and
// limitations under the License.

//go:build !no_listeners
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

go build tags are not namespaced so there is always risk that it could conflict when another project uses the same name.

As such I would prefer something more like go_systemd_no_listeners or even coreos_go_systemd_no_listeners

@Luap99
Copy link
Collaborator

Luap99 commented Dec 5, 2025

Looks like something in the fedora CI tests broke, we need to look into that.

Otherwise I guess it would also be nice to add a CI test to make sure the build tag compiles correctly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants