arc-build: Export CCLD when selecting clang

When building with clang from arc-toolchain-n, we have to pass
--gcc-toolchain and -target in order to link correctly.  By default,
libtool strips flags it does not recognize from CFLAGS when constructing
the linker command-line, but it provides the -XCClinker flag to pass raw
arguments through.  We can't pass -XCClinker in CFLAGS because the
regular compiler frontend won't recognize it, but libtool also has a
special CCLD variable that represents the version of the compiler that
will be passed to libtool for linking.  By setting CCLD to CC plus the
needed flags, we can convince libtool to pass these flags through to the
linker without messing with the regular compiler.

CCLD is not picked up from the environment by automake and it isn't
filled in by configure (no AC_SUBST call), so ebuilds that use this will
need to call emake CCLD="$CCLD" to pass this through if they need it.
ebuilds that don't use clang for the compiler or don't use libtool
should be able to ignore CCLD.

BUG=b:64515630
TEST=Built arc-mesa for kahlee/eve with clang.

Change-Id: I01805378b0d6048ca4408d181853e4fd6fac69bf
Reviewed-on: https://chromium-review.googlesource.com/710577
Commit-Ready: Benjamin Gordon <bmgordon@chromium.org>
Tested-by: Benjamin Gordon <bmgordon@chromium.org>
Reviewed-by: Tomasz Figa <tfiga@chromium.org>
1 file changed