summaryrefslogtreecommitdiff
path: root/eclass
diff options
context:
space:
mode:
Diffstat (limited to 'eclass')
-rw-r--r--eclass/Manifest.gzbin39029 -> 39029 bytes
-rw-r--r--eclass/cargo.eclass41
-rw-r--r--eclass/rust.eclass49
-rw-r--r--eclass/toolchain.eclass18
4 files changed, 86 insertions, 22 deletions
diff --git a/eclass/Manifest.gz b/eclass/Manifest.gz
index 165875069939..567962a4013f 100644
--- a/eclass/Manifest.gz
+++ b/eclass/Manifest.gz
Binary files differ
diff --git a/eclass/cargo.eclass b/eclass/cargo.eclass
index 02b048732f7f..b1285e13a5b2 100644
--- a/eclass/cargo.eclass
+++ b/eclass/cargo.eclass
@@ -138,6 +138,10 @@ ECARGO_VENDOR="${ECARGO_HOME}/gentoo"
# - optionally: the path to look for Cargo.toml in.
# - This will also replace the string "%commit%" with the commit's checksum.
# - Defaults to: "${crate}-%commit%"
+# - optionally: the git host so it would generate tarball download link.
+# - E.g. gitlab
+# - It fallbacks to detecting from URL if it's gitlab.com or github.com
+# if no host provided.
#
# Example of a simple definition with no path to Cargo.toml:
# @CODE
@@ -153,6 +157,13 @@ ECARGO_VENDOR="${ECARGO_HOME}/gentoo"
# [rustpython-parser]="https://github.com/RustPython/RustPython;4f38cb68e4a97aeea9eb19673803a0bd5f655383;RustPython-%commit%/compiler/parser"
# )
# @CODE
+#
+# Example with host defined:
+# @CODE
+# declare -A GIT_CRATES=(
+# [clapper]="https://gitlab.gnome.org/JanGernert/clapper-rs;530b6fd53a60563d8038f7a1d9d735d6dc496adb;clapper-rs-%commit%/libclapper-rs;gitlab"
+# )
+# @CODE
# @ECLASS_VARIABLE: CARGO_BOOTSTRAP
# @DEFAULT_UNSET
@@ -269,22 +280,38 @@ _cargo_set_crate_uris() {
if declare -p GIT_CRATES &>/dev/null; then
if [[ $(declare -p GIT_CRATES) == "declare -A"* ]]; then
- local crate commit crate_uri crate_dir repo_ext feat_expr
+ local crate commit crate_uri crate_dir host repo_ext feat_expr
for crate in "${!GIT_CRATES[@]}"; do
- IFS=';' read -r crate_uri commit crate_dir <<< "${GIT_CRATES[${crate}]}"
+ IFS=';' read -r crate_uri commit crate_dir host <<< "${GIT_CRATES[${crate}]}"
+
+ if [[ -z ${host} ]]; then
+ case "${crate_uri}" in
+ https://github.com/*)
+ host="github"
+ ;;
+ https://gitlab.com/*)
+ host="gitlab"
+ ;;
+ esac
+ fi
- case "${crate_uri}" in
- https://github.com/*)
+ case "${host}" in
+ github)
repo_ext=".gh"
repo_name="${crate_uri##*/}"
crate_uri="${crate_uri%/}/archive/%commit%.tar.gz"
;;
- https://gitlab.com/*)
+ gitlab)
repo_ext=".gl"
repo_name="${crate_uri##*/}"
crate_uri="${crate_uri%/}/-/archive/%commit%/${repo_name}-%commit%.tar.gz"
;;
+ gitea)
+ repo_ext=".gt"
+ repo_name="${crate_uri##*/}"
+ crate_uri="${crate_uri%/}/archive/%commit%.tar.gz"
+ ;;
*)
repo_ext=
repo_name="${crate}"
@@ -395,11 +422,11 @@ _cargo_gen_git_config() {
git_crates_type="$(declare -p GIT_CRATES 2>&-)"
if [[ ${git_crates_type} == "declare -A "* ]]; then
- local crate commit crate_uri crate_dir
+ local crate commit crate_uri crate_dir host
local -A crate_patches
for crate in "${!GIT_CRATES[@]}"; do
- IFS=';' read -r crate_uri commit crate_dir <<< "${GIT_CRATES[${crate}]}"
+ IFS=';' read -r crate_uri commit crate_dir host <<< "${GIT_CRATES[${crate}]}"
: "${crate_dir:=${crate}-%commit%}"
crate_patches["${crate_uri}"]+="${crate} = { path = \"${WORKDIR}/${crate_dir//%commit%/${commit}}\" };;"
done
diff --git a/eclass/rust.eclass b/eclass/rust.eclass
index 2bf0b27b3f40..eb14ca2329b5 100644
--- a/eclass/rust.eclass
+++ b/eclass/rust.eclass
@@ -102,6 +102,26 @@ declare -a -g -r _RUST_SLOTS_ORDERED=(
"1.54.0"
)
+# == user control knobs ==
+
+# @ECLASS_VARIABLE: ERUST_SLOT_OVERRIDE
+# @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
+# acceptable Rust version will be used. May be combined with ERUST_TYPE_OVERRIDE.
+# This variable must not be set in ebuilds.
+
+# @ECLASS_VARIABLE: ERUST_TYPE_OVERRIDE
+# @USER_VARIABLE
+# @DESCRIPTION:
+# Specify the type of Rust to be used by the package from options:
+# 'source' or 'binary' (-bin). This is useful for troubleshooting and
+# debugging purposes. If unset, the standard eclass logic will be used
+# to determine the type of Rust to use (i.e. prefer source if binary
+# is also available). May be combined with ERUST_SLOT_OVERRIDE.
+# This variable must not be set in ebuilds.
+
# == control variables ==
# @ECLASS_VARIABLE: RUST_MAX_VER
@@ -336,6 +356,10 @@ _get_rust_slot() {
fi
fi
+ if [[ -n "${ERUST_SLOT_OVERRIDE}" && "${slot}" != "${ERUST_SLOT_OVERRIDE}" ]]; then
+ continue
+ fi
+
# If we're in LLVM mode we can skip any slots that don't match the selected USE
if [[ -n "${RUST_NEEDS_LLVM}" ]]; then
if [[ "${llvm_slot}" != "${llvm_r1_slot}" ]]; then
@@ -349,12 +373,27 @@ _get_rust_slot() {
rust_check_deps && return
else
local usedep="${RUST_REQ_USE+[${RUST_REQ_USE}]}"
- # When checking for installed packages prefer the non `-bin` package
+ # When checking for installed packages prefer the source package;
# if effort was put into building it we should use it.
- local rust_pkgs=(
- "dev-lang/rust:${slot}${usedep}"
- "dev-lang/rust-bin:${slot}${usedep}"
- )
+ local rust_pkgs
+ case "${ERUST_TYPE_OVERRIDE}" in
+ source)
+ rust_pkgs=(
+ "dev-lang/rust:${slot}${usedep}"
+ )
+ ;;
+ binary)
+ rust_pkgs=(
+ "dev-lang/rust-bin:${slot}${usedep}"
+ )
+ ;;
+ *)
+ rust_pkgs=(
+ "dev-lang/rust:${slot}${usedep}"
+ "dev-lang/rust-bin:${slot}${usedep}"
+ )
+ ;;
+ esac
local _pkg
for _pkg in "${rust_pkgs[@]}"; do
if has_version "${hv_switch}" "${_pkg}"; then
diff --git a/eclass/toolchain.eclass b/eclass/toolchain.eclass
index 565a2f359488..8e91816735a9 100644
--- a/eclass/toolchain.eclass
+++ b/eclass/toolchain.eclass
@@ -775,7 +775,7 @@ tc_enable_hardened_gcc() {
hardened_gcc_flags+=" -DDEF_GENTOO_ZNOW"
fi
- if _tc_use_if_iuse cet && [[ ${CTARGET} == *x86_64*-linux-gnu* ]] ; then
+ if _tc_use_if_iuse cet && [[ -z ${CLANG_DISABLE_CET_HACK} && ${CTARGET} == *x86_64*-linux-gnu* ]] ; then
einfo "Updating gcc to use x86-64 control flow protection by default ..."
hardened_gcc_flags+=" -DEXTRA_OPTIONS_CF"
fi
@@ -1149,6 +1149,11 @@ toolchain_src_configure() {
export ac_cv_std_swap_in_utility=no
fi
+ # Workaround -march=native not working for stage1 with non-GCC (bug #933772).
+ if ! tc-is-gcc && [[ "${CFLAGS}${CXXFLAGS}" == *-march=native* ]] ; then
+ CLANG_DISABLE_CET_HACK=1
+ fi
+
local flag
for flag in $(all-flag-vars) ; do
einfo "${flag}=\"${!flag}\""
@@ -1308,7 +1313,7 @@ toolchain_src_configure() {
BUILD_CONFIG_TARGETS+=( bootstrap-lto )
fi
- if tc_version_is_at_least 12 && _tc_use_if_iuse cet && [[ ${CTARGET} == x86_64-*-gnu* ]] ; then
+ if tc_version_is_at_least 12 && _tc_use_if_iuse cet && [[ -z ${CLANG_DISABLE_CET_HACK} && ${CTARGET} == x86_64-*-gnu* ]] ; then
BUILD_CONFIG_TARGETS+=( bootstrap-cet )
fi
@@ -1694,7 +1699,7 @@ toolchain_src_configure() {
enable_cet_for 'x86_64' 'gnu' 'cet'
enable_cet_for 'aarch64' 'gnu' 'standard-branch-protection'
- [[ ${CTARGET} == i[34567]86-* ]] && confgcc+=( --disable-cet )
+ [[ -n ${CLANG_DISABLE_CET_HACK} || ${CTARGET} == i[34567]86-* ]] && confgcc+=( --disable-cet )
fi
if in_iuse systemtap ; then
@@ -2261,13 +2266,6 @@ gcc_do_make() {
STAGE1_CXXFLAGS="-O2"
fi
- # Workaround -march=native not working for stage1 with
- # non-GCC (bug #933772).
- if ! tc-is-gcc ; then
- STAGE1_CFLAGS+=" $(test-flags-CC -fcf-protection=none)"
- STAGE1_CXXFLAGS+=" $(test-flags-CXX -fcf-protection=none)"
- fi
-
# We only want to use the system's CFLAGS if not building a
# cross-compiler.
STAGE1_CFLAGS=${STAGE1_CFLAGS-"$(get_abi_CFLAGS ${TARGET_DEFAULT_ABI}) ${CFLAGS}"}