mirror of
https://github.com/opencontainers/runc.git
synced 2026-07-11 06:03:57 +08:00
makefile: update ldflags and add strip for static builds
This patch * drops the default `-w` flag for `make static`, which helps with debugging the static runc binary; * adds `EXTRA_LDFLAGS="-w -s"` to `script/release.sh` to disable DWARF generation and symbol table for the release runc binary; * adds strip in `script/release.sh` for a further size-optimized release runc binary. Signed-off-by: Kailun Qin <kailun.qin@intel.com>
This commit is contained in:
committed by
Kir Kolyshkin
parent
1f5f237b37
commit
61e201abb2
@@ -23,7 +23,7 @@ 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 "-w -extldflags -static -X main.gitCommit=$(COMMIT) -X main.version=$(VERSION) $(EXTRA_LDFLAGS)"
|
||||
-ldflags "-extldflags -static -X main.gitCommit=$(COMMIT) -X main.version=$(VERSION) $(EXTRA_LDFLAGS)"
|
||||
|
||||
.DEFAULT: runc
|
||||
|
||||
|
||||
+3
-1
@@ -33,6 +33,7 @@ function build_project() {
|
||||
local libseccomp_ver='2.5.1'
|
||||
local tarball="libseccomp-${libseccomp_ver}.tar.gz"
|
||||
local prefix
|
||||
local ldflags="-w -s"
|
||||
prefix="$(mktemp -d)"
|
||||
wget "https://github.com/seccomp/libseccomp/releases/download/v${libseccomp_ver}/${tarball}"{,.asc}
|
||||
tar xf "$tarball"
|
||||
@@ -46,8 +47,9 @@ function build_project() {
|
||||
# Add -a to go build flags to make sure it links against
|
||||
# the provided libseccomp, not the system one (otherwise
|
||||
# it can reuse cached pkg-config results).
|
||||
make -C "$root" PKG_CONFIG_PATH="${prefix}/lib/pkgconfig" COMMIT_NO= EXTRA_FLAGS="-a" static
|
||||
make -C "$root" PKG_CONFIG_PATH="${prefix}/lib/pkgconfig" COMMIT_NO= EXTRA_FLAGS="-a" EXTRA_LDFLAGS="${ldflags}" static
|
||||
rm -rf "$prefix"
|
||||
strip "$root/$project"
|
||||
mv "$root/$project" "$1"
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user