Skip to content

Commit

Permalink
tools: Update scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
taiki-e committed Mar 9, 2024
1 parent 95c31b9 commit 6c11668
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
3 changes: 1 addition & 2 deletions tools/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,7 @@ rustc_minor_version="${rustc_minor_version%%.*}"
llvm_version=$(rustc ${pre_args[@]+"${pre_args[@]}"} -Vv | (grep 'LLVM version: ' || true) | (sed 's/LLVM version: //' || true))
llvm_version="${llvm_version%%.*}"
host=$(rustc ${pre_args[@]+"${pre_args[@]}"} -Vv | grep 'host: ' | sed 's/host: //')
metadata=$(cargo metadata --format-version=1 --no-deps)
target_dir=$(jq <<<"${metadata}" -r '.target_directory')
target_dir=$(pwd)/target
# Do not use check here because it misses some errors such as invalid inline asm operands and LLVM codegen errors.
subcmd=build
if [[ -n "${TARGET_GROUP:-}" ]]; then
Expand Down
3 changes: 1 addition & 2 deletions tools/no-std.sh
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,7 @@ rustc_target_list=$(rustc ${pre_args[@]+"${pre_args[@]}"} --print target-list)
rustc_version=$(rustc ${pre_args[@]+"${pre_args[@]}"} -Vv | grep 'release: ' | sed 's/release: //')
rustc_minor_version="${rustc_version#*.}"
rustc_minor_version="${rustc_minor_version%%.*}"
metadata=$(cargo metadata --format-version=1 --no-deps)
target_dir=$(jq <<<"${metadata}" -r '.target_directory')
target_dir=$(pwd)/target
nightly=''
if [[ "${rustc_version}" == *"nightly"* ]] || [[ "${rustc_version}" == *"dev"* ]]; then
nightly=1
Expand Down
21 changes: 13 additions & 8 deletions tools/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ rustc_version=$(rustc ${pre_args[@]+"${pre_args[@]}"} -Vv | grep 'release: ' | s
rustc_minor_version="${rustc_version#*.}"
rustc_minor_version="${rustc_minor_version%%.*}"
host=$(rustc ${pre_args[@]+"${pre_args[@]}"} -Vv | grep 'host: ' | sed 's/host: //')
target_dir=$(pwd)/target
nightly=''
if [[ "${rustc_version}" == *"nightly"* ]] || [[ "${rustc_version}" == *"dev"* ]]; then
nightly=1
Expand Down Expand Up @@ -260,14 +261,16 @@ run() {
# LTO + doctests is very slow on some platforms (probably related to the fact that they compile binaries for each example)
if [[ "${RUSTFLAGS:-}" =~ -Z( )?sanitizer=memory ]]; then
# Workaround https://github.com/google/sanitizers/issues/558
CARGO_PROFILE_RELEASE_OPT_LEVEL=0 \
CARGO_TARGET_DIR="${target_dir}"/fat-lto \
CARGO_PROFILE_RELEASE_OPT_LEVEL=0 \
CARGO_PROFILE_RELEASE_CODEGEN_UNITS=1 \
CARGO_PROFILE_RELEASE_LTO=fat \
x_cargo test ${build_std[@]+"${build_std[@]}"} --release --tests --target-dir target/fat-lto "$@"
x_cargo test ${build_std[@]+"${build_std[@]}"} --release --tests "$@"
else
CARGO_PROFILE_RELEASE_CODEGEN_UNITS=1 \
CARGO_TARGET_DIR="${target_dir}"/fat-lto \
CARGO_PROFILE_RELEASE_CODEGEN_UNITS=1 \
CARGO_PROFILE_RELEASE_LTO=fat \
x_cargo test ${build_std[@]+"${build_std[@]}"} --release --tests --target-dir target/fat-lto "$@"
x_cargo test ${build_std[@]+"${build_std[@]}"} --release --tests "$@"
fi

# cargo-careful only supports nightly. rustc-build-sysroot doesn't work on old nightly (at least on nightly-2022-08-12 - 1.65.0-nightly).
Expand All @@ -286,14 +289,16 @@ run() {
*-windows-gnu*) ;;
*)
if [[ ${#build_std[@]} -gt 0 ]]; then
RUSTFLAGS="${RUSTFLAGS:-}${flags}" \
CARGO_TARGET_DIR="${target_dir}"/careful \
RUSTFLAGS="${RUSTFLAGS:-}${flags}" \
RUSTDOCFLAGS="${RUSTDOCFLAGS:-}${flags}" \
x_cargo careful test -Z doctest-xcompile ${release[@]+"${release[@]}"} ${tests[@]+"${tests[@]}"} --target-dir target/careful "$@"
x_cargo careful test -Z doctest-xcompile ${release[@]+"${release[@]}"} ${tests[@]+"${tests[@]}"} "$@"
else
# -Z doctest-xcompile is already passed
RUSTFLAGS="${RUSTFLAGS:-}${flags}" \
CARGO_TARGET_DIR="${target_dir}"/careful \
RUSTFLAGS="${RUSTFLAGS:-}${flags}" \
RUSTDOCFLAGS="${RUSTDOCFLAGS:-}${flags}" \
x_cargo careful test ${release[@]+"${release[@]}"} ${tests[@]+"${tests[@]}"} --target-dir target/careful "$@"
x_cargo careful test ${release[@]+"${release[@]}"} ${tests[@]+"${tests[@]}"} "$@"
fi
;;
esac
Expand Down

0 comments on commit 6c11668

Please sign in to comment.