Gentoo Archives: gentoo-dev

From: Theo Anderson <telans@××××××.de>
To: gentoo-dev@l.g.o
Subject: [gentoo-dev] [PATCH] toolchain-funcs.eclass: new function tc-ld-force-bfd()
Date: Wed, 20 Jan 2021 21:01:15
Message-Id: 20210121100059.7479182d@genbox
1 Hello, please see the below patch to support disabling ld.lld like
2 ld.gold. This has not been split into a separate function
3 such as tc-ld-disable-lld(), as I do not believe there is a use case
4 where ld.gold is supported and ld.lld is not.
5
6 Thanks.
7
8 Pull-request: https://github.com/gentoo/gentoo/pull/19116
9
10 From c0894e304cbd209ab2cf6b3754f75d9bfd93634a Mon Sep 17 00:00:00 2001
11 From: Theo Anderson <telans@××××××.de>
12 Date: Thu, 21 Jan 2021 09:59:09 +1300
13 Subject: [PATCH] toolchain-funcs.eclass: new function tc-ld-force-bfd()
14
15 No functions currently force bfd usage when lld is active.
16 This function takes over tc-ld-disable-gold so that any current
17 calls to tc-ld-disable-gold will also disable lld. With ld.ldd
18 this fixes configure for packages like sys-libs/db where
19 --default-symver is added to ldflags.
20 tc-ld-disable-gold has been marked as deprecated and should be
21 replaced by tc-ld-force-bfd within ebuilds.
22
23 Package-Manager: Portage-3.0.14, Repoman-3.0.2
24 Signed-off-by: Theo Anderson <telans@××××××.de>
25 ---
26 eclass/toolchain-funcs.eclass | 23 +++++++++++++++++------
27 1 file changed, 17 insertions(+), 6 deletions(-)
28
29 diff --git a/eclass/toolchain-funcs.eclass
30 b/eclass/toolchain-funcs.eclass index 4a4bb27fc08..2cf7ddfb790 100644
31 --- a/eclass/toolchain-funcs.eclass
32 +++ b/eclass/toolchain-funcs.eclass
33 @@ -1,4 +1,4 @@
34 -# Copyright 2002-2019 Gentoo Authors
35 +# Copyright 2002-2021 Gentoo Authors
36 # Distributed under the terms of the GNU General Public License v2
37
38 # @ECLASS: toolchain-funcs.eclass
39 @@ -502,15 +502,26 @@ tc-ld-is-lld() {
40 # @FUNCTION: tc-ld-disable-gold
41 # @USAGE: [toolchain prefix]
42 # @DESCRIPTION:
43 +# Deprecated in favor of tc-ld-force-bfd.
44 +#
45 # If the gold linker is currently selected, configure the compilation
46 # settings so that we use the older bfd linker instead.
47 tc-ld-disable-gold() {
48 - if ! tc-ld-is-gold "$@" ; then
49 - # They aren't using gold, so nothing to do!
50 + tc-ld-force-bfd "$@"
51 +}
52 +
53 +# @FUNCTION: tc-ld-force-bfd
54 +# @USAGE: [toolchain prefix]
55 +# @DESCRIPTION:
56 +# If the gold or lld linker is currently selected, configure the
57 compilation +# settings so that we use the bfd linker instead.
58 +tc-ld-force-bfd() {
59 + if ! tc-ld-is-gold "$@" && ! tc-ld-is-lld "$@" ; then
60 + # They aren't using gold or lld, so nothing to do!
61 return
62 fi
63
64 - ewarn "Forcing usage of the BFD linker instead of GOLD"
65 + ewarn "Forcing usage of the BFD linker"
66
67 # Set up LD to point directly to bfd if it's available.
68 # We need to extract the first word in case there are flags
69 appended @@ -520,7 +531,7 @@ tc-ld-disable-gold() {
70 local path_ld=$(which "${bfd_ld}" 2>/dev/null)
71 [[ -e ${path_ld} ]] && export LD=${bfd_ld}
72
73 - # Set up LDFLAGS to select gold based on the gcc / clang
74 version.
75 + # Set up LDFLAGS to select bfd based on the gcc / clang
76 version. local fallback="true"
77 if tc-is-gcc; then
78 local major=$(gcc-major-version "$@")
79 @@ -548,7 +559,7 @@ tc-ld-disable-gold() {
80 ln -sf "${path_ld}" "${d}"/ld
81 export LDFLAGS="${LDFLAGS} -B${d}"
82 else
83 - die "unable to locate a BFD linker to bypass
84 gold"
85 + die "unable to locate a BFD linker"
86 fi
87 fi
88 }
89 --
90 2.30.0

Replies

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