Skip to content

Commit 70f8427

Browse files
committed
Work around strip bugs in rustc and cargo
1 parent cdb45d6 commit 70f8427

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ Note: In this file, do not use the hard wrap in the middle of a sentence for com
1010

1111
## [Unreleased]
1212

13+
- Work around strip bugs in rustc and cargo. See [#69](https://github.com/taiki-e/upload-rust-binary-action/pull/69) for details.
14+
1315
## [1.19.0] - 2024-03-05
1416

1517
- Align default strip behavior to [Cargo 1.77+'s default (strip=debuginfo)](https://github.com/rust-lang/cargo/pull/13257). See [#66](https://github.com/taiki-e/upload-rust-binary-action/pull/66) for details.

main.sh

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -252,11 +252,18 @@ fi
252252

253253
workspace_root=$(jq <<<"${metadata}" -r '.workspace_root')
254254
# TODO: This is a somewhat rough check as it does not look at the type of profile.
255-
if ! grep -Eq '^strip\s*=' "${workspace_root}/Cargo.toml" && [[ -z "${CARGO_PROFILE_RELEASE_STRIP:-}" ]]; then
255+
if ! grep -Eq '^\s*strip\s*=' "${workspace_root}/Cargo.toml" && [[ -z "${CARGO_PROFILE_RELEASE_STRIP:-}" ]]; then
256256
# On pre-1.77, align to Cargo 1.77+'s default: https://github.com/rust-lang/cargo/pull/13257
257+
# 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.
257258
# strip option builds requires Cargo 1.59
258-
if [[ "${rustc_minor_version}" -lt 77 ]] && [[ "${rustc_minor_version}" -ge 59 ]]; then
259-
export CARGO_PROFILE_RELEASE_STRIP=debuginfo
259+
case "${target}" in
260+
# Do not strip debuginfo on MSVC https://github.com/rust-lang/cargo/pull/13630
261+
# This is the same behavior as pre-1.19.0 upload-rust-binary-action.
262+
*-pc-windows-msvc) strip_default=none ;;
263+
*) strip_default=debuginfo ;;
264+
esac
265+
if [[ "${rustc_minor_version}" -lt 79 ]] && [[ "${rustc_minor_version}" -ge 59 ]]; then
266+
export CARGO_PROFILE_RELEASE_STRIP="${strip_default}"
260267
fi
261268
fi
262269

0 commit comments

Comments
 (0)