diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8ba81bb01..5aae7b7bc 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -126,5 +126,4 @@ jobs: go-version: 1.x # Latest stable - name: unit test - # cgo is disabled by default when cross-compiling - run: sudo -E PATH="$PATH" -- make GOARCH=386 CGO_ENABLED=1 localunittest + run: sudo -E PATH="$PATH" -- make GOARCH=386 localunittest diff --git a/Makefile b/Makefile index a882a3aa1..9c49e5d8f 100644 --- a/Makefile +++ b/Makefile @@ -40,12 +40,21 @@ ifneq (,$(filter $(GOARCH),arm64 amd64)) endif endif # Enable static PIE binaries on supported platforms. -GO_BUILD_STATIC := CGO_ENABLED=1 $(GO) build -trimpath $(GO_BUILDMODE_STATIC) \ +GO_BUILD_STATIC := $(GO) build -trimpath $(GO_BUILDMODE_STATIC) \ $(EXTRA_FLAGS) -tags "$(BUILDTAGS) netgo osusergo" \ -ldflags "$(LDFLAGS_COMMON) $(LDFLAGS_STATIC) $(EXTRA_LDFLAGS)" GPG_KEYID ?= asarai@suse.de +# Some targets need cgo, which is disabled by default when cross compiling. +# Enable cgo explicitly for those. +# Both runc and libcontainer/integration need libcontainer/nsenter. +runc static localunittest: export CGO_ENABLED=1 +# seccompagent needs libseccomp (when seccomp build tag is set). +ifneq (,$(filter $(BUILDTAGS),seccomp)) +seccompagent: export CGO_ENABLED=1 +endif + .DEFAULT: runc runc: