Last active
September 30, 2025 21:25
-
-
Save ormaaj/844d028f681fcd9c825cf78c6592d646 to your computer and use it in GitHub Desktop.
ld xattr hooks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| post_src_install() { | |
| local -; set +o monitor -o pipefail | |
| typeset k e r=${EROOT%%+(/)} cpn=${CATEGORY}/${PN} | |
| e=${r:+${r}/}${ED%%+(/)} | |
| typeset -A base=( | |
| [sys-devel/binutils]=bfd | |
| [sys-devel/mold]=mold | |
| [llvm-core/lld]=lld | |
| ) | |
| typeset -A xattr=( | |
| [user.ld]=ld.${base[$cpn]} | |
| [user.ctarget]=${CTARGET:-$CHOST} | |
| [user.gentoo-package]=$cpn | |
| ) | |
| typeset -A target=( | |
| [sys-devel/binutils]=${e}/usr/${CTARGET:-${CHOST}}/${PN}-bin/${PV} | |
| [sys-devel/mold]=${e}/usr/bin | |
| [llvm-core/lld]=${e}/usr/lib/llvm/${LLVM_MAJOR:-${SLOT}}/bin | |
| ) | |
| [[ -e ${target[$cpn]}/${xattr[user.ld]} ]] || die | |
| case $cpn in | |
| llvm-core/lld) | |
| ln -nfv -- "${target[$cpn]}/ld"{.lld,} | einfo "$(</proc/self/fd/0)" || die # hardlink ld to ld.lld | |
| ln -snv -- ld.lld "${target[$cpn]}/${xattr[user.ctarget]}-${xattr[user.ld]}" | einfo "$(</proc/self/fd/0)" || die # add ${CHOST}-ld.lld symlink | |
| esac | |
| einfo "Adding xattrs for ${base[$cpn]}..." | |
| for k in "${!xattr[@]}"; do | |
| einfo "${| printf -v REPLY '%s=%q => %#q' "$k" "${xattr[$k]}" "${target[$cpn]}/${xattr[user.ld]}"; }" | |
| setfattr --raw -n "$k" -v "${xattr[$k]}" -- "${target[$cpn]}/${xattr[user.ld]}" || die | |
| done | |
| } | |
| # vim: set ft=bash fenc=utf-8 ff=unix ts=4 noet : |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment