Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 586474 - kernel-2.eclass:detect_arch() / toolchain-funcs.eclass:tc-ninja_magic_to_arch() trigger call to KV_to_int() in global scope
Summary: kernel-2.eclass:detect_arch() / toolchain-funcs.eclass:tc-ninja_magic_to_arch...
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Eclasses (show other bugs)
Hardware: All Linux
: Highest major (vote)
Assignee: Gentoo Kernel Bug Wranglers and Kernel Maintainers
: 586470 586472 586476 586478 586480 587000 (view as bug list)
Depends on:
Blocks: 384041
  Show dependency tree
Reported: 2016-06-20 15:21 UTC by Göktürk Yüksek
Modified: 2016-06-27 18:30 UTC (History)
5 users (show)

See Also:
Package list:
Runtime testing required: ---


Note You need to log in before you can comment on or make changes to this bug.
Description Göktürk Yüksek archtester gentoo-dev 2016-06-20 15:21:23 UTC
The call to detect_arch() results in a call to KV_to_int() down the call stack. This call is completely useless in the global scope during ebuild sourcing and future versions of portage will die on this behavior. Please migrate them to pkg_setup() or a similar phase.
Comment 1 Arfrever Frehtes Taifersar Arahesis 2016-06-20 23:36:38 UTC
Example output of Portage:

 * ERROR: sys-kernel/gentoo-sources-4.6.2::gentoo failed (depend phase):
 *   KV_to_int() calls are not allowed in global scope
 * Call stack:
 *           , line  606:  Called source '/var/db/repositories/gentoo/sys-kernel/gentoo-sources/gentoo-sources-4.6.2.ebuild'
 *   gentoo-sources-4.6.2.ebuild, line   14:  Called detect_arch
 *               kernel-2.eclass, line 1220:  Called tc-arch-kernel
 *        toolchain-funcs.eclass, line  550:  Called tc-ninja_magic_to_arch 'kern'
 *        toolchain-funcs.eclass, line  532:  Called KV_to_int '4.6.2-gentoo'
 *           , line   78:  Called die
 * The specific snippet of code:
 *              eval "${x}() { die \"\${FUNCNAME}() calls are not allowed in global scope\"; }"


detect_arch() {
        # This function sets ARCH_URI and ARCH_PATCH
        # with the neccessary info for the arch sepecific compatibility
        # patchsets.
        # ARCH_URI is the URI for all the ${ARCH}_URI patches
        # ARCH_PATCH is ARCH_URI broken into files for UNIPATCH

ARCH_URI is used in SRC_URI, which must be set in global scope.
So detect_arch() or tc-ninja_magic_to_arch() should be improved.
Comment 2 SpanKY gentoo-dev 2016-06-21 00:32:12 UTC
*** Bug 586470 has been marked as a duplicate of this bug. ***
Comment 3 SpanKY gentoo-dev 2016-06-21 00:32:18 UTC
*** Bug 586472 has been marked as a duplicate of this bug. ***
Comment 4 SpanKY gentoo-dev 2016-06-21 00:32:22 UTC
*** Bug 586476 has been marked as a duplicate of this bug. ***
Comment 5 SpanKY gentoo-dev 2016-06-21 00:32:27 UTC
*** Bug 586478 has been marked as a duplicate of this bug. ***
Comment 6 SpanKY gentoo-dev 2016-06-21 00:32:33 UTC
*** Bug 586480 has been marked as a duplicate of this bug. ***
Comment 7 SpanKY gentoo-dev 2016-06-21 00:33:27 UTC
there's no value in filing bugs against every package.  this is how all the ebuilds work with this eclass, so we'll simply fix them all together at the same time.
Comment 8 Mike Gilbert gentoo-dev 2016-06-25 17:45:01 UTC
*** Bug 587000 has been marked as a duplicate of this bug. ***
Comment 9 Jeroen Roovers (RETIRED) gentoo-dev 2016-06-26 09:18:01 UTC
With newer app-portage/repoman it is now impossible to work in any directory with an ebuild that inherits kernel-2.eclass.
Comment 10 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2016-06-27 05:49:16 UTC
Now, the real fun fact is that those functions got in the ban only because previously they were replaced by 'return 1' in global scope. I'd say KV_to_int() did not deserve that... but that also means it actually did not work as expected in global scope for a long time...
Comment 11 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2016-06-27 06:01:10 UTC
commit 81c226e451be564a545696f93fc5880ebc160812
Author:     Michał Górny <>
AuthorDate: Mon Jun 27 07:52:14 2016
Commit:     Michał Górny <>
CommitDate: Mon Jun 27 07:58:14 2016

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

This should fix the immediate issue. As ulm pointed out, we no longer have <2.6.24 sources in-tree, so this shouldn't do any harm. Originally I wanted to use versionator.eclass for this but due to some careless developer it is impossible without inherit loops.

However, we really need to put more effort into this. All Portage KV_* uses need to be removed and banned. Also we need to look for any other possible Portage functions, and possible leftovers of old global $KV variable.