-
Notifications
You must be signed in to change notification settings - Fork 2.2k
makefile: make runc non-PHONY target #4873
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -51,11 +51,16 @@ ifneq (,$(filter $(GOARCH),arm64 amd64)) | |||
LDFLAGS_STATIC := -linkmode external -extldflags -static-pie | ||||
endif | ||||
endif | ||||
# 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)" | ||||
|
||||
# "static" just maps to runc with a different "go build" invocation. This lets | ||||
# us avoid rebuilding if the sources haven't changed -- even with .PHONY. | ||||
.PHONY: static | ||||
static: export GO_BUILD=$(GO_BUILD_STATIC) | ||||
static: runc | ||||
|
||||
GPG_KEYID ?= [email protected] | ||||
|
||||
# Some targets need cgo, which is disabled by default when cross compiling. | ||||
|
@@ -67,14 +72,13 @@ ifneq (,$(filter $(BUILDTAGS),seccomp)) | |||
seccompagent: export CGO_ENABLED=1 | ||||
endif | ||||
|
||||
.DEFAULT: runc | ||||
|
||||
.PHONY: runc | ||||
runc: runc-bin | ||||
GO_SRC := \ | ||||
go.mod go.sum \ | ||||
$(shell find . -type f -name '*.go' -or -name '*.c') | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And Line 25 in d845c4a
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let me cook up some
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @cyphar I'm not convinced we want to stop relying on the compiler for this on every runc compilation. I'm not very familiar with uprobes, how are you attaching them? If you really need the binary to not change, I think something like: It would be great if go provided, like gcc, a feature to list the dependencies in a makefile-style fashion. Or if we can say to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I was wrong though -- the Go compiler doesn't replace the binary if it would be identical (the inode number is unchanged after |
||||
|
||||
.PHONY: runc-bin | ||||
runc-bin: | ||||
$(GO_BUILD) -o runc . | ||||
.DEFAULT: runc | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This So just calling |
||||
runc: $(GO_SRC) | ||||
$(GO_BUILD) -o $@ . | ||||
|
||||
.PHONY: all | ||||
all: runc memfd-bind | ||||
|
@@ -101,13 +105,6 @@ clean: | |||
sudo rm -rf release | ||||
rm -rf man/man8 | ||||
|
||||
.PHONY: static | ||||
static: static-bin | ||||
|
||||
.PHONY: static-bin | ||||
static-bin: | ||||
$(GO_BUILD_STATIC) -o runc . | ||||
|
||||
.PHONY: releaseall | ||||
releaseall: RELEASE_ARGS := "-a 386 -a amd64 -a arm64 -a armel -a armhf -a ppc64le -a riscv64 -a s390x" | ||||
releaseall: release | ||||
|
Uh oh!
There was an error while loading. Please reload this page.
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.
nit: is
export
really needed here? Looks like not, since we don't use sub-make, but maybe I'm missing something.