diff options
author | Jörg Thalheim <joerg@thalheim.io> | 2018-09-23 14:45:32 +0100 |
---|---|---|
committer | Jörg Thalheim <joerg@thalheim.io> | 2018-09-23 21:33:43 +0100 |
commit | 58a97dfb491be6ae92499c3f819440f281d826a1 (patch) | |
tree | b0a6df656229d3e713d76e865141877f82a536c8 /pkgs/build-support/setup-hooks | |
parent | ef764eb0d8314b81a012dae04642b4766199956d (diff) | |
download | nixlib-58a97dfb491be6ae92499c3f819440f281d826a1.tar nixlib-58a97dfb491be6ae92499c3f819440f281d826a1.tar.gz nixlib-58a97dfb491be6ae92499c3f819440f281d826a1.tar.bz2 nixlib-58a97dfb491be6ae92499c3f819440f281d826a1.tar.lz nixlib-58a97dfb491be6ae92499c3f819440f281d826a1.tar.xz nixlib-58a97dfb491be6ae92499c3f819440f281d826a1.tar.zst nixlib-58a97dfb491be6ae92499c3f819440f281d826a1.zip |
autoPatchelfHook: do not patch statically linked files
Also speed up quite significantly due less forking.
Diffstat (limited to 'pkgs/build-support/setup-hooks')
-rw-r--r-- | pkgs/build-support/setup-hooks/auto-patchelf.sh | 25 |
1 files changed, 7 insertions, 18 deletions
diff --git a/pkgs/build-support/setup-hooks/auto-patchelf.sh b/pkgs/build-support/setup-hooks/auto-patchelf.sh index 32fdb1000e27..94ea3e4e98e3 100644 --- a/pkgs/build-support/setup-hooks/auto-patchelf.sh +++ b/pkgs/build-support/setup-hooks/auto-patchelf.sh @@ -7,21 +7,7 @@ gatherLibraries() { addEnvHooks "$targetOffset" gatherLibraries isExecutable() { - [ "$(file -b -N --mime-type "$1")" = application/x-executable ] -} - -findElfs() { - find "$1" -type f -exec "$SHELL" -c ' - while [ -n "$1" ]; do - mimeType="$(file -b -N --mime-type "$1")" - if [ "$mimeType" = application/x-executable \ - -o "$mimeType" = application/x-pie-executable \ - -o "$mimeType" = application/x-sharedlib ]; then - echo "$1" - fi - shift - done - ' -- {} + + readelf -h "$1" | grep -q '^ *Type: *EXEC\>' } # We cache dependencies so that we don't need to search through all of them on @@ -167,9 +153,12 @@ autoPatchelf() { # findDependency outside of this, the dependency cache needs to be rebuilt # from scratch, so keep this in mind if you want to run findDependency # outside of this function. - findElfs "$prefix" | while read -r elffile; do - autoPatchelfFile "$elffile" - done + while IFS= read -r -d $'\0' file; do + isELF "$file" || continue + # dynamically linked? + readelf -l "$file" | grep -q "^ *INTERP\\>" || continue + autoPatchelfFile "$file" + done < <(find "$prefix" -type f -print0) } # XXX: This should ultimately use fixupOutputHooks but we currently don't have |