Merge pull request #1783 from crosbymichael/static-shim
Compile shim without cgo for size and mem usage
This commit is contained in:
commit
95cbe81247
7
Makefile
7
Makefile
@ -41,7 +41,8 @@ COMMANDS=ctr containerd containerd-stress containerd-release
|
|||||||
BINARIES=$(addprefix bin/,$(COMMANDS))
|
BINARIES=$(addprefix bin/,$(COMMANDS))
|
||||||
|
|
||||||
GO_TAGS=$(if $(BUILDTAGS),-tags "$(BUILDTAGS)",)
|
GO_TAGS=$(if $(BUILDTAGS),-tags "$(BUILDTAGS)",)
|
||||||
GO_LDFLAGS=-ldflags "-s -w -X $(PKG)/version.Version=$(VERSION) -X $(PKG)/version.Revision=$(REVISION) -X $(PKG)/version.Package=$(PKG) $(EXTRA_LDFLAGS)"
|
GO_LDFLAGS=-ldflags '-s -w -X $(PKG)/version.Version=$(VERSION) -X $(PKG)/version.Revision=$(REVISION) -X $(PKG)/version.Package=$(PKG) $(EXTRA_LDFLAGS)'
|
||||||
|
SHIM_GO_LDFLAGS=-ldflags '-s -w -X $(PKG)/version.Version=$(VERSION) -X $(PKG)/version.Revision=$(REVISION) -X $(PKG)/version.Package=$(PKG) -extldflags "-static"'
|
||||||
|
|
||||||
TESTFLAGS_RACE=
|
TESTFLAGS_RACE=
|
||||||
GO_GCFLAGS=
|
GO_GCFLAGS=
|
||||||
@ -142,6 +143,10 @@ bin/%: cmd/% FORCE
|
|||||||
@echo "$(WHALE) $@${BINARY_SUFFIX}"
|
@echo "$(WHALE) $@${BINARY_SUFFIX}"
|
||||||
@go build -o $@${BINARY_SUFFIX} ${GO_LDFLAGS} ${GO_TAGS} ${GO_GCFLAGS} ./$<
|
@go build -o $@${BINARY_SUFFIX} ${GO_LDFLAGS} ${GO_TAGS} ${GO_GCFLAGS} ./$<
|
||||||
|
|
||||||
|
bin/containerd-shim: cmd/containerd-shim FORCE # set !cgo and omit pie for a static shim build: https://github.com/golang/go/issues/17789#issuecomment-258542220
|
||||||
|
@echo "$(WHALE) bin/containerd-shim"
|
||||||
|
@CGO_ENABLED=0 go build -o bin/containerd-shim ${SHIM_GO_LDFLAGS} ${GO_TAGS} ./cmd/containerd-shim
|
||||||
|
|
||||||
binaries: $(BINARIES) ## build binaries
|
binaries: $(BINARIES) ## build binaries
|
||||||
@echo "$(WHALE) $@"
|
@echo "$(WHALE) $@"
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user