autoPatchelfHook: do not patch statically linked files
Also speed up quite significantly due less forking.
This commit is contained in:
@@ -7,21 +7,7 @@ gatherLibraries() {
|
|||||||
addEnvHooks "$targetOffset" gatherLibraries
|
addEnvHooks "$targetOffset" gatherLibraries
|
||||||
|
|
||||||
isExecutable() {
|
isExecutable() {
|
||||||
[ "$(file -b -N --mime-type "$1")" = application/x-executable ]
|
readelf -h "$1" | grep -q '^ *Type: *EXEC\>'
|
||||||
}
|
|
||||||
|
|
||||||
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
|
|
||||||
' -- {} +
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# We cache dependencies so that we don't need to search through all of them on
|
# 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
|
# findDependency outside of this, the dependency cache needs to be rebuilt
|
||||||
# from scratch, so keep this in mind if you want to run findDependency
|
# from scratch, so keep this in mind if you want to run findDependency
|
||||||
# outside of this function.
|
# outside of this function.
|
||||||
findElfs "$prefix" | while read -r elffile; do
|
while IFS= read -r -d $'\0' file; do
|
||||||
autoPatchelfFile "$elffile"
|
isELF "$file" || continue
|
||||||
done
|
# 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
|
# XXX: This should ultimately use fixupOutputHooks but we currently don't have
|
||||||
|
|||||||
@@ -81,8 +81,7 @@ with pkgs;
|
|||||||
{ deps = [ autoconf264 automake111x gettext libtool ]; }
|
{ deps = [ autoconf264 automake111x gettext libtool ]; }
|
||||||
../build-support/setup-hooks/autoreconf.sh;
|
../build-support/setup-hooks/autoreconf.sh;
|
||||||
|
|
||||||
autoPatchelfHook = makeSetupHook
|
autoPatchelfHook = makeSetupHook { name = "auto-patchelf-hook"; }
|
||||||
{ name = "auto-patchelf-hook"; deps = [ file ]; }
|
|
||||||
../build-support/setup-hooks/auto-patchelf.sh;
|
../build-support/setup-hooks/auto-patchelf.sh;
|
||||||
|
|
||||||
ensureNewerSourcesHook = { year }: makeSetupHook {}
|
ensureNewerSourcesHook = { year }: makeSetupHook {}
|
||||||
|
|||||||
Reference in New Issue
Block a user