Skip to contentSkip to conversation

package/redis: fix static linking with libatomic

PATCH New Bernd Kuhls 3 participants 3 messages May 25, 2017 – Jun 1, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 package/redis: fix static linking with libatomic

Fixes
http://autobuild.buildroot.net/results/7f1/7f1ecccbfdb6bd95824d9c884f1577e71e0e1e09/
http://autobuild.buildroot.net/results/c0b/c0b1bdcc5fbddf8b996b923015184d753882d4b8/

---
 package/redis/redis.mk | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
package/redis/redis.mk +7 -1
index 3f4956cf3..2a5012812 100644
@@ -14,8 +14,14 @@ define REDIS_USERS
 endef
 
 # Uses __atomic_fetch_add_4
+# src/Makefile contains a wrong linking order which breaks linking
+# for static builds. 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
Signature · 1 line
2.11.0
#1 lore raw

PATCH 1/1 package/redis: fix static linking with libatomic

Hello,

package/redis/redis.mk define REDIS_USERS · line 18

Quoted 3 lines · Bernd Kuhls

# Uses __atomic_fetch_add_4

package/redis/redis.mk +2 -0
+# src/Makefile contains a wrong linking order which breaks linking
+# for static builds. We need to add -latomic to FINAL_LIBS to provide

The Makefile doesn't really contain a "wrong linking" order, it's simply that LDFLAGS are used before the list of object files. So I've reworded a bit the comment here.

package/redis/redis.mk define REDIS_USERS · line 18

Quoted 3 lines
package/redis/redis.mk +1 -1
+# -latomic at the correct place in the linking command.
 ifeq ($(BR2_TOOLCHAIN_HAS_LIBATOMIC),y)
-REDIS_LIBATOMIC = -latomic

You forgot to adjust the place where REDIS_LIBATOMIC was used, so I've adjusted that as well.

Applied to master with those two issues fixed.

Could you submit a patch upstream that adds something like EXTRA_FINAL_LIBS:

FINAL_LIBS = -lm $(EXTRA_FINAL_LIBS)

This way we could nicely pass it from the environment.

Thanks!

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
#2 lore raw

PATCH 1/1 package/redis: fix static linking with libatomic

In reply to Bernd Kuhls
Quoted 7 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Bernd" == Bernd Kuhls <[email protected]> writes:

Fixes
http://autobuild.buildroot.net/results/7f1/7f1ecccbfdb6bd95824d9c884f1577e71e0e1e09/
http://autobuild.buildroot.net/results/c0b/c0b1bdcc5fbddf8b996b923015184d753882d4b8/

Committed to 2017.02.x, thanks.

Signature · 1 line
Bye, Peter Korsgaard