From b1fd662a6023857bd37b55ff6e19348eb64e762f Mon Sep 17 00:00:00 2001 From: Noah Stride Date: Tue, 4 Mar 2025 23:05:49 +0000 Subject: [PATCH] [v17] Fix CGO-less TBot Build (#52560) * Fix CGOLess tbot build * Remove buildmode=pie for CGO_ENABLED=0 builds --- Makefile | 5 +++-- integrations/teleport-spacelift-runner/Makefile | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 9f52d77899447..3a8cafc604fcf 100644 --- a/Makefile +++ b/Makefile @@ -397,9 +397,10 @@ $(BUILDDIR)/tsh: .PHONY: $(BUILDDIR)/tbot # tbot is CGO-less by default except on Windows because lib/client/terminal/ wants CGO on this OS -$(BUILDDIR)/tbot: TBOT_CGO_FLAGS ?= $(if $(filter windows,$(OS)),$(CGOFLAG)) +# We force cgo to be disabled, else the compiler might decide to enable it. +$(BUILDDIR)/tbot: TBOT_CGO_FLAGS ?= $(if $(filter windows,$(OS)),$(CGOFLAG),CGO_ENABLED=0) # Build mode pie requires CGO -$(BUILDDIR)/tbot: BUILDFLAGS_TBOT += $(if $(TBOT_CGO_FLAGS), -buildmode=pie) +$(BUILDDIR)/tbot: BUILDFLAGS_TBOT += $(if $(findstring CGO_ENABLED=1,$(TBOT_CGO_FLAGS)), -buildmode=pie) $(BUILDDIR)/tbot: GOOS=$(OS) GOARCH=$(ARCH) $(TBOT_CGO_FLAGS) go build -tags "$(FIPS_TAG) $(KUSTOMIZE_NO_DYNAMIC_PLUGIN)" -o $(BUILDDIR)/tbot $(BUILDFLAGS_TBOT) $(TOOLS_LDFLAGS) ./tool/tbot diff --git a/integrations/teleport-spacelift-runner/Makefile b/integrations/teleport-spacelift-runner/Makefile index e5a724afcec3a..3d72cf62c427d 100644 --- a/integrations/teleport-spacelift-runner/Makefile +++ b/integrations/teleport-spacelift-runner/Makefile @@ -14,7 +14,7 @@ include ../../build.assets/images.mk .PHONY: docker-build docker-build: docker buildx build --platform="$(OS)/$(ARCH)" \ - --build-arg BUILDBOX=$(BUILDBOX_CENTOS7) \ + --build-arg BUILDBOX=$(BUILDBOX_CENTOS7_NOARCH) \ --build-arg BASE_IMAGE=$(BASE_IMAGE) \ --load \ -f ./Dockerfile \