@@ -84,7 +84,9 @@ ALLOY_BINARY ?= build/alloy
84
84
SERVICE_BINARY ?= build/alloy-service
85
85
ALLOYLINT_BINARY ?= build/alloylint
86
86
GOOS ?= $(shell go env GOOS)
87
+ GOHOSTOS ?= $(shell go env GOHOSTOS)
87
88
GOARCH ?= $(shell go env GOARCH)
89
+ GOHOSTARCH ?= $(shell go env GOHOSTARCH)
88
90
GOARM ?= $(shell go env GOARM)
89
91
CGO_ENABLED ?= 1
90
92
RELEASE_BUILD ?= 0
@@ -94,7 +96,7 @@ GOEXPERIMENT ?= $(shell go env GOEXPERIMENT)
94
96
# container. USE_CONTAINER must _not_ be included to avoid infinite recursion.
95
97
PROPAGATE_VARS := \
96
98
ALLOY_IMAGE ALLOY_IMAGE_WINDOWS \
97
- BUILD_IMAGE GOOS GOARCH GOARM CGO_ENABLED RELEASE_BUILD \
99
+ BUILD_IMAGE GOOS GOHOSTOS GOARCH GOHOSTARCH GOARM CGO_ENABLED RELEASE_BUILD \
98
100
ALLOY_BINARY \
99
101
VERSION GO_TAGS GOEXPERIMENT
100
102
@@ -114,9 +116,10 @@ GO_LDFLAGS := -X $(VPREFIX).Branch=$(GIT_BRANCH) \
114
116
-X $(VPREFIX ) .BuildUser=$(shell whoami) @$(shell hostname) \
115
117
-X $(VPREFIX ) .BuildDate=$(shell date -u +"% Y-% m-% dT% H:% M:% SZ")
116
118
119
+ GO_BUILTIN_TAGS := beyla_bpf $(GO_TAGS )
117
120
DEFAULT_FLAGS := $(GO_FLAGS )
118
- DEBUG_GO_FLAGS := -ldflags "$(GO_LDFLAGS ) " -tags "$(GO_TAGS ) "
119
- RELEASE_GO_FLAGS := -ldflags "-s -w $(GO_LDFLAGS ) " -tags "$(GO_TAGS ) "
121
+ DEBUG_GO_FLAGS := -ldflags "$(GO_LDFLAGS ) " -tags "$(GO_BUILTIN_TAGS ) "
122
+ RELEASE_GO_FLAGS := -ldflags "-s -w $(GO_LDFLAGS ) " -tags "$(GO_BUILTIN_TAGS ) "
120
123
121
124
ifeq ($(RELEASE_BUILD ) ,1)
122
125
GO_FLAGS := $(DEFAULT_FLAGS ) $(RELEASE_GO_FLAGS )
@@ -139,7 +142,7 @@ lint: alloylint
139
142
# We have to run test twice: once for all packages with -race and then once
140
143
# more without -race for packages that have known race detection issues. The
141
144
# final command runs tests for all other submodules.
142
- test :
145
+ test : generate-beyla
143
146
$(GO_ENV ) go test $(GO_FLAGS ) -race $(shell go list ./... | grep -v /integration-tests/)
144
147
$(GO_ENV ) go test $(GO_FLAGS ) ./internal/static/integrations/node_exporter ./internal/static/logs ./internal/component/otelcol/processor/tail_sampling ./internal/component/loki/source/file ./internal/component/loki/source/docker
145
148
$(GO_ENV ) find . -name go.mod -not -path " ./go.mod" -execdir go test -race ./... \;
@@ -163,7 +166,7 @@ integration-test:
163
166
.PHONY : binaries alloy
164
167
binaries : alloy
165
168
166
- alloy :
169
+ alloy : generate-beyla
167
170
ifeq ($(USE_CONTAINER ) ,1)
168
171
$(RERUN_IN_CONTAINER)
169
172
else
178
181
$(GO_ENV) go build $(GO_FLAGS) -o $(SERVICE_BINARY) ./internal/cmd/alloy-service
179
182
endif
180
183
181
- alloylint :
184
+ alloylint : generate-beyla
182
185
ifeq ($(USE_CONTAINER ) ,1)
183
186
$(RERUN_IN_CONTAINER)
184
187
else
@@ -273,6 +276,13 @@ drone: generate-drone
273
276
drone lint .drone/drone.yml --trusted
274
277
drone --server https://drone.grafana.net sign --save grafana/alloy .drone/drone.yml
275
278
279
+ # Required by vendored Beyla to build eBPF artifacts prior to building the
280
+ # Alloy binary
281
+ .PHONY : generate-beyla
282
+ generate-beyla :
283
+ @go mod vendor
284
+ @GOOS=$(GOHOSTOS ) GOARCH=$(GOHOSTARCH ) go generate vendor/github.com/grafana/beyla/v2/bpf/build_ebpf.go > /dev/null
285
+
276
286
.PHONY : clean
277
287
clean : clean-dist clean-build-container-cache
278
288
rm -rf ./build/*
@@ -285,7 +295,9 @@ info:
285
295
@printf " BUILD_IMAGE = $( BUILD_IMAGE) \n"
286
296
@printf " ALLOY_BINARY = $( ALLOY_BINARY) \n"
287
297
@printf " GOOS = $( GOOS) \n"
298
+ @printf " GOHOSTOS = $( GOHOSTOS) \n"
288
299
@printf " GOARCH = $( GOARCH) \n"
300
+ @printf " GOHOSTARCH = $( GOHOSTARCH) \n"
289
301
@printf " GOARM = $( GOARM) \n"
290
302
@printf " CGO_ENABLED = $( CGO_ENABLED) \n"
291
303
@printf " RELEASE_BUILD = $( RELEASE_BUILD) \n"
0 commit comments