Skip to content

Commit c460d38

Browse files
committed
etc: Fix install script for rpath removal
This adds detection of the relevant LD_LIBRARY_PATH-like environment variable and appropriately sets it when testing whether binaries can run or not. Additionally, the installation prints a recommended value if one is necessary.
1 parent 8ddd286 commit c460d38

File tree

1 file changed

+35
-6
lines changed

1 file changed

+35
-6
lines changed

src/etc/install.sh

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,19 @@ then
285285
CFG_LIBDIR_RELATIVE=bin
286286
fi
287287

288+
if [ "$CFG_OSTYPE" = "pc-mingw32" ] || [ "$CFG_OSTYPE" = "w64-mingw32" ]
289+
then
290+
CFG_LD_PATH_VAR=PATH
291+
CFG_OLD_LD_PATH_VAR=$PATH
292+
elif [ "$CFG_OSTYPE" = "Darwin" ]
293+
then
294+
CFG_LD_PATH_VAR=DYLD_LIBRARY_PATH
295+
CFG_OLD_LD_PATH_VAR=$DYLD_LIBRARY_PATH
296+
else
297+
CFG_LD_PATH_VAR=LD_LIBRARY_PATH
298+
CFG_OLD_LD_PATH_VAR=$LD_LIBRARY_PATH
299+
fi
300+
288301
flag uninstall "only uninstall from the installation prefix"
289302
opt verify 1 "verify that the installed binaries run correctly"
290303
valopt prefix "/usr/local" "set installation prefix"
@@ -312,11 +325,13 @@ then
312325
if [ -z "${CFG_UNINSTALL}" ]
313326
then
314327
msg "verifying platform can run binaries"
328+
export $CFG_LD_PATH_VAR="${CFG_SRC_DIR}/lib":$CFG_OLD_LD_PATH_VAR
315329
"${CFG_SRC_DIR}/bin/rustc" --version > /dev/null
316330
if [ $? -ne 0 ]
317331
then
318332
err "can't execute rustc binary on this platform"
319333
fi
334+
export $CFG_LD_PATH_VAR=$CFG_OLD_LD_PATH_VAR
320335
fi
321336
fi
322337

@@ -452,17 +467,31 @@ while read p; do
452467
done < "${CFG_SRC_DIR}/${CFG_LIBDIR_RELATIVE}/rustlib/manifest.in"
453468

454469
# Sanity check: can we run the installed binaries?
470+
#
471+
# As with the verification above, make sure the right LD_LIBRARY_PATH-equivalent
472+
# is in place. Try first without this variable, and if that fails try again with
473+
# the variable. If the second time tries, print a hopefully helpful message to
474+
# add something to the appropriate environment variable.
455475
if [ -z "${CFG_DISABLE_VERIFY}" ]
456476
then
457477
msg "verifying installed binaries are executable"
458-
"${CFG_PREFIX}/bin/rustc" --version > /dev/null
478+
"${CFG_PREFIX}/bin/rustc" --version 2> /dev/null 1> /dev/null
459479
if [ $? -ne 0 ]
460480
then
461-
ERR="can't execute installed rustc binary. "
462-
ERR="${ERR}installation may be broken. "
463-
ERR="${ERR}if this is expected then rerun install.sh with \`--disable-verify\` "
464-
ERR="${ERR}or \`make install\` with \`--disable-verify-install\`"
465-
err "${ERR}"
481+
export $CFG_LD_PATH_VAR="${CFG_PREFIX}/lib":$CFG_OLD_LD_PATH_VAR
482+
"${CFG_PREFIX}/bin/rustc" --version > /dev/null
483+
if [ $? -ne 0 ]
484+
then
485+
ERR="can't execute installed rustc binary. "
486+
ERR="${ERR}installation may be broken. "
487+
ERR="${ERR}if this is expected then rerun install.sh with \`--disable-verify\` "
488+
ERR="${ERR}or \`make install\` with \`--disable-verify-install\`"
489+
err "${ERR}"
490+
else
491+
echo
492+
echo " please ensure '${CFG_PREFIX}/lib' is added to ${CFG_LD_PATH_VAR}"
493+
echo
494+
fi
466495
fi
467496
fi
468497

0 commit comments

Comments
 (0)