Gentoo Archives: gentoo-dev

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

Replies

Subject Author
Re: [gentoo-dev] [PATCH v2] toolchain-funcs.eclass: new function tc-ld-force-bfd() Manoj Gupta <manojgupta@××××××.com>