[gentoo-commits] repo/gentoo:master commit in: eclass/tests/, eclass/

2024-02-10 Thread Michał Górny
commit: 5618de75aec49009489efb560a89e014fd060524
Author: Michał Górny  gentoo  org>
AuthorDate: Mon Feb  5 19:29:36 2024 +
Commit: Michał Górny  gentoo  org>
CommitDate: Sat Feb 10 10:47:23 2024 +
URL:https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=5618de75

llvm-r1.eclass: Initial version

Bug: https://bugs.gentoo.org/923228
Bug: https://bugs.gentoo.org/880671
Closes: https://bugs.gentoo.org/821955
Closes: https://bugs.gentoo.org/919150
Signed-off-by: Michał Górny  gentoo.org>

 eclass/llvm-r1.eclass   | 250 
 eclass/tests/llvm-r1.sh | 151 +
 2 files changed, 401 insertions(+)

diff --git a/eclass/llvm-r1.eclass b/eclass/llvm-r1.eclass
new file mode 100644
index ..658946a1ecbd
--- /dev/null
+++ b/eclass/llvm-r1.eclass
@@ -0,0 +1,250 @@
+# Copyright 2024 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+# @ECLASS: llvm-r1.eclass
+# @MAINTAINER:
+# Michał Górny 
+# @AUTHOR:
+# Michał Górny 
+# @SUPPORTED_EAPIS: 8
+# @PROVIDES: llvm-utils
+# @BLURB: Provide LLVM_SLOT to build against slotted LLVM
+# @DESCRIPTION:
+# An eclass to reliably depend on a set of LLVM-related packages
+# in a matching slot.  To use the eclass:
+#
+# 1. Set LLVM_COMPAT to the list of supported LLVM slots.
+# 2. Use llvm_gen_dep and/or LLVM_USEDEP to add appropriate
+#dependencies.
+# 3. Use llvm-r1_pkg_setup, get_llvm_prefix or LLVM_SLOT.
+#
+# The eclass sets IUSE and REQUIRED_USE.  The flag corresponding
+# to the newest supported stable LLVM slot (or the newest testing,
+# if no stable slots are supported) is enabled by default.
+#
+# Example:
+# @CODE
+# LLVM_COMPAT=( {16..18} )
+#
+# inherit llvm-r1
+#
+# DEPEND="
+#   dev-libs/libfoo[${LLVM_USEDEP}]
+#   $(llvm_gen_dep '
+# sys-devel/clang:${LLVM_SLOT}
+# sys-devel/llvm:${LLVM_SLOT}
+#   ')
+# "
+# @CODE
+
+case ${EAPI} in
+   8) ;;
+   *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;;
+esac
+
+if [[ ! ${_LLVM_R1_ECLASS} ]]; then
+_LLVM_R1_ECLASS=1
+
+inherit llvm-utils
+
+# == internal control knobs ==
+
+# @ECLASS_VARIABLE: _LLVM_OLDEST_SLOT
+# @INTERNAL
+# @DESCRIPTION:
+# Oldest supported LLVM slot.  This is used to automatically filter out
+# unsupported LLVM_COMPAT values.
+_LLVM_OLDEST_SLOT=15
+
+# @ECLASS_VARIABLE: _LLVM_NEWEST_STABLE
+# @INTERNAL
+# @DESCRIPTION:
+# The newest stable LLVM version.  Versions newer than that won't
+# be automatically enabled via USE defaults.
+_LLVM_NEWEST_STABLE=17
+
+# == control variables ==
+
+# @ECLASS_VARIABLE: LLVM_COMPAT
+# @PRE_INHERIT
+# @REQUIRED
+# @DESCRIPTION:
+# A list of LLVM slots supported by the package, oldest to newest.
+#
+# Example:
+# @CODE
+# LLVM_COMPAT=( {15..17} )
+# @CODE
+
+# @ECLASS_VARIABLE: LLVM_OPTIONAL
+# @PRE_INHERIT
+# @DEFAULT_UNSET
+# @DESCRIPTION:
+# If set to a non-empty value, disables setting REQUIRED_USE
+# and exporting pkg_setup.  You have to add LLVM_REQUIRED_USE and call
+# pkg_setup manually, with appropriate USE conditions.
+
+# == global metadata ==
+
+# @ECLASS_VARIABLE: LLVM_REQUIRED_USE
+# @OUTPUT_VARIABLE
+# @DESCRIPTION:
+# An eclass-generated REQUIRED_USE string that enforces selecting
+# exactly one slot.  It LLVM_OPTIONAL is set, it needs to be copied
+# into REQUIRED_USE, under appropriate USE conditions.  Otherwise,
+# it is added automatically.
+
+# @ECLASS_VARIABLE: LLVM_USEDEP
+# @OUTPUT_VARIABLE
+# @DESCRIPTION:
+# An eclass-generated USE dependency string that can be applied to other
+# packages using the same eclass, to enforce a LLVM slot match.
+
+_llvm_set_globals() {
+   debug-print-function ${FUNCNAME} "${@}"
+
+   if [[ ${LLVM_COMPAT@a} != *a* ]]; then
+   die "LLVM_COMPAT must be set to an array before inheriting 
${ECLASS}"
+   fi
+
+   local stable=() unstable=()
+   local x
+   for x in "${LLVM_COMPAT[@]}"; do
+   if [[ ${x} -gt ${_LLVM_NEWEST_STABLE} ]]; then
+   unstable+=( "${x}" )
+   elif [[ ${x} -ge ${_LLVM_OLDEST_SLOT} ]]; then
+   stable+=( "${x}" )
+   fi
+   done
+
+   _LLVM_SLOTS=( "${stable[@]}" "${unstable[@]}" )
+   if [[ ! ${_LLVM_SLOTS[@]} ]]; then
+   die "LLVM_COMPAT does not contain any valid versions (all older 
than ${_LLVM_OLDEST_SLOT}?)"
+   fi
+
+   if [[ ${stable[@]} ]]; then
+   IUSE="+llvm_slot_${stable[-1]}"
+   unset 'stable[-1]'
+   else
+   IUSE="+llvm_slot_${unstable[-1]}"
+   unset 'unstable[-1]'
+   fi
+   local nondefault=( "${stable[@]}" "${unstable[@]}" )
+   IUSE+=" ${nondefault[*]/#/llvm_slot_}"
+
+   local flags=( "${_LLVM_SLOTS[@]/#/llvm_slot_}" )
+   LLVM_REQUIRED_USE="^^ ( ${flags[*]} )"
+   local usedep_flags=${flags[*]/%/(-)?}
+   LLVM_USEDEP=${usedep_flags// /,}
+   readonly LLVM_REQUIRED_USE LLVM_USEDEP
+
+   i

[gentoo-commits] repo/gentoo:master commit in: eclass/tests/, eclass/

2024-02-10 Thread Michał Górny
commit: 511ce42e90eccd89a8d0d2ccbc239578d6af11ea
Author: Michał Górny  gentoo  org>
AuthorDate: Wed Feb  7 16:34:34 2024 +
Commit: Michał Górny  gentoo  org>
CommitDate: Sat Feb 10 10:47:20 2024 +
URL:https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=511ce42e

llvm-utils.eclass: Introduce an eclass for common helpers

Move some reusable functions from llvm.eclass to llvm-utils.eclass.
This is with minimal modifications so far (only argument checks were
cleaned up).

Signed-off-by: Michał Górny  gentoo.org>

 eclass/llvm-utils.eclass   | 115 +
 eclass/llvm.eclass |  92 ++--
 eclass/tests/llvm-utils.sh |  82 
 3 files changed, 200 insertions(+), 89 deletions(-)

diff --git a/eclass/llvm-utils.eclass b/eclass/llvm-utils.eclass
new file mode 100644
index ..43988f6f88c7
--- /dev/null
+++ b/eclass/llvm-utils.eclass
@@ -0,0 +1,115 @@
+# Copyright 2024 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+# @ECLASS: llvm-utils.eclass
+# @MAINTAINER:
+# Michał Górny 
+# @AUTHOR:
+# Michał Górny 
+# @SUPPORTED_EAPIS: 7 8
+# @BLURB: Common utility functions for building against installed LLVM
+# @DESCRIPTION:
+# The utility eclass providing shared functions reused between
+# llvm.eclass and llvm-r1.eclass.  It may also be used directly
+# in ebuilds.
+
+case ${EAPI} in
+   7|8) ;;
+   *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;;
+esac
+
+if [[ ! ${_LLVM_UTILS_ECLASS} ]]; then
+_LLVM_UTILS_ECLASS=1
+
+# @FUNCTION: llvm_tuple_to_target
+# @USAGE: []
+# @DESCRIPTION:
+# Translate a tuple into a target suitable for LLVM_TARGETS.
+# Defaults to ${CHOST} if not specified.
+llvm_tuple_to_target() {
+   debug-print-function ${FUNCNAME} "${@}"
+
+   [[ ${#} -gt 1 ]] && die "Usage: ${FUNCNAME} []"
+
+   case ${1:-${CHOST}} in
+   aarch64*) echo "AArch64";;
+   amdgcn*) echo "AMDGPU";;
+   arc*) echo "ARC";;
+   arm*) echo "ARM";;
+   avr*) echo "AVR";;
+   bpf*) echo "BPF";;
+   csky*) echo "CSKY";;
+   loong*) echo "LoongArch";;
+   m68k*) echo "M68k";;
+   mips*) echo "Mips";;
+   msp430*) echo "MSP430";;
+   nvptx*) echo "NVPTX";;
+   powerpc*) echo "PowerPC";;
+   riscv*) echo "RISCV";;
+   sparc*) echo "Sparc";;
+   s390*) echo "SystemZ";;
+   x86_64*|i?86*) echo "X86";;
+   xtensa*) echo "Xtensa";;
+   *) die "Unknown LLVM target for tuple ${1:-${CHOST}}"
+   esac
+}
+
+# @FUNCTION: llvm_fix_clang_version
+# @USAGE: ...
+# @DESCRIPTION:
+# Fix the clang compiler name in specified variables to include
+# the major version, to prevent PATH alterations from forcing an older
+# clang version being used.
+llvm_fix_clang_version() {
+   debug-print-function ${FUNCNAME} "${@}"
+
+   local shopt_save=$(shopt -p -o noglob)
+   set -f
+   local var
+   for var; do
+   local split=( ${!var} )
+   case ${split[0]} in
+   *clang|*clang++|*clang-cpp)
+   local version=()
+   read -r -a version < <("${split[0]}" --version)
+   local major=${version[-1]%%.*}
+   if [[ -n ${major//[0-9]} ]]; then
+   die "${var}=${!var} produced invalid 
--version: ${version[*]}"
+   fi
+
+   split[0]+=-${major}
+   if ! type -P "${split[0]}" &>/dev/null; then
+   die "${split[0]} does not seem to exist"
+   fi
+   declare -g "${var}=${split[*]}"
+   ;;
+   esac
+   done
+   ${shopt_save}
+}
+
+# @FUNCTION: llvm_fix_tool_path
+# @USAGE: ...
+# @DESCRIPTION:
+# Fix the LLVM tools referenced in the specified variables to their
+# current location, to prevent PATH alterations from forcing older
+# versions being used.
+llvm_fix_tool_path() {
+   debug-print-function ${FUNCNAME} "${@}"
+
+   local shopt_save=$(shopt -p -o noglob)
+   set -f
+   local var
+   for var; do
+   local split=( ${!var} )
+   local path=$(type -P ${split[0]} 2>/dev/null)
+   # if it resides in one of the LLVM prefixes, it's an LLVM tool!
+   if [[ ${path} == "${BROOT}/usr/lib/llvm"* ]]; then
+   split[0]=${path}
+   declare -g "${var}=${split[*]}"
+   fi
+   done
+   ${shopt_save}
+}
+
+fi

diff --git a/eclass/llvm.eclass b/eclass/llvm.eclass
index 91cc68d966fe..05ffcfd7cc6d 100644
--- a

[gentoo-commits] repo/gentoo:master commit in: eclass/tests/, eclass/

2023-09-13 Thread Michał Górny
commit: e111329e222787152b6d99ce4b551c8758349aac
Author: Michał Górny  gentoo  org>
AuthorDate: Sun Sep  3 13:21:57 2023 +
Commit: Michał Górny  gentoo  org>
CommitDate: Thu Sep 14 05:30:10 2023 +
URL:https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=e111329e

verify-sig.eclass: Support `openssl dgst` format checksums

Signed-off-by: Michał Górny  gentoo.org>

 eclass/tests/verify-sig.sh | 18 
 eclass/verify-sig.eclass   | 54 ++
 2 files changed, 54 insertions(+), 18 deletions(-)

diff --git a/eclass/tests/verify-sig.sh b/eclass/tests/verify-sig.sh
index fcd2ee7480a2..fb7f2cdb2a5d 100755
--- a/eclass/tests/verify-sig.sh
+++ b/eclass/tests/verify-sig.sh
@@ -62,4 +62,22 @@ EOF
 test_verify_unsigned_checksums sha256
 eoutdent
 
+einfo "Testing openssl-dgst format."
+eindent
+
+> "annoying ( filename )= yes ).txt" || die
+
+cat > checksums.txt <<-EOF || die
+   junk text that ought to be ignored
+
+   
SHA256(empty)=e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
+   SHA256(text)= 
b47cc0f104b62d4c7c30bcd68fd8e67613e287dc4ad8c310ef10cbadea9c4380
+   
SHA256(fail)=b47cc0f104b62d4c7c30bcd68fd8e67613e287dc4ad8c310ef10cbadea9c4380
+
+   SHA256(annoying ( filename )= yes )= 
e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
+EOF
+
+test_verify_unsigned_checksums openssl-dgst
+eoutdent
+
 texit

diff --git a/eclass/verify-sig.eclass b/eclass/verify-sig.eclass
index d99dc3461858..815299b419ed 100644
--- a/eclass/verify-sig.eclass
+++ b/eclass/verify-sig.eclass
@@ -214,12 +214,15 @@ verify-sig_verify_message() {
 }
 
 # @FUNCTION: verify-sig_verify_unsigned_checksums
-# @USAGE:   
+# @USAGE:   
 # @DESCRIPTION:
 # Verify the checksums for all files listed in the space-separated list
-#  (akin to ${A}) using a .   specifies
-# the checksum algorithm (e.g. sha256).   can be "-"
-# for stdin.
+#  (akin to ${A}) using a .   specifies
+# the checksum file format.   can be "-" for stdin.
+#
+# The following formats are supported:
+#  - sha256 -- sha256sum ( )
+#  - openssl-dgst -- openssl dgst (()=)
 #
 # The function dies if one of the files does not match checksums or
 # is missing from the checksum file.
@@ -231,35 +234,50 @@ verify-sig_verify_message() {
 # verify-sig_verify_signed_checksums instead.
 verify-sig_verify_unsigned_checksums() {
local checksum_file=${1}
-   local algo=${2}
+   local format=${2}
local files=()
read -r -d '' -a files <<<"${3}"
-   local chksum_prog chksum_len
+   local chksum_prog chksum_len algo=${format}
 
-   case ${algo} in
+   case ${format} in
sha256)
-   chksum_prog=sha256sum
chksum_len=64
;;
+   openssl-dgst)
+   ;;
*)
-   die "${FUNCNAME}: unknown checksum algo ${algo}"
+   die "${FUNCNAME}: unknown checksum format ${format}"
;;
esac
 
[[ ${checksum_file} == - ]] && checksum_file=/dev/stdin
-   local checksum filename junk ret=0 count=0
-   while read -r checksum filename junk; do
-   if [[ ${checksum} == "-BEGIN" ]]; then
+   local line checksum filename junk ret=0 count=0
+   while read -r line; do
+   if [[ ${line} == "-BEGIN"* ]]; then
die "${FUNCNAME}: PGP armor found, use 
verify-sig_verify_signed_checksums instead"
fi
 
-   [[ ${#checksum} -eq ${chksum_len} ]] || continue
-   [[ -z ${checksum//[0-9a-f]} ]] || continue
-   has "${filename}" "${files[@]}" || continue
-   [[ -z ${junk} ]] || continue
+   case ${format} in
+   sha256)
+   read -r checksum filename junk <<<"${line}"
+   [[ ${#checksum} -ne ${chksum_len} ]] && continue
+   [[ -n ${checksum//[0-9a-f]} ]] && continue
+   [[ -n ${junk} ]] && continue
+   ;;
+   openssl-dgst)
+   [[ ${line} != *"("*")="* ]] && continue
+   checksum=${line##*)=}
+   algo=${line%%(*}
+   filename=${line#*(}
+   filename=${filename%)=*}
+   ;;
+   esac
+
+   if ! has "${filename}" "${files[@]}"; then
+   continue
+   fi
 
-   "${chksum_prog}" -c --strict - <<<"${checksum} ${filename}"
-   if [[ ${?} -eq 0 ]]; then
+   if "${algo,,}sum" -c --strict - <<<"${checksum} ${filename}"; 
then
(( count++ ))
else
r

[gentoo-commits] repo/gentoo:master commit in: eclass/tests/, eclass/

2023-07-02 Thread Michał Górny
commit: 6d9ca31b20ed4a4d7130602e67aa61385f8511e0
Author: Michał Górny  gentoo  org>
AuthorDate: Fri Jun 23 06:10:46 2023 +
Commit: Michał Górny  gentoo  org>
CommitDate: Sun Jul  2 15:06:27 2023 +
URL:https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=6d9ca31b

python-utils-r1.eclass: make pypy3 match Python 3.10 now

Signed-off-by: Michał Górny  gentoo.org>

 eclass/python-utils-r1.eclass   | 6 +++---
 eclass/tests/python-utils-r1.sh | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass
index 7a1be381f596..d2bbe90da049 100644
--- a/eclass/python-utils-r1.eclass
+++ b/eclass/python-utils-r1.eclass
@@ -238,12 +238,12 @@ _python_impl_matches() {
fi
return 0
;;
-   3.9)
-   # the only unmasked pypy3 version is pypy3.9 atm
+   3.9|3.10)
+   # =7.3.12 is 3.10
[[ ${impl} == python${pattern/./_} || ${impl} 
== pypy3 ]] &&
return 0
;;
-   3.8|3.1[0-2])
+   3.8|3.1[1-2])
[[ ${impl} == python${pattern/./_} ]] && return 0
;;
*)

diff --git a/eclass/tests/python-utils-r1.sh b/eclass/tests/python-utils-r1.sh
index 635d49decbdd..81c459765f0f 100755
--- a/eclass/tests/python-utils-r1.sh
+++ b/eclass/tests/python-utils-r1.sh
@@ -208,7 +208,7 @@ test_is "_python_impl_matches python3_11 3.12" 1
 test_is "_python_impl_matches python3_12 3.10" 1
 test_is "_python_impl_matches python3_12 3.11" 1
 test_is "_python_impl_matches python3_12 3.12" 0
-test_is "_python_impl_matches pypy3 3.10" 1
+test_is "_python_impl_matches pypy3 3.10" 0
 test_is "_python_impl_matches pypy3 3.11" 1
 test_is "_python_impl_matches pypy3 3.12" 1
 eoutdent



[gentoo-commits] repo/gentoo:master commit in: eclass/tests/, eclass/

2023-06-18 Thread Michał Górny
commit: ac817be5fd5756bcd017e41321cf5731cd291c54
Author: Michał Górny  gentoo  org>
AuthorDate: Thu Jun 15 15:31:16 2023 +
Commit: Michał Górny  gentoo  org>
CommitDate: Sun Jun 18 14:57:46 2023 +
URL:https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=ac817be5

cargo.eclass: Support separating crate names/versions via `@`

Support specifying crate names and versions separated by `@` character
rather than `-`.  Since `@` are not valid in crate names, this
makes splitting the tokens trivial and free of regular expressions.
Effectively, the `@` variant is roughly 180% faster:

```
 * CRATES with '@' separator
real  952 it/s
user  952 it/s
 * CRATES with '-' separator
real  339 it/s
user  339 it/s
```

Signed-off-by: Michał Górny  gentoo.org>

 eclass/cargo.eclass |  24 +++---
 eclass/tests/cargo-bench.sh | 111 +++-
 2 files changed, 75 insertions(+), 60 deletions(-)

diff --git a/eclass/cargo.eclass b/eclass/cargo.eclass
index d97bb0df9348..8618c90bd986 100644
--- a/eclass/cargo.eclass
+++ b/eclass/cargo.eclass
@@ -59,12 +59,16 @@ ECARGO_VENDOR="${ECARGO_HOME}/gentoo"
 # Bash string containing all crates that are to be downloaded.
 # It is used by cargo_crate_uris.
 #
+# Ideally, crate names and versions should be separated by a `@`
+# character.  A legacy syntax using hyphen is also supported but it is
+# much slower.
+#
 # Example:
 # @CODE
 # CRATES="
-# metal-1.2.3
-# bar-4.5.6
-# iron_oxide-0.0.1
+# metal@1.2.3
+# bar@4.5.6
+# iron_oxide@0.0.1
 # "
 # inherit cargo
 # ...
@@ -182,10 +186,16 @@ _cargo_set_crate_uris() {
CARGO_CRATE_URIS=
for crate in ${crates}; do
local name version url
-   [[ $crate =~ $regex ]] || die "Could not parse name and version 
from crate: $crate"
-   name="${BASH_REMATCH[1]}"
-   version="${BASH_REMATCH[2]}"
-   
url="https://crates.io/api/v1/crates/${name}/${version}/download -> 
${crate}.crate"
+   if [[ ${crate} == *@* ]]; then
+   name=${crate%@*}
+   version=${crate##*@}
+   else
+   [[ ${crate} =~ ${regex} ]] ||
+   die "Could not parse name and version from 
crate: ${crate}"
+   name="${BASH_REMATCH[1]}"
+   version="${BASH_REMATCH[2]}"
+   fi
+   
url="https://crates.io/api/v1/crates/${name}/${version}/download -> 
${name}-${version}.crate"
CARGO_CRATE_URIS+="${url} "
done
 

diff --git a/eclass/tests/cargo-bench.sh b/eclass/tests/cargo-bench.sh
index 11b740f8dfcd..d30b04569905 100755
--- a/eclass/tests/cargo-bench.sh
+++ b/eclass/tests/cargo-bench.sh
@@ -47,63 +47,68 @@ timeit() {
 
 # taken from cryptograpy-41.0.1
 CRATES="
-   Inflector-0.11.4
-   aliasable-0.1.3
-   asn1-0.15.2
-   asn1_derive-0.15.2
-   autocfg-1.1.0
-   base64-0.13.1
-   bitflags-1.3.2
-   cc-1.0.79
-   cfg-if-1.0.0
-   foreign-types-0.3.2
-   foreign-types-shared-0.1.1
-   indoc-1.0.9
-   libc-0.2.144
-   lock_api-0.4.9
-   memoffset-0.8.0
-   once_cell-1.17.2
-   openssl-0.10.54
-   openssl-macros-0.1.1
-   openssl-sys-0.9.88
-   ouroboros-0.15.6
-   ouroboros_macro-0.15.6
-   parking_lot-0.12.1
-   parking_lot_core-0.9.7
-   pem-1.1.1
-   pkg-config-0.3.27
-   proc-macro-error-1.0.4
-   proc-macro-error-attr-1.0.4
-   proc-macro2-1.0.59
-   pyo3-0.18.3
-   pyo3-build-config-0.18.3
-   pyo3-ffi-0.18.3
-   pyo3-macros-0.18.3
-   pyo3-macros-backend-0.18.3
-   quote-1.0.28
-   redox_syscall-0.2.16
-   scopeguard-1.1.0
-   smallvec-1.10.0
-   syn-1.0.109
-   syn-2.0.18
-   target-lexicon-0.12.7
-   unicode-ident-1.0.9
-   unindent-0.1.11
-   vcpkg-0.2.15
-   version_check-0.9.4
-   windows-sys-0.45.0
-   windows-targets-0.42.2
-   windows_aarch64_gnullvm-0.42.2
-   windows_aarch64_msvc-0.42.2
-   windows_i686_gnu-0.42.2
-   windows_i686_msvc-0.42.2
-   windows_x86_64_gnu-0.42.2
-   windows_x86_64_gnullvm-0.42.2
-   windows_x86_64_msvc-0.42.2
+   Inflector@0.11.4
+   aliasable@0.1.3
+   asn1@0.15.2
+   asn1_derive@0.15.2
+   autocfg@1.1.0
+   base64@0.13.1
+   bitflags@1.3.2
+   cc@1.0.79
+   cfg-if@1.0.0
+   foreign-types@0.3.2
+   foreign-types-shared@0.1.1
+   indoc@1.0.9
+   libc@0.2.144
+   lock_api@0.4.9
+   memoffset@0.8.0
+   once_cell@1.17.2
+   openssl@0.10.54
+   openssl-macros@0.1.1
+   openssl-sys@0.9.88
+   ouroboros@0.15.6
+   ouroboros_macro@0.15.6
+   parking_lot@0.12.1
+   parking_lot_core@0.9.7
+   pem@1.1.1
+   pkg-config@0.3.27
+   proc-macro-error@1.0.4
+   proc-macro-error-attr@1.0.4
+   proc-macro2@1.0.

[gentoo-commits] repo/gentoo:master commit in: eclass/tests/, eclass/

2023-06-18 Thread Michał Górny
commit: 59dbfb80f748a0fc5741a8f3028f7552af28eecf
Author: Michał Górny  gentoo  org>
AuthorDate: Thu Jun 15 15:20:43 2023 +
Commit: Michał Górny  gentoo  org>
CommitDate: Sun Jun 18 14:57:44 2023 +
URL:https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=59dbfb80

cargo.eclass: Add variable alternative to $(cargo_crate_uris)

Add a helper function that sets ${CARGO_CRATE_URIS} variable to make
it possible to set SRC_URI without subshells.  This gives a slight
speedup (~20%):

```
real  300 it/s
user  324 it/s
```

Signed-off-by: Michał Górny  gentoo.org>

 eclass/cargo.eclass | 48 +++--
 eclass/tests/cargo-bench.sh |  4 +++-
 2 files changed, 36 insertions(+), 16 deletions(-)

diff --git a/eclass/cargo.eclass b/eclass/cargo.eclass
index 991e808d453f..4e0cd1e4de70 100644
--- a/eclass/cargo.eclass
+++ b/eclass/cargo.eclass
@@ -68,7 +68,7 @@ ECARGO_VENDOR="${ECARGO_HOME}/gentoo"
 # "
 # inherit cargo
 # ...
-# SRC_URI="$(cargo_crate_uris)"
+# SRC_URI="${CARGO_CRATE_URIS}"
 # @CODE
 
 # @ECLASS_VARIABLE: GIT_CRATES
@@ -162,31 +162,31 @@ ECARGO_VENDOR="${ECARGO_HOME}/gentoo"
 # group, and then switch over to building with FEATURES=userpriv.
 # Or vice-versa.
 
-# @FUNCTION: cargo_crate_uris
+# @ECLASS_VARIABLE: CARGO_CRATE_URIS
+# @OUTPUT_VARIABLE
+# @DESCRIPTION:
+# List of URIs to put in SRC_URI created from CRATES variable.
+
+# @FUNCTION: _cargo_set_crate_uris
+# @USAGE: 
 # @DESCRIPTION:
 # Generates the URIs to put in SRC_URI to help fetch dependencies.
 # Constructs a list of crates from its arguments.
 # If no arguments are provided, it uses the CRATES variable.
-cargo_crate_uris() {
+# The value is set as CARGO_CRATE_URIS.
+_cargo_set_crate_uris() {
local -r regex='^([a-zA-Z0-9_\-]+)-([0-9]+\.[0-9]+\.[0-9]+.*)$'
-   local crate crates
-
-   if [[ -n ${@} ]]; then
-   crates="$@"
-   elif [[ -n ${CRATES} ]]; then
-   crates="${CRATES}"
-   else
-   eerror "CRATES variable is not defined and nothing passed as 
argument"
-   die "Can't generate SRC_URI from empty input"
-   fi
+   local crates=${1}
+   local crate
 
+   CARGO_CRATE_URIS=
for crate in ${crates}; do
local name version url
[[ $crate =~ $regex ]] || die "Could not parse name and version 
from crate: $crate"
name="${BASH_REMATCH[1]}"
version="${BASH_REMATCH[2]}"

url="https://crates.io/api/v1/crates/${name}/${version}/download -> 
${crate}.crate"
-   echo "${url}"
+   CARGO_CRATE_URIS+="${url} "
done
 
local git_crates_type
@@ -214,12 +214,30 @@ cargo_crate_uris() {
;;
esac
 
-   printf -- '%s -> %s\n' 
"${crate_uri//%commit%/${commit}}" "${repo_name}-${commit}${repo_ext}.tar.gz"
+   CARGO_CRATE_URIS+="${crate_uri//%commit%/${commit}} -> 
${repo_name}-${commit}${repo_ext}.tar.gz "
done
elif [[ -n ${git_crates_type} ]]; then
die "GIT_CRATE must be declared as an associative array"
fi
 }
+_cargo_set_crate_uris "${CRATES}"
+
+# @FUNCTION: cargo_crate_uris
+# @USAGE: [...]
+# @DESCRIPTION:
+# Generates the URIs to put in SRC_URI to help fetch dependencies.
+# Constructs a list of crates from its arguments.
+# If no arguments are provided, it uses the CRATES variable.
+cargo_crate_uris() {
+   local crates=${*-${CRATES}}
+   if [[ -z ${crates} ]]; then
+   eerror "CRATES variable is not defined and nothing passed as 
argument"
+   die "Can't generate SRC_URI from empty input"
+   fi
+
+   _cargo_set_crate_uris "${crates}"
+   echo "${CARGO_CRATE_URIS}"
+}
 
 # @FUNCTION: cargo_gen_config
 # @DESCRIPTION:

diff --git a/eclass/tests/cargo-bench.sh b/eclass/tests/cargo-bench.sh
index cdc5e4431c14..11b740f8dfcd 100755
--- a/eclass/tests/cargo-bench.sh
+++ b/eclass/tests/cargo-bench.sh
@@ -12,8 +12,9 @@ RUNS=3
 
 doit() {
for (( i = 0; i < ITERATIONS; i++ )); do
+   _cargo_set_crate_uris "${CRATES}"
SRC_URI="
-   $(cargo_crate_uris)
+   ${CARGO_CRATE_URIS}
"
done
 }
@@ -102,6 +103,7 @@ CRATES="
 "
 
 inherit cargo
+
 timeit
 
 texit



[gentoo-commits] repo/gentoo:master commit in: eclass/tests/, eclass/

2023-06-07 Thread Ulrich Müller
commit: 610b01ff117232fde9068a9e97e7355d6e53f2e4
Author: Ulrich Müller  gentoo  org>
AuthorDate: Wed Jun  7 08:42:07 2023 +
Commit: Ulrich Müller  gentoo  org>
CommitDate: Wed Jun  7 08:56:25 2023 +
URL:https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=610b01ff

eapi8-dosym.eclass: Fix another corner case of strange input

Signed-off-by: Ulrich Müller  gentoo.org>

 eclass/eapi8-dosym.eclass   | 4 ++--
 eclass/tests/eapi8-dosym.sh | 1 +
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/eclass/eapi8-dosym.eclass b/eclass/eapi8-dosym.eclass
index e139b74cfea0..866c98c78d91 100644
--- a/eclass/eapi8-dosym.eclass
+++ b/eclass/eapi8-dosym.eclass
@@ -31,7 +31,7 @@ esac
 _dosym8_canonicalize() {
local path slash i prev out IFS=/
 
-   read -r -d '' -a path < <(echo -n "$1")
+   read -r -d '' -a path < <(printf '%s\0' "$1")
[[ $1 == /* ]] && slash=/
 
while true; do
@@ -56,7 +56,7 @@ _dosym8_canonicalize() {
done
 
out="${slash}${path[*]}"
-   echo "${out:-.}"
+   printf "%s\n" "${out:-.}"
 }
 
 # @FUNCTION: dosym8

diff --git a/eclass/tests/eapi8-dosym.sh b/eclass/tests/eapi8-dosym.sh
index cae66e3bb2ee..a0f8961d4d96 100755
--- a/eclass/tests/eapi8-dosym.sh
+++ b/eclass/tests/eapi8-dosym.sh
@@ -54,6 +54,7 @@ teq foo _dosym8_canonicalize foo/.
 teq ../foo _dosym8_canonicalize ../foo
 teq ../baz _dosym8_canonicalize foo/bar/../../../baz
 teq '*' _dosym8_canonicalize '*'
+teq '-e' _dosym8_canonicalize '-e'
 
 for f in ref_dosym_r "dosym8 -r"; do
teq ../../bin/foo ${f} /bin/foo /usr/bin/foo



[gentoo-commits] repo/gentoo:master commit in: eclass/tests/, eclass/, profiles/base/, app-portage/gpyutils/files/, ...

2023-01-14 Thread David Seifert
commit: 69b674e49e70369b4a5da3a958f4e1556d6b01f7
Author: David Seifert  gentoo  org>
AuthorDate: Sat Jan 14 11:16:16 2023 +
Commit: David Seifert  gentoo  org>
CommitDate: Sat Jan 14 11:16:16 2023 +
URL:https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=69b674e4

python-utils-r1.eclass: remove py3.8

Signed-off-by: David Seifert  gentoo.org>

 app-portage/gpyutils/files/implementations.txt |  2 +-
 eclass/python-utils-r1.eclass  | 10 --
 eclass/tests/python-utils-r1.sh| 17 ++---
 profiles/base/package.use.force|  3 +--
 profiles/desc/python_single_target.desc|  3 +--
 profiles/desc/python_targets.desc  |  3 +--
 6 files changed, 18 insertions(+), 20 deletions(-)

diff --git a/app-portage/gpyutils/files/implementations.txt 
b/app-portage/gpyutils/files/implementations.txt
index 88202c6748a3..ab471bfc7b49 100644
--- a/app-portage/gpyutils/files/implementations.txt
+++ b/app-portage/gpyutils/files/implementations.txt
@@ -17,7 +17,7 @@ python3_4 dead3.4
 python3_5  dead3.5
 python3_6  dead3.6
 python3_7  dead3.7
-python3_8  old 3.8
+python3_8  dead3.8
 python3_9  old 3.9
 python3_10 current 3.10
 python3_11 supported   3.11

diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass
index 83bf5d035c4a..43472bd1fae0 100644
--- a/eclass/python-utils-r1.eclass
+++ b/eclass/python-utils-r1.eclass
@@ -40,7 +40,7 @@ inherit multiprocessing toolchain-funcs
 # All supported Python implementations, most preferred last.
 _PYTHON_ALL_IMPLS=(
pypy3
-   python3_{8..11}
+   python3_{9..11}
 )
 readonly _PYTHON_ALL_IMPLS
 
@@ -52,7 +52,7 @@ _PYTHON_HISTORICAL_IMPLS=(
jython2_7
pypy pypy1_{8,9} pypy2_0
python2_{5..7}
-   python3_{1..7}
+   python3_{1..8}
 )
 readonly _PYTHON_HISTORICAL_IMPLS
 
@@ -129,9 +129,9 @@ _python_set_impls() {
# please keep them in sync with _PYTHON_ALL_IMPLS
# and _PYTHON_HISTORICAL_IMPLS
case ${i} in
-   pypy3|python3_[89]|python3_1[01])
+   pypy3|python3_9|python3_1[01])
;;
-   
jython2_7|pypy|pypy1_[89]|pypy2_0|python2_[5-7]|python3_[1-7])
+   
jython2_7|pypy|pypy1_[89]|pypy2_0|python2_[5-7]|python3_[1-8])
obsolete+=( "${i}" )
;;
*)
@@ -440,8 +440,6 @@ _python_export() {
PYTHON_PKG_DEP)
local d
case ${impl} in
-   python3.8)
-   
PYTHON_PKG_DEP=">=dev-lang/python-3.8.16:3.8";;
python3.9)

PYTHON_PKG_DEP=">=dev-lang/python-3.9.16:3.9";;
python3.10)

diff --git a/eclass/tests/python-utils-r1.sh b/eclass/tests/python-utils-r1.sh
index 6a1d2f98cbf9..9d37bf0b24d0 100755
--- a/eclass/tests/python-utils-r1.sh
+++ b/eclass/tests/python-utils-r1.sh
@@ -1,5 +1,5 @@
 #!/bin/bash
-# Copyright 1999-2020 Gentoo Authors
+# Copyright 1999-2023 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 EAPI=7
@@ -64,7 +64,7 @@ tmpfile=$(mktemp)
 
 inherit python-utils-r1
 
-for minor in 8 9 10 11; do
+for minor in 9 10 11; do
ebegin "Testing python3.${minor}"
eindent
test_var EPYTHON "python3_${minor}" "python3.${minor}"
@@ -199,15 +199,18 @@ test_is "_python_impl_matches python3_6 python*" 0
 test_is "_python_impl_matches python3_7 python*" 0
 test_is "_python_impl_matches pypy3 python*" 1
 set +f
-test_is "_python_impl_matches python3_8 3.8" 0
-test_is "_python_impl_matches python3_8 3.9" 1
-test_is "_python_impl_matches python3_8 3.10" 1
-test_is "_python_impl_matches python3_9 3.8" 1
 test_is "_python_impl_matches python3_9 3.9" 0
 test_is "_python_impl_matches python3_9 3.10" 1
-test_is "_python_impl_matches pypy3 3.8" 1
+test_is "_python_impl_matches python3_9 3.11" 1
+test_is "_python_impl_matches python3_10 3.9" 1
+test_is "_python_impl_matches python3_10 3.10" 0
+test_is "_python_impl_matches python3_10 3.11" 1
+test_is "_python_impl_matches python3_11 3.9" 1
+test_is "_python_impl_matches python3_11 3.10" 1
+test_is "_python_impl_matches python3_11 3.11" 0
 test_is "_python_impl_matches pypy3 3.9" 0
 test_is "_python_impl_matches pypy3 3.10" 1
+test_is "_python_impl_matches pypy3 3.11" 1
 eoutdent
 
 rm "${tmpfile}"

diff --git a/profiles/base/package.use.force b/profiles/base/package.use.force
index fbce620680a2..7521

[gentoo-commits] repo/gentoo:master commit in: eclass/tests/, eclass/

2022-11-15 Thread Michał Górny
commit: 95a6dff78a57dde2133dba050d16cae2c5113b23
Author: Michał Górny  gentoo  org>
AuthorDate: Fri Oct 28 09:59:52 2022 +
Commit: Michał Górny  gentoo  org>
CommitDate: Tue Nov 15 16:34:06 2022 +
URL:https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=95a6dff7

scons-utils.eclass: Reuse makeopts_jobs

Closes: https://github.com/gentoo/gentoo/pull/27999
Signed-off-by: Michał Górny  gentoo.org>

 eclass/scons-utils.eclass   | 102 ++--
 eclass/tests/scons-utils.sh |  64 ---
 2 files changed, 4 insertions(+), 162 deletions(-)

diff --git a/eclass/scons-utils.eclass b/eclass/scons-utils.eclass
index cbe92f6fc385..acb51300f348 100644
--- a/eclass/scons-utils.eclass
+++ b/eclass/scons-utils.eclass
@@ -71,8 +71,8 @@
 # @DEFAULT_UNSET
 # @DESCRIPTION:
 # The default set of options to pass to scons. Similar to MAKEOPTS,
-# supposed to be set in make.conf. If unset, escons() will use cleaned
-# up MAKEOPTS instead.
+# supposed to be set in make.conf. If unset, escons() will set -j
+# based on MAKEOPTS.
 
 # @ECLASS_VARIABLE: EXTRA_ESCONS
 # @USER_VARIABLE
@@ -148,11 +148,8 @@ escons() {
die "EPYTHON unset in escons"
fi
 
-   # if SCONSOPTS are _unset_, use cleaned MAKEOPTS
-   if [[ ! ${SCONSOPTS+set} ]]; then
-   local SCONSOPTS
-   _scons_clean_makeopts
-   fi
+   # if SCONSOPTS are unset, grab -j from MAKEOPTS
+   : "${SCONSOPTS:=-j$(makeopts_jobs)}"
 
# pass ebuild environment variables through!
local -x GENTOO_SCONS_ENV_PASSTHROUGH=1
@@ -161,94 +158,3 @@ escons() {
echo "${@}" >&2
"${@}" || die -n "escons failed."
 }
-
-# @FUNCTION: _scons_clean_makeopts
-# @USAGE: [makeflags] [...]
-# @INTERNAL
-# @DESCRIPTION:
-# Strip the supplied makeflags (or ${MAKEOPTS} if called without
-# an argument) of options not supported by SCons and make sure --jobs
-# gets an argument. Output the resulting flag list (suitable
-# for an assignment to SCONSOPTS).
-_scons_clean_makeopts() {
-   local new_makeopts=()
-
-   debug-print-function ${FUNCNAME} "${@}"
-
-   if [[ ${#} -eq 0 ]]; then
-   debug-print "Using MAKEOPTS: [${MAKEOPTS}]"
-   set -- ${MAKEOPTS}
-   else
-   # unquote if necessary
-   set -- ${*}
-   fi
-
-   # empty MAKEOPTS give out empty SCONSOPTS
-   # thus, we do need to worry about the initial setup
-   if [[ ${*} = ${_SCONS_CACHE_MAKEOPTS} ]]; then
-   SCONSOPTS=${_SCONS_CACHE_SCONSOPTS}
-   debug-print "Cache hit: [${SCONSOPTS}]"
-   return
-   fi
-   _SCONS_CACHE_MAKEOPTS=${*}
-
-   while [[ ${#} -gt 0 ]]; do
-   case ${1} in
-   # clean, simple to check -- we like that
-   --jobs=*|--keep-going)
-   new_makeopts+=( ${1} )
-   ;;
-   # need to take a look at the next arg and guess
-   --jobs)
-   if [[ ${#} -gt 1 && ${2} =~ ^[0-9]+$ ]]; then
-   new_makeopts+=( ${1} ${2} )
-   shift
-   else
-   # no value means no limit, let's pass a 
default instead
-   new_makeopts+=( ${1}=$(( $(get_nproc) + 
1 )) )
-   fi
-   ;;
-   # strip other long options
-   --*)
-   ;;
-   # short option hell
-   -*)
-   local str new_optstr
-   new_optstr=
-   str=${1#-}
-
-   while [[ -n ${str} ]]; do
-   case ${str} in
-   k*)
-   new_optstr+=k
-   ;;
-   # -j needs to come last
-   j)
-   if [[ ${#} -gt 1 && 
${2} =~ ^[0-9]+$ ]]; then
-   new_optstr+="j 
${2}"
-   shift
-   else
-   new_optstr+="j 
$(( $(get_nproc) + 1 ))"
-   fi
-   ;;
-   # otherwise, everything after 
-j is treated as an arg
-  

[gentoo-commits] repo/gentoo:master commit in: eclass/tests/, eclass/

2022-10-10 Thread Michał Górny
commit: 96ddadb40ddba1bfdba68ff8f2fd889cfd004f03
Author: Michał Górny  gentoo  org>
AuthorDate: Fri Oct  7 15:22:01 2022 +
Commit: Michał Górny  gentoo  org>
CommitDate: Mon Oct 10 20:52:35 2022 +
URL:https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=96ddadb4

toolchain-funcs.eclass: Add tc-get-c-rtlib() to get CC runtime

Add a new tc-get-c-rtlib() that attempts to get the runtime used
by the current C compiler.  Currently it supports compiler-rt
and libgcc.

Signed-off-by: Michał Górny  gentoo.org>

 eclass/tests/toolchain-funcs.sh | 10 ++
 eclass/toolchain-funcs.eclass   | 28 
 2 files changed, 38 insertions(+)

diff --git a/eclass/tests/toolchain-funcs.sh b/eclass/tests/toolchain-funcs.sh
index 5a35a44ce018..d8a357fb24fe 100755
--- a/eclass/tests/toolchain-funcs.sh
+++ b/eclass/tests/toolchain-funcs.sh
@@ -202,6 +202,10 @@ if type -P gcc &>/dev/null; then
tbegin "tc-get-cxx-stdlib (gcc)"
[[ $(CXX=g++ tc-get-cxx-stdlib) == libstdc++ ]]
tend $?
+
+   tbegin "tc-get-c-rtlib (gcc)"
+   [[ $(CC=gcc tc-get-c-rtlib) == libgcc ]]
+   tend $?
 fi
 
 if type -P clang &>/dev/null; then
@@ -218,6 +222,12 @@ if type -P clang &>/dev/null; then
tbegin "tc-get-cxx-stdlib (clang, invalid)"
! CXX=clang++ CXXFLAGS="-stdlib=invalid" tc-get-cxx-stdlib
tend $?
+
+   for rtlib in compiler-rt libgcc; do
+   tbegin "tc-get-c-rtlib (clang, ${rtlib})"
+   [[ $(CC=clang CFLAGS="--rtlib=${rtlib}" tc-get-c-rtlib) == 
${rtlib} ]]
+   tend $?
+   done
 fi
 
 texit

diff --git a/eclass/toolchain-funcs.eclass b/eclass/toolchain-funcs.eclass
index 92494158201e..32e446cb2368 100644
--- a/eclass/toolchain-funcs.eclass
+++ b/eclass/toolchain-funcs.eclass
@@ -1209,4 +1209,32 @@ tc-get-cxx-stdlib() {
return 0
 }
 
+# @FUNCTION: tc-get-c-rtlib
+# @DESCRIPTION:
+# Attempt to identify the runtime used by the C/C++ compiler.
+# If the runtime is identifed, the function returns 0 and prints one
+# of the following:
+#
+# - ``compiler-rt`` for ``sys-libs/compiler-rt``
+# - ``libgcc`` for ``sys-devel/gcc``'s libgcc
+#
+# If the runtime is not recognized, the function returns 1.
+tc-get-c-rtlib() {
+   local res=$(
+   $(tc-getCC) ${CFLAGS} ${CPPFLAGS} ${LDFLAGS} \
+   -print-libgcc-file-name 2>/dev/null
+   )
+
+   case ${res} in
+   *libclang_rt*)
+   echo compiler-rt;;
+   *libgcc*)
+   echo libgcc;;
+   *)
+   return 1;;
+   esac
+
+   return 0
+}
+
 fi



[gentoo-commits] repo/gentoo:master commit in: eclass/tests/, eclass/

2022-09-28 Thread Michał Górny
commit: 725aa5a066e69f5611e40c3cc84660eee07f940c
Author: Michał Górny  gentoo  org>
AuthorDate: Wed Sep 28 20:44:47 2022 +
Commit: Michał Górny  gentoo  org>
CommitDate: Wed Sep 28 20:55:24 2022 +
URL:https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=725aa5a0

unpacker.eclass: Workaround zstd refusing to process symlinks

Closes: https://bugs.gentoo.org/873352
Signed-off-by: Michał Górny  gentoo.org>

 eclass/tests/unpacker.sh | 7 ++-
 eclass/unpacker.eclass   | 4 ++--
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/eclass/tests/unpacker.sh b/eclass/tests/unpacker.sh
index b15953966f65..105f28fd4858 100755
--- a/eclass/tests/unpacker.sh
+++ b/eclass/tests/unpacker.sh
@@ -42,9 +42,14 @@ test_unpack() {
eval "${packcmd}"
assert "packing ${archive} failed"
cd testdir || die
+
+   # create a symlink to flush out compressor issues and resemble distdir 
more
+   # https://bugs.gentoo.org/873352
+   ln -s "../${archive}" "${archive}" || die
+
local out
out=$(
-   _unpacker "../${archive}" 2>&1
+   _unpacker "${archive}" 2>&1
)
ret=$?
if [[ ${ret} -eq 0 ]]; then

diff --git a/eclass/unpacker.eclass b/eclass/unpacker.eclass
index 3d23151b636e..6c9bcbdd7a7b 100644
--- a/eclass/unpacker.eclass
+++ b/eclass/unpacker.eclass
@@ -523,11 +523,11 @@ _unpacker() {
if [[ -z ${arch} ]] ; then
# Need to decompress the file into $PWD #408801
local _a=${a%.*}
-   ${comp} "${a}" > "${_a##*/}"
+   ${comp} < "${a}" > "${_a##*/}"
elif [[ -z ${comp} ]] ; then
${arch} "${a}"
else
-   ${comp} "${a}" | ${arch} -
+   ${comp} < "${a}" | ${arch} -
fi
 
assert "unpacking ${a} failed (comp=${comp} arch=${arch})"



[gentoo-commits] repo/gentoo:master commit in: eclass/tests/, eclass/

2022-05-01 Thread Michał Górny
commit: a00223eb88742885325b8863ba080e7d94202d8f
Author: Michał Górny  gentoo  org>
AuthorDate: Thu Apr 28 10:44:02 2022 +
Commit: Michał Górny  gentoo  org>
CommitDate: Sun May  1 07:30:36 2022 +
URL:https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=a00223eb

multiprocessing.eclass: Default makeopts_jobs to inf=nproc+1

Change the default value for 'inf' argument to makeopts_jobs from 999
to $(get_nproc) + 1.  This means that if MAKEOPTS specifies a `-j`
argument without a specific value, nproc will be used rather than
infinity-ish number of jobs.

The old default made sense for ebuilds using both makeopts_jobs
and makeopts_loadavg.  However, these are very rare — only 4 packages
and 3 eclass at this time.  For the remaining ebuilds, they meant
uncontrollably using up to 999 jobs.

The new default is both safer and more correct for the vast majority
of Gentoo packages, removing the necessity of repeating:

$(makeopts_jobs "${MAKEOPTS}" "$(get_nproc)")

The ebuilds and eclasses using makeopts_loadavg have been updated
to pass the old default.

Signed-off-by: Michał Górny  gentoo.org>

 eclass/multiprocessing.eclass | 11 +--
 eclass/tests/multiprocessing_makeopts_jobs.sh | 15 ++-
 2 files changed, 15 insertions(+), 11 deletions(-)

diff --git a/eclass/multiprocessing.eclass b/eclass/multiprocessing.eclass
index c32bfaac2e6b..e55be636a02c 100644
--- a/eclass/multiprocessing.eclass
+++ b/eclass/multiprocessing.eclass
@@ -1,4 +1,4 @@
-# Copyright 1999-2021 Gentoo Authors
+# Copyright 1999-2022 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 # @ECLASS: multiprocessing.eclass
@@ -65,22 +65,21 @@ get_nproc() {
 }
 
 # @FUNCTION: makeopts_jobs
-# @USAGE: [${MAKEOPTS}] [${inf:-999}]
+# @USAGE: [${MAKEOPTS}] [${inf:-$(( $(get_nproc) + 1 ))}]
 # @DESCRIPTION:
 # Searches the arguments (defaults to ${MAKEOPTS}) and extracts the jobs number
 # specified therein.  Useful for running non-make tools in parallel too.
 # i.e. if the user has MAKEOPTS=-j9, this will echo "9" -- we can't return the
 # number as bash normalizes it to [0, 255].  If the flags haven't specified a
-# -j flag, then "1" is shown as that is the default `make` uses.  Since there's
-# no way to represent infinity, we return ${inf} (defaults to 999) if the user
-# has -j without a number.
+# -j flag, then "1" is shown as that is the default `make` uses.  If the flags
+# specify -j without a number, ${inf} is returned (defaults to nproc).
 makeopts_jobs() {
[[ $# -eq 0 ]] && set -- "${MAKEOPTS}"
# This assumes the first .* will be more greedy than the second .*
# since POSIX doesn't specify a non-greedy match (i.e. ".*?").
local jobs=$(echo " $* " | sed -r -n \
-e 
's:.*[[:space:]](-[a-z]*j|--jobs[=[:space:]])[[:space:]]*([0-9]+).*:\2:p' \
-   -e "s:.*[[:space:]](-[a-z]*j|--jobs)[[:space:]].*:${2:-999}:p")
+   -e "s:.*[[:space:]](-[a-z]*j|--jobs)[[:space:]].*:${2:-$(( 
$(get_nproc) + 1 ))}:p")
echo ${jobs:-1}
 }
 

diff --git a/eclass/tests/multiprocessing_makeopts_jobs.sh 
b/eclass/tests/multiprocessing_makeopts_jobs.sh
index 70a6085d5362..37d5a7257775 100755
--- a/eclass/tests/multiprocessing_makeopts_jobs.sh
+++ b/eclass/tests/multiprocessing_makeopts_jobs.sh
@@ -16,14 +16,19 @@ test-makeopts_jobs() {
tend 1 "Mismatch between MAKEOPTS/cli: '${indirect}' != 
'${direct}'"
else
[[ ${direct} == "${exp}" ]]
-   tend $? "Got back: ${act}"
+   tend $? "Got back: ${direct}"
fi
 }
 
+# override to avoid relying on a specific value
+get_nproc() {
+   echo 41
+}
+
 tests=(
-   999 "-j"
-   999 "--jobs"
-   999 "-j -l9"
+   42 "-j"
+   42 "--jobs"
+   42 "-j -l9"
1 ""
1 "-l9 -w"
1 "-l9 -w-j4"
@@ -37,7 +42,7 @@ tests=(
7 "-l3 --jobs 7 -w"
4 "-j1 -j 2 --jobs 3 --jobs=4"
8 " -j  8 "
-   999 "-kj"
+   42 "-kj"
4 "-kj4"
5 "-kj 5"
 )



[gentoo-commits] repo/gentoo:master commit in: eclass/tests/, eclass/

2022-02-09 Thread Michał Górny
commit: beda1fe93abc87691239919653283ab0c299e00b
Author: Michał Górny  gentoo  org>
AuthorDate: Fri Feb  4 18:47:20 2022 +
Commit: Michał Górny  gentoo  org>
CommitDate: Wed Feb  9 08:43:51 2022 +
URL:https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=beda1fe9

python-utils-r1.eclass: Remove python_is_python3

Signed-off-by: Michał Górny  gentoo.org>

 eclass/distutils-r1.eclass  |  8 +++-
 eclass/python-utils-r1.eclass   | 17 -
 eclass/tests/python-utils-r1.sh |  5 -
 3 files changed, 3 insertions(+), 27 deletions(-)

diff --git a/eclass/distutils-r1.eclass b/eclass/distutils-r1.eclass
index 0507551897b9..b4bbb7d67e04 100644
--- a/eclass/distutils-r1.eclass
+++ b/eclass/distutils-r1.eclass
@@ -333,11 +333,9 @@ unset -f _distutils_set_globals
 # (allowing any implementation). If multiple values are specified,
 # implementations matching any of the patterns will be accepted.
 #
-# The patterns can be either fnmatch-style patterns (matched via bash
-# == operator against PYTHON_COMPAT values) or '-2' / '-3' to indicate
-# appropriately all enabled Python 2/3 implementations (alike
-# python_is_python3). Remember to escape or quote the fnmatch patterns
-# to prevent accidental shell filename expansion.
+# The patterns are fnmatch-style patterns (matched via bash == operator
+# against PYTHON_COMPAT values). Remember to escape or quote the fnmatch
+# patterns to prevent accidental shell filename expansion.
 #
 # If the restriction needs to apply conditionally to a USE flag,
 # the variable should be set conditionally as well (e.g. in an early

diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass
index 395e3e6420f4..29ff04d2892c 100644
--- a/eclass/python-utils-r1.eclass
+++ b/eclass/python-utils-r1.eclass
@@ -945,23 +945,6 @@ _python_wrapper_setup() {
export PATH PKG_CONFIG_PATH
 }
 
-# @FUNCTION: python_is_python3
-# @USAGE: []
-# @DESCRIPTION:
-# Check whether  (or ${EPYTHON}) is a Python3k variant
-# (i.e. uses syntax and stdlib of Python 3.*).
-#
-# Returns 0 (true) if it is, 1 (false) otherwise.
-python_is_python3() {
-   eqawarn "${FUNCNAME} is deprecated, as Python 2 is not supported 
anymore"
-   [[ ${EAPI} == [67] ]] || die "${FUNCNAME} banned in EAPI ${EAPI}"
-
-   local impl=${1:-${EPYTHON}}
-   [[ ${impl} ]] || die "python_is_python3: no impl nor EPYTHON"
-
-   [[ ${impl} == python3* || ${impl} == pypy3 ]]
-}
-
 # @FUNCTION: python_fix_shebang
 # @USAGE: [-f|--force] [-q|--quiet] ...
 # @DESCRIPTION:

diff --git a/eclass/tests/python-utils-r1.sh b/eclass/tests/python-utils-r1.sh
index 7ba4a864ff10..0244ce26ad0f 100755
--- a/eclass/tests/python-utils-r1.sh
+++ b/eclass/tests/python-utils-r1.sh
@@ -156,11 +156,6 @@ fi
 test_var PYTHON_PKG_DEP pypy3 '*dev-python/pypy3*:0='
 test_var PYTHON_SCRIPTDIR pypy3 /usr/lib/python-exec/pypy3
 
-test_is "python_is_python3 python2.7" 1
-test_is "python_is_python3 python3.2" 0
-test_is "python_is_python3 pypy" 1
-test_is "python_is_python3 pypy3" 0
-
 # generic shebangs
 test_fix_shebang '#!/usr/bin/python' python3.6 '#!/usr/bin/python3.6'
 test_fix_shebang '#!/usr/bin/python' pypy3 '#!/usr/bin/pypy3'



[gentoo-commits] repo/gentoo:master commit in: eclass/tests/, eclass/

2022-01-09 Thread Michał Górny
commit: 61d3e4f58783d613521c9cd9d2877c932212e460
Author: Michał Górny  gentoo  org>
AuthorDate: Fri Dec 31 08:59:17 2021 +
Commit: Michał Górny  gentoo  org>
CommitDate: Sun Jan  9 08:09:06 2022 +
URL:https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=61d3e4f5

python-utils-r1.eclass: Bump minimal Python versions

Bump minimal Python package versions to ensure that the python-exec deps
are inside.

Signed-off-by: Michał Górny  gentoo.org>

 eclass/python-utils-r1.eclass   | 10 --
 eclass/tests/distutils-r1.sh|  2 +-
 eclass/tests/distutils-r1_single.sh |  2 +-
 3 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass
index 22e00c56815d..ff5b350cd469 100644
--- a/eclass/python-utils-r1.eclass
+++ b/eclass/python-utils-r1.eclass
@@ -1,4 +1,4 @@
-# Copyright 1999-2021 Gentoo Authors
+# Copyright 1999-2022 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 # @ECLASS: python-utils-r1.eclass
@@ -416,12 +416,18 @@ _python_export() {
case ${impl} in
python2.7)

PYTHON_PKG_DEP='>=dev-lang/python-2.7.5-r2:2.7';;
+   python3.8)
+   
PYTHON_PKG_DEP=">=dev-lang/python-3.8.12_p1-r1:3.8";;
+   python3.9)
+   
PYTHON_PKG_DEP=">=dev-lang/python-3.9.9-r1:3.9";;
+   python3.10)
+   
PYTHON_PKG_DEP=">=dev-lang/python-3.10.0_p1-r1:3.10";;
python*)

PYTHON_PKG_DEP="dev-lang/python:${impl#python}";;
pypy)

PYTHON_PKG_DEP='>=dev-python/pypy-7.3.0:0=';;
pypy3)
-   
PYTHON_PKG_DEP='>=dev-python/pypy3-7.3.7:0=';;
+   
PYTHON_PKG_DEP='>=dev-python/pypy3-7.3.7-r1:0=';;
*)
die "Invalid implementation: 
${impl}"
esac

diff --git a/eclass/tests/distutils-r1.sh b/eclass/tests/distutils-r1.sh
index 1ccb1dfbc523..a582bd9bbee7 100755
--- a/eclass/tests/distutils-r1.sh
+++ b/eclass/tests/distutils-r1.sh
@@ -97,7 +97,7 @@ tend
 einfo distutils_enable_tests
 eindent
 BASE_IUSE="python_targets_python3_8"
-BASE_DEPS="python_targets_python3_8? ( dev-lang/python:3.8 ) 
>=dev-lang/python-exec-2:=[python_targets_python3_8(-)?]"
+BASE_DEPS="python_targets_python3_8? ( >=dev-lang/python-3.8.12_p1-r1:3.8 ) 
>=dev-lang/python-exec-2:=[python_targets_python3_8(-)?]"
 TEST_RESTRICT="!test? ( test )"
 
 einfo "empty RDEPEND"

diff --git a/eclass/tests/distutils-r1_single.sh 
b/eclass/tests/distutils-r1_single.sh
index 56b62ca0e90f..8d07eebb133f 100755
--- a/eclass/tests/distutils-r1_single.sh
+++ b/eclass/tests/distutils-r1_single.sh
@@ -77,7 +77,7 @@ inherit distutils-r1
 einfo distutils_enable_tests
 eindent
 BASE_IUSE="+python_single_target_python3_8"
-BASE_DEPS="python_single_target_python3_8? ( dev-lang/python:3.8 
>=dev-lang/python-exec-2:=[python_targets_python3_8] )"
+BASE_DEPS="python_single_target_python3_8? ( 
>=dev-lang/python-3.8.12_p1-r1:3.8 
>=dev-lang/python-exec-2:=[python_targets_python3_8] )"
 TEST_RESTRICT="!test? ( test )"
 
 einfo "empty RDEPEND"



[gentoo-commits] repo/gentoo:master commit in: eclass/tests/, eclass/

2021-06-23 Thread Michał Górny
commit: a0eb5847674c9d295fbc80e2b7c53855cfca5a66
Author: Michał Górny  gentoo  org>
AuthorDate: Sun Jun 20 07:14:32 2021 +
Commit: Michał Górny  gentoo  org>
CommitDate: Wed Jun 23 21:44:08 2021 +
URL:https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=a0eb5847

python-utils-r1.eclass: Deprecated and EAPI8-ban python_is_python3

There is no use for python_is_python3 anymore, as Python 2 is no longer
supported at runtime and the remaining any-r1 uses are pure-2.

Signed-off-by: Michał Górny  gentoo.org>

 eclass/python-utils-r1.eclass   | 3 +++
 eclass/tests/python-utils-r1.sh | 4 
 2 files changed, 7 insertions(+)

diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass
index 1a20a3cae99..b435ebaa7ad 100644
--- a/eclass/python-utils-r1.eclass
+++ b/eclass/python-utils-r1.eclass
@@ -1010,6 +1010,9 @@ _python_wrapper_setup() {
 #
 # Returns 0 (true) if it is, 1 (false) otherwise.
 python_is_python3() {
+   eqawarn "${FUNCNAME} is deprecated, as Python 2 is not supported 
anymore"
+   [[ ${EAPI} == [67] ]] || die "${FUNCNAME} banned in EAPI ${EAPI}"
+
local impl=${1:-${EPYTHON}}
[[ ${impl} ]] || die "python_is_python3: no impl nor EPYTHON"
 

diff --git a/eclass/tests/python-utils-r1.sh b/eclass/tests/python-utils-r1.sh
index 85a6a53654d..63a94c90b71 100755
--- a/eclass/tests/python-utils-r1.sh
+++ b/eclass/tests/python-utils-r1.sh
@@ -5,6 +5,10 @@
 EAPI=7
 source tests-common.sh
 
+eqawarn() {
+   : # stub
+}
+
 test_var() {
local var=${1}
local impl=${2}



[gentoo-commits] repo/gentoo:master commit in: eclass/tests/, eclass/

2021-01-15 Thread Michał Górny
commit: 10da6fd3ccd3ba547cb855371b670db909cb165c
Author: Michał Górny  gentoo  org>
AuthorDate: Thu Dec 31 11:18:04 2020 +
Commit: Michał Górny  gentoo  org>
CommitDate: Fri Jan 15 17:05:53 2021 +
URL:https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=10da6fd3

python-utils-r1.eclass: Inline _python_impl_supported()

The _python_impl_supported() function is not used anymore in its
original function.  It is called only once, in order to die on incorrect
targets in PYTHON_COMPAT.  Let's inline the corresponding logic
in _python_set_impls() and remove the function.

While at it, add an extra check for outdated patterns.  This also
renders the relevant tests obsolete.

Signed-off-by: Michał Górny  gentoo.org>

 eclass/python-utils-r1.eclass   | 56 +++--
 eclass/tests/python-utils-r1.sh | 18 -
 2 files changed, 20 insertions(+), 54 deletions(-)

diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass
index 9c8b6a14d2a..2aa953213b6 100644
--- a/eclass/python-utils-r1.eclass
+++ b/eclass/python-utils-r1.eclass
@@ -69,38 +69,6 @@ readonly _PYTHON_HISTORICAL_IMPLS
 # which can involve revisions of this eclass that support a different
 # set of Python implementations.
 
-# @FUNCTION: _python_impl_supported
-# @USAGE: 
-# @INTERNAL
-# @DESCRIPTION:
-# Check whether the implementation  (PYTHON_COMPAT-form)
-# is still supported.
-#
-# Returns 0 if the implementation is valid and supported. If it is
-# unsupported, returns 1 -- and the caller should ignore the entry.
-# If it is invalid, dies with an appopriate error messages.
-_python_impl_supported() {
-   debug-print-function ${FUNCNAME} "${@}"
-
-   [[ ${#} -eq 1 ]] || die "${FUNCNAME}: takes exactly 1 argument (impl)."
-
-   local impl=${1}
-
-   # keep in sync with _PYTHON_ALL_IMPLS!
-   # (not using that list because inline patterns shall be faster)
-   case "${impl}" in
-   python2_7|python3_[6789]|pypy3)
-   return 0
-   ;;
-   jython2_7|pypy|pypy1_[89]|pypy2_0|python2_[56]|python3_[12345])
-   return 1
-   ;;
-   *)
-   [[ ${PYTHON_COMPAT_NO_STRICT} ]] && return 1
-   die "Invalid implementation in PYTHON_COMPAT: ${impl}"
-   esac
-}
-
 # @FUNCTION: _python_verify_patterns
 # @USAGE: ...
 # @INTERNAL
@@ -149,10 +117,26 @@ _python_set_impls() {
if [[ $(declare -p PYTHON_COMPAT) != "declare -a"* ]]; then
die 'PYTHON_COMPAT must be an array.'
fi
-   for i in "${PYTHON_COMPAT[@]}"; do
-   # trigger validity checks
-   _python_impl_supported "${i}"
-   done
+   if [[ ! ${PYTHON_COMPAT_NO_STRICT} ]]; then
+   for i in "${PYTHON_COMPAT[@]}"; do
+   # check for incorrect implementations
+   # we're using pattern matching as an optimization
+   # please keep them in sync with _PYTHON_ALL_IMPLS
+   # and _PYTHON_HISTORICAL_IMPLS
+   case ${i} in
+   
jython2_7|pypy|pypy1_[89]|pypy2_0|pypy3|python2_[5-7]|python3_[1-9])
+   ;;
+   *)
+   if has "${i}" "${_PYTHON_ALL_IMPLS[@]}" 
\
+   "${_PYTHON_HISTORICAL_IMPLS[@]}"
+   then
+   die "Mis-synced patterns in 
_python_set_impls: missing ${i}"
+   else
+   die "Invalid implementation in 
PYTHON_COMPAT: ${i}"
+   fi
+   esac
+   done
+   fi
 
local supp=() unsupp=()
 

diff --git a/eclass/tests/python-utils-r1.sh b/eclass/tests/python-utils-r1.sh
index 86b87ec173d..eb8223ec6ac 100755
--- a/eclass/tests/python-utils-r1.sh
+++ b/eclass/tests/python-utils-r1.sh
@@ -183,24 +183,6 @@ test_fix_shebang '#!/usr/bin/foo' python2.7 FAIL
 # regression test for bug #522080
 test_fix_shebang '#!/usr/bin/python ' python2.7 '#!/usr/bin/python2.7 '
 
-# make sure we don't break pattern matching
-test_is "_python_impl_supported python2_5" 1
-test_is "_python_impl_supported python2_6" 1
-test_is "_python_impl_supported python2_7" 0
-test_is "_python_impl_supported python3_1" 1
-test_is "_python_impl_supported python3_2" 1
-test_is "_python_impl_supported python3_3" 1
-test_is "_python_impl_supported python3_4" 1
-test_is "_python_impl_supported python3_5" 1
-test_is "_python_impl_supported python3_6" 0
-test_is "_python_impl_supported python3_7" 0
-test_is "_python_impl_supported python3_8" 0
-test_is "_python_impl_supported pypy1_8" 1
-test_is "_python_impl_supported pypy1_9" 1
-test_is

[gentoo-commits] repo/gentoo:master commit in: eclass/tests/, eclass/

2021-01-05 Thread Sergei Trofimovich
commit: f8ed334c4a1f2a9802f898663b3facac5ec15e01
Author: Sergei Trofimovich  gentoo  org>
AuthorDate: Tue Jan  5 22:40:59 2021 +
Commit: Sergei Trofimovich  gentoo  org>
CommitDate: Tue Jan  5 23:01:37 2021 +
URL:https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=f8ed334c

toolchain-funcs.eclass: fix or1k* tuple detection

Before the change the only recognised CHOST was 'or1k'.
After the change CHOSTs like 'or1k-linux-musl' are
also recognised as 'openrisc'.

Reported-by: adam  pimentel.space
Bug: https://bugs.gentoo.org/763606
Signed-off-by: Sergei Trofimovich  gentoo.org>

 eclass/tests/toolchain-funcs.sh | 3 ++-
 eclass/toolchain-funcs.eclass   | 2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/eclass/tests/toolchain-funcs.sh b/eclass/tests/toolchain-funcs.sh
index a0a56fd9e5d..23ac568c4a5 100755
--- a/eclass/tests/toolchain-funcs.sh
+++ b/eclass/tests/toolchain-funcs.sh
@@ -27,7 +27,8 @@ test-tc-arch-kernel() {
 tbegin "tc-arch-kernel() (KV=2.6.30)"
 test-tc-arch-kernel 2.6.30 \
i{3..6}86:x86 x86_64:x86 \
-   powerpc{,64}:powerpc i{3..6}86-gentoo-freebsd:i386
+   powerpc{,64}:powerpc i{3..6}86-gentoo-freebsd:i386 \
+   or1k:openrisc or1k-linux-musl:openrisc
 tend $?
 
 #

diff --git a/eclass/toolchain-funcs.eclass b/eclass/toolchain-funcs.eclass
index ec7b920bcfa..4a4bb27fc08 100644
--- a/eclass/toolchain-funcs.eclass
+++ b/eclass/toolchain-funcs.eclass
@@ -665,7 +665,7 @@ ninj() { [[ ${type} == "kern" ]] && echo $1 || echo $2 ; }
mips*)  echo mips;;
nios2*) echo nios2;;
nios*)  echo nios;;
-   or1k|or32*) echo openrisc;;
+   or1k*|or32*)echo openrisc;;
powerpc*)
# Starting with linux-2.6.15, the 'ppc' and 'ppc64' 
trees
# have been unified into simply 'powerpc', but until 
2.6.16,



[gentoo-commits] repo/gentoo:master commit in: eclass/tests/, eclass/

2020-05-24 Thread Michał Górny
commit: e563ed3af0dad1d3eaa165f5eb89b6f7ed0a1c9c
Author: Michał Górny  gentoo  org>
AuthorDate: Mon May 25 06:04:34 2020 +
Commit: Michał Górny  gentoo  org>
CommitDate: Mon May 25 06:07:18 2020 +
URL:https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=e563ed3a

python-utils-r1.eclass: Enable python3_9

Signed-off-by: Michał Górny  gentoo.org>

 eclass/python-utils-r1.eclass   |  4 ++--
 eclass/tests/python-utils-r1.sh | 16 +++-
 2 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass
index 4af710da363..1067d2367ab 100644
--- a/eclass/python-utils-r1.eclass
+++ b/eclass/python-utils-r1.eclass
@@ -41,7 +41,7 @@ inherit toolchain-funcs
 _PYTHON_ALL_IMPLS=(
pypy3
python2_7
-   python3_6 python3_7 python3_8
+   python3_6 python3_7 python3_8 python3_9
 )
 readonly _PYTHON_ALL_IMPLS
 
@@ -77,7 +77,7 @@ _python_impl_supported() {
# keep in sync with _PYTHON_ALL_IMPLS!
# (not using that list because inline patterns shall be faster)
case "${impl}" in
-   python2_7|python3_[678]|pypy3)
+   python2_7|python3_[6789]|pypy3)
return 0
;;
jython2_7|pypy|pypy1_[89]|pypy2_0|python2_[56]|python3_[12345])

diff --git a/eclass/tests/python-utils-r1.sh b/eclass/tests/python-utils-r1.sh
index 192c1183e80..86b87ec173d 100755
--- a/eclass/tests/python-utils-r1.sh
+++ b/eclass/tests/python-utils-r1.sh
@@ -1,5 +1,5 @@
 #!/bin/bash
-# Copyright 1999-2019 Gentoo Authors
+# Copyright 1999-2020 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 EAPI=7
@@ -115,6 +115,20 @@ fi
 test_var PYTHON_PKG_DEP python3_8 '*dev-lang/python*:3.8'
 test_var PYTHON_SCRIPTDIR python3_8 /usr/lib/python-exec/python3.8
 
+test_var EPYTHON python3_9 python3.9
+test_var PYTHON python3_9 /usr/bin/python3.9
+if [[ -x /usr/bin/python3.9 ]]; then
+   abiflags=$(/usr/bin/python3.9 -c 'import sysconfig; 
print(sysconfig.get_config_var("ABIFLAGS"))')
+   test_var PYTHON_SITEDIR python3_9 "/usr/lib/python3.9/site-packages"
+   test_var PYTHON_INCLUDEDIR python3_9 "/usr/include/python3.9${abiflags}"
+   test_var PYTHON_LIBPATH python3_9 
"/usr/lib*/libpython3.9${abiflags}$(get_libname)"
+   test_var PYTHON_CONFIG python3_9 "/usr/bin/python3.9${abiflags}-config"
+   test_var PYTHON_CFLAGS python3_9 "*-I/usr/include/python3.9*"
+   test_var PYTHON_LIBS python3_9 "*-lpython3.9*"
+fi
+test_var PYTHON_PKG_DEP python3_9 '*dev-lang/python*:3.9'
+test_var PYTHON_SCRIPTDIR python3_9 /usr/lib/python-exec/python3.9
+
 test_var EPYTHON pypy3 pypy3
 test_var PYTHON pypy3 /usr/bin/pypy3
 if [[ -x /usr/bin/pypy3 ]]; then



[gentoo-commits] repo/gentoo:master commit in: eclass/tests/, eclass/

2020-03-28 Thread Sergei Trofimovich
commit: 1a687fd280c3d33cbf7ef99cd6f96fda95039c75
Author: Sergei Trofimovich  gentoo  org>
AuthorDate: Sat Mar 28 19:53:49 2020 +
Commit: Sergei Trofimovich  gentoo  org>
CommitDate: Sat Mar 28 19:54:47 2020 +
URL:https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=1a687fd2

eclass/multilib.eclass: update copyright and fix typos

Reported-by: Mike Gilbert
Signed-off-by: Sergei Trofimovich  gentoo.org>

 eclass/multilib.eclass   | 2 +-
 eclass/tests/multilib.sh | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/eclass/multilib.eclass b/eclass/multilib.eclass
index 8b4a7dacaa3..bbaab709b4f 100644
--- a/eclass/multilib.eclass
+++ b/eclass/multilib.eclass
@@ -1,4 +1,4 @@
-# Copyright 1999-2015 Gentoo Foundation
+# Copyright 1999-2020 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 # @ECLASS: multilib.eclass

diff --git a/eclass/tests/multilib.sh b/eclass/tests/multilib.sh
index 68c0dd6e142..a483d4bef36 100755
--- a/eclass/tests/multilib.sh
+++ b/eclass/tests/multilib.sh
@@ -1,5 +1,5 @@
 #!/bin/bash
-# Copyright 1999-2020 Gentoo Foundation
+# Copyright 2020 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 source tests-common.sh
@@ -46,7 +46,7 @@ test-multilib_env() {
fi
 }
 
-# Pick a few interesting gargets from:
+# Pick a few interesting targets from:
 # $ grep -h -o -R 'CHOST=.*' ../../profiles/ | sort -u
 
 test-multilib_env \



[gentoo-commits] repo/gentoo:master commit in: eclass/tests/, eclass/

2020-03-26 Thread Sergei Trofimovich
commit: a5003d48705fa9b501022d4e6326c8f516a2eec0
Author: Sergei Trofimovich  gentoo  org>
AuthorDate: Thu Mar 26 07:49:07 2020 +
Commit: Sergei Trofimovich  gentoo  org>
CommitDate: Thu Mar 26 07:50:41 2020 +
URL:https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=a5003d48

flag-o-matic.eclass: revert "don't use -Werror in test-flag-PROG(), bug #712488"

This reverts commit ab8fe14ae2e9110faa85ca1c4528b470c0be1535.
Triggers build failures on sys-libs/compiler-rt-sanitizers.

Reported-by: Craig Andrews
Bug: https://bugs.gentoo.org/714742
Bug: https://bugs.gentoo.org/712488
Signed-off-by: Sergei Trofimovich  gentoo.org>

 eclass/flag-o-matic.eclass   | 19 +++
 eclass/tests/flag-o-matic.sh | 10 --
 2 files changed, 15 insertions(+), 14 deletions(-)

diff --git a/eclass/flag-o-matic.eclass b/eclass/flag-o-matic.eclass
index d8111fb9e38..9ef9ac3685e 100644
--- a/eclass/flag-o-matic.eclass
+++ b/eclass/flag-o-matic.eclass
@@ -487,15 +487,11 @@ test-flag-PROG() {
 
printf "%s\n" "${in_src}" > "${test_in}" || die "Failed to create 
'${test_in}'"
 
-   # Don't set -Werror as there are cases when benign
-   # always-on warnings filter out all flags like bug #712488.
-   # We'll have to live with potential '-Wunused-command-line-argument'.
-   # flags.
-   #
-   # We can add more selective detection of no-op flags via
-   # '-Werror=ignored-optimization-argument' and similar error options.
local cmdline=(
"${comp[@]}"
+   # Clang will warn about unknown gcc flags but exit 0.
+   # Need -Werror to force it to exit non-zero.
+   -Werror
"$@"
# -x options need to go before first source file
"${cmdline_extra[@]}"
@@ -503,7 +499,14 @@ test-flag-PROG() {
"${test_in}" -o "${test_out}"
)
 
-   "${cmdline[@]}" &>/dev/null
+   if ! "${cmdline[@]}" &>/dev/null; then
+   # -Werror makes clang bail out on unused arguments as well;
+   # try to add -Qunused-arguments to work-around that
+   # other compilers don't support it but then, it's failure like
+   # any other
+   cmdline+=( -Qunused-arguments )
+   "${cmdline[@]}" &>/dev/null
+   fi
 }
 
 # @FUNCTION: test-flag-CC

diff --git a/eclass/tests/flag-o-matic.sh b/eclass/tests/flag-o-matic.sh
index 6dfacb04c07..229dff52af9 100755
--- a/eclass/tests/flag-o-matic.sh
+++ b/eclass/tests/flag-o-matic.sh
@@ -161,12 +161,10 @@ out=$(CC=clang test-flags-CC -finvalid-flag)
 [[ $? -ne 0 && -z ${out} ]]
 ftend
 
-### '-finline-limit=1200' is 'ignored' flag, not invalid.
-### We don't filter out ignored flags currently, bug #712488
-#tbegin "test-flags-CC (gcc-valid but clang-invalid flags)"
-#out=$(CC=clang test-flags-CC -finline-limit=1200)
-#[[ $? -ne 0 && -z ${out} ]]
-#ftend
+tbegin "test-flags-CC (gcc-valid but clang-invalid flags)"
+out=$(CC=clang test-flags-CC -finline-limit=1200)
+[[ $? -ne 0 && -z ${out} ]]
+ftend
 
 tbegin "test-flags-CC (unused flags w/clang)"
 out=$(CC=clang test-flags-CC -Wl,-O1)



[gentoo-commits] repo/gentoo:master commit in: eclass/tests/, eclass/

2020-01-11 Thread Sergei Trofimovich
commit: 12bfa1e4f9595dbbcbe0a442c6a63bc3ef890cc2
Author: Sergei Trofimovich  gentoo  org>
AuthorDate: Sat Jan 11 23:11:13 2020 +
Commit: Sergei Trofimovich  gentoo  org>
CommitDate: Sat Jan 11 23:53:08 2020 +
URL:https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=12bfa1e4

toolchain.eclass: fix arch downgrade for gcc-10

The bug is in lexical comparison instead of version compare.

Signed-off-by: Sergei Trofimovich  gentoo.org>

 eclass/tests/toolchain.sh | 12 +++-
 eclass/toolchain.eclass   | 17 +
 2 files changed, 20 insertions(+), 9 deletions(-)

diff --git a/eclass/tests/toolchain.sh b/eclass/tests/toolchain.sh
index 56609aa180e..1d05f6c126b 100755
--- a/eclass/tests/toolchain.sh
+++ b/eclass/tests/toolchain.sh
@@ -12,6 +12,12 @@ source tests-common.sh
 
 inherit toolchain
 
+# Ignore actually running version of gcc and fake new version
+# to force downgrade test on all conditions below.
+gcc-version() {
+   echo "99.99"
+}
+
 test_downgrade_arch_flags() {
local exp msg ret=0 ver
 
@@ -26,13 +32,14 @@ test_downgrade_arch_flags() {
downgrade_arch_flags ${ver}
 
if [[ ${CFLAGS} != ${exp} ]]; then
-   msg="Failure - Expected: \"${exp}\" Got: \"${CFLAGS}\""
+   msg="Failure - Expected: \"${exp}\" Got: \"${CFLAGS}\" Ver: 
${ver}"
ret=1
fi
tend ${ret} ${msg}
 }
 
 # ver  expectedgiven
+test_downgrade_arch_flags 10  "-march=haswell""-march=haswell"
 test_downgrade_arch_flags 4.9 "-march=haswell""-march=haswell"
 test_downgrade_arch_flags 4.8 "-march=core-avx2"  "-march=haswell"
 test_downgrade_arch_flags 4.7 "-march=core-avx2"  "-march=haswell"
@@ -64,6 +71,7 @@ test_downgrade_arch_flags 3.3 "-march=c3" 
"-march=c3-2"
 
 test_downgrade_arch_flags 4.5 "-march=garbage""-march=garbage"
 
+test_downgrade_arch_flags 10  "-mtune=intel"  "-mtune=intel"
 test_downgrade_arch_flags 4.9 "-mtune=intel"  "-mtune=intel"
 test_downgrade_arch_flags 4.8 "-mtune=generic""-mtune=intel"
 test_downgrade_arch_flags 3.4 ""  "-mtune=generic"
@@ -74,9 +82,11 @@ test_downgrade_arch_flags 4.5 "-march=amdfam10 
-mtune=generic" "-march=btver2 -m
 test_downgrade_arch_flags 3.3 "-march=k6-2"   "-march=geode 
-mtune=barcelona"
 test_downgrade_arch_flags 3.4 "-march=k8" "-march=btver2 
-mtune=generic"
 
+test_downgrade_arch_flags 10  "-march=native" "-march=native"
 test_downgrade_arch_flags 4.2 "-march=native" "-march=native"
 test_downgrade_arch_flags 4.1 "-march=nocona" "-march=native"
 
+test_downgrade_arch_flags 10  "-march=foo -mno-sha -mno-rtm -mno-avx2 -mno-avx 
-mno-sse4.1" "-march=foo -mno-sha -mno-rtm -mno-avx2 -mno-avx -mno-sse4.1"
 test_downgrade_arch_flags 4.9 "-march=foo -mno-sha -mno-rtm -mno-avx2 -mno-avx 
-mno-sse4.1" "-march=foo -mno-sha -mno-rtm -mno-avx2 -mno-avx -mno-sse4.1"
 test_downgrade_arch_flags 4.8 "-march=foo -mno-rtm -mno-avx2 -mno-avx 
-mno-sse4.1" "-march=foo -mno-sha -mno-rtm -mno-avx2 -mno-avx -mno-sse4.1"
 test_downgrade_arch_flags 4.7 "-march=foo -mno-avx2 -mno-avx -mno-sse4.1" 
"-march=foo -mno-sha -mno-rtm -mno-avx2 -mno-avx -mno-sse4.1"

diff --git a/eclass/toolchain.eclass b/eclass/toolchain.eclass
index 5f9bd7750dd..bd3d024f989 100644
--- a/eclass/toolchain.eclass
+++ b/eclass/toolchain.eclass
@@ -1406,7 +1406,8 @@ downgrade_arch_flags() {
local arch bver i isa myarch mytune rep ver
 
bver=${1:-${GCC_BRANCH_VER}}
-   [[ $(gcc-version) < ${bver} ]] && return 0
+   # Don't perform downgrade if running gcc is older than ebuild's.
+   tc_version_is_at_least ${bver} $(gcc-version) || return 0
[[ $(tc-arch) != amd64 && $(tc-arch) != x86 ]] && return 0
 
myarch=$(get-flag march)
@@ -1414,7 +1415,7 @@ downgrade_arch_flags() {
 
# If -march=native isn't supported we have to tease out the actual arch
if [[ ${myarch} == native || ${mytune} == native ]] ; then
-   if [[ ${bver} < 4.2 ]] ; then
+   if ! tc_version_is_at_least 4.2 ${bver}; then
arch=$($(tc-getCC) -march=native -v -E -P - &1 \
| sed -rn "/cc1.*-march/s:.*-march=([^ 
']*).*:\1:p")
replace-cpu-flags native ${arch}
@@ -1422,10 +1423,10 @@ downgrade_arch_flags() {
fi
 
# Handle special -mtune flags
-   [[ ${mytune} == intel && ${bver} < 4.9 ]] && replace-cpu-flags intel 
generic
-   [[ ${mytune} == generic && ${bver} < 4.2 ]] && filter-flags '-mtune=*'
+   [[ ${mytune} == intel ]] && ! tc_version_is_at_least 4.9 ${bver} && 
replace-cpu-flags intel generic
+   [[ ${mytune} == generic ]] && ! tc_version_is_at_least 4.2 ${bver} && 
filter-flags '-mtune=*'
[[ ${mytune} == x86-64 ]] && filter-flags '-mtune=*'
-   [[ ${bver} < 3.4 ]] && filter-flags '-mtune=*'
+   tc_version_is_at_least 3.4 ${bver} || filter-

[gentoo-commits] repo/gentoo:master commit in: eclass/tests/, eclass/

2019-12-30 Thread Michał Górny
commit: 8844b4c200dc82d7d09547b3d913f011f05cf592
Author: David Seifert  gentoo  org>
AuthorDate: Mon Dec 30 00:48:32 2019 +
Commit: Michał Górny  gentoo  org>
CommitDate: Mon Dec 30 12:58:51 2019 +
URL:https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=8844b4c2

python-utils-r1.eclass: Remove PYTHON_TARGETS="pypy"

* With the EOL of CPython 2, we also want to
  remove support for PyPy (i.e. PyPy for Python 2).
  This change does not affect PyPy3, i.e. Pypy for
  Python 3.

Signed-off-by: David Seifert  gentoo.org>
Signed-off-by: Michał Górny  gentoo.org>

 eclass/python-utils-r1.eclass   | 6 +++---
 eclass/tests/python-utils-r1.sh | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass
index 370898bcea0..09b501a4ad2 100644
--- a/eclass/python-utils-r1.eclass
+++ b/eclass/python-utils-r1.eclass
@@ -40,7 +40,7 @@ inherit toolchain-funcs
 # All supported Python implementations, most preferred last.
 _PYTHON_ALL_IMPLS=(
jython2_7
-   pypy pypy3
+   pypy3
python2_7
python3_6 python3_7 python3_8
 )
@@ -78,10 +78,10 @@ _python_impl_supported() {
# keep in sync with _PYTHON_ALL_IMPLS!
# (not using that list because inline patterns shall be faster)
case "${impl}" in
-   python2_7|python3_[678]|jython2_7|pypy|pypy3)
+   python2_7|python3_[678]|jython2_7|pypy3)
return 0
;;
-   pypy1_[89]|pypy2_0|python2_[56]|python3_[12345])
+   pypy|pypy1_[89]|pypy2_0|python2_[56]|python3_[12345])
return 1
;;
*)

diff --git a/eclass/tests/python-utils-r1.sh b/eclass/tests/python-utils-r1.sh
index df77a3fcf6e..f8d4858da7c 100755
--- a/eclass/tests/python-utils-r1.sh
+++ b/eclass/tests/python-utils-r1.sh
@@ -188,7 +188,7 @@ test_is "_python_impl_supported python3_8" 0
 test_is "_python_impl_supported pypy1_8" 1
 test_is "_python_impl_supported pypy1_9" 1
 test_is "_python_impl_supported pypy2_0" 1
-test_is "_python_impl_supported pypy" 0
+test_is "_python_impl_supported pypy" 1
 test_is "_python_impl_supported pypy3" 0
 test_is "_python_impl_supported jython2_7" 0
 



[gentoo-commits] repo/gentoo:master commit in: eclass/tests/, eclass/

2019-12-30 Thread Michał Górny
commit: f0f388d6e7b7990006384bd024ec5bf2d7f66737
Author: David Seifert  gentoo  org>
AuthorDate: Mon Dec 30 00:48:32 2019 +
Commit: Michał Górny  gentoo  org>
CommitDate: Mon Dec 30 12:58:50 2019 +
URL:https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=f0f388d6

python-utils-r1.eclass: Remove PYTHON_TARGETS="python3_5"

* Python 3.5 will go EOL on 2020-09-13 and in order to reduce testing
  and maintenance burden, we want to keep the number of active Py3
  impls below four.

  https://devguide.python.org/#status-of-python-branches

Signed-off-by: David Seifert  gentoo.org>
Signed-off-by: Michał Górny  gentoo.org>

 eclass/python-utils-r1.eclass   | 6 +++---
 eclass/tests/python-utils-r1.sh | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass
index e0711a35e3a..370898bcea0 100644
--- a/eclass/python-utils-r1.eclass
+++ b/eclass/python-utils-r1.eclass
@@ -42,7 +42,7 @@ _PYTHON_ALL_IMPLS=(
jython2_7
pypy pypy3
python2_7
-   python3_5 python3_6 python3_7 python3_8
+   python3_6 python3_7 python3_8
 )
 readonly _PYTHON_ALL_IMPLS
 
@@ -78,10 +78,10 @@ _python_impl_supported() {
# keep in sync with _PYTHON_ALL_IMPLS!
# (not using that list because inline patterns shall be faster)
case "${impl}" in
-   python2_7|python3_[5678]|jython2_7|pypy|pypy3)
+   python2_7|python3_[678]|jython2_7|pypy|pypy3)
return 0
;;
-   pypy1_[89]|pypy2_0|python2_[56]|python3_[1234])
+   pypy1_[89]|pypy2_0|python2_[56]|python3_[12345])
return 1
;;
*)

diff --git a/eclass/tests/python-utils-r1.sh b/eclass/tests/python-utils-r1.sh
index e883da38cea..df77a3fcf6e 100755
--- a/eclass/tests/python-utils-r1.sh
+++ b/eclass/tests/python-utils-r1.sh
@@ -181,7 +181,7 @@ test_is "_python_impl_supported python3_1" 1
 test_is "_python_impl_supported python3_2" 1
 test_is "_python_impl_supported python3_3" 1
 test_is "_python_impl_supported python3_4" 1
-test_is "_python_impl_supported python3_5" 0
+test_is "_python_impl_supported python3_5" 1
 test_is "_python_impl_supported python3_6" 0
 test_is "_python_impl_supported python3_7" 0
 test_is "_python_impl_supported python3_8" 0



[gentoo-commits] repo/gentoo:master commit in: eclass/tests/, eclass/

2019-12-24 Thread Sergei Trofimovich
commit: 28d6437fc7009002f98f28e8900e994109927726
Author: Sergei Trofimovich  gentoo  org>
AuthorDate: Mon Dec 23 11:41:20 2019 +
Commit: Sergei Trofimovich  gentoo  org>
CommitDate: Tue Dec 24 11:01:01 2019 +
URL:https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=28d6437f

flag-o-matic.eclass: add LDFLAGS testing against linker

Before the change we tested only compiler driver (gcc flag parser)
for LDFLAGS.

This does not cover cases when we would really like to filter out
unsupported linker flags like -Wl,--hash-style=gnu passed to non-ELF
targets.

The change adds test-flag-CCLD() helper to perform all of assembly,
compilation and linking steps. Helper is used to filter LDFLAGS variable
in strip-unsupported-flags().

Closes: https://bugs.gentoo.org/333763
Signed-off-by: Sergei Trofimovich  gentoo.org>

 eclass/flag-o-matic.eclass   | 72 +++-
 eclass/tests/flag-o-matic.sh |  2 +-
 2 files changed, 59 insertions(+), 15 deletions(-)

diff --git a/eclass/flag-o-matic.eclass b/eclass/flag-o-matic.eclass
index f882b09d621..0aec22c83f2 100644
--- a/eclass/flag-o-matic.eclass
+++ b/eclass/flag-o-matic.eclass
@@ -441,29 +441,63 @@ test-flag-PROG() {
# 'type' needs a binary name
type -p ${comp[0]} >/dev/null || return 1
 
+   # Set up test file.
+   local in_src in_ext cmdline_extra=()
+   case "${lang}" in
+   # compiler/assembler only
+   c)
+   in_ext='.c'
+   in_src='int main(void) { return 0; }'
+   cmdline_extra+=(-xc -c)
+   ;;
+   c++)
+   in_ext='.cc'
+   in_src='int main(void) { return 0; }'
+   cmdline_extra+=(-xc++ -c)
+   ;;
+   f77)
+   in_ext='.f'
+   # fixed source form
+   in_src='  end'
+   cmdline_extra+=(-xf77 -c)
+   ;;
+   f95)
+   in_ext='.f90'
+   in_src='end'
+   cmdline_extra+=(-xf95 -c)
+   ;;
+
+   # C compiler/assembler/linker
+   c+ld)
+   in_ext='.c'
+   in_src='int main(void) { return 0; }'
+   cmdline_extra+=(-xc)
+   ;;
+   esac
+   local test_in=${T}/test-flag-${comp}.${lang}
+   local test_out=${T}/test-flag-${comp}.exe
+
+   printf "%s\n" "${in_src}" > "${test_in}" || return 1
+
local cmdline=(
"${comp[@]}"
# Clang will warn about unknown gcc flags but exit 0.
# Need -Werror to force it to exit non-zero.
-Werror
-   # Use -c so we can test the assembler as well.
-   -c -o /dev/null
+   "$@"
+   # -x options need to go before first source file
+   "${cmdline_extra[@]}"
+
+   "${test_in}" -o "${test_out}"
)
-   if "${cmdline[@]}" -x${lang} - /dev/null ; then
-   cmdline+=( "$@" -x${lang} - )
-   else
-   # XXX: what's the purpose of this? does it even work with
-   # any compiler?
-   cmdline+=( "$@" -c -o /dev/null /dev/null )
-   fi
 
