From 4deb45dc3f466472689247a39b53b1929bfc82d5 Mon Sep 17 00:00:00 2001 From: Eric Anderson Date: Sat, 5 Aug 2023 13:02:50 -0700 Subject: [PATCH] Makefile: Eagerly run pkg-config for protobuf Protobuf added a dependency on absl and now pkg-config is incredibly slow. `pkg-config --libs protobuf` and `--cflags` each take around 1.5 seconds on my laptop. Running pkg-config only once reduces a 100% incremental build for 'make all' from 90 seconds to 3.2 seconds. Unfortunately we will pay the 3 seconds every time we execute make, even for something that doesn't need protobuf. --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 12d9a35d..836614b5 100644 --- a/Makefile +++ b/Makefile @@ -138,12 +138,12 @@ PROTOS = \ PROTO_HDRS = $(patsubst %.proto, $(OBJDIR)/%.pb.h, $(PROTOS)) PROTO_SRCS = $(patsubst %.proto, $(OBJDIR)/%.pb.cc, $(PROTOS)) PROTO_OBJS = $(patsubst %.cc, %.o, $(PROTO_SRCS)) -PROTO_CFLAGS = $(shell $(PKG_CONFIG) --cflags protobuf) +PROTO_CFLAGS := $(shell $(PKG_CONFIG) --cflags protobuf) $(PROTO_SRCS): | $(PROTO_HDRS) $(PROTO_OBJS): CFLAGS += $(PROTO_CFLAGS) PROTO_LIB = $(OBJDIR)/libproto.a $(PROTO_LIB): $(PROTO_OBJS) -PROTO_LDFLAGS = $(shell $(PKG_CONFIG) --libs protobuf) -pthread +PROTO_LDFLAGS := $(shell $(PKG_CONFIG) --libs protobuf) -pthread .PRECIOUS: $(PROTO_HDRS) $(PROTO_SRCS) include dep/agg/build.mk