Skip to content

Work around strip bugs in rustc and cargo #69

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ Note: In this file, do not use the hard wrap in the middle of a sentence for com

## [Unreleased]

- Work around strip bugs in rustc and cargo. See [#69](https://github.com/taiki-e/upload-rust-binary-action/pull/69) for details.

## [1.19.0] - 2024-03-05

- 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.
Expand Down
13 changes: 10 additions & 3 deletions main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -252,11 +252,18 @@ fi

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

Expand Down