Gentoo Archives: gentoo-dev

From: Manoj Gupta <manojgupta@××××××.com>
To: gentoo-dev@l.g.o
Subject: Re: [gentoo-dev] [PATCH v2] toolchain-funcs.eclass: new function tc-ld-force-bfd()
Date: Thu, 21 Jan 2021 21:51:15
Message-Id: CAH=QcsjugcbFE4ir3Ga7EhnrN-R2VkYZK4bg1NC+vDsJNi-DHQ@mail.gmail.com
In Reply to: [gentoo-dev] [PATCH v2] toolchain-funcs.eclass: new function tc-ld-force-bfd() by Theo Anderson
1 On Thu, Jan 21, 2021 at 3:00 AM Theo Anderson <telans@××××××.de> wrote:
2
3 > Hello, please see v2 of the tc-ld-force-bfd() patch below.
4 >
5 > v2 changes: only calls tc-ld-force-bfd from tc-ld-disable-gold if
6 > the gold linker is active.
7 >
8 > With this change ebuilds that require both ld.gold & ld.lld to be
9 > disabled will need to be updated to use tc-ld-force-bfd.
10 >
11 > Thanks, this patch is exactly the behavior I preferred :)
12
13
14 > From 761078671a7c31b1e3dc9c5c21f14941b70443ac Mon Sep 17 00:00:00 2001
15 > From: Theo Anderson <telans@××××××.de>
16 > Date: Thu, 21 Jan 2021 23:51:03 +1300
17 > Subject: [PATCH] toolchain-funcs.eclass: new function tc-ld-force-bfd()
18 >
19 > No functions currently force ld.bfd usage when ld.lld is active.
20 > This function forces ld.bfd when either ld.gold or ld.lld is active.
21 > tc-ld-disable-gold() now calls this new function
22 > only if ld.gold is active.
23 >
24 > Package-Manager: Portage-3.0.14, Repoman-3.0.2
25 > Signed-off-by: Theo Anderson <telans@××××××.de>
26 > ---
27 > eclass/toolchain-funcs.eclass | 21 +++++++++++++++------
28 > 1 file changed, 15 insertions(+), 6 deletions(-)
29 >
30 > diff --git a/eclass/toolchain-funcs.eclass
31 > b/eclass/toolchain-funcs.eclass index 4a4bb27fc08..267cf5cfce3 100644
32 > --- a/eclass/toolchain-funcs.eclass
33 > +++ b/eclass/toolchain-funcs.eclass
34 > @@ -1,4 +1,4 @@
35 > -# Copyright 2002-2019 Gentoo Authors
36 > +# Copyright 2002-2021 Gentoo Authors
37 > # Distributed under the terms of the GNU General Public License v2
38 >
39 > # @ECLASS: toolchain-funcs.eclass
40 > @@ -505,12 +505,21 @@ tc-ld-is-lld() {
41 > # If the gold linker is currently selected, configure the compilation
42 > # settings so that we use the older bfd linker instead.
43 > tc-ld-disable-gold() {
44 > - if ! tc-ld-is-gold "$@" ; then
45 > - # They aren't using gold, so nothing to do!
46 > + tc-ld-is-gold "$@" && tc-ld-force-bfd "$@"
47 > +}
48 > +
49 > +# @FUNCTION: tc-ld-force-bfd
50 > +# @USAGE: [toolchain prefix]
51 > +# @DESCRIPTION:
52 > +# If the gold or lld linker is currently selected, configure the
53 > compilation +# settings so that we use the bfd linker instead.
54 > +tc-ld-force-bfd() {
55 > + if ! tc-ld-is-gold "$@" && ! tc-ld-is-lld "$@" ; then
56 > + # They aren't using gold or lld, so nothing to do!
57 > return
58 > fi
59 >
60 > - ewarn "Forcing usage of the BFD linker instead of GOLD"
61 > + ewarn "Forcing usage of the BFD linker"
62 >
63 > # Set up LD to point directly to bfd if it's available.
64 > # We need to extract the first word in case there are flags
65 > appended @@ -520,7 +529,7 @@ tc-ld-disable-gold() {
66 > local path_ld=$(which "${bfd_ld}" 2>/dev/null)
67 > [[ -e ${path_ld} ]] && export LD=${bfd_ld}
68 >
69 > - # Set up LDFLAGS to select gold based on the gcc / clang
70 > version.
71 > + # Set up LDFLAGS to select bfd based on the gcc / clang
72 > version. local fallback="true"
73 > if tc-is-gcc; then
74 > local major=$(gcc-major-version "$@")
75 > @@ -548,7 +557,7 @@ tc-ld-disable-gold() {
76 > ln -sf "${path_ld}" "${d}"/ld
77 > export LDFLAGS="${LDFLAGS} -B${d}"
78 > else
79 > - die "unable to locate a BFD linker to bypass
80 > gold"
81 > + die "unable to locate a BFD linker"
82 > fi
83 > fi
84 > }
85 > --
86 > 2.30.0
87 >
88 >
89 >