Skip to content

Commit 3be2c1a

Browse files
committed
[build] compile ROR once to success
1 parent fbd4253 commit 3be2c1a

File tree

2 files changed

+64
-38
lines changed

2 files changed

+64
-38
lines changed

deps/Makefile

Lines changed: 33 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -164,37 +164,41 @@ ROCKSDB_BUILD_FLAGS=USE_COROUTINES=1 USE_FOLLY=1 $(ROCKSDB_BUILD_FOLLY_FLAGS)
164164
if [ ! -f rocksdb/_build_folly/installed/folly/lib/libfolly.a ]; then \
165165
cd rocksdb && ${ROCKSDB_BUILD_FOLLY_FLAGS} ${MAKE} checkout_folly && ${ROCKSDB_BUILD_FOLLY_FLAGS} ${MAKE} build_folly; \
166166
fi
167-
rm -rf ./rocksdb/_build_folly/libs
168-
mkdir -p ./rocksdb/_build_folly/libs
169-
FBUILD_PATH=`ls -d ./rocksdb/_build_folly*`; \
170-
BOOST_PATH=`ls -d $${FBUILD_PATH}/installed/boost*`; \
171-
DBL_CONV_PATH=`ls -d $${FBUILD_PATH}/installed/double-conversion*`; \
172-
FMT_PATH=`ls -d $${FBUILD_PATH}/installed/fmt*`; \
173-
GLOG_PATH=`ls -d $${FBUILD_PATH}/installed/glog*`; \
174-
GFLAGS_PATH=`ls -d $${FBUILD_PATH}/installed/gflags*`; \
175-
LIBEVENT_PATH=`ls -d $${FBUILD_PATH}/installed/libevent*`; \
176-
GLOG_LIB_PATH=`ls -d $${GLOG_PATH}/lib*`; \
177-
FMT_LIB_PATH=`ls -d $${FMT_PATH}/lib*`; \
178-
cp -r $${BOOST_PATH} ./rocksdb/_build_folly/libs/boost; \
179-
cp -r $${DBL_CONV_PATH} ./rocksdb/_build_folly/libs/double-conversion; \
180-
mkdir -p ./rocksdb/_build_folly/libs/fmt; \
181-
cp -r $${FMT_PATH}/include ./rocksdb/_build_folly/libs/fmt/include; \
182-
cp -r $${FMT_LIB_PATH} ./rocksdb/_build_folly/libs/fmt/lib; \
183-
mkdir -p ./rocksdb/_build_folly/libs/glog; \
184-
cp -r $${GLOG_PATH}/include ./rocksdb/_build_folly/libs/glog/include; \
185-
cp -r $${GLOG_LIB_PATH} ./rocksdb/_build_folly/libs/glog/lib; \
186-
mkdir -p ./rocksdb/_build_folly/libs/libiberty; \
187-
cp -r $${GFLAGS_PATH} ./rocksdb/_build_folly/libs/gflags; \
188-
cp -r $${LIBEVENT_PATH} ./rocksdb/_build_folly/libs/libevent; \
189-
cp -r $${FBUILD_PATH}/installed/folly ./rocksdb/_build_folly/libs/folly
190-
191-
192-
193-
rocksdb: ./rocksdb/_build_folly/folly/lib/libfolly.a .make-prerequisites
194-
@printf '%b %b\n' $(MAKECOLOR)MAKE$(ENDCOLOR) $(BINCOLOR)$@$(ENDCOLOR)
167+
if [ ! -d ./rocksdb/_build_folly/libs/boost ]; then \
168+
rm -rf ./rocksdb/_build_folly/libs; \
169+
mkdir -p ./rocksdb/_build_folly/libs; \
170+
FBUILD_PATH=`ls -d ./rocksdb/_build_folly*`; \
171+
BOOST_PATH=`ls -d $${FBUILD_PATH}/installed/boost*`; \
172+
DBL_CONV_PATH=`ls -d $${FBUILD_PATH}/installed/double-conversion*`; \
173+
FMT_PATH=`ls -d $${FBUILD_PATH}/installed/fmt*`; \
174+
GLOG_PATH=`ls -d $${FBUILD_PATH}/installed/glog*`; \
175+
GFLAGS_PATH=`ls -d $${FBUILD_PATH}/installed/gflags*`; \
176+
LIBEVENT_PATH=`ls -d $${FBUILD_PATH}/installed/libevent*`; \
177+
GLOG_LIB_PATH=`ls -d $${GLOG_PATH}/lib*`; \
178+
FMT_LIB_PATH=`ls -d $${FMT_PATH}/lib*`; \
179+
cp -r $${BOOST_PATH} ./rocksdb/_build_folly/libs/boost; \
180+
cp -r $${DBL_CONV_PATH} ./rocksdb/_build_folly/libs/double-conversion; \
181+
mkdir -p ./rocksdb/_build_folly/libs/fmt; \
182+
cp -r $${FMT_PATH}/include ./rocksdb/_build_folly/libs/fmt/include; \
183+
cp -r $${FMT_LIB_PATH} ./rocksdb/_build_folly/libs/fmt/lib; \
184+
mkdir -p ./rocksdb/_build_folly/libs/glog; \
185+
cp -r $${GLOG_PATH}/include ./rocksdb/_build_folly/libs/glog/include; \
186+
cp -r $${GLOG_LIB_PATH} ./rocksdb/_build_folly/libs/glog/lib; \
187+
mkdir -p ./rocksdb/_build_folly/libs/libiberty; \
188+
cp -r $${GFLAGS_PATH} ./rocksdb/_build_folly/libs/gflags; \
189+
cp -r $${LIBEVENT_PATH} ./rocksdb/_build_folly/libs/libevent; \
190+
cp -r $${FBUILD_PATH}/installed/folly ./rocksdb/_build_folly/libs/folly; \
191+
fi
192+
193+
194+
195+
rocksdb: rocksdb/librocksdb.a
196+
197+
rocksdb/librocksdb.a: ./rocksdb/_build_folly/folly/lib/libfolly.a
198+
@printf '%b %b\n' $(MAKECOLOR)MAKE$(ENDCOLOR) $(BINCOLOR)rocksdb$(ENDCOLOR)
195199
cd rocksdb && $(ROCKSDB_BUILD_FLAGS) $(MAKE) CFLAGS="$(ROCKSDB_CFLAGS)" static_lib
196200

