Skip to content

Commit

Permalink
Remove ldflags -s -w from release build
Browse files Browse the repository at this point in the history
  • Loading branch information
hjiawei committed Apr 20, 2022
1 parent a05f0f3 commit 159103b
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 22 deletions.
2 changes: 1 addition & 1 deletion api/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ bin/list-gnp: examples/list-gnp/main.go
@echo Building list-gnp example binary...
mkdir -p bin
$(DOCKER_RUN) $(CALICO_BUILD) sh -c '$(GIT_CONFIG_SSH) \
go build -v -o $@ -v $(LDFLAGS) "examples/list-gnp/main.go"'
go build -v -o $@ "examples/list-gnp/main.go"'

WHAT?=.
GINKGO_FOCUS?=.*
Expand Down
17 changes: 2 additions & 15 deletions apiserver/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,6 @@ VERSION_FLAGS = -X $(PACKAGE_NAME)/cmd/apiserver/server.VERSION=$(APISERVER_VERS
-X $(PACKAGE_NAME)/cmd/apiserver/server.GIT_DESCRIPTION=$(APISERVER_GIT_DESCRIPTION) \
-X $(PACKAGE_NAME)/cmd/apiserver/server.GIT_REVISION=$(APISERVER_GIT_REVISION)

BUILD_LDFLAGS = -ldflags "$(VERSION_FLAGS)"
RELEASE_LDFLAGS = -ldflags "$(VERSION_FLAGS) -w"

##############################################################################
# Download and include ../lib.Makefile before anything else
# Additions to EXTRA_DOCKER_ARGS need to happen before the include since
Expand Down Expand Up @@ -92,23 +89,13 @@ cd: image-all cd-common
# "apiserver" instead of "$(BINDIR)/apiserver".
#########################################################################
$(BINDIR)/apiserver-$(ARCH): $(K8SAPISERVER_GO_FILES)
ifndef RELEASE_BUILD
$(eval LDFLAGS:=$(RELEASE_LDFLAGS))
else
$(eval LDFLAGS:=$(BUILD_LDFLAGS))
endif
mkdir -p $(BINDIR)
$(DOCKER_RUN) -e CGO_ENABLED=$(CGO_ENABLED) $(CALICO_BUILD) \
sh -c '$(GIT_CONFIG_SSH) go build -v -o $@ -v $(LDFLAGS) $(PACKAGE_NAME)/cmd/apiserver'
sh -c '$(GIT_CONFIG_SSH) go build -v -o $@ -ldflags "$(VERSION_FLAGS)" $(PACKAGE_NAME)/cmd/apiserver'

$(BINDIR)/filecheck-$(ARCH): $(K8SAPISERVER_GO_FILES)
ifndef RELEASE_BUILD
$(eval LDFLAGS:=$(RELEASE_LDFLAGS))
else
$(eval LDFLAGS:=$(BUILD_LDFLAGS))
endif
$(DOCKER_RUN) -e CGO_ENABLED=$(CGO_ENABLED) $(CALICO_BUILD) \
sh -c '$(GIT_CONFIG_SSH) go build -v -o $@ -v $(LDFLAGS) $(PACKAGE_NAME)/cmd/filecheck'
sh -c '$(GIT_CONFIG_SSH) go build -v -o $@ -ldflags "$(VERSION_FLAGS)" $(PACKAGE_NAME)/cmd/filecheck'

###############################################################################
# Building the image
Expand Down
4 changes: 2 additions & 2 deletions app-policy/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ bin/dikastes-%: protobuf $(SRC_FILES)
$(DOCKER_RUN_RO) \
-e CGO_ENABLED=$(CGO_ENABLED) \
-v $(CURDIR)/bin:/go/src/$(PACKAGE_NAME)/bin \
$(CALICO_BUILD) go build $(BUILD_FLAGS) -ldflags "-X main.VERSION=$(GIT_VERSION) -w" -v -o bin/dikastes-$(ARCH) ./cmd/dikastes
$(CALICO_BUILD) go build $(BUILD_FLAGS) -ldflags "-X main.VERSION=$(GIT_VERSION)" -v -o bin/dikastes-$(ARCH) ./cmd/dikastes

bin/healthz-amd64: ARCH=amd64
bin/healthz-arm64: ARCH=arm64
Expand All @@ -94,7 +94,7 @@ bin/healthz-%: protobuf $(SRC_FILES)
$(DOCKER_RUN_RO) \
-e CGO_ENABLED=$(CGO_ENABLED) \
-v $(CURDIR)/bin:/go/src/$(PACKAGE_NAME)/bin \
$(CALICO_BUILD) go build $(BUILD_FLAGS) -ldflags "-X main.VERSION=$(GIT_VERSION) -s -w" -v -o bin/healthz-$(ARCH) ./cmd/healthz
$(CALICO_BUILD) go build $(BUILD_FLAGS) -ldflags "-X main.VERSION=$(GIT_VERSION)" -v -o bin/healthz-$(ARCH) ./cmd/healthz

# We use gogofast for protobuf compilation. Regular gogo is incompatible with
# gRPC, since gRPC uses golang/protobuf for marshalling/unmarshalling in that
Expand Down
2 changes: 1 addition & 1 deletion calicoctl/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ CALICOCTL_GIT_REVISION?=$(shell git rev-parse --short HEAD)

LDFLAGS=-ldflags "-X $(PACKAGE_NAME)/calicoctl/commands.VERSION=$(GIT_VERSION) \
-X $(PACKAGE_NAME)/calicoctl/commands.GIT_REVISION=$(CALICOCTL_GIT_REVISION) \
-X $(PACKAGE_NAME)/calicoctl/commands/common.VERSION=$(GIT_VERSION) -s -w"
-X $(PACKAGE_NAME)/calicoctl/commands/common.VERSION=$(GIT_VERSION)"

.PHONY: clean
## Clean enough that a new release build will be clean
Expand Down
6 changes: 3 additions & 3 deletions cni-plugin/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ $(BIN)/install binary: $(SRC_FILES)
-mkdir -p .go-pkg-cache
-mkdir -p $(BIN)
$(DOCKER_RUN) -e CGO_ENABLED=$(CGO_ENABLED) $(CALICO_BUILD) sh -c '\
$(GIT_CONFIG_SSH) go build -v -o $(BIN)/install -ldflags "-X main.VERSION=$(GIT_VERSION) -w" $(PACKAGE_NAME)/cmd/calico && \
$(GIT_CONFIG_SSH) go build -v -o $(BIN)/install -ldflags "-X main.VERSION=$(GIT_VERSION)" $(PACKAGE_NAME)/cmd/calico && \
$(CHECK_BORINGSSL)'

## Build the Calico network plugin and ipam plugins for Windows
Expand All @@ -98,8 +98,8 @@ $(BIN_WIN)/calico.exe $(BIN_WIN)/calico-ipam.exe: $(SRC_FILES)
-e GOOS=windows \
-e CGO_ENABLED=1 \
$(CALICO_BUILD) sh -c '$(GIT_CONFIG_SSH) \
go build -v -o $(BIN_WIN)/calico.exe -ldflags "-X main.VERSION=$(GIT_VERSION) -s -w" $(PACKAGE_NAME)/cmd/calico && \
go build -v -o $(BIN_WIN)/calico-ipam.exe -ldflags "-X main.VERSION=$(GIT_VERSION) -s -w" $(PACKAGE_NAME)/cmd/calico'
go build -v -o $(BIN_WIN)/calico.exe -ldflags "-X main.VERSION=$(GIT_VERSION)" $(PACKAGE_NAME)/cmd/calico && \
go build -v -o $(BIN_WIN)/calico-ipam.exe -ldflags "-X main.VERSION=$(GIT_VERSION)" $(PACKAGE_NAME)/cmd/calico'


###############################################################################
Expand Down

0 comments on commit 159103b

Please sign in to comment.