1 |
On Fri, Sep 13, 2019 at 7:32 AM Ulrich Mueller <ulm@g.o> wrote: |
2 |
> |
3 |
> >>>>> On Fri, 13 Sep 2019, Manoj Gupta 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 |
> |
31 |
> Why 2>&1 here, and not 2>/dev/null? |
32 |
> |
33 |
> >> + if [[ ${out} == *"LLD"* ]] ; then |
34 |
> >> + return 0 |
35 |
> >> + fi |
36 |
> >> + |
37 |
> >> + # Then see if they're selecting lld via compiler flags. |
38 |
> >> + # Note: We're assuming they're using LDFLAGS to hold the |
39 |
> >> + # options and not CFLAGS/CXXFLAGS. |
40 |
> >> + local base="${T}/test-tc-lld" |
41 |
> >> + cat <<-EOF > "${base}.c" |
42 |
> >> + int main() { return 0; } |
43 |
> >> + EOF |
44 |
> >> + out=$($(tc-getCC "$@") ${CFLAGS} ${CPPFLAGS} ${LDFLAGS} -Wl,--version "${base}.c" -o "${base}" 2>&1) |
45 |
> |
46 |
> Ditto. |
47 |
> |
48 |
> >> + rm -f "${base}"* |
49 |
> >> + if [[ ${out} == *"LLD"* ]] ; then |
50 |
> >> + return 0 |
51 |
> >> + fi |
52 |
> >> + |
53 |
> >> + # No lld here! |
54 |
> >> + return 1 |
55 |
> |
56 |
> The previous 6 lines could be shortened to one: |
57 |
> [[ ${out} == *"LLD"* ]] |
58 |
|
59 |
Thanks for the review. I did it this way to make this an exact copy of |
60 |
tc-ld-is-gold function above it except the LLD checks. |
61 |
Should I also change the tc-ld-is-gold function? |
62 |
> |
63 |
> >> +} |
64 |
> >> + |
65 |
> >> # @FUNCTION: tc-ld-disable-gold |
66 |
> >> # @USAGE: [toolchain prefix] |
67 |
> >> # @DESCRIPTION: |