Gentoo Archives: gentoo-dev

From: Manoj Gupta <manojgupta@××××××.com>
To: gentoo-dev@l.g.o
Subject: [gentoo-dev] Re: [PATCH] toolchain-funcs: Add tc-ld-is-lld helper.
Date: Fri, 13 Sep 2019 14:11:25
Message-Id: CAH=QcsjVD67uipu8HDcOYo-O6CW45YsFXiZ3dHrSfbk5ov3YYg@mail.gmail.com
In Reply to: [gentoo-dev] [PATCH] toolchain-funcs: Add tc-ld-is-lld helper. by Manoj Gupta
1 friendly ping for patch review.
2
3 On Thu, Sep 12, 2019 at 4:32 AM Manoj Gupta <manojgupta@××××××.com> wrote:
4 >
5 > LLD is a new linker for LLVM project.
6 > Add tc-ld-is-lld helper to be able to detect it.
7 >
8 > Signed-off-by: Manoj Gupta <manojgupta@××××××.com>
9 > ---
10 > eclass/toolchain-funcs.eclass | 30 ++++++++++++++++++++++++++++++
11 > 1 file changed, 30 insertions(+)
12 >
13 > diff --git a/eclass/toolchain-funcs.eclass b/eclass/toolchain-funcs.eclass
14 > index 7bd90bb4e4a..e358d484417 100644
15 > --- a/eclass/toolchain-funcs.eclass
16 > +++ b/eclass/toolchain-funcs.eclass
17 > @@ -453,6 +453,36 @@ tc-ld-is-gold() {
18 > return 1
19 > }
20 >
21 > +# @FUNCTION: tc-ld-is-lld
22 > +# @USAGE: [toolchain prefix]
23 > +# @DESCRIPTION:
24 > +# Return true if the current linker is set to lld.
25 > +tc-ld-is-lld() {
26 > + local out
27 > +
28 > + # First check the linker directly.
29 > + out=$($(tc-getLD "$@") --version 2>&1)
30 > + if [[ ${out} == *"LLD"* ]] ; then
31 > + return 0
32 > + fi
33 > +
34 > + # Then see if they're selecting lld via compiler flags.
35 > + # Note: We're assuming they're using LDFLAGS to hold the
36 > + # options and not CFLAGS/CXXFLAGS.
37 > + local base="${T}/test-tc-lld"
38 > + cat <<-EOF > "${base}.c"
39 > + int main() { return 0; }
40 > + EOF
41 > + out=$($(tc-getCC "$@") ${CFLAGS} ${CPPFLAGS} ${LDFLAGS} -Wl,--version "${base}.c" -o "${base}" 2>&1)
42 > + rm -f "${base}"*
43 > + if [[ ${out} == *"LLD"* ]] ; then
44 > + return 0
45 > + fi
46 > +
47 > + # No lld here!
48 > + return 1
49 > +}
50 > +
51 > # @FUNCTION: tc-ld-disable-gold
52 > # @USAGE: [toolchain prefix]
53 > # @DESCRIPTION:
54 > --
55 > 2.23.0.162.g0b9fbb3734-goog
56 >

Replies