Sysop: | Amessyroom |
---|---|
Location: | Fayetteville, NC |
Users: | 28 |
Nodes: | 6 (0 / 6) |
Uptime: | 51:07:48 |
Calls: | 422 |
Files: | 1,025 |
Messages: | 90,550 |
From: Michal Rostecki <vadorovsky@protonmail.com>
Rust defaults to static linking (`-C target-feature=+crt-static`) on
musl targets. We already patch dev-lang/rust to always prefer dynamic linking, but to ensure that behavior with dev-lang/rust-bin, set the
opposite option (`-C target-feature=-crt-static`) in RUSTFLAGS.
Bug: https://bugs.gentoo.org/940722
Signed-off-by: Michal Rostecki <vadorovsky@protonmail.com>
Closes: https://github.com/gentoo/gentoo/pull/40797
Signed-off-by: Arthur Zamarin <arthurzam@gentoo.org>
---
eclass/cargo.eclass | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/eclass/cargo.eclass b/eclass/cargo.eclass
index 909321c355b..dae2b93f24f 100644
--- a/eclass/cargo.eclass
+++ b/eclass/cargo.eclass
@@ -745,10 +745,15 @@ cargo_env() {
# The default linker is "cc" so override by setting linker to CC in the
# RUSTFLAGS. The given linker cannot include any arguments, so split these
# into link-args along with LDFLAGS.
+ #
+ # Rust defaults to static linking (-C target-feature=+crt-static) on musl
+ # targets. We already patch dev-lang/rust to always prefer dynamic linking,
+ # but to ensure that behavior with dev-lang/rust-bin, set the opposite option
+ # (-C target-feature=-crt-static) in RUSTFLAGS.
local -x CARGO_BUILD_TARGET=$(rust_abi)
local TRIPLE=${CARGO_BUILD_TARGET//-/_}
local TRIPLE=${TRIPLE^^} LD_A=( $(tc-getCC) ${LDFLAGS} )
- local -Ix CARGO_TARGET_"${TRIPLE}"_RUSTFLAGS+=" -C strip=none -C linker=${LD_A[0]}"
+ local -Ix CARGO_TARGET_"${TRIPLE}"_RUSTFLAGS+=" -C strip=none -C linker=${LD_A[0]} -C target-feature=-crt-static"
[[ ${#LD_A[@]} -gt 1 ]] && local CARGO_TARGET_"${TRIPLE}"_RUSTFLAGS+="$(printf -- ' -C link-arg=%s' "${LD_A[@]:1}")"
local CARGO_TARGET_"${TRIPLE}"_RUSTFLAGS+=" ${RUSTFLAGS}"