From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id D87651582EF for ; Sat, 08 Mar 2025 14:04:49 +0000 (UTC) Received: from lists.gentoo.org (bobolink.gentoo.org [140.211.166.189]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) (Authenticated sender: relay-lists.gentoo.org@gentoo.org) by smtp.gentoo.org (Postfix) with ESMTPSA id A80E53430D7 for ; Sat, 08 Mar 2025 14:04:49 +0000 (UTC) Received: from bobolink.gentoo.org (localhost [127.0.0.1]) by bobolink.gentoo.org (Postfix) with ESMTP id F0BFA1103AC; Sat, 08 Mar 2025 14:02:52 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bobolink.gentoo.org (Postfix) with ESMTPS id E44B31103AC for ; Sat, 08 Mar 2025 14:02:52 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 9EB7B3430A9 for ; Sat, 08 Mar 2025 14:02:52 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 06BC8289D for ; Sat, 08 Mar 2025 14:02:51 +0000 (UTC) From: "Arthur Zamarin" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Arthur Zamarin" Message-ID: <1741442549.3b573d2233ad0b6548c10435b6547eba40d0b9fb.arthurzam@gentoo> Subject: [gentoo-commits] repo/gentoo:master commit in: eclass/ X-VCS-Repository: repo/gentoo X-VCS-Files: eclass/cargo.eclass X-VCS-Directories: eclass/ X-VCS-Committer: arthurzam X-VCS-Committer-Name: Arthur Zamarin X-VCS-Revision: 3b573d2233ad0b6548c10435b6547eba40d0b9fb X-VCS-Branch: master Date: Sat, 08 Mar 2025 14:02:51 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 8c3a7b67-f61a-4876-b773-1d80e2fd6dd3 X-Archives-Hash: 94cbf1dd99ff544222bdc7806f56502d commit: 3b573d2233ad0b6548c10435b6547eba40d0b9fb Author: Michal Rostecki protonmail com> AuthorDate: Thu Feb 27 16:09:53 2025 +0000 Commit: Arthur Zamarin gentoo org> CommitDate: Sat Mar 8 14:02:29 2025 +0000 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=3b573d22 cargo.eclass: Enable dynamic linking by default 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 protonmail.com> Closes: https://github.com/gentoo/gentoo/pull/40797 Signed-off-by: Arthur Zamarin gentoo.org> eclass/cargo.eclass | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/eclass/cargo.eclass b/eclass/cargo.eclass index 909321c355b8..dae2b93f24f3 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}"