Gentoo Archives: gentoo-commits

From: Sergei Trofimovich <slyfox@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: eclass/
Date: Fri, 13 Sep 2019 18:43:09
Message-Id: 1568400176.463ec5b25ac36933127e726c553ad83994017aa1.slyfox@gentoo
1 commit: 463ec5b25ac36933127e726c553ad83994017aa1
2 Author: Manoj Gupta <manojgupta <AT> google <DOT> com>
3 AuthorDate: Thu Sep 12 11:32:40 2019 +0000
4 Commit: Sergei Trofimovich <slyfox <AT> gentoo <DOT> org>
5 CommitDate: Fri Sep 13 18:42:56 2019 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=463ec5b2
7
8 toolchain-funcs: Add tc-ld-is-lld helper.
9
10 LLD is a new linker for LLVM project.
11 Add tc-ld-is-lld helper to be able to detect it.
12
13 Signed-off-by: Manoj Gupta <manojgupta <AT> google.com>
14 Signed-off-by: Sergei Trofimovich <slyfox <AT> gentoo.org>
15
16 eclass/toolchain-funcs.eclass | 30 ++++++++++++++++++++++++++++++
17 1 file changed, 30 insertions(+)
18
19 diff --git a/eclass/toolchain-funcs.eclass b/eclass/toolchain-funcs.eclass
20 index 7bd90bb4e4a..e358d484417 100644
21 --- a/eclass/toolchain-funcs.eclass
22 +++ b/eclass/toolchain-funcs.eclass
23 @@ -453,6 +453,36 @@ tc-ld-is-gold() {
24 return 1
25 }
26
27 +# @FUNCTION: tc-ld-is-lld
28 +# @USAGE: [toolchain prefix]
29 +# @DESCRIPTION:
30 +# Return true if the current linker is set to lld.
31 +tc-ld-is-lld() {
32 + local out
33 +
34 + # First check the linker directly.
35 + out=$($(tc-getLD "$@") --version 2>&1)
36 + if [[ ${out} == *"LLD"* ]] ; then
37 + return 0
38 + fi
39 +
40 + # Then see if they're selecting lld via compiler flags.
41 + # Note: We're assuming they're using LDFLAGS to hold the
42 + # options and not CFLAGS/CXXFLAGS.
43 + local base="${T}/test-tc-lld"
44 + cat <<-EOF > "${base}.c"
45 + int main() { return 0; }
46 + EOF
47 + out=$($(tc-getCC "$@") ${CFLAGS} ${CPPFLAGS} ${LDFLAGS} -Wl,--version "${base}.c" -o "${base}" 2>&1)
48 + rm -f "${base}"*
49 + if [[ ${out} == *"LLD"* ]] ; then
50 + return 0
51 + fi
52 +
53 + # No lld here!
54 + return 1
55 +}
56 +
57 # @FUNCTION: tc-ld-disable-gold
58 # @USAGE: [toolchain prefix]
59 # @DESCRIPTION: