redis -1 redis -1 * /var/lib/redis /bin/false - Redis Server
endef
-# Uses __atomic_fetch_add_4
+# Uses __atomic_fetch_add_4. Adding -latomic to LDFLAGS does not work,
+# because LDFLAGS is used before the list of object files. We need to
+# add -latomic to FINAL_LIBS to provide -latomic at the correct place
+# in the linking command.
ifeq ($(BR2_TOOLCHAIN_HAS_LIBATOMIC),y)
-REDIS_LIBATOMIC = -latomic
+define REDIS_FIX_MAKEFILE
+ $(SED) 's/FINAL_LIBS=-lm/FINAL_LIBS=-lm -latomic/' $(@D)/src/Makefile
+endef
+REDIS_POST_PATCH_HOOKS = REDIS_FIX_MAKEFILE
endif
# Redis doesn't support DESTDIR (yet, see
# https://github.com/antirez/redis/pull/609). We set PREFIX
# instead.
REDIS_BUILDOPTS = $(TARGET_CONFIGURE_OPTS) \
- LDFLAGS="$(TARGET_LDFLAGS) $(REDIS_LIBATOMIC)" \
PREFIX=$(TARGET_DIR)/usr MALLOC=libc
define REDIS_BUILD_CMDS