]> git.ipfire.org Git - thirdparty/openwrt.git/commitdiff
package: binutils: deduplicate ld 21997/head
authorKonstantin Demin <rockdrilla@gmail.com>
Fri, 17 Apr 2026 20:47:11 +0000 (23:47 +0300)
committerNick Hainke <vincent@systemli.org>
Sat, 18 Apr 2026 17:34:21 +0000 (19:34 +0200)
ld.bfd is the default/only implementation for now but things may change in future.

Signed-off-by: Konstantin Demin <rockdrilla@gmail.com>
Link: https://github.com/openwrt/openwrt/pull/21997
Signed-off-by: Nick Hainke <vincent@systemli.org>
package/devel/binutils/Makefile

index 54b2ae8c8c112b34ae7fac6ce09bd65b25e7f16d..8bd62d0f9b1d56dad19418249030602fb7fbd5d6 100644 (file)
@@ -169,6 +169,23 @@ define Package/binutils/install
        mv $(1)/usr/bin/strings $(1)/usr/bin/binutils-strings
        rm -f $(1)/usr/bin/objdump
        rm -f $(1)/usr/bin/ar
+
+       : # deduplicate "/usr/bin/ld.*":
+       : # "ld.bfd" is the implementation, "ld" is the variant selector,
+       : # so the link should be "ld" -> "ld.bfd"
+       _ld='$(1)/usr/bin/ld'; \
+       [ -f "$$$${_ld}" ] || exit 0; \
+       find "$$$${_ld%/*}/" -follow -name "$$$${_ld##*/}*" -type f \
+       | grep -Fxv -e "$$$${_ld}" | sort -V \
+       | while read -r _ld_variant; do \
+               cmp -s "$$$${_ld}" "$$$${_ld_variant}" || continue; \
+               cp -L "$$$${_ld_variant}" "$$$${_ld_variant}.new"; \
+               rm -f "$$$${_ld_variant}"; \
+               mv "$$$${_ld_variant}.new" "$$$${_ld_variant}"; \
+               rm -f "$$$${_ld}"; \
+               ln -s "$$$${_ld_variant##*/}" "$$$${_ld}"; \
+               break; \
+       done
 endef
 
 $(eval $(call BuildPackage,libbfd))