From 0d06e515af83736a10a1901f918565e9a14a35d2 Mon Sep 17 00:00:00 2001 From: Ozan Tezcan Date: Mon, 18 May 2026 15:47:08 +0300 Subject: [PATCH] Fix compile on some linux distros (#15225) Fixes: 1. After #15096, we pass -flto to jemalloc. On Azure Linux, the resulting jemalloc library cannot be handled at link time and the build fails. Adding -ffat-lto-objects so the compiler also emits regular object code that the linker can fall back to when it cannot handle the LTO-compiled library. 2. Fixed a warning about `path` being NULL in `moduleLoadInternalModules()`. 3. Fixed compile warnings on older GCC versions introduced by #15162 (reported on Ubuntu 20.04) Co-authored-by: debing.sun --- deps/tre/lib/xmalloc.c | 6 +++--- src/Makefile | 2 +- src/module.c | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/deps/tre/lib/xmalloc.c b/deps/tre/lib/xmalloc.c index 637235d8d..4179d7c03 100644 --- a/deps/tre/lib/xmalloc.c +++ b/deps/tre/lib/xmalloc.c @@ -126,7 +126,7 @@ hash_table_add(hashTable *tbl, void *ptr, size_t bytes, } static void -#if defined(__GNUC__) && __GNUC__ >= 10 +#if defined(__GNUC__) && __GNUC__ >= 11 __attribute__((access(none, 2))) #endif hash_table_del(hashTable *tbl, void *ptr) @@ -344,12 +344,12 @@ xrealloc_impl(void *ptr, size_t new_size, const char *file, int line, new_ptr = realloc(ptr, new_size); if (new_ptr != NULL && new_ptr != ptr) { -#if defined(__GNUC__) && !defined(__clang__) +#if defined(__GNUC__) && !defined(__clang__) && __GNUC__ >= 12 #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wuse-after-free" #endif hash_table_del(xmalloc_table, ptr); -#if defined(__GNUC__) && !defined(__clang__) +#if defined(__GNUC__) && !defined(__clang__) && __GNUC__ >= 12 #pragma GCC diagnostic pop #endif hash_table_add(xmalloc_table, new_ptr, (int)new_size, file, line, func); diff --git a/src/Makefile b/src/Makefile index fea95efd4..8939f89e0 100644 --- a/src/Makefile +++ b/src/Makefile @@ -30,7 +30,7 @@ ifeq ($(OPTIMIZATION),-O3) ifeq (clang,$(CLANG)) ENABLE_LTO=-flto else - ENABLE_LTO=-flto=auto + ENABLE_LTO=-flto=auto -ffat-lto-objects endif OPTIMIZATION+=$(ENABLE_LTO) endif diff --git a/src/module.c b/src/module.c index 38a6ad388..9843e6ccc 100644 --- a/src/module.c +++ b/src/module.c @@ -13373,7 +13373,7 @@ int moduleOnLoad(int (*onload)(void *, void **, int), const char *path, void *ha moduleCreateContext(&ctx, NULL, REDISMODULE_CTX_TEMP_CLIENT); /* We pass NULL since we don't have a module yet. */ if (onload((void*)&ctx,module_argv,module_argc) == REDISMODULE_ERR) { serverLog(LL_WARNING, - "Module %s initialization failed. Module not loaded",path); + "Module %s initialization failed. Module not loaded", path ? path : "(null)"); if (ctx.module) { moduleUnregisterCleanup(ctx.module); moduleRemoveCateogires(ctx.module);