On Fri, Sep 13, 2019 at 7:32 AM Ulrich Mueller <[email protected]> wrote:
>
> >>>>> On Fri, 13 Sep 2019, Manoj Gupta wrote:
>
> >> LLD is a new linker for LLVM project.
> >> Add tc-ld-is-lld helper to be able to detect it.
> >>
> >> Signed-off-by: Manoj Gupta <[email protected]>
> >> ---
> >> eclass/toolchain-funcs.eclass | 30 ++++++++++++++++++++++++++++++
> >> 1 file changed, 30 insertions(+)
> >>
> >> diff --git a/eclass/toolchain-funcs.eclass b/eclass/toolchain-funcs.eclass
> >> index 7bd90bb4e4a..e358d484417 100644
> >> --- a/eclass/toolchain-funcs.eclass
> >> +++ b/eclass/toolchain-funcs.eclass
> >> @@ -453,6 +453,36 @@ tc-ld-is-gold() {
> >>  return 1
> >>  }
> >>
> >> +# @FUNCTION: tc-ld-is-lld
> >> +# @USAGE: [toolchain prefix]
> >> +# @DESCRIPTION:
> >> +# Return true if the current linker is set to lld.
> >> +tc-ld-is-lld() {
> >> +       local out
> >> +
> >> +       # First check the linker directly.
> >> +       out=$($(tc-getLD "$@") --version 2>&1)
>
> Why 2>&1 here, and not 2>/dev/null?
>
> >> +       if [[ ${out} == *"LLD"* ]] ; then
> >> +               return 0
> >> +       fi
> >> +
> >> +       # Then see if they're selecting lld via compiler flags.
> >> +       # Note: We're assuming they're using LDFLAGS to hold the
> >> +       # options and not CFLAGS/CXXFLAGS.
> >> +       local base="${T}/test-tc-lld"
> >> +       cat <<-EOF > "${base}.c"
> >> +       int main() { return 0; }
> >> +       EOF
> >> +       out=$($(tc-getCC "$@") ${CFLAGS} ${CPPFLAGS} ${LDFLAGS} 
> >> -Wl,--version "${base}.c" -o "${base}" 2>&1)
>
> Ditto.
>
> >> +       rm -f "${base}"*
> >> +       if [[ ${out} == *"LLD"* ]] ; then
> >> +               return 0
> >> +       fi
> >> +
> >> +       # No lld here!
> >> +       return 1
>
> The previous 6 lines could be shortened to one:
> [[ ${out} == *"LLD"* ]]

Thanks for the review. I did it this way to make this an exact copy of
tc-ld-is-gold function above it except the LLD checks.
Should I also change the  tc-ld-is-gold function?
>
> >> +}
> >> +
> >>  # @FUNCTION: tc-ld-disable-gold
> >>  # @USAGE: [toolchain prefix]
> >>  # @DESCRIPTION:

Reply via email to