Skip to content

Commit d962bb0

Browse files
committed
merge branch 'pr-3099'
Kir Kolyshkin (1): script/release.sh: make builds reproducible Kailun Qin (1): makefile: update ldflags and add strip for static builds LGTMs: AkihiroSuda cyphar Closes opencontainers#3099
2 parents 1f5f237 + 18f434e commit d962bb0

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-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: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,17 @@ function build_project() {
4343
)
4444
mv "$tarball"{,.asc} "$builddir"
4545

46+
# For reproducible builds, add these to EXTRA_LDFLAGS:
47+
# -w to disable DWARF generation;
48+
# -s to disable symbol table;
49+
# -buildid= to remove variable build id.
50+
local ldflags="-w -s -buildid="
4651
# Add -a to go build flags to make sure it links against
4752
# the provided libseccomp, not the system one (otherwise
4853
# it can reuse cached pkg-config results).
49-
make -C "$root" PKG_CONFIG_PATH="${prefix}/lib/pkgconfig" COMMIT_NO= EXTRA_FLAGS="-a" static
54+
make -C "$root" PKG_CONFIG_PATH="${prefix}/lib/pkgconfig" COMMIT_NO= EXTRA_FLAGS="-a" EXTRA_LDFLAGS="${ldflags}" static
5055
rm -rf "$prefix"
56+
strip "$root/$project"
5157
mv "$root/$project" "$1"
5258
}
5359

0 commit comments

Comments
 (0)