From da4b883580906ca24d35b905295e319b820a7bea Mon Sep 17 00:00:00 2001 From: Hanxi Zhang Date: Thu, 23 Apr 2026 17:52:43 -0700 Subject: [PATCH 1/3] Reverts the clang-17 pin, strip LTO flags from static Lua module build Signed-off-by: Hanxi Zhang --- src/Makefile | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Makefile b/src/Makefile index 0560c13d988..7000d94d45a 100644 --- a/src/Makefile +++ b/src/Makefile @@ -734,9 +734,14 @@ $(TLS_MODULE_NAME): $(SERVER_NAME) $(RDMA_MODULE_NAME): $(SERVER_NAME) $(QUIET_CC)$(CC) $(LDFLAGS) -o $@ rdma.c -shared -fPIC $(RDMA_MODULE_CFLAGS) +# Strip LTO flags from OPTIMIZATION for the static Lua module build. +# When archiving into a .a, LTO bitcode objects cause linker failures +# if the system's LLVM gold plugin version doesn't match clang's version. +LUA_MODULE_OPTIMIZATION=$(subst -flto,,$(subst -ffat-lto-objects,,$(subst -flto=auto,,$(OPTIMIZATION)))) + # engine_lua.so $(LUA_MODULE_NAME): .make-prerequisites - $(MAKE) -C modules/lua OPTIMIZATION="$(OPTIMIZATION)" BUILD_LUA="$(BUILD_LUA)" + $(MAKE) -C modules/lua OPTIMIZATION="$(LUA_MODULE_OPTIMIZATION)" BUILD_LUA="$(BUILD_LUA)" # valkey-cli $(ENGINE_CLI_NAME): $(ENGINE_CLI_OBJ) From 2039bf0ce1c19baec40c71aa008d36ad32db05e7 Mon Sep 17 00:00:00 2001 From: Hanxi Zhang Date: Fri, 24 Apr 2026 12:57:05 -0700 Subject: [PATCH 2/3] Move LTO flag stripping into the Lua module Makefile Signed-off-by: Hanxi Zhang --- src/Makefile | 7 +------ src/modules/lua/Makefile | 4 ++++ 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/Makefile b/src/Makefile index 7000d94d45a..0560c13d988 100644 --- a/src/Makefile +++ b/src/Makefile @@ -734,14 +734,9 @@ $(TLS_MODULE_NAME): $(SERVER_NAME) $(RDMA_MODULE_NAME): $(SERVER_NAME) $(QUIET_CC)$(CC) $(LDFLAGS) -o $@ rdma.c -shared -fPIC $(RDMA_MODULE_CFLAGS) -# Strip LTO flags from OPTIMIZATION for the static Lua module build. -# When archiving into a .a, LTO bitcode objects cause linker failures -# if the system's LLVM gold plugin version doesn't match clang's version. -LUA_MODULE_OPTIMIZATION=$(subst -flto,,$(subst -ffat-lto-objects,,$(subst -flto=auto,,$(OPTIMIZATION)))) - # engine_lua.so $(LUA_MODULE_NAME): .make-prerequisites - $(MAKE) -C modules/lua OPTIMIZATION="$(LUA_MODULE_OPTIMIZATION)" BUILD_LUA="$(BUILD_LUA)" + $(MAKE) -C modules/lua OPTIMIZATION="$(OPTIMIZATION)" BUILD_LUA="$(BUILD_LUA)" # valkey-cli $(ENGINE_CLI_NAME): $(ENGINE_CLI_OBJ) diff --git a/src/modules/lua/Makefile b/src/modules/lua/Makefile index 8f534a51b48..84d33ff4b84 100644 --- a/src/modules/lua/Makefile +++ b/src/modules/lua/Makefile @@ -9,6 +9,10 @@ ifeq ($(BUILD_LUA),module) else STATIC_LUA_FLAG=-DSTATIC_LUA=1 LUA_TARGET=libvalkeylua.a + # Strip LTO flags for the static build. When archiving into a .a, + # LTO bitcode objects cause linker failures if the system linker + # cannot read them. + OPTIMIZATION:=$(subst -flto,,$(subst -ffat-lto-objects,,$(subst -flto=auto,,$(OPTIMIZATION)))) endif ifeq ($(uname_S),Darwin) From caf189a72d546bc4b056677855b24ea2c19561dc Mon Sep 17 00:00:00 2001 From: Hanxi Zhang Date: Fri, 24 Apr 2026 13:31:13 -0700 Subject: [PATCH 3/3] Override the original command-line variable Signed-off-by: Hanxi Zhang --- src/modules/lua/Makefile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/modules/lua/Makefile b/src/modules/lua/Makefile index 84d33ff4b84..5754ff32358 100644 --- a/src/modules/lua/Makefile +++ b/src/modules/lua/Makefile @@ -11,8 +11,9 @@ else LUA_TARGET=libvalkeylua.a # Strip LTO flags for the static build. When archiving into a .a, # LTO bitcode objects cause linker failures if the system linker - # cannot read them. - OPTIMIZATION:=$(subst -flto,,$(subst -ffat-lto-objects,,$(subst -flto=auto,,$(OPTIMIZATION)))) + # cannot read them. Use 'override' because OPTIMIZATION is passed + # as a command-line variable from the parent Makefile. + override OPTIMIZATION:=$(subst -flto,,$(subst -ffat-lto-objects,,$(subst -flto=auto,,$(OPTIMIZATION)))) endif ifeq ($(uname_S),Darwin)