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