Gentoo Archives: gentoo-dev

From: Manoj Gupta <manojgupta@××××××.com>
To: gentoo-dev@l.g.o
Subject: Re: [gentoo-dev] [PATCH] toolchain-funcs.eclass: new function tc-ld-force-bfd()
Date: Thu, 21 Jan 2021 02:41:36
Message-Id: CAH=QcshfEBYfr_RmbW2fdvcHhonKDLdvJe16JOYGpCnF8ZoSeQ@mail.gmail.com
In Reply to: [gentoo-dev] [PATCH] toolchain-funcs.eclass: new function tc-ld-force-bfd() by Theo Anderson
1 On Wed, Jan 20, 2021 at 1:01 PM Theo Anderson <telans@××××××.de> wrote:
2
3 > Hello, please see the below patch to support disabling ld.lld like
4 > ld.gold. This has not been split into a separate function
5 > such as tc-ld-disable-lld(), as I do not believe there is a use case
6 > where ld.gold is supported and ld.lld is not.
7 >
8 > Thanks.
9 >
10 > Pull-request: https://github.com/gentoo/gentoo/pull/19116
11 >
12 >
13 I am not a Gentoo maintainer but this forces bfd linker for the ebuilds
14 when gold is not even used e.g. lld is default linker. I am curious how
15 many places where gold is disabled do not work with lld.
16 In my experience, LLD is far more compatible with bfd than gold e.g. it can
17 link Linux kernels. So, imo we should not disable lld as a side effect when
18 the compatibility problem is with gold only.
19 i.e. It is ok to add a function to force bfd but disabling gold needs to
20 have a check if gold is the current linker.
21
22 My preference us to add 2 functions:
23 tc-ld-force-bfd
24 tc-ld-disable-lld
25
26 And tc-ld-disable-gold should check if gold is the current linker. If not,
27 only then force bfd.
28
29 What do the maintainers think?
30
31 Thanks,
32 Manoj
33
34
35
36
37 > From c0894e304cbd209ab2cf6b3754f75d9bfd93634a Mon Sep 17 00:00:00 2001
38 > From: Theo Anderson <telans@××××××.de>
39 > Date: Thu, 21 Jan 2021 09:59:09 +1300
40 > Subject: [PATCH] toolchain-funcs.eclass: new function tc-ld-force-bfd()
41 >
42 > No functions currently force bfd usage when lld is active.
43 > This function takes over tc-ld-disable-gold so that any current
44 > calls to tc-ld-disable-gold will also disable lld. With ld.ldd
45 > this fixes configure for packages like sys-libs/db where
46 > --default-symver is added to ldflags.
47 > tc-ld-disable-gold has been marked as deprecated and should be
48 > replaced by tc-ld-force-bfd within ebuilds.
49 >
50 > Package-Manager: Portage-3.0.14, Repoman-3.0.2
51 > Signed-off-by: Theo Anderson <telans@××××××.de>
52 > ---
53 > eclass/toolchain-funcs.eclass | 23 +++++++++++++++++------
54 > 1 file changed, 17 insertions(+), 6 deletions(-)
55 >
56 > diff --git a/eclass/toolchain-funcs.eclass
57 > b/eclass/toolchain-funcs.eclass index 4a4bb27fc08..2cf7ddfb790 100644
58 > --- a/eclass/toolchain-funcs.eclass
59 > +++ b/eclass/toolchain-funcs.eclass
60 > @@ -1,4 +1,4 @@
61 > -# Copyright 2002-2019 Gentoo Authors
62 > +# Copyright 2002-2021 Gentoo Authors
63 > # Distributed under the terms of the GNU General Public License v2
64 >
65 > # @ECLASS: toolchain-funcs.eclass
66 > @@ -502,15 +502,26 @@ tc-ld-is-lld() {
67 > # @FUNCTION: tc-ld-disable-gold
68 > # @USAGE: [toolchain prefix]
69 > # @DESCRIPTION:
70 > +# Deprecated in favor of tc-ld-force-bfd.
71 > +#
72 > # If the gold linker is currently selected, configure the compilation
73 > # settings so that we use the older bfd linker instead.
74 > tc-ld-disable-gold() {
75 > - if ! tc-ld-is-gold "$@" ; then
76 > - # They aren't using gold, so nothing to do!
77 > + tc-ld-force-bfd "$@"
78 > +}
79 > +
80 > +# @FUNCTION: tc-ld-force-bfd
81 > +# @USAGE: [toolchain prefix]
82 > +# @DESCRIPTION:
83 > +# If the gold or lld linker is currently selected, configure the
84 > compilation +# settings so that we use the bfd linker instead.
85 > +tc-ld-force-bfd() {
86 > + if ! tc-ld-is-gold "$@" && ! tc-ld-is-lld "$@" ; then
87 > + # They aren't using gold or lld, so nothing to do!
88 > return
89 > fi
90 >
91 > - ewarn "Forcing usage of the BFD linker instead of GOLD"
92 > + ewarn "Forcing usage of the BFD linker"
93 >
94 > # Set up LD to point directly to bfd if it's available.
95 > # We need to extract the first word in case there are flags
96 > appended @@ -520,7 +531,7 @@ tc-ld-disable-gold() {
97 > local path_ld=$(which "${bfd_ld}" 2>/dev/null)
98 > [[ -e ${path_ld} ]] && export LD=${bfd_ld}
99 >
100 > - # Set up LDFLAGS to select gold based on the gcc / clang
101 > version.
102 > + # Set up LDFLAGS to select bfd based on the gcc / clang
103 > version. local fallback="true"
104 > if tc-is-gcc; then
105 > local major=$(gcc-major-version "$@")
106 > @@ -548,7 +559,7 @@ tc-ld-disable-gold() {
107 > ln -sf "${path_ld}" "${d}"/ld
108 > export LDFLAGS="${LDFLAGS} -B${d}"
109 > else
110 > - die "unable to locate a BFD linker to bypass
111 > gold"
112 > + die "unable to locate a BFD linker"
113 > fi
114 > fi
115 > }
116 > --
117 > 2.30.0
118 >
119 >
120 >

Replies