Skip to content

Commit 2123855

Browse files
committed
Add build tag to omit grpc
This is needed so we can build the runc shim without grpc as a transative dependency. With this change the runc shim binary went from 14MB to 11MB. The RSS from an idle shim went from about 17MB to 14MB (back around where it was in in 1.7). Signed-off-by: Brian Goff <[email protected]>
1 parent 64d29eb commit 2123855

File tree

38 files changed

+170
-197
lines changed

38 files changed

+170
-197
lines changed

Makefile

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,8 @@ GOTEST ?= $(GO) test
150150
OUTPUTDIR = $(join $(ROOTDIR), _output)
151151
CRIDIR=$(OUTPUTDIR)/cri
152152

153+
SHIM_GO_TAGS := --tags no_grpc
154+
153155
.PHONY: clean all AUTHORS build binaries test integration generate protos check-protos coverage ci check help install uninstall vendor release static-release mandir install-man install-doc genman install-cri-deps cri-release cri-cni-release cri-integration install-deps bin/cri-integration.test remove-replace clean-vendor
154156
.DEFAULT: default
155157

@@ -171,7 +173,7 @@ generate: protos
171173
@echo "$(WHALE) $@"
172174
@PATH="${ROOTDIR}/bin:${PATH}" $(GO) generate -x ${PACKAGES}
173175

174-
protos: bin/protoc-gen-go-fieldpath
176+
protos: bin/protoc-gen-go-fieldpath bin/go-buildtag
175177
@echo "$(WHALE) $@"
176178
@find . -path ./vendor -prune -false -o -name '*.pb.go' | xargs rm
177179
$(eval TMPDIR := $(shell mktemp -d))
@@ -181,6 +183,7 @@ protos: bin/protoc-gen-go-fieldpath
181183
@rm -rf ${TMPDIR} v2
182184
go-fix-acronym -w -a '^Os' $(shell find api/ -name '*.pb.go')
183185
go-fix-acronym -w -a '(Id|Io|Uuid|Os)$$' $(shell find api/ -name '*.pb.go')
186+
bin/go-buildtag -w --tags '!no_grpc' $(shell find api/ -name '*_grpc.pb.go')
184187
@test -z "$$(git status --short | grep "api/next.pb.txt" | tee /dev/stderr)" || \
185188
$(GO) mod edit -replace=github.com/containerd/containerd/api=./api
186189

@@ -230,7 +233,7 @@ cri-integration: binaries bin/cri-integration.test ## run cri integration tests
230233
# build runc shimv2 with failpoint control, only used by integration test
231234
bin/containerd-shim-runc-fp-v1: integration/failpoint/cmd/containerd-shim-runc-fp-v1 FORCE
232235
@echo "$(WHALE) $@"
233-
@CGO_ENABLED=${SHIM_CGO_ENABLED} $(GO) build ${GO_BUILD_FLAGS} -o $@ ${SHIM_GO_LDFLAGS} ${GO_TAGS} ./integration/failpoint/cmd/containerd-shim-runc-fp-v1
236+
@CGO_ENABLED=${SHIM_CGO_ENABLED} $(GO) build ${GO_BUILD_FLAGS} -o $@ ${SHIM_GO_LDFLAGS} ${GO_TAGS} ${SHIM_GO_TAGS} ./integration/failpoint/cmd/containerd-shim-runc-fp-v1
234237

235238
# build CNI bridge plugin wrapper with failpoint support, only used by integration test
236239
bin/cni-bridge-fp: integration/failpoint/cmd/cni-bridge-fp FORCE
@@ -264,7 +267,7 @@ bin/gen-manpages: cmd/gen-manpages FORCE
264267

265268
bin/containerd-shim-runc-v2: cmd/containerd-shim-runc-v2 FORCE # set !cgo and omit pie for a static shim build: https://github.com/golang/go/issues/17789#issuecomment-258542220
266269
@echo "$(WHALE) $@"
267-
@CGO_ENABLED=${SHIM_CGO_ENABLED} $(GO) build ${GO_BUILD_FLAGS} -o $@ ${SHIM_GO_LDFLAGS} ${GO_TAGS} ./cmd/containerd-shim-runc-v2
270+
CGO_ENABLED=${SHIM_CGO_ENABLED} $(GO) build ${GO_BUILD_FLAGS} -o $@ ${SHIM_GO_LDFLAGS} ${GO_TAGS} ${SHIM_GO_TAGS} ./cmd/containerd-shim-runc-v2
268271

269272
binaries: $(BINARIES) ## build binaries
270273
@echo "$(WHALE) $@"

api/runtime/sandbox/v1/sandbox_grpc.pb.go

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/runtime/task/v3/shim_grpc.pb.go

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/services/containers/v1/containers_grpc.pb.go

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/services/content/v1/content_grpc.pb.go

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/services/diff/v1/diff_grpc.pb.go

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/services/events/v1/events_grpc.pb.go

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/services/images/v1/images_grpc.pb.go

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/services/introspection/v1/introspection_grpc.pb.go

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/services/leases/v1/leases_grpc.pb.go

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)