Skip to content

Commit 3a8cdd7

Browse files
committed
fix(mysqlx): serialize plugin build so protobuf finishes before link
The v4.0 tarball build failed at the plugin link with: /usr/bin/ld: cannot find .../protobuf-3.21.12/install/lib/libprotobuf.a Root cause: the vendored protobuf target (deps/Makefile) is a recursive sub-make whose recipe `rm -rf`s deps/protobuf and re-runs a slow cmake build+install. The plugin is built from both build_deps_default and build_src_default, and under the parent build's -j that destructive rebuild races the plugin's .o/.pb.o compiles and the final .so link -- all of which list $(PROTOBUF_LIB) as a prereq, yet the link fired while libprotobuf.a was mid-rebuild and absent. Add .NOTPARALLEL to plugins/mysqlx/Makefile so protobuf is fully built before any plugin object or link (the plugin build is small, so the lost parallelism is negligible), and fail-fast in the $(PROTOBUF_LIB) rule if the deps build somehow doesn't produce the archive. Claude-Session: https://claude.ai/code/session_014qhWjonVGoNJhRRu8H3i5J
1 parent a5ccb86 commit 3a8cdd7

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

plugins/mysqlx/Makefile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,17 @@ CXXFLAGS += -fstack-protector-strong
9292

9393
.DEFAULT_GOAL := all
9494

95+
# Serialize this plugin's build. The vendored protobuf target (deps/Makefile)
96+
# is a recursive sub-make whose recipe first `rm -rf`s deps/protobuf and then
97+
# runs a slow cmake build+install. The plugin's .o, .pb.o and the final .so
98+
# all list $(PROTOBUF_LIB) as a prereq, but under the parent build's -j that
99+
# destructive rebuild has been observed to race the link -- the .so link
100+
# fires while protobuf is only partway rebuilt and libprotobuf.a is absent:
101+
# /usr/bin/ld: cannot find .../protobuf-3.21.12/install/lib/libprotobuf.a
102+
# .NOTPARALLEL forces protobuf to finish before any plugin object or link.
103+
# The plugin build is small, so the lost parallelism is negligible.
104+
.NOTPARALLEL:
105+
95106
SRCS := $(PLUGIN_DIR)/src/mysqlx_plugin.cpp \
96107
$(PLUGIN_DIR)/src/mysqlx_admin_schema.cpp \
97108
$(PLUGIN_DIR)/src/mysqlx_config_store.cpp \
@@ -111,6 +122,7 @@ $(ODIR):
111122

112123
$(PROTOBUF_LIB):
113124
$(MAKE) -C $(PROXYSQL_PATH)/deps PROXYSQL40=1 protobuf
125+
@test -f $@ || { echo "ERROR: deps protobuf build did not produce $@" >&2; exit 1; }
114126

115127
# Several plugin sources transitively include <google/protobuf/...> via
116128
# the .pb.h files under plugins/mysqlx/proto/ (e.g. mysqlx_protocol.cpp,

0 commit comments

Comments
 (0)