|
63 | 63 |
|
64 | 64 | ## Preparation |
65 | 65 | # macOS does not have a useful readlink/realpath so we have to use Python instead... |
66 | | -MIRIDIR=$(dirname "$(python3 -c 'import os, sys; print(os.path.realpath(sys.argv[1]))' "$0")") |
| 66 | +MIRIDIR=$(python3 -c 'import os, sys; print(os.path.dirname(os.path.realpath(sys.argv[1])))' "$0") |
67 | 67 | # Determine toolchain *in the Miri dir* and use that. |
68 | 68 | TOOLCHAIN=$(cd "$MIRIDIR"; rustup show active-toolchain | head -n 1 | cut -d ' ' -f 1) |
| 69 | + |
69 | 70 | # Determine some toolchain properties |
70 | 71 | TARGET=$(rustc +$TOOLCHAIN --version --verbose | grep "^host:" | cut -d ' ' -f 2) |
71 | 72 | SYSROOT=$(rustc +$TOOLCHAIN --print sysroot) |
72 | 73 | LIBDIR=$SYSROOT/lib/rustlib/$TARGET/lib |
73 | | - |
74 | 74 | if ! test -d "$LIBDIR"; then |
75 | 75 | echo "Something went wrong determining the library dir." |
76 | 76 | echo "I got $LIBDIR but that does not exist." |
77 | 77 | echo "Please report a bug at https://github.com/rust-lang/miri/issues." |
78 | 78 | exit 2 |
79 | 79 | fi |
80 | 80 |
|
| 81 | +# Prepare flags for cargo and rustc. |
81 | 82 | CARGO="cargo +$TOOLCHAIN" |
82 | 83 | if [ -z "$CARGO_INCREMENTAL" ]; then |
83 | 84 | # Default CARGO_INCREMENTAL to 1. |
|
91 | 92 | # We enable debug-assertions to get tracing. |
92 | 93 | # We enable line-only debuginfo for backtraces. |
93 | 94 | export RUSTFLAGS="-C link-args=-Wl,-rpath,$LIBDIR -C debug-assertions -C debuginfo=1 $RUSTFLAGS" |
| 95 | +# Determine flags passed to all cargo invocations. |
| 96 | +# This is a bit more annoying that one would hope due to |
| 97 | +# <https://github.com/rust-lang/cargo/issues/6992>. |
| 98 | +case "$COMMAND" in |
| 99 | +*-debug) |
| 100 | + CARGO_INSTALL_FLAGS="--target $TARGET --debug $CARGO_EXTRA_FLAGS" |
| 101 | + CARGO_BUILD_FLAGS="--target $TARGET $CARGO_EXTRA_FLAGS" |
| 102 | + ;; |
| 103 | +*) |
| 104 | + CARGO_INSTALL_FLAGS="--target $TARGET $CARGO_EXTRA_FLAGS" |
| 105 | + CARGO_BUILD_FLAGS="--target $TARGET --release $CARGO_EXTRA_FLAGS" |
| 106 | + ;; |
| 107 | +esac |
94 | 108 |
|
95 | 109 | ## Helper functions |
96 | 110 |
|
@@ -119,20 +133,6 @@ find_sysroot() { |
119 | 133 |
|
120 | 134 | ## Main |
121 | 135 |
|
122 | | -# Determine flags passed to all cargo invocations. |
123 | | -# This is a bit more annoying that one would hope due to |
124 | | -# <https://github.com/rust-lang/cargo/issues/6992>. |
125 | | -case "$COMMAND" in |
126 | | -*-debug) |
127 | | - CARGO_INSTALL_FLAGS="--target $TARGET --debug $CARGO_EXTRA_FLAGS" |
128 | | - CARGO_BUILD_FLAGS="--target $TARGET $CARGO_EXTRA_FLAGS" |
129 | | - ;; |
130 | | -*) |
131 | | - CARGO_INSTALL_FLAGS="--target $TARGET $CARGO_EXTRA_FLAGS" |
132 | | - CARGO_BUILD_FLAGS="--target $TARGET --release $CARGO_EXTRA_FLAGS" |
133 | | - ;; |
134 | | -esac |
135 | | - |
136 | 136 | # Run command. |
137 | 137 | case "$COMMAND" in |
138 | 138 | install|install-debug) |
|
0 commit comments