Skip to content

Commit fa7811b

Browse files
committed
use the cargo default for debug/release builds
1 parent 5d5999a commit fa7811b

File tree

2 files changed

+27
-49
lines changed

2 files changed

+27
-49
lines changed

ci.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ set -euo pipefail
33
set -x
44

55
# Determine configuration
6-
export RUSTFLAGS="-D warnings -C debug-assertions -C debuginfo=1"
6+
export RUSTFLAGS="-D warnings"
77
export CARGO_INCREMENTAL=0
88
export CARGO_EXTRA_FLAGS="--all-features"
99

1010
# Prepare
1111
echo "Build and install miri"
12-
RUSTFLAGS="" ./miri install # implicitly locked, and explicitly without debug assertions
12+
./miri install # implicitly locked
1313
./miri build --all-targets --locked # the build that all the `./miri test` below will use
1414
echo
1515

miri

Lines changed: 25 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ USAGE=$(cat <<"EOF"
66
./miri install <flags>:
77
Installs the miri driver and cargo-miri. <flags> are passed to `cargo
88
install`. Sets up the rpath such that the installed binary should work in any
9-
working directory.
9+
working directory. However, the rustup toolchain when invoking `cargo miri`
10+
needs to be the same one used for `./miri install`.
1011
1112
./miri build <flags>:
1213
Just build miri. <flags> are passed to `cargo build`.
@@ -22,10 +23,6 @@ to the final `cargo test` invocation.
2223
Build miri, set up a sysroot and then run the driver with the given <flags>.
2324
(Also respects MIRIFLAGS environment variable.)
2425
25-
The commands above also exist in a "-debug" variant (e.g. "./miri run-debug
26-
<flags>") which uses debug builds instead of release builds, for faster build
27-
times and slower execution times.
28-
2926
./miri fmt <flags>:
3027
Format all sources and tests. <flags> are passed to `rustfmt`.
3128
@@ -99,38 +96,21 @@ fi
9996

10097
# Prepare flags for cargo and rustc.
10198
CARGO="cargo +$TOOLCHAIN"
102-
if [ -z "$CARGO_INCREMENTAL" ]; then
103-
# Default CARGO_INCREMENTAL to 1.
104-
export CARGO_INCREMENTAL=1
105-
fi
10699
if [ -z "$CARGO_TARGET_DIR" ]; then
107100
# Share target dir between `miri` and `cargo-miri`.
108101
export CARGO_TARGET_DIR="$MIRIDIR/target"
109102
fi
110103
# We set the rpath so that Miri finds the private rustc libraries it needs.
111104
export RUSTFLAGS="-C link-args=-Wl,-rpath,$LIBDIR $RUSTFLAGS"
112-
# Determine flags passed to all cargo invocations.
113-
# This is a bit more annoying that one would hope due to
114-
# <https://github.com/rust-lang/cargo/issues/6992>.
115-
case "$COMMAND" in
116-
*-debug)
117-
CARGO_INSTALL_FLAGS="--target $TARGET --debug $CARGO_EXTRA_FLAGS"
118-
CARGO_BUILD_FLAGS="--target $TARGET $CARGO_EXTRA_FLAGS"
119-
;;
120-
*)
121-
CARGO_INSTALL_FLAGS="--target $TARGET $CARGO_EXTRA_FLAGS"
122-
CARGO_BUILD_FLAGS="--target $TARGET --release $CARGO_EXTRA_FLAGS"
123-
;;
124-
esac
125105

126106
## Helper functions
127107

128108
# Build a sysroot and set MIRI_SYSROOT to use it. Arguments are passed to `cargo miri setup`.
129109
build_sysroot() {
130110
# Build once, for the user to see.
131-
$CARGO run $CARGO_BUILD_FLAGS --manifest-path "$MIRIDIR"/cargo-miri/Cargo.toml -- miri setup "$@"
111+
$CARGO run $CARGO_EXTRA_FLAGS --manifest-path "$MIRIDIR"/cargo-miri/Cargo.toml -- miri setup "$@"
132112
# Call again, to just set env var.
133-
export MIRI_SYSROOT="$($CARGO run $CARGO_BUILD_FLAGS --manifest-path "$MIRIDIR"/cargo-miri/Cargo.toml -q -- miri setup --print-sysroot "$@")"
113+
export MIRI_SYSROOT="$($CARGO run $CARGO_EXTRA_FLAGS --manifest-path "$MIRIDIR"/cargo-miri/Cargo.toml -q -- miri setup --print-sysroot "$@")"
134114
}
135115

