about summary refs log tree commit diff
path: root/pkgs/games/build-support
diff options
context:
space:
mode:
authoraszlig <aszlig@nix.build>2018-02-01 21:17:04 +0100
committeraszlig <aszlig@nix.build>2018-02-01 22:28:26 +0100
commit4af374e2c191465de99d4169376e1a9430302e82 (patch)
tree16b0dd4521a1ede5e380cf7d768e8fe835ebd719 /pkgs/games/build-support
parent9dc27c57880db6469865dc2e6aaf295665c681a3 (diff)
auto-patchelf: Only search for deps with same arch
So far we only matched the file name of the dependency but not its
architecture, so if for example there is one shared object for
i686-linux and another one with the same name but for x86_64-linux,
chances are that the wrong architecture is chosen.

Now we're checking the architecture of the shared object file and only
pick it, if it matches the architecture of the file to patchelf.

Signed-off-by: aszlig <aszlig@nix.build>
Diffstat (limited to 'pkgs/games/build-support')
-rw-r--r--pkgs/games/build-support/setup-hooks/auto-patchelf.sh15
1 files changed, 11 insertions, 4 deletions
diff --git a/pkgs/games/build-support/setup-hooks/auto-patchelf.sh b/pkgs/games/build-support/setup-hooks/auto-patchelf.sh
index 99ce3be4..e24e278f 100644
--- a/pkgs/games/build-support/setup-hooks/auto-patchelf.sh
+++ b/pkgs/games/build-support/setup-hooks/auto-patchelf.sh
@@ -62,8 +62,13 @@ populateCacheWithRecursiveDeps() {
     done
 }
 
+getSoArch() {
+    objdump -f "$1" | sed -ne 's/^architecture: *\([^,]\+\).*/\1/p'
+}
+
 findDependency() {
     local filename="$1"
+    local arch="$2"
     local lib dep
 
     if [ $depCacheInitialised -eq 0 ]; then
@@ -75,15 +80,17 @@ findDependency() {
 
     for dep in "${cachedDependencies[@]}"; do
         if [ "$filename" = "${dep##*/}" ]; then
-            foundDependency="$dep"
-            return 0
+            if [ "$(getSoArch "$dep")" = "$arch" ]; then
+                foundDependency="$dep"
+                return 0
+            fi
         fi
     done
 
     if [ $doneRecursiveSearch -eq 0 ]; then
         populateCacheWithRecursiveDeps
         doneRecursiveSearch=1
-        findDependency "$filename" || return 1
+        findDependency "$filename" "$arch" || return 1
         return 0
     fi
     return 1
@@ -113,7 +120,7 @@ autoPatchelfFile() {
 
     for dep in $missing; do
         echo -n "  $dep -> " >&2
-        if findDependency "$dep"; then
+        if findDependency "$dep" "$(getSoArch "$toPatch")"; then
             rpath="$rpath${rpath:+:}${foundDependency%/*}"
             echo "found: $foundDependency" >&2
         else