diff options
Diffstat (limited to 'eclass')
43 files changed, 1422 insertions, 721 deletions
diff --git a/eclass/Manifest.gz b/eclass/Manifest.gz Binary files differindex 87dc65282eb3..a9608fe7e379 100644 --- a/eclass/Manifest.gz +++ b/eclass/Manifest.gz diff --git a/eclass/aspell-dict-r1.eclass b/eclass/aspell-dict-r1.eclass index c95f7c056354..4d2df961993b 100644 --- a/eclass/aspell-dict-r1.eclass +++ b/eclass/aspell-dict-r1.eclass @@ -63,6 +63,7 @@ SLOT="0" RDEPEND="app-text/aspell" DEPEND="${RDEPEND}" +BDEPEND="sys-apps/which" _ASPELL_MAJOR_VERSION=${ASPELL_VERSION:-6} [[ ${_ASPELL_MAJOR_VERSION} != [56] ]] && die "Unsupported ASPELL_VERSION=${ASPELL_VERSION}" diff --git a/eclass/autotools.eclass b/eclass/autotools.eclass index b8eeb55fd8f2..d6c5b7f0ec0d 100644 --- a/eclass/autotools.eclass +++ b/eclass/autotools.eclass @@ -283,7 +283,7 @@ _at_uses_pkg() { for macro ; do args+=( -e "^[[:space:]]*${macro}\>" ) done - egrep -q "${args[@]}" configure.?? + grep -E -q "${args[@]}" configure.?? fi } _at_uses_autoheader() { _at_uses_pkg A{C,M}_CONFIG_HEADER{S,}; } diff --git a/eclass/check-reqs.eclass b/eclass/check-reqs.eclass index 5a754c54a303..ddf0a47775ae 100644 --- a/eclass/check-reqs.eclass +++ b/eclass/check-reqs.eclass @@ -1,4 +1,4 @@ -# Copyright 2004-2021 Gentoo Authors +# Copyright 2004-2022 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 # @ECLASS: check-reqs.eclass @@ -76,6 +76,12 @@ _CHECK_REQS_ECLASS=1 # This is a user flag and should under _no circumstances_ be set in the ebuild. [[ -n ${I_KNOW_WHAT_I_AM_DOING} ]] && CHECKREQS_DONOTHING=1 +# @ECLASS_VARIABLE: CHECKREQS_FAILED +# @INTERNAL +# @DESCRIPTION: +# If set the checks failed and eclass should abort the build. +# Internal, do not set yourself. + # @FUNCTION: check-reqs_pkg_setup # @DESCRIPTION: # Exported function running the resources checks in pkg_setup phase. @@ -457,11 +463,6 @@ _check-reqs_unsatisfied() { [[ ${EBUILD_PHASE} == "pretend" && -z ${CHECKREQS_DONOTHING} ]] && msg="eerror" ${msg} "There is NOT at least ${sizeunit} ${location}" - # @ECLASS_VARIABLE: CHECKREQS_FAILED - # @INTERNAL - # @DESCRIPTION: - # If set the checks failed and eclass should abort the build. - # Internal, do not set yourself. CHECKREQS_FAILED="true" } diff --git a/eclass/cmake.eclass b/eclass/cmake.eclass index 59e5b60957c2..bd7e64cfe6c7 100644 --- a/eclass/cmake.eclass +++ b/eclass/cmake.eclass @@ -136,7 +136,7 @@ case ${CMAKE_MAKEFILE_GENERATOR} in BDEPEND="sys-devel/make" ;; ninja) - BDEPEND="dev-util/ninja" + BDEPEND="${NINJA_DEPEND}" ;; *) eerror "Unknown value for \${CMAKE_MAKEFILE_GENERATOR}" @@ -363,13 +363,6 @@ cmake_src_prepare() { die "FATAL: Unable to find CMakeLists.txt" fi - # if ninja is enabled but not installed, the build could fail - # this could happen if ninja is manually enabled (eg. make.conf) but not installed - if [[ ${CMAKE_MAKEFILE_GENERATOR} == ninja ]] && ! has_version -b dev-util/ninja; then - eerror "CMAKE_MAKEFILE_GENERATOR is set to ninja, but ninja is not installed." - die "Please install dev-util/ninja or unset CMAKE_MAKEFILE_GENERATOR." - fi - local modules_list if [[ ${EAPI} == 7 && $(declare -p CMAKE_REMOVE_MODULES_LIST) != "declare -a"* ]]; then modules_list=( ${CMAKE_REMOVE_MODULES_LIST} ) @@ -705,11 +698,7 @@ cmake_src_test() { cmake_src_install() { debug-print-function ${FUNCNAME} "$@" - _cmake_check_build_dir - pushd "${BUILD_DIR}" > /dev/null || die - DESTDIR="${D}" ${CMAKE_MAKEFILE_GENERATOR} install "$@" || - die "died running ${CMAKE_MAKEFILE_GENERATOR} install" - popd > /dev/null || die + DESTDIR="${D}" cmake_build install "$@" if [[ ${EAPI} == 7 ]]; then pushd "${S}" > /dev/null || die diff --git a/eclass/desktop.eclass b/eclass/desktop.eclass index 82e764e2a1a4..de912bb80932 100644 --- a/eclass/desktop.eclass +++ b/eclass/desktop.eclass @@ -308,7 +308,7 @@ _iconins() { case ${size} in 16|22|24|32|36|48|64|72|96|128|192|256|512) size=${size}x${size};; - scalable) + symbolic|scalable) ;; *) eerror "${size} is an unsupported icon size!" diff --git a/eclass/distutils-r1.eclass b/eclass/distutils-r1.eclass index ed368da79896..4e8c2d67db0b 100644 --- a/eclass/distutils-r1.eclass +++ b/eclass/distutils-r1.eclass @@ -106,6 +106,10 @@ esac # # - maturin - maturin backend # +# - meson-python - meson-python (mesonpy) backend +# +# - no - no PEP517 build system (see below) +# # - pbr - pbr backend # # - pdm - pdm.pep517 backend @@ -117,10 +121,21 @@ esac # - sip - sipbuild backend # # - standalone - standalone build systems without external deps -# (used for bootstrapping). +# (used for bootstrapping). # # The variable needs to be set before the inherit line. The eclass # adds appropriate build-time dependencies and verifies the value. +# +# The special value "no" indicates that the package has no build system. +# This is not equivalent to unset DISTUTILS_USE_PEP517 (legacy mode). +# It causes the eclass not to include any build system dependencies +# and to disable default python_compile() and python_install() +# implementations. Baseline Python deps and phase functions will still +# be set (depending on the value of DISTUTILS_OPTIONAL). Most of +# the other eclass functions will work. Testing venv will be provided +# in ${BUILD_DIR}/install after python_compile(), and if any (other) +# files are found in ${BUILD_DIR}/install after python_install(), they +# will be merged into ${D}. # @ECLASS_VARIABLE: DISTUTILS_USE_SETUPTOOLS # @DEFAULT_UNSET @@ -136,10 +151,10 @@ esac # - rdepend -- add it to BDEPEND+RDEPEND (e.g. when using pkg_resources) # # - pyproject.toml -- use pyproject2setuptools to install a project -# using pyproject.toml (flit, poetry...) +# using pyproject.toml (flit, poetry...) # # - manual -- do not add the dependency and suppress the checks -# (assumes you will take care of doing it correctly) +# (assumes you will take care of doing it correctly) # # This variable is effective only if DISTUTILS_OPTIONAL is disabled. # It is available only in non-PEP517 mode. It needs to be set before @@ -212,6 +227,14 @@ _distutils_set_globals() { bdep+=' >=dev-util/maturin-0.12.7[${PYTHON_USEDEP}]' ;; + no) + # undo the generic deps added above + bdep= + ;; + meson-python) + bdep+=' + dev-python/meson-python[${PYTHON_USEDEP}]' + ;; pbr) bdep+=' >=dev-python/pbr-5.8.0-r1[${PYTHON_USEDEP}]' @@ -611,8 +634,11 @@ distutils_enable_tests() { # (if ${EPYTHON} is set; fallback 'python' otherwise). # # setup.py will be passed the following, in order: +# # 1. ${DISTUTILS_ARGS[@]} +# # 2. ${mydistutilsargs[@]} (deprecated) +# # 3. additional arguments passed to the esetup.py function. # # Please note that setup.py will respect defaults (unless overridden @@ -789,7 +815,7 @@ distutils_install_for_testing() { distutils_write_namespace() { debug-print-function ${FUNCNAME} "${@}" - if [[ ! ${DISTUTILS_USE_PEP517} ]]; then + if [[ ! ${DISTUTILS_USE_PEP517:-no} != no ]]; then die "${FUNCNAME} is available only in PEP517 mode" fi if [[ ${EBUILD_PHASE} != test || ! ${BUILD_DIR} ]]; then @@ -835,7 +861,8 @@ _distutils-r1_disable_ez_setup() { # @FUNCTION: _distutils-r1_handle_pyproject_toml # @INTERNAL # @DESCRIPTION: -# Generate setup.py for pyproject.toml if requested. +# Verify whether DISTUTILS_USE_SETUPTOOLS is set correctly +# for pyproject.toml build systems (in non-PEP517 mode). _distutils-r1_handle_pyproject_toml() { if [[ ${DISTUTILS_USE_PEP517} ]]; then die "${FUNCNAME} is not implemented in PEP517 mode" @@ -912,6 +939,14 @@ _distutils-r1_print_package_versions() { dev-util/maturin ) ;; + no) + return + ;; + meson-python) + packages+=( + dev-python/meson-python + ) + ;; pbr) packages+=( dev-python/pbr @@ -1114,6 +1149,9 @@ _distutils-r1_backend_to_key() { maturin) echo maturin ;; + mesonpy) + echo meson-python + ;; pbr.build) echo pbr ;; @@ -1143,7 +1181,7 @@ _distutils-r1_backend_to_key() { _distutils-r1_get_backend() { debug-print-function ${FUNCNAME} "${@}" - local build_backend + local build_backend legacy_fallback if [[ -f pyproject.toml ]]; then # if pyproject.toml exists, try getting the backend from it # NB: this could fail if pyproject.toml doesn't list one @@ -1154,6 +1192,7 @@ _distutils-r1_get_backend() { then # use the legacy setuptools backend as a fallback build_backend=setuptools.build_meta:__legacy__ + legacy_fallback=1 fi if [[ -z ${build_backend} ]]; then die "Unable to obtain build-backend from pyproject.toml" @@ -1179,6 +1218,11 @@ _distutils-r1_get_backend() { poetry.masonry.api) new_backend=poetry.core.masonry.api ;; + setuptools.build_meta:__legacy__) + # this backend should only be used as implicit fallback + [[ ! ${legacy_fallback} ]] && + new_backend=setuptools.build_meta + ;; esac if [[ -n ${new_backend} ]]; then @@ -1207,6 +1251,10 @@ distutils_pep517_install() { debug-print-function ${FUNCNAME} "${@}" [[ ${#} -eq 1 ]] || die "${FUNCNAME} takes exactly one argument: root" + if [[ ! ${DISTUTILS_USE_PEP517:-no} != no ]]; then + die "${FUNCNAME} is available only in PEP517 mode" + fi + local root=${1} local -x WHEEL_BUILD_DIR=${BUILD_DIR}/wheel mkdir -p "${WHEEL_BUILD_DIR}" || die @@ -1271,7 +1319,7 @@ distutils_pep517_install() { ) [[ -n ${wheel} ]] || die "No wheel name returned" - einfo " Installing the wheel to ${root}" + einfo " Installing ${wheel} to ${root}" gpep517 install-wheel --destdir="${root}" --interpreter="${PYTHON}" \ --prefix="${EPREFIX}/usr" "${WHEEL_BUILD_DIR}/${wheel}" || die "Wheel install failed" @@ -1294,12 +1342,19 @@ distutils_pep517_install() { # @FUNCTION: distutils-r1_python_compile # @USAGE: [additional-args...] # @DESCRIPTION: -# The default python_compile(). Runs 'esetup.py build'. Any parameters -# passed to this function will be appended to setup.py invocation, -# i.e. passed as options to the 'build' command. +# The default python_compile(). +# +# If DISTUTILS_USE_PEP517 is set to "no", a no-op. # -# This phase also sets up initial setup.cfg with build directories -# and copies upstream egg-info files if supplied. +# If DISTUTILS_USE_PEP517 is set to any other value, builds a wheel +# using the PEP517 backend and installs it into ${BUILD_DIR}/install. +# May additionally call build_ext prior to that when using setuptools +# and the eclass detects a potential benefit from parallel extension +# builds. +# +# In legacy mode, runs 'esetup.py build'. Any parameters passed to this +# function will be appended to setup.py invocation, i.e. passed +# as options to the 'build' command. distutils-r1_python_compile() { debug-print-function ${FUNCNAME} "${@}" @@ -1351,6 +1406,9 @@ distutils-r1_python_compile() { in_iuse debug && use debug && MATURIN_PEP517_ARGS+=" --cargo-extra-args=--profile=dev" ;; + no) + return + ;; esac if [[ ${DISTUTILS_USE_PEP517} ]]; then @@ -1361,33 +1419,7 @@ distutils-r1_python_compile() { addpredict /usr/lib/portage/pym addpredict /usr/local # bug 498232 - local root=${BUILD_DIR}/install - distutils_pep517_install "${root}" - - # copy executables to python-exec directory - # we do it early so that we can alter bindir recklessly - local bindir=${root}${EPREFIX}/usr/bin - local rscriptdir=${root}$(python_get_scriptdir) - [[ -d ${rscriptdir} ]] && - die "${rscriptdir} should not exist!" - if [[ -d ${bindir} ]]; then - mkdir -p "${rscriptdir}" || die - cp -a --reflink=auto "${bindir}"/. "${rscriptdir}"/ || die - fi - - # enable venv magic inside the install tree - mkdir -p "${bindir}" || die - ln -s "${PYTHON}" "${bindir}/${EPYTHON}" || die - ln -s "${EPYTHON}" "${bindir}/python3" || die - ln -s "${EPYTHON}" "${bindir}/python" || die - cat > "${bindir}"/pyvenv.cfg <<-EOF || die - include-system-site-packages = true - EOF - - # we need to change shebangs to point to the venv-python - find "${bindir}" -type f -exec sed -i \ - -e "1s@^#!\(${EPREFIX}/usr/bin/\(python\|pypy\)\)@#!${root}\1@" \ - {} + || die + distutils_pep517_install "${BUILD_DIR}/install" fi } @@ -1489,29 +1521,60 @@ distutils-r1_python_test() { # @FUNCTION: distutils-r1_python_install # @USAGE: [additional-args...] # @DESCRIPTION: -# The default python_install(). Runs 'esetup.py install', doing -# intermediate root install and handling script wrapping afterwards. +# The default python_install(). +# +# In PEP517 mode, merges the files from ${BUILD_DIR}/install +# (if present) to the image directory. +# +# In the legacy mode, calls `esetup.py install` to install the package. # Any parameters passed to this function will be appended # to the setup.py invocation (i.e. as options to the 'install' command). -# -# This phase updates the setup.cfg file with install directories. distutils-r1_python_install() { debug-print-function ${FUNCNAME} "${@}" _python_check_EPYTHON local scriptdir=${EPREFIX}/usr/bin + local merge_root= if [[ ${DISTUTILS_USE_PEP517} ]]; then local root=${BUILD_DIR}/install + local reg_scriptdir=${root}/${scriptdir} + local wrapped_scriptdir=${root}$(python_get_scriptdir) + + # we are assuming that _distutils-r1_post_python_compile + # has been called and ${root} has not been altered since + # let's explicitly verify these assumptions + + # remove files that we've created explicitly + rm "${reg_scriptdir}"/{"${EPYTHON}",python3,python,pyvenv.cfg} || die + # verify that scriptdir & wrapped_scriptdir both contain + # the same files + ( + cd "${reg_scriptdir}" && find . -mindepth 1 + ) | sort > "${T}"/.distutils-files-bin + assert "listing ${reg_scriptdir} failed" + ( + if [[ -d ${wrapped_scriptdir} ]]; then + cd "${wrapped_scriptdir}" && find . -mindepth 1 + fi + ) | sort > "${T}"/.distutils-files-wrapped + assert "listing ${wrapped_scriptdir} failed" + if ! diff -U 0 "${T}"/.distutils-files-{bin,wrapped}; then + die "File lists for ${reg_scriptdir} and ${wrapped_scriptdir} differ (see diff above)" + fi + # remove the altered bindir, executables from the package # are already in scriptdir - rm -r "${root}${scriptdir}" || die + rm -r "${reg_scriptdir}" || die if [[ ${DISTUTILS_SINGLE_IMPL} ]]; then - local wrapped_scriptdir=${root}$(python_get_scriptdir) if [[ -d ${wrapped_scriptdir} ]]; then - mv "${wrapped_scriptdir}" "${root}${scriptdir}" || die + mv "${wrapped_scriptdir}" "${reg_scriptdir}" || die fi fi + # prune empty directories to see if ${root} contains anything + # to merge + find "${BUILD_DIR}"/install -type d -empty -delete || die + [[ -d ${BUILD_DIR}/install ]] && merge_root=1 else local root=${D%/}/_${EPYTHON} [[ ${DISTUTILS_SINGLE_IMPL} ]] && root=${D%/} @@ -1538,6 +1601,8 @@ distutils-r1_python_install() { addpredict /usr/local # bug 498232 if [[ ! ${DISTUTILS_SINGLE_IMPL} ]]; then + merge_root=1 + # user may override --install-scripts # note: this is poor but distutils argv parsing is dumb @@ -1566,36 +1631,8 @@ distutils-r1_python_install() { esetup.py "${args[@]}" fi - local forbidden_package_names=( - examples test tests - .pytest_cache .hypothesis - ) - local p - for p in "${forbidden_package_names[@]}"; do - if [[ -d ${root}$(python_get_sitedir)/${p} ]]; then - die "Package installs '${p}' package which is forbidden and likely a bug in the build system." - fi - done - - local shopt_save=$(shopt -p nullglob) - shopt -s nullglob - local pypy_dirs=( - "${root}${EPREFIX}/usr/$(get_libdir)"/pypy*/share - "${root}${EPREFIX}/usr/lib"/pypy*/share - ) - ${shopt_save} - - if [[ -n ${pypy_dirs} ]]; then - die "Package installs 'share' in PyPy prefix, see bug #465546." - fi - - if [[ ! ${DISTUTILS_SINGLE_IMPL} || ${DISTUTILS_USE_PEP517} ]]; then + if [[ ${merge_root} ]]; then multibuild_merge_root "${root}" "${D%/}" - if [[ ${DISTUTILS_USE_PEP517} ]]; then - # we need to recompile everything here in order to embed - # the correct paths - python_optimize "${D%/}$(python_get_sitedir)" - fi fi if [[ ! ${DISTUTILS_SINGLE_IMPL} ]]; then _distutils-r1_wrap_scripts "${scriptdir}" @@ -1629,6 +1666,8 @@ distutils-r1_run_phase() { debug-print-function ${FUNCNAME} "${@}" if [[ ${DISTUTILS_IN_SOURCE_BUILD} ]]; then + [[ ${DISTUTILS_USE_PEP517} ]] && + die "DISTUTILS_IN_SOURCE_BUILD is not supported in PEP517 mode" # only force BUILD_DIR if implementation is explicitly enabled # for building; any-r1 API may select one that is not # https://bugs.gentoo.org/701506 @@ -1687,6 +1726,11 @@ distutils-r1_run_phase() { fi cd "${_DISTUTILS_INITIAL_CWD}" || die + if [[ ! ${_DISTUTILS_IN_COMMON_IMPL} ]] && + declare -f "_distutils-r1_post_python_${EBUILD_PHASE}" >/dev/null + then + "_distutils-r1_post_python_${EBUILD_PHASE}" + fi return "${ret}" } @@ -1701,6 +1745,7 @@ distutils-r1_run_phase() { # of sources made for the selected Python interpreter. _distutils-r1_run_common_phase() { local DISTUTILS_ORIG_BUILD_DIR=${BUILD_DIR} + local _DISTUTILS_IN_COMMON_IMPL=1 if [[ ${DISTUTILS_SINGLE_IMPL} ]]; then # reuse the dedicated code branch @@ -1731,6 +1776,7 @@ _distutils-r1_run_foreach_impl() { set -- distutils-r1_run_phase "${@}" if [[ ! ${DISTUTILS_SINGLE_IMPL} ]]; then + local _DISTUTILS_CALLING_FOREACH_IMPL=1 python_foreach_impl "${@}" else if [[ ! ${EPYTHON} ]]; then @@ -1781,6 +1827,43 @@ distutils-r1_src_configure() { return ${ret} } +# @FUNCTION: _distutils-r1_post_python_compile +# @INTERNAL +# @DESCRIPTION: +# Post-phase function called after python_compile. In PEP517 mode, +# it adjusts the install tree for venv-style usage. +_distutils-r1_post_python_compile() { + debug-print-function ${FUNCNAME} "${@}" + + local root=${BUILD_DIR}/install + if [[ ${DISTUTILS_USE_PEP517} && -d ${root} ]]; then + # copy executables to python-exec directory + # we do it early so that we can alter bindir recklessly + local bindir=${root}${EPREFIX}/usr/bin + local rscriptdir=${root}$(python_get_scriptdir) + [[ -d ${rscriptdir} ]] && + die "${rscriptdir} should not exist!" + if [[ -d ${bindir} ]]; then + mkdir -p "${rscriptdir}" || die + cp -a --reflink=auto "${bindir}"/. "${rscriptdir}"/ || die + fi + + # enable venv magic inside the install tree + mkdir -p "${bindir}" || die + ln -s "${PYTHON}" "${bindir}/${EPYTHON}" || die + ln -s "${EPYTHON}" "${bindir}/python3" || die + ln -s "${EPYTHON}" "${bindir}/python" || die + cat > "${bindir}"/pyvenv.cfg <<-EOF || die + include-system-site-packages = true + EOF + + # we need to change shebangs to point to the venv-python + find "${bindir}" -type f -exec sed -i \ + -e "1s@^#!\(${EPREFIX}/usr/bin/\(python\|pypy\)\)@#!${root}\1@" \ + {} + || die + fi +} + distutils-r1_src_compile() { debug-print-function ${FUNCNAME} "${@}" local ret=0 @@ -1812,15 +1895,24 @@ _distutils-r1_clean_egg_info() { rm -rf "${BUILD_DIR}"/lib/*.egg-info || die } +# @FUNCTION: _distutils-r1_post_python_test +# @INTERNAL +# @DESCRIPTION: +# Post-phase function called after python_test. +_distutils-r1_post_python_test() { + debug-print-function ${FUNCNAME} "${@}" + + if [[ ! ${DISTUTILS_USE_PEP517} ]]; then + _distutils-r1_clean_egg_info + fi +} + distutils-r1_src_test() { debug-print-function ${FUNCNAME} "${@}" local ret=0 if declare -f python_test >/dev/null; then _distutils-r1_run_foreach_impl python_test || ret=${?} - if [[ ! ${DISTUTILS_USE_PEP517} ]]; then - _distutils-r1_run_foreach_impl _distutils-r1_clean_egg_info - fi fi if declare -f python_test_all >/dev/null; then @@ -1830,6 +1922,35 @@ distutils-r1_src_test() { return ${ret} } +# @FUNCTION: _distutils-r1_post_python_install +# @INTERNAL +# @DESCRIPTION: +# Post-phase function called after python_install. Performs QA checks. +# In PEP517 mode, additionally optimizes installed Python modules. +_distutils-r1_post_python_install() { + debug-print-function ${FUNCNAME} "${@}" + + local sitedir=${D%/}$(python_get_sitedir) + if [[ -d ${sitedir} ]]; then + local forbidden_package_names=( + examples test tests + .pytest_cache .hypothesis _trial_temp + ) + local p + for p in "${forbidden_package_names[@]}"; do + if [[ -d ${sitedir}/${p} ]]; then + die "Package installs '${p}' package which is forbidden and likely a bug in the build system." + fi + done + + if [[ ${DISTUTILS_USE_PEP517} ]]; then + # we need to recompile everything here in order to embed + # the correct paths + python_optimize "${sitedir}" + fi + fi +} + # @FUNCTION: _distutils-r1_check_namespace_pth # @INTERNAL # @DESCRIPTION: @@ -1854,6 +1975,10 @@ _distutils-r1_check_namespace_pth() { ewarn "the ebuild accordingly:" ewarn ewarn " https://projects.gentoo.org/python/guide/concept.html#namespace-packages" + + if ! has "${EAPI}" 6 7 8; then + die "*-nspkg.pth files are banned in EAPI ${EAPI}" + fi fi } diff --git a/eclass/epatch.eclass b/eclass/epatch.eclass index 5d18befe55b9..6a9c460da0a3 100644 --- a/eclass/epatch.eclass +++ b/eclass/epatch.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: epatch.eclass @@ -285,13 +285,13 @@ epatch() { # people could (accidently) patch files in the root filesystem. # Or trigger other unpleasantries #237667. So disallow -p0 on # such patches. - local abs_paths=$(egrep -n '^[-+]{3} /' "${PATCH_TARGET}" | awk '$2 != "/dev/null" { print }') + local abs_paths=$(grep -E -n '^[-+]{3} /' "${PATCH_TARGET}" | awk '$2 != "/dev/null" { print }') if [[ -n ${abs_paths} ]] ; then count=1 printf "NOTE: skipping -p0 due to absolute paths in patch:\n%s\n" "${abs_paths}" >> "${STDERR_TARGET}" fi # Similar reason, but with relative paths. - local rel_paths=$(egrep -n '^[-+]{3} [^ ]*[.][.]/' "${PATCH_TARGET}") + local rel_paths=$(grep -E -n '^[-+]{3} [^ ]*[.][.]/' "${PATCH_TARGET}") if [[ -n ${rel_paths} ]] ; then echo eerror "Rejected Patch: ${patchname}!" diff --git a/eclass/flag-o-matic.eclass b/eclass/flag-o-matic.eclass index 50caa401bacf..0e15d7423547 100644 --- a/eclass/flag-o-matic.eclass +++ b/eclass/flag-o-matic.eclass @@ -218,6 +218,14 @@ filter-lfs-flags() { filter-flags -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_TIME_BITS=64 } +# @FUNCTION: filter-lto +# @DESCRIPTION: +# Remove flags that enable LTO and those that depend on it +filter-lto() { + [[ $# -ne 0 ]] && die "filter-lto takes no arguments" + filter-flags '-flto*' -fwhole-program-vtables '-fsanitize=cfi*' +} + # @FUNCTION: filter-ldflags # @USAGE: <flags> # @DESCRIPTION: diff --git a/eclass/ghc-package.eclass b/eclass/ghc-package.eclass index 303cf32d7ef5..8c77ad5bc3cb 100644 --- a/eclass/ghc-package.eclass +++ b/eclass/ghc-package.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: ghc-package.eclass @@ -152,10 +152,10 @@ ghc-supports-parallel-make() { $(ghc-getghc) --info | grep "Support parallel --make" | grep -q "YES" } -# @FUNCTION: ghc-extractportageversion +# @FUNCTION: ghc-extract-pm-version # @DESCRIPTION: # extract the version of a portage-installed package -ghc-extractportageversion() { +ghc-extract-pm-version() { local pkg local version pkg="$(best_version $1)" diff --git a/eclass/gnustep-2.eclass b/eclass/gnustep-2.eclass index 68c15bbc62e1..e1d7f00da080 100644 --- a/eclass/gnustep-2.eclass +++ b/eclass/gnustep-2.eclass @@ -1,18 +1,18 @@ -# Copyright 1999-2021 Gentoo Authors +# Copyright 1999-2022 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 # @ECLASS: gnustep-2.eclass # @MAINTAINER: # GNUstep Herd <gnustep@gentoo.org> -# @SUPPORTED_EAPIS: 5 6 7 8 +# @SUPPORTED_EAPIS: 6 7 8 # @PROVIDES: gnustep-base # @BLURB: eclass for GNUstep Apps, Frameworks, and Bundles build # @DESCRIPTION: # This eclass sets up GNUstep environment to properly install # GNUstep packages -case ${EAPI:-0} in - [5678]) ;; +case ${EAPI} in + 6|7|8) ;; *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;; esac @@ -21,8 +21,8 @@ _GNUSTEP_2_ECLASS=1 inherit gnustep-base -case ${EAPI:-0} in - [56]) +case ${EAPI} in + 6) DEPEND=">=gnustep-base/gnustep-make-2.0" ;; *) diff --git a/eclass/gnustep-base.eclass b/eclass/gnustep-base.eclass index d37ecad102e0..9d72e6315fff 100644 --- a/eclass/gnustep-base.eclass +++ b/eclass/gnustep-base.eclass @@ -1,17 +1,18 @@ -# Copyright 1999-2021 Gentoo Authors +# Copyright 1999-2022 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 # @ECLASS: gnustep-base.eclass # @MAINTAINER: # GNUstep Herd <gnustep@gentoo.org> -# @SUPPORTED_EAPIS: 5 6 7 8 +# @SUPPORTED_EAPIS: 6 7 8 # @BLURB: Internal handling of GNUstep pacakges # @DESCRIPTION: # Inner gnustep eclass, should only be inherited directly by gnustep-base # packages -case ${EAPI:-0} in - [5678]) inherit eutils ;; +case ${EAPI} in + 6|7) inherit eutils ;; + 8) ;; *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;; esac @@ -64,7 +65,7 @@ gnustep-base_src_prepare() { eend $? fi - ! has ${EAPI} 5 && default + default } gnustep-base_src_configure() { diff --git a/eclass/gstreamer-meson.eclass b/eclass/gstreamer-meson.eclass index bae35c7edcea..f81c2beeccd8 100644 --- a/eclass/gstreamer-meson.eclass +++ b/eclass/gstreamer-meson.eclass @@ -40,7 +40,7 @@ esac # @ECLASS_VARIABLE: GST_PLUGINS_ENABLED # @DESCRIPTION: # Defines the plugins to be built. -# May be set by an ebuild and contain more than one indentifier, space +# May be set by an ebuild and contain more than one identifier, space # separated (only src_configure can handle mutiple plugins at this time). # @ECLASS_VARIABLE: GST_PLUGINS_NOAUTO @@ -202,7 +202,7 @@ multilib_src_compile() { gstreamer_multilib_src_compile; } multilib_src_install() { gstreamer_multilib_src_install; } if [[ "${PN}" != "${GST_ORG_MODULE}" ]]; then - # Do not run test phase for invididual plugin ebuilds. + # Do not run test phase for individual plugin ebuilds. RESTRICT="test" RDEPEND="${RDEPEND} >=media-libs/${GST_ORG_MODULE}-${PV}:${SLOT}[${MULTILIB_USEDEP}]" diff --git a/eclass/gstreamer.eclass b/eclass/gstreamer.eclass index 1a2c01afc884..28db8b1e035f 100644 --- a/eclass/gstreamer.eclass +++ b/eclass/gstreamer.eclass @@ -40,8 +40,8 @@ esac # @ECLASS_VARIABLE: GST_PLUGINS_BUILD # @DESCRIPTION: # Defines the plugins to be built. -# May be set by an ebuild and contain more than one indentifier, space -# seperated (only src_configure can handle mutiple plugins at this time). +# May be set by an ebuild and contain more than one identifier, space +# separated (only src_configure can handle mutiple plugins at this time). : ${GST_PLUGINS_BUILD:=${PN/gst-plugins-/}} # @ECLASS_VARIABLE: GST_PLUGINS_BUILD_DIR @@ -103,7 +103,7 @@ DEPEND=" multilib_src_configure() { gstreamer_multilib_src_configure; } if [[ ${PN} != ${GST_ORG_MODULE} ]]; then - # Do not run test phase for invididual plugin ebuilds. + # Do not run test phase for individual plugin ebuilds. RESTRICT="test" RDEPEND="${RDEPEND} >=media-libs/${GST_ORG_MODULE}-${PV}:${SLOT}[${MULTILIB_USEDEP}]" diff --git a/eclass/haskell-cabal.eclass b/eclass/haskell-cabal.eclass index ae3229cc2676..541bb4a90ee5 100644 --- a/eclass/haskell-cabal.eclass +++ b/eclass/haskell-cabal.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: haskell-cabal.eclass @@ -183,7 +183,7 @@ cabal-version() { else # We ask portage, not ghc, so that we only pick up # portage-installed cabal versions. - _CABAL_VERSION_CACHE="$(ghc-extractportageversion dev-haskell/cabal)" + _CABAL_VERSION_CACHE="$(ghc-extract-pm-version dev-haskell/cabal)" fi fi echo "${_CABAL_VERSION_CACHE}" @@ -288,8 +288,8 @@ cabal-show-brokens() { elog "ghc-pkg check: 'checking for other broken packages:'" # pretty-printer $(ghc-getghcpkg) check 2>&1 \ - | egrep -v '^Warning: haddock-(html|interfaces): ' \ - | egrep -v '^Warning: include-dirs: ' \ + | grep -E -v '^Warning: haddock-(html|interfaces): ' \ + | grep -E -v '^Warning: include-dirs: ' \ | head -n 20 cabal-die-if-nonempty 'broken' \ diff --git a/eclass/java-utils-2.eclass b/eclass/java-utils-2.eclass index 5b4783f350f2..e5a2b611d111 100644 --- a/eclass/java-utils-2.eclass +++ b/eclass/java-utils-2.eclass @@ -124,7 +124,7 @@ JAVA_PKG_ALLOW_VM_CHANGE=${JAVA_PKG_ALLOW_VM_CHANGE:="yes"} # ) # @CODE -# @ECLASS-VARIABLE: JAVA_TEST_RUNNER_EXTRA_ARGS +# @ECLASS_VARIABLE: JAVA_TEST_RUNNER_EXTRA_ARGS # @DEFAULT_UNSET # @DESCRIPTION: # Array of extra arguments that should be passed to the test runner when running tests. diff --git a/eclass/java-vm-2.eclass b/eclass/java-vm-2.eclass index 7c63e63fad76..ad814d7efd1a 100644 --- a/eclass/java-vm-2.eclass +++ b/eclass/java-vm-2.eclass @@ -24,6 +24,12 @@ RDEPEND=" app-eselect/eselect-java " DEPEND="${RDEPEND}" +BDEPEND="app-arch/unzip" +IDEPEND="app-eselect/eselect-java" + +if [[ ${EAPI} == 6 ]]; then + DEPEND+=" ${BDEPEND}" +fi export WANT_JAVA_CONFIG=2 @@ -83,14 +89,35 @@ java-vm-2_pkg_postinst() { xdg_desktop_database_update } +# @FUNCTION: has_eselect_java-vm_update +# @INTERNAL +# @DESCRIPTION: +# Checks if an eselect-java version providing "eselect java-vm update" +# is available. +# @RETURN: 0 if >=app-eselect/eselect-java-0.5 is installed, 1 otherwise. +has_eselect_java-vm_update() { + local has_version_args="-b" + if [[ ${EAPI} == 6 ]]; then + has_version_args="--host-root" + fi + + has_version "${has_version_args}" ">=app-eselect/eselect-java-0.5" +} # @FUNCTION: java-vm-2_pkg_prerm # @DESCRIPTION: # default pkg_prerm # -# Warn user if removing system-vm. +# Does nothing if eselect-java-0.5 or newer is available. Otherwise, +# warn user if removing system-vm. java-vm-2_pkg_prerm() { + if has_eselect_java-vm_update; then + # We will potentially switch to a new Java system VM in + # pkg_postrm(). + return + fi + if [[ $(GENTOO_VM= java-config -f 2>/dev/null) == ${VMHANDLE} && -z ${REPLACED_BY_VERSION} ]]; then ewarn "It appears you are removing your system-vm! Please run" ewarn "\"eselect java-vm list\" to list available VMs, then use" @@ -103,10 +130,14 @@ java-vm-2_pkg_prerm() { # @DESCRIPTION: # default pkg_postrm # -# Update mime database. +# Invoke "eselect java-vm update" if eselect-java 0.5, or newer, is +# available. Also update the mime database. java-vm-2_pkg_postrm() { xdg_desktop_database_update + if has_eselect_java-vm_update; then + eselect java-vm update + fi } diff --git a/eclass/kde.org.eclass b/eclass/kde.org.eclass index 8e0c97f0ec00..b38ca5a024ab 100644 --- a/eclass/kde.org.eclass +++ b/eclass/kde.org.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: kde.org.eclass @@ -137,6 +137,16 @@ esac # a proper error message via pkg_nofetch. KDE_UNRELEASED=( ) +# @ECLASS_VARIABLE: EGIT_MIRROR +# @DESCRIPTION: +# This variable allows easy overriding of default kde mirror service +# (anongit) with anything else you might want to use. + +# @ECLASS_VARIABLE: EGIT_REPONAME +# @DESCRIPTION: +# This variable allows overriding of default repository name. +# Specify only if this differs from PN and KDE_ORG_NAME. + HOMEPAGE="https://kde.org/" case ${CATEGORY} in @@ -249,10 +259,6 @@ _kde.org_calculate_live_repo() { SRC_URI="" - # @ECLASS_VARIABLE: EGIT_MIRROR - # @DESCRIPTION: - # This variable allows easy overriding of default kde mirror service - # (anongit) with anything else you might want to use. EGIT_MIRROR=${EGIT_MIRROR:=https://invent.kde.org/${KDE_ORG_CATEGORY}} if [[ ${PV} == 5.??(.?)*.9999 && ${CATEGORY} == dev-qt ]]; then @@ -267,10 +273,6 @@ _kde.org_calculate_live_repo() { EGIT_BRANCH="Plasma/$(ver_cut 1-2)" fi - # @ECLASS_VARIABLE: EGIT_REPONAME - # @DESCRIPTION: - # This variable allows overriding of default repository - # name. Specify only if this differs from PN and KDE_ORG_NAME. EGIT_REPO_URI="${EGIT_MIRROR}/${EGIT_REPONAME:=$KDE_ORG_NAME}.git" } diff --git a/eclass/kernel-2.eclass b/eclass/kernel-2.eclass index 02c70422ee07..b3fb5cef76c3 100644 --- a/eclass/kernel-2.eclass +++ b/eclass/kernel-2.eclass @@ -1411,7 +1411,16 @@ kernel-2_src_unpack() { # allow ebuilds to massage the source tree after patching but before # we run misc `make` functions below - [[ $(type -t kernel-2_hook_premake) == "function" ]] && kernel-2_hook_premake + if [[ $(type -t kernel-2_hook_premake) == "function" ]]; then + ewarn "The function name: kernel-2_hook_premake is being deprecated and" + ewarn "being changed to: kernel-2_insert_premake to comply with pms policy." + ewarn "See bug #843686 " + ewarn "The call to the old function name will be removed on or about July 1st, 2022 " + ewarn "Please update your ebuild before this date." + kernel-2_hook_premake + else + [[ $(type -t kernel-2_insert_premake) == "function" ]] && kernel-2_insert_premake + fi debug-print "Doing unpack_set_extraversion" diff --git a/eclass/kernel-build.eclass b/eclass/kernel-build.eclass index 0a49533e48d3..dbd9080ab98a 100644 --- a/eclass/kernel-build.eclass +++ b/eclass/kernel-build.eclass @@ -33,7 +33,7 @@ case "${EAPI:-0}" in ;; esac -PYTHON_COMPAT=( python3_{8..10} ) +PYTHON_COMPAT=( python3_{8..11} ) inherit python-any-r1 savedconfig toolchain-funcs kernel-install @@ -43,7 +43,8 @@ BDEPEND=" sys-devel/bc sys-devel/flex virtual/libelf - virtual/yacc" + virtual/yacc +" # @FUNCTION: kernel-build_src_configure # @DESCRIPTION: @@ -195,6 +196,13 @@ kernel-build_src_install() { local image_path=$(dist-kernel_get_image_path) cp -p "build/${image_path}" "${ED}/usr/src/linux-${ver}/${image_path}" || die + # Install the unstripped uncompressed vmlinux for use with systemtap + # etc. Use mv rather than doins for the same reason as above -- + # space and time. + if use debug; then + mv build/vmlinux "${ED}/usr/src/linux-${ver}/" || die + fi + # building modules fails with 'vmlinux has no symtab?' if stripped use ppc64 && dostrip -x "/usr/src/linux-${ver}/${image_path}" diff --git a/eclass/linux-info.eclass b/eclass/linux-info.eclass index 7b56a47016c6..7e130062a6c1 100644 --- a/eclass/linux-info.eclass +++ b/eclass/linux-info.eclass @@ -148,15 +148,30 @@ esac # @DESCRIPTION: # Set the env ARCH to match what the kernel expects. set_arch_to_kernel() { export ARCH=$(tc-arch-kernel); } + # @FUNCTION: set_arch_to_portage # @DESCRIPTION: # Set the env ARCH to match what portage expects. -set_arch_to_portage() { export ARCH=$(tc-arch); } +set_arch_to_portage() { -# qeinfo "Message" -# ------------------- -# qeinfo is a quiet einfo call when EBUILD_PHASE -# should not have visible output. + ewarn "The function name: set_arch_to_portage is being deprecated and" + ewarn "being changed to: set_arch_to_pkgmgr to comply with pms policy." + ewarn "See bug #843686" + ewarn "The old function name will be removed on or about July 1st, 2022." + ewarn "Please update your ebuild or eclass before this date." + ewarn "" + + export ARCH=$(tc-arch); +} + +# @FUNCTION: set_arch_to_pkgmgr +# @DESCRIPTION: +# Set the env ARCH to match what the package manager expects. +set_arch_to_pkgmgr() { export ARCH=$(tc-arch); } + +# @FUNCTION: qout +# @DESCRIPTION: +# qout <einfo | ewarn | eerror> is a quiet call when EBUILD_PHASE should not have visible output. qout() { local outputmsg type type=${1} @@ -170,8 +185,21 @@ qout() { [ -n "${outputmsg}" ] && ${type} "${outputmsg}" } +# @FUNCTION: qeinfo +# @DESCRIPTION: +# qeinfo is a quiet einfo call when EBUILD_PHASE should not have visible output. qeinfo() { qout einfo "${@}" ; } + +# @FUNCTION: qewarn +# @DESCRIPTION: +# qewarn is a quiet ewarn call when EBUILD_PHASE +# should not have visible output. qewarn() { qout ewarn "${@}" ; } + +# @FUNCTION: qeerror +# @DESCRIPTION: +# qeerror is a quiet error call when EBUILD_PHASE +# should not have visible output. qeerror() { qout eerror "${@}" ; } # File Functions @@ -253,6 +281,10 @@ getfilevar_noexec() { # config is available at all. _LINUX_CONFIG_EXISTS_DONE= +# @FUNCTION: linux_config_qa_check +# @INTERNAL +# @DESCRIPTION: +# Helper funciton which returns an error before the function argument is run if no config exists linux_config_qa_check() { local f="$1" if [ -z "${_LINUX_CONFIG_EXISTS_DONE}" ]; then @@ -422,26 +454,9 @@ kernel_is() { "${1:-${KV_MAJOR:-0}}.${2:-${KV_MINOR:-0}}.${3:-${KV_PATCH:-0}}" } -get_localversion() { - local lv_list i x - - local shopt_save=$(shopt -p nullglob) - shopt -s nullglob - local files=( ${1}/localversion* ) - ${shopt_save} - - # ignore files with ~ in it. - for i in "${files[@]}"; do - [[ -n ${i//*~*} ]] && lv_list="${lv_list} ${i}" - done - - for i in ${lv_list}; do - x="${x}$(<${i})" - done - x=${x/ /} - echo ${x} -} - +# @FUNCTION: get_makefile_extract_function +# @INTERNAL +# @DESCRIPTION: # Check if the Makefile is valid for direct parsing. # Check status results: # - PASS, use 'getfilevar' to extract values @@ -457,7 +472,10 @@ get_makefile_extract_function() { echo "${mkfunc}" } -# internal variable, so we know to only print the warning once +# @ECLASS_VARIABLE: get_version_warning_done +# @INTERNAL +# @DESCRIPTION: +# Internal variable, so we know to only print the warning once. get_version_warning_done= # @FUNCTION: get_version @@ -874,6 +892,9 @@ check_extra_config() { export LINUX_CONFIG_EXISTS_DONE="${old_LINUX_CONFIG_EXISTS_DONE}" } +# @FUNCTION: check_zlibinflate +# @DESCRIPTION: +# Function to make sure a ZLIB_INFLATE configuration has the required symbols. check_zlibinflate() { if ! use kernel_linux; then die "${FUNCNAME}() called on non-Linux system, please fix the ebuild" diff --git a/eclass/linux-mod.eclass b/eclass/linux-mod.eclass index 36325fab0fa5..b7c13cbf7e76 100644 --- a/eclass/linux-mod.eclass +++ b/eclass/linux-mod.eclass @@ -193,46 +193,6 @@ DEPEND="${RDEPEND} # eclass utilities # ---------------------------------- -check_vermagic() { - debug-print-function ${FUNCNAME} $* - - local curr_gcc_ver=$(gcc -dumpversion) - local tmpfile old_chost old_gcc_ver result=0 - [ -n "${MODULES_OPTIONAL_USE}" ] && use !${MODULES_OPTIONAL_USE} && return - - tmpfile=`find "${KV_DIR}/" -iname "*.o.cmd" -exec grep usr/lib/gcc {} \; -quit` - tmpfile=${tmpfile//*usr/lib} - tmpfile=${tmpfile//\/include*} - old_chost=${tmpfile//*gcc\/} - old_chost=${old_chost//\/*} - old_gcc_ver=${tmpfile//*\/} - - if [[ -z ${old_gcc_ver} || -z ${old_chost} ]]; then - ewarn "" - ewarn "Unable to detect what version of GCC was used to compile" - ewarn "the kernel. Build will continue, but you may experience problems." - elif [[ ${curr_gcc_ver} != ${old_gcc_ver} ]]; then - ewarn "" - ewarn "The version of GCC you are using (${curr_gcc_ver}) does" - ewarn "not match the version of GCC used to compile the" - ewarn "kernel (${old_gcc_ver})." - result=1 - elif [[ ${CHOST} != ${old_chost} ]]; then - ewarn "" - ewarn "The current CHOST (${CHOST}) does not match the chost" - ewarn "used when compiling the kernel (${old_chost})." - result=1 - fi - - if [[ ${result} -gt 0 ]]; then - ewarn "" - ewarn "Build will not continue, because you will experience problems." - ewarn "To fix this either change the version of GCC you wish to use" - ewarn "to match the kernel, or recompile the kernel first." - die "GCC Version Mismatch." - fi -} - # @FUNCTION: use_m # @RETURN: true or false # @DESCRIPTION: @@ -267,11 +227,10 @@ convert_to_m() { fi } -# internal function -# -# FUNCTION: update_depmod -# DESCRIPTION: -# It updates the modules.dep file for the current kernel. +# @FUNCTION: update_depmod +# @INTERNAL +# @DESCRIPTION: +# Updates the modules.dep file for the current kernel. update_depmod() { debug-print-function ${FUNCNAME} $* @@ -292,11 +251,10 @@ update_depmod() { fi } -# internal function -# -# FUNCTION: move_old_moduledb -# DESCRIPTION: -# It updates the location of the database used by the module-rebuild utility. +# @FUNCTION: move_old_moduledb +# @INTERNAL +# @DESCRIPTION: +# Updates the location of the database used by the module-rebuild utility. move_old_moduledb() { debug-print-function ${FUNCNAME} $* @@ -312,11 +270,9 @@ move_old_moduledb() { fi } -# internal function -# -# FUNCTION: update_moduledb -# DESCRIPTION: -# It adds the package to the /var/lib/module-rebuild/moduledb database used by the module-rebuild utility. +# @FUNCTION: update_moduledb +# @DESCRIPTION: +# Adds the package to the /var/lib/module-rebuild/moduledb database used by the module-rebuild utility. update_moduledb() { debug-print-function ${FUNCNAME} $* @@ -334,12 +290,9 @@ update_moduledb() { fi } -# internal function -# -# FUNCTION: remove_moduledb -# DESCRIPTION: -# It removes the package from the /var/lib/module-rebuild/moduledb database used by -# the module-rebuild utility. +# @FUNCTION: remove_moduledb +# @DESCRIPTION: +# Removes the package from the /var/lib/module-rebuild/moduledb database used by remove_moduledb() { debug-print-function ${FUNCNAME} $* @@ -369,6 +322,10 @@ set_kvobj() { # einfo "Using KV_OBJ=${KV_OBJ}" } +# @FUNCTION: get-KERNEL_CC +# @RETURN: Name of the C compiler. +# @DESCRIPTION: +# Return name of the C compiler while honoring variables defined in ebuilds. get-KERNEL_CC() { debug-print-function ${FUNCNAME} $* @@ -389,12 +346,11 @@ get-KERNEL_CC() { echo "${kernel_cc}" } -# internal function -# -# FUNCTION: -# USAGE: /path/to/the/modulename_without_extension -# RETURN: A file in /etc/modprobe.d -# DESCRIPTION: +# @FUNCTION: generate_modulesd +# @INTERNAL +# @USAGE: /path/to/the/modulename_without_extension +# @RETURN: A file in /etc/modprobe.d +# @DESCRIPTION: # This function will generate and install the neccessary modprobe.d file from the # information contained in the modules exported parms. # (see the variables MODULESD_<modulename>_ENABLED, MODULESD_<modulename>_EXAMPLES, @@ -543,12 +499,11 @@ generate_modulesd() { return 0 } -# internal function -# -# FUNCTION: find_module_params -# USAGE: A string "NAME(LIBDIR:SRCDIR:OBJDIR)" -# RETURN: The string "modulename:NAME libdir:LIBDIR srcdir:SRCDIR objdir:OBJDIR" -# DESCRIPTION: +# @FUNCTION: find_module_params +# @USAGE: A string "NAME(LIBDIR:SRCDIR:OBJDIR)" +# @INTERNAL +# @RETURN: The string "modulename:NAME libdir:LIBDIR srcdir:SRCDIR objdir:OBJDIR" +# @DESCRIPTION: # Analyze the specification NAME(LIBDIR:SRCDIR:OBJDIR) of one module as described in MODULE_NAMES. find_module_params() { debug-print-function ${FUNCNAME} $* @@ -621,10 +576,6 @@ linux-mod_pkg_setup() { strip_modulenames; [[ -n ${MODULE_NAMES} ]] && check_modules_supported set_kvobj; - # Commented out with permission from johnm until a fixed version for arches - # who intentionally use different kernel and userland compilers can be - # introduced - Jason Wever <weeve@gentoo.org>, 23 Oct 2005 - #check_vermagic; } # @FUNCTION: linux-mod_pkg_setup_binary @@ -645,6 +596,9 @@ linux-mod_pkg_setup_binary() { linux-info_pkg_setup; } +# @FUNCTION: strip_modulenames +# @DESCRIPTION: +# Remove modules from being built automatically using the default src_compile/src_install strip_modulenames() { debug-print-function ${FUNCNAME} $* @@ -719,7 +673,7 @@ linux-mod_src_compile() { fi done - set_arch_to_portage + set_arch_to_pkgmgr ABI="${myABI}" } @@ -757,7 +711,22 @@ linux-mod_src_install() { einfo "Installing ${modulename} module" cd "${objdir}" || die "${objdir} does not exist" insinto "${INSTALL_MOD_PATH}"/lib/modules/${KV_FULL}/${libdir} - doins ${modulename}.${KV_OBJ} || die "doins ${modulename}.${KV_OBJ} failed" + + # check here for CONFIG_MODULE_COMPRESS_<compression option> (NONE, GZIP, XZ, ZSTD) + # and similarily compress the module being built if != NONE. + + if linux_chkconfig_present MODULE_COMPRESS_XZ; then + xz ${modulename}.${KV_OBJ} + doins ${modulename}.${KV_OBJ}.xz || die "doins ${modulename}.${KV_OBJ}.xz failed" + elif linux_chkconfig_present MODULE_COMPRESS_GZIP; then + gzip ${modulename}.${KV_OBJ} + doins ${modulename}.${KV_OBJ}.gz || die "doins ${modulename}.${KV_OBJ}.gz failed" + elif linux_chkconfig_present MODULE_COMPRESS_ZSTD; then + zstd ${modulename}.${KV_OBJ} + doins ${modulename}.${KV_OBJ}.zst || die "doins ${modulename}.${KV_OBJ}.zst failed" + else + doins ${modulename}.${KV_OBJ} || die "doins ${modulename}.${KV_OBJ} failed" + fi cd "${OLDPWD}" generate_modulesd "${objdir}/${modulename}" diff --git a/eclass/llvm.org.eclass b/eclass/llvm.org.eclass index 0ddd48b19e46..29140a294804 100644 --- a/eclass/llvm.org.eclass +++ b/eclass/llvm.org.eclass @@ -47,6 +47,12 @@ esac # the correct branch to use. _LLVM_MASTER_MAJOR=15 +# @ECLASS_VARIABLE: _LLVM_NEWEST_MANPAGE_RELEASE +# @INTERNAL +# @DESCRIPTION: +# The newest release of LLVM for which manpages were generated. +_LLVM_NEWEST_MANPAGE_RELEASE=14.0.6 + # @ECLASS_VARIABLE: _LLVM_SOURCE_TYPE # @INTERNAL # @DESCRIPTION: @@ -66,6 +72,10 @@ fi inherit multiprocessing +if ver_test -ge 14.0.5; then + inherit verify-sig +fi + # == control variables == @@ -86,9 +96,10 @@ inherit multiprocessing # @ECLASS_VARIABLE: LLVM_MANPAGES # @DEFAULT_UNSET # @DESCRIPTION: -# Set to 'build', include the dependency on dev-python/sphinx to build -# the manpages. If set to 'pregenerated', fetch and install -# pregenerated manpages from the archive. +# Set to a non-empty value in ebuilds that build manpages via Sphinx. +# The eclass will either include the dependency on dev-python/sphinx +# or pull the pregenerated manpage tarball depending on the package +# version. # @ECLASS_VARIABLE: LLVM_PATCHSET # @DEFAULT_UNSET @@ -150,7 +161,9 @@ case ${PV} in ) ;; *) - ALL_LLVM_EXPERIMENTAL_TARGETS=( ARC CSKY LoongArch M68k ) + ALL_LLVM_EXPERIMENTAL_TARGETS=( + ARC CSKY DirectX LoongArch M68k SPIRV + ) ALL_LLVM_PRODUCTION_TARGETS=( AArch64 AMDGPU ARM AVR BPF Hexagon Lanai Mips MSP430 NVPTX PowerPC RISCV Sparc SystemZ VE WebAssembly X86 XCore @@ -186,8 +199,24 @@ llvm.org_set_globals() { [[ ${PV} != ${_LLVM_MASTER_MAJOR}.* ]] && EGIT_BRANCH="release/${PV%%.*}.x" elif [[ ${_LLVM_SOURCE_TYPE} == tar ]]; then - SRC_URI+=" - https://github.com/llvm/llvm-project/archive/llvmorg-${PV/_/-}.tar.gz" + if ver_test -ge 14.0.5; then + SRC_URI+=" + https://github.com/llvm/llvm-project/releases/download/llvmorg-${PV}/llvm-project-${PV}.src.tar.xz + verify-sig? ( + https://github.com/llvm/llvm-project/releases/download/llvmorg-${PV}/llvm-project-${PV}.src.tar.xz.sig + ) + " + BDEPEND+=" + verify-sig? ( + sec-keys/openpgp-keys-llvm + ) + " + VERIFY_SIG_OPENPGP_KEY_PATH=${BROOT}/usr/share/openpgp-keys/llvm.asc + else + SRC_URI+=" + https://github.com/llvm/llvm-project/archive/llvmorg-${PV/_/-}.tar.gz + " + fi else die "Invalid _LLVM_SOURCE_TYPE: ${LLVM_SOURCE_TYPE}" fi @@ -199,25 +228,22 @@ llvm.org_set_globals() { RESTRICT+=" !test? ( test )" fi - case ${LLVM_MANPAGES:-__unset__} in - __unset__) - # no manpage support - ;; - build) - IUSE+=" doc" - # NB: this is not always the correct dep but it does no harm - BDEPEND+=" dev-python/sphinx" - ;; - pregenerated) + if [[ ${LLVM_MANPAGES} ]]; then + # use pregenerated tarball for releases + # up to _LLVM_NEWEST_MANPAGE_RELEASE + if llvm_manpage_dist_available; then IUSE+=" doc" SRC_URI+=" !doc? ( https://dev.gentoo.org/~mgorny/dist/llvm/llvm-${PV}-manpages.tar.bz2 - )" - ;; - *) - die "Invalid LLVM_MANPAGES=${LLVM_MANPAGES}" - esac + ) + " + else + IUSE+=" doc" + # NB: this is not always the correct dep but it does no harm + BDEPEND+=" dev-python/sphinx" + fi + fi if [[ -n ${LLVM_PATCHSET} ]]; then SRC_URI+=" @@ -275,10 +301,24 @@ llvm.org_src_unpack() { default_src_unpack else local archive=llvmorg-${PV/_/-}.tar.gz + if ver_test -ge 14.0.5; then + archive=llvm-project-${PV/_/-}.src.tar.xz + if use verify-sig; then + verify-sig_verify_detached \ + "${DISTDIR}/${archive}" "${DISTDIR}/${archive}.sig" + fi + fi + ebegin "Unpacking from ${archive}" - tar -x -z -o --strip-components 1 \ - -f "${DISTDIR}/${archive}" \ - "${components[@]/#/llvm-project-${archive%.tar*}/}" || die + if ver_test -ge 14.0.5; then + tar -x -J -o --strip-components 1 \ + -f "${DISTDIR}/${archive}" \ + "${components[@]/#/${archive%.tar*}/}" || die + else + tar -x -z -o --strip-components 1 \ + -f "${DISTDIR}/${archive}" \ + "${components[@]/#/llvm-project-${archive%.tar*}/}" || die + fi eend ${?} # unpack all remaining distfiles @@ -354,12 +394,21 @@ get_lit_flags() { echo "-vv;-j;${LIT_JOBS:-$(makeopts_jobs)}" } +# @FUNCTION: llvm_manpage_dist_available +# @DESCRIPTION: +# Return true (0) if this LLVM version features prebuilt manpage +# tarball, false (1) otherwise. +llvm_manpage_dist_available() { + [[ ${_LLVM_SOURCE_TYPE} == tar ]] && + ver_test "${PV}" -le "${_LLVM_NEWEST_MANPAGE_RELEASE}" +} + # @FUNCTION: llvm_are_manpages_built # @DESCRIPTION: # Return true (0) if manpages are going to be built from source, # false (1) if preinstalled manpages will be used. llvm_are_manpages_built() { - use doc || [[ ${LLVM_MANPAGES} == build ]] + use doc || ! llvm_manpage_dist_available } # @FUNCTION: llvm_install_manpages diff --git a/eclass/mercurial.eclass b/eclass/mercurial.eclass index 8f0e6edfeb0b..2616b88311cf 100644 --- a/eclass/mercurial.eclass +++ b/eclass/mercurial.eclass @@ -94,6 +94,10 @@ BDEPEND="dev-vcs/mercurial" # users. EHG_OFFLINE="${EHG_OFFLINE:-${EVCS_OFFLINE}}" +# @ECLASS_VARIABLE: EHG_BOOTSTRAP +# @DESCRIPTION: +# Command to be executed after checkout and clone of the specified repository. + # @FUNCTION: mercurial_fetch # @USAGE: [repository_uri] [module] [sourcedir] # @DESCRIPTION: @@ -171,10 +175,6 @@ mercurial_fetch() { mercurial_bootstrap() { debug-print-function ${FUNCNAME} "$@" - # @ECLASS_VARIABLE: EHG_BOOTSTRAP - # @DESCRIPTION: - # Command to be executed after checkout and clone of the specified - # repository. if [[ ${EHG_BOOTSTRAP} ]]; then pushd "${S}" > /dev/null einfo "Starting bootstrap" diff --git a/eclass/mozcoreconf-v5.eclass b/eclass/mozcoreconf-v5.eclass index b01ffe1858e0..8da12ab0f939 100644 --- a/eclass/mozcoreconf-v5.eclass +++ b/eclass/mozcoreconf-v5.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: mozcoreconf-v5.eclass @@ -105,12 +105,6 @@ moz_pkgsetup() { # false positives when toplevel configure passes downwards. export QA_CONFIGURE_OPTIONS=".*" - if [[ $(gcc-major-version) -eq 3 ]]; then - ewarn "Unsupported compiler detected, DO NOT file bugs for" - ewarn "outdated compilers. Bugs opened with gcc-3 will be closed" - ewarn "invalid." - fi - python-any-r1_pkg_setup } @@ -157,9 +151,9 @@ mozconfig_init() { #################################### # Set optimization level - if [[ $(gcc-major-version) -ge 7 ]]; then - mozconfig_annotate "Workaround known breakage" --enable-optimize=-O2 - elif [[ ${ARCH} == hppa ]]; then + mozconfig_annotate "Workaround known breakage" --enable-optimize=-O2 + + if [[ ${ARCH} == hppa ]]; then mozconfig_annotate "more than -O0 causes a segfault on hppa" --enable-optimize=-O0 elif [[ ${ARCH} == x86 ]]; then mozconfig_annotate "less then -O2 causes a segfault on x86" --enable-optimize=-O2 @@ -214,10 +208,8 @@ mozconfig_init() { ;; esac - # We need to append flags for gcc-6 support - if [[ $(gcc-major-version) -ge 6 ]]; then - append-cxxflags -fno-delete-null-pointer-checks -fno-lifetime-dse -fno-schedule-insns2 - fi + # We need to append flags for >= gcc-6 support + append-cxxflags -fno-delete-null-pointer-checks -fno-lifetime-dse -fno-schedule-insns2 # Use the MOZILLA_FIVE_HOME for the rpath append-ldflags -Wl,-rpath="${MOZILLA_FIVE_HOME}",--enable-new-dtags diff --git a/eclass/multilib.eclass b/eclass/multilib.eclass index ec2676cb6cfb..8590bbdfbff0 100644 --- a/eclass/multilib.eclass +++ b/eclass/multilib.eclass @@ -422,9 +422,9 @@ multilib_env() { # the default abi is set to the 1-level libdir default - local __libdir_riscvdefaultabi_variable="LIBDIR_${DEFAULT_ABI}" - local __libdir_riscvdefaultabi=${!__libdir_riscvdefaultabi_variable} - export ${__libdir_riscvdefaultabi_variable}=${__libdir_riscvdefaultabi:-lib64} + local _libdir_riscvdefaultabi_variable="LIBDIR_${DEFAULT_ABI}" + local _libdir_riscvdefaultabi=${!_libdir_riscvdefaultabi_variable} + export ${_libdir_riscvdefaultabi_variable}=${_libdir_riscvdefaultabi:-lib64} # all other abi are set to the 2-level libdir default @@ -454,9 +454,9 @@ multilib_env() { # the default abi is set to the 1-level libdir default - local __libdir_riscvdefaultabi_variable="LIBDIR_${DEFAULT_ABI}" - local __libdir_riscvdefaultabi=${!__libdir_riscvdefaultabi_variable} - export ${__libdir_riscvdefaultabi_variable}=${__libdir_riscvdefaultabi:-lib} + local _libdir_riscvdefaultabi_variable="LIBDIR_${DEFAULT_ABI}" + local _libdir_riscvdefaultabi=${!_libdir_riscvdefaultabi_variable} + export ${_libdir_riscvdefaultabi_variable}=${_libdir_riscvdefaultabi:-lib} # all other abi are set to the 2-level libdir default diff --git a/eclass/postgres.eclass b/eclass/postgres.eclass index de2d0a28761b..ec5242be59f8 100644 --- a/eclass/postgres.eclass +++ b/eclass/postgres.eclass @@ -27,7 +27,7 @@ esac # @DESCRIPTION: # List of versions to reverse sort POSTGRES_COMPAT slots -_POSTGRES_ALL_VERSIONS=( 9999 14 13 12 11 10 9.6 9.5 9.4 9.3 9.2 ) +_POSTGRES_ALL_VERSIONS=( 9999 14 13 12 11 10 ) diff --git a/eclass/python-any-r1.eclass b/eclass/python-any-r1.eclass index 2051b5e89b81..fc66434cc6bf 100644 --- a/eclass/python-any-r1.eclass +++ b/eclass/python-any-r1.eclass @@ -139,7 +139,7 @@ EXPORT_FUNCTIONS pkg_setup # Example use: # @CODE # python_check_deps() { -# has_version "dev-python/foo[${PYTHON_USEDEP}]" +# python_has_version "dev-python/foo[${PYTHON_USEDEP}]" # } # @CODE # @@ -161,7 +161,7 @@ EXPORT_FUNCTIONS pkg_setup # Example use: # @CODE # python_check_deps() { -# has_version "dev-python/bar[${PYTHON_SINGLE_USEDEP}]" +# python_has_version "dev-python/bar[${PYTHON_SINGLE_USEDEP}]" # } # @CODE # @@ -228,9 +228,9 @@ if [[ ! ${_PYTHON_ANY_R1} ]]; then # dev-python/baz[${PYTHON_USEDEP}] )')" # # python_check_deps() { -# has_version "dev-python/foo[${PYTHON_SINGLE_USEDEP}]" \ -# && { has_version "dev-python/bar[${PYTHON_USEDEP}]" \ -# || has_version "dev-python/baz[${PYTHON_USEDEP}]"; } +# python_has_version "dev-python/foo[${PYTHON_SINGLE_USEDEP}]" \ +# && { python_has_version "dev-python/bar[${PYTHON_USEDEP}]" \ +# || python_has_version "dev-python/baz[${PYTHON_USEDEP}]"; } # } # @CODE # diff --git a/eclass/python-r1.eclass b/eclass/python-r1.eclass index 2f8cfa0316d9..3471e17bdde6 100644 --- a/eclass/python-r1.eclass +++ b/eclass/python-r1.eclass @@ -625,6 +625,24 @@ _python_multibuild_wrapper() { python_foreach_impl() { debug-print-function ${FUNCNAME} "${@}" + if [[ ${_DISTUTILS_R1} ]]; then + if has "${EBUILD_PHASE}" prepare configure compile test install && + [[ ! ${_DISTUTILS_CALLING_FOREACH_IMPL} && + ! ${_DISTUTILS_FOREACH_IMPL_WARNED} ]] + then + eqawarn "python_foreach_impl has been called directly while using distutils-r1." + eqawarn "Please redefine python_*() phase functions to meet your expectations" + eqawarn "instead." + _DISTUTILS_FOREACH_IMPL_WARNED=1 + + if ! has "${EAPI}" 6 7 8; then + die "Calling python_foreach_impl from distutils-r1 is banned in EAPI ${EAPI}" + fi + fi + # undo the eclass-set value to catch nested calls + local _DISTUTILS_CALLING_FOREACH_IMPL= + fi + local MULTIBUILD_VARIANTS _python_obtain_impls diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass index 67dc5bf754d6..b9cf9c03caeb 100644 --- a/eclass/python-utils-r1.eclass +++ b/eclass/python-utils-r1.eclass @@ -696,6 +696,9 @@ python_scriptinto() { python_doexe() { debug-print-function ${FUNCNAME} "${@}" + [[ ${EBUILD_PHASE} != install ]] && + die "${FUNCNAME} can only be used in src_install" + local f for f; do python_newexe "${f}" "${f##*/}" @@ -714,6 +717,8 @@ python_doexe() { python_newexe() { debug-print-function ${FUNCNAME} "${@}" + [[ ${EBUILD_PHASE} != install ]] && + die "${FUNCNAME} can only be used in src_install" [[ ${EPYTHON} ]] || die 'No Python implementation set (EPYTHON is null).' [[ ${#} -eq 2 ]] || die "Usage: ${FUNCNAME} <path> <new-name>" @@ -762,6 +767,9 @@ python_newexe() { python_doscript() { debug-print-function ${FUNCNAME} "${@}" + [[ ${EBUILD_PHASE} != install ]] && + die "${FUNCNAME} can only be used in src_install" + local _PYTHON_REWRITE_SHEBANG=1 python_doexe "${@}" } @@ -786,6 +794,9 @@ python_doscript() { python_newscript() { debug-print-function ${FUNCNAME} "${@}" + [[ ${EBUILD_PHASE} != install ]] && + die "${FUNCNAME} can only be used in src_install" + local _PYTHON_REWRITE_SHEBANG=1 python_newexe "${@}" } @@ -805,10 +816,10 @@ python_newscript() { # site-packages directory. # # In the relative case, the exact path is determined directly -# by each python_doscript/python_newscript function. Therefore, -# python_moduleinto can be safely called before establishing the Python -# interpreter and/or a single call can be used to set the path correctly -# for multiple implementations, as can be seen in the following example. +# by each python_domodule invocation. Therefore, python_moduleinto +# can be safely called before establishing the Python interpreter and/or +# a single call can be used to set the path correctly for multiple +# implementations, as can be seen in the following example. # # Example: # @CODE @@ -832,6 +843,10 @@ python_moduleinto() { # and packages (directories). All listed files will be installed # for all enabled implementations, and compiled afterwards. # +# The files are installed into ${D} when run in src_install() phase. +# Otherwise, they are installed into ${BUILD_DIR}/install location +# that is suitable for picking up by distutils-r1 in PEP517 mode. +# # Example: # @CODE # src_install() { @@ -854,13 +869,24 @@ python_domodule() { d=${sitedir#${EPREFIX}}/${_PYTHON_MODULEROOT//.//} fi - ( - insopts -m 0644 - insinto "${d}" - doins -r "${@}" || return ${?} - ) - - python_optimize "${ED%/}/${d}" + if [[ ${EBUILD_PHASE} == install ]]; then + ( + insopts -m 0644 + insinto "${d}" + doins -r "${@}" || return ${?} + ) + python_optimize "${ED%/}/${d}" + elif [[ -n ${BUILD_DIR} ]]; then + local dest=${BUILD_DIR}/install${EPREFIX}/${d} + mkdir -p "${dest}" || die + cp -pR "${@}" "${dest}/" || die + ( + cd "${dest}" && + chmod -R a+rX "${@##*/}" + ) || die + else + die "${FUNCNAME} can only be used in src_install or with BUILD_DIR set" + fi } # @FUNCTION: python_doheader @@ -879,6 +905,8 @@ python_domodule() { python_doheader() { debug-print-function ${FUNCNAME} "${@}" + [[ ${EBUILD_PHASE} != install ]] && + die "${FUNCNAME} can only be used in src_install" [[ ${EPYTHON} ]] || die 'No Python implementation set (EPYTHON is null).' local includedir=$(python_get_includedir) @@ -1318,6 +1346,11 @@ epytest() { # remove common temporary directories left over by pytest plugins rm -rf .hypothesis .pytest_cache || die + # pytest plugins create additional .pyc files while testing + # see e.g. https://bugs.gentoo.org/847235 + if [[ -n ${BUILD_DIR} && -d ${BUILD_DIR} ]]; then + find "${BUILD_DIR}" -name '*-pytest-*.pyc' -delete || die + fi return ${ret} } diff --git a/eclass/qmail.eclass b/eclass/qmail.eclass index 471f2fe7ce5e..ed53bca56fae 100644 --- a/eclass/qmail.eclass +++ b/eclass/qmail.eclass @@ -169,9 +169,6 @@ qmail_base_install() { doexe qmail-queue ) - - declare -F qmail_base_install_hook >/dev/null && \ - qmail_base_install_hook } qmail_config_install() { @@ -182,9 +179,6 @@ qmail_config_install() { einfo "Installing configuration sanity checker and launcher" insinto "${QMAIL_HOME}"/bin doins "${GENQMAIL_S}"/control/qmail-config-system - - declare -F qmail_config_install_hook >/dev/null && \ - qmail_config_install_hook } qmail_man_install() { @@ -200,9 +194,6 @@ qmail_man_install() { else dodoc CHANGES.md FAQ.md SECURITY.md THOUGHTS.md UPGRADE.md fi - - declare -F qmail_man_install_hook >/dev/null && \ - qmail_man_install_hook } qmail_sendmail_install() { @@ -211,9 +202,6 @@ qmail_sendmail_install() { dosym "${QMAIL_HOME}"/bin/sendmail /usr/sbin/sendmail dosym "${QMAIL_HOME}"/bin/sendmail /usr/lib/sendmail - - declare -F qmail_sendmail_install_hook >/dev/null && \ - qmail_sendmail_install_hook } qmail_maildir_install() { @@ -245,9 +233,6 @@ qmail_maildir_install() { done ) - - declare -F qmail_maildir_install_hook >/dev/null && \ - qmail_maildir_install_hook } qmail_tcprules_install() { @@ -280,9 +265,6 @@ qmail_supervise_install() { qmail_supervise_install_one qmail-pop3d use ssl && qmail_supervise_install_one qmail-pop3sd fi - - declare -F qmail_supervise_install_hook >/dev/null && \ - qmail_supervise_install_hook } qmail_spp_install() { @@ -295,9 +277,6 @@ qmail_spp_install() { for i in authlog mfdnscheck ifauthnext tarpit; do dospp "${GENQMAIL_S}"/spp/${i} done - - declare -F qmail_spp_install_hook >/dev/null && \ - qmail_spp_install_hook } qmail_ssl_install() { @@ -317,9 +296,6 @@ qmail_ssl_install() { doexe "${GENQMAIL_S}"/ssl/qmail-genrsacert.sh keepdir "${QMAIL_HOME}"/control/tlshosts - - declare -F qmail_ssl_install_hook >/dev/null && \ - qmail_ssl_install_hook } qmail_src_install() { @@ -433,7 +409,7 @@ qmail_config_fast() { } qmail_tcprules_config() { - local localips ip tcpstring line proto f + local localips ip tcpstring proto f einfo "Accepting relaying by default from all ips configured on this machine." @@ -449,10 +425,9 @@ qmail_tcprules_config() { tcpstring=':allow,RELAYCLIENT="",RBLSMTPD=""' for ip in ${localips}; do - line="${ip}${tcpstring}" for proto in smtp qmtp qmqp; do f="${EROOT}${TCPRULES_DIR}/tcp.qmail-${proto}" - egrep -qs "${line}" "${f}" || echo "${line}" >> "${f}" + grep -qs "^${ip}:" "${f}" || echo "${ip}${tcpstring}" >> "${f}" done done } diff --git a/eclass/qt5-build.eclass b/eclass/qt5-build.eclass index 6da97387c1ab..86082a07f4bc 100644 --- a/eclass/qt5-build.eclass +++ b/eclass/qt5-build.eclass @@ -63,6 +63,13 @@ readonly QT5_PV # The upstream package name of the module this package belongs to. # Used for SRC_URI and S. +# @ECLASS_VARIABLE: _QT5_GENTOOPATCHSET_REV +# @DEFAULT_UNSET +# @INTERNAL +# @DESCRIPTION: +# Gentoo downstream patchset version applied over qtbase. Used for SRC_URI and +# applied in src_prepare. + # @ECLASS_VARIABLE: QT5_TARGET_SUBDIRS # @DEFAULT_UNSET # @DESCRIPTION: @@ -100,7 +107,7 @@ if [[ ${PN} != qtwebengine ]]; then *9999 ) inherit kde.org # kde/5.15 branch ;; - 5.15.[3-9]* ) + 5.15.[3-9]* | 5.15.??* ) # official stable release _QT5_P=${QT5_MODULE}-everywhere-opensource-src-${PV} HOMEPAGE="https://www.qt.io/" @@ -115,6 +122,11 @@ if [[ ${PN} != qtwebengine ]]; then esac fi +if [[ ${QT5_MODULE} == qtbase ]] && [[ ${PV} == 5.15.[5-9]* ]]; then + _QT5_GENTOOPATCHSET_REV=1 + SRC_URI+=" https://dev.gentoo.org/~asturm/distfiles/qtbase-5.15-gentoo-patchset-${_QT5_GENTOOPATCHSET_REV}.tar.xz" +fi + # @ECLASS_VARIABLE: QT5_BUILD_DIR # @OUTPUT_VARIABLE # @DESCRIPTION: @@ -189,6 +201,8 @@ qt5-build_src_prepare() { # Respect build variables in configure tests (bug #639494) sed -i -e "s|\"\$outpath/bin/qmake\" \"\$relpathMangled\" -- \"\$@\"|& $(qt5_qmake_args) |" configure || die + + [[ -n ${_QT5_GENTOOPATCHSET_REV} ]] && eapply "${WORKDIR}/qtbase-5.15-gentoo-patchset-${_QT5_GENTOOPATCHSET_REV}" fi [[ -n ${QT5_KDEPATCHSET_REV} ]] && eapply "${WORKDIR}/${QT5_MODULE}-${PV}-gentoo-kde-${QT5_KDEPATCHSET_REV}" diff --git a/eclass/rebar.eclass b/eclass/rebar.eclass index e7a64bb7a7e2..5ee99aed445c 100644 --- a/eclass/rebar.eclass +++ b/eclass/rebar.eclass @@ -39,7 +39,7 @@ BDEPEND=" >=sys-apps/gawk-4.1 " if [[ ${EAPI} == 6 ]]; then - DEPEND+="${BDEPEND}" + DEPEND+=" ${BDEPEND}" fi # @ECLASS_VARIABLE: REBAR_APP_SRC diff --git a/eclass/ruby-fakegem.eclass b/eclass/ruby-fakegem.eclass index 41dbb1e16340..6f561f4f6a2f 100644 --- a/eclass/ruby-fakegem.eclass +++ b/eclass/ruby-fakegem.eclass @@ -210,6 +210,11 @@ case ${EAPI} in ;; esac +# Many (but not all) extensions use pkgconfig in src_configure. +if [[ ${#RUBY_FAKEGEM_EXTENSIONS[@]} -gt 0 ]]; then + BDEPEND+=" virtual/pkgconfig " +fi + # @FUNCTION: ruby_fakegem_gemsdir # @RETURN: Returns the gem data directory # @DESCRIPTION: @@ -564,10 +569,10 @@ each_fakegem_test() { esac } +# @FUNCTION: each_ruby_test +# @DESCRIPTION: +# Run the tests for this package. if [[ ${RUBY_FAKEGEM_RECIPE_TEST} != none ]]; then - # @FUNCTION: each_ruby_test - # @DESCRIPTION: - # Run the tests for this package. each_ruby_test() { each_fakegem_test } diff --git a/eclass/ruby-ng.eclass b/eclass/ruby-ng.eclass index 70cb5be74b87..f0d6c4f6f6c4 100644 --- a/eclass/ruby-ng.eclass +++ b/eclass/ruby-ng.eclass @@ -604,7 +604,7 @@ _each_ruby_check_install() { # that's what changes between two implementations (otherwise you'd get false # positives now that Ruby 1.9.2 installs with the same sitedir as 1.8) ${scancmd} -qnR "${D}${sitelibdir}" "${D}${sitelibdir/site_ruby/gems}" \ - | fgrep -v "${libruby_soname}" \ + | grep -F -v "${libruby_soname}" \ | grep -E -v "${RUBY_QA_ALLOWED_LIBS}" \ > "${T}"/ruby-ng-${_ruby_implementation}-mislink.log diff --git a/eclass/toolchain-funcs.eclass b/eclass/toolchain-funcs.eclass index 77fb304940b2..17c075895d55 100644 --- a/eclass/toolchain-funcs.eclass +++ b/eclass/toolchain-funcs.eclass @@ -1,4 +1,4 @@ -# Copyright 2002-2021 Gentoo Authors +# Copyright 2002-2022 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 # @ECLASS: toolchain-funcs.eclass @@ -453,6 +453,9 @@ econf_build() { tc-ld-is-gold() { local out + # Ensure ld output is in English. + local -x LC_ALL=C + # First check the linker directly. out=$($(tc-getLD "$@") --version 2>&1) if [[ ${out} == *"GNU gold"* ]] ; then @@ -483,6 +486,9 @@ tc-ld-is-gold() { tc-ld-is-lld() { local out + # Ensure ld output is in English. + local -x LC_ALL=C + # First check the linker directly. out=$($(tc-getLD "$@") --version 2>&1) if [[ ${out} == *"LLD"* ]] ; then @@ -569,11 +575,12 @@ tc-ld-force-bfd() { fi } -# @FUNCTION: tc-has-openmp +# @FUNCTION: _tc-has-openmp +# @INTERNAL # @USAGE: [toolchain prefix] # @DESCRIPTION: # See if the toolchain supports OpenMP. -tc-has-openmp() { +_tc-has-openmp() { local base="${T}/test-tc-openmp" cat <<-EOF > "${base}.c" #include <omp.h> @@ -593,6 +600,16 @@ tc-has-openmp() { return ${ret} } +# @FUNCTION: tc-has-openmp +# @DEPRECATED: tc-check-openmp +# @USAGE: [toolchain prefix] +# @DESCRIPTION: +# See if the toolchain supports OpenMP. This function is deprecated and will be +# removed on 2023-01-01. +tc-has-openmp() { + _tc-has-openmp "$@" +} + # @FUNCTION: tc-check-openmp # @DESCRIPTION: # Test for OpenMP support with the current compiler and error out with @@ -600,8 +617,21 @@ tc-has-openmp() { # OpenMP support that has been requested by the ebuild. Using this function # to test for OpenMP support should be preferred over tc-has-openmp and # printing a custom message, as it presents a uniform interface to the user. +# +# You should test for any necessary OpenMP support in pkg_pretend in order to +# warn the user of required toolchain changes. You must still check for OpenMP +# support at build-time, e.g. +# @CODE +# pkg_pretend() { +# [[ ${MERGE_TYPE} != binary ]] && use openmp && tc-check-openmp +# } +# +# pkg_setup() { +# [[ ${MERGE_TYPE} != binary ]] && use openmp && tc-check-openmp +# } +# @CODE tc-check-openmp() { - if ! tc-has-openmp; then + if ! _tc-has-openmp; then eerror "Your current compiler does not support OpenMP!" if tc-is-gcc; then diff --git a/eclass/toolchain.eclass b/eclass/toolchain.eclass index 1bbacfa2bdb4..caabb5f25fa1 100644 --- a/eclass/toolchain.eclass +++ b/eclass/toolchain.eclass @@ -19,15 +19,15 @@ _TOOLCHAIN_ECLASS=1 DESCRIPTION="The GNU Compiler Collection" HOMEPAGE="https://gcc.gnu.org/" -inherit flag-o-matic gnuconfig libtool multilib pax-utils toolchain-funcs prefix +inherit edo flag-o-matic gnuconfig libtool multilib pax-utils toolchain-funcs prefix tc_is_live() { [[ ${PV} == *9999* ]] } if tc_is_live ; then - EGIT_REPO_URI="https://gcc.gnu.org/git/gcc.git" - # naming style: + EGIT_REPO_URI="https://gcc.gnu.org/git/gcc.git https://github.com/gcc-mirror/gcc" + # Naming style: # gcc-10.1.0_pre9999 -> gcc-10-branch # Note that the micro version is required or lots of stuff will break. # To checkout master set gcc_LIVE_BRANCH="master" in the ebuild before @@ -35,6 +35,8 @@ if tc_is_live ; then EGIT_BRANCH="releases/${PN}-${PV%.?.?_pre9999}" EGIT_BRANCH=${EGIT_BRANCH//./_} inherit git-r3 +elif [[ -n ${TOOLCHAIN_USE_GIT_PATCHES} ]] ; then + inherit git-r3 fi FEATURES=${FEATURES/multilib-strict/} @@ -55,32 +57,90 @@ is_crosscompile() { [[ ${CHOST} != ${CTARGET} ]] } -# General purpose version check. Without a second arg matches up to minor version (x.x.x) +# @FUNCTION: tc_version_is_at_least +# @USAGE: ver1 [ver2] +# @DESCRIPTION: +# General purpose version check. Without a second argument, matches +# up to minor version (x.x.x). tc_version_is_at_least() { ver_test "${2:-${GCC_RELEASE_VER}}" -ge "$1" } -# General purpose version range check +# @FUNCTION: tc_version_is_between +# @USAGE: ver1 ver2 +# @DESCRIPTION: +# General purpose version range check. # Note that it matches up to but NOT including the second version tc_version_is_between() { tc_version_is_at_least "${1}" && ! tc_version_is_at_least "${2}" } +# @ECLASS_VARIABLE: TOOLCHAIN_GCC_PV +# @DEFAULT_UNSET +# @DESCRIPTION: +# Used to override GCC version. Useful for e.g. live ebuilds or snapshots. +# Defaults to ${PV}. + +# @ECLASS_VARIABLE: TOOLCHAIN_USE_GIT_PATCHES +# @DEFAULT_UNSET +# @DESCRIPTION: +# Used to force fetching patches from git. Useful for non-released versions +# of GCC where we don't want to keep creating patchset tarballs for a new +# release series (e.g. suppose 12.0 just got released, then adding snapshots +# for 13.0, we don't want to create new patchsets for every single 13.0 snapshot, +# so just grab patches from git each time if this variable is set). + +# @ECLASS_VARIABLE: TOOLCHAIN_PATCH_DEV +# @DEFAULT_UNSET +# @DESCRIPTION: +# Indicate the developer who hosts the patchset for an ebuild. + +# @ECLASS_VARIABLE: GCC_PV +# @INTERNAL +# @DESCRIPTION: +# Internal variable representing (spoofed) GCC version. GCC_PV=${TOOLCHAIN_GCC_PV:-${PV}} + +# @ECLASS_VARIABLE: GCC_PVR +# @INTERNAL +# @DESCRIPTION: +# Full GCC version including revision. GCC_PVR=${GCC_PV} [[ ${PR} != "r0" ]] && GCC_PVR=${GCC_PVR}-${PR} +# @ECLASS_VARIABLE: GCC_RELEASE_VER +# @INTERNAL +# @DESCRIPTION: # GCC_RELEASE_VER must always match 'gcc/BASE-VER' value. # It's an internal representation of gcc version used for: # - versioned paths on disk # - 'gcc -dumpversion' output. Must always match <digit>.<digit>.<digit>. GCC_RELEASE_VER=$(ver_cut 1-3 ${GCC_PV}) +# @ECLASS_VARIABLE: GCC_BRANCH_VER +# @INTERNAL +# @DESCRIPTION: +# GCC branch version. GCC_BRANCH_VER=$(ver_cut 1-2 ${GCC_PV}) +# @ECLASS_VARIABLE: GCCMAJOR +# @INTERNAL +# @DESCRIPTION: +# Major GCC version. GCCMAJOR=$(ver_cut 1 ${GCC_PV}) +# @ECLASS_VARIABLE: GCCMINOR +# @INTERNAL +# @DESCRIPTION: +# Minor GCC version. GCCMINOR=$(ver_cut 2 ${GCC_PV}) +# @ECLASS_VARIABLE: GCCMICRO +# @INTERNAL +# @DESCRIPTION: +# GCC micro version. GCCMICRO=$(ver_cut 3 ${GCC_PV}) +# @ECLASS_VARIABLE: GCC_CONFIG_VER +# @INTERNAL +# @DESCRIPTION: # Ideally this variable should allow for custom gentoo versioning # of binary and gcc-config names not directly tied to upstream # versioning. In practice it's hard to untangle from gcc/BASE-VER @@ -92,13 +152,13 @@ GCC_CONFIG_VER=${GCC_RELEASE_VER} # 1.2.3_pYYYYMMDD (or 1.2.3_preYYYYMMDD for unreleased major versions): weekly snapshots # 1.2.3_rcYYYYMMDD: release candidates if [[ ${GCC_PV} == *_pre* ]] ; then - # weekly snapshots + # Weekly snapshots SNAPSHOT=${GCCMAJOR}-${GCC_PV##*_pre} elif [[ ${GCC_PV} == *_p* ]] ; then - # weekly snapshots + # Weekly snapshots SNAPSHOT=${GCCMAJOR}-${GCC_PV##*_p} elif [[ ${GCC_PV} == *_rc* ]] ; then - # release candidates + # Release candidates SNAPSHOT=${GCC_PV%_rc*}-RC-${GCC_PV##*_rc} fi @@ -121,7 +181,7 @@ fi DATAPATH=${TOOLCHAIN_DATAPATH:-${PREFIX}/share/gcc-data/${CTARGET}/${GCC_CONFIG_VER}} -# Dont install in /usr/include/g++-v3/, but in gcc internal directory. +# Don't install in /usr/include/g++-v3/, but instead to gcc's internal directory. # We will handle /usr/include/g++-v3/ with gcc-config ... STDCXX_INCDIR=${TOOLCHAIN_STDCXX_INCDIR:-${LIBPATH}/include/g++-v${GCC_BRANCH_VER/\.*/}} @@ -137,7 +197,7 @@ tc_has_feature() { has "$1" "${TC_FEATURES[@]}" } -if [[ ${PN} != "kgcc64" && ${PN} != gcc-* ]] ; then +if [[ ${PN} != kgcc64 && ${PN} != gcc-* ]] ; then IUSE+=" debug +cxx +nptl" TC_FEATURES+=( nptl ) [[ -n ${PIE_VER} ]] && IUSE+=" nopie" [[ -n ${SPECS_VER} ]] && IUSE+=" nossp" @@ -148,11 +208,14 @@ if [[ ${PN} != "kgcc64" && ${PN} != gcc-* ]] ; then IUSE+=" objc-gc" TC_FEATURES+=( objc-gc ) IUSE+=" libssp objc++" IUSE+=" +openmp" + tc_version_is_at_least 4.3 && IUSE+=" fixed-point" tc_version_is_at_least 4.7 && IUSE+=" go" + # sanitizer support appeared in gcc-4.8, but <gcc-5 does not # support modern glibc. tc_version_is_at_least 5 && IUSE+=" +sanitize" TC_FEATURES+=( sanitize ) + # Note: # <gcc-4.8 supported graphite, it required forked ppl # versions which we dropped. Since graphite was also experimental in @@ -161,15 +224,18 @@ if [[ ${PN} != "kgcc64" && ${PN} != gcc-* ]] ; then # <gcc-6.5 supported graphite, it required old incompatible isl tc_version_is_at_least 6.5 && IUSE+=" graphite" TC_FEATURES+=( graphite ) + tc_version_is_between 4.9 8 && IUSE+=" cilk" tc_version_is_at_least 4.9 && IUSE+=" ada" tc_version_is_at_least 4.9 && IUSE+=" vtv" tc_version_is_at_least 5.0 && IUSE+=" jit" tc_version_is_between 5.0 9 && IUSE+=" mpx" tc_version_is_at_least 6.0 && IUSE+=" +pie +ssp +pch" + # systemtap is a gentoo-specific switch: bug #654748 tc_version_is_at_least 8.0 && IUSE+=" systemtap" TC_FEATURES+=( systemtap ) + tc_version_is_at_least 9.0 && IUSE+=" d" tc_version_is_at_least 9.1 && IUSE+=" lto" tc_version_is_at_least 10 && IUSE+=" cet" @@ -225,6 +291,9 @@ DEPEND="${RDEPEND}" if tc_has_feature gcj ; then DEPEND+=" gcj? ( + app-arch/zip + app-arch/unzip + >=media-libs/libart_lgpl-2.1 awt? ( x11-base/xorg-proto x11-libs/libXt @@ -234,9 +303,6 @@ if tc_has_feature gcj ; then x11-libs/pango virtual/pkgconfig ) - >=media-libs/libart_lgpl-2.1 - app-arch/zip - app-arch/unzip ) " fi @@ -262,10 +328,32 @@ if tc_has_feature valgrind; then BDEPEND+=" valgrind? ( dev-util/valgrind )" fi +if tc_version_is_at_least 12.0 ; then + # D in 12+ is self-hosting and needs D to bootstrap. + # TODO: package some binary we can use, like for Ada + # bug #840182 + BDEPEND+=" d? ( || ( sys-devel/gcc[d(-)] <sys-devel/gcc-12[d(-)] ) )" +fi + PDEPEND=">=sys-devel/gcc-config-2.3" #---->> S + SRC_URI essentials <<---- +# @ECLASS_VARIABLE: TOOLCHAIN_PATCH_SUFFIX +# @DESCRIPTION: +# Used to override compression used for for patchsets. +# Default is xz for EAPI 8+ and bz2 for older EAPIs. +if [[ ${EAPI} == 8 ]] ; then + : ${TOOLCHAIN_PATCH_SUFFIX:=xz} +else + # Older EAPIs + : ${TOOLCHAIN_PATCH_SUFFIX:=bz2} +fi + +# @ECLASS_VARIABLE: TOOLCHAIN_SET_S +# @DESCRIPTION: +# Used to override value of S for snapshots and such. Mainly useful +# if needing to set GCC_TARBALL_SRC_URI. : ${TOOLCHAIN_SET_S:=yes} # Set the source directory depending on whether we're using @@ -283,6 +371,31 @@ if [[ ${TOOLCHAIN_SET_S} == yes ]] ; then fi gentoo_urls() { + # slyfox's distfiles are mirrored to sam's devspace + declare -A devspace_urls=( + [soap]=HTTP~soap/distfiles/URI + [sam]=HTTP~sam/distfiles/sys-devel/gcc/URI + [slyfox]=HTTP~sam/distfiles/URI + [tamiko]=HTTP~tamiko/distfiles/URI + [zorry]=HTTP~zorry/patches/gcc/URI + [vapier]=HTTP~vapier/dist/URI + [blueness]=HTTP~blueness/dist/URI + ) + + # Newer ebuilds should set TOOLCHAIN_PATCH_DEV and we'll just + # return the full URL from the array. + if [[ -n ${TOOLCHAIN_PATCH_DEV} ]] ; then + local devspace_url=${devspace_urls[${TOOLCHAIN_PATCH_DEV}]} + if [[ -n ${devspace_url} ]] ; then + local devspace_url_exp=${devspace_url//HTTP/https:\/\/dev.gentoo.org\/} + devspace_url_exp=${devspace_url_exp//URI/$1} + echo ${devspace_url_exp} + return + fi + fi + + # But we keep the old fallback list for compatibility with + # older ebuilds (overlays etc). local devspace=" HTTP~soap/distfiles/URI HTTP~sam/distfiles/URI @@ -322,7 +435,7 @@ gentoo_urls() { # PIE_VER # PIE_GCC_VER # These variables control patching in various updates for the logic -# controlling Position Independant Executables. PIE_VER is expected +# controlling Position Independent Executables. PIE_VER is expected # to be the version of this patch, and PIE_GCC_VER the gcc version of # the patch: # An example: @@ -362,7 +475,7 @@ get_gcc_src_uri() { if tc_is_live ; then : # Nothing to do w/git snapshots. elif [[ -n ${GCC_TARBALL_SRC_URI} ]] ; then - # pull gcc tarball from another location. Frequently used by gnat-gpl. + # Pull gcc tarball from another location. Frequently used by gnat-gpl. GCC_SRC_URI="${GCC_TARBALL_SRC_URI}" elif [[ -n ${SNAPSHOT} ]] ; then GCC_SRC_URI="https://gcc.gnu.org/pub/gcc/snapshots/${SNAPSHOT}/gcc-${SNAPSHOT}.tar.xz" @@ -374,26 +487,18 @@ get_gcc_src_uri() { fi fi - local PATCH_SUFFIX="xz" - if ! tc_version_is_at_least 9.4.1_p20220317 || tc_version_is_between 9 9.5 \ - || tc_version_is_between 10 10.4 || tc_version_is_between 11 11.4 \ - || tc_version_is_between 12 12.0.1_pre20220424 ; then - # These are versions before we started to use .xz - PATCH_SUFFIX="bz2" - fi - [[ -n ${PATCH_VER} ]] && \ - GCC_SRC_URI+=" $(gentoo_urls gcc-${PATCH_GCC_VER}-patches-${PATCH_VER}.tar.${PATCH_SUFFIX})" + GCC_SRC_URI+=" $(gentoo_urls gcc-${PATCH_GCC_VER}-patches-${PATCH_VER}.tar.${TOOLCHAIN_PATCH_SUFFIX})" [[ -n ${MUSL_VER} ]] && \ - GCC_SRC_URI+=" $(gentoo_urls gcc-${MUSL_GCC_VER}-musl-patches-${MUSL_VER}.tar.${PATCH_SUFFIX})" + GCC_SRC_URI+=" $(gentoo_urls gcc-${MUSL_GCC_VER}-musl-patches-${MUSL_VER}.tar.${TOOLCHAIN_PATCH_SUFFIX})" [[ -n ${PIE_VER} ]] && \ - PIE_CORE=${PIE_CORE:-gcc-${PIE_GCC_VER}-piepatches-v${PIE_VER}.tar.${PATCH_SUFFIX}} && \ + PIE_CORE=${PIE_CORE:-gcc-${PIE_GCC_VER}-piepatches-v${PIE_VER}.tar.${TOOLCHAIN_PATCH_SUFFIX}} && \ GCC_SRC_URI+=" $(gentoo_urls ${PIE_CORE})" # gcc minispec for the hardened gcc 4 compiler [[ -n ${SPECS_VER} ]] && \ - GCC_SRC_URI+=" $(gentoo_urls gcc-${SPECS_GCC_VER}-specs-${SPECS_VER}.tar.${PATCH_SUFFIX})" + GCC_SRC_URI+=" $(gentoo_urls gcc-${SPECS_GCC_VER}-specs-${SPECS_VER}.tar.${TOOLCHAIN_PATCH_SUFFIX})" if tc_has_feature gcj ; then if tc_version_is_at_least 4.5 ; then @@ -431,19 +536,54 @@ toolchain_pkg_pretend() { #---->> pkg_setup <<---- toolchain_pkg_setup() { - # we dont want to use the installed compiler's specs to build gcc + # We don't want to use the installed compiler's specs to build gcc unset GCC_SPECS - unset LANGUAGES #265283 + + # bug #265283 + unset LANGUAGES + + # See https://www.gnu.org/software/make/manual/html_node/Parallel-Output.html + # Avoid really confusing logs from subconfigure spam, makes logs far + # more legible. + MAKEOPTS="--output-sync=line ${MAKEOPTS}" } #---->> src_unpack <<---- +# @FUNCTION: toolchain_fetch_git_patches +# @INTERNAL +# @DESCRIPTION: +# Fetch patches from Gentoo's gcc-patches repository. +toolchain_fetch_git_patches() { + local gcc_patches_repo="https://anongit.gentoo.org/git/proj/gcc-patches.git https://github.com/gentoo/gcc-patches" + + # If we weren't given a patchset number, pull it from git too. + einfo "Fetching patchset from git as PATCH_VER is unset" + EGIT_REPO_URI=${gcc_patches_repo} EGIT_BRANCH="master" \ + EGIT_CHECKOUT_DIR="${WORKDIR}"/patch.tmp \ + git-r3_src_unpack + + mkdir "${WORKDIR}"/patch || die + mv "${WORKDIR}"/patch.tmp/${PATCH_GCC_VER}/gentoo/* "${WORKDIR}"/patch || die + + if [[ -n ${MUSL_VER} || -d "${WORKDIR}"/musl ]] && [[ ${CTARGET} == *musl* ]] ; then + mkdir "${WORKDIR}"/musl || die + mv "${WORKDIR}"/patch.tmp/${PATCH_GCC_VER}/musl/* "${WORKDIR}"/musl || die + fi +} + toolchain_src_unpack() { if tc_is_live ; then git-r3_src_unpack + + if [[ -z ${PATCH_VER} ]] && ! use vanilla ; then + toolchain_fetch_git_patches + fi + elif [[ -z ${PATCH_VER} && -n ${TOOLCHAIN_USE_GIT_PATCHES} ]] ; then + toolchain_fetch_git_patches fi - default_src_unpack + default } #---->> src_prepare <<---- @@ -467,9 +607,9 @@ toolchain_src_prepare() { make_gcc_hard fi - # make sure the pkg config files install into multilib dirs. - # since we configure with just one --libdir, we can't use that - # (as gcc itself takes care of building multilibs). #435728 + # Make sure the pkg-config files install into multilib dirs. + # Since we configure with just one --libdir, we can't use that + # (as gcc itself takes care of building multilibs). bug #435728 find "${S}" -name Makefile.in \ -exec sed -i '/^pkgconfigdir/s:=.*:=$(toolexeclibdir)/pkgconfig:' {} + || die @@ -504,7 +644,7 @@ toolchain_src_prepare() { gnuconfig_update - # update configure files + # Update configure files local f einfo "Fixing misc issues in configure files" for f in $(grep -l 'autoconf version 2.13' $(find "${S}" -name configure)) ; do @@ -513,9 +653,10 @@ toolchain_src_prepare() { || eerror "Please file a bug about this" eend $? done - sed -i 's|A-Za-z0-9|[:alnum:]|g' "${S}"/gcc/*.awk || die #215828 + # bug #215828 + sed -i 's|A-Za-z0-9|[:alnum:]|g' "${S}"/gcc/*.awk || die - # Prevent new texinfo from breaking old versions (see #198182, #464008) + # Prevent new texinfo from breaking old versions (see #198182, bug #464008) einfo "Remove texinfo (bug #198182, bug #464008)" eapply "${FILESDIR}"/gcc-configure-texinfo.patch @@ -531,13 +672,13 @@ toolchain_src_prepare() { do_gcc_gentoo_patches() { if ! use vanilla ; then - if [[ -n ${PATCH_VER} ]] ; then + if [[ -n ${PATCH_VER} || -d "${WORKDIR}"/patch ]] ; then einfo "Applying Gentoo patches ..." eapply "${WORKDIR}"/patch/*.patch BRANDING_GCC_PKGVERSION="${BRANDING_GCC_PKGVERSION} p${PATCH_VER}" fi - if [[ -n ${MUSL_VER} ]] && [[ ${CTARGET} == *musl* ]] ; then + if [[ -n ${MUSL_VER} || -d "${WORKDIR}"/musl ]] && [[ ${CTARGET} == *musl* ]] ; then if [[ ${CATEGORY} == cross-* ]] ; then # We don't want to apply some patches when cross-compiling. if [[ -d "${WORKDIR}"/musl/nocross ]] ; then @@ -561,7 +702,7 @@ do_gcc_PIE_patches() { want_pie || return 0 use vanilla && return 0 - einfo "Applying pie patches ..." + einfo "Applying PIE patches ..." eapply "${WORKDIR}"/piepatch/*.patch BRANDING_GCC_PKGVERSION="${BRANDING_GCC_PKGVERSION}, pie-${PIE_VER}" @@ -572,7 +713,7 @@ do_gcc_CYGWINPORTS_patches() { use elibc_Cygwin || return 0 local p d="${WORKDIR}/gcc-${CYGWINPORTS_GITREV}" - # readarray -t is available since bash-4.4 only, #690686 + # readarray -t is available since bash-4.4 only, bug #690686 local patches=( $( for p in $( sed -e '1,/PATCH_URI="/d;/"/,$d' < "${d}"/gcc.cygport @@ -588,14 +729,15 @@ do_gcc_CYGWINPORTS_patches() { make_gcc_hard() { local gcc_hard_flags="" - # If we use gcc-6 or newer with pie enable to compile older gcc we need to pass -no-pie - # to stage1; bug #618908 + # If we use gcc-6 or newer with PIE enabled to compile older gcc, + # we need to pass -no-pie to stage1; bug #618908 if ! tc_version_is_at_least 6.0 && [[ $(gcc-major-version) -ge 6 ]] ; then einfo "Disabling PIE in stage1 (only) ..." sed -i -e "/^STAGE1_LDFLAGS/ s/$/ -no-pie/" "${S}"/Makefile.in || die fi - # Gcc >= 6.X we can use configurations options to turn pie/ssp on as default + # For gcc >= 6.x, we can use configuration options to turn PIE/SSP + # on as default if tc_version_is_at_least 6.0 ; then if _tc_use_if_iuse pie ; then einfo "Updating gcc to use automatic PIE building ..." @@ -605,21 +747,21 @@ make_gcc_hard() { fi if _tc_use_if_iuse hardened ; then # Will add some hardened options as default, like: - # -fstack-clash-protection - # -z now - # see *_all_extra-options.patch gcc patches. + # * -fstack-clash-protection + # * -z now + # See gcc *_all_extra-options.patch patches. gcc_hard_flags+=" -DEXTRA_OPTIONS" if _tc_use_if_iuse cet && [[ ${CTARGET} == *x86_64*-linux* ]] ; then gcc_hard_flags+=" -DEXTRA_OPTIONS_CF" fi - # rebrand to make bug reports easier + # Rebrand to make bug reports easier BRANDING_GCC_PKGVERSION=${BRANDING_GCC_PKGVERSION/Gentoo/Gentoo Hardened} fi else if _tc_use_if_iuse hardened ; then - # rebrand to make bug reports easier + # Rebrand to make bug reports easier BRANDING_GCC_PKGVERSION=${BRANDING_GCC_PKGVERSION/Gentoo/Gentoo Hardened} if hardened_gcc_works ; then einfo "Updating gcc to use automatic PIE + SSP building ..." @@ -633,7 +775,7 @@ make_gcc_hard() { ewarn "PIE has not been enabled by default" gcc_hard_flags+=" -DEFAULT_SSP" else - # do nothing if hardened isn't supported, but don't die either + # Do nothing if hardened isn't supported, but don't die either ewarn "hardened is not supported for this arch in this gcc version" return 0 fi @@ -645,7 +787,7 @@ make_gcc_hard() { fi fi - # we want to be able to control the pie patch logic via something other + # We want to be able to control the PIE patch logic via something other # than ALL_CFLAGS... sed -e '/^ALL_CFLAGS/iHARD_CFLAGS = ' \ -e 's|^ALL_CFLAGS = |ALL_CFLAGS = $(HARD_CFLAGS) |' \ @@ -683,13 +825,13 @@ setup_multilib_osdirnames() { local config local libdirs="../lib64 ../lib32" - # this only makes sense for some Linux targets + # This only makes sense for some Linux targets case ${CTARGET} in - x86_64*-linux*) config="i386" ;; - powerpc64*-linux*) config="rs6000" ;; - sparc64*-linux*) config="sparc" ;; - s390x*-linux*) config="s390" ;; - *) return 0 ;; + x86_64*-linux*) config="i386" ;; + powerpc64*-linux*) config="rs6000" ;; + sparc64*-linux*) config="sparc" ;; + s390x*-linux*) config="s390" ;; + *) return 0 ;; esac config+="/t-linux64" @@ -698,14 +840,14 @@ setup_multilib_osdirnames() { sed_args+=( -e 's:$[(]call if_multiarch[^)]*[)]::g' ) fi if [[ ${SYMLINK_LIB} == "yes" ]] ; then - einfo "updating multilib directories to be: ${libdirs}" + einfo "Updating multilib directories to be: ${libdirs}" if tc_version_is_at_least 4.6.4 || tc_version_is_at_least 4.7 ; then sed_args+=( -e '/^MULTILIB_OSDIRNAMES.*lib32/s:[$][(]if.*):../lib32:' ) else sed_args+=( -e "/^MULTILIB_OSDIRNAMES/s:=.*:= ${libdirs}:" ) fi else - einfo "using upstream multilib; disabling lib32 autodetection" + einfo "Using upstream multilib; disabling lib32 autodetection" sed_args+=( -r -e 's:[$][(]if.*,(.*)[)]:\1:' ) fi sed -i "${sed_args[@]}" "${S}"/gcc/config/${config} || die @@ -717,7 +859,7 @@ gcc_version_patch() { local version_string=${GCC_RELEASE_VER} - einfo "patching gcc version: ${version_string} (${BRANDING_GCC_PKGVERSION})" + einfo "Patching gcc version: ${version_string} (${BRANDING_GCC_PKGVERSION})" local gcc_sed=( -e 's:gcc\.gnu\.org/bugs\.html:bugs\.gentoo\.org/:' ) if grep -qs VERSUFFIX "${S}"/gcc/version.c ; then @@ -735,15 +877,21 @@ toolchain_src_configure() { downgrade_arch_flags gcc_do_filter_flags + if tc_version_is_between 10 11 && [[ $(gcc-major-version) -ge 12 ]] ; then + # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105695 + # bug #849359 + export ac_cv_std_swap_in_utility=no + fi + einfo "CFLAGS=\"${CFLAGS}\"" einfo "CXXFLAGS=\"${CXXFLAGS}\"" einfo "LDFLAGS=\"${LDFLAGS}\"" # Force internal zip based jar script to avoid random - # issues with 3rd party jar implementations. #384291 + # issues with 3rd party jar implementations. bug #384291 export JAR=no - # For hardened gcc 4.3 piepatchset to build the hardened specs + # For hardened gcc 4.3: add the pie patchset to build the hardened specs # file (build.specs) to use when building gcc. if ! tc_version_is_at_least 4.4 && want_minispecs ; then setup_minispecs_gcc_build_specs @@ -751,6 +899,8 @@ toolchain_src_configure() { local confgcc=( --host=${CHOST} ) + local build_config_targets=() + if is_crosscompile || tc-is-cross-compiler ; then # Straight from the GCC install doc: # "GCC has code to correctly determine the correct value for target @@ -790,14 +940,13 @@ toolchain_src_configure() { is_d && GCC_LANG+=",d" is_gcj && GCC_LANG+=",java" is_go && GCC_LANG+=",go" - is_jit && GCC_LANG+=",jit" if is_objc || is_objcxx ; then GCC_LANG+=",objc" use objc-gc && confgcc+=( --enable-objc-gc ) is_objcxx && GCC_LANG+=",obj-c++" fi - # fortran support just got sillier! the lang value can be f77 for + # Fortran support just got sillier! The lang value can be f77 for # fortran77, f95 for fortran95, or just plain old fortran for the # currently supported standard depending on gcc version. is_fortran && GCC_LANG+=",fortran" @@ -839,12 +988,12 @@ toolchain_src_configure() { --with-pkgversion="${BRANDING_GCC_PKGVERSION}" ) - # If we want hardened support with the newer piepatchset for >=gcc 4.4 + # If we want hardened support with the newer PIE patchset for >=gcc 4.4 if tc_version_is_at_least 4.4 && want_minispecs && in_iuse hardened ; then confgcc+=( $(use_enable hardened esp) ) fi - # allow gcc to search for clock funcs in the main C lib. + # Allow gcc to search for clock funcs in the main C lib. # if it can't find them, then tough cookies -- we aren't # going to link in -lrt to all C++ apps. bug #411681 if tc_version_is_at_least 4.4 && is_cxx ; then @@ -853,17 +1002,18 @@ toolchain_src_configure() { # Build compiler itself using LTO if tc_version_is_at_least 9.1 && _tc_use_if_iuse lto ; then - confgcc+=( --with-build-config=bootstrap-lto ) + build_config_targets+=( bootstrap-lto ) fi - # Support to disable pch when building libstdcxx + if tc_version_is_at_least 12 && _tc_use_if_iuse cet ; then + build_config_targets+=( bootstrap-cet ) + fi + + # Support to disable PCH when building libstdcxx if tc_version_is_at_least 6.0 && ! _tc_use_if_iuse pch ; then confgcc+=( --disable-libstdcxx-pch ) fi - # The jit language requires this. - is_jit && confgcc+=( --enable-host-shared ) - # build-id was disabled for file collisions: bug #526144 # # # Turn on the -Wl,--build-id flag by default for ELF targets. bug #525942 @@ -876,7 +1026,7 @@ toolchain_src_configure() { # ;; # esac - # newer gcc versions like to bootstrap themselves with C++, + # Newer gcc versions like to bootstrap themselves with C++, # so we need to manually disable it ourselves if tc_version_is_between 4.7 4.8 && ! is_cxx ; then confgcc+=( --disable-build-with-cxx --disable-build-poststage1-with-cxx ) @@ -892,37 +1042,55 @@ toolchain_src_configure() { # disable a bunch of features or gcc goes boom local needed_libc="" case ${CTARGET} in - *-linux) needed_libc=error-unknown-libc;; - *-dietlibc) needed_libc=dietlibc;; - *-elf|*-eabi) - needed_libc=newlib - # Bare-metal targets don't have access to clock_gettime() - # arm-none-eabi example: bug #589672 - # But we explicitly do --enable-libstdcxx-time above. - # Undoing it here. - confgcc+=( --disable-libstdcxx-time ) - ;; - *-gnu*) needed_libc=glibc;; - *-klibc) needed_libc=klibc;; - *-musl*) needed_libc=musl;; - *-cygwin) needed_libc=cygwin;; - x86_64-*-mingw*|\ - *-w64-mingw*) needed_libc=mingw64-runtime;; - avr) confgcc+=( --enable-shared --disable-threads );; + *-linux) + needed_libc=error-unknown-libc + ;; + *-dietlibc) + needed_libc=dietlibc + ;; + *-elf|*-eabi) + needed_libc=newlib + # Bare-metal targets don't have access to clock_gettime() + # arm-none-eabi example: bug #589672 + # But we explicitly do --enable-libstdcxx-time above. + # Undoing it here. + confgcc+=( --disable-libstdcxx-time ) + ;; + *-gnu*) + needed_libc=glibc + ;; + *-klibc) + needed_libc=klibc + ;; + *-musl*) + needed_libc=musl + ;; + *-cygwin) + needed_libc=cygwin + ;; + x86_64-*-mingw*|*-w64-mingw*) + needed_libc=mingw64-runtime + ;; + avr) + confgcc+=( --enable-shared --disable-threads ) + ;; esac + if [[ -n ${needed_libc} ]] ; then local confgcc_no_libc=( --disable-shared ) # requires libc: bug #734820 tc_version_is_at_least 4.6 && confgcc_no_libc+=( --disable-libquadmath ) # requires libc tc_version_is_at_least 4.8 && confgcc_no_libc+=( --disable-libatomic ) + if ! has_version ${CATEGORY}/${needed_libc} ; then confgcc+=( "${confgcc_no_libc[@]}" --disable-threads --without-headers ) - if [[ $needed_libc == glibc ]]; then + + if [[ ${needed_libc} == glibc ]] ; then # By default gcc looks at glibc's headers # to detect long double support. This does # not work for --disable-headers mode. @@ -948,31 +1116,33 @@ toolchain_src_configure() { confgcc+=( --enable-shared ) fi case ${CHOST} in - mingw*|*-mingw*) - confgcc+=( --enable-threads=win32 ) ;; - *) - confgcc+=( --enable-threads=posix ) ;; + mingw*|*-mingw*) + confgcc+=( --enable-threads=win32 ) + ;; + *) + confgcc+=( --enable-threads=posix ) + ;; esac fi # __cxa_atexit is "essential for fully standards-compliant handling of # destructors", but apparently requires glibc. case ${CTARGET} in - *-elf|*-eabi) - confgcc+=( --with-newlib ) - ;; - *-musl*) - confgcc+=( --enable-__cxa_atexit ) - ;; - *-gnu*) - confgcc+=( - --enable-__cxa_atexit - --enable-clocale=gnu - ) - ;; - *-solaris*) - confgcc+=( --enable-__cxa_atexit ) - ;; + *-elf|*-eabi) + confgcc+=( --with-newlib ) + ;; + *-musl*) + confgcc+=( --enable-__cxa_atexit ) + ;; + *-gnu*) + confgcc+=( + --enable-__cxa_atexit + --enable-clocale=gnu + ) + ;; + *-solaris*) + confgcc+=( --enable-__cxa_atexit ) + ;; esac ### arch options @@ -985,99 +1155,117 @@ toolchain_src_configure() { tc_version_is_at_least 4.3 && in_iuse fixed-point && confgcc+=( $(use_enable fixed-point) ) case $(tc-is-softfloat) in - yes) confgcc+=( --with-float=soft ) ;; - softfp) confgcc+=( --with-float=softfp ) ;; - *) - # If they've explicitly opt-ed in, do hardfloat, - # otherwise let the gcc default kick in. - case ${CTARGET//_/-} in - *-hardfloat-*|*eabihf) confgcc+=( --with-float=hard ) ;; - esac + yes) + confgcc+=( --with-float=soft ) + ;; + softfp) + confgcc+=( --with-float=softfp ) + ;; + *) + # If they've explicitly opt-ed in, do hardfloat, + # otherwise let the gcc default kick in. + case ${CTARGET//_/-} in + *-hardfloat-*|*eabihf) + confgcc+=( --with-float=hard ) + ;; + esac esac local with_abi_map=() case $(tc-arch) in - arm) #264534 #414395 - local a arm_arch=${CTARGET%%-*} - # Remove trailing endian variations first: eb el be bl b l - for a in e{b,l} {b,l}e b l ; do - if [[ ${arm_arch} == *${a} ]] ; then - arm_arch=${arm_arch%${a}} - break + arm) + # bug #264534, bug #414395 + local a arm_arch=${CTARGET%%-*} + # Remove trailing endian variations first: eb el be bl b l + for a in e{b,l} {b,l}e b l ; do + if [[ ${arm_arch} == *${a} ]] ; then + arm_arch=${arm_arch%${a}} + break + fi + done + + # Convert armv6m to armv6-m + [[ ${arm_arch} == armv6m ]] && arm_arch=armv6-m + # Convert armv7{a,r,m} to armv7-{a,r,m} + [[ ${arm_arch} == armv7? ]] && arm_arch=${arm_arch/7/7-} + # See if this is a valid --with-arch flag + if (srcdir=${S}/gcc target=${CTARGET} with_arch=${arm_arch}; + . "${srcdir}"/config.gcc) &>/dev/null + then + confgcc+=( --with-arch=${arm_arch} ) fi - done - # Convert armv7{a,r,m} to armv7-{a,r,m} - [[ ${arm_arch} == armv7? ]] && arm_arch=${arm_arch/7/7-} - # See if this is a valid --with-arch flag - if (srcdir=${S}/gcc target=${CTARGET} with_arch=${arm_arch}; - . "${srcdir}"/config.gcc) &>/dev/null - then - confgcc+=( --with-arch=${arm_arch} ) - fi - # Make default mode thumb for microcontroller classes #418209 - [[ ${arm_arch} == *-m ]] && confgcc+=( --with-mode=thumb ) + # Make default mode thumb for microcontroller classes, bug #418209 + [[ ${arm_arch} == *-m ]] && confgcc+=( --with-mode=thumb ) + + # Enable hardvfp + if [[ $(tc-is-softfloat) == "no" ]] && \ + [[ ${CTARGET} == armv[67]* ]] && \ + tc_version_is_at_least 4.5 + then + # Follow the new arm hardfp distro standard by default + confgcc+=( --with-float=hard ) + case ${CTARGET} in + armv6*) confgcc+=( --with-fpu=vfp ) ;; + armv7*) confgcc+=( --with-fpu=vfpv3-d16 ) ;; + esac + fi + ;; + mips) + # Add --with-abi flags to set default ABI + confgcc+=( --with-abi=$(gcc-abi-map ${TARGET_DEFAULT_ABI}) ) + ;; - # Enable hardvfp - if [[ $(tc-is-softfloat) == "no" ]] && \ - [[ ${CTARGET} == armv[67]* ]] && \ - tc_version_is_at_least 4.5 - then - # Follow the new arm hardfp distro standard by default - confgcc+=( --with-float=hard ) - case ${CTARGET} in - armv6*) confgcc+=( --with-fpu=vfp ) ;; - armv7*) confgcc+=( --with-fpu=vfpv3-d16 ) ;; - esac - fi - ;; - mips) - # Add --with-abi flags to set default ABI - confgcc+=( --with-abi=$(gcc-abi-map ${TARGET_DEFAULT_ABI}) ) - ;; - amd64) - # drop the older/ABI checks once this get's merged into some - # version of gcc upstream - if tc_version_is_at_least 4.8 && has x32 $(get_all_abis TARGET) ; then + amd64) + # drop the older/ABI checks once this get's merged into some + # version of gcc upstream + if tc_version_is_at_least 4.8 && has x32 $(get_all_abis TARGET) ; then + confgcc+=( --with-abi=$(gcc-abi-map ${TARGET_DEFAULT_ABI}) ) + fi + ;; + x86) + # Default arch for x86 is normally i386, let's give it a bump + # since glibc will do so based on CTARGET anyways + confgcc+=( --with-arch=${CTARGET%%-*} ) + ;; + hppa) + # Enable sjlj exceptions for backward compatibility on hppa + [[ ${GCCMAJOR} == "3" ]] && confgcc+=( --enable-sjlj-exceptions ) + ;; + ppc) + # Set up defaults based on current CFLAGS + is-flagq -mfloat-gprs=double && confgcc+=( --enable-e500-double ) + [[ ${CTARGET//_/-} == *-e500v2-* ]] && confgcc+=( --enable-e500-double ) + ;; + ppc64) + # On ppc64, the big endian target gcc assumes elfv1 by default, + # and elfv2 on little endian. + # But musl does not support elfv1 at all on any endian ppc64. + # See: + # - https://git.musl-libc.org/cgit/musl/tree/INSTALL + # - bug #704784 + # - https://gcc.gnu.org/PR93157 + [[ ${CTARGET} == powerpc64-*-musl ]] && confgcc+=( --with-abi=elfv2 ) + ;; + riscv) + # Add --with-abi flags to set default ABI confgcc+=( --with-abi=$(gcc-abi-map ${TARGET_DEFAULT_ABI}) ) - fi - ;; - x86) - # Default arch for x86 is normally i386, lets give it a bump - # since glibc will do so based on CTARGET anyways - confgcc+=( --with-arch=${CTARGET%%-*} ) - ;; - hppa) - # Enable sjlj exceptions for backward compatibility on hppa - [[ ${GCCMAJOR} == "3" ]] && confgcc+=( --enable-sjlj-exceptions ) - ;; - ppc) - # Set up defaults based on current CFLAGS - is-flagq -mfloat-gprs=double && confgcc+=( --enable-e500-double ) - [[ ${CTARGET//_/-} == *-e500v2-* ]] && confgcc+=( --enable-e500-double ) - ;; - ppc64) - # On ppc64 big endian target gcc assumes elfv1 by default, - # and elfv2 on little endian - # but musl does not support elfv1 at all on any endian ppc64 - # see https://git.musl-libc.org/cgit/musl/tree/INSTALL - # https://bugs.gentoo.org/704784 - # https://gcc.gnu.org/PR93157 - [[ ${CTARGET} == powerpc64-*-musl ]] && confgcc+=( --with-abi=elfv2 ) - ;; - riscv) - # Add --with-abi flags to set default ABI - confgcc+=( --with-abi=$(gcc-abi-map ${TARGET_DEFAULT_ABI}) ) - ;; + ;; esac - # if the target can do biarch (-m32/-m64), enable it. overhead should + # If the target can do biarch (-m32/-m64), enable it. overhead should # be small, and should simplify building of 64bit kernels in a 32bit - # userland by not needing sys-devel/kgcc64. #349405 + # userland by not needing sys-devel/kgcc64. bug #349405 case $(tc-arch) in - ppc|ppc64) confgcc+=( --enable-targets=all ) ;; - sparc) tc_version_is_at_least 4.4 && confgcc+=( --enable-targets=all ) ;; - amd64|x86) tc_version_is_at_least 4.3 && confgcc+=( --enable-targets=all ) ;; + ppc|ppc64) + confgcc+=( --enable-targets=all ) + ;; + sparc) + tc_version_is_at_least 4.4 && confgcc+=( --enable-targets=all ) + ;; + amd64|x86) + tc_version_is_at_least 4.3 && confgcc+=( --enable-targets=all ) + ;; esac # On Darwin we need libdir to be set in order to get correct install names @@ -1099,16 +1287,16 @@ toolchain_src_configure() { fi if in_iuse openmp ; then - # Make sure target has pthreads support. #326757 #335883 + # Make sure target has pthreads support: bug #326757, bug #335883 # There shouldn't be a chicken & egg problem here as openmp won't - # build without a C library, and you can't build that w/out - # already having a compiler ... + # build without a C library, and you can't build that w/o + # already having a compiler... if ! is_crosscompile || \ $(tc-getCPP ${CTARGET}) -E - <<<"#include <pthread.h>" >& /dev/null then confgcc+=( $(use_enable openmp libgomp) ) else - # Force disable as the configure script can be dumb #359855 + # Force disable as the configure script can be dumb, bug #359855 confgcc+=( --disable-libgomp ) fi else @@ -1122,13 +1310,18 @@ toolchain_src_configure() { if hardened_gcc_is_stable ssp; then export gcc_cv_libc_provides_ssp=yes fi + if _tc_use_if_iuse ssp; then # On some targets USE="ssp -libssp" is an invalid - # configuration as target libc does not provide + # configuration as the target libc does not provide # stack_chk_* functions. Do not disable libssp there. case ${CTARGET} in - mingw*|*-mingw*) ewarn "Not disabling libssp" ;; - *) confgcc+=( --disable-libssp ) ;; + mingw*|*-mingw*) + ewarn "Not disabling libssp" + ;; + *) + confgcc+=( --disable-libssp ) + ;; esac else confgcc+=( --disable-libssp ) @@ -1171,6 +1364,8 @@ toolchain_src_configure() { confgcc+=( $(use_with zstd) ) fi + # This only controls whether the compiler *supports* LTO, not whether + # it's *built using* LTO. Hence we do it without a USE flag. if tc_version_is_at_least 4.6 ; then confgcc+=( --enable-lto ) elif tc_version_is_at_least 4.5 ; then @@ -1178,7 +1373,7 @@ toolchain_src_configure() { fi # graphite was added in 4.4 but we only support it in 6.5+ due to external - # library issues. #448024, #701270 + # library issues. bug #448024, bug #701270 if tc_version_is_at_least 6.5 && in_iuse graphite ; then confgcc+=( $(use_with graphite isl) ) use graphite && confgcc+=( --disable-isl-version-check ) @@ -1211,7 +1406,7 @@ toolchain_src_configure() { fi # Disable gcc info regeneration -- it ships with generated info pages - # already. Our custom version/urls/etc... trigger it. #464008 + # already. Our custom version/urls/etc... trigger it. bug #464008 export gcc_cv_prog_makeinfo_modern=no # Do not let the X detection get in our way. We know things can be found @@ -1222,6 +1417,11 @@ toolchain_src_configure() { confgcc+=( "$@" ${EXTRA_ECONF} ) + if [[ -n ${build_config_targets} ]] ; then + # ./configure --with-build-config='bootstrap-lto bootstrap-cet' + confgcc+=( --with-build-config="${build_config_targets[*]}" ) + fi + # Nothing wrong with a good dose of verbosity echo einfo "PREFIX: ${PREFIX}" @@ -1229,26 +1429,47 @@ toolchain_src_configure() { einfo "LIBPATH: ${LIBPATH}" einfo "DATAPATH: ${DATAPATH}" einfo "STDCXX_INCDIR: ${STDCXX_INCDIR}" - echo einfo "Languages: ${GCC_LANG}" echo - einfo "Configuring GCC with: ${confgcc[@]//--/\n\t--}" - echo # Build in a separate build tree - mkdir -p "${WORKDIR}"/build - pushd "${WORKDIR}"/build > /dev/null + mkdir -p "${WORKDIR}"/build || die + pushd "${WORKDIR}"/build > /dev/null || die - # and now to do the actual configuration + # ...and now to do the actual configuration addwrite /dev/zero - echo "${S}"/configure "${confgcc[@]}" + + local gcc_shell="${BROOT}"/bin/bash # Older gcc versions did not detect bash and re-exec itself, so force the - # use of bash. Newer ones will auto-detect, but this is not harmful. - CONFIG_SHELL="${EPREFIX}/bin/bash" \ - bash "${S}"/configure "${confgcc[@]}" || die "failed to run configure" + # use of bash for them. + if tc_version_is_at_least 11.2 ; then + gcc_shell="${BROOT}"/bin/sh + fi - # return to whatever directory we were in before - popd > /dev/null + if is_jit ; then + einfo "Configuring JIT gcc" + + mkdir -p "${WORKDIR}"/build-jit || die + pushd "${WORKDIR}"/build-jit > /dev/null || die + CONFIG_SHELL="${gcc_shell}" edo "${gcc_shell}" "${S}"/configure \ + "${confgcc[@]}" \ + --disable-libada \ + --disable-libsanitizer \ + --disable-libvtv \ + --disable-libgomp \ + --disable-libquadmath \ + --disable-libatomic \ + --disable-lto \ + --disable-bootstrap \ + --enable-host-shared \ + --enable-languages=jit + popd > /dev/null || die + fi + + CONFIG_SHELL="${gcc_shell}" edo "${gcc_shell}" "${S}"/configure "${confgcc[@]}" + + # Return to whatever directory we were in before + popd > /dev/null || die } # Replace -m flags unsupported by the version being built with the best @@ -1320,7 +1541,7 @@ downgrade_arch_flags() { fi done - # we only check -mno* here since -m* get removed by strip-flags later on + # We only check -mno* here since -m* get removed by strip-flags later on local isalist=( 4.9 -mno-sha 4.9 -mno-avx512pf @@ -1372,16 +1593,21 @@ gcc_do_filter_flags() { # relating to failed builds, we strip most CFLAGS out to ensure as few # problems as possible. strip-flags + # Lock gcc at -O2; we want to be conservative here. filter-flags '-O?' append-flags -O2 fi - # dont want to funk ourselves + # Avoid shooting self in foot filter-flags '-mabi*' -m31 -m32 -m64 - filter-flags -frecord-gcc-switches # 490738 - filter-flags -mno-rtm -mno-htm # 506202 + # bug #490738 + filter-flags -frecord-gcc-switches + # bug #506202 + filter-flags -mno-rtm -mno-htm + + filter-flags '-fsanitize=*' if tc_version_is_between 6 8 ; then # -mstackrealign triggers crashes in exception throwing @@ -1394,25 +1620,25 @@ gcc_do_filter_flags() { amd64|x86) filter-flags '-mcpu=*' - tc_version_is_between 4.4 4.5 && append-flags -mno-avx # 357287 + # bug #357287 + tc_version_is_between 4.4 4.5 && append-flags -mno-avx if tc_version_is_between 4.6 4.7 ; then - # https://bugs.gentoo.org/411333 - # https://bugs.gentoo.org/466454 + # bug #411333, bug #466454 replace-cpu-flags c3-2 pentium2 pentium3 pentium3m pentium-m i686 fi ;; alpha) - # https://bugs.gentoo.org/454426 + # bug #454426 append-ldflags -Wl,--no-relax ;; sparc) - # temporary workaround for random ICEs reproduced by multiple users - # https://bugs.gentoo.org/457062 + # Temporary workaround for random ICEs reproduced by multiple users + # bug #457062 tc_version_is_between 4.6 4.8 && MAKEOPTS+=" -j1" ;; *-macos) - # http://gcc.gnu.org/PR25127 + # https://gcc.gnu.org/PR25127 tc_version_is_between 4.0 4.2 && \ filter-flags '-mcpu=*' '-march=*' '-mtune=*' ;; @@ -1420,7 +1646,7 @@ gcc_do_filter_flags() { strip-unsupported-flags - # these are set here so we have something sane at configure time + # These are set here so we have something sane at configure time if is_crosscompile ; then # Set this to something sane for both native and target CFLAGS="-O2 -pipe" @@ -1440,14 +1666,17 @@ setup_minispecs_gcc_build_specs() { if hardened_gcc_works pie ; then cat "${WORKDIR}"/specs/pie.specs >> "${WORKDIR}"/build.specs fi + if hardened_gcc_works ssp ; then for s in ssp sspall ; do cat "${WORKDIR}"/specs/${s}.specs >> "${WORKDIR}"/build.specs done fi + for s in nostrict znow ; do cat "${WORKDIR}"/specs/${s}.specs >> "${WORKDIR}"/build.specs done + export GCC_SPECS="${WORKDIR}"/build.specs } @@ -1462,16 +1691,17 @@ gcc-multilib-configure() { confgcc+=( --enable-multilib ) fi - # translate our notion of multilibs into gcc's + # Translate our notion of multilibs into gcc's local abi list for abi in $(get_all_abis TARGET) ; do local l=$(gcc-abi-map ${abi}) [[ -n ${l} ]] && list+=",${l}" done + if [[ -n ${list} ]] ; then case ${CTARGET} in - x86_64*) - tc_version_is_at_least 4.8 && confgcc+=( --with-multilib-list=${list:1} ) + x86_64*) + tc_version_is_at_least 4.8 && confgcc+=( --with-multilib-list=${list:1} ) ;; esac fi @@ -1481,9 +1711,15 @@ gcc-abi-map() { # Convert the ABI name we use in Gentoo to what gcc uses local map=() case ${CTARGET} in - mips*) map=("o32 32" "n32 n32" "n64 64") ;; - riscv*) map=("lp64d lp64d" "lp64 lp64" "ilp32d ilp32d" "ilp32 ilp32") ;; - x86_64*) map=("amd64 m64" "x86 m32" "x32 mx32") ;; + mips*) + map=("o32 32" "n32 n32" "n64 64") + ;; + riscv*) + map=("lp64d lp64d" "lp64 lp64" "ilp32d ilp32d" "ilp32 ilp32") + ;; + x86_64*) + map=("amd64 m64" "x86 m32" "x32 mx32") + ;; esac local m @@ -1496,7 +1732,7 @@ gcc-abi-map() { #----> src_compile <---- toolchain_src_compile() { - touch "${S}"/gcc/c-gperf.h + touch "${S}"/gcc/c-gperf.h || die # Do not make manpages if we do not have perl ... [[ ! -x /usr/bin/perl ]] \ @@ -1508,11 +1744,16 @@ toolchain_src_compile() { unset ADAFLAGS # Older gcc versions did not detect bash and re-exec itself, so force the - # use of bash. Newer ones will auto-detect, but this is not harmful. + # use of bash for them. # This needs to be set for compile as well, as it's used in libtool - # generation, which will break install otherwise (at least in 3.3.6): #664486 - CONFIG_SHELL="${EPREFIX}/bin/bash" \ - gcc_do_make ${GCC_MAKE_TARGET} + # generation, which will break install otherwise (at least in 3.3.6): bug #664486 + local gcc_shell="${BROOT}"/bin/bash + if tc_version_is_at_least 11.2 ; then + gcc_shell="${BROOT}"/bin/sh + fi + + CONFIG_SHELL="${gcc_shell}" \ + gcc_do_make ${GCC_MAKE_TARGET} } gcc_do_make() { @@ -1527,11 +1768,17 @@ gcc_do_make() { # default target if is_crosscompile || tc-is-cross-compiler ; then - # 3 stage bootstrapping doesnt quite work when you cant run the - # resulting binaries natively ^^; + # 3 stage bootstrapping doesn't quite work when you can't run the + # resulting binaries natively GCC_MAKE_TARGET=${GCC_MAKE_TARGET-all} else - if _tc_use_if_iuse pgo; then + if [[ ${EXTRA_ECONF} == *--disable-bootstrap* ]] ; then + GCC_MAKE_TARGET=${GCC_MAKE_TARGET-all} + + ewarn "Disabling bootstrapping. ONLY recommended for development." + ewarn "This is NOT a safe configuration for endusers!" + ewarn "This compiler may not be safe or reliable for production use!" + elif _tc_use_if_iuse pgo; then GCC_MAKE_TARGET=${GCC_MAKE_TARGET-profiledbootstrap} else GCC_MAKE_TARGET=${GCC_MAKE_TARGET-bootstrap-lean} @@ -1540,7 +1787,7 @@ gcc_do_make() { # Older versions of GCC could not do profiledbootstrap in parallel due to # collisions with profiling info. - if [[ ${GCC_MAKE_TARGET} == "profiledbootstrap" ]]; then + if [[ ${GCC_MAKE_TARGET} == "profiledbootstrap" ]] ; then ! tc_version_is_at_least 4.6 && export MAKEOPTS="${MAKEOPTS} -j1" fi @@ -1562,23 +1809,36 @@ gcc_do_make() { BOOT_CFLAGS=${BOOT_CFLAGS-"$(get_abi_CFLAGS ${TARGET_DEFAULT_ABI}) ${CFLAGS}"} fi + if is_jit ; then + # TODO: docs for jit? + pushd "${WORKDIR}"/build-jit > /dev/null || die + + einfo "Building JIT" + emake \ + LDFLAGS="${LDFLAGS}" \ + STAGE1_CFLAGS="${STAGE1_CFLAGS}" \ + LIBPATH="${LIBPATH}" \ + BOOT_CFLAGS="${BOOT_CFLAGS}" + popd > /dev/null || die + fi + einfo "Compiling ${PN} (${GCC_MAKE_TARGET})..." - pushd "${WORKDIR}"/build >/dev/null + pushd "${WORKDIR}"/build >/dev/null || die emake \ LDFLAGS="${LDFLAGS}" \ STAGE1_CFLAGS="${STAGE1_CFLAGS}" \ LIBPATH="${LIBPATH}" \ BOOT_CFLAGS="${BOOT_CFLAGS}" \ - ${GCC_MAKE_TARGET} \ - || die "emake failed with ${GCC_MAKE_TARGET}" + ${GCC_MAKE_TARGET} if is_ada; then - # Without these links it is not getting the good compiler - # Need to check why + # Without these links, it is not getting the good compiler + # TODO: Need to check why ln -s gcc ../build/prev-gcc || die ln -s ${CHOST} ../build/prev-${CHOST} || die + # Building standard ada library emake -C gcc gnatlib-shared # Building gnat toold @@ -1589,16 +1849,17 @@ gcc_do_make() { if type -p doxygen > /dev/null ; then if tc_version_is_at_least 4.3 ; then cd "${CTARGET}"/libstdc++-v3/doc - emake doc-man-doxygen || ewarn "failed to make docs" + emake doc-man-doxygen else cd "${CTARGET}"/libstdc++-v3 - emake doxygen-man || ewarn "failed to make docs" + emake doxygen-man fi - # Clean bogus manpages. #113902 + # Clean bogus manpages. bug #113902 find -name '*_build_*' -delete - # Blow away generated directory references. Newer versions of gcc - # have gotten better at this, but not perfect. This is easier than - # backporting all of the various doxygen patches. #486754 + + # Blow away generated directory references. Newer versions of gcc + # have gotten better at this, but not perfect. This is easier than + # backporting all of the various doxygen patches. bug #486754 find -name '*_.3' -exec grep -l ' Directory Reference ' {} + | \ xargs rm -f else @@ -1606,30 +1867,40 @@ gcc_do_make() { fi fi - popd >/dev/null + popd >/dev/null || die } #---->> src_test <<---- toolchain_src_test() { - cd "${WORKDIR}"/build + cd "${WORKDIR}"/build || die + + # From opensuse's spec file: + # "asan needs a whole shadow address space" + ulimit -v unlimited + # 'asan' wants to be preloaded first, so does 'sandbox'. # To make asan tests work disable sandbox for all of test suite. # 'backtrace' tests also does not like 'libsandbox.so' presence. SANDBOX_ON=0 LD_PRELOAD= emake -k check + + einfo "Testing complete." + einfo "Please ignore any 'mail' lines in the summary output below (no mail is sent)." + einfo "Summary:" + "${S}"/contrib/test_summary } #---->> src_install <<---- toolchain_src_install() { - cd "${WORKDIR}"/build + cd "${WORKDIR}"/build || die # Don't allow symlinks in private gcc include dir as this can break the build - find gcc/include*/ -type l -delete + find gcc/include*/ -type l -delete || die # Copy over the info pages. We disabled their generation earlier, but the - # build system only expects to install out of the build dir, not the source. #464008 - mkdir -p gcc/doc + # build system only expects to install out of the build dir, not the source. bug #464008 + mkdir -p gcc/doc || die local x= for x in "${S}"/gcc/doc/*.info* ; do if [[ -f ${x} ]] ; then @@ -1648,8 +1919,32 @@ toolchain_src_install() { && rm -f "${x}" done < <(find gcc/include*/ -name '*.h') + if is_jit ; then + # See https://gcc.gnu.org/onlinedocs/gcc-11.3.0/jit/internals/index.html#packaging-notes + # and bug #843341. + # + # Both of the non-JIT and JIT builds are configured to install to $(DESTDIR) + # Install the configuration with --enable-host-shared first + # *then* the one without, so that the faster build + # of "cc1" et al overwrites the slower build. + # + # Do the 'make install' from the build directory + pushd "${WORKDIR}"/build-jit > /dev/null || die + S="${WORKDIR}"/build-jit emake DESTDIR="${D}" install + + # Punt some tools which are really only useful while building gcc + find "${ED}" -name install-tools -prune -type d -exec rm -rf "{}" \; + # This one comes with binutils + find "${ED}" -name libiberty.a -delete + + # Move the libraries to the proper location + gcc_movelibs + + popd > /dev/null || die + fi + # Do the 'make install' from the build directory - S="${WORKDIR}"/build emake -j1 DESTDIR="${D}" install || die + S="${WORKDIR}"/build emake DESTDIR="${D}" install # Punt some tools which are really only useful while building gcc find "${ED}" -name install-tools -prune -type d -exec rm -rf "{}" \; @@ -1673,12 +1968,12 @@ toolchain_src_install() { # Setup the gcc_env_entry for hardened gcc 4 with minispecs want_minispecs && copy_minispecs_gcc_specs - # Make sure we dont have stuff lying around that + # Make sure we don't have stuff lying around that # can nuke multiple versions of gcc gcc_slot_java dodir /usr/bin - cd "${D}"${BINPATH} + cd "${D}"${BINPATH} || die # Ugh: we really need to auto-detect this list. # It's constantly out of date. for x in cpp gcc g++ c++ gcov g77 gcj gcjh gfortran gccgo gnat* ; do @@ -1712,7 +2007,7 @@ toolchain_src_install() { # When cross-building gcc does install native tools. if ! is_crosscompile; then # Rename the main go binaries as we don't want to clobber dev-lang/go - # when gcc-config runs. #567806 + # when gcc-config runs. bug #567806 if tc_version_is_at_least 5 && is_go ; then for x in go gofmt; do mv ${x} ${x}-${GCCMAJOR} || die @@ -1720,7 +2015,7 @@ toolchain_src_install() { fi fi - # As gcc installs object files built against bost ${CHOST} and ${CTARGET} + # As gcc installs object files built against both ${CHOST} and ${CTARGET} # ideally we will need to strip them using different tools: # Using ${CHOST} tools: # - "${D}${BINPATH}" @@ -1743,14 +2038,14 @@ toolchain_src_install() { fi fi - # portage regenerates 'dir' files on it's own: bug #672408 + # Portage regenerates 'dir' files on its own: bug #672408 # Drop 'dir' files to avoid collisions. if [[ -f "${D}${DATAPATH}"/info/dir ]]; then einfo "Deleting '${D}${DATAPATH}/info/dir'" rm "${D}${DATAPATH}"/info/dir || die fi - # prune empty dirs left behind + # Prune empty dirs left behind find "${ED}" -depth -type d -delete 2>/dev/null # libstdc++.la: Delete as it doesn't add anything useful: g++ itself @@ -1766,14 +2061,14 @@ toolchain_src_install() { # libgomp-plugin-*.la: Same as above, and it's an internal plugin only # loaded via dlopen. # libgfortran.la: gfortran itself handles linkage correctly in the - # dynamic & static case (libgfortran.spec). #573302 + # dynamic & static case (libgfortran.spec). bug #573302 # libgfortranbegin.la: Same as above, and it's an internal lib. # libmpx.la: gcc itself handles linkage correctly (libmpx.spec). # libmpxwrappers.la: See above. # libitm.la: gcc itself handles linkage correctly (libitm.spec). # libvtv.la: gcc itself handles linkage correctly. # lib*san.la: Sanitizer linkage is handled internally by gcc, and they - # do not support static linking. #487550 #546700 + # do not support static linking. bug #487550, bug #546700 find "${D}${LIBPATH}" \ '(' \ -name libstdc++.la -o \ @@ -1803,9 +2098,12 @@ toolchain_src_install() { pushd "${D}${LIBPATH}" >/dev/null for py in $(find . -name '*-gdb.py') ; do local multidir=${py%/*} + insinto "${gdbdir}/${multidir}" - sed -i "/^libdir =/s:=.*:= '${LIBPATH}/${multidir}':" "${py}" || die #348128 - doins "${py}" || die + # bug #348128 + sed -i "/^libdir =/s:=.*:= '${LIBPATH}/${multidir}':" "${py}" || die + doins "${py}" + rm "${py}" || die done popd >/dev/null @@ -1814,16 +2112,16 @@ toolchain_src_install() { export QA_EXECSTACK="usr/lib*/go/*/*.gox" export QA_WX_LOAD="usr/lib*/go/*/*.gox" - # Disable RANDMMAP so PCH works. #301299 + # Disable RANDMMAP so PCH works, bug #301299 if tc_version_is_at_least 4.3 ; then - pax-mark -r "${D}${PREFIX}/libexec/gcc/${CTARGET}/${GCC_CONFIG_VER}/cc1" - pax-mark -r "${D}${PREFIX}/libexec/gcc/${CTARGET}/${GCC_CONFIG_VER}/cc1plus" + pax-mark -r "${ED}/libexec/gcc/${CTARGET}/${GCC_CONFIG_VER}/cc1" + pax-mark -r "${ED}/libexec/gcc/${CTARGET}/${GCC_CONFIG_VER}/cc1plus" fi - # Disable MPROTECT so java works. #574808 + # Disable MPROTECT so java works, bug #574808 if is_gcj ; then - pax-mark -m "${D}${PREFIX}/libexec/gcc/${CTARGET}/${GCC_CONFIG_VER}/ecj1" - pax-mark -m "${D}${PREFIX}/${CTARGET}/gcc-bin/${GCC_CONFIG_VER}/gij" + pax-mark -m "${ED}/libexec/gcc/${CTARGET}/${GCC_CONFIG_VER}/ecj1" + pax-mark -m "${ED}/${CTARGET}/gcc-bin/${GCC_CONFIG_VER}/gij" fi } @@ -1839,9 +2137,10 @@ gcc_movelibs() { dodir "${HOSTLIBPATH#${EPREFIX}}" mv "${ED}"/usr/$(get_libdir)/libcc1* "${D}${HOSTLIBPATH}" || die fi + # libgccjit gets installed to /usr/lib, not /usr/$(get_libdir). Probably # due to a bug in gcc build system. - if is_jit ; then + if [[ ${PWD} == "${WORKDIR}"/build-jit ]] && is_jit ; then dodir "${LIBPATH#${EPREFIX}}" mv "${ED}"/usr/lib/libgccjit* "${D}${LIBPATH}" || die fi @@ -1893,24 +2192,25 @@ gcc_movelibs() { for FROMDIR in ${removedirs} ; do rmdir "${D}"${FROMDIR} >& /dev/null done + find -depth "${ED}" -type d -exec rmdir {} + >& /dev/null } -# make sure the libtool archives have libdir set to where they actually -# -are-, and not where they -used- to be. also, any dependencies we have +# Make sure the libtool archives have libdir set to where they actually +# -are-, and not where they -used- to be. Also, any dependencies we have # on our own .la files need to be updated. fix_libtool_libdir_paths() { local libpath="$1" - pushd "${D}" >/dev/null + pushd "${D}" >/dev/null || die - pushd "./${libpath}" >/dev/null + pushd "./${libpath}" >/dev/null || die local dir="${PWD#${D%/}}" local allarchives=$(echo *.la) allarchives="\(${allarchives// /\\|}\)" - popd >/dev/null + popd >/dev/null || die - # The libdir might not have any .la files. #548782 + # The libdir might not have any .la files. bug #548782 find "./${dir}" -maxdepth 1 -name '*.la' \ -exec sed -i -e "/^libdir=/s:=.*:='${dir}':" {} + || die # Would be nice to combine these, but -maxdepth can not be specified @@ -1920,13 +2220,13 @@ fix_libtool_libdir_paths() { find "./${dir}/" -maxdepth 1 -name '*.la' \ -exec sed -i -e "/^dependency_libs=/s:/[^ ]*/${allarchives}:${libpath}/\1:g" {} + || die - popd >/dev/null + popd >/dev/null || die } create_gcc_env_entry() { dodir /etc/env.d/gcc - local gcc_envd_base="/etc/env.d/gcc/${CTARGET}-${GCC_CONFIG_VER}" + local gcc_envd_base="/etc/env.d/gcc/${CTARGET}-${GCC_CONFIG_VER}" local gcc_specs_file local gcc_envd_file="${ED}${gcc_envd_base}" if [[ -z $1 ]] ; then @@ -1983,12 +2283,12 @@ create_revdep_rebuild_entry() { } copy_minispecs_gcc_specs() { - # on gcc 6 we don't need minispecs + # On gcc 6, we don't need minispecs if tc_version_is_at_least 6.0 ; then return 0 fi - # setup the hardenedno* specs files and the vanilla specs file. + # Setup the hardenedno* specs files and the vanilla specs file. if hardened_gcc_works ; then create_gcc_env_entry hardenednopiessp fi @@ -2038,7 +2338,7 @@ gcc_slot_java() { done # Rename jar because it could clash with Kaffe's jar if this gcc is - # primary compiler (aka don't have the -<version> extension) + # primary compiler (aka doesn't have the -<version> extension) cd "${D}${BINPATH}" [[ -f jar ]] && mv -f jar gcj-jar } @@ -2047,6 +2347,7 @@ gcc_slot_java() { toolchain_pkg_postinst() { do_gcc_config + if [[ ! ${ROOT} && -f ${EPREFIX}/usr/share/eselect/modules/compiler-shadow.eselect ]] ; then eselect compiler-shadow update all fi @@ -2066,7 +2367,7 @@ toolchain_pkg_postrm() { eselect compiler-shadow clean all fi - # clean up the cruft left behind by cross-compilers + # Clean up the cruft left behind by cross-compilers if is_crosscompile ; then if [[ -z $(ls "${EROOT}"/etc/env.d/gcc/${CTARGET}* 2>/dev/null) ]] ; then einfo "Removing last cross-compiler instance. Deleting dangling symlinks." @@ -2094,7 +2395,7 @@ do_gcc_config() { current_gcc_config=$(gcc-config -c ${CTARGET} 2>/dev/null) if [[ -n ${current_gcc_config} ]] ; then local current_specs use_specs - # figure out which specs-specific config is active + # Figure out which specs-specific config is active current_specs=$(gcc-config -S ${current_gcc_config} | awk '{print $3}') [[ -n ${current_specs} ]] && use_specs=-${current_specs} @@ -2112,7 +2413,7 @@ do_gcc_config() { target="${CTARGET}-${GCC_CONFIG_VER}${use_specs}" else # The curent target is invalid. Attempt to switch to a valid one. - # Blindly pick the latest version. #529608 + # Blindly pick the latest version. bug #529608 # TODO: Should update gcc-config to accept `-l ${CTARGET}` rather than # doing a partial grep like this. target=$(gcc-config -l 2>/dev/null | grep " ${CTARGET}-[0-9]" | tail -1 | awk '{print $2}') @@ -2127,9 +2428,9 @@ should_we_gcc_config() { local curr_config curr_config=$(gcc-config -c ${CTARGET} 2>&1) || return 0 - # if the previously selected config has the same major.minor (branch) as + # If the previously selected config has the same major.minor (branch) as # the version we are installing, then it will probably be uninstalled - # for being in the same SLOT, make sure we run gcc-config. + # for being in the same SLOT, so make sure we run gcc-config. local curr_config_ver=$(gcc-config -S ${curr_config} | awk '{print $2}') local curr_branch_ver=$(ver_cut 1-2 ${curr_config_ver}) @@ -2137,12 +2438,14 @@ should_we_gcc_config() { if [[ ${curr_branch_ver} == ${GCC_BRANCH_VER} ]] ; then return 0 else - # if we're installing a genuinely different compiler version, + # If we're installing a genuinely different compiler version, # we should probably tell the user -how- to switch to the new - # gcc version, since we're not going to do it for him/her. + # gcc version, since we're not going to do it for them. + # # We don't want to switch from say gcc-3.3 to gcc-3.4 right in # the middle of an emerge operation (like an 'emerge -e world' # which could install multiple gcc versions). + # # Only warn if we're installing a pkg as we might be called from # the pkg_{pre,post}rm steps. #446830 if [[ ${EBUILD_PHASE} == *"inst" ]] ; then @@ -2218,10 +2521,12 @@ is_go() { is_jit() { gcc-lang-supported jit || return 1 + # cross-compiler does not really support jit as it has - # to generate code for a target. On target like avr + # to generate code for a target. On targets like avr, # libgcclit.so can't link at all: bug #594572 is_crosscompile && return 1 + _tc_use_if_iuse jit } @@ -2248,7 +2553,7 @@ get_make_var() { XGCC() { get_make_var GCC_FOR_TARGET ; } -# The gentoo piessp patches allow for 3 configurations: +# The gentoo pie-ssp patches allow for 3 configurations: # 1) PIE+SSP by default # 2) PIE by default # 3) SSP by default @@ -2290,7 +2595,7 @@ hardened_gcc_is_stable() { } want_minispecs() { - # on gcc 6 we don't need minispecs + # On gcc 6, we don't need minispecs if tc_version_is_at_least 6.0 ; then return 0 fi diff --git a/eclass/udev.eclass b/eclass/udev.eclass index 073e5d8acbc9..830e3eeb125e 100644 --- a/eclass/udev.eclass +++ b/eclass/udev.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: udev.eclass @@ -26,6 +26,14 @@ # # udev_dorules contrib/99-foomatic # # udev_newrules contrib/98-foomatic 99-foomatic # } +# +# pkg_postinst() { +# udev_reload +# } +# +# pkg_postrm() { +# udev_reload +# } # @CODE case ${EAPI} in @@ -110,7 +118,9 @@ udev_newrules() { # @FUNCTION: udev_reload # @DESCRIPTION: -# Run udevadm control --reload to refresh rules and databases +# Run "udevadm control --reload" to refresh rules and databases. +# Should be called from pkg_postinst and pkg_postrm in packages which install +# udev rules or hwdb data. udev_reload() { if [[ -n ${ROOT%/} ]]; then return 0 diff --git a/eclass/user.eclass b/eclass/user.eclass index aab549d0c473..d5b827d2e76b 100644 --- a/eclass/user.eclass +++ b/eclass/user.eclass @@ -31,12 +31,12 @@ _USER_ECLASS=1 inherit user-info -# @FUNCTION: _assert_pkg_ebuild_phase +# @FUNCTION: _user_assert_pkg_phase # @INTERNAL # @USAGE: <calling func name> # @DESCRIPTION: # Raises an alert if the phase is not suitable for user.eclass usage. -_assert_pkg_ebuild_phase() { +_user_assert_pkg_phase() { case ${EBUILD_PHASE} in setup|preinst|postinst|prerm|postrm) ;; *) @@ -89,7 +89,7 @@ enewuser() { ewarn "Insufficient privileges to execute ${FUNCNAME[0]}" return 0 fi - _assert_pkg_ebuild_phase ${FUNCNAME} + _user_assert_pkg_phase ${FUNCNAME} local create_home=1 force_uid= while [[ ${1} == -* ]]; do @@ -123,13 +123,13 @@ enewuser() { # handle uid local euid=${1}; shift if [[ -n ${euid} && ${euid} != -1 ]] ; then - if [[ ${euid} -gt 0 ]] ; then + if [[ ${euid} -ge 0 ]] ; then if [[ -n $(egetent passwd ${euid}) ]] ; then [[ -n ${force_uid} ]] && die "${FUNCNAME}: UID ${euid} already taken" euid="next" fi else - eerror "Userid given but is not greater than 0!" + eerror "Userid given but is not greater than or equal to 0!" die "${euid} is not a valid UID" fi else @@ -262,7 +262,7 @@ enewgroup() { ewarn "Insufficient privileges to execute ${FUNCNAME[0]}" return 0 fi - _assert_pkg_ebuild_phase ${FUNCNAME} + _user_assert_pkg_phase ${FUNCNAME} local force_gid= while [[ ${1} == -* ]]; do @@ -289,13 +289,13 @@ enewgroup() { # handle gid local egid=${1}; shift if [[ -n ${egid} && ${egid} != -1 ]] ; then - if [[ ${egid} -gt 0 ]] ; then + if [[ ${egid} -ge 0 ]] ; then if [[ -n $(egetent group ${egid}) ]] ; then [[ -n ${force_gid} ]] && die "${FUNCNAME}: GID ${egid} already taken" egid="next available; requested gid taken" fi else - eerror "Groupid given but is not greater than 0!" + eerror "Groupid given but is not greater than or equal to 0!" die "${egid} is not a valid GID" fi else @@ -365,7 +365,7 @@ enewgroup() { # If the new home directory does not exist, it is created. # Any previously existing home directory is NOT moved. esethome() { - _assert_pkg_ebuild_phase ${FUNCNAME} + _user_assert_pkg_phase ${FUNCNAME} # get the username local euser=${1}; shift @@ -451,7 +451,7 @@ esethome() { # Required parameters is the username and the new shell. # Specify -1 if you want to set shell to platform-specific nologin. esetshell() { - _assert_pkg_ebuild_phase ${FUNCNAME} + _user_assert_pkg_phase ${FUNCNAME} # get the username local euser=${1}; shift @@ -528,7 +528,7 @@ esetshell() { # Update the comment field in a platform-agnostic way. # Required parameters is the username and the new comment. esetcomment() { - _assert_pkg_ebuild_phase ${FUNCNAME} + _user_assert_pkg_phase ${FUNCNAME} # get the username local euser=${1}; shift @@ -602,7 +602,7 @@ esetcomment() { # Required parameters is the username and the new list of groups, # primary group first. esetgroups() { - _assert_pkg_ebuild_phase ${FUNCNAME} + _user_assert_pkg_phase ${FUNCNAME} [[ ${#} -eq 2 ]] || die "Usage: ${FUNCNAME} <user> <groups>" diff --git a/eclass/vim-doc.eclass b/eclass/vim-doc.eclass index ba9d00f4f5e8..119ce793071d 100644 --- a/eclass/vim-doc.eclass +++ b/eclass/vim-doc.eclass @@ -1,10 +1,10 @@ -# Copyright 1999-2021 Gentoo Authors +# Copyright 1999-2022 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 # @ECLASS: vim-doc.eclass # @MAINTAINER: # vim@gentoo.org -# @SUPPORTED_EAPIS: 6 7 +# @SUPPORTED_EAPIS: 6 7 8 # @BLURB: Eclass for vim{,-plugin}.eclass to update documentation tags. # @DESCRIPTION: # This eclass is used by vim.eclass and vim-plugin.eclass to update @@ -16,26 +16,31 @@ # DEPEND in vim-plugin or by whatever version of vim is being # installed by the eclass. -case ${EAPI:-0} in - [67]) ;; +case ${EAPI} in + 6|7|8) ;; *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;; esac -if [[ -z ${_VIM_DOC_ECLASS} ]] ; then -_VIM_DOC_ECLASS=1 +if [[ ! ${_VIM_DOC_ECLASS} ]] ; then +# @FUNCTION: update_vim_helptags +# @USAGE: +# @DESCRIPTION: +# Update the documentation tags in the versioned Vim directory. update_vim_helptags() { - local vimfiles vim d s + debug-print-function ${FUNCNAME} "${@}" + + local vimfiles helpfile files vim d # This is where vim plugins are installed vimfiles="${EROOT}"/usr/share/vim/vimfiles - if [[ $PN != vim-core ]]; then + if [[ ${PN} != vim-core ]]; then # Find a suitable vim binary for updating tags :helptags vim=$(type -P vim 2>/dev/null) - [[ -z "$vim" ]] && vim=$(type -P gvim 2>/dev/null) - [[ -z "$vim" ]] && vim=$(type -P kvim 2>/dev/null) - if [[ -z "$vim" ]]; then + [[ -z "${vim}" ]] && vim=$(type -P gvim 2>/dev/null) + [[ -z "${vim}" ]] && vim=$(type -P kvim 2>/dev/null) + if [[ -z "${vim}" ]]; then ewarn "No suitable vim binary to rebuild documentation tags" fi fi @@ -43,44 +48,57 @@ update_vim_helptags() { # Make vim not try to connect to X. See :help gui-x11-start # in vim for how this evil trickery works. if [[ -n "${vim}" ]] ; then - ln -s "${vim}" "${T}/tagvim" + ln -s "${vim}" "${T}/tagvim" || die vim="${T}/tagvim" fi # Install the documentation symlinks into the versioned vim # directory and run :helptags for d in "${EROOT%/}"/usr/share/vim/vim[0-9]*; do - [[ -d "$d/doc" ]] || continue # catch a failed glob + [[ -d "${d}/doc" ]] || continue # catch a failed glob - # Remove links, and possibly remove stale dirs - find $d/doc -name \*.txt -type l | while read s; do - [[ $(readlink "$s") = $vimfiles/* ]] && rm -f "$s" + # Remove links + readarray -d '' files < <(find "${d}"/doc -name "*.txt" -type l -print0 || die "cannot traverse ${d}/doc" ) + for helpfile in "${files[@]}"; do + if [[ $(readlink -f "${helpfile}") == "${vimfiles}"/* ]]; then + rm "${helpfile}" || die + fi done - if [[ -f "$d/doc/tags" && $(find "$d" | wc -l | tr -d ' ') = 3 ]]; then + + # Remove stale dirs, if possible + readarray -d '' files < <(find "${d}" -print0 || die "cannot traverse ${d}") + if [[ -f "${d}/doc/tags" && ${#files[@]} -eq 3 ]]; then # /usr/share/vim/vim61 # /usr/share/vim/vim61/doc # /usr/share/vim/vim61/doc/tags - einfo "Removing $d" - rm -r "$d" + einfo "Removing ${d}" + rm -r "${d}" || die continue fi # Re-create / install new links - if [[ -d $vimfiles/doc ]]; then - ln -s $vimfiles/doc/*.txt $d/doc 2>/dev/null + if [[ -d "${vimfiles}"/doc ]]; then + for helpfile in "${vimfiles}"/doc/*.txt; do + if [[ ! -e "${d}/doc/$(basename "${helpfile}")" ]]; then + ln -s "${helpfile}" "${d}/doc" || die + fi + done fi # Update tags; need a vim binary for this - if [[ -n "$vim" ]]; then - einfo "Updating documentation tags in $d" - DISPLAY= $vim -u NONE -U NONE -T xterm -X -n -f \ + if [[ -n "${vim}" ]]; then + einfo "Updating documentation tags in ${d}" + DISPLAY= "${vim}" -u NONE -U NONE -T xterm -X -n -f \ '+set nobackup nomore' \ - "+helptags $d/doc" \ - '+qa!' </dev/null &>/dev/null + "+helptags ${d}/doc" \ + '+qa!' </dev/null &>/dev/null || die fi done - [[ -n "${vim}" && -f "${vim}" ]] && rm "${vim}" + if [[ -n "${vim}" && -f "${vim}" ]]; then + rm "${vim}" || die + fi } +_VIM_DOC_ECLASS=1 fi diff --git a/eclass/vim-plugin.eclass b/eclass/vim-plugin.eclass index 50e727e98f4e..edf1c94d31b1 100644 --- a/eclass/vim-plugin.eclass +++ b/eclass/vim-plugin.eclass @@ -1,10 +1,10 @@ -# Copyright 1999-2021 Gentoo Authors +# Copyright 1999-2022 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 # @ECLASS: vim-plugin.eclass # @MAINTAINER: # vim@gentoo.org -# @SUPPORTED_EAPIS: 6 7 +# @SUPPORTED_EAPIS: 6 7 8 # @BLURB: used for installing vim plugins # @DESCRIPTION: # This eclass simplifies installation of app-vim plugins into @@ -13,14 +13,19 @@ # documentation, for which we make a special case via vim-doc.eclass. case ${EAPI} in - 6|7);; - *) die "EAPI ${EAPI:-0} unsupported (too old)";; + 6|7) ;; + 8) _DEFINE_VIM_PLUGIN_SRC_PREPARE=true ;; + *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;; esac +if [[ ! ${_VIM_PLUGIN_ECLASS} ]]; then + inherit vim-doc -EXPORT_FUNCTIONS src_install pkg_postinst pkg_postrm -VIM_PLUGIN_VIM_VERSION="${VIM_PLUGIN_VIM_VERSION:-7.3}" +# @ECLASS_VARIABLE: VIM_PLUGIN_VIM_VERSION +# @DESCRIPTION: +# Minimum Vim version the plugin supports. +: ${VIM_PLUGIN_VIM_VERSION:=7.3} DEPEND="|| ( >=app-editors/vim-${VIM_PLUGIN_VIM_VERSION} >=app-editors/gvim-${VIM_PLUGIN_VIM_VERSION} )" @@ -31,14 +36,59 @@ if [[ ${PV} != 9999* ]] ; then fi SLOT="0" +if [[ ${_DEFINE_VIM_PLUGIN_SRC_PREPARE} ]]; then +# @FUNCTION: vim-plugin_src_prepare +# @USAGE: +# @DESCRIPTION: +# Moves "after/syntax" plugins to directories to avoid file collisions with +# other packages. +# Note that this function is only defined and exported in EAPIs >= 8. +vim-plugin_src_prepare() { + debug-print-function ${FUNCNAME} "${@}" + + default_src_prepare + + # return if there's nothing to do + [[ -d after/syntax ]] || return + + pushd after/syntax >/dev/null || die + for file in *.vim; do + [[ -f "${file}" ]] || continue + mkdir "${file%.vim}" || die + mv "${file}" "${file%.vim}/${PN}.vim" || die + done + popd >/dev/null || die +} +fi + +# @ECLASS_VARIABLE: _VIM_PLUGIN_ALLOWED_DIRS +# @INTERNAL +# @DESCRIPTION: +# Vanilla Vim dirs. +# See /usr/share/vim/vim* for reference. +_VIM_PLUGIN_ALLOWED_DIRS=( + after autoload colors compiler doc ftdetect ftplugin indent keymap + macros plugin spell syntax +) + # @FUNCTION: vim-plugin_src_install +# @USAGE: [<dir>...] # @DESCRIPTION: # Overrides the default src_install phase. In order, this function: -# * fixes file permission across all files in ${S}. +# # * installs help and documentation files. -# * installs all files in "${ED}"/usr/share/vim/vimfiles. +# +# * installs all files recognized by default Vim installation and directories +# passed to this function as arguments in "${ED}"/usr/share/vim/vimfiles. +# +# Example use: +# @CODE +# src_install() { +# vim-plugin_src_install syntax_checkers +# } +# @CODE vim-plugin_src_install() { - has "${EAPI:-0}" 0 1 2 && ! use prefix && ED="${D}" + debug-print-function ${FUNCNAME} "${@}" # Install non-vim-help-docs einstalldocs @@ -46,21 +96,35 @@ vim-plugin_src_install() { # Install remainder of plugin insinto /usr/share/vim/vimfiles/ local d - for d in *; do - [[ -d "${d}" ]] || continue - doins -r "${d}" - done + case ${EAPI:-0} in + 6|7) + for d in *; do + [[ -d "${d}" ]] || continue + doins -r "${d}" + done ;; + *) + for d in "${_VIM_PLUGIN_ALLOWED_DIRS[@]}" "${@}"; do + [[ -d "${d}" ]] || continue + doins -r "${d}" + done ;; + esac } # @FUNCTION: vim-plugin_pkg_postinst +# @USAGE: # @DESCRIPTION: # Overrides the pkg_postinst phase for this eclass. # The following functions are called: +# # * update_vim_helptags +# # * update_vim_afterscripts +# # * display_vim_plugin_help vim-plugin_pkg_postinst() { - update_vim_helptags # from vim-doc + debug-print-function ${FUNCNAME} "${@}" + + update_vim_helptags # from vim-doc update_vim_afterscripts # see below display_vim_plugin_help # see below } @@ -71,8 +135,9 @@ vim-plugin_pkg_postinst() { # This function calls the update_vim_helptags and update_vim_afterscripts # functions and eventually removes a bunch of empty directories. vim-plugin_pkg_postrm() { - has "${EAPI:-0}" 0 1 2 && ! use prefix && EPREFIX= - update_vim_helptags # from vim-doc + debug-print-function ${FUNCNAME} "${@}" + + update_vim_helptags # from vim-doc update_vim_afterscripts # see below # Remove empty dirs; this allows @@ -82,25 +147,26 @@ vim-plugin_pkg_postrm() { } # @FUNCTION: update_vim_afterscripts +# @USAGE: # @DESCRIPTION: # Creates scripts in /usr/share/vim/vimfiles/after/* # comprised of the snippets in /usr/share/vim/vimfiles/after/*/*.d update_vim_afterscripts() { - has "${EAPI:-0}" 0 1 2 && ! use prefix && EROOT="${ROOT}" - has "${EAPI:-0}" 0 1 2 && ! use prefix && EPREFIX= + debug-print-function ${FUNCNAME} "${@}" + local d f afterdir="${EROOT}"/usr/share/vim/vimfiles/after # Nothing to do if the dir isn't there - [ -d "${afterdir}" ] || return 0 + [[ -d "${afterdir}" ]] || return 0 - einfo "Updating scripts in ${EPREFIX}/usr/share/vim/vimfiles/after" + einfo "Updating scripts in ${afterdir}" find "${afterdir}" -type d -name \*.vim.d | while read d; do echo '" Generated by update_vim_afterscripts' > "${d%.d}" || die find "${d}" -name \*.vim -type f -maxdepth 1 -print0 | sort -z | \ xargs -0 cat >> "${d%.d}" || die "update_vim_afterscripts failed" done - einfo "Removing dead scripts in ${EPREFIX}/usr/share/vim/vimfiles/after" + einfo "Removing dead scripts in ${afterdir}" find "${afterdir}" -type f -name \*.vim | \ while read f; do [[ "$(head -n 1 ${f})" == '" Generated by update_vim_afterscripts' ]] \ @@ -115,6 +181,7 @@ update_vim_afterscripts() { } # @FUNCTION: display_vim_plugin_help +# @USAGE: # @DESCRIPTION: # Displays a message with the plugin's help file if one is available. Uses the # VIM_PLUGIN_HELPFILES env var. If multiple help files are available, they @@ -124,6 +191,8 @@ update_vim_afterscripts() { # extra message regarding enabling filetype plugins is displayed if # VIM_PLUGIN_MESSAGES includes the word "filetype". display_vim_plugin_help() { + debug-print-function ${FUNCNAME} "${@}" + local h if [[ -z ${REPLACING_VERSIONS} ]]; then @@ -160,3 +229,14 @@ display_vim_plugin_help() { fi fi } + +_VIM_PLUGIN_ECLASS=1 +fi + +EXPORT_FUNCTIONS src_install pkg_postinst pkg_postrm + +# src_prepare is only exported in EAPI >= 8 +case ${EAPI} in + 6|7) ;; + *) EXPORT_FUNCTIONS src_prepare ;; +esac diff --git a/eclass/waf-utils.eclass b/eclass/waf-utils.eclass index 7945cc869eb6..d5d52b9af247 100644 --- a/eclass/waf-utils.eclass +++ b/eclass/waf-utils.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: waf-utils.eclass @@ -29,6 +29,11 @@ esac # this is _not_ meant to be set in ebuilds : ${WAF_VERBOSE:=ON} +# @ECLASS_VARIABLE: WAF_BINARY +# @DESCRIPTION: +# Eclass can use different waf executable. Usually it is located +# in "${S}/waf". + # @FUNCTION: waf-utils_src_configure # @DESCRIPTION: # General function for configuring with waf. @@ -69,9 +74,6 @@ waf-utils_src_configure() { [[ ${fail} ]] && die "Invalid use of waf-utils.eclass" - # @ECLASS_VARIABLE: WAF_BINARY - # @DESCRIPTION: - # Eclass can use different waf executable. Usually it is located in "${S}/waf". : ${WAF_BINARY:="${S}/waf"} local conf_args=() diff --git a/eclass/xorg-3.eclass b/eclass/xorg-3.eclass index c68b3041629a..d7ff91417caf 100644 --- a/eclass/xorg-3.eclass +++ b/eclass/xorg-3.eclass @@ -152,6 +152,14 @@ BDEPEND+=" ${EAUTORECONF_DEPENDS}" unset EAUTORECONF_DEPENDS unset EAUTORECONF_DEPEND +# @ECLASS_VARIABLE: FONT_DIR +# @PRE_INHERIT +# @DESCRIPTION: +# If you're creating a font package and the suffix of PN is not equal to +# the subdirectory of /usr/share/fonts/ it should install into, set +# FONT_DIR to that directory or directories. Set before inheriting this +# eclass. + if [[ ${FONT} == yes ]]; then RDEPEND+=" media-fonts/encodings >=x11-apps/mkfontscale-1.2.0" @@ -160,13 +168,6 @@ if [[ ${FONT} == yes ]]; then >=x11-apps/mkfontscale-1.2.0" BDEPEND+=" x11-apps/bdftopcf" - # @ECLASS_VARIABLE: FONT_DIR - # @PRE_INHERIT - # @DESCRIPTION: - # If you're creating a font package and the suffix of PN is not equal to - # the subdirectory of /usr/share/fonts/ it should install into, set - # FONT_DIR to that directory or directories. Set before inheriting this - # eclass. [[ -z ${FONT_DIR} ]] && FONT_DIR=${PN##*-} # Fix case of font directories @@ -336,9 +337,12 @@ xorg-3_flags_setup() { # Win32 require special define [[ ${CHOST} == *-winnt* ]] && append-cppflags -DWIN32 -D__STDC__ - # hardened ldflags - [[ ${PN} == xorg-server || ${PN} == xf86-video-* || ${PN} == xf86-input-* ]] \ - && append-ldflags -Wl,-z,lazy + + # Hardened flags break module autoloading et al (also fixes #778494) + if [[ ${PN} == xorg-server || ${PN} == xf86-video-* || ${PN} == xf86-input-* ]]; then + filter-flags -fno-plt + append-ldflags -Wl,-z,lazy + fi # Quite few libraries fail on runtime without these: if has static-libs ${IUSE//+}; then @@ -352,6 +356,11 @@ multilib_src_configure() { ECONF_SOURCE="${S}" econf "${econfargs[@]}" } +# @VARIABLE: XORG_CONFIGURE_OPTIONS +# @DESCRIPTION: +# Array of an additional options to pass to configure. +# @DEFAULT_UNSET + # @FUNCTION: xorg-3_src_configure # @DESCRIPTION: # Perform any necessary pre-configuration steps, then run configure @@ -360,10 +369,6 @@ xorg-3_src_configure() { xorg-3_flags_setup - # @VARIABLE: XORG_CONFIGURE_OPTIONS - # @DESCRIPTION: - # Array of an additional options to pass to configure. - # @DEFAULT_UNSET local xorgconfadd=("${XORG_CONFIGURE_OPTIONS[@]}") local FONT_OPTIONS=() |