Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 700812

Summary: toolchain-funcs.eclass: tc-ld-is-gold doesn't strictly respect LD
Product: Gentoo Linux Reporter: Michał Górny <mgorny>
Component: EclassesAssignee: Gentoo Toolchain Maintainers <toolchain>
Status: RESOLVED FIXED    
Severity: normal    
Priority: Normal    
Version: unspecified   
Hardware: All   
OS: Linux   
Whiteboard:
Package list:
Runtime testing required: ---

Description Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2019-11-20 20:43:49 UTC
The following tests fail when 'ld' is set to gold:

 * Testing tc-ld-is-gold (bfd selected) ...                                                                                                  [ !! ]
 * Testing tc-ld-disable-gold (bfd selected) ...                                                                                             [ !! ]

This is because of a bug in tc-ld-is-gold.  The test is called with LD=ld.bfd override.  However, the function does the test in two parts:

1. It tests '$(tc-getLD "$@") --version' for gold,

2. If the above fails, it tests '$(tc-getCC "$@") [...] -Wl,--version' for gold.

Now, the LD override works only for the former but the latter apparently doesn't care for it.  Therefore, if system linker is set to gold, the second test comes positive independently of LD value.
Comment 1 Sergei Trofimovich (RETIRED) gentoo-dev 2019-12-13 08:32:20 UTC
tc-ld-is-gold() checks if any of $LD of $CC are using gold linker. It's arguably a problematic user configuration (or problematic test in this case) when one does not match another.

In test we'll need to convince CC to use bfd as well. One of ways to replicate it it to do an equivalent of tc-ld-disable-gold().

For example setting LDFLAGS to -fuse-ld=bfd should have the desired effect for at least gcc and clang. Or calling tc-ld-disable-gold() directly.
Comment 2 Larry the Git Cow gentoo-dev 2019-12-13 22:37:22 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=063d79790a2c0ee4542552f76334f511aaced319

commit 063d79790a2c0ee4542552f76334f511aaced319
Author:     Sergei Trofimovich <slyfox@gentoo.org>
AuthorDate: 2019-12-13 22:22:11 +0000
Commit:     Sergei Trofimovich <slyfox@gentoo.org>
CommitDate: 2019-12-13 22:37:12 +0000

    eclass/tests/toolchain-funcs.sh: fix gold tests, bug #700812
    
    As written tests assumed that $CC always called ld.bfd as a linker.
    
    The assumption fails when default linker is not ld.bfd,
    (for example sys-devel/binutils[default-gold]).
    
    The change uses LDFLAGS=-fuse-ld=bfd explicitly.
    
    Fixes the following tests:
     * Testing tc-ld-is-gold (bfd selected) ...       [ !! ]
     * Testing tc-ld-disable-gold (bfd selected) ...  [ !! ]
    
    Reported-by: Michał Górny
    Closes: https://bugs.gentoo.org/700812
    Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>

 eclass/tests/toolchain-funcs.sh | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)