mirror of
https://github.com/opencontainers/runc.git
synced 2026-07-11 06:03:57 +08:00
Makefile: set CGO_ENABLED=1 when needed
It doesn't matter whether static or dynamic linking is used, runc always needs libcontainer/nsenter, which is written in C and thus requires cgo. Same is true for libcontainer/integration. In addition, contrib/pkg/seccompagent also needs cgo (if seccomp build tag is set), as it need to be linked against libseccomp C library. By default, cgo is disabled when cross-compiling, meaning that CGO_ENABLED=1 has to be set explicitly in such cases. In all other cases (e.g. other contrib binaries) we do not need cgo. Remove CGO_ENABLED=1 from GO_BUILD_STATIC (as it does not have anything to do with static linking), and add it to all targets that require it. Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This commit is contained in:
@@ -126,5 +126,4 @@ jobs:
|
|||||||
go-version: 1.x # Latest stable
|
go-version: 1.x # Latest stable
|
||||||
|
|
||||||
- name: unit test
|
- name: unit test
|
||||||
# cgo is disabled by default when cross-compiling
|
run: sudo -E PATH="$PATH" -- make GOARCH=386 localunittest
|
||||||
run: sudo -E PATH="$PATH" -- make GOARCH=386 CGO_ENABLED=1 localunittest
|
|
||||||
|
|||||||
@@ -40,12 +40,21 @@ ifneq (,$(filter $(GOARCH),arm64 amd64))
|
|||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
# Enable static PIE binaries on supported platforms.
|
# 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" \
|
$(EXTRA_FLAGS) -tags "$(BUILDTAGS) netgo osusergo" \
|
||||||
-ldflags "$(LDFLAGS_COMMON) $(LDFLAGS_STATIC) $(EXTRA_LDFLAGS)"
|
-ldflags "$(LDFLAGS_COMMON) $(LDFLAGS_STATIC) $(EXTRA_LDFLAGS)"
|
||||||
|
|
||||||
GPG_KEYID ?= asarai@suse.de
|
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
|
.DEFAULT: runc
|
||||||
|
|
||||||
runc:
|
runc:
|
||||||
|
|||||||
Reference in New Issue
Block a user