136116
# Prepare and set MIRI_SYSROOT. Respects `MIRI_TEST_TARGET` and takes into account
@@ -152,37 +132,35 @@ find_sysroot() {
152132

153133
# Run command.
154134
case "$COMMAND" in
155-
install|install-debug)
135+
install)
156136
# "--locked" to respect the Cargo.lock file if it exists,
157137
# "--offline" to avoid querying the registry (for yanked packages).
158-
$CARGO install $CARGO_INSTALL_FLAGS --path "$MIRIDIR" --force --locked --offline "$@"
159-
$CARGO install $CARGO_INSTALL_FLAGS --path "$MIRIDIR"/cargo-miri --force --locked --offline "$@"
138+
$CARGO install $CARGO_EXTRA_FLAGS --path "$MIRIDIR" --force --locked --offline "$@"
139+
$CARGO install $CARGO_EXTRA_FLAGS --path "$MIRIDIR"/cargo-miri --force --locked --offline "$@"
160140
;;
161-
check|check-debug)
141+
check)
162142
# Check, and let caller control flags.
163-
$CARGO check $CARGO_BUILD_FLAGS --manifest-path "$MIRIDIR"/Cargo.toml --all-targets "$@"
164-
$CARGO check $CARGO_BUILD_FLAGS --manifest-path "$MIRIDIR"/cargo-miri/Cargo.toml "$@"
143+
$CARGO check $CARGO_EXTRA_FLAGS --manifest-path "$MIRIDIR"/Cargo.toml --all-targets "$@"
144+
$CARGO check $CARGO_EXTRA_FLAGS --manifest-path "$MIRIDIR"/cargo-miri/Cargo.toml "$@"
165145
;;
166-
build|build-debug)
146+
build)
167147
# Build, and let caller control flags.
168-
$CARGO build $CARGO_BUILD_FLAGS --manifest-path "$MIRIDIR"/Cargo.toml "$@"
169-
$CARGO build $CARGO_BUILD_FLAGS --manifest-path "$MIRIDIR"/cargo-miri/Cargo.toml "$@"
148+
$CARGO build $CARGO_EXTRA_FLAGS --manifest-path "$MIRIDIR"/Cargo.toml "$@"
149+
$CARGO build $CARGO_EXTRA_FLAGS --manifest-path "$MIRIDIR"/cargo-miri/Cargo.toml "$@"
170150
;;
171-
test|test-debug|bless|bless-debug)
151+
test|bless)
172152
# First build and get a sysroot.
173-
$CARGO build $CARGO_BUILD_FLAGS --manifest-path "$MIRIDIR"/Cargo.toml
153+
$CARGO build $CARGO_EXTRA_FLAGS --manifest-path "$MIRIDIR"/Cargo.toml
174154
find_sysroot
175-
case "$COMMAND" in
176-
bless|bless-debug)
155+
if [ "$COMMAND" = "bless" ]; then
177156
export MIRI_BLESS="Gesundheit"
178-
;;
179-
esac
157+
fi
180158
# Then test, and let caller control flags.
181159
# Only in root project and ui_test as `cargo-miri` has no tests.
182-
$CARGO test $CARGO_BUILD_FLAGS --manifest-path "$MIRIDIR"/Cargo.toml "$@"
183-
$CARGO test $CARGO_BUILD_FLAGS --manifest-path "$MIRIDIR"/ui_test/Cargo.toml "$@"
160+
$CARGO test $CARGO_EXTRA_FLAGS --manifest-path "$MIRIDIR"/Cargo.toml "$@"
161+
$CARGO test $CARGO_EXTRA_FLAGS --manifest-path "$MIRIDIR"/ui_test/Cargo.toml "$@"
184162
;;
185-
run|run-debug)
163+
run)
186164
# Scan for "--target" to overwrite the "MIRI_TEST_TARGET" env var so
187165
# that we set the MIRI_SYSROOT up the right way.
188166
FOUND_TARGET_OPT=0
@@ -200,19 +178,19 @@ run|run-debug)
200178
MIRIFLAGS="$MIRIFLAGS --target $MIRI_TEST_TARGET"
201179
fi
202180
# First build and get a sysroot.
203-
$CARGO build $CARGO_BUILD_FLAGS --manifest-path "$MIRIDIR"/Cargo.toml
181+
$CARGO build $CARGO_EXTRA_FLAGS --manifest-path "$MIRIDIR"/Cargo.toml
204182
find_sysroot
205183
# Then run the actual command.
206-
exec $CARGO run $CARGO_BUILD_FLAGS --manifest-path "$MIRIDIR"/Cargo.toml -- --sysroot "$MIRI_SYSROOT" $MIRIFLAGS "$@"
184+
exec $CARGO run $CARGO_EXTRA_FLAGS --manifest-path "$MIRIDIR"/Cargo.toml -- --sysroot "$MIRI_SYSROOT" $MIRIFLAGS "$@"
207185
;;
208186
fmt)
209187
find "$MIRIDIR" -not \( -name target -prune \) -name '*.rs' \
210188
| xargs rustfmt +$TOOLCHAIN --edition=2021 --config-path "$MIRIDIR/rustfmt.toml" "$@"
211189
;;
212190
clippy)
213-
$CARGO clippy $CARGO_BUILD_FLAGS --manifest-path "$MIRIDIR"/Cargo.toml --all-targets "$@"
214-
$CARGO clippy $CARGO_BUILD_FLAGS --manifest-path "$MIRIDIR"/ui_test/Cargo.toml --all-targets "$@"
215-
$CARGO clippy $CARGO_BUILD_FLAGS --manifest-path "$MIRIDIR"/cargo-miri/Cargo.toml "$@"
191+
$CARGO clippy $CARGO_EXTRA_FLAGS --manifest-path "$MIRIDIR"/Cargo.toml --all-targets "$@"
192+
$CARGO clippy $CARGO_EXTRA_FLAGS --manifest-path "$MIRIDIR"/ui_test/Cargo.toml --all-targets "$@"
193+
$CARGO clippy $CARGO_EXTRA_FLAGS --manifest-path "$MIRIDIR"/cargo-miri/Cargo.toml "$@"
216194
;;
217195
*)
218196
if [ -n "$COMMAND" ]; then

0 commit comments

Comments
 (0)