Skip to content

Commit b1e39bc

Browse files
staticfloatKeno
authored andcommitted
Eliminate erroneous quoting on ${PATCHELF} (#34377)
* Eliminate erroneous quoting on `${PATCHELF}` This only manifests on platforms like `aarch64` and `ppc64le` because we force extra arguments to `PATCHELF` in these cases which didn't interact well with these well-meaning quotes. * patchelf doesn't parse `--arg=val` properly * `debug` output should not be captured by `$()` * Quoting, permissions, and debugging fixes. All of my favorite things in one place!
1 parent 0ee3264 commit b1e39bc

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

Make.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -940,7 +940,7 @@ endif
940940
# explicitly tell it to use this large page size so that when we rewrite rpaths and
941941
# such, we don't accidentally create incorrectly-aligned sections in our ELF files.
942942
ifneq (,$(filter $(ARCH),aarch64 powerpc64le))
943-
PATCHELF += --page-size=65536
943+
PATCHELF += --page-size 65536
944944
endif
945945

946946
# Use ILP64 BLAS interface when building openblas from source on 64-bit architectures

contrib/fixup-libgfortran.sh

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ PATCHELF=${PATCHELF:-patchelf}
88
# If we're invoked with "--verbose", create a `debug` function that prints stuff out
99
if [ "$1" = "--verbose" ] || [ "$1" = "-v" ]; then
1010
shift 1
11-
debug() { echo "$*"; }
11+
debug() { echo "$*" >&2; }
1212
else
1313
debug() { :; }
1414
fi
@@ -36,9 +36,9 @@ find_shlib()
3636
lib_path="$1"
3737
if [ -f "$lib_path" ]; then
3838
if [ "$UNAME" = "Linux" ]; then
39-
"${PATCHELF}" --print-needed "$lib_path" | grep $2 | xargs
39+
${PATCHELF} --print-needed "$lib_path" | grep "$2" | xargs
4040
else # $UNAME is "Darwin", we only have two options, see above
41-
otool -L "$lib_path" | grep $2 | cut -d' ' -f1 | xargs
41+
otool -L "$lib_path" | grep "$2" | cut -d' ' -f1 | xargs
4242
fi
4343
fi
4444
}
@@ -50,7 +50,7 @@ find_shlib_dir()
5050
# only get something like `@rpath/libgfortran.5.dylib` when inspecting the
5151
# libraries. We can, as a last resort, ask `$FC` directly what the full
5252
# filepath for this library is, but only if we don't have a direct path to it:
53-
if [ $(dirname "$1") = "@rpath" ] || [ $(dirname "$1") = "." ]; then
53+
if [ "$(dirname "$1")" = "@rpath" ] || [ "$(dirname "$1")" = "." ]; then
5454
dirname "$($FC -print-file-name="$(basename "$1")" 2>/dev/null)"
5555
else
5656
dirname "$1" 2>/dev/null
@@ -104,6 +104,7 @@ for soname in $SONAMES; do
104104
cp -v "$dir/$soname" "$private_libdir"
105105
chmod 755 "$private_libdir/$soname"
106106
if [ "$UNAME" = "Darwin" ]; then
107+
debug "Rewriting identity of ${private_libdir}/${soname} to @rpath/${soname}"
107108
install_name_tool -id "@rpath/$soname" "$private_libdir/$soname"
108109
fi
109110
fi
@@ -149,6 +150,7 @@ for lib in libopenblas libcholmod liblapack $SONAMES; do
149150
# Iterate over dependency names that need to be changed
150151
for soname in $SONAMES; do
151152
debug "changing linkage of $lib_path to $soname"
153+
chmod 755 "$lib_path"
152154
change_linkage "$lib_path" "$soname"
153155
done
154156
done

0 commit comments

Comments
 (0)