From: James Le Cuirot <chewi@gentoo.org>
To: gentoo-dev@lists.gentoo.org
Subject: Re: [gentoo-dev] [PATCH 4/5] cargo.eclass: Enable dynamic linking by default
Date: Sat, 08 Mar 2025 16:23:21 +0000 [thread overview]
Message-ID: <25c410b7a27d7d599e081ea9574b1aac4e8719ae.camel@gentoo.org> (raw)
In-Reply-To: <20250308135921.593905-5-arthurzam@gentoo.org>
[-- Attachment #1: Type: text/plain, Size: 2106 bytes --]
On Sat, 2025-03-08 at 15:59 +0200, Arthur Zamarin wrote:
> 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}"
I considered this when writing the above lines, but I wasn't sure if it was a
good idea. If the testing has been done, then I'm glad to see it.
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 858 bytes --]
next prev parent reply other threads:[~2025-03-08 16:24 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-08 13:59 [gentoo-dev] [PATCH 0/5] Various rust/cargo eclass improvements Arthur Zamarin
2025-03-08 13:59 ` [gentoo-dev] [PATCH 1/5] cargo.eclass: fix typos Arthur Zamarin
2025-03-08 13:59 ` [gentoo-dev] [PATCH 2/5] rust.eclass: " Arthur Zamarin
2025-03-08 13:59 ` [gentoo-dev] [PATCH 3/5] rust.eclass: add documentation for RUST_{SLOT,TYPE} Arthur Zamarin
2025-03-08 13:59 ` [gentoo-dev] [PATCH 4/5] cargo.eclass: Enable dynamic linking by default Arthur Zamarin
2025-03-08 16:23 ` James Le Cuirot [this message]
2025-03-08 13:59 ` [gentoo-dev] [PATCH 5/5] cargo.eclass: use static.crates.io cdn Arthur Zamarin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=25c410b7a27d7d599e081ea9574b1aac4e8719ae.camel@gentoo.org \
--to=chewi@gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox