summary refs log tree commit diff
path: root/pkgs/development/tools/misc/patchelf/setup-hook.sh
blob: 03b6f362a779e281bd8440c43f61f0b5ee5d180a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# This setup hook calls patchelf to automatically remove unneeded
# directories from the RPATH of every library or executable in every
# output.

fixupOutputHooks+=('if [ -z "$dontPatchELF" ]; then patchELF "$prefix"; fi')

patchELF() {
    header "shrinking RPATHs of ELF executables and libraries in $prefix"

    local i
    while IFS= read -r -d $'\0' i; do
        if [[ "$i" =~ .build-id ]]; then continue; fi
        if ! isELF "$i"; then continue; fi
        echo "shrinking $i"
        patchelf --shrink-rpath "$i" || true
    done < <(find "$prefix" -type f -print0)

    stopNest
}