build.config.msm.common: Use clang to compile DTC

Switch to use Clang for compiling DTC, in preparation for hermetic
toolchain. kernel/build provides nearly all the necessary flags.

 - Set CC to clang
 - set AR to llvm-ar
 - HOSTLDFLAGS and HOSTCFLAGS sets up sysroot
 - Also needed to explicitly add -fuse-ld=lld --rtlib=compiler-rt
   - Kbuild does this in the LLVM=1 path of top level Makefile
   - fuse-ld specifies which linker to use (ld.lld from clang prebuilts)
   - rtlib specifies which runtime library to use (use the builtin
     runtime library from clang).

Change-Id: I303c119b59c178685197a8444469e65ce907b37a
Signed-off-by: Elliot Berman <eberman@codeaurora.org>
This commit is contained in:
Elliot Berman 2021-04-21 10:29:10 -07:00
parent 905956970b
commit 8ccaf89920

View File

@ -20,9 +20,13 @@ function compile_external_dtc() {
(
OUT_DIR=${COMMON_OUT_DIR}/external/dtc
cd ${ROOT_DIR}/external/dtc
NO_PYTHON=1 CC=cc make all install PREFIX=${COMMON_OUT_DIR}/host
DTC_MAKE_ARGS=("CC=${HOSTCC}" "AR=${AR}")
DTC_MAKE_ARGS+=("LDFLAGS=${HOSTLDFLAGS} -fuse-ld=${LD##*.} --rtlib=compiler-rt")
DTC_MAKE_ARGS+=("EXTRA_CFLAGS=${HOSTCFLAGS}")
make all install "${DTC_MAKE_ARGS[@]}" NO_PYTHON=1 PREFIX=${COMMON_OUT_DIR}/host
)
}
ADDITIONAL_HOST_TOOLS=pkg-config
append_cmd PRE_DEFCONFIG_CMDS 'compile_external_dtc'
################################################################################