-   if ! "${cmdline[@]}" /dev/null; then
+   if ! "${cmdline[@]}" &>/dev/null; then
# -Werror makes clang bail out on unused arguments as well;
# try to add -Qunused-arguments to work-around that
# other compilers don't support it but then, it's failure like
# any other
cmdline+=( -Qunused-arguments )
-   "${cmdline[@]}" /dev/null
+   "${cmdline[@]}" &>/dev/null
fi
 }
 
@@ -491,6 +525,12 @@ test-flag-F77() { test-flag-PROG "F77" f77 "$@"; }
 # Returns shell true if  is supported by the Fortran 90 compiler, else 
returns shell false.
 test-flag-FC() { test-flag-PROG "FC" f95 "$@"; }
 
+# @FUNCTION: test-flag-CCLD
+# @USAGE: 
+# @DESCRIPTION:
+# Returns shell true if  is supported by the C compiler and linker, else 
returns shell false.
+test-flag-CCLD() { test-flag-PROG "CC" c+ld "$@"; }
+
 test-flags-PROG() {
local comp=$1
local flags=()
@@ -548,6 +588,12 @@ test-flags-F77() { test-flags-PROG "F77" "$@"; }
 # Returns shell true if  are supported by the Fortran 90 compiler, else 
returns shell false.
 test-flags-FC() { test-flags-PROG "FC" "$@"; }
 
+# @FUNCTION: test-flags-CCLD
+# @USAGE: 
+# @DESCRIPTION:
+# Returns shell true if  are supported by the C compiler and default 
linker, else returns shell false.
+test-flags-CCLD() { test-flags-PROG "CCLD" "$@"; }
+
 # @FUNCTION: test-flags
 # @USAGE: 
 # @DESCRIPTION:
@@ -576,9 +622,7 @@ strip-unsupported-flags() {
export CXXFLAGS=$(test-fla

[gentoo-commits] repo/gentoo:master commit in: eclass/tests/, eclass/

2018-04-18 Thread Mike Gilbert
commit: 1e64d3ebf9edf0f02cc271faa9c3eaedeb6d280d
Author: Mike Gilbert  gentoo  org>
AuthorDate: Fri Apr 13 16:04:53 2018 +
Commit: Mike Gilbert  gentoo  org>
CommitDate: Wed Apr 18 18:13:10 2018 +
URL:https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=1e64d3eb

flag-o-matic.eclass: treat "--param x" as a unit when testing flags

For clang and gcc, --param consumes the next argument. Testing --param
and its value separately is nonsensical.

Acked-by: Sergei Trofimovich  gentoo.org>

 eclass/flag-o-matic.eclass   | 33 +++--
 eclass/tests/flag-o-matic.sh |  4 ++--
 2 files changed, 25 insertions(+), 12 deletions(-)

diff --git a/eclass/flag-o-matic.eclass b/eclass/flag-o-matic.eclass
index 14b84fbdbeb..5ab14b08d6e 100644
--- a/eclass/flag-o-matic.eclass
+++ b/eclass/flag-o-matic.eclass
@@ -421,9 +421,9 @@ strip-flags() {
 test-flag-PROG() {
local comp=$1
local lang=$2
-   local flag=$3
+   shift 2
 
-   [[ -z ${comp} || -z ${flag} ]] && return 1
+   [[ -z ${comp} || -z $1 ]] && return 1
 
local cmdline=(
$(tc-get${comp})
@@ -434,11 +434,11 @@ test-flag-PROG() {
-c -o /dev/null
)
if "${cmdline[@]}" -x${lang} - /dev/null ; then
-   cmdline+=( "${flag}" -x${lang} - )
+   cmdline+=( "$@" -x${lang} - )
else
# XXX: what's the purpose of this? does it even work with
# any compiler?
-   cmdline+=( "${flag}" -c -o /dev/null /dev/null )
+   cmdline+=( "$@" -c -o /dev/null /dev/null )
fi
 
if ! "${cmdline[@]}" /dev/null; then
@@ -455,25 +455,25 @@ test-flag-PROG() {
 # @USAGE: 
 # @DESCRIPTION:
 # Returns shell true if  is supported by the C compiler, else returns 
shell false.
-test-flag-CC() { test-flag-PROG "CC" c "$1"; }
+test-flag-CC() { test-flag-PROG "CC" c "$@"; }
 
 # @FUNCTION: test-flag-CXX
 # @USAGE: 
 # @DESCRIPTION:
 # Returns shell true if  is supported by the C++ compiler, else returns 
shell false.
-test-flag-CXX() { test-flag-PROG "CXX" c++ "$1"; }
+test-flag-CXX() { test-flag-PROG "CXX" c++ "$@"; }
 
 # @FUNCTION: test-flag-F77
 # @USAGE: 
 # @DESCRIPTION:
 # Returns shell true if  is supported by the Fortran 77 compiler, else 
returns shell false.
-test-flag-F77() { test-flag-PROG "F77" f77 "$1"; }
+test-flag-F77() { test-flag-PROG "F77" f77 "$@"; }
 
 # @FUNCTION: test-flag-FC
 # @USAGE: 
 # @DESCRIPTION:
 # Returns shell true if  is supported by the Fortran 90 compiler, else 
returns shell false.
-test-flag-FC() { test-flag-PROG "FC" f95 "$1"; }
+test-flag-FC() { test-flag-PROG "FC" f95 "$@"; }
 
 test-flags-PROG() {
local comp=$1
@@ -484,8 +484,21 @@ test-flags-PROG() {
 
[[ -z ${comp} ]] && return 1
 
-   for x ; do
-   test-flag-${comp} "${x}" && flags+=( "${x}" )
+   while (( $# )); do
+   case "$1" in
+   --param)
+   if test-flag-${comp} "$1" "$2"; then
+   flags+=( "$1" "$2" )
+   fi
+   shift 2
+   ;;
+   *)
+   if test-flag-${comp} "$1"; then
+   flags+=( "$1" )
+   fi
+   shift 1
+   ;;
+   esac
done
 
echo "${flags[*]}"

diff --git a/eclass/tests/flag-o-matic.sh b/eclass/tests/flag-o-matic.sh
index 53af9f862c4..97cd71d710a 100755
--- a/eclass/tests/flag-o-matic.sh
+++ b/eclass/tests/flag-o-matic.sh
@@ -6,7 +6,7 @@ source tests-common.sh
 
 inherit flag-o-matic
 
-CFLAGS="-a -b -c=1"
+CFLAGS="-a -b -c=1 --param l1-cache-size=32"
 CXXFLAGS="-x -y -z=2"
 LDFLAGS="-l -m -n=3"
 ftend() {
@@ -55,7 +55,7 @@ done <<<"
 
 tbegin "strip-unsupported-flags"
 strip-unsupported-flags
-[[ ${CFLAGS} == "" ]] && [[ ${CXXFLAGS} == "-z=2" ]] && [[ ${LDFLAGS} == "" ]]
+[[ ${CFLAGS} == "--param l1-cache-size=32" ]] && [[ ${CXXFLAGS} == "-z=2" ]] 
&& [[ ${LDFLAGS} == "" ]]
 ftend
 
 for var in $(all-flag-vars) ; do



[gentoo-commits] repo/gentoo:master commit in: eclass/tests/, eclass/

2018-01-04 Thread Michał Górny
commit: 0e50583c165feedf24152dae1973af88e0005191
Author: Michał Górny  gentoo  org>
AuthorDate: Sun Dec 31 10:29:42 2017 +
Commit: Michał Górny  gentoo  org>
CommitDate: Thu Jan  4 21:56:14 2018 +
URL:https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=0e50583c

multiprocessing.eclass: Remove multijob_* functions

Remove the multijob functions that were used to run bash code
in parallel. The code was very complex, fragile and unmaintained. It has
been used scarcely, and pretty much by a single developer. It gave very
little gain, usually at the cost of losing readability and violating
PMS.

Closes: https://bugs.gentoo.org/613322

 eclass/multiprocessing.eclass   | 178 +++-
 eclass/tests/multiprocessing.sh |  42 --
 2 files changed, 10 insertions(+), 210 deletions(-)

diff --git a/eclass/multiprocessing.eclass b/eclass/multiprocessing.eclass
index b6e92976f73..cfe22303043 100644
--- a/eclass/multiprocessing.eclass
+++ b/eclass/multiprocessing.eclass
@@ -1,4 +1,4 @@
-# Copyright 1999-2014 Gentoo Foundation
+# Copyright 1999-2017 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 # @ECLASS: multiprocessing.eclass
@@ -7,29 +7,20 @@
 # @AUTHOR:
 # Brian Harring 
 # Mike Frysinger 
-# @BLURB: parallelization with bash (wtf?)
+# @BLURB: multiprocessing helper functions
 # @DESCRIPTION:
-# The multiprocessing eclass contains a suite of functions that allow ebuilds
-# to quickly run things in parallel using shell code.
+# The multiprocessing eclass contains a suite of utility functions
+# that could be helpful to controlling parallel multiple job execution.
+# The most common use is processing MAKEOPTS in order to obtain job
+# count.
 #
-# It has two modes: pre-fork and post-fork.  If you don't want to dive into any
-# more nuts & bolts, just use the pre-fork mode.  For main threads that mostly
-# spawn children and then wait for them to finish, use the pre-fork mode.  For
-# main threads that do a bit of processing themselves, use the post-fork mode.
-# You may mix & match them for longer computation loops.
 # @EXAMPLE:
 #
 # @CODE
-# # First initialize things:
-# multijob_init
-#
-# # Then hash a bunch of files in parallel:
-# for n in {0..20} ; do
-#  multijob_child_init md5sum data.${n} > data.${n}
-# done
-#
-# # Then wait for all the children to finish:
-# multijob_finish
+# src_compile() {
+#   # custom build system that does not support most of MAKEOPTS
+#   ./mybs -j$(makeopts_jobs)
+# }
 # @CODE
 
 if [[ -z ${_MULTIPROCESSING_ECLASS} ]]; then
@@ -126,155 +117,6 @@ makeopts_loadavg() {
echo ${lavg:-${2:-999}}
 }
 
-# @FUNCTION: multijob_init
-# @USAGE: [${MAKEOPTS}]
-# @DESCRIPTION:
-# Setup the environment for executing code in parallel.
-# You must call this before any other multijob function.
-multijob_init() {
-   # When something goes wrong, try to wait for all the children so we
-   # don't leave any zombies around.
-   has wait ${EBUILD_DEATH_HOOKS} || EBUILD_DEATH_HOOKS+=" wait "
-
-   # Setup a pipe for children to write their pids to when they finish.
-   # We have to allocate two fd's because POSIX has undefined behavior
-   # when using one single fd for both read and write. #487056
-   # However, opening an fd for read or write only will block until the
-   # opposite end is opened as well. Thus we open the first fd for both
-   # read and write to not block ourselve, but use it for reading only.
-   # The second fd really is opened for write only, as Cygwin supports
-   # just one single read fd per FIFO. #583962
-   local pipe="${T}/multijob.pipe"
-   mkfifo -m 600 "${pipe}"
-   redirect_alloc_fd mj_read_fd "${pipe}"
-   redirect_alloc_fd mj_write_fd "${pipe}" '>'
-   rm -f "${pipe}"
-
-   # See how many children we can fork based on the user's settings.
-   mj_max_jobs=$(makeopts_jobs "$@")
-   mj_num_jobs=0
-}
-
-# @FUNCTION: multijob_child_init
-# @USAGE: [--pre|--post] [command to run in background]
-# @DESCRIPTION:
-# This function has two forms.  You can use it to execute a simple command
-# in the background (and it takes care of everything else), or you must
-# call this first thing in your forked child process.
-#
-# The --pre/--post options allow you to select the child generation mode.
-#
-# @CODE
-# # 1st form: pass the command line as arguments:
-# multijob_child_init ls /dev
-# # Or if you want to use pre/post fork modes:
-# multijob_child_init --pre ls /dev
-# multijob_child_init --post ls /dev
-#
-# # 2nd form: execute multiple stuff in the background (post fork):
-# (
-# multijob_child_init
-# out=`ls`
-# if echo "${out}" | grep foo ; then
-#  echo "YEAH"
-# fi
-# ) &
-# multijob_post_fork
-#
-# # 2nd form: execute multiple stuff in the background (pre fork):
-# multijob_pre_fork
-# (
-# multijob_child_init
-# out=`ls`
-# if echo "${out}" | grep foo ; then
-#  echo "YEAH

[gentoo-commits] repo/gentoo:master commit in: eclass/tests/, eclass/

2017-09-26 Thread Ulrich Müller
commit: 7175c90c8c4bc1332899dffa6b5fa7a7b30ad2a4
Author: Ulrich Müller  gentoo  org>
AuthorDate: Sat Sep 23 08:58:43 2017 +
Commit: Ulrich Müller  gentoo  org>
CommitDate: Tue Sep 26 18:46:27 2017 +
URL:https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=7175c90c

eapi7-ver.eclass: Use lexicographic rather than arithmetic comparison.

This removes the 2**63-1 limit for integer components.

 eclass/eapi7-ver.eclass   | 36 ++--
 eclass/tests/eapi7-ver.sh |  2 +-
 2 files changed, 27 insertions(+), 11 deletions(-)

diff --git a/eclass/eapi7-ver.eclass b/eclass/eapi7-ver.eclass
index 5ca8b8143af..7eb070c6817 100644
--- a/eclass/eapi7-ver.eclass
+++ b/eclass/eapi7-ver.eclass
@@ -174,6 +174,28 @@ ver_rs() {
echo "${comp[*]}"
 }
 
+# @FUNCTION: _ver_compare_int
+# @USAGE:  
+# @RETURN: 0 if  -eq , 1 if  -lt , 3 if  -gt 
+# @INTERNAL
+# @DESCRIPTION:
+# Compare two non-negative integers  and , of arbitrary length.
+# If  is equal to, less than, or greater than , return 0, 1, or 3
+# as exit status, respectively.
+_ver_compare_int() {
+   local a=$1 b=$2 d=$(( ${#1}-${#2} ))
+
+   # Zero-pad to equal length if necessary.
+   if [[ ${d} -gt 0 ]]; then
+   printf -v b "%0${d}d%s" 0 "${b}"
+   elif [[ ${d} -lt 0 ]]; then
+   printf -v a "%0$(( -d ))d%s" 0 "${a}"
+   fi
+
+   [[ ${a} > ${b} ]] && return 3
+   [[ ${a} == "${b}" ]]
+}
+
 # @FUNCTION: _ver_compare
 # @USAGE:  
 # @RETURN: 1 if  < , 2 if  = , 3 if  > 
@@ -200,10 +222,7 @@ _ver_compare() {
 
# Compare numeric components (PMS algorithm 3.2)
# First component
-   a=${an%%.*}
-   b=${bn%%.*}
-   [[ 10#${a} -gt 10#${b} ]] && return 3
-   [[ 10#${a} -lt 10#${b} ]] && return 1
+   _ver_compare_int "${an%%.*}" "${bn%%.*}" || return
 
while [[ ${an} == *.* && ${bn} == *.* ]]; do
# Other components (PMS algorithm 3.3)
@@ -218,8 +237,7 @@ _ver_compare() {
[[ ${a} > ${b} ]] && return 3
[[ ${a} < ${b} ]] && return 1
else
-   [[ ${a} -gt ${b} ]] && return 3
-   [[ ${a} -lt ${b} ]] && return 1
+   _ver_compare_int "${a}" "${b}" || return
fi
done
[[ ${an} == *.* ]] && return 3
@@ -237,8 +255,7 @@ _ver_compare() {
a=${as%%_*}
b=${bs%%_*}
if [[ ${a%%[0-9]*} == "${b%%[0-9]*}" ]]; then
-   [[ 10#${a##*[a-z]} -gt 10#${b##*[a-z]} ]] && return 3
-   [[ 10#${a##*[a-z]} -lt 10#${b##*[a-z]} ]] && return 1
+   _ver_compare_int "${a##*[a-z]}" "${b##*[a-z]}" || return
else
# Check for p first
[[ ${a%%[0-9]*} == p ]] && return 3
@@ -256,8 +273,7 @@ _ver_compare() {
fi
 
# Compare revision components (PMS algorithm 3.7)
-   [[ 10#${ar#-r} -gt 10#${br#-r} ]] && return 3
-   [[ 10#${ar#-r} -lt 10#${br#-r} ]] && return 1
+   _ver_compare_int "${ar#-r}" "${br#-r}" || return
 
return 2
 }

diff --git a/eclass/tests/eapi7-ver.sh b/eclass/tests/eapi7-ver.sh
index fd085a415b6..d4aa4fdbd28 100755
--- a/eclass/tests/eapi7-ver.sh
+++ b/eclass/tests/eapi7-ver.sh
@@ -150,7 +150,7 @@ teqr 0 ver_test 1.010 -eq 1.01
 teqr 0 ver_test 1.01 -lt 1.1
 teqr 0 ver_test 1.2_pre08-r09 -eq 1.2_pre8-r9
 teqr 0 ver_test 0 -lt 576460752303423488 # 2**59
-#teqr 0 ver_test 0 -lt 9223372036854775808 # 2**63 fails, integer rollover
+teqr 0 ver_test 0 -lt 9223372036854775808 # 2**63
 
 # Bad number or ordering of arguments
 txf ver_test 1



[gentoo-commits] repo/gentoo:master commit in: eclass/tests/, eclass/

2017-09-19 Thread Michał Górny
commit: 59a1a0dda7300177a263eb1de347da493f09fdee
Author: Michał Górny  gentoo  org>
AuthorDate: Fri Sep  8 11:12:30 2017 +
Commit: Michał Górny  gentoo  org>
CommitDate: Tue Sep 19 11:08:26 2017 +
URL:https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=59a1a0dd

eapi7-ver.eclass: 'Early adopter' version of EAPI 7 version manip

EAPI 7 is introducing new version manipulation and comparison functions
that aim to replace versionator.eclass. This eclass provides an 'early
adopter' versions of those routines.

It serves two goals:

a. getting wider review and some real-life testing before
the specification is set in stone,

b. making it possible to adapt ebuilds to the new routines early,
reducing the future work of EAPI 7 porting,

c. improving cache generation speed (the rountines are roughly 15-20
times than versionator.eclass).

For more details on the new logic, please see the eclass documentation.
Long story short, we are introducing three functions:

1. ver_cut -- to get substrings of the version string,

2. ver_rs -- to replace version separators via indices,

3. ver_test -- to compare two version numbers.

The third function is not implemented in the eclass. It's meant to reuse
the algorithms from the package manager, and the final implementation
will most likely reuse the code from the package manager (e.g. via IPC).

The code has been initially written by Ulrich Müller.

 eclass/eapi7-ver.eclass | 190 
 eclass/tests/eapi7-ver.sh   |  65 
 eclass/tests/eapi7-ver_benchmark.sh | 113 +
 3 files changed, 368 insertions(+)

diff --git a/eclass/eapi7-ver.eclass b/eclass/eapi7-ver.eclass
new file mode 100644
index 000..1e8e3c5e55b
--- /dev/null
+++ b/eclass/eapi7-ver.eclass
@@ -0,0 +1,190 @@
+# Copyright 1999-2017 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+# @ECLASS: eapi7-ver.eclass
+# @MAINTAINER:
+# PMS team 
+# @AUTHOR:
+# Ulrich Müller 
+# Michał Górny 
+# @BLURB: Testing implementation of EAPI 7 version manipulators
+# @DESCRIPTION:
+# A stand-alone implementation of the version manipulation functions
+# aimed for EAPI 7.  Intended to be used for wider testing of
+# the proposed functions and to allow ebuilds to switch to the new
+# model early, with minimal change needed for actual EAPI 7.
+#
+# https://bugs.gentoo.org/482170
+#
+# Note: version comparison function is not included currently.
+#
+# @ROFF .SS
+# Version strings
+#
+# The functions support arbitrary version strings consisting of version
+# components interspersed with (possibly empty) version separators.
+#
+# A version component can either consist purely of digits ([0-9]+)
+# or purely of uppercase and lowercase letters ([A-Za-z]+).  A version
+# separator is either a string of any other characters ([^A-Za-z0-9]+),
+# or it occurs at the transition between a sequence of letters
+# and a sequence of digits, or vice versa.  In the latter case,
+# the version separator is an empty string.
+#
+# The version is processed left-to-right, and each successive component
+# is assigned numbers starting with 1.  The components are either split
+# on version separators or on boundaries between digits and letters
+# (in which case the separator between the components is empty).
+# Version separators are assigned numbers starting with 1 for
+# the separator between 1st and 2nd components.  As a special case,
+# if the version string starts with a separator, it is assigned index 0.
+#
+# Examples:
+#
+# @CODE
+#   1.2b-alpha4 -> 1 . 2 '' b - alpha '' 4
+#  c s c s  c s c s  c
+#  1 1 2 2  3 3 4 4  5
+#
+#   .11.-> . 11 .
+#  s c  s
+#  0 1  1
+# @CODE
+#
+# @ROFF .SS
+# Ranges
+#
+# A range can be specified as 'm' for m-th version component, 'm-'
+# for all components starting with m-th or 'm-n' for components starting
+# at m-th and ending at n-th (inclusive).  If the range spans outside
+# the version string, it is truncated silently.
+
+case ${EAPI:-0} in
+   0|1|2|3|4|5)
+   die "${ECLASS}: EAPI=${EAPI:-0} not supported";;
+   6)
+   ;;
+   *)
+   die "${ECLASS}: EAPI=${EAPI} unknown";;
+esac
+
+# @FUNCTION: _ver_parse_range
+# @USAGE:  
+# @INTERNAL
+# @DESCRIPTION:
+# Parse the range string , setting 'start' and 'end' variables
+# to the appropriate bounds.   and  specify the appropriate
+# lower and upper bound for the range; the user-specified value is
+# truncated to this range.
+_ver_parse_range() {
+   local range=${1}
+   local max=${2}
+
+   [[ ${range} == [0-9]* ]] \
+   || die "${FUNCNAME}: range must start with a number"
+   start=${range%-*}
+   [[ ${range} == *-* ]] && end=${range#*-} || end=${start}
+   if [[ ${end} ]]; then
+   [[ ${start} -le ${end} ]] \
+   || die "${FUN

[gentoo-commits] repo/gentoo:master commit in: eclass/tests/, eclass/

2017-08-25 Thread Michał Górny
commit: ae9870d9f6b1394ede86176443770b36d7e60ac1
Author: Michał Górny  gentoo  org>
AuthorDate: Fri Aug 11 15:17:45 2017 +
Commit: Michał Górny  gentoo  org>
CommitDate: Fri Aug 25 13:53:15 2017 +
URL:https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=ae9870d9

flag-o-matic.eclass: test-flag-PROG, ignore unused args in clang

By default, clang considers unused arguments as error when -Werror is
used. Since flag tests are performed without linking, this causes all
tests for linker flags to fail inadvertently and all those flags
are stripped as a result.

While the correctness of passing unused flags is doubtful, silently
stripping them in a few random packages is certainly not the solution
to the problem, and also makes the results differ between gcc and clang.
To account for that, use clang's -Qunused-arguments option to silence
unused argument warnings.

To avoid wasting time on testing the compiler, just try passing
-Qunused-arguments every time a flag check fails. If clang is not used,
the additional call will fail just the same as the previous one (either
because of the original flag or because of -Qunused-arguments), so
the result will be the same.

 eclass/flag-o-matic.eclass   | 9 -
 eclass/tests/flag-o-matic.sh | 5 +
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/eclass/flag-o-matic.eclass b/eclass/flag-o-matic.eclass
index 0393a30b74c..79866e04a48 100644
--- a/eclass/flag-o-matic.eclass
+++ b/eclass/flag-o-matic.eclass
@@ -441,7 +441,14 @@ test-flag-PROG() {
cmdline+=( "${flag}" -c -o /dev/null /dev/null )
fi
 
-   "${cmdline[@]}" /dev/null
+   if ! "${cmdline[@]}" /dev/null; then
+   # -Werror makes clang bail out on unused arguments as well;
+   # try to add -Qunused-arguments to work-around that
+   # other compilers don't support it but then, it's failure like
+   # any other
+   cmdline+=( -Qunused-arguments )
+   "${cmdline[@]}" /dev/null
+   fi
 }
 
 # @FUNCTION: test-flag-CC

diff --git a/eclass/tests/flag-o-matic.sh b/eclass/tests/flag-o-matic.sh
index 92c68b82c3c..5e7ee354bf3 100755
--- a/eclass/tests/flag-o-matic.sh
+++ b/eclass/tests/flag-o-matic.sh
@@ -143,6 +143,11 @@ tbegin "test-flags-CC (gcc-valid but clang-invalid flags)"
 out=$(CC=clang test-flags-CC -finline-limit=1200)
 [[ $? -ne 0 && -z ${out} ]]
 ftend
+
+tbegin "test-flags-CC (unused flags w/clang)"
+out=$(CC=clang test-flags-CC -Wl,-O1)
+[[ $? -eq 0 && ${out} == "-Wl,-O1" ]]
+ftend
 fi
 
 texit



[gentoo-commits] repo/gentoo:master commit in: eclass/tests/, eclass/

2017-08-11 Thread Michał Górny
commit: 28dd7e772d7245723a725ea13673b3419139cd43
Author: Michał Górny  gentoo  org>
AuthorDate: Fri Aug 11 14:33:18 2017 +
Commit: Michał Górny  gentoo  org>
CommitDate: Fri Aug 11 14:35:09 2017 +
URL:https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=28dd7e77

flag-o-matic.eclass: Revert "Strip LDFLAGS unsupported by the C..."

The current logic strips too much, causing build failures. Revert it
until we get it right.

Bug: https://bugs.gentoo.org/627474

 eclass/flag-o-matic.eclass   | 3 ---
 eclass/tests/flag-o-matic.sh | 2 +-
 2 files changed, 1 insertion(+), 4 deletions(-)

diff --git a/eclass/flag-o-matic.eclass b/eclass/flag-o-matic.eclass
index 4ef32c519f2..b2f3742b3ec 100644
--- a/eclass/flag-o-matic.eclass
+++ b/eclass/flag-o-matic.eclass
@@ -535,9 +535,6 @@ strip-unsupported-flags() {
export CXXFLAGS=$(test-flags-CXX ${CXXFLAGS})
export FFLAGS=$(test-flags-F77 ${FFLAGS})
export FCFLAGS=$(test-flags-FC ${FCFLAGS})
-   # note: this does not verify the linker flags but it is enough
-   # to strip invalid C flags which are much more likely, #621274
-   export LDFLAGS=$(test-flags-CC ${LDFLAGS})
 }
 
 # @FUNCTION: get-flag

diff --git a/eclass/tests/flag-o-matic.sh b/eclass/tests/flag-o-matic.sh
index 24f2a4c4af4..92c68b82c3c 100755
--- a/eclass/tests/flag-o-matic.sh
+++ b/eclass/tests/flag-o-matic.sh
@@ -55,7 +55,7 @@ done <<<"
 
 tbegin "strip-unsupported-flags"
 strip-unsupported-flags
-[[ ${CFLAGS} == "" ]] && [[ ${CXXFLAGS} == "-z=2" ]] && [[ ${LDFLAGS} == "" ]]
+[[ ${CFLAGS} == "" ]] && [[ ${CXXFLAGS} == "-z=2" ]]
 ftend
 
 for var in $(all-flag-vars) ; do



[gentoo-commits] repo/gentoo:master commit in: eclass/tests/, eclass/

2017-08-08 Thread Michał Górny
commit: 0e6d20439e89c82fa99bbaefbe2a728efc77631c
Author: Michał Górny  gentoo  org>
AuthorDate: Sat Jul  1 16:14:44 2017 +
Commit: Michał Górny  gentoo  org>
CommitDate: Tue Aug  8 19:42:17 2017 +
URL:https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=0e6d2043

flag-o-matic.eclass: Strip LDFLAGS unsupported by the C compiler, #621274

Include LDFLAGS in the variables stripped by strip-unsupported-flags.
The code reuses the current functions for testing CC, and so only remove
LDFLAGS that are rejected by the C compiler and not the linker. This
solves the case of bug #621274 where LDFLAGS contained GCC-specific
-flto flag.

 eclass/flag-o-matic.eclass   | 3 +++
 eclass/tests/flag-o-matic.sh | 2 +-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/eclass/flag-o-matic.eclass b/eclass/flag-o-matic.eclass
index b2f3742b3ec..4ef32c519f2 100644
--- a/eclass/flag-o-matic.eclass
+++ b/eclass/flag-o-matic.eclass
@@ -535,6 +535,9 @@ strip-unsupported-flags() {
export CXXFLAGS=$(test-flags-CXX ${CXXFLAGS})
export FFLAGS=$(test-flags-F77 ${FFLAGS})
export FCFLAGS=$(test-flags-FC ${FCFLAGS})
+   # note: this does not verify the linker flags but it is enough
+   # to strip invalid C flags which are much more likely, #621274
+   export LDFLAGS=$(test-flags-CC ${LDFLAGS})
 }
 
 # @FUNCTION: get-flag

diff --git a/eclass/tests/flag-o-matic.sh b/eclass/tests/flag-o-matic.sh
index 92c68b82c3c..24f2a4c4af4 100755
--- a/eclass/tests/flag-o-matic.sh
+++ b/eclass/tests/flag-o-matic.sh
@@ -55,7 +55,7 @@ done <<<"
 
 tbegin "strip-unsupported-flags"
 strip-unsupported-flags
-[[ ${CFLAGS} == "" ]] && [[ ${CXXFLAGS} == "-z=2" ]]
+[[ ${CFLAGS} == "" ]] && [[ ${CXXFLAGS} == "-z=2" ]] && [[ ${LDFLAGS} == "" ]]
 ftend
 
 for var in $(all-flag-vars) ; do



[gentoo-commits] repo/gentoo:master commit in: eclass/tests/, eclass/

2017-03-18 Thread Michał Górny
commit: f7a4c94d344b6c73773bf83bd397ba468386e294
Author: Michał Górny  gentoo  org>
AuthorDate: Sat Mar 11 13:25:42 2017 +
Commit: Michał Górny  gentoo  org>
CommitDate: Sat Mar 18 07:33:16 2017 +
URL:https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=f7a4c94d

estack.eclass: Split estack* logic from eutils

Split the estack_* and related functions from eutils into a dedicated
estack.eclass. Those functions have significant complexity and are not
used frequently, therefore they benefit from having a separate file
and an explicit dedicated maintainer.

The new eclass is implicitly inherited by eutils to preserve
compatibility. However, the inherit will be removed in EAPI 7,
and the ebuilds should switch to using estack directly.

Thanks to Ulrich Müller for doing the research on this.

 eclass/estack.eclass   | 217 +
 eclass/eutils.eclass   | 210 +---
 .../tests/{eutils_eshopts.sh => estack_eshopts.sh} |   4 +-
 .../tests/{eutils_estack.sh => estack_estack.sh}   |   4 +-
 eclass/tests/{eutils_evar.sh => estack_evar.sh}|   4 +-
 5 files changed, 230 insertions(+), 209 deletions(-)

diff --git a/eclass/estack.eclass b/eclass/estack.eclass
new file mode 100644
index 000..19c388f3d8d
--- /dev/null
+++ b/eclass/estack.eclass
@@ -0,0 +1,217 @@
+# Copyright 1999-2017 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+# @ECLASS: estack.eclass
+# @MAINTAINER:
+# base-sys...@gentoo.org
+# @BLURB: stack-like value storage support
+# @DESCRIPTION:
+# Support for storing values on stack-like variables.
+
+if [[ -z ${_ESTACK_ECLASS} ]]; then
+
+# @FUNCTION: estack_push
+# @USAGE:  [items to push]
+# @DESCRIPTION:
+# Push any number of items onto the specified stack.  Pick a name that
+# is a valid variable (i.e. stick to alphanumerics), and push as many
+# items as you like onto the stack at once.
+#
+# The following code snippet will echo 5, then 4, then 3, then ...
+# @CODE
+#  estack_push mystack 1 2 3 4 5
+#  while estack_pop mystack i ; do
+#  echo "${i}"
+#  done
+# @CODE
+estack_push() {
+   [[ $# -eq 0 ]] && die "estack_push: incorrect # of arguments"
+   local stack_name="_ESTACK_$1_" ; shift
+   eval ${stack_name}+=\( \"\$@\" \)
+}
+
+# @FUNCTION: estack_pop
+# @USAGE:  [variable]
+# @DESCRIPTION:
+# Pop a single item off the specified stack.  If a variable is specified,
+# the popped item is stored there.  If no more items are available, return
+# 1, else return 0.  See estack_push for more info.
+estack_pop() {
+   [[ $# -eq 0 || $# -gt 2 ]] && die "estack_pop: incorrect # of arguments"
+
+   # We use the fugly _estack_xxx var names to avoid collision with
+   # passing back the return value.  If we used "local i" and the
+   # caller ran `estack_pop ... i`, we'd end up setting the local
+   # copy of "i" rather than the caller's copy.  The _estack_xxx
+   # garbage is preferable to using $1/$2 everywhere as that is a
+   # bit harder to read.
+   local _estack_name="_ESTACK_$1_" ; shift
+   local _estack_retvar=$1 ; shift
+   eval local _estack_i=\${#${_estack_name}\[@\]}
+   # Don't warn -- let the caller interpret this as a failure
+   # or as normal behavior (akin to `shift`)
+   [[ $(( --_estack_i )) -eq -1 ]] && return 1
+
+   if [[ -n ${_estack_retvar} ]] ; then
+   eval ${_estack_retvar}=\"\${${_estack_name}\[${_estack_i}\]}\"
+   fi
+   eval unset \"${_estack_name}\[${_estack_i}\]\"
+}
+
+# @FUNCTION: evar_push
+# @USAGE:  [more vars to save]
+# @DESCRIPTION:
+# This let's you temporarily modify a variable and then restore it (including
+# set vs unset semantics).  Arrays are not supported at this time.
+#
+# This is meant for variables where using `local` does not work (such as
+# exported variables, or only temporarily changing things in a func).
+#
+# For example:
+# @CODE
+#  evar_push LC_ALL
+#  export LC_ALL=C
+#  ... do some stuff that needs LC_ALL=C set ...
+#  evar_pop
+#
+#  # You can also save/restore more than one var at a time
+#  evar_push BUTTERFLY IN THE SKY
+#  ... do stuff with the vars ...
+#  evar_pop # This restores just one var, SKY
+#  ... do more stuff ...
+#  evar_pop 3   # This pops the remaining 3 vars
+# @CODE
+evar_push() {
+   local var val
+   for var ; do
+   [[ ${!var+set} == "set" ]] \
+   && val=${!var} \
+   || val="unset_76fc3c462065bb4ca959f939e6793f94"
+   estack_push evar "${var}" "${val}"
+   done
+}
+
+# @FUNCTION: evar_push_set
+# @USAGE:  [new value to store]
+# @DESCRIPTION:
+# This is a handy shortcut to save and temporarily set a variable.  If a va

[gentoo-commits] repo/gentoo:master commit in: eclass/tests/, eclass/

2017-02-09 Thread Mike Frysinger
commit: 9470312c23d126f0055f82c0e656003b3945430b
Author: Mike Frysinger  gentoo  org>
AuthorDate: Thu Feb  9 18:15:13 2017 +
Commit: Mike Frysinger  gentoo  org>
CommitDate: Thu Feb  9 18:16:07 2017 +
URL:https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=9470312c

multiprocess.eclass: makeopts_{jobs,loadavg}: fix implicit handling of 
$MAKEOPTS #608242

We missed quoting on ${MAKEOPTS} to set it as the first arg which meant
we might load invalid values into the second arg which is the "infinite"
scenario.

 eclass/multiprocessing.eclass|  4 ++--
 eclass/tests/multiprocessing_makeopts_jobs.sh| 12 +---
 eclass/tests/multiprocessing_makeopts_loadavg.sh | 11 ---
 3 files changed, 19 insertions(+), 8 deletions(-)

diff --git a/eclass/multiprocessing.eclass b/eclass/multiprocessing.eclass
index 67f7e2d65b..73d852410b 100644
--- a/eclass/multiprocessing.eclass
+++ b/eclass/multiprocessing.eclass
@@ -96,7 +96,7 @@ get_nproc() {
 # no way to represent infinity, we return ${inf} (defaults to 999) if the user
 # has -j without a number.
 makeopts_jobs() {
-   [[ $# -eq 0 ]] && set -- ${MAKEOPTS}
+   [[ $# -eq 0 ]] && set -- "${MAKEOPTS}"
# This assumes the first .* will be more greedy than the second .*
# since POSIX doesn't specify a non-greedy match (i.e. ".*?").
local jobs=$(echo " $* " | sed -r -n \
@@ -117,7 +117,7 @@ makeopts_jobs() {
 # If no limit is specified or --load-average is used without a number, ${inf}
 # (defaults to 999) is returned.
 makeopts_loadavg() {
-   [[ $# -eq 0 ]] && set -- ${MAKEOPTS}
+   [[ $# -eq 0 ]] && set -- "${MAKEOPTS}"
# This assumes the first .* will be more greedy than the second .*
# since POSIX doesn't specify a non-greedy match (i.e. ".*?").
local lavg=$(echo " $* " | sed -r -n \

diff --git a/eclass/tests/multiprocessing_makeopts_jobs.sh 
b/eclass/tests/multiprocessing_makeopts_jobs.sh
index ef477277ab..cc4f91b694 100755
--- a/eclass/tests/multiprocessing_makeopts_jobs.sh
+++ b/eclass/tests/multiprocessing_makeopts_jobs.sh
@@ -10,14 +10,20 @@ inherit multiprocessing
 test-makeopts_jobs() {
local exp=$1; shift
tbegin "makeopts_jobs($1${2+; inf=${2}}) == ${exp}"
-   local act=$(makeopts_jobs "$@")
-   [[ ${act} == "${exp}" ]]
-   tend $? "Got back: ${act}"
+   local indirect=$(MAKEOPTS="$*" makeopts_jobs)
+   local direct=$(makeopts_jobs "$@")
+   if [[ "${direct}" != "${indirect}" ]] ; then
+   tend 1 "Mismatch between MAKEOPTS/cli: '${indirect}' != 
'${direct}'"
+   else
+   [[ ${direct} == "${exp}" ]]
+   tend $? "Got back: ${act}"
+   fi
 }
 
 tests=(
999 "-j"
999 "--jobs"
+   999 "-j -l9"
1 ""
1 "-l9 -w"
1 "-l9 -w-j4"

diff --git a/eclass/tests/multiprocessing_makeopts_loadavg.sh 
b/eclass/tests/multiprocessing_makeopts_loadavg.sh
index 6b976beb1a..ffa679d13e 100755
--- a/eclass/tests/multiprocessing_makeopts_loadavg.sh
+++ b/eclass/tests/multiprocessing_makeopts_loadavg.sh
@@ -10,9 +10,14 @@ inherit multiprocessing
 test-makeopts_loadavg() {
local exp=$1; shift
tbegin "makeopts_loadavg($1${2+; inf=${2}}) == ${exp}"
-   local act=$(makeopts_loadavg "$@")
-   [[ ${act} == "${exp}" ]]
-   tend $? "Got back: ${act}"
+   local indirect=$(MAKEOPTS="$*" makeopts_loadavg)
+   local direct=$(makeopts_loadavg "$@")
+   if [[ "${direct}" != "${indirect}" ]] ; then
+   tend 1 "Mismatch between MAKEOPTS/cli: '${indirect}' != 
'${direct}'"
+   else
+   [[ ${direct} == "${exp}" ]]
+   tend $? "Got back: ${act}"
+   fi
 }
 
 tests=(



[gentoo-commits] repo/gentoo:master commit in: eclass/tests/, eclass/

2016-12-18 Thread Michał Górny
commit: 639d76a02d2965f426944f7fa6d0259a99a613f9
Author: Michał Górny  gentoo  org>
AuthorDate: Tue Dec 13 08:57:46 2016 +
Commit: Michał Górny  gentoo  org>
CommitDate: Sun Dec 18 13:45:43 2016 +
URL:https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=639d76a0

multiprocessing.eclass: Fix handling multiple short options (e.g. -kj)

Improve the regular expressions to handle parameters consisting of
multiple short options (such as -kj). It should be noted that the code
is not perfect but should handle all common (valid) cases; it could e.g.
incorrectly process a short option followed by string arg such as
'-Wfoo.j' although having this in MAKEOPTS is extremely unlikely.

 eclass/multiprocessing.eclass| 8 
 eclass/tests/multiprocessing_makeopts_jobs.sh| 3 +++
 eclass/tests/multiprocessing_makeopts_loadavg.sh | 3 +++
 3 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/eclass/multiprocessing.eclass b/eclass/multiprocessing.eclass
index 06e004a..5a5fe9a 100644
--- a/eclass/multiprocessing.eclass
+++ b/eclass/multiprocessing.eclass
@@ -67,8 +67,8 @@ makeopts_jobs() {
# This assumes the first .* will be more greedy than the second .*
# since POSIX doesn't specify a non-greedy match (i.e. ".*?").
local jobs=$(echo " $* " | sed -r -n \
-   -e 
's:.*[[:space:]](-j|--jobs[=[:space:]])[[:space:]]*([0-9]+).*:\2:p' \
-   -e 's:.*[[:space:]](-j|--jobs)[[:space:]].*:999:p')
+   -e 
's:.*[[:space:]](-[a-z]*j|--jobs[=[:space:]])[[:space:]]*([0-9]+).*:\2:p' \
+   -e 's:.*[[:space:]](-[a-z]*j|--jobs)[[:space:]].*:999:p')
echo ${jobs:-1}
 }
 
@@ -86,8 +86,8 @@ makeopts_loadavg() {
# This assumes the first .* will be more greedy than the second .*
# since POSIX doesn't specify a non-greedy match (i.e. ".*?").
local lavg=$(echo " $* " | sed -r -n \
-   -e 
's:.*[[:space:]](-l|--(load-average|max-load)[=[:space:]])[[:space:]]*([0-9]+|[0-9]+\.[0-9]+).*:\3:p'
 \
-   -e 
's:.*[[:space:]](-l|--(load-average|max-load))[[:space:]].*:999:p')
+   -e 
's:.*[[:space:]](-[a-z]*l|--(load-average|max-load)[=[:space:]])[[:space:]]*([0-9]+|[0-9]+\.[0-9]+).*:\3:p'
 \
+   -e 
's:.*[[:space:]](-[a-z]*l|--(load-average|max-load))[[:space:]].*:999:p')
# Default to 999 since the default is to not use a load limit.
echo ${lavg:-999}
 }

diff --git a/eclass/tests/multiprocessing_makeopts_jobs.sh 
b/eclass/tests/multiprocessing_makeopts_jobs.sh
index 017d491..a1e43c8 100755
--- a/eclass/tests/multiprocessing_makeopts_jobs.sh
+++ b/eclass/tests/multiprocessing_makeopts_jobs.sh
@@ -31,6 +31,9 @@ tests=(
7 "-l3 --jobs 7 -w"
4 "-j1 -j 2 --jobs 3 --jobs=4"
8 " -j  8 "
+   999 "-kj"
+   4 "-kj4"
+   5 "-kj 5"
 )
 for (( i = 0; i < ${#tests[@]}; i += 2 )) ; do
test-makeopts_jobs "${tests[i]}" "${tests[i+1]}"

diff --git a/eclass/tests/multiprocessing_makeopts_loadavg.sh 
b/eclass/tests/multiprocessing_makeopts_loadavg.sh
index 12f9d01..276b7e7 100755
--- a/eclass/tests/multiprocessing_makeopts_loadavg.sh
+++ b/eclass/tests/multiprocessing_makeopts_loadavg.sh
@@ -28,6 +28,9 @@ tests=(
4 "-j1 -j 2 --load-average 3 --load-average=4"
3 " --max-load=3 -x"
8 " -l  8 "
+   999 "-kl"
+   4 "-kl4"
+   5 "-kl 5"
 )
 for (( i = 0; i < ${#tests[@]}; i += 2 )) ; do
test-makeopts_loadavg "${tests[i]}" "${tests[i+1]}"



[gentoo-commits] repo/gentoo:master commit in: eclass/tests/, eclass/

2016-06-26 Thread Michał Górny
commit: 81c226e451be564a545696f93fc5880ebc160812
Author: Michał Górny  gentoo  org>
AuthorDate: Mon Jun 27 05:52:14 2016 +
Commit: Michał Górny  gentoo  org>
CommitDate: Mon Jun 27 05:58:14 2016 +
URL:https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=81c226e4

toolchain-funcs.eclass: tc-ninja_magic_to_arch, remove old KV support

Remove the support for old kernel versions that are no longer used
in Gentoo, and rely on KV_to_int() function. This functions is provided
by Portage but not listed in PMS. Furthermore, for a long time Portage
replaced it with 'return 1' in global scope, so they did not really work
as expected anyway.

 eclass/tests/toolchain-funcs.sh |  7 ---
 eclass/toolchain-funcs.eclass   | 16 +++-
 2 files changed, 3 insertions(+), 20 deletions(-)

diff --git a/eclass/tests/toolchain-funcs.sh b/eclass/tests/toolchain-funcs.sh
index e6a1538..bfbe26f 100755
--- a/eclass/tests/toolchain-funcs.sh
+++ b/eclass/tests/toolchain-funcs.sh
@@ -25,13 +25,6 @@ test-tc-arch-kernel() {
done
return ${ret}
 }
-tbegin "tc-arch-kernel() (KV=2.6.0)"
-test-tc-arch-kernel 2.6.0 \
-   alpha arm{,eb}:arm avr32 bfin:blackfin cris hppa:parisc \
-   i{3..6}86:i386 ia64 m68k mips{,eb}:mips nios2 powerpc:ppc 
powerpc64:ppc64 \
-   s390{,x}:s390 sh{1..4}{,eb}:sh sparc{,64} vax x86_64 \
-   i{3..6}86-gentoo-freebsd:i386
-tend $?
 tbegin "tc-arch-kernel() (KV=2.6.30)"
 test-tc-arch-kernel 2.6.30 \
i{3..6}86:x86 x86_64:x86 \

diff --git a/eclass/toolchain-funcs.eclass b/eclass/toolchain-funcs.eclass
index d3abfb5..2652e0e 100644
--- a/eclass/toolchain-funcs.eclass
+++ b/eclass/toolchain-funcs.eclass
@@ -460,10 +460,6 @@ ninj() { [[ ${type} == "kern" ]] && echo $1 || echo $2 ; }
local host=$2
[[ -z ${host} ]] && host=${CTARGET:-${CHOST}}
 
-   local KV=${KV:-${KV_FULL}}
-   [[ ${type} == "kern" ]] && [[ -z ${KV} ]] && \
-   ewarn "QA: Kernel version could not be determined, please inherit 
kernel-2 or linux-info"
-
case ${host} in
aarch64*)   echo arm64;;
alpha*) echo alpha;;
@@ -479,7 +475,7 @@ ninj() { [[ ${type} == "kern" ]] && echo $1 || echo $2 ; }
# Starting with linux-2.6.24, the 'x86_64' and 'i386'
# trees have been unified into 'x86'.
# FreeBSD still uses i386
-   if [[ ${type} == "kern" ]] && [[ $(KV_to_int ${KV}) -lt 
$(KV_to_int 2.6.24) || ${host} == *freebsd* ]] ; then
+   if [[ ${type} == "kern" && ${host} == *freebsd* ]] ; 
then
echo i386
else
echo x86
@@ -497,14 +493,8 @@ ninj() { [[ ${type} == "kern" ]] && echo $1 || echo $2 ; }
# Starting with linux-2.6.15, the 'ppc' and 'ppc64' 
trees
# have been unified into simply 'powerpc', but until 
2.6.16,
# ppc32 is still using ARCH="ppc" as default
-   if [[ ${type} == "kern" ]] && [[ $(KV_to_int ${KV}) -ge 
$(KV_to_int 2.6.16) ]] ; then
+   if [[ ${type} == "kern" ]] ; then
echo powerpc
-   elif [[ ${type} == "kern" ]] && [[ $(KV_to_int ${KV}) 
-eq $(KV_to_int 2.6.15) ]] ; then
-   if [[ ${host} == powerpc64* ]] || [[ 
${PROFILE_ARCH} == "ppc64" ]] ; then
-   echo powerpc
-   else
-   echo ppc
-   fi
elif [[ ${host} == powerpc64* ]] ; then
echo ppc64
elif [[ ${PROFILE_ARCH} == "ppc64" ]] ; then
@@ -529,7 +519,7 @@ ninj() { [[ ${type} == "kern" ]] && echo $1 || echo $2 ; }
x86_64*)
# Starting with linux-2.6.24, the 'x86_64' and 'i386'
# trees have been unified into 'x86'.
-   if [[ ${type} == "kern" ]] && [[ $(KV_to_int ${KV}) -ge 
$(KV_to_int 2.6.24) ]] ; then
+   if [[ ${type} == "kern" ]] ; then
echo x86
else
ninj x86_64 amd64



[gentoo-commits] repo/gentoo:master commit in: eclass/tests/, eclass/

2016-06-26 Thread Michał Górny
commit: 2fea606eba41d9246f510814ce833879368bd835
Author: Michał Górny  gentoo  org>
AuthorDate: Wed Jun 22 19:50:21 2016 +
Commit: Michał Górny  gentoo  org>
CommitDate: Sun Jun 26 15:34:47 2016 +
URL:https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=2fea606e

toolchain-funcs.eclass: Add tc-get-compiler-type()

Add a tc-get-compiler-type() function that can be used to identify
the compiler being used, using the preprocessor defines. Alike
gcc-*version() routines, it uses CPP (which in turn uses CC).

The major usage would be applying compiler-specific quirks and limiting
gcc version checks to compilers that actually are gcc, since e.g. clang
reports gcc version 4.2 -- which would incorrectly cause numerous gcc
version checks in ebuilds to fail.

 eclass/tests/toolchain-funcs.sh | 40 
 eclass/toolchain-funcs.eclass   | 22 ++
 2 files changed, 62 insertions(+)

diff --git a/eclass/tests/toolchain-funcs.sh b/eclass/tests/toolchain-funcs.sh
index 41c1ae5..6f37996 100755
--- a/eclass/tests/toolchain-funcs.sh
+++ b/eclass/tests/toolchain-funcs.sh
@@ -111,5 +111,45 @@ tc-ld-disable-gold
 )
 tend $?
 
+unset CPP
+
+tbegin "tc-get-compiler-type (gcc)"
+(
+export CC=gcc
+[[ $(tc-get-compiler-type) == gcc ]]
+)
+tend $?
+
+if type -P clang &>/dev/null; then
+   tbegin "tc-get-compiler-type (clang)"
+   (
+   export CC=clang
+   [[ $(tc-get-compiler-type) == clang ]]
+   )
+   tend $?
+fi
+
+if type -P pathcc &>/dev/null; then
+   tbegin "tc-get-compiler-type (pathcc)"
+   (
+   export CC=pathcc
+   [[ $(tc-get-compiler-type) == pathcc ]]
+   )
+   tend $?
+
+   tbegin "! tc-is-gcc (pathcc)"
+   (
+   export CC=pathcc
+   ! tc-is-gcc
+   )
+   tend $?
+
+   tbegin "! tc-is-clang (pathcc)"
+   (
+   export CC=pathcc
+   ! tc-is-clang
+   )
+   tend $?
+fi
 
 texit

diff --git a/eclass/toolchain-funcs.eclass b/eclass/toolchain-funcs.eclass
index 1baab96..a29784c 100644
--- a/eclass/toolchain-funcs.eclass
+++ b/eclass/toolchain-funcs.eclass
@@ -585,6 +585,28 @@ tc-endian() {
esac
 }
 
+# @FUNCTION: tc-get-compiler-type
+# @RETURN: keyword identifying the compiler: gcc, clang, pathcc, unknown
+tc-get-compiler-type() {
+   local code='
+#if defined(__PATHSCALE__)
+   HAVE_PATHCC
+#elif defined(__clang__)
+   HAVE_CLANG
+#elif defined(__GNUC__)
+   HAVE_GCC
+#endif
+'
+   local res=$($(tc-getCPP "$@") -E -P - <<<"${code}")
+
+   case ${res} in
+   *HAVE_PATHCC*)  echo pathcc;;
+   *HAVE_CLANG*)   echo clang;;
+   *HAVE_GCC*) echo gcc;;
+   *)  echo unknown;;
+   esac
+}
+
 # Internal func.  The first argument is the version info to expand.
 # Query the preprocessor to improve compatibility across different
 # compilers rather than maintaining a --version flag matrix. #335943



[gentoo-commits] repo/gentoo:master commit in: eclass/tests/, eclass/

2016-01-07 Thread Michał Górny
commit: de0c03eda7a5570984491fe6fc2e4959b36ce128
Author: Michał Górny  gentoo  org>
AuthorDate: Fri Jan  1 12:55:26 2016 +
Commit: Michał Górny  gentoo  org>
CommitDate: Fri Jan  8 05:14:36 2016 +
URL:https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=de0c03ed

scons-utils.eclass: _scons_clean_makeopts, fix result caching

Stop calling _scons_clean_makeopts in a subshell in order to make
it possible for the cache to be preserved. Pass the result through
SCONSOPTS variable.

 eclass/scons-utils.eclass   | 15 +--
 eclass/tests/scons-utils.sh |  7 ---
 2 files changed, 13 insertions(+), 9 deletions(-)

diff --git a/eclass/scons-utils.eclass b/eclass/scons-utils.eclass
index e5e309b..4da2c4a 100644
--- a/eclass/scons-utils.eclass
+++ b/eclass/scons-utils.eclass
@@ -124,8 +124,12 @@ escons() {
fi
 
# if SCONSOPTS are _unset_, use cleaned MAKEOPTS
-   set -- scons ${SCONSOPTS-$(_scons_clean_makeopts)} ${EXTRA_ESCONS} \
-   "${@}"
+   if [[ ! ${SCONSOPTS+set} ]]; then
+   local SCONSOPTS
+   _scons_clean_makeopts
+   fi
+
+   set -- scons ${SCONSOPTS} ${EXTRA_ESCONS} "${@}"
echo "${@}" >&2
"${@}"
ret=${?}
@@ -169,9 +173,8 @@ _scons_clean_makeopts() {
# empty MAKEOPTS give out empty SCONSOPTS
# thus, we do need to worry about the initial setup
if [[ ${*} = ${_SCONS_CACHE_MAKEOPTS} ]]; then
-   set -- ${_SCONS_CACHE_SCONSOPTS}
-   debug-print "Cache hit: [${*}]"
-   echo ${*}
+   SCONSOPTS=${_SCONS_CACHE_SCONSOPTS}
+   debug-print "Cache hit: [${SCONSOPTS}]"
return
fi
export _SCONS_CACHE_MAKEOPTS=${*}
@@ -235,7 +238,7 @@ _scons_clean_makeopts() {
set -- ${new_makeopts}
export _SCONS_CACHE_SCONSOPTS=${*}
debug-print "New SCONSOPTS: [${*}]"
-   echo ${*}
+   SCONSOPTS=${*}
 }
 
 # @FUNCTION: use_scons

diff --git a/eclass/tests/scons-utils.sh b/eclass/tests/scons-utils.sh
index df8af7a..6355c54 100755
--- a/eclass/tests/scons-utils.sh
+++ b/eclass/tests/scons-utils.sh
@@ -10,14 +10,15 @@ inherit scons-utils
 test-scons_clean_makeopts() {
tbegin "scons_clean_makeopts() for ${1}"
 
-   local sconsopts=$(_scons_clean_makeopts ${1}) ret=0
+   local SCONSOPTS ret=0
+   _scons_clean_makeopts ${1}
 
-   if [[ ${sconsopts} != ${2-${1}} ]]; then
+   if [[ ${SCONSOPTS} != ${2-${1}} ]]; then
eerror "Self-test failed:"
eindent
eerror "MAKEOPTS: ${1}"
eerror "Expected: ${2-${1}}"
-   eerror "Actual: ${sconsopts}"
+   eerror "Actual: ${SCONSOPTS}"
eoutdent
ret=1
fi



[gentoo-commits] repo/gentoo:master commit in: eclass/tests/, eclass/

2016-01-07 Thread Michał Górny
commit: a4de8aa2e9ef28100fb8834aaeb4495f66efb8d9
Author: Michał Górny  gentoo  org>
AuthorDate: Fri Jan  1 12:52:26 2016 +
Commit: Michał Górny  gentoo  org>
CommitDate: Fri Jan  8 05:14:36 2016 +
URL:https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=a4de8aa2

scons-utils.eclass: scons_clean_makeopts, mark internal

 eclass/scons-utils.eclass   | 7 ---
 eclass/tests/scons-utils.sh | 2 +-
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/eclass/scons-utils.eclass b/eclass/scons-utils.eclass
index b8051b0..e5e309b 100644
--- a/eclass/scons-utils.eclass
+++ b/eclass/scons-utils.eclass
@@ -124,7 +124,7 @@ escons() {
fi
 
# if SCONSOPTS are _unset_, use cleaned MAKEOPTS
-   set -- scons ${SCONSOPTS-$(scons_clean_makeopts)} ${EXTRA_ESCONS} \
+   set -- scons ${SCONSOPTS-$(_scons_clean_makeopts)} ${EXTRA_ESCONS} \
"${@}"
echo "${@}" >&2
"${@}"
@@ -145,14 +145,15 @@ escons() {
return ${ret}
 }
 
-# @FUNCTION: scons_clean_makeopts
+# @FUNCTION: _scons_clean_makeopts
+# @INTERNAL
 # @USAGE: [makeflags] [...]
 # @DESCRIPTION:
 # Strip the supplied makeflags (or ${MAKEOPTS} if called without
 # an argument) of options not supported by SCons and make sure --jobs
 # gets an argument. Output the resulting flag list (suitable
 # for an assignment to SCONSOPTS).
-scons_clean_makeopts() {
+_scons_clean_makeopts() {
local new_makeopts
 
debug-print-function ${FUNCNAME} "${@}"

diff --git a/eclass/tests/scons-utils.sh b/eclass/tests/scons-utils.sh
index 7387135..df8af7a 100755
--- a/eclass/tests/scons-utils.sh
+++ b/eclass/tests/scons-utils.sh
@@ -10,7 +10,7 @@ inherit scons-utils
 test-scons_clean_makeopts() {
tbegin "scons_clean_makeopts() for ${1}"
 
-   local sconsopts=$(scons_clean_makeopts ${1}) ret=0
+   local sconsopts=$(_scons_clean_makeopts ${1}) ret=0
 
if [[ ${sconsopts} != ${2-${1}} ]]; then
eerror "Self-test failed:"



[gentoo-commits] repo/gentoo:master commit in: eclass/tests/, eclass/

2015-12-09 Thread Michał Górny
commit: f16b1c0b5321673d017ac61af3623041f155c71a
Author: Michał Górny  gentoo  org>
AuthorDate: Wed Dec  9 19:21:32 2015 +
Commit: Michał Górny  gentoo  org>
CommitDate: Wed Dec  9 20:41:16 2015 +
URL:https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=f16b1c0b

python-utils-r1.eclass: Disable jython2_5

 eclass/python-utils-r1.eclass   | 6 ++
 eclass/tests/python-utils-r1.sh | 1 -
 2 files changed, 2 insertions(+), 5 deletions(-)

diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass
index 3ea23a8..cf0e134 100644
--- a/eclass/python-utils-r1.eclass
+++ b/eclass/python-utils-r1.eclass
@@ -44,7 +44,7 @@ declare -g -r _PYTHON_ALL_IMPLS=(
python2_7
python3_3 python3_4 python3_5
pypy pypy3
-   jython2_5 jython2_7
+   jython2_7
 )
 
 # @FUNCTION: _python_impl_supported
@@ -67,7 +67,7 @@ _python_impl_supported() {
# keep in sync with _PYTHON_ALL_IMPLS!
# (not using that list because inline patterns shall be faster)
case "${impl}" in
-   python2_7|python3_[345]|jython2_[57])
+   python2_7|python3_[345]|jython2_7)
return 0
;;
pypy1_[89]|pypy2_0|python2_[56]|python3_[12])
@@ -368,8 +368,6 @@ python_export() {

PYTHON_PKG_DEP='virtual/pypy:0=';;
pypy3)

PYTHON_PKG_DEP='virtual/pypy3:0=';;
-   jython2.5)
-   
PYTHON_PKG_DEP='>=dev-java/jython-2.5.3-r2:2.5';;
jython2.7)

PYTHON_PKG_DEP='dev-java/jython:2.7';;
*)

diff --git a/eclass/tests/python-utils-r1.sh b/eclass/tests/python-utils-r1.sh
index b89acfd..922b690 100755
--- a/eclass/tests/python-utils-r1.sh
+++ b/eclass/tests/python-utils-r1.sh
@@ -175,7 +175,6 @@ test_is "_python_impl_supported pypy1_9" 1
 test_is "_python_impl_supported pypy2_0" 1
 test_is "_python_impl_supported pypy" 0
 test_is "_python_impl_supported pypy3" 0
-test_is "_python_impl_supported jython2_5" 0
 test_is "_python_impl_supported jython2_7" 0
 
 rm "${tmpfile}"



[gentoo-commits] repo/gentoo:master commit in: eclass/tests/, eclass/

2015-11-24 Thread Mike Frysinger
commit: ddd7a0bc1e06c0f7737799b784c110b7903f0a58
Author: Mike Frysinger  gentoo  org>
AuthorDate: Tue Nov 24 17:02:31 2015 +
Commit: Mike Frysinger  gentoo  org>
CommitDate: Tue Nov 24 17:03:49 2015 +
URL:https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=ddd7a0bc

multiprocessing.eclass: makeopts_loadavg: various fixes #543116

- Add support for --max-load option
- Fix default load value if not specified (999)
- Fix trailing flag consumption so we don't leave garbage behind
- Add tests!

 eclass/multiprocessing.eclass|  7 +++--
 eclass/tests/multiprocessing_makeopts_loadavg.sh | 36 
 2 files changed, 40 insertions(+), 3 deletions(-)

diff --git a/eclass/multiprocessing.eclass b/eclass/multiprocessing.eclass
index 534b35c..06e004a 100644
--- a/eclass/multiprocessing.eclass
+++ b/eclass/multiprocessing.eclass
@@ -86,9 +86,10 @@ makeopts_loadavg() {
# This assumes the first .* will be more greedy than the second .*
# since POSIX doesn't specify a non-greedy match (i.e. ".*?").
local lavg=$(echo " $* " | sed -r -n \
-   -e 
's:.*[[:space:]](-l|--load-average[=[:space:]])[[:space:]]*([0-9]+|[0-9]+\.[0-9]+)[^0-9.]*:\2:p'
 \
-   -e 's:.*[[:space:]](-l|--load-average)[[:space:]].*:999:p')
-   echo ${lavg:-1}
+   -e 
's:.*[[:space:]](-l|--(load-average|max-load)[=[:space:]])[[:space:]]*([0-9]+|[0-9]+\.[0-9]+).*:\3:p'
 \
+   -e 
's:.*[[:space:]](-l|--(load-average|max-load))[[:space:]].*:999:p')
+   # Default to 999 since the default is to not use a load limit.
+   echo ${lavg:-999}
 }
 
 # @FUNCTION: multijob_init

diff --git a/eclass/tests/multiprocessing_makeopts_loadavg.sh 
b/eclass/tests/multiprocessing_makeopts_loadavg.sh
new file mode 100755
index 000..12f9d01
--- /dev/null
+++ b/eclass/tests/multiprocessing_makeopts_loadavg.sh
@@ -0,0 +1,36 @@
+#!/bin/bash
+# Copyright 1999-2015 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+source tests-common.sh
+
+inherit multiprocessing
+
+test-makeopts_loadavg() {
+   local exp=$1; shift
+   tbegin "makeopts_loadavg($*) == ${exp}"
+   local act=$(makeopts_loadavg "$@")
+   [[ ${act} == "${exp}" ]]
+   tend $? "Got back: ${act}"
+}
+
+tests=(
+   999 "-j"
+   999 "-l"
+   999 ""
+   9 "-l9 -w"
+   9 "-l 9 -w-j4"
+   3 "-l3 -j 4 -w"
+   5 "--load-average=5"
+   6 "--load-average 6"
+   7 "-l3 --load-average 7 -w"
+   4 "-j1 -j 2 --load-average 3 --load-average=4"
+   3 " --max-load=3 -x"
+   8 " -l  8 "
+)
+for (( i = 0; i < ${#tests[@]}; i += 2 )) ; do
+   test-makeopts_loadavg "${tests[i]}" "${tests[i+1]}"
+done
+
+texit



[gentoo-commits] repo/gentoo:master commit in: eclass/tests/, eclass/

2015-11-11 Thread Michał Górny
commit: 0f076c65649b8eda6480f8c44e4b85f583cdd014
Author: Michał Górny  gentoo  org>
AuthorDate: Sun Nov  8 08:27:50 2015 +
Commit: Michał Górny  gentoo  org>
CommitDate: Wed Nov 11 10:21:33 2015 +
URL:https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=0f076c65

python-utils-r1.eclass: Support getting PYTHON_CONFIG path

 eclass/python-utils-r1.eclass   | 47 +
 eclass/tests/python-utils-r1.sh |  2 ++
 2 files changed, 49 insertions(+)

diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass
index e8de6b9..68926ab 100644
--- a/eclass/python-utils-r1.eclass
+++ b/eclass/python-utils-r1.eclass
@@ -190,6 +190,20 @@ _python_impl_supported() {
 # -lpython2.7
 # @CODE
 
+# @ECLASS-VARIABLE: PYTHON_CONFIG
+# @DEFAULT_UNSET
+# @DESCRIPTION:
+# Path to the python-config executable.
+#
+# Set and exported on request using python_export().
+# Valid only for CPython. Requires a proper build-time dependency
+# on the Python implementation and on pkg-config.
+#
+# Example value:
+# @CODE
+# /usr/bin/python2.7-config
+# @CODE
+
 # @ECLASS-VARIABLE: PYTHON_PKG_DEP
 # @DEFAULT_UNSET
 # @DESCRIPTION:
@@ -323,6 +337,22 @@ python_export() {
export PYTHON_LIBS=${val}
debug-print "${FUNCNAME}: PYTHON_LIBS = 
${PYTHON_LIBS}"
;;
+   PYTHON_CONFIG)
+   local flags val
+
+   case "${impl}" in
+   python*)
+   flags=$("${PYTHON}" -c 'import 
sysconfig; print(sysconfig.get_config_var("ABIFLAGS") or "")')
+   val=${PYTHON}${flags}-config
+   ;;
+   *)
+   die "${impl}: obtaining ${var} 
not supported"
+   ;;
+   esac
+
+   export PYTHON_CONFIG=${val}
+   debug-print "${FUNCNAME}: PYTHON_CONFIG = 
${PYTHON_CONFIG}"
+   ;;
PYTHON_PKG_DEP)
local d
case ${impl} in
@@ -443,6 +473,23 @@ python_get_LIBS() {
echo "${PYTHON_LIBS}"
 }
 
+# @FUNCTION: python_get_PYTHON_CONFIG
+# @USAGE: []
+# @DESCRIPTION:
+# Obtain and print the PYTHON_CONFIG location for the given
+# implementation. If no implementation is provided, ${EPYTHON} will be
+# used.
+#
+# Please note that this function can be used with CPython only.
+# It requires Python installed, and therefore proper build-time
+# dependencies need be added to the ebuild.
+python_get_PYTHON_CONFIG() {
+   debug-print-function ${FUNCNAME} "${@}"
+
+   python_export "${@}" PYTHON_CONFIG
+   echo "${PYTHON_CONFIG}"
+}
+
 # @FUNCTION: python_get_scriptdir
 # @USAGE: []
 # @DESCRIPTION:

diff --git a/eclass/tests/python-utils-r1.sh b/eclass/tests/python-utils-r1.sh
index 457756d..b683c51 100755
--- a/eclass/tests/python-utils-r1.sh
+++ b/eclass/tests/python-utils-r1.sh
@@ -67,6 +67,7 @@ if [[ -x /usr/bin/python2.7 ]]; then
test_var PYTHON_SITEDIR python2_7 "/usr/lib*/python2.7/site-packages"
test_var PYTHON_INCLUDEDIR python2_7 /usr/include/python2.7
test_var PYTHON_LIBPATH python2_7 "/usr/lib*/libpython2.7$(get_libname)"
+   test_var PYTHON_CONFIG python2_7 /usr/bin/python2.7-config
 fi
 test_var PYTHON_PKG_DEP python2_7 '*dev-lang/python*:2.7'
 test_var PYTHON_SCRIPTDIR python2_7 /usr/lib/python-exec/python2.7
@@ -78,6 +79,7 @@ if [[ -x /usr/bin/python3.4 ]]; then
test_var PYTHON_SITEDIR python3_4 "/usr/lib*/python3.4/site-packages"
test_var PYTHON_INCLUDEDIR python3_4 "/usr/include/python3.4${abiflags}"
test_var PYTHON_LIBPATH python3_4 
"/usr/lib*/libpython3.4${abiflags}$(get_libname)"
+   test_var PYTHON_CONFIG python3_4 "/usr/bin/python3.4${abiflags}-config"
 fi
 test_var PYTHON_PKG_DEP python3_4 '*dev-lang/python*:3.4'
 test_var PYTHON_SCRIPTDIR python3_4 /usr/lib/python-exec/python3.4