Gentoo Archives: gentoo-dev

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

Replies

Subject Author
[gentoo-dev] Re: [PATCH] toolchain-funcs: Add tc-ld-is-lld helper. Manoj Gupta <manojgupta@××××××.com>