1
1

package: binutils: deduplicate ld

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>
This commit is contained in:
Konstantin Demin 2026-04-17 23:47:11 +03:00 committed by Nick Hainke
parent 68ef220f34
commit d43c458e02

View 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))