Skip to content

Commit 590eb89

Browse files
committed
Do not strip debuginfo on Apple targets/illumos/AIX in cross-compilation
1 parent 4d59693 commit 590eb89

File tree

1 file changed

+27
-12
lines changed

1 file changed

+27
-12
lines changed

main.sh

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -277,20 +277,35 @@ else
277277
fi
278278

279279
workspace_root=$(jq <<<"${metadata}" -r '.workspace_root')
280-
# TODO: This is a somewhat rough check as it does not look at the type of profile.
281-
if ! grep -Eq '^\s*strip\s*=' "${workspace_root}/Cargo.toml" && [[ -z "${CARGO_PROFILE_RELEASE_STRIP:-}" ]]; then
282-
# On pre-1.77, align to Cargo 1.77+'s default: https://github.com/rust-lang/cargo/pull/13257
283-
# However, set env on pre-1.79 because it is 1.79+ that actually works correctly due to https://github.com/rust-lang/cargo/issues/13617.
284-
# strip option builds requires Cargo 1.59
285-
case "${target}" in
286-
# Do not strip debuginfo on MSVC https://github.com/rust-lang/cargo/pull/13630
287-
# This is the same behavior as pre-1.19.0 upload-rust-binary-action.
288-
*-windows-msvc) strip_default=none ;;
289-
*) strip_default=debuginfo ;;
290-
esac
291-
if [[ "${rustc_minor_version}" -lt 79 ]] && [[ "${rustc_minor_version}" -ge 59 ]]; then
280+
# Skip setting the strip option (requires Cargo 1.59) if it is unavailable or already set.
281+
# TODO: This check is somewhat rough as it does not look at the type of profile.
282+
if [[ "${rustc_minor_version}" -ge 59 ]] && [[ -z "${CARGO_PROFILE_RELEASE_STRIP:-}" ]] && ! grep -Eq '^\s*strip\s*=' "${workspace_root}/Cargo.toml"; then
283+
if [[ "${rustc_minor_version}" -lt 79 ]]; then
284+
# On pre-1.77, align to Cargo 1.77+'s default: https://github.com/rust-lang/cargo/pull/13257
285+
# However, set environment variable on pre-1.79 because it is 1.79+ that actually works correctly due to https://github.com/rust-lang/cargo/issues/13617.
286+
case "${target}" in
287+
# Do not strip debuginfo on MSVC https://github.com/rust-lang/cargo/pull/13630
288+
# This is the same behavior as pre-1.19.0 upload-rust-binary-action.
289+
*-windows-msvc) strip_default=none ;;
290+
*) strip_default=debuginfo ;;
291+
esac
292292
export CARGO_PROFILE_RELEASE_STRIP="${strip_default}"
293293
fi
294+
# Do not strip debuginfo on these targets in cross-compilation (including docker via cross).
295+
# https://github.com/nextest-rs/nextest/commit/d4f982b3184f07ff5c40cc90c52d3fc6567be0b9#commitcomment-140325483
296+
# https://github.com/rust-lang/rust/issues/123151#issuecomment-2024743520
297+
# https://github.com/rust-lang/rust/blob/c25473ff62a99541426423e8ef41c63d71e0a4a0/compiler/rustc_codegen_ssa/src/back/link.rs#L1032-L1077
298+
# TODO: Add `if [[ "${rustc_minor_version}" -lt patched_version ]]; ..` once upstream bug fixed.
299+
case "${target}" in
300+
*-apple-*)
301+
case "${host_os}" in
302+
macos) ;; # apple to apple cross-compilation is okay
303+
*) export CARGO_PROFILE_RELEASE_STRIP=none ;;
304+
esac
305+
;;
306+
# illumos/AIX host is not supported on GitHub Actions.
307+
*-illumos* | *-aix*) export CARGO_PROFILE_RELEASE_STRIP=none ;;
308+
esac
294309
fi
295310

296311
build() {

0 commit comments

Comments
 (0)