Skip to content

Commit 942c72e

Browse files
committed
auto merge of #15550 : alexcrichton/rust/install-script, r=brson
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. Closes #15545
2 parents 66e1f11 + 6f8b6c8 commit 942c72e

File tree

2 files changed

+85
-56
lines changed

2 files changed

+85
-56
lines changed

src/etc/install.sh

+35-6
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

src/libsyntax/ast.rs

+50-50
Original file line numberDiff line numberDiff line change
@@ -561,56 +561,56 @@ pub enum TokenTree {
561561
TTNonterminal(Span, Ident)
562562
}
563563

564-
/// Matchers are nodes defined-by and recognized-by the main rust parser and
565-
/// language, but they're only ever found inside syntax-extension invocations;
566-
/// indeed, the only thing that ever _activates_ the rules in the rust parser
567-
/// for parsing a matcher is a matcher looking for the 'matchers' nonterminal
568-
/// itself. Matchers represent a small sub-language for pattern-matching
569-
/// token-trees, and are thus primarily used by the macro-defining extension
570-
/// itself.
571-
///
572-
/// MatchTok
573-
/// --------
574-
///
575-
/// A matcher that matches a single token, denoted by the token itself. So
576-
/// long as there's no $ involved.
577-
///
578-
///
579-
/// MatchSeq
580-
/// --------
581-
///
582-
/// A matcher that matches a sequence of sub-matchers, denoted various
583-
/// possible ways:
584-
///
585-
/// $(M)* zero or more Ms
586-
/// $(M)+ one or more Ms
587-
/// $(M),+ one or more comma-separated Ms
588-
/// $(A B C);* zero or more semi-separated 'A B C' seqs
589-
///
590-
///
591-
/// MatchNonterminal
592-
/// -----------------
593-
///
594-
/// A matcher that matches one of a few interesting named rust
595-
/// nonterminals, such as types, expressions, items, or raw token-trees. A
596-
/// black-box matcher on expr, for example, binds an expr to a given ident,
597-
/// and that ident can re-occur as an interpolation in the RHS of a
598-
/// macro-by-example rule. For example:
599-
///
600-
/// $foo:expr => 1 + $foo // interpolate an expr
601-
/// $foo:tt => $foo // interpolate a token-tree
602-
/// $foo:tt => bar! $foo // only other valid interpolation
603-
/// // is in arg position for another
604-
/// // macro
605-
///
606-
/// As a final, horrifying aside, note that macro-by-example's input is
607-
/// also matched by one of these matchers. Holy self-referential! It is matched
608-
/// by a MatchSeq, specifically this one:
609-
///
610-
/// $( $lhs:matchers => $rhs:tt );+
611-
///
612-
/// If you understand that, you have closed the loop and understand the whole
613-
/// macro system. Congratulations.
564+
// Matchers are nodes defined-by and recognized-by the main rust parser and
565+
// language, but they're only ever found inside syntax-extension invocations;
566+
// indeed, the only thing that ever _activates_ the rules in the rust parser
567+
// for parsing a matcher is a matcher looking for the 'matchers' nonterminal
568+
// itself. Matchers represent a small sub-language for pattern-matching
569+
// token-trees, and are thus primarily used by the macro-defining extension
570+
// itself.
571+
//
572+
// MatchTok
573+
// --------
574+
//
575+
// A matcher that matches a single token, denoted by the token itself. So
576+
// long as there's no $ involved.
577+
//
578+
//
579+
// MatchSeq
580+
// --------
581+
//
582+
// A matcher that matches a sequence of sub-matchers, denoted various
583+
// possible ways:
584+
//
585+
// $(M)* zero or more Ms
586+
// $(M)+ one or more Ms
587+
// $(M),+ one or more comma-separated Ms
588+
// $(A B C);* zero or more semi-separated 'A B C' seqs
589+
//
590+
//
591+
// MatchNonterminal
592+
// -----------------
593+
//
594+
// A matcher that matches one of a few interesting named rust
595+
// nonterminals, such as types, expressions, items, or raw token-trees. A
596+
// black-box matcher on expr, for example, binds an expr to a given ident,
597+
// and that ident can re-occur as an interpolation in the RHS of a
598+
// macro-by-example rule. For example:
599+
//
600+
// $foo:expr => 1 + $foo // interpolate an expr
601+
// $foo:tt => $foo // interpolate a token-tree
602+
// $foo:tt => bar! $foo // only other valid interpolation
603+
// // is in arg position for another
604+
// // macro
605+
//
606+
// As a final, horrifying aside, note that macro-by-example's input is
607+
// also matched by one of these matchers. Holy self-referential! It is matched
608+
// by a MatchSeq, specifically this one:
609+
//
610+
// $( $lhs:matchers => $rhs:tt );+
611+
//
612+
// If you understand that, you have closed the loop and understand the whole
613+
// macro system. Congratulations.
614614
pub type Matcher = Spanned<Matcher_>;
615615

616616
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]

0 commit comments

Comments
 (0)