197-
.PHONY: rocksdb
201+
# Remove .PHONY for rocksdb to enable incremental builds
198202

199203
XREDIS_GTID_CFLAGS= -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops $(CFLAGS)
200204
XREDIS_GTID_LDFLAGS= $(LDFLAGS)

src/Makefile

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@ endif
3838
DEPENDENCY_TARGETS=hiredis linenoise lua hdr_histogram fpconv fast_float xredis-gtid
3939
NODEPS:=clean distclean
4040
ifdef SWAP
41-
DEPENDENCY_TARGETS+=tdigest rocksdb
41+
DEPENDENCY_TARGETS+=tdigest
42+
# rocksdb will be built separately during linking to avoid blocking object compilation
43+
LINK_DEPS=rocksdb
4244
endif
4345
# Default settings
4446
STD=-pedantic -DREDIS_STATIC=''
@@ -440,17 +442,27 @@ persist-settings: distclean
440442

441443
.PHONY: persist-settings
442444

443-
# Prerequisites target
444-
.make-prerequisites:
445+
# Prerequisites target - separated for compile-time and link-time deps
446+
.make-compile-prerequisites:
445447
@touch $@
446448

447-
# Clean everything, persist settings and build dependencies if anything changed
449+
# Clean everything, persist settings and build compile dependencies if anything changed
448450
ifneq ($(strip $(PREV_FINAL_CFLAGS)), $(strip $(FINAL_CFLAGS)))
449-
.make-prerequisites: persist-settings
451+
.make-compile-prerequisites: persist-settings
450452
endif
451453

452454
ifneq ($(strip $(PREV_FINAL_LDFLAGS)), $(strip $(FINAL_LDFLAGS)))
453-
.make-prerequisites: persist-settings
455+
.make-compile-prerequisites: persist-settings
456+
endif
457+
458+
# Build link dependencies separately
459+
ifdef SWAP
460+
.make-link-prerequisites: .make-compile-prerequisites
461+
-(cd ../deps && $(MAKE) $(LINK_DEPS))
462+
@touch $@
463+
else
464+
.make-link-prerequisites: .make-compile-prerequisites
465+
@touch $@
454466
endif
455467

456468

@@ -474,7 +486,7 @@ SWAP_LIBS= ../deps/rocksdb/librocksdb.a ../deps/tdigest/tdigest.o
474486
endif
475487

476488
# redis-server
477-
$(REDIS_SERVER_NAME): $(REDIS_SERVER_OBJ) $(REDIS_VEC_SETS_OBJ)
489+
$(REDIS_SERVER_NAME): $(REDIS_SERVER_OBJ) $(REDIS_VEC_SETS_OBJ) .make-link-prerequisites
478490
$(REDIS_LD) -o $@ $^ ../deps/hiredis/libhiredis.a ../deps/lua/src/liblua.a ../deps/hdr_histogram/libhdrhistogram.a ../deps/fpconv/libfpconv.a ../deps/fast_float/libfast_float.a ../deps/xredis-gtid/lib/libgtid.a $(SWAP_LIBS) $(FINAL_LIBS)
479491

480492
# redis-sentinel
@@ -506,15 +518,25 @@ DEP = $(REDIS_SERVER_OBJ:%.o=%.d) $(REDIS_VEC_SETS_OBJ:%.o=%.d) $(REDIS_CLI_OBJ:
506518

507519
# Because the jemalloc.h header is generated as a part of the jemalloc build,
508520
# building it should complete before building any other object. Instead of
509-
# depending on a single artifact, build all dependencies first.
510-
%.o: %.c .make-prerequisites
521+
# depending on a single artifact, build all compile dependencies first.
522+
%.o: %.c .make-compile-prerequisites
523+
$(REDIS_CC) -MMD -o $@ -c $<
524+
525+
# commands.o specifically depends on the generated command definition file
526+
commands.o: commands.c $(COMMANDS_DEF_FILENAME).def .make-compile-prerequisites
511527
$(REDIS_CC) -MMD -o $@ -c $<
512528

513529
# The following files are checked in and don't normally need to be rebuilt. They
514530
# are built only if python is available and their prereqs are modified.
515531
ifneq (,$(PYTHON))
532+
ifdef SWAP
533+
# For SWAP builds, depend on both base commands and json.merge files
534+
commands_swap.def: commands/*.json commands_swap/*.json.merge ../utils/generate-command-code.py
535+
$(QUIET_GEN)$(PYTHON) ../utils/generate-command-code.py $(GEN_COMMANDS_FLAGS)
536+
else
516537
$(COMMANDS_DEF_FILENAME).def: commands/*.json ../utils/generate-command-code.py
517538
$(QUIET_GEN)$(PYTHON) ../utils/generate-command-code.py $(GEN_COMMANDS_FLAGS)
539+
endif
518540

519541
fmtargs.h: ../utils/generate-fmtargs.py
520542
$(QUITE_GEN)sed '/Everything below this line/,$$d' $@ > $@.tmp

0 commit comments

Comments
 (0)