Skip to content

Commit 092811a

Browse files
adammwjoshfrench
authored andcommitted
Add GCFLAGS
1 parent d224304 commit 092811a

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,11 @@ COPY ./ ./
4141
ARG package=.
4242
ARG ARCH
4343
ARG LDFLAGS
44+
ARG GCFLAGS
4445
RUN --mount=type=cache,target=/root/.cache/go-build \
4546
--mount=type=cache,target=/go/pkg/mod \
4647
--mount=type=cache,target=/root/.local/share/golang \
47-
CGO_ENABLED=0 GOOS=linux GOARCH=${ARCH} go build -ldflags "${LDFLAGS} -extldflags '-static'" -o manager ${package}
48+
CGO_ENABLED=0 GOOS=linux GOARCH=${ARCH} go build -gcflags "${GCFLAGS}" -ldflags "${LDFLAGS} -extldflags '-static'" -o manager ${package}
4849
ENTRYPOINT [ "/start.sh", "/workspace/manager" ]
4950

5051
# Copy the controller-manager into a thin image

Makefile

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,9 @@ RBAC_ROOT ?= $(MANIFEST_ROOT)/rbac
137137
# Allow overriding the imagePullPolicy
138138
PULL_POLICY ?= Always
139139

140+
# Allow overriding the GCFLAGS
141+
GCFLAGS ?=
142+
140143
# Set build time variables including version details
141144
LDFLAGS := $(shell source ./hack/version.sh; version::ldflags)
142145

@@ -387,12 +390,12 @@ binaries: managers clusterawsadm ## Builds and installs all binaries
387390

388391
.PHONY: clusterawsadm
389392
clusterawsadm: ## Build clusterawsadm binary
390-
go build -ldflags "$(LDFLAGS)" -o $(BIN_DIR)/clusterawsadm ./cmd/clusterawsadm
393+
go build -gcflags "$(GCFLAGS)" -ldflags "$(LDFLAGS)" -o $(BIN_DIR)/clusterawsadm ./cmd/clusterawsadm
391394

392395

393396
.PHONY: docker-build
394397
docker-build: docker-pull-prerequisites ## Build the docker image for controller-manager
395-
docker build --build-arg ARCH=$(ARCH) --build-arg builder_image=$(GO_CONTAINER_IMAGE) --build-arg LDFLAGS="$(LDFLAGS)" . -t $(CORE_CONTROLLER_IMG)-$(ARCH):$(TAG)
398+
docker build --build-arg ARCH=$(ARCH) --build-arg builder_image=$(GO_CONTAINER_IMAGE) --build-arg GCFLAGS="$(GCFLAGS)" --build-arg LDFLAGS="$(LDFLAGS)" . -t $(CORE_CONTROLLER_IMG)-$(ARCH):$(TAG)
396399

397400
.PHONY: docker-build-all ## Build all the architecture docker images
398401
docker-build-all: $(addprefix docker-build-,$(ALL_ARCH))
@@ -411,7 +414,7 @@ managers: ## Alias for manager-aws-infrastructure
411414

412415
.PHONY: manager-aws-infrastructure
413416
manager-aws-infrastructure: ## Build manager binary
414-
CGO_ENABLED=0 GOARCH=${ARCH} go build -ldflags "${LDFLAGS} -extldflags '-static'" -o $(BIN_DIR)/manager .
417+
CGO_ENABLED=0 GOARCH=${ARCH} go build -gcflags "${GCFLAGS}" -ldflags "${LDFLAGS} -extldflags '-static'" -o $(BIN_DIR)/manager .
415418

416419
##@ test:
417420

0 commit comments

Comments
 (0)