Skip to content

Commit 61e201a

Browse files
kailun-qinkolyshkin
authored andcommitted
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 <[email protected]>
1 parent 1f5f237 commit 61e201a

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ endif
2323
GO_BUILD := $(GO) build -trimpath $(GO_BUILDMODE) $(EXTRA_FLAGS) -tags "$(BUILDTAGS)" \
2424
-ldflags "-X main.gitCommit=$(COMMIT) -X main.version=$(VERSION) $(EXTRA_LDFLAGS)"
2525
GO_BUILD_STATIC := CGO_ENABLED=1 $(GO) build -trimpath $(EXTRA_FLAGS) -tags "$(BUILDTAGS) netgo osusergo" \
26-
-ldflags "-w -extldflags -static -X main.gitCommit=$(COMMIT) -X main.version=$(VERSION) $(EXTRA_LDFLAGS)"
26+
-ldflags "-extldflags -static -X main.gitCommit=$(COMMIT) -X main.version=$(VERSION) $(EXTRA_LDFLAGS)"
2727

2828
.DEFAULT: runc
2929

script/release.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ function build_project() {
3333
local libseccomp_ver='2.5.1'
3434
local tarball="libseccomp-${libseccomp_ver}.tar.gz"
3535
local prefix
36+
local ldflags="-w -s"
3637
prefix="$(mktemp -d)"
3738
wget "https://github.com/seccomp/libseccomp/releases/download/v${libseccomp_ver}/${tarball}"{,.asc}
3839
tar xf "$tarball"
@@ -46,8 +47,9 @@ function build_project() {
4647
# Add -a to go build flags to make sure it links against
4748
# the provided libseccomp, not the system one (otherwise
4849
# it can reuse cached pkg-config results).
49-
make -C "$root" PKG_CONFIG_PATH="${prefix}/lib/pkgconfig" COMMIT_NO= EXTRA_FLAGS="-a" static
50+
make -C "$root" PKG_CONFIG_PATH="${prefix}/lib/pkgconfig" COMMIT_NO= EXTRA_FLAGS="-a" EXTRA_LDFLAGS="${ldflags}" static
5051
rm -rf "$prefix"
52+
strip "$root/$project"
5153
mv "$root/$project" "$1"
5254
}
5355

0 commit comments

Comments
 (0)