Skip to content

Commit a9f6655

Browse files
committed
Update to so patching for ROCm
Wildcard used in grep to grab the actual numbered so file referenced in patchelf. This allows the removal of specifying the so number in DEPS_LIST & DEPS_SONAME This commit also adds the functionality for trimming so names to build_libtorch.sh from build_common.sh
1 parent 8fc92e6 commit a9f6655

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

manywheel/build_common.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,9 +279,9 @@ replace_needed_sofiles() {
279279
find $1 -name '*.so*' | while read sofile; do
280280
origname=$2
281281
patchedname=$3
282-
if [[ "$origname" != "$patchedname" ]]; then
282+
if [[ "$origname" != "$patchedname" ]] || [[ "$DESIRED_CUDA" == *"rocm"* ]]; then
283283
set +e
284-
$PATCHELF_BIN --print-needed $sofile | grep $origname 2>&1 >/dev/null
284+
origname=$($PATCHELF_BIN --print-needed $sofile | grep "$origname*")
285285
ERRCODE=$?
286286
set -e
287287
if [ "$ERRCODE" -eq "0" ]; then

manywheel/build_libtorch.sh

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,11 @@ fname_with_sha256() {
228228
fi
229229
}
230230

231+
fname_without_so_number() {
232+
LINKNAME=$(echo $1 | sed -e 's/\.so.*/.so/g')
233+
echo "$LINKNAME"
234+
}
235+
231236
make_wheel_record() {
232237
FPATH=$1
233238
if echo $FPATH | grep RECORD >/dev/null 2>&1; then
@@ -277,8 +282,12 @@ for pkg in /$LIBTORCH_HOUSE_DIR/libtorch*.zip; do
277282
if [[ "$filepath" != "$destpath" ]]; then
278283
cp $filepath $destpath
279284
fi
280-
281-
patchedpath=$(fname_with_sha256 $destpath)
285+
286+
if [[ "$DESIRED_CUDA" == *"rocm"* ]]; then
287+
patchedpath=$(fname_without_so_number $destpath)
288+
else
289+
patchedpath=$(fname_with_sha256 $destpath)
290+
fi
282291
patchedname=$(basename $patchedpath)
283292
if [[ "$destpath" != "$patchedpath" ]]; then
284293
mv $destpath $patchedpath
@@ -292,9 +301,9 @@ for pkg in /$LIBTORCH_HOUSE_DIR/libtorch*.zip; do
292301
find $PREFIX -name '*.so*' | while read sofile; do
293302
origname=${DEPS_SONAME[i]}
294303
patchedname=${patched[i]}
295-
if [[ "$origname" != "$patchedname" ]]; then
304+
if [[ "$origname" != "$patchedname" ]] || [[ "$DESIRED_CUDA" == *"rocm"* ]]; then
296305
set +e
297-
$PATCHELF_BIN --print-needed $sofile | grep $origname 2>&1 >/dev/null
306+
origname=$($PATCHELF_BIN --print-needed $sofile | grep "$origname*")
298307
ERRCODE=$?
299308
set -e
300309
if [ "$ERRCODE" -eq "0" ]; then

0 commit comments

Comments
 (0)