* [gentoo-dev] [PATCH 0/5] Various rust/cargo eclass improvements @ 2025-03-08 13:59 Arthur Zamarin 2025-03-08 13:59 ` [gentoo-dev] [PATCH 1/5] cargo.eclass: fix typos Arthur Zamarin ` (4 more replies) 0 siblings, 5 replies; 7+ messages in thread From: Arthur Zamarin @ 2025-03-08 13:59 UTC (permalink / raw To: gentoo-dev; +Cc: rust, Arthur Zamarin This patchset contains various improvements to the rust and cargo eclasses, including typo fixes and documentation improvements. Main changes are: * use dynamic linking by default in cargo.eclass (important for rust-bin on musl where it was previous broken) * use static.crates.io CDN in cargo.eclass This patchset can also be seen in https://github.com/gentoo/gentoo/pull/40938 Arthur Zamarin (3): cargo.eclass: fix typos rust.eclass: fix typos rust.eclass: add documentation for RUST_{SLOT,TYPE} Michal Rostecki (1): cargo.eclass: Enable dynamic linking by default swomf (1): cargo.eclass: use static.crates.io cdn eclass/cargo.eclass | 13 +++++++++---- eclass/rust.eclass | 36 ++++++++++++++++++++++++------------ 2 files changed, 33 insertions(+), 16 deletions(-) -- 2.48.1 ^ permalink raw reply [flat|nested] 7+ messages in thread
* [gentoo-dev] [PATCH 1/5] cargo.eclass: fix typos 2025-03-08 13:59 [gentoo-dev] [PATCH 0/5] Various rust/cargo eclass improvements Arthur Zamarin @ 2025-03-08 13:59 ` Arthur Zamarin 2025-03-08 13:59 ` [gentoo-dev] [PATCH 2/5] rust.eclass: " Arthur Zamarin ` (3 subsequent siblings) 4 siblings, 0 replies; 7+ messages in thread From: Arthur Zamarin @ 2025-03-08 13:59 UTC (permalink / raw To: gentoo-dev; +Cc: rust, Arthur Zamarin Signed-off-by: Arthur Zamarin <arthurzam@gentoo.org> --- eclass/cargo.eclass | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/eclass/cargo.eclass b/eclass/cargo.eclass index 25a2127f639..909321c355b 100644 --- a/eclass/cargo.eclass +++ b/eclass/cargo.eclass @@ -181,7 +181,7 @@ ECARGO_VENDOR="${ECARGO_HOME}/gentoo" # functions will be exported. # # If you enable CARGO_OPTIONAL call at least cargo_gen_config manually -# before using other src_functions or cargo_env of this eclass. +# before using other src_* functions or cargo_env of this eclass. # Note that cargo_gen_config is automatically called by cargo_src_unpack. # @ECLASS_VARIABLE: myfeatures @@ -779,7 +779,7 @@ cargo_src_compile() { # @FUNCTION: cargo_src_install # @DESCRIPTION: # Installs the binaries generated by cargo. -# In come cases workspaces need an alternative --path parameter. +# In some cases workspaces need an alternative --path parameter. # Defaults to '--path ./' if no path is specified. # '--path ./somedir' can be passed directly to cargo_src_install. cargo_src_install() { -- 2.48.1 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* [gentoo-dev] [PATCH 2/5] rust.eclass: fix typos 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 ` Arthur Zamarin 2025-03-08 13:59 ` [gentoo-dev] [PATCH 3/5] rust.eclass: add documentation for RUST_{SLOT,TYPE} Arthur Zamarin ` (2 subsequent siblings) 4 siblings, 0 replies; 7+ messages in thread From: Arthur Zamarin @ 2025-03-08 13:59 UTC (permalink / raw To: gentoo-dev; +Cc: rust, Arthur Zamarin Signed-off-by: Arthur Zamarin <arthurzam@gentoo.org> --- eclass/rust.eclass | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/eclass/rust.eclass b/eclass/rust.eclass index 9ead9d00570..f69ea466f50 100644 --- a/eclass/rust.eclass +++ b/eclass/rust.eclass @@ -12,12 +12,12 @@ # An eclass to reliably depend on a Rust or Rust/LLVM combination for # a given Rust slot. To use the eclass: # -# 1. If required, set RUST_{MAX,MIN}_SLOT to the range of supported slots. +# 1. If required, set RUST_{MAX,MIN}_VER to the range of supported slots. # # 2. If rust is optional, set RUST_OPTIONAL to a non-empty value then -# appropriately gate ${RUST_DEPEND} +# appropriately gate ${RUST_DEPEND}. # -# 3. Use rust_pkg_setup, get_rust_prefix or RUST_SLOT. +# 3. Use rust_pkg_setup, get_rust_prefix, or RUST_SLOT. # Example use for a package supporting Rust 1.72.0 to 1.82.0: # @CODE @@ -116,7 +116,7 @@ declare -a -g -r _RUST_SLOTS_ORDERED=( # @USER_VARIABLE # @DESCRIPTION: # Specify the version (slot) of Rust to be used by the package. This is -# useful for troubleshooting and debugging purposes; If unset, the newest +# useful for troubleshooting and debugging purposes. If unset, the newest # acceptable Rust version will be used. May be combined with ERUST_TYPE_OVERRIDE. # This variable must not be set in ebuilds. @@ -175,7 +175,7 @@ declare -a -g -r _RUST_SLOTS_ORDERED=( # @DEFAULT_UNSET # @DESCRIPTION: # If set to a non-empty value, the Rust dependency will not be added -# to BDEPEND. This is useful for where packages need to gate rust behind +# to BDEPEND. This is useful for packages that need to gate rust behind # certain USE themselves. # @ECLASS_VARIABLE: RUST_REQ_USE @@ -303,12 +303,12 @@ unset -f _rust_set_globals # If -d is specified, the checks are performed relative to ESYSROOT, # and ESYSROOT-path is returned. # -# If RUST_M{AX,IN}_SLOT is non-zero, then only Rust versions that +# If RUST_M{AX,IN}_VER is non-zero, then only Rust versions that # are not newer or older than the specified slot(s) will be considered. -# Otherwise, all Rust versions are be considered acceptable. +# Otherwise, all Rust versions are considered acceptable. # # If the `rust_check_deps()` function is defined within the ebuild, it -# will be called to verify whether a particular slot is accepable. +# will be called to verify whether a particular slot is acceptable. # Within the function scope, RUST_SLOT and LLVM_SLOT will be defined. # # The function should return a true status if the slot is acceptable, @@ -443,7 +443,7 @@ _get_rust_slot() { # @FUNCTION: get_rust_path # @USAGE: prefix slot rust_type # @DESCRIPTION: -# Given argument of slot and rust_type, return an appropriate path +# Given arguments of prefix, slot, and rust_type, return an appropriate path # for the Rust install. The rust_type should be either "source" # or "binary". If the rust_type is not one of these, the function # will die. @@ -472,7 +472,7 @@ get_rust_path() { # and print an absolute path to it. If both -bin and regular Rust # are installed, the regular Rust is preferred. # -# The options and behavior are the same as get_rust_slot. +# The options and behavior are the same as _get_rust_slot. get_rust_prefix() { debug-print-function ${FUNCNAME} "$@" @@ -501,10 +501,10 @@ rust_prepend_path() { # `llvm-r1_pkg_setup` call should be made in addition to this function. # For path determination logic, please see the get_rust_prefix documentation. # -# The highest acceptable Rust slot can be set in RUST_MAX_VER variable. +# The highest acceptable Rust slot can be set in the RUST_MAX_VER variable. # If it is unset or empty, any slot is acceptable. # -# The lowest acceptable Rust slot can be set in RUST_MIN_VER variable. +# The lowest acceptable Rust slot can be set in the RUST_MIN_VER variable. # If it is unset or empty, any slot is acceptable. # # `CARGO` and `RUSTC` variables are set for the selected slot and exported. -- 2.48.1 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* [gentoo-dev] [PATCH 3/5] rust.eclass: add documentation for RUST_{SLOT,TYPE} 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 ` Arthur Zamarin 2025-03-08 13:59 ` [gentoo-dev] [PATCH 4/5] cargo.eclass: Enable dynamic linking by default Arthur Zamarin 2025-03-08 13:59 ` [gentoo-dev] [PATCH 5/5] cargo.eclass: use static.crates.io cdn Arthur Zamarin 4 siblings, 0 replies; 7+ messages in thread From: Arthur Zamarin @ 2025-03-08 13:59 UTC (permalink / raw To: gentoo-dev; +Cc: rust, Arthur Zamarin Signed-off-by: Arthur Zamarin <arthurzam@gentoo.org> --- eclass/rust.eclass | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/eclass/rust.eclass b/eclass/rust.eclass index f69ea466f50..41197ce4e3a 100644 --- a/eclass/rust.eclass +++ b/eclass/rust.eclass @@ -144,6 +144,18 @@ declare -a -g -r _RUST_SLOTS_ORDERED=( # Lowest Rust slot supported by the package. Needs to be set before # rust_pkg_setup is called. If unset, no lower bound is assumed. +# @ECLASS_VARIABLE: RUST_SLOT +# @OUTPUT_VARIABLE +# @DESCRIPTION: +# The selected Rust slot for building, from the range defined by +# RUST_MAX_VER and RUST_MIN_VER. This is set by rust_pkg_setup. + +# @ECLASS_VARIABLE: RUST_TYPE +# @OUTPUT_VARIABLE +# @DESCRIPTION: +# The selected Rust type for building, either 'source' or 'binary'. +# This is set by rust_pkg_setup. + # @ECLASS_VARIABLE: RUST_NEEDS_LLVM # @DEFAULT_UNSET # @DESCRIPTION: -- 2.48.1 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* [gentoo-dev] [PATCH 4/5] cargo.eclass: Enable dynamic linking by default 2025-03-08 13:59 [gentoo-dev] [PATCH 0/5] Various rust/cargo eclass improvements Arthur Zamarin ` (2 preceding siblings ...) 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 ` Arthur Zamarin 2025-03-08 16:23 ` James Le Cuirot 2025-03-08 13:59 ` [gentoo-dev] [PATCH 5/5] cargo.eclass: use static.crates.io cdn Arthur Zamarin 4 siblings, 1 reply; 7+ messages in thread From: Arthur Zamarin @ 2025-03-08 13:59 UTC (permalink / raw To: gentoo-dev; +Cc: rust, Michal Rostecki, Arthur Zamarin 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}" -- 2.48.1 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [gentoo-dev] [PATCH 4/5] cargo.eclass: Enable dynamic linking by default 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 0 siblings, 0 replies; 7+ messages in thread From: James Le Cuirot @ 2025-03-08 16:23 UTC (permalink / raw To: gentoo-dev [-- 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 --] ^ permalink raw reply [flat|nested] 7+ messages in thread
* [gentoo-dev] [PATCH 5/5] cargo.eclass: use static.crates.io cdn 2025-03-08 13:59 [gentoo-dev] [PATCH 0/5] Various rust/cargo eclass improvements Arthur Zamarin ` (3 preceding siblings ...) 2025-03-08 13:59 ` [gentoo-dev] [PATCH 4/5] cargo.eclass: Enable dynamic linking by default Arthur Zamarin @ 2025-03-08 13:59 ` Arthur Zamarin 4 siblings, 0 replies; 7+ messages in thread From: Arthur Zamarin @ 2025-03-08 13:59 UTC (permalink / raw To: gentoo-dev; +Cc: rust, swomf, Arthur Zamarin From: swomf <swomf@proton.me> Starting from 2024-03-12, cargo began to download crates directly from static.crates.io CDN servers worldwide. See https://blog.rust-lang.org/2024/03/11/crates-io-download-changes.html Signed-off-by: swomf <swomf@proton.me> Closes: https://github.com/gentoo/gentoo/pull/40944 Signed-off-by: Arthur Zamarin <arthurzam@gentoo.org> --- eclass/cargo.eclass | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eclass/cargo.eclass b/eclass/cargo.eclass index dae2b93f24f..9edfff88aa2 100644 --- a/eclass/cargo.eclass +++ b/eclass/cargo.eclass @@ -269,7 +269,7 @@ _cargo_set_crate_uris() { name="${BASH_REMATCH[1]}" version="${BASH_REMATCH[2]}" fi - url="https://crates.io/api/v1/crates/${name}/${version}/download -> ${name}-${version}.crate" + url="https://static.crates.io/api/v1/crates/${name}/${version}/download -> ${name}-${version}.crate" CARGO_CRATE_URIS+="${url} " # when invoked by pkgbump, avoid fetching all the crates -- 2.48.1 ^ permalink raw reply related [flat|nested] 7+ messages in thread
end of thread, other threads:[~2025-03-08 16:24 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 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 2025-03-08 13:59 ` [gentoo-dev] [PATCH 5/5] cargo.eclass: use static.crates.io cdn Arthur Zamarin
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox