toolchain: link ldd when using external toolchain
authorArien Judge <arienjudge@outlook.com>
Fri, 13 Oct 2023 09:58:16 +0000 (20:58 +1100)
committerChristian Marangi <ansuelsmth@gmail.com>
Fri, 20 Oct 2023 16:55:55 +0000 (18:55 +0200)
When using an external toolchain, ldd is not linked into the rootfs.
This causes subsequent upgrades to fail with 'Failed to exec upgraded'.
This patch adds the symlink when using an external toolchain and musl.

Signed-off-by: Arien Judge <arienjudge@outlook.com>
package/libs/toolchain/Makefile

index f44536144df29084acc4f0d64a707daa1b433c94..ea36af5da44a67e644c2bcc272ffd6bfc6572ec7 100644 (file)
@@ -655,12 +655,23 @@ else
        exit 0
   endef
 
+  define Package/glibc/install
+  endef
+
+  LD_MUSL_NAME = $(notdir $(firstword $(wildcard $(TOOLCHAIN_ROOT_DIR)/lib/libc.so*)))
+
+  define Package/musl/install
+       $(INSTALL_DIR) $(1)/usr/bin
+       $(LN) ../../lib/$(LD_MUSL_NAME) $(1)/usr/bin/ldd
+  endef
+
   define Package/libc/install
        for file in $(call qstrip,$(CONFIG_LIBC_FILE_SPEC)); do \
                $(INSTALL_DIR) $(1)/lib ; \
                $(CP) $(call qstrip,$(CONFIG_LIBC_ROOT_DIR))/$$$$file $(1)/lib/ ; \
        done ; \
        exit 0
+       $(call Package/$(LIBC)/install,$1)
   endef
 
   define Package/libpthread/install