Skip to content

Commit 8fc750f

Browse files
committed
Fix clang LTO build failure due to LLVM version mismatch
Signed-off-by: Hanxi Zhang <hanxizh@amazon.com>
1 parent 7e10ee7 commit 8fc750f

2 files changed

Lines changed: 6 additions & 9 deletions

File tree

src/Makefile

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -141,12 +141,6 @@ FINAL_LDFLAGS=$(LDFLAGS) $(OPT) $(SERVER_LDFLAGS) $(DEBUG)
141141
FINAL_LIBS=-lm
142142
DEBUG=-g -ggdb
143143

144-
# Use lld when linking with clang to avoid LLVM version mismatches
145-
# between clang and the system's gold plugin during LTO.
146-
ifeq (clang,$(CLANG))
147-
FINAL_LDFLAGS+=-fuse-ld=lld
148-
endif
149-
150144
# Linux ARM32 needs -latomic at linking time
151145
ifneq (,$(findstring armv,$(uname_M)))
152146
FINAL_LIBS+=-latomic
@@ -740,9 +734,14 @@ $(TLS_MODULE_NAME): $(SERVER_NAME)
740734
$(RDMA_MODULE_NAME): $(SERVER_NAME)
741735
$(QUIET_CC)$(CC) $(LDFLAGS) -o $@ rdma.c -shared -fPIC $(RDMA_MODULE_CFLAGS)
742736

737+
# Strip -flto from OPTIMIZATION for the static Lua module build.
738+
# When archiving into a .a, LTO bitcode objects cause linker failures
739+
# if the system's LLVM gold plugin version doesn't match clang's version.
740+
LUA_MODULE_OPTIMIZATION=$(subst -flto,,$(OPTIMIZATION))
741+
743742
# engine_lua.so
744743
$(LUA_MODULE_NAME): .make-prerequisites
745-
$(MAKE) -C modules/lua OPTIMIZATION="$(OPTIMIZATION)" BUILD_LUA="$(BUILD_LUA)"
744+
$(MAKE) -C modules/lua OPTIMIZATION="$(LUA_MODULE_OPTIMIZATION)" BUILD_LUA="$(BUILD_LUA)"
746745

747746
# valkey-cli
748747
$(ENGINE_CLI_NAME): $(ENGINE_CLI_OBJ)

src/modules/lua/Makefile

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ QUIET_LINK_MOD = @printf ' %b %b\n' $(LINKCOLOR_MOD)LINK$(RESET) $(BINCOLOR_M
3232
endif
3333
ifeq (clang,$(CLANG))
3434
SHOBJ_LDFLAGS+= -fuse-ld=lld
35-
# Use llvm-ar for LTO bitcode compatibility when archiving with clang.
36-
AR=llvm-ar
3735
endif
3836

3937
endif

0 commit comments

Comments
 (0)