diff options
Diffstat (limited to 'eclass/cargo.eclass')
-rw-r--r-- | eclass/cargo.eclass | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/eclass/cargo.eclass b/eclass/cargo.eclass index 25a2127f6391..dae2b93f24f3 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 @@ -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}" @@ -779,7 +784,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() { |