commit: 0c65bf3a8be23a1087252ab0b5c684360ac30d1b Author: Andreas K. Hüttel <dilfridge <AT> gentoo <DOT> org> AuthorDate: Fri Sep 11 15:02:28 2020 +0000 Commit: Andreas K. Hüttel <dilfridge <AT> gentoo <DOT> org> CommitDate: Fri Sep 11 15:02:28 2020 +0000 URL: https://gitweb.gentoo.org/proj/riscv.git/commit/?id=0c65bf3a
eclass: Moved to main tree Signed-off-by: Andreas K. Hüttel <dilfridge <AT> gentoo.org> eclass/multilib-build.eclass | 694 ------------------------------------------- eclass/multilib.eclass | 554 ---------------------------------- 2 files changed, 1248 deletions(-) diff --git a/eclass/multilib-build.eclass b/eclass/multilib-build.eclass deleted file mode 100644 index dc4f8a2..0000000 --- a/eclass/multilib-build.eclass +++ /dev/null @@ -1,694 +0,0 @@ -# Copyright 2013-2020 Gentoo Authors -# Distributed under the terms of the GNU General Public License v2 - -# @ECLASS: multilib-build.eclass -# @MAINTAINER: -# gx86-multilib team <multi...@gentoo.org> -# @AUTHOR: -# Author: Michał Górny <mgo...@gentoo.org> -# @SUPPORTED_EAPIS: 4 5 6 7 -# @BLURB: flags and utility functions for building multilib packages -# @DESCRIPTION: -# The multilib-build.eclass exports USE flags and utility functions -# necessary to build packages for multilib in a clean and uniform -# manner. -# -# Please note that dependency specifications for multilib-capable -# dependencies shall use the USE dependency string in ${MULTILIB_USEDEP} -# to properly request multilib enabled. - -if [[ ! ${_MULTILIB_BUILD} ]]; then - -# EAPI=4 is required for meaningful MULTILIB_USEDEP. -case ${EAPI:-0} in - 4|5|6|7) ;; - *) die "EAPI=${EAPI} is not supported" ;; -esac - -[[ ${EAPI} == [45] ]] && inherit eutils -inherit multibuild multilib - -# @ECLASS-VARIABLE: _MULTILIB_FLAGS -# @INTERNAL -# @DESCRIPTION: -# The list of multilib flags and corresponding ABI values. If the same -# flag is reused for multiple ABIs (e.g. x86 on Linux&FreeBSD), multiple -# ABIs may be separated by commas. -# -# Please contact multilib before modifying this list. This way we can -# ensure that every *preliminary* work is done and the multilib can be -# extended safely. -_MULTILIB_FLAGS=( - abi_x86_32:x86,x86_fbsd,x86_freebsd,x86_linux,x86_macos,x86_solaris - abi_x86_64:amd64,amd64_fbsd,x64_freebsd,amd64_linux,x64_macos,x64_solaris - abi_x86_x32:x32 - abi_mips_n32:n32 - abi_mips_n64:n64 - abi_mips_o32:o32 -# abi_ppc_32:ppc,ppc_aix,ppc_macos -# abi_ppc_64:ppc64 - abi_riscv_lp64d:lp64d - abi_riscv_lp64:lp64 - abi_riscv_ilp32d:ilp32d - abi_riscv_ilp32:ilp32 - abi_s390_32:s390 - abi_s390_64:s390x -) -readonly _MULTILIB_FLAGS - -# @ECLASS-VARIABLE: MULTILIB_COMPAT -# @DEFAULT_UNSET -# @DESCRIPTION: -# List of multilib ABIs supported by the ebuild. If unset, defaults to -# all ABIs supported by the eclass. -# -# This variable is intended for use in prebuilt multilib packages that -# can provide binaries only for a limited set of ABIs. If ABIs need to -# be limited due to a bug in source code, package.use.mask is to be used -# instead. Along with MULTILIB_COMPAT, KEYWORDS should contain '-*'. -# -# Note that setting this variable effectively disables support for all -# other ABIs, including other architectures. For example, specifying -# abi_x86_{32,64} disables support for MIPS as well. -# -# The value of MULTILIB_COMPAT determines the value of IUSE. If set, it -# also enables REQUIRED_USE constraints. -# -# Example use: -# @CODE -# # Upstream provides binaries for x86 & amd64 only -# MULTILIB_COMPAT=( abi_x86_{32,64} ) -# @CODE - -# @ECLASS-VARIABLE: MULTILIB_USEDEP -# @OUTPUT_VARIABLE -# @DESCRIPTION: -# The USE-dependency to be used on dependencies (libraries) needing -# to support multilib as well. -# -# Example use: -# @CODE -# RDEPEND="dev-libs/libfoo[${MULTILIB_USEDEP}] -# net-libs/libbar[ssl,${MULTILIB_USEDEP}]" -# @CODE - -# @ECLASS-VARIABLE: MULTILIB_ABI_FLAG -# @OUTPUT_VARIABLE -# @DESCRIPTION: -# The complete ABI name. Resembles the USE flag name. -# -# This is set within multilib_foreach_abi(), -# multilib_parallel_foreach_abi() and multilib-minimal sub-phase -# functions. -# -# It may be null (empty) when the build is done on ABI not controlled -# by a USE flag (e.g. on non-multilib arch or when using multilib -# portage). The build will always be done for a single ABI then. -# -# Example value: -# @CODE -# abi_x86_64 -# @CODE - -_multilib_build_set_globals() { - local flags=( "${_MULTILIB_FLAGS[@]%:*}" ) - - if [[ ${MULTILIB_COMPAT[@]} ]]; then - # Validate MULTILIB_COMPAT and filter out the flags. - local f - for f in "${MULTILIB_COMPAT[@]}"; do - if ! has "${f}" "${flags[@]}"; then - die "Invalid value in MULTILIB_COMPAT: ${f}" - fi - done - - flags=( "${MULTILIB_COMPAT[@]}" ) - - REQUIRED_USE="|| ( ${flags[*]} )" - fi - - local usedeps=${flags[@]/%/(-)?} - - IUSE=${flags[*]} - MULTILIB_USEDEP=${usedeps// /,} - readonly MULTILIB_USEDEP -} -_multilib_build_set_globals -unset -f _multilib_build_set_globals - -# @FUNCTION: multilib_get_enabled_abis -# @DESCRIPTION: -# Return the ordered list of enabled ABIs if multilib builds -# are enabled. The best (most preferred) ABI will come last. -# -# If multilib is disabled, the default ABI will be returned -# in order to enforce consistent testing with multilib code. -multilib_get_enabled_abis() { - debug-print-function ${FUNCNAME} "${@}" - - local pairs=( $(multilib_get_enabled_abi_pairs) ) - echo "${pairs[@]#*.}" -} - -# @FUNCTION: multilib_get_enabled_abi_pairs -# @DESCRIPTION: -# Return the ordered list of enabled <use-flag>.<ABI> pairs -# if multilib builds are enabled. The best (most preferred) -# ABI will come last. -# -# If multilib is disabled, the default ABI will be returned -# along with empty <use-flag>. -multilib_get_enabled_abi_pairs() { - debug-print-function ${FUNCNAME} "${@}" - - local abis=( $(get_all_abis) ) - - local abi i found - for abi in "${abis[@]}"; do - for i in "${_MULTILIB_FLAGS[@]}"; do - local m_abis=${i#*:} m_abi - local m_flag=${i%:*} - - # split on ,; we can't switch IFS for function scope because - # paludis is broken (bug #486592), and switching it locally - # for the split is more complex than cheating like this - for m_abi in ${m_abis//,/ }; do - if [[ ${m_abi} == ${abi} ]] \ - && { [[ ! "${MULTILIB_COMPAT[@]}" ]] || has "${m_flag}" "${MULTILIB_COMPAT[@]}"; } \ - && use "${m_flag}" - then - echo "${m_flag}.${abi}" - found=1 - break 2 - fi - done - done - done - - if [[ ! ${found} ]]; then - # ${ABI} can be used to override the fallback (multilib-portage), - # ${DEFAULT_ABI} is the safe fallback. - local abi=${ABI:-${DEFAULT_ABI}} - - debug-print "${FUNCNAME}: no ABIs enabled, fallback to ${abi}" - debug-print "${FUNCNAME}: ABI=${ABI}, DEFAULT_ABI=${DEFAULT_ABI}" - echo ".${abi}" - fi -} - -# @FUNCTION: _multilib_multibuild_wrapper -# @USAGE: <argv>... -# @INTERNAL -# @DESCRIPTION: -# Initialize the environment for ABI selected for multibuild. -_multilib_multibuild_wrapper() { - debug-print-function ${FUNCNAME} "${@}" - - local ABI=${MULTIBUILD_VARIANT#*.} - local -r MULTILIB_ABI_FLAG=${MULTIBUILD_VARIANT%.*} - - multilib_toolchain_setup "${ABI}" - readonly ABI - "${@}" -} - -# @FUNCTION: multilib_foreach_abi -# @USAGE: <argv>... -# @DESCRIPTION: -# If multilib support is enabled, sets the toolchain up for each -# supported ABI along with the ABI variable and correct BUILD_DIR, -# and runs the given commands with them. -# -# If multilib support is disabled, it just runs the commands. No setup -# is done. -multilib_foreach_abi() { - debug-print-function ${FUNCNAME} "${@}" - - local MULTIBUILD_VARIANTS=( $(multilib_get_enabled_abi_pairs) ) - multibuild_foreach_variant _multilib_multibuild_wrapper "${@}" -} - -# @FUNCTION: multilib_parallel_foreach_abi -# @USAGE: <argv>... -# @DESCRIPTION: -# If multilib support is enabled, sets the toolchain up for each -# supported ABI along with the ABI variable and correct BUILD_DIR, -# and runs the given commands with them. -# -# If multilib support is disabled, it just runs the commands. No setup -# is done. -# -# This function used to run multiple commands in parallel. Now it's just -# a deprecated alias to multilib_foreach_abi. -multilib_parallel_foreach_abi() { - debug-print-function ${FUNCNAME} "${@}" - - local MULTIBUILD_VARIANTS=( $(multilib_get_enabled_abi_pairs) ) - multibuild_foreach_variant _multilib_multibuild_wrapper "${@}" -} - -# @FUNCTION: multilib_for_best_abi -# @USAGE: <argv>... -# @DESCRIPTION: -# Runs the given command with setup for the 'best' (usually native) ABI. -multilib_for_best_abi() { - debug-print-function ${FUNCNAME} "${@}" - - [[ ${EAPI} == [45] ]] || die "${FUNCNAME} is banned in EAPI ${EAPI}, use multilib_is_native_abi() instead" - - eqawarn "QA warning: multilib_for_best_abi() function is deprecated and should" - eqawarn "not be used. The multilib_is_native_abi() check may be used instead." - - local MULTIBUILD_VARIANTS=( $(multilib_get_enabled_abi_pairs) ) - - multibuild_for_best_variant _multilib_multibuild_wrapper "${@}" -} - -# @FUNCTION: multilib_check_headers -# @DESCRIPTION: -# Check whether the header files are consistent between ABIs. -# -# This function needs to be called after each ABI's installation phase. -# It obtains the header file checksums and compares them with previous -# runs (if any). Dies if header files differ. -multilib_check_headers() { - _multilib_header_cksum() { - set -o pipefail - - if [[ -d ${ED%/}/usr/include ]]; then - find "${ED%/}"/usr/include -type f \ - -exec cksum {} + | sort -k2 - fi - } - - local cksum cksum_prev - local cksum_file=${T}/.multilib_header_cksum - cksum=$(_multilib_header_cksum) || die - unset -f _multilib_header_cksum - - if [[ -f ${cksum_file} ]]; then - cksum_prev=$(< "${cksum_file}") || die - - if [[ ${cksum} != ${cksum_prev} ]]; then - echo "${cksum}" > "${cksum_file}.new" || die - - eerror "Header files have changed between ABIs." - - if type -p diff &>/dev/null; then - eerror "$(diff -du "${cksum_file}" "${cksum_file}.new")" - else - eerror "Old checksums in: ${cksum_file}" - eerror "New checksums in: ${cksum_file}.new" - fi - - die "Header checksum mismatch, aborting." - fi - else - echo "${cksum}" > "${cksum_file}" || die - fi -} - -# @FUNCTION: multilib_copy_sources -# @DESCRIPTION: -# Create a single copy of the package sources for each enabled ABI. -# -# The sources are always copied from initial BUILD_DIR (or S if unset) -# to ABI-specific build directory matching BUILD_DIR used by -# multilib_foreach_abi(). -multilib_copy_sources() { - debug-print-function ${FUNCNAME} "${@}" - - local MULTIBUILD_VARIANTS=( $(multilib_get_enabled_abi_pairs) ) - multibuild_copy_sources -} - -# @ECLASS-VARIABLE: MULTILIB_WRAPPED_HEADERS -# @DEFAULT_UNSET -# @DESCRIPTION: -# A list of headers to wrap for multilib support. The listed headers -# will be moved to a non-standard location and replaced with a file -# including them conditionally to current ABI. -# -# This variable has to be a bash array. Paths shall be relative to -# installation root (${ED}), and name regular files. Recursive wrapping -# is not supported. -# -# Please note that header wrapping is *discouraged*. It is preferred to -# install all headers in a subdirectory of libdir and use pkg-config to -# locate the headers. Some C preprocessors will not work with wrapped -# headers. -# -# Example: -# @CODE -# MULTILIB_WRAPPED_HEADERS=( -# /usr/include/foobar/config.h -# ) -# @CODE - -# @ECLASS-VARIABLE: MULTILIB_CHOST_TOOLS -# @DEFAULT_UNSET -# @DESCRIPTION: -# A list of tool executables to preserve for each multilib ABI. -# The listed executables will be renamed to ${CHOST}-${basename}, -# and the native variant will be symlinked to the generic name. -# -# This variable has to be a bash array. Paths shall be relative to -# installation root (${ED}), and name regular files or symbolic -# links to regular files. Recursive wrapping is not supported. -# -# If symbolic link is passed, both symlink path and symlink target -# will be changed. As a result, the symlink target is expected -# to be wrapped as well (either by listing in MULTILIB_CHOST_TOOLS -# or externally). -# -# Please note that tool wrapping is *discouraged*. It is preferred to -# install pkg-config files for each ABI, and require reverse -# dependencies to use that. -# -# Packages that search for tools properly (e.g. using AC_PATH_TOOL -# macro) will find the wrapper executables automatically. Other packages -# will need explicit override of tool paths. -# -# Example: -# @CODE -# MULTILIB_CHOST_TOOLS=( -# /usr/bin/foo-config -# ) -# @CODE - -# @FUNCTION: multilib_prepare_wrappers -# @USAGE: [<install-root>] -# @DESCRIPTION: -# Perform the preparation of all kinds of wrappers for the current ABI. -# This function shall be called once per each ABI, after installing -# the files to be wrapped. -# -# Takes an optional custom <install-root> from which files will be -# used. If no root is specified, uses ${ED}. -# -# The files to be wrapped are specified using separate variables, -# e.g. MULTILIB_WRAPPED_HEADERS. Those variables shall not be changed -# between the successive calls to multilib_prepare_wrappers -# and multilib_install_wrappers. -# -# After all wrappers are prepared, multilib_install_wrappers shall -# be called to commit them to the installation tree. -multilib_prepare_wrappers() { - debug-print-function ${FUNCNAME} "${@}" - - [[ ${#} -le 1 ]] || die "${FUNCNAME}: too many arguments" - - local root=${1:-${ED%/}} - local f - - if [[ ${COMPLETE_MULTILIB} == yes ]]; then - # symlink '${CHOST}-foo -> foo' to support abi-wrapper while - # keeping ${CHOST}-foo calls correct. - - for f in "${MULTILIB_CHOST_TOOLS[@]}"; do - # drop leading slash if it's there - f=${f#/} - - local dir=${f%/*} - local fn=${f##*/} - - ln -s "${fn}" "${root}/${dir}/${CHOST}-${fn}" || die - done - - return - fi - - for f in "${MULTILIB_CHOST_TOOLS[@]}"; do - # drop leading slash if it's there - f=${f#/} - - local dir=${f%/*} - local fn=${f##*/} - - if [[ -L ${root}/${f} ]]; then - # rewrite the symlink target - local target - target=$(readlink "${root}/${f}") || die - local target_dir target_fn=${target##*/} - - [[ ${target} == */* ]] && target_dir=${target%/*} - - ln -f -s "${target_dir+${target_dir}/}${CHOST}-${target_fn}" \ - "${root}/${f}" || die - fi - - mv "${root}/${f}" "${root}/${dir}/${CHOST}-${fn}" || die - - # symlink the native one back - if multilib_is_native_abi; then - ln -s "${CHOST}-${fn}" "${root}/${f}" || die - fi - done - - if [[ ${MULTILIB_WRAPPED_HEADERS[@]} ]]; then - # If abi_flag is unset, then header wrapping is unsupported on - # this ABI. This means the arch doesn't support multilib at all - # -- in this case, the headers are not wrapped and everything - # works as expected. - - if [[ ${MULTILIB_ABI_FLAG} ]]; then - for f in "${MULTILIB_WRAPPED_HEADERS[@]}"; do - # drop leading slash if it's there - f=${f#/} - - if [[ ${f} != usr/include/* ]]; then - die "Wrapping headers outside of /usr/include is not supported at the moment." - fi - # and then usr/include - f=${f#usr/include} - - local dir=${f%/*} - - # Some ABIs may have install less files than others. - if [[ -f ${root}/usr/include${f} ]]; then - local wrapper=${ED%/}/tmp/multilib-include${f} - - if [[ ! -f ${ED%/}/tmp/multilib-include${f} ]]; then - dodir "/tmp/multilib-include${dir}" - # a generic template - cat > "${wrapper}" <<_EOF_ || die -/* This file is auto-generated by multilib-build.eclass - * as a multilib-friendly wrapper. For the original content, - * please see the files that are #included below. - */ - -#if defined(__x86_64__) /* amd64 */ -# if defined(__ILP32__) /* x32 ABI */ -# error "abi_x86_x32 not supported by the package." -# else /* 64-bit ABI */ -# error "abi_x86_64 not supported by the package." -# endif -#elif defined(__i386__) /* plain x86 */ -# error "abi_x86_32 not supported by the package." -#elif defined(__mips__) -# if(_MIPS_SIM == _ABIN32) /* n32 */ -# error "abi_mips_n32 not supported by the package." -# elif(_MIPS_SIM == _ABI64) /* n64 */ -# error "abi_mips_n64 not supported by the package." -# elif(_MIPS_SIM == _ABIO32) /* o32 */ -# error "abi_mips_o32 not supported by the package." -# endif -#elif defined(__riscv) -# if (__WORDSIZE == 64) && defined(__riscv_float_abi_double) -# error "abi_riscv_lp64d not supported by the package." -# elif (__WORDSIZE == 64) && defined(__riscv_float_abi_single) -# error "abi_riscv_lp64f not supported by the package." -# elif (__WORDSIZE == 64) -# error "abi_riscv_lp64 not supported by the package." -# elif (__WORDSIZE == 32) && defined(__riscv_float_abi_double) -# error "abi_riscv_ilp32d not supported by the package." -# elif (__WORDSIZE == 32) && defined(__riscv_float_abi_single) -# error "abi_riscv_ilp32f not supported by the package." -# else -# error "abi_riscv_ilp32 not supported by the package." -# endif -#elif defined(__sparc__) -# if defined(__arch64__) -# error "abi_sparc_64 not supported by the package." -# else -# error "abi_sparc_32 not supported by the package." -# endif -#elif defined(__s390__) -# if defined(__s390x__) -# error "abi_s390_64 not supported by the package." -# else -# error "abi_s390_32 not supported by the package." -# endif -#elif defined(__powerpc__) || defined(__ppc__) -# if defined(__powerpc64__) || defined(__ppc64__) -# error "abi_ppc_64 not supported by the package." -# else -# error "abi_ppc_32 not supported by the package." -# endif -#elif defined(SWIG) /* https://sourceforge.net/p/swig/bugs/799/ */ -# error "Native ABI not supported by the package." -#else -# error "No ABI matched, please report a bug to bugs.gentoo.org" -#endif -_EOF_ - fi - - if ! grep -q "${MULTILIB_ABI_FLAG} " "${wrapper}" - then - die "Flag ${MULTILIB_ABI_FLAG} not listed in wrapper template. Please report a bug to https://bugs.gentoo.org." - fi - - # $CHOST shall be set by multilib_toolchain_setup - dodir "/tmp/multilib-include/${CHOST}${dir}" - mv "${root}/usr/include${f}" "${ED%/}/tmp/multilib-include/${CHOST}${dir}/" || die - - # Note: match a space afterwards to avoid collision potential. - sed -e "/${MULTILIB_ABI_FLAG} /s&error.*&include <${CHOST}${f}>&" \ - -i "${wrapper}" || die - - # Needed for swig. - if multilib_is_native_abi; then - sed -e "/Native ABI/s&error.*&include <${CHOST}${f}>&" \ - -i "${wrapper}" || die - fi - fi - done - fi - fi -} - -# @FUNCTION: multilib_install_wrappers -# @USAGE: [<install-root>] -# @DESCRIPTION: -# Install the previously-prepared wrappers. This function shall -# be called once, after all wrappers were prepared. -# -# Takes an optional custom <install-root> to which the wrappers will be -# installed. If no root is specified, uses ${ED}. There is no need to -# use the same root as when preparing the wrappers. -# -# The files to be wrapped are specified using separate variables, -# e.g. MULTILIB_WRAPPED_HEADERS. Those variables shall not be changed -# between the calls to multilib_prepare_wrappers -# and multilib_install_wrappers. -multilib_install_wrappers() { - debug-print-function ${FUNCNAME} "${@}" - - [[ ${#} -le 1 ]] || die "${FUNCNAME}: too many arguments" - - [[ ${COMPLETE_MULTILIB} == yes ]] && return - - local root=${1:-${ED}} - - if [[ -d ${ED%/}/tmp/multilib-include ]]; then - multibuild_merge_root \ - "${ED%/}"/tmp/multilib-include "${root}"/usr/include - # it can fail if something else uses /tmp - rmdir "${ED%/}"/tmp &>/dev/null - fi -} - -# @FUNCTION: multilib_is_native_abi -# @DESCRIPTION: -# Determine whether the currently built ABI is the profile native. -# Return true status (0) if that is true, otherwise false (1). -multilib_is_native_abi() { - debug-print-function ${FUNCNAME} "${@}" - - [[ ${#} -eq 0 ]] || die "${FUNCNAME}: too many arguments" - - [[ ${COMPLETE_MULTILIB} == yes || ${ABI} == ${DEFAULT_ABI} ]] -} - -# @FUNCTION: multilib_build_binaries -# @DESCRIPTION: -# Deprecated synonym for multilib_is_native_abi -multilib_build_binaries() { - debug-print-function ${FUNCNAME} "${@}" - - [[ ${EAPI} == [45] ]] || die "${FUNCNAME} is banned in EAPI ${EAPI}, use multilib_is_native_abi() instead" - - eqawarn "QA warning: multilib_build_binaries is deprecated. Please use the equivalent" - eqawarn "multilib_is_native_abi function instead." - - multilib_is_native_abi "${@}" -} - -# @FUNCTION: multilib_native_use_with -# @USAGE: <flag> [<opt-name> [<opt-value>]] -# @DESCRIPTION: -# Output --with configure option alike use_with if USE <flag> is enabled -# and executables are being built (multilib_is_native_abi is true). -# Otherwise, outputs --without configure option. Arguments are the same -# as for use_with in the EAPI. -multilib_native_use_with() { - if multilib_is_native_abi; then - use_with "${@}" - else - echo "--without-${2:-${1}}" - fi -} - -# @FUNCTION: multilib_native_use_enable -# @USAGE: <flag> [<opt-name> [<opt-value>]] -# @DESCRIPTION: -# Output --enable configure option alike use_enable if USE <flag> -# is enabled and executables are being built (multilib_is_native_abi -# is true). Otherwise, outputs --disable configure option. Arguments are -# the same as for use_enable in the EAPI. -multilib_native_use_enable() { - if multilib_is_native_abi; then - use_enable "${@}" - else - echo "--disable-${2:-${1}}" - fi -} - -# @FUNCTION: multilib_native_enable -# @USAGE: <opt-name> [<opt-value>] -# @DESCRIPTION: -# Output --enable configure option if executables are being built -# (multilib_is_native_abi is true). Otherwise, output --disable configure -# option. -multilib_native_enable() { - if multilib_is_native_abi; then - echo "--enable-${1}${2+=${2}}" - else - echo "--disable-${1}" - fi -} - -# @FUNCTION: multilib_native_with -# @USAGE: <opt-name> [<opt-value>] -# @DESCRIPTION: -# Output --with configure option if executables are being built -# (multilib_is_native_abi is true). Otherwise, output --without configure -# option. -multilib_native_with() { - if multilib_is_native_abi; then - echo "--with-${1}${2+=${2}}" - else - echo "--without-${1}" - fi -} - -# @FUNCTION: multilib_native_usex -# @USAGE: <flag> [<true1> [<false1> [<true2> [<false2>]]]] -# @DESCRIPTION: -# Output the concatenation of <true1> (or 'yes' if unspecified) -# and <true2> if USE <flag> is enabled and executables are being built -# (multilib_is_native_abi is true). Otherwise, output the concatenation -# of <false1> (or 'no' if unspecified) and <false2>. Arguments -# are the same as for usex in the EAPI. -# -# Note: in EAPI 4 you need to inherit eutils to use this function. -multilib_native_usex() { - if multilib_is_native_abi; then - usex "${@}" - else - echo "${3-no}${5}" - fi -} - -_MULTILIB_BUILD=1 -fi diff --git a/eclass/multilib.eclass b/eclass/multilib.eclass deleted file mode 100644 index 9c7042f..0000000 --- a/eclass/multilib.eclass +++ /dev/null @@ -1,554 +0,0 @@ -# Copyright 1999-2020 Gentoo Authors -# Distributed under the terms of the GNU General Public License v2 - -# @ECLASS: multilib.eclass -# @MAINTAINER: -# am...@gentoo.org -# toolch...@gentoo.org -# @BLURB: This eclass is for all functions pertaining to handling multilib configurations. -# @DESCRIPTION: -# This eclass is for all functions pertaining to handling multilib configurations. - -if [[ -z ${_MULTILIB_ECLASS} ]]; then -_MULTILIB_ECLASS=1 - -inherit toolchain-funcs - -# Defaults: -export MULTILIB_ABIS=${MULTILIB_ABIS:-"default"} -export DEFAULT_ABI=${DEFAULT_ABI:-"default"} -export CFLAGS_default -export LDFLAGS_default -export CHOST_default=${CHOST_default:-${CHOST}} -export CTARGET_default=${CTARGET_default:-${CTARGET:-${CHOST_default}}} -export LIBDIR_default=${CONF_LIBDIR:-"lib"} -export KERNEL_ABI=${KERNEL_ABI:-${DEFAULT_ABI}} - -# @FUNCTION: has_multilib_profile -# @DESCRIPTION: -# Return true if the current profile is a multilib profile and lists more than -# one abi in ${MULTILIB_ABIS}. When has_multilib_profile returns true, that -# profile should enable the 'multilib' use flag. This is so you can DEPEND on -# a package only for multilib or not multilib. -has_multilib_profile() { - [ -n "${MULTILIB_ABIS}" -a "${MULTILIB_ABIS}" != "${MULTILIB_ABIS/ /}" ] -} - -# @FUNCTION: get_libdir -# @RETURN: the libdir for the selected ABI -# @DESCRIPTION: -# This function simply returns the desired lib directory. With portage -# 2.0.51, we now have support for installing libraries to lib32/lib64 -# to accomidate the needs of multilib systems. It's no longer a good idea -# to assume all libraries will end up in lib. Replace any (sane) instances -# where lib is named directly with $(get_libdir) if possible. -# -# Jeremy Huddleston <eradica...@gentoo.org> (23 Dec 2004): -# Added support for ${ABI} and ${DEFAULT_ABI}. If they're both not set, -# fall back on old behavior. Any profile that has these set should also -# depend on a newer version of portage (not yet released) which uses these -# over CONF_LIBDIR in econf, dolib, etc... -if has "${EAPI:-0}" 0 1 2 3 4 5; then - get_libdir() { - local CONF_LIBDIR - if [ -n "${CONF_LIBDIR_OVERRIDE}" ] ; then - # if there is an override, we want to use that... always. - echo ${CONF_LIBDIR_OVERRIDE} - else - get_abi_LIBDIR - fi - } -fi - -# @FUNCTION: get_abi_var -# @USAGE: <VAR> [ABI] -# @RETURN: returns the value of ${<VAR>_<ABI>} which should be set in make.defaults -# @INTERNAL -# @DESCRIPTION: -# ex: -# CFLAGS=$(get_abi_var CFLAGS sparc32) # CFLAGS=-m32 -# -# Note that the prefered method is to set CC="$(tc-getCC) $(get_abi_CFLAGS)" -# This will hopefully be added to portage soon... -# -# If <ABI> is not specified, ${ABI} is used. -# If <ABI> is not specified and ${ABI} is not defined, ${DEFAULT_ABI} is used. -# If <ABI> is not specified and ${ABI} and ${DEFAULT_ABI} are not defined, we return an empty string. -get_abi_var() { - local flag=$1 - local abi=${2:-${ABI:-${DEFAULT_ABI:-default}}} - local var="${flag}_${abi}" - echo ${!var} -} - -# @FUNCTION: get_abi_CFLAGS -# @USAGE: [ABI] -# @DESCRIPTION: -# Alias for 'get_abi_var CFLAGS' -get_abi_CFLAGS() { get_abi_var CFLAGS "$@"; } - -# @FUNCTION: get_abi_LDFLAGS -# @USAGE: [ABI] -# @DESCRIPTION: -# Alias for 'get_abi_var LDFLAGS' -get_abi_LDFLAGS() { get_abi_var LDFLAGS "$@"; } - -# @FUNCTION: get_abi_CHOST -# @USAGE: [ABI] -# @DESCRIPTION: -# Alias for 'get_abi_var CHOST' -get_abi_CHOST() { get_abi_var CHOST "$@"; } - -# @FUNCTION: get_abi_CTARGET -# @USAGE: [ABI] -# @DESCRIPTION: -# Alias for 'get_abi_var CTARGET' -get_abi_CTARGET() { get_abi_var CTARGET "$@"; } - -# @FUNCTION: get_abi_FAKE_TARGETS -# @USAGE: [ABI] -# @DESCRIPTION: -# Alias for 'get_abi_var FAKE_TARGETS' -get_abi_FAKE_TARGETS() { get_abi_var FAKE_TARGETS "$@"; } - -# @FUNCTION: get_abi_LIBDIR -# @USAGE: [ABI] -# @DESCRIPTION: -# Alias for 'get_abi_var LIBDIR' -get_abi_LIBDIR() { get_abi_var LIBDIR "$@"; } - -# @FUNCTION: get_install_abis -# @DESCRIPTION: -# Return a list of the ABIs we want to install for with -# the last one in the list being the default. -get_install_abis() { - local x order="" - - if [[ -z ${MULTILIB_ABIS} ]] ; then - echo "default" - return 0 - fi - - if [[ ${EMULTILIB_PKG} == "true" ]] ; then - for x in ${MULTILIB_ABIS} ; do - if [[ ${x} != "${DEFAULT_ABI}" ]] ; then - has ${x} ${ABI_DENY} || order="${order} ${x}" - fi - done - has ${DEFAULT_ABI} ${ABI_DENY} || order="${order} ${DEFAULT_ABI}" - - if [[ -n ${ABI_ALLOW} ]] ; then - local ordera="" - for x in ${order} ; do - if has ${x} ${ABI_ALLOW} ; then - ordera="${ordera} ${x}" - fi - done - order=${ordera} - fi - else - order=${DEFAULT_ABI} - fi - - if [[ -z ${order} ]] ; then - die "The ABI list is empty. Are you using a proper multilib profile? Perhaps your USE flags or MULTILIB_ABIS are too restrictive for this package." - fi - - echo ${order} - return 0 -} - -# @FUNCTION: get_all_abis -# @DESCRIPTION: -# Return a list of the ABIs supported by this profile. -# the last one in the list being the default. -get_all_abis() { - local x order="" mvar dvar - - mvar="MULTILIB_ABIS" - dvar="DEFAULT_ABI" - if [[ -n $1 ]] ; then - mvar="$1_${mvar}" - dvar="$1_${dvar}" - fi - - if [[ -z ${!mvar} ]] ; then - echo "default" - return 0 - fi - - for x in ${!mvar}; do - if [[ ${x} != ${!dvar} ]] ; then - order="${order:+${order} }${x}" - fi - done - order="${order:+${order} }${!dvar}" - - echo ${order} - return 0 -} - -# @FUNCTION: get_all_libdirs -# @DESCRIPTION: -# Returns a list of all the libdirs used by this profile. This includes -# those that might not be touched by the current ebuild and always includes -# "lib". -get_all_libdirs() { - local libdirs abi - - for abi in ${MULTILIB_ABIS}; do - libdirs+=" $(get_abi_LIBDIR ${abi})" - done - [[ " ${libdirs} " != *" lib "* ]] && libdirs+=" lib" - - echo "${libdirs}" -} - -# @FUNCTION: is_final_abi -# @DESCRIPTION: -# Return true if ${ABI} is the last ABI on our list (or if we're not -# using the new multilib configuration. This can be used to determine -# if we're in the last (or only) run through src_{unpack,compile,install} -is_final_abi() { - has_multilib_profile || return 0 - set -- $(get_install_abis) - local LAST_ABI=$# - [[ ${!LAST_ABI} == ${ABI} ]] -} - -# @FUNCTION: number_abis -# @DESCRIPTION: -# echo the number of ABIs we will be installing for -number_abis() { - set -- `get_install_abis` - echo $# -} - -# @FUNCTION: get_exeext -# @DESCRIPTION: -# Returns standard executable program suffix (null, .exe, etc.) -# for the current platform identified by CHOST. -# -# Example: -# get_exeext -# Returns: null string (almost everywhere) || .exe (mingw*) || ... -get_exeext() { - case ${CHOST} in - *-cygwin*|mingw*|*-mingw*) echo ".exe";; - esac -} - -# @FUNCTION: get_libname -# @USAGE: [version] -# @DESCRIPTION: -# Returns libname with proper suffix {.so,.dylib,.dll,etc} and optionally -# supplied version for the current platform identified by CHOST. -# -# Example: -# get_libname ${PV} -# Returns: .so.${PV} (ELF) || .${PV}.dylib (MACH) || ... -get_libname() { - local libname - local ver=$1 - case ${CHOST} in - *-cygwin*) libname="dll.a";; # import lib - mingw*|*-mingw*) libname="dll";; - *-darwin*) libname="dylib";; - *-mint*) libname="irrelevant";; - hppa*-hpux*) libname="sl";; - *) libname="so";; - esac - - if [[ -z $* ]] ; then - echo ".${libname}" - else - for ver in "$@" ; do - case ${CHOST} in - *-cygwin*) echo ".${ver}.${libname}";; - *-darwin*) echo ".${ver}.${libname}";; - *-mint*) echo ".${libname}";; - *) echo ".${libname}.${ver}";; - esac - done - fi -} - -# @FUNCTION: get_modname -# @USAGE: -# @DESCRIPTION: -# Returns modulename with proper suffix {.so,.bundle,etc} for the current -# platform identified by CHOST. -# -# Example: -# libfoo$(get_modname) -# Returns: libfoo.so (ELF) || libfoo.bundle (MACH) || ... -get_modname() { - local modname - local ver=$1 - case ${CHOST} in - *-darwin*) modname="bundle";; - *) modname="so";; - esac - - echo ".${modname}" -} - -# This is for the toolchain to setup profile variables when pulling in -# a crosscompiler (and thus they aren't set in the profile). -multilib_env() { - local CTARGET=${1:-${CTARGET}} - local cpu=${CTARGET%%*-} - - if [[ ${CTARGET} = *-musl* ]]; then - # musl has no multilib support and can run only in 'lib': - # - https://bugs.gentoo.org/675954 - # - https://gcc.gnu.org/PR90077 - # - https://github.com/gentoo/musl/issues/245 - : ${MULTILIB_ABIS=default} - : ${DEFAULT_ABI=default} - export MULTILIB_ABIS DEFAULT_ABI - return - fi - - case ${cpu} in - aarch64*) - # Not possible to do multilib with aarch64 and a single toolchain. - export CFLAGS_arm=${CFLAGS_arm-} - case ${cpu} in - aarch64*be) export CHOST_arm="armv8b-${CTARGET#*-}";; - *) export CHOST_arm="armv8l-${CTARGET#*-}";; - esac - CHOST_arm=${CHOST_arm/%-gnu/-gnueabi} - export CTARGET_arm=${CHOST_arm} - export LIBDIR_arm="lib" - - export CFLAGS_arm64=${CFLAGS_arm64-} - export CHOST_arm64=${CTARGET} - export CTARGET_arm64=${CHOST_arm64} - export LIBDIR_arm64="lib64" - - : ${MULTILIB_ABIS=arm64} - : ${DEFAULT_ABI=arm64} - ;; - x86_64*) - export CFLAGS_x86=${CFLAGS_x86--m32} - export CHOST_x86=${CTARGET/x86_64/i686} - CHOST_x86=${CHOST_x86/%-gnux32/-gnu} - export CTARGET_x86=${CHOST_x86} - if [[ ${SYMLINK_LIB} == "yes" ]] ; then - export LIBDIR_x86="lib32" - else - export LIBDIR_x86="lib" - fi - - export CFLAGS_amd64=${CFLAGS_amd64--m64} - export CHOST_amd64=${CTARGET/%-gnux32/-gnu} - export CTARGET_amd64=${CHOST_amd64} - export LIBDIR_amd64="lib64" - - export CFLAGS_x32=${CFLAGS_x32--mx32} - export CHOST_x32=${CTARGET/%-gnu/-gnux32} - export CTARGET_x32=${CHOST_x32} - export LIBDIR_x32="libx32" - - case ${CTARGET} in - *-gnux32) - : ${MULTILIB_ABIS=x32 amd64 x86} - : ${DEFAULT_ABI=x32} - ;; - *) - : ${MULTILIB_ABIS=amd64 x86} - : ${DEFAULT_ABI=amd64} - ;; - esac - ;; - mips64*|mipsisa64*) - export CFLAGS_o32=${CFLAGS_o32--mabi=32} - export CHOST_o32=${CTARGET/mips64/mips} - export CHOST_o32=${CHOST_o32/mipsisa64/mipsisa32} - export CTARGET_o32=${CHOST_o32} - export LIBDIR_o32="lib" - - export CFLAGS_n32=${CFLAGS_n32--mabi=n32} - export CHOST_n32=${CTARGET} - export CTARGET_n32=${CHOST_n32} - export LIBDIR_n32="lib32" - - export CFLAGS_n64=${CFLAGS_n64--mabi=64} - export CHOST_n64=${CTARGET} - export CTARGET_n64=${CHOST_n64} - export LIBDIR_n64="lib64" - - : ${MULTILIB_ABIS=n64 n32 o32} - : ${DEFAULT_ABI=n32} - ;; - powerpc64*) - export CFLAGS_ppc=${CFLAGS_ppc--m32} - export CHOST_ppc=${CTARGET/powerpc64/powerpc} - export CTARGET_ppc=${CHOST_ppc} - export LIBDIR_ppc="lib" - - export CFLAGS_ppc64=${CFLAGS_ppc64--m64} - export CHOST_ppc64=${CTARGET} - export CTARGET_ppc64=${CHOST_ppc64} - export LIBDIR_ppc64="lib64" - - : ${MULTILIB_ABIS=ppc64 ppc} - : ${DEFAULT_ABI=ppc64} - ;; - riscv64*) - export CFLAGS_lp64d=${CFLAGS_lp64d--mabi=lp64d -march=rv64imafdc} - export CHOST_lp64d=${CTARGET} - export CTARGET_lp64d=${CTARGET} - export LIBDIR_lp64d="lib64/lp64d" - - export CFLAGS_lp64=${CFLAGS_lp64--mabi=lp64 -march=rv64imac} - export CHOST_lp64=${CTARGET} - export CTARGET_lp64=${CTARGET} - export LIBDIR_lp64="lib64/lp64" - - export CFLAGS_ilp32d=${CFLAGS_ilp32d--mabi=ilp32d -march=rv32imafdc} - export CHOST_ilp32d=${CTARGET/riscv64/riscv32} - export CTARGET_ilp32d=${CTARGET/riscv64/riscv32} - export LIBDIR_ilp32d="lib32/ilp32d" - - export CFLAGS_ilp32=${CFLAGS_ilp32--mabi=ilp32 -march=rv32imac} - export CHOST_ilp32=${CTARGET/riscv64/riscv32} - export CTARGET_ilp32=${CTARGET/riscv64/riscv32} - export LIBDIR_ilp32="lib32/ilp32" - - : ${MULTILIB_ABIS=lp64d lp64 ilp32d ilp32} - : ${DEFAULT_ABI=lp64d} - ;; - riscv32*) - export CFLAGS_ilp32d=${CFLAGS_ilp32d--mabi=ilp32d} - export CHOST_ilp32d=${CTARGET} - export CTARGET_ilp32d=${CTARGET} - export LIBDIR_ilp32d="lib32/ilp32d" - - export CFLAGS_ilp32=${CFLAGS_ilp32--mabi=ilp32 -march=rv32imac} - export CHOST_ilp32=${CTARGET} - export CTARGET_ilp32=${CTARGET} - export LIBDIR_ilp32="lib32/ilp32" - - : ${MULTILIB_ABIS=ilp32d ilp32} - : ${DEFAULT_ABI=ilp32d} - ;; - s390x*) - export CFLAGS_s390=${CFLAGS_s390--m31} # the 31 is not a typo - export CHOST_s390=${CTARGET/s390x/s390} - export CTARGET_s390=${CHOST_s390} - export LIBDIR_s390="lib" - - export CFLAGS_s390x=${CFLAGS_s390x--m64} - export CHOST_s390x=${CTARGET} - export CTARGET_s390x=${CHOST_s390x} - export LIBDIR_s390x="lib64" - - : ${MULTILIB_ABIS=s390x s390} - : ${DEFAULT_ABI=s390x} - ;; - sparc64*) - export CFLAGS_sparc32=${CFLAGS_sparc32--m32} - export CHOST_sparc32=${CTARGET/sparc64/sparc} - export CTARGET_sparc32=${CHOST_sparc32} - export LIBDIR_sparc32="lib" - - export CFLAGS_sparc64=${CFLAGS_sparc64--m64} - export CHOST_sparc64=${CTARGET} - export CTARGET_sparc64=${CHOST_sparc64} - export LIBDIR_sparc64="lib64" - - : ${MULTILIB_ABIS=sparc64 sparc32} - : ${DEFAULT_ABI=sparc64} - ;; - *) - : ${MULTILIB_ABIS=default} - : ${DEFAULT_ABI=default} - ;; - esac - - export MULTILIB_ABIS DEFAULT_ABI -} - -# @FUNCTION: multilib_toolchain_setup -# @DESCRIPTION: -# Hide multilib details here for packages which are forced to be compiled for a -# specific ABI when run on another ABI (like x86-specific packages on amd64) -multilib_toolchain_setup() { - local v vv - - export ABI=$1 - - local save_restore_variables=( - CBUILD - CHOST - AR - CC - CXX - F77 - FC - LD - NM - OBJDUMP - PKG_CONFIG - RANLIB - READELF - STRINGS - STRIP - PKG_CONFIG_LIBDIR - PKG_CONFIG_PATH - PKG_CONFIG_SYSTEM_LIBRARY_PATH - ) - - # First restore any saved state we have laying around. - if [[ ${_DEFAULT_ABI_SAVED} == "true" ]] ; then - for v in "${save_restore_variables[@]}" ; do - vv="_abi_saved_${v}" - [[ ${!vv+set} == "set" ]] && export ${v}="${!vv}" || unset ${v} - unset ${vv} - done - unset _DEFAULT_ABI_SAVED - fi - - if [[ ${ABI} != ${DEFAULT_ABI} ]] ; then - # Back that multilib-ass up so we can restore it later - for v in "${save_restore_variables[@]}" ; do - vv="_abi_saved_${v}" - [[ ${!v+set} == "set" ]] && export ${vv}="${!v}" || unset ${vv} - done - export _DEFAULT_ABI_SAVED="true" - - # Set CBUILD only if not cross-compiling. - if [[ ${CBUILD} == "${CHOST}" ]]; then - export CBUILD=$(get_abi_CHOST $1) - fi - - # Set the CHOST native first so that we pick up the native - # toolchain and not a cross-compiler by accident #202811. - # - # Make sure ${save_restore_variables[@]} list matches below. - export CHOST=$(get_abi_CHOST ${DEFAULT_ABI}) - - export AR="$(tc-getAR)" # Avoid 'ar', use '${CHOST}-ar' - export CC="$(tc-getCC) $(get_abi_CFLAGS)" - export CXX="$(tc-getCXX) $(get_abi_CFLAGS)" - export F77="$(tc-getF77) $(get_abi_CFLAGS)" - export FC="$(tc-getFC) $(get_abi_CFLAGS)" - export LD="$(tc-getLD) $(get_abi_LDFLAGS)" - export NM="$(tc-getNM)" # Avoid 'nm', use '${CHOST}-nm' - export OBJDUMP="$(tc-getOBJDUMP)" # Avoid 'objdump', use '${CHOST}-objdump' - export PKG_CONFIG="$(tc-getPKG_CONFIG)" - export RANLIB="$(tc-getRANLIB)" # Avoid 'ranlib', use '${CHOST}-ranlib' - export READELF="$(tc-getREADELF)" # Avoid 'readelf', use '${CHOST}-readelf' - export STRINGS="$(tc-getSTRINGS)" # Avoid 'strings', use '${CHOST}-strings' - export STRIP="$(tc-getSTRIP)" # Avoid 'strip', use '${CHOST}-strip' - - export CHOST=$(get_abi_CHOST $1) - export PKG_CONFIG_LIBDIR=${EPREFIX}/usr/$(get_libdir)/pkgconfig - export PKG_CONFIG_PATH=${EPREFIX}/usr/share/pkgconfig - export PKG_CONFIG_SYSTEM_LIBRARY_PATH=${EPREFIX}/usr/$(get_libdir) - fi -} - -fi