-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
release: build riscv64 binary, build static PIE if supported #3446
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
d542ad6
Dockerfile: nit
kolyshkin 476aa18
Dockerfile: rm dpkg --add-architecture lines
kolyshkin f0f1b5f
Dockerfile: don't use crossbuild-essential-*
kolyshkin f2f6e59
Makefile: add LDFLAGS_COMMON and LDFLAGS_STATIC
kolyshkin ab5c60d
Makefile: fix GO_BUILDMODE setting
kolyshkin 21e32d4
Makefile: add support for static PIE
kolyshkin dafcacb
Makefile: set CGO_ENABLED=1 when needed
kolyshkin 1d7b297
libct/seccomp: add riscv64
AkihiroSuda a14cc40
release: add riscv64 binary
kolyshkin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,23 +10,51 @@ GIT_BRANCH_CLEAN := $(shell echo $(GIT_BRANCH) | sed -e "s/[^[:alnum:]]/-/g") | |
RUNC_IMAGE := runc_dev$(if $(GIT_BRANCH_CLEAN),:$(GIT_BRANCH_CLEAN)) | ||
PROJECT := github.com/opencontainers/runc | ||
BUILDTAGS ?= seccomp | ||
|
||
COMMIT ?= $(shell git describe --dirty --long --always) | ||
VERSION := $(shell cat ./VERSION) | ||
LDFLAGS_COMMON := -X main.gitCommit=$(COMMIT) -X main.version=$(VERSION) | ||
|
||
GOARCH := $(shell $(GO) env GOARCH) | ||
|
||
ifeq ($(shell $(GO) env GOOS),linux) | ||
ifeq (,$(filter $(shell $(GO) env GOARCH),mips mipsle mips64 mips64le ppc64)) | ||
ifeq (,$(findstring -race,$(EXTRA_FLAGS))) | ||
GO_BUILDMODE := "-buildmode=pie" | ||
endif | ||
GO_BUILDMODE := | ||
# Enable dynamic PIE executables on supported platforms. | ||
ifneq (,$(filter $(GOARCH),386 amd64 arm arm64 ppc64le riscv64 s390x)) | ||
ifeq (,$(findstring -race,$(EXTRA_FLAGS))) | ||
GO_BUILDMODE := "-buildmode=pie" | ||
endif | ||
endif | ||
GO_BUILD := $(GO) build -trimpath $(GO_BUILDMODE) \ | ||
$(EXTRA_FLAGS) -tags "$(BUILDTAGS)" \ | ||
-ldflags "$(LDFLAGS_COMMON) $(EXTRA_LDFLAGS)" | ||
|
||
GO_BUILDMODE_STATIC := | ||
LDFLAGS_STATIC := -extldflags -static | ||
# Enable static PIE executables on supported platforms. | ||
# This (among the other things) requires libc support (rcrt1.o), which seems | ||
# to be available only for arm64 and amd64 (Debian Bullseye). | ||
ifneq (,$(filter $(GOARCH),arm64 amd64)) | ||
ifeq (,$(findstring -race,$(EXTRA_FLAGS))) | ||
GO_BUILDMODE_STATIC := -buildmode=pie | ||
LDFLAGS_STATIC := -linkmode external -extldflags --static-pie | ||
endif | ||
endif | ||
GO_BUILD := $(GO) build -trimpath $(GO_BUILDMODE) $(EXTRA_FLAGS) -tags "$(BUILDTAGS)" \ | ||
-ldflags "-X main.gitCommit=$(COMMIT) -X main.version=$(VERSION) $(EXTRA_LDFLAGS)" | ||
GO_BUILD_STATIC := CGO_ENABLED=1 $(GO) build -trimpath $(EXTRA_FLAGS) -tags "$(BUILDTAGS) netgo osusergo" \ | ||
-ldflags "-extldflags -static -X main.gitCommit=$(COMMIT) -X main.version=$(VERSION) $(EXTRA_LDFLAGS)" | ||
# Enable static PIE binaries on supported platforms. | ||
GO_BUILD_STATIC := $(GO) build -trimpath $(GO_BUILDMODE_STATIC) \ | ||
$(EXTRA_FLAGS) -tags "$(BUILDTAGS) netgo osusergo" \ | ||
-ldflags "$(LDFLAGS_COMMON) $(LDFLAGS_STATIC) $(EXTRA_LDFLAGS)" | ||
|
||
GPG_KEYID ?= [email protected] | ||
|
||
# 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: | ||
|
@@ -40,7 +68,7 @@ recvtty sd-helper seccompagent: | |
static: | ||
$(GO_BUILD_STATIC) -o runc . | ||
|
||
releaseall: RELEASE_ARGS := "-a arm64 -a armel -a armhf -a ppc64le -a s390x" | ||
releaseall: RELEASE_ARGS := "-a arm64 -a armel -a armhf -a ppc64le -a riscv64 -a s390x" | ||
releaseall: release | ||
|
||
release: runcimage | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
afaik
-buildmode=pie
is not supported only on windows arm64 and linux mips*, ppc64be. should work on riscv64. see https://github.com/golang/go/blob/4aa1efed4853ea067d665a952eee77c52faac774/src/cmd/internal/sys/supported.go#L125-L131There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, this is a list of supported platforms. Meaning, we do enable
-buildmode=pie
forriscv64
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See commit description at ab5c60d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@crazy-max PTAL ^^^