kernel: Use LLVM binutils by default

* GCC has been completely removed in AOSP but we keep it
  for compatibility reasons with older kernels until they
  are adapted to remove all the dependencies to GCC.
* Most updated 4.19+ kernels should be able to use LLVM
  binutils out of the box. 4.14 is possible with a few patches
  and 4.9 with even more patches.
* Make this the default and allow devices opting out by using
  TARGET_KERNEL_LLVM_BINUTILS := false

Change-Id: I569cf290b41aaf2dc16ff9cc4cc6dc461f0d504e
This commit is contained in:
Michael Bestas
2022-09-08 04:19:32 +03:00
parent 57687fd6ce
commit bca38c6f68

View File

@@ -27,6 +27,7 @@
# x86_64-linux-android- for x86
#
# TARGET_KERNEL_CLANG_COMPILE = Compile kernel with clang, defaults to true
# TARGET_KERNEL_LLVM_BINUTILS = Use LLVM binutils, defaults to true
# TARGET_KERNEL_VERSION = Reported kernel version in top level kernel
# makefile. Can be overriden in device trees
# in the event of prebuilt kernel.
@@ -172,9 +173,9 @@ KERNEL_MAKE_CMD := $(BUILD_TOP)/prebuilts/build-tools/$(HOST_PREBUILT_TAG)/bin/m
KERNEL_MAKE_FLAGS += HOSTCC=$(CLANG_PREBUILTS)/bin/clang
KERNEL_MAKE_FLAGS += HOSTCXX=$(CLANG_PREBUILTS)/bin/clang++
# Use LLVM's substitutes for GNU binutils if compatible kernel version.
# Use LLVM's substitutes for GNU binutils
ifneq ($(TARGET_KERNEL_CLANG_COMPILE), false)
ifneq (,$(filter 5.4 5.10, $(TARGET_KERNEL_VERSION)))
ifneq ($(TARGET_KERNEL_LLVM_BINUTILS), false)
KERNEL_MAKE_FLAGS += LLVM=1 LLVM_IAS=1
KERNEL_MAKE_FLAGS += LD=$(CLANG_PREBUILTS)/bin/ld.lld
KERNEL_MAKE_FLAGS += AR=$(CLANG_PREBUILTS)/bin/llvm-ar