From 1fdd9e01904d7c5c1a800e06fa402fa6def1fafb Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Sat, 23 Mar 2024 00:43:02 +0100 Subject: [PATCH 1/4] build: Add support for using the system concurrentqueue headers Add a new USE_SYSTEM_CONCURRENTQUEUE make variable to select whether to include the system concurrentqueue headers. --- src/Makefile | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Makefile b/src/Makefile index fc58b64f5..9452f5959 100644 --- a/src/Makefile +++ b/src/Makefile @@ -268,7 +268,13 @@ endif # Include paths to dependencies FINAL_CFLAGS+= -I../deps/hiredis -I../deps/linenoise -I../deps/lua/src -I../deps/hdr_histogram -FINAL_CXXFLAGS+= -I../deps/hiredis -I../deps/linenoise -I../deps/lua/src -I../deps/hdr_histogram -I../deps/rocksdb/include/ -I../deps/concurrentqueue +FINAL_CXXFLAGS+= -I../deps/hiredis -I../deps/linenoise -I../deps/lua/src -I../deps/hdr_histogram -I../deps/rocksdb/include/ + +ifeq ($(USE_SYSTEM_CONCURRENTQUEUE),yes) + FINAL_CXXFLAGS+= -I/usr/include/concurrentqueue/moodycamel +else + FINAL_CXXFLAGS+= -I../deps/concurrentqueue +endif # Determine systemd support and/or build preference (defaulting to auto-detection) BUILD_WITH_SYSTEMD=no @@ -414,6 +420,7 @@ persist-settings: distclean echo STD=$(STD) >> .make-settings echo WARN=$(WARN) >> .make-settings echo OPT=$(OPT) >> .make-settings + echo USE_SYSTEM_CONCURRENTQUEUE=$(USE_SYSTEM_CONCURRENTQUEUE) >> .make-settings echo MALLOC=$(MALLOC) >> .make-settings echo BUILD_TLS=$(BUILD_TLS) >> .make-settings echo USE_SYSTEMD=$(USE_SYSTEMD) >> .make-settings From 16bfe91119cfafe5e9bcf98d32faa049a136fb68 Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Fri, 22 Mar 2024 23:54:28 +0100 Subject: [PATCH 2/4] build: Add support for linking against a system libjemalloc Add a new USE_SYSTEM_JEMALLOC make variable to select whether to link against the system libjemalloc. --- deps/Makefile | 2 + ...support-for-USE_SYSTEM_JEMALLOC-flag.patch | 107 ------------------ pkg/deb/debian_dh9/patches/series | 1 - src/Makefile | 7 ++ 4 files changed, 9 insertions(+), 108 deletions(-) delete mode 100644 pkg/deb/debian_dh9/patches/0010-Add-support-for-USE_SYSTEM_JEMALLOC-flag.patch diff --git a/deps/Makefile b/deps/Makefile index 28cf4e01d..37f1b4117 100644 --- a/deps/Makefile +++ b/deps/Makefile @@ -37,7 +37,9 @@ distclean: -(cd hiredis && $(MAKE) clean) > /dev/null || true -(cd linenoise && $(MAKE) clean) > /dev/null || true -(cd lua && $(MAKE) clean) > /dev/null || true +ifneq ($(USE_SYSTEM_JEMALLOC),yes) -(cd jemalloc && [ -f Makefile ] && $(MAKE) distclean) > /dev/null || true +endif -(cd rocksdb && $(MAKE) clean) > /dev/null || true -(cd hdr_histogram && $(MAKE) clean) > /dev/null || true -(rm -f .make-*) diff --git a/pkg/deb/debian_dh9/patches/0010-Add-support-for-USE_SYSTEM_JEMALLOC-flag.patch b/pkg/deb/debian_dh9/patches/0010-Add-support-for-USE_SYSTEM_JEMALLOC-flag.patch deleted file mode 100644 index d7f8b2d1e..000000000 --- a/pkg/deb/debian_dh9/patches/0010-Add-support-for-USE_SYSTEM_JEMALLOC-flag.patch +++ /dev/null @@ -1,107 +0,0 @@ -From: Chris Lamb -Date: Sat, 25 Aug 2018 17:52:13 +0200 -Subject: Add support for USE_SYSTEM_JEMALLOC flag. - -https://github.com/antirez/redis/pull/5279 ---- - deps/Makefile | 2 ++ - src/Makefile | 5 +++++ - src/object.c | 5 +++++ - src/zmalloc.c | 10 ++++++++++ - src/zmalloc.h | 4 ++++ - 5 files changed, 26 insertions(+) - -diff --git a/deps/Makefile b/deps/Makefile -index eb35c1e..1342fac 100644 ---- a/deps/Makefile -+++ b/deps/Makefile -@@ -36,7 +36,9 @@ distclean: - -(cd hiredis && $(MAKE) clean) > /dev/null || true - -(cd linenoise && $(MAKE) clean) > /dev/null || true - -(cd lua && $(MAKE) clean) > /dev/null || true -+ifneq ($(USE_SYSTEM_JEMALLOC),yes) - -(cd jemalloc && [ -f Makefile ] && $(MAKE) distclean) > /dev/null || true -+endif - -(rm -f .make-*) - - .PHONY: distclean -diff --git a/src/Makefile b/src/Makefile -index 0ff6e8b..51363fe 100644 ---- a/src/Makefile -+++ b/src/Makefile -@@ -120,10 +120,15 @@ ifeq ($(MALLOC),tcmalloc_minimal) - endif - - ifeq ($(MALLOC),jemalloc) -+ifeq ($(USE_SYSTEM_JEMALLOC),yes) -+ FINAL_CFLAGS+= -DUSE_JEMALLOC -I/usr/include/jemalloc/include -+ FINAL_LIBS := -ljemalloc $(FINAL_LIBS) -+else - DEPENDENCY_TARGETS+= jemalloc - FINAL_CFLAGS+= -DUSE_JEMALLOC -I../deps/jemalloc/include - FINAL_LIBS := ../deps/jemalloc/lib/libjemalloc.a $(FINAL_LIBS) - endif -+endif - - REDIS_CC=$(QUIET_CC)$(CC) $(FINAL_CFLAGS) $(CPPFLAGS) - REDIS_LD=$(QUIET_LINK)$(CC) $(FINAL_LDFLAGS) -diff --git a/src/object.c b/src/object.c -index 6987e1e..e49c2c2 100644 ---- a/src/object.c -+++ b/src/object.c -@@ -36,6 +36,11 @@ - #define strtold(a,b) ((long double)strtod((a),(b))) - #endif - -+#if defined(USE_JEMALLOC) && (USE_SYSTEM_JEMALLOC == yes) -+#define je_mallctl mallctl -+#define je_malloc_stats_print malloc_stats_print -+#endif -+ - /* ===================== Creation and parsing of objects ==================== */ - - robj *createObject(int type, void *ptr) { -diff --git a/src/zmalloc.c b/src/zmalloc.c -index 2482f51..80e6571 100644 ---- a/src/zmalloc.c -+++ b/src/zmalloc.c -@@ -63,6 +63,15 @@ void zlibc_free(void *ptr) { - #define realloc(ptr,size) tc_realloc(ptr,size) - #define free(ptr) tc_free(ptr) - #elif defined(USE_JEMALLOC) -+#if USE_SYSTEM_JEMALLOC == yes -+#define malloc(size) malloc(size) -+#define calloc(count,size) calloc(count,size) -+#define realloc(ptr,size) realloc(ptr,size) -+#define free(ptr) free(ptr) -+#define mallocx(size,flags) mallocx(size,flags) -+#define dallocx(ptr,flags) dallocx(ptr,flags) -+#define je_mallctl mallctl -+#else - #define malloc(size) je_malloc(size) - #define calloc(count,size) je_calloc(count,size) - #define realloc(ptr,size) je_realloc(ptr,size) -@@ -70,6 +79,7 @@ void zlibc_free(void *ptr) { - #define mallocx(size,flags) je_mallocx(size,flags) - #define dallocx(ptr,flags) je_dallocx(ptr,flags) - #endif -+#endif - - #define update_zmalloc_stat_alloc(__n) do { \ - size_t _n = (__n); \ -diff --git a/src/zmalloc.h b/src/zmalloc.h -index 6fb19b0..62ccf29 100644 ---- a/src/zmalloc.h -+++ b/src/zmalloc.h -@@ -50,7 +50,11 @@ - #include - #if (JEMALLOC_VERSION_MAJOR == 2 && JEMALLOC_VERSION_MINOR >= 1) || (JEMALLOC_VERSION_MAJOR > 2) - #define HAVE_MALLOC_SIZE 1 -+#if USE_SYSTEM_JEMALLOC == yes -+#define zmalloc_size(p) malloc_usable_size(p) -+#else - #define zmalloc_size(p) je_malloc_usable_size(p) -+#endif - #else - #error "Newer version of jemalloc required" - #endif diff --git a/pkg/deb/debian_dh9/patches/series b/pkg/deb/debian_dh9/patches/series index ccb3d98d6..3e108036d 100644 --- a/pkg/deb/debian_dh9/patches/series +++ b/pkg/deb/debian_dh9/patches/series @@ -2,7 +2,6 @@ #debian-packaging/0003-dpkg-buildflags.patch #debian-packaging/0007-Set-Debian-configuration-defaults.patch #0010-Use-get_current_dir_name-over-PATHMAX-etc.patch -#0010-Add-support-for-USE_SYSTEM_JEMALLOC-flag.patch #0011-Add-support-for-a-USE_SYSTEM_LUA-flag.patch #0007-Add-support-for-a-USE_SYSTEM_HIREDIS-flag.patch #test diff --git a/src/Makefile b/src/Makefile index 9452f5959..493a1db17 100644 --- a/src/Makefile +++ b/src/Makefile @@ -317,11 +317,17 @@ ifeq ($(MALLOC),tcmalloc_minimal) endif ifeq ($(MALLOC),jemalloc) +ifeq ($(USE_SYSTEM_JEMALLOC),yes) + FINAL_CFLAGS+= -DUSE_JEMALLOC $(shell $(PKG_CONFIG) --cflags jemalloc) + FINAL_CXXFLAGS+= -DUSE_JEMALLOC $(shell $(PKG_CONFIG) --cflags jemalloc) + FINAL_LIBS := $(shell $(PKG_CONFIG) --libs jemalloc) $(FINAL_LIBS) +else DEPENDENCY_TARGETS+= jemalloc FINAL_CFLAGS+= -DUSE_JEMALLOC -I../deps/jemalloc/include FINAL_CXXFLAGS+= -DUSE_JEMALLOC -I../deps/jemalloc/include FINAL_LIBS := ../deps/jemalloc/lib/libjemalloc.a $(FINAL_LIBS) endif +endif ifeq ($(MALLOC),memkind) DEPENDENCY_TARGETS+= memkind @@ -422,6 +428,7 @@ persist-settings: distclean echo OPT=$(OPT) >> .make-settings echo USE_SYSTEM_CONCURRENTQUEUE=$(USE_SYSTEM_CONCURRENTQUEUE) >> .make-settings echo MALLOC=$(MALLOC) >> .make-settings + echo USE_SYSTEM_JEMALLOC=$(USE_SYSTEM_JEMALLOC) >> .make-settings echo BUILD_TLS=$(BUILD_TLS) >> .make-settings echo USE_SYSTEMD=$(USE_SYSTEMD) >> .make-settings echo CFLAGS=$(CFLAGS) >> .make-settings From 0ec4e906d2147b5eb5264f3d7e3b8dec185f92aa Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Sat, 23 Mar 2024 00:08:14 +0100 Subject: [PATCH 3/4] build: Add support for linking against a system librocksdb Add a new USE_SYSTEM_ROCKSDB make variable to select whether to link against the system librocksdb. --- deps/Makefile | 2 ++ src/Makefile | 11 +++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/deps/Makefile b/deps/Makefile index 37f1b4117..7112907ab 100644 --- a/deps/Makefile +++ b/deps/Makefile @@ -40,7 +40,9 @@ distclean: ifneq ($(USE_SYSTEM_JEMALLOC),yes) -(cd jemalloc && [ -f Makefile ] && $(MAKE) distclean) > /dev/null || true endif +ifneq ($(USE_SYSTEM_ROCKSDB),yes) -(cd rocksdb && $(MAKE) clean) > /dev/null || true +endif -(cd hdr_histogram && $(MAKE) clean) > /dev/null || true -(rm -f .make-*) diff --git a/src/Makefile b/src/Makefile index 493a1db17..4476f7c96 100644 --- a/src/Makefile +++ b/src/Makefile @@ -73,12 +73,19 @@ ifneq ($(strip $(SANITIZE)),) endif ifeq ($(ENABLE_FLASH),yes) + STORAGE_OBJ+= storage/rocksdb.o storage/rocksdbfactory.o +ifeq ($(USE_SYSTEM_ROCKSDB),yes) + FINAL_LIBS+= $(shell pkg-config --libs rocksdb) + FINAL_CXXFLAGS+= $(shell pkg-config --cflags rocksdb) -DENABLE_ROCKSDB + +else FINAL_LIBS+= -lz -lcrypto -lbz2 -lzstd -llz4 -lsnappy CXXFLAGS+= -I../deps/rocksdb/include/ -DENABLE_ROCKSDB - STORAGE_OBJ+= storage/rocksdb.o storage/rocksdbfactory.o + FINAL_CXXFLAGS+= -I../deps/rocksdb/include/ FINAL_LIBS+= ../deps/rocksdb/librocksdb.a DEPENDENCY_TARGETS+= rocksdb endif +endif ifeq ($(CHECKED),true) @@ -268,7 +275,7 @@ endif # Include paths to dependencies FINAL_CFLAGS+= -I../deps/hiredis -I../deps/linenoise -I../deps/lua/src -I../deps/hdr_histogram -FINAL_CXXFLAGS+= -I../deps/hiredis -I../deps/linenoise -I../deps/lua/src -I../deps/hdr_histogram -I../deps/rocksdb/include/ +FINAL_CXXFLAGS+= -I../deps/hiredis -I../deps/linenoise -I../deps/lua/src -I../deps/hdr_histogram ifeq ($(USE_SYSTEM_CONCURRENTQUEUE),yes) FINAL_CXXFLAGS+= -I/usr/include/concurrentqueue/moodycamel From 657229a9ac6e7c9d9820bf74061c1e0a4a12f927 Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Sat, 23 Mar 2024 00:23:16 +0100 Subject: [PATCH 4/4] build: Add support for linking against a system libhiredis/libhiredis_ssl Add a new USE_SYSTEM_HIREDIS make variable to select whether to link against the system libhiredis (and libhiredis_ssl if BUILD_TLS is enabled). Move the sdscompat.h header from the vendored hiredis directory to src/, as this file is not and has never been part of the upstream hiredis project, it got added in commit bffbbeaa9a1a6b8e81384297272cb0631502e8fd in redis itself. --- deps/Makefile | 2 + ...upport-for-a-USE_SYSTEM_HIREDIS-flag.patch | 84 ------------------- pkg/deb/debian_dh9/patches/series | 1 - src/Makefile | 32 +++++-- src/cli_common.c | 2 +- src/keydb-diagnostic-tool.cpp | 2 +- src/motd.cpp | 4 +- src/redis-benchmark.cpp | 2 +- src/redis-cli.c | 2 +- src/redis-cli.h | 2 +- {deps/hiredis => src}/sdscompat.h | 4 + 11 files changed, 38 insertions(+), 99 deletions(-) delete mode 100644 pkg/deb/debian_dh9/patches/0007-Add-support-for-a-USE_SYSTEM_HIREDIS-flag.patch rename {deps/hiredis => src}/sdscompat.h (98%) diff --git a/deps/Makefile b/deps/Makefile index 7112907ab..7ef872784 100644 --- a/deps/Makefile +++ b/deps/Makefile @@ -34,7 +34,9 @@ ifneq ($(shell sh -c '[ -f .make-ldflags ] && cat .make-ldflags || echo none'), endif distclean: +ifneq ($(USE_SYSTEM_HIREDIS),yes) -(cd hiredis && $(MAKE) clean) > /dev/null || true +endif -(cd linenoise && $(MAKE) clean) > /dev/null || true -(cd lua && $(MAKE) clean) > /dev/null || true ifneq ($(USE_SYSTEM_JEMALLOC),yes) diff --git a/pkg/deb/debian_dh9/patches/0007-Add-support-for-a-USE_SYSTEM_HIREDIS-flag.patch b/pkg/deb/debian_dh9/patches/0007-Add-support-for-a-USE_SYSTEM_HIREDIS-flag.patch deleted file mode 100644 index 8e59cc144..000000000 --- a/pkg/deb/debian_dh9/patches/0007-Add-support-for-a-USE_SYSTEM_HIREDIS-flag.patch +++ /dev/null @@ -1,84 +0,0 @@ -From: Chris Lamb -Date: Wed, 3 Oct 2018 19:24:16 +0100 -Subject: Add support for a USE_SYSTEM_HIREDIS flag. - ---- - deps/Makefile | 2 ++ - src/Makefile | 19 ++++++++++++++----- - 2 files changed, 16 insertions(+), 5 deletions(-) - -diff --git a/deps/Makefile b/deps/Makefile -index 2ed7736..d6b8e3e 100644 ---- a/deps/Makefile -+++ b/deps/Makefile -@@ -33,7 +33,9 @@ ifneq ($(shell sh -c '[ -f .make-ldflags ] && cat .make-ldflags || echo none'), - endif - - distclean: -+ifneq ($(USE_SYSTEM_HIREDIS),yes) - -(cd hiredis && $(MAKE) clean) > /dev/null || true -+endif - -(cd linenoise && $(MAKE) clean) > /dev/null || true - ifneq ($(USE_SYSTEM_LUA),yes) - -(cd lua && $(MAKE) clean) > /dev/null || true -diff --git a/src/Makefile b/src/Makefile -index 49085f2..9e7e6f1 100644 ---- a/src/Makefile -+++ b/src/Makefile -@@ -16,7 +16,7 @@ release_hdr := $(shell sh -c './mkreleasehdr.sh') - uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not') - uname_M := $(shell sh -c 'uname -m 2>/dev/null || echo not') - OPTIMIZATION?=-O2 --DEPENDENCY_TARGETS=hiredis linenoise -+DEPENDENCY_TARGETS=linenoise - NODEPS:=clean distclean - - # Default settings -@@ -107,7 +107,7 @@ endif - endif - endif - # Include paths to dependencies --FINAL_CFLAGS+= -I../deps/hiredis -I../deps/linenoise -+FINAL_CFLAGS+= -I../deps/linenoise - - ifeq ($(MALLOC),tcmalloc) - FINAL_CFLAGS+= -DUSE_TCMALLOC -@@ -139,6 +139,15 @@ else - FINAL_LIBS := ../deps/lua/src/liblua.a $(FINAL_LIBS) - endif - -+ifeq ($(USE_SYSTEM_HIREDIS),yes) -+ FINAL_LIBS+= -lhiredis -+ FINAL_CFLAGS+= -I/usr/include/hiredis -+else -+ DEPENDENCY_TARGETS += hiredis -+ FINAL_LIBS+= ../deps/hiredis/libhiredis.a -+ FINAL_CFLAGS+= -I../deps/hiredis -+endif -+ - REDIS_CC=$(QUIET_CC)$(CC) $(FINAL_CFLAGS) $(CPPFLAGS) - REDIS_LD=$(QUIET_LINK)$(CC) $(FINAL_LDFLAGS) - REDIS_INSTALL=$(QUIET_INSTALL)$(INSTALL) -@@ -210,7 +219,7 @@ endif - - # redis-server - $(REDIS_SERVER_NAME): $(REDIS_SERVER_OBJ) -- $(REDIS_LD) -o $@ $^ ../deps/hiredis/libhiredis.a $(FINAL_LIBS) -+ $(REDIS_LD) -o $@ $^ $(FINAL_LIBS) - - # redis-sentinel - $(REDIS_SENTINEL_NAME): $(REDIS_SERVER_NAME) -@@ -226,11 +235,11 @@ $(REDIS_CHECK_AOF_NAME): $(REDIS_SERVER_NAME) - - # redis-cli - $(REDIS_CLI_NAME): $(REDIS_CLI_OBJ) -- $(REDIS_LD) -o $@ $^ ../deps/hiredis/libhiredis.a ../deps/linenoise/linenoise.o $(FINAL_LIBS) -+ $(REDIS_LD) -o $@ $^ ../deps/linenoise/linenoise.o $(FINAL_LIBS) - - # redis-benchmark - $(REDIS_BENCHMARK_NAME): $(REDIS_BENCHMARK_OBJ) -- $(REDIS_LD) -o $@ $^ ../deps/hiredis/libhiredis.a $(FINAL_LIBS) -+ $(REDIS_LD) -o $@ $^ $(FINAL_LIBS) - - dict-benchmark: dict.c zmalloc.c sds.c siphash.c - $(REDIS_CC) $(FINAL_CFLAGS) $^ -D DICT_BENCHMARK_MAIN -o $@ $(FINAL_LIBS) diff --git a/pkg/deb/debian_dh9/patches/series b/pkg/deb/debian_dh9/patches/series index 3e108036d..2da3b11e1 100644 --- a/pkg/deb/debian_dh9/patches/series +++ b/pkg/deb/debian_dh9/patches/series @@ -3,5 +3,4 @@ #debian-packaging/0007-Set-Debian-configuration-defaults.patch #0010-Use-get_current_dir_name-over-PATHMAX-etc.patch #0011-Add-support-for-a-USE_SYSTEM_LUA-flag.patch -#0007-Add-support-for-a-USE_SYSTEM_HIREDIS-flag.patch #test diff --git a/src/Makefile b/src/Makefile index 4476f7c96..587a265fd 100644 --- a/src/Makefile +++ b/src/Makefile @@ -20,7 +20,7 @@ release_hdr := $(shell sh -c './mkreleasehdr.sh') uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not') uname_M := $(shell sh -c 'uname -m 2>/dev/null || echo not') OPTIMIZATION?=-O2 -flto -DEPENDENCY_TARGETS=hiredis linenoise lua hdr_histogram +DEPENDENCY_TARGETS=linenoise lua hdr_histogram NODEPS:=clean distclean # Default settings @@ -274,8 +274,8 @@ ifdef OPENSSL_PREFIX endif # Include paths to dependencies -FINAL_CFLAGS+= -I../deps/hiredis -I../deps/linenoise -I../deps/lua/src -I../deps/hdr_histogram -FINAL_CXXFLAGS+= -I../deps/hiredis -I../deps/linenoise -I../deps/lua/src -I../deps/hdr_histogram +FINAL_CFLAGS+= -I../deps/linenoise -I../deps/lua/src -I../deps/hdr_histogram +FINAL_CXXFLAGS+= -I../deps/linenoise -I../deps/lua/src -I../deps/hdr_histogram ifeq ($(USE_SYSTEM_CONCURRENTQUEUE),yes) FINAL_CXXFLAGS+= -I/usr/include/concurrentqueue/moodycamel @@ -343,6 +343,22 @@ ifeq ($(MALLOC),memkind) FINAL_LIBS := ../deps/memkind/src/.libs/libmemkind.a -lnuma $(FINAL_LIBS) endif +ifeq ($(USE_SYSTEM_HIREDIS),yes) + HIREDIS_CFLAGS := $(shell $(PKG_CONFIG) --cflags hiredis) -DUSE_SYSTEM_HIREDIS=1 + FINAL_CFLAGS+= $(HIREDIS_CFLAGS) + FINAL_CXXFLAGS+= $(HIREDIS_CFLAGS) + FINAL_LIBS+= $(shell $(PKG_CONFIG) --libs hiredis) +ifeq ($(BUILD_TLS),yes) + HIREDIS_TLS_CFLAGS := $(shell $(PKG_CONFIG) --cflags hiredis_ssl) + FINAL_CFLAGS+= $(HIREDIS_TLS_CFLAGS) + FINAL_CXXFLAGS+= $(HIREDIS_TLS_CFLAGS) + FINAL_LIBS+= $(shell $(PKG_CONFIG) --libs hiredis_ssl) +endif +else + DEPENDENCY_TARGETS+= hiredis + FINAL_CFLAGS+= -I../deps/hiredis + FINAL_CXXFLAGS+= -I../deps/hiredis + FINAL_LIBS+=../deps/hiredis/libhiredis.a ifeq ($(BUILD_TLS),yes) FINAL_CFLAGS+=-DUSE_OPENSSL $(OPENSSL_CFLAGS) FINAL_CXXFLAGS+=-DUSE_OPENSSL $(OPENSSL_CXXFLAGS) @@ -361,6 +377,7 @@ else endif FINAL_LIBS += ../deps/hiredis/libhiredis_ssl.a $(LIBSSL_LIBS) $(LIBCRYPTO_LIBS) endif +endif ifndef V define MAKE_INSTALL @@ -438,6 +455,7 @@ persist-settings: distclean echo USE_SYSTEM_JEMALLOC=$(USE_SYSTEM_JEMALLOC) >> .make-settings echo BUILD_TLS=$(BUILD_TLS) >> .make-settings echo USE_SYSTEMD=$(USE_SYSTEMD) >> .make-settings + echo USE_SYSTEM_HIREDIS=$(USE_SYSTEM_HIREDIS) >> .make-settings echo CFLAGS=$(CFLAGS) >> .make-settings echo CXXFLAGS=$(CXXFLAGS) >> .make-settings echo LDFLAGS=$(LDFLAGS) >> .make-settings @@ -467,7 +485,7 @@ endif # keydb-server $(REDIS_SERVER_NAME): $(REDIS_SERVER_OBJ) $(KEYDB_SERVER_OBJ) - $(REDIS_LD) -o $@ $^ ../deps/hiredis/libhiredis.a ../deps/lua/src/liblua.a $(FINAL_LIBS) + $(REDIS_LD) -o $@ $^ ../deps/lua/src/liblua.a $(FINAL_LIBS) # keydb-sentinel $(REDIS_SENTINEL_NAME): $(REDIS_SERVER_NAME) @@ -483,15 +501,15 @@ $(REDIS_CHECK_AOF_NAME): $(REDIS_SERVER_NAME) # keydb-cli $(REDIS_CLI_NAME): $(REDIS_CLI_OBJ) - $(REDIS_LD) -o $@ $^ ../deps/hiredis/libhiredis.a ../deps/linenoise/linenoise.o $(FINAL_LIBS) + $(REDIS_LD) -o $@ $^ ../deps/linenoise/linenoise.o $(FINAL_LIBS) # keydb-benchmark $(REDIS_BENCHMARK_NAME): $(REDIS_BENCHMARK_OBJ) - $(REDIS_LD) -o $@ $^ ../deps/hiredis/libhiredis.a ../deps/hdr_histogram/hdr_histogram.o $(FINAL_LIBS) + $(REDIS_LD) -o $@ $^ ../deps/hdr_histogram/hdr_histogram.o $(FINAL_LIBS) # keydb-diagnostic-tool $(KEYDB_DIAGNOSTIC_NAME): $(KEYDB_DIAGNOSTIC_OBJ) - $(REDIS_LD) -o $@ $^ ../deps/hiredis/libhiredis.a $(FINAL_LIBS) + $(REDIS_LD) -o $@ $^ $(FINAL_LIBS) DEP = $(REDIS_SERVER_OBJ:%.o=%.d) $(KEYDB_SERVER_OBJ:%.o=%.d) $(REDIS_CLI_OBJ:%.o=%.d) $(REDIS_BENCHMARK_OBJ:%.o=%.d) -include $(DEP) diff --git a/src/cli_common.c b/src/cli_common.c index e88327ace..c531c6c98 100644 --- a/src/cli_common.c +++ b/src/cli_common.c @@ -31,7 +31,7 @@ #include "cli_common.h" #include #include -#include /* Use hiredis' sds compat header that maps sds calls to their hi_ variants */ +#include "sdscompat.h" /* Use hiredis' sds compat header that maps sds calls to their hi_ variants */ #include /* use sds.h from hiredis, so that only one set of sds functions will be present in the binary */ #ifdef USE_OPENSSL #include diff --git a/src/keydb-diagnostic-tool.cpp b/src/keydb-diagnostic-tool.cpp index 2368043b0..43cf116d9 100644 --- a/src/keydb-diagnostic-tool.cpp +++ b/src/keydb-diagnostic-tool.cpp @@ -46,7 +46,7 @@ #include extern "C" { #include /* Use hiredis sds. */ -#include +#include "sdscompat.h" #include "hiredis.h" } #include "ae.h" diff --git a/src/motd.cpp b/src/motd.cpp index 795281734..ba957fa32 100644 --- a/src/motd.cpp +++ b/src/motd.cpp @@ -1,6 +1,6 @@ #ifdef CLIENT extern "C" { -#include +#include "sdscompat.h" #include } #else @@ -19,7 +19,7 @@ extern "C" { #ifdef MOTD #include -#ifdef CLIENT +#if !defined(USE_SYSTEM_HIREDIS) && defined(CLIENT) extern "C" { __attribute__ ((weak)) hisds hi_sdscatlen(hisds s, const void *t, size_t len) { return sdscatlen(s, t, len); diff --git a/src/redis-benchmark.cpp b/src/redis-benchmark.cpp index 34e19c372..538ed5275 100644 --- a/src/redis-benchmark.cpp +++ b/src/redis-benchmark.cpp @@ -44,7 +44,7 @@ #include #include extern "C" { -#include /* Use hiredis' sds compat header that maps sds calls to their hi_ variants */ +#include "sdscompat.h" /* Use hiredis' sds compat header that maps sds calls to their hi_ variants */ #include /* Use hiredis sds. */ #include } diff --git a/src/redis-cli.c b/src/redis-cli.c index 6d077dbdd..a7a3b8e8a 100644 --- a/src/redis-cli.c +++ b/src/redis-cli.c @@ -54,7 +54,7 @@ #include #include #endif -#include /* Use hiredis' sds compat header that maps sds calls to their hi_ variants */ +#include "sdscompat.h" /* Use hiredis' sds compat header that maps sds calls to their hi_ variants */ #include /* use sds.h from hiredis, so that only one set of sds functions will be present in the binary */ #include "adlist.h" #include "zmalloc.h" diff --git a/src/redis-cli.h b/src/redis-cli.h index 677f952c1..858c4e110 100644 --- a/src/redis-cli.h +++ b/src/redis-cli.h @@ -1,6 +1,6 @@ #pragma once #include "cli_common.h" -#include /* Use hiredis' sds compat header that maps sds calls to their hi_ variants */ +#include "sdscompat.h" /* Use hiredis' sds compat header that maps sds calls to their hi_ variants */ #include #ifdef __cplusplus diff --git a/deps/hiredis/sdscompat.h b/src/sdscompat.h similarity index 98% rename from deps/hiredis/sdscompat.h rename to src/sdscompat.h index e5a2574f3..58e6fdbdf 100644 --- a/deps/hiredis/sdscompat.h +++ b/src/sdscompat.h @@ -42,6 +42,8 @@ #ifndef HIREDIS_SDS_COMPAT #define HIREDIS_SDS_COMPAT +#ifndef USE_SYSTEM_HIREDIS + #define sds hisds #define sdslen hi_sdslen @@ -91,4 +93,6 @@ #define sdsull2str hi_sdsull2str #define sdsupdatelen hi_sdsupdatelen +#endif /* !USE_SYSTEM_HIREDIS */ + #endif /* HIREDIS_SDS_COMPAT */