Pack relative relocations in x86-64 musl release builds (#59805)

## What changed

Add `-z pack-relative-relocs` to the Cargo and Bazel release linker flags for
`x86_64-unknown-linux-musl`, alongside the existing safe identical code folding.

GitOrigin-RevId: 1398ea6775e6b8ec81e624def6c23e8053363544
This commit is contained in:
Dmitriy Kovalenko
2026-11-06 03:09:21 +00:00
committed by copyberry
parent da279f6fd4
commit 7b54fd245d
2 changed files with 3 additions and 3 deletions
+2 -2
View File
@@ -261,9 +261,9 @@ target_cxx_var="CXX_${TARGET}"
target_cxx_var="${target_cxx_var//-/_}"
echo "${target_cxx_var}=${cxx}" >> "$GITHUB_ENV"
# Enable safe identical code folding for release packages on x86-64 musl.
# Fold identical code and pack relocations for x86-64 musl release packages.
if [[ "${TARGET}" == "x86_64-unknown-linux-musl" && "${CODEX_MUSL_RELEASE_LINK_FLAGS:-}" == "1" ]]; then
link_flags=(-Cllvm-args=--addrsig -Clink-arg=-fuse-ld=lld -Clink-arg=-Wl,--icf=safe)
link_flags=(-Cllvm-args=--addrsig -Clink-arg=-fuse-ld=lld -Clink-arg=-Wl,--icf=safe,-z,pack-relative-relocs)
echo "RUSTFLAGS=${RUSTFLAGS:+$RUSTFLAGS }${link_flags[*]}" >> "$GITHUB_ENV"
fi
+1 -1
View File
@@ -71,7 +71,7 @@ def _release_profile_impl(settings, attr):
# Match the Cargo release linker for x86-64 static PIEs.
profile[_RUSTC_FLAGS] += [
"-Cllvm-args=--addrsig",
"-Clink-arg=-Wl,--icf=safe",
"-Clink-arg=-Wl,--icf=safe,-z,pack-relative-relocs",
]
return profile