Skip to content

Commit 3bb9f76

Browse files
add -buildmode=pie flags for go binary builds
1 parent c22c6b0 commit 3bb9f76

File tree

6 files changed

+6
-2
lines changed

6 files changed

+6
-2
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ ifeq (, $(shell command -v ocb 2>/dev/null))
4040
[ "$${machine}" != x86_64 ] || machine=amd64 ;\
4141
echo "Installing ocb ($${os}/$${machine}) at $(OTELCOL_BUILDER_DIR)";\
4242
mkdir -p $(OTELCOL_BUILDER_DIR) ;\
43-
CGO_ENABLED=0 go install -trimpath -ldflags="-s -w" go.opentelemetry.io/collector/cmd/builder@v$(OTELCOL_BUILDER_VERSION) ;\
43+
CGO_ENABLED=0 go install -trimpath -ldflags="-s -w" -buildmode=pie go.opentelemetry.io/collector/cmd/builder@v$(OTELCOL_BUILDER_VERSION) ;\
4444
mv $$(go env GOPATH)/bin/builder $(OTELCOL_BUILDER) ;\
4545
}
4646
else

cmd/goreleaser/internal/configure.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ func Build(dist string) config.Build {
7373
Binary: dist,
7474
BuildDetails: config.BuildDetails{
7575
Env: []string{"CGO_ENABLED=0"},
76-
Flags: []string{"-trimpath"},
76+
Flags: []string{"-trimpath", "-buildmode=pie"},
7777
Ldflags: []string{"-s", "-w"},
7878
},
7979
Goos: []string{"darwin", "linux", "windows"},

distributions/otelcol-contrib/.goreleaser.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ builds:
4646
- -w
4747
flags:
4848
- -trimpath
49+
- -buildmode=pie
4950
env:
5051
- CGO_ENABLED=0
5152
archives:

distributions/otelcol-k8s/.goreleaser.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ builds:
2222
- -w
2323
flags:
2424
- -trimpath
25+
- -buildmode=pie
2526
env:
2627
- CGO_ENABLED=0
2728
archives:

distributions/otelcol-otlp/.goreleaser.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ builds:
4545
- -w
4646
flags:
4747
- -trimpath
48+
- -buildmode=pie
4849
env:
4950
- CGO_ENABLED=0
5051
archives:

distributions/otelcol/.goreleaser.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ builds:
4646
- -w
4747
flags:
4848
- -trimpath
49+
- -buildmode=pie
4950
env:
5051
- CGO_ENABLED=0
5152
archives:

0 commit comments

Comments
 (0)