Skip to content

Commit 5b38129

Browse files
authored
fix(operations): Fix restoring of rust-toolchain file (vectordotdev#1224)
Signed-off-by: Alexander Rodin <rodin.alexander@gmail.com>
1 parent 89c50b1 commit 5b38129

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

scripts/build-archive.sh

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,16 +54,17 @@ if [ -z "$NATIVE_BUILD" ]; then
5454
build_flags="$build_flags --target $TARGET"
5555
fi
5656

57-
57+
on_exit=""
5858

5959
# Currently the only way to set Rust codegen LTO type (-C lto, as opposed to
6060
# -C compiler-plugin-lto) at build time for a crate with library dependencies
6161
# is to patch Cargo.toml before the build. See
6262
# https://github.com/rust-lang/cargo/issues/4349 and
6363
# https://bugzilla.mozilla.org/show_bug.cgi?id=1386371#c2.
6464
if [ -n "$RUST_LTO" ]; then
65+
on_exit="mv Cargo.toml.orig Cargo.toml; $on_exit"
66+
trap "$on_exit" EXIT
6567
cp Cargo.toml Cargo.toml.orig
66-
trap "mv Cargo.toml.orig Cargo.toml" EXIT
6768
case "$RUST_LTO" in
6869
lto) lto_value="true";;
6970
lto=thin) lto_value="\"thin\"";;
@@ -73,7 +74,8 @@ fi
7374

7475
# Rename the rust-toolchain file so that we can use our custom version of rustc installed
7576
# on release containers.
76-
trap "mv rust-toolchain.bak rust-toolchain" EXIT
77+
on_exit="mv rust-toolchain.bak rust-toolchain; $on_exit"
78+
trap "$on_exit" EXIT
7779
mv rust-toolchain rust-toolchain.bak
7880

7981
if [ "$FEATURES" != "default" ]; then

0 commit comments

Comments
 (0)