Skip to content

Commit 2d4baf6

Browse files
committed
don't fallback onto deps from vendor
Abort build if protobuf-c cannot be found in the system without falling back to building and using protobuf-c from vendor subdir. axiom build needs protoc-c (provided by protobuf-c-compiler package) and agent needs to link to protobuf-c static library (provided by protobuf-c-devel). Static library is required to avoid shared objects runtime dependencies on customers' systems. Don't attempt to build protobuf compiler from vendor subdir - assume it is installed and let the build fail if it is not. protobuf compiler alone is not enough for the rule that used it anyway - protoc-gen-go is needed too, and it has never been vendored but rather was assumed to be installed on the build system. The rule that uses protobuf compiler and protoc-gen-go is not part of the build anyway - its output is checked in to the repository. The rule exists as documentation how to regenerate infinite tracing code for the daemon.
1 parent 3d71d47 commit 2d4baf6

File tree

5 files changed

+26
-36
lines changed

5 files changed

+26
-36
lines changed

Makefile

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ bin/:
227227
#
228228

229229
.PHONY: axiom
230-
axiom: vendor
230+
axiom: protobuf-c
231231
$(MAKE) -C axiom
232232

233233
#
@@ -238,15 +238,15 @@ axiom: vendor
238238
# TESTARGS =
239239

240240
.PHONY: axiom-tests
241-
axiom-tests: vendor
241+
axiom-tests: protobuf-c
242242
$(MAKE) -C axiom tests
243243

244244
.PHONY: axiom-check axiom-run-tests
245-
axiom-check axiom-run-tests: vendor axiom/tests/cross_agent_tests
245+
axiom-check axiom-run-tests: protobuf-c axiom/tests/cross_agent_tests
246246
$(MAKE) -C axiom run_tests
247247

248248
.PHONY: axiom-valgrind
249-
axiom-valgrind: vendor axiom/tests/cross_agent_tests
249+
axiom-valgrind: protobuf-c axiom/tests/cross_agent_tests
250250
$(MAKE) -C axiom valgrind
251251

252252
.PHONY: tests
@@ -279,9 +279,7 @@ axiom-clean:
279279
daemon-protobuf: daemon/internal/newrelic/infinite_tracing/com_newrelic_trace_v1/v1.pb.go
280280

281281
daemon/internal/newrelic/infinite_tracing/com_newrelic_trace_v1/v1.pb.go: protocol/infinite_tracing/v1.proto
282-
$(MAKE) vendor # Only build vendor stuff if v1.proto has changed. Otherwise
283-
# this rule will be triggered every time the daemon is built.
284-
$(VENDOR_PREFIX)/bin/protoc \
282+
protoc \
285283
-I=./protocol/infinite_tracing \
286284
--go_out="paths=source_relative,plugins=grpc:daemon/internal/newrelic/infinite_tracing/com_newrelic_trace_v1" \
287285
protocol/infinite_tracing/v1.proto
@@ -403,7 +401,7 @@ coverage:
403401
#
404402

405403
.PHONY: clean
406-
clean: agent-clean axiom-clean daemon-clean package-clean coverage-clean vendor-clean
404+
clean: agent-clean axiom-clean daemon-clean package-clean coverage-clean
407405
rm -rf releases
408406
rm -f agent/newrelic.map agent/LicenseData/license_errors.txt
409407

@@ -441,21 +439,14 @@ lasp-test-all:
441439
$(MAKE) lasp-test SUITE_LASP=suite-random-3
442440

443441
#
444-
# Vendored libraries
442+
# Check for protobuf-c (HAVE_PROTOBUF_C):
443+
# - axiom build needs protoc-c (protobuf-c-compiler)
444+
# - agent build needs protobuf-c static library (protobuf-c-devel)
445445
#
446-
export GIT
447-
448-
.PHONY: vendor vendor-clean
446+
.PHONY: protobuf-c
447+
protobuf-c:
449448
ifeq (0,$(HAVE_PROTOBUF_C))
450-
vendor:
451-
$(MAKE) -C vendor all
452-
453-
vendor-clean:
454-
$(MAKE) -C vendor clean
455-
else
456-
vendor: ;
457-
458-
vendor-clean: ;
449+
$(error Build dependency 'protobuf-c' not found.)
459450
endif
460451

461452
#

axiom/Makefile

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ nr_config.h: configure Makefile
195195
#
196196
# Build the 8T protobuf code.
197197
#
198-
v1.pb-c.c: v1.proto
198+
v1.pb-c.c: v1.proto protobuf-c
199199
$(PROTOBUF_C_PREFIX)/bin/protoc-c --c_out=. $<
200200

201201
#
@@ -205,6 +205,12 @@ v1.pb-c.c: v1.proto
205205
v1.pb-c.o: v1.pb-c.c
206206
$(CC) $(AXIOM_CPPFLAGS) $(CPPFLAGS) $(AXIOM_CFLAGS) $(PCRE_CFLAGS) $(VENDOR_CFLAGS) $(CFLAGS) -MMD -MP -Wno-cast-qual -c $< -o $@
207207

208+
.PHONY: protobuf-c
209+
protobuf-c:
210+
ifeq (0,$(HAVE_PROTOBUF_C))
211+
$(error Build dependency 'protobuf-c' not found.)
212+
endif
213+
208214
#
209215
# Track the flags passed to the compiler to force a rebuild when they change.
210216
# This ensures a rebuild occurs when the version number or commit are updated.

files/Dockerfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
4444
libmcrypt-dev \
4545
libonig-dev \
4646
libpcre3 libpcre3-dev \
47+
# 8T protobuf code in axiom depends on libprotobuf-c library
48+
libprotobuf-c-dev \
4749
libreadline-dev \
4850
libssl-dev \
4951
libsqlite3-dev \
@@ -52,6 +54,10 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
5254
locales \
5355
locales-all \
5456
netcat-openbsd \
57+
# needed to generate 8T protobuf code in daemon
58+
protobuf-compiler \
59+
# needed to generate 8T protobuf code in axiom
60+
protobuf-c-compiler \
5561
python3-yaml \
5662
${PHP_USER_SPECIFIED_PACKAGES} \
5763
zlib1g-dev

make/config.mk

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,6 @@ ifneq ($(findstring environment,$(origin PROTOBUF_C_PREFIX)), )
5959
ifeq ($(HAVE_PROTOBUF_C), 0)
6060
$(error User provided 'protobuf-c' installation is not valid!)
6161
endif
62-
else
63-
ifeq ($(HAVE_PROTOBUF_C), 0)
64-
$(info 'protobuf-c' installation not found, falling back to building from vendor subdir.)
65-
endif
6662
endif
6763

6864

make/vendor.mk

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,8 @@
1111
# It is recommended to use the VENDOR_... variables.
1212
#
1313

14-
# We need to find where the project's vendored dependencies live for these
15-
# variables.
16-
ifeq (0,$(HAVE_PROTOBUF_C))
17-
PROTOBUF_C_PREFIX := $(realpath $(dir $(abspath $(lastword $(MAKEFILE_LIST))))../vendor)/local
18-
endif
19-
20-
#
21-
# protobuf-c
2214
#
23-
# Note that this does not require protobuf, which is a build time dependency
24-
# only.
15+
# protobuf-c: 8T protobuf code from axiom needs protobuf-c library
2516
#
2617
PROTOBUF_C_CFLAGS := -I$(PROTOBUF_C_PREFIX)/include
2718
PROTOBUF_C_LDFLAGS := -L$(PROTOBUF_C_PREFIX)/lib

0 commit comments

Comments
 (0)