kernel: Use LLVM's substitutes for GNU binutils if possible
Co-authored-by: LuK1337 <priv.luk@gmail.com> Change-Id: I06884fb774b6548aad68942f1ce659384521c62a
This commit is contained in:
committed by
Michael Bestas
parent
87c0acd05e
commit
09a874fe75
@@ -1,4 +1,4 @@
|
|||||||
# Copyright (C) 2018-2020 The LineageOS Project
|
# Copyright (C) 2018-2022 The LineageOS Project
|
||||||
#
|
#
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
# you may not use this file except in compliance with the License.
|
# you may not use this file except in compliance with the License.
|
||||||
@@ -28,6 +28,9 @@
|
|||||||
# x86_64-linux-android- for x86
|
# x86_64-linux-android- for x86
|
||||||
#
|
#
|
||||||
# TARGET_KERNEL_CLANG_COMPILE = Compile kernel with clang, defaults to true
|
# TARGET_KERNEL_CLANG_COMPILE = Compile kernel with clang, 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.
|
||||||
#
|
#
|
||||||
# KERNEL_TOOLCHAIN_PREFIX = Overrides TARGET_KERNEL_CROSS_COMPILE_PREFIX,
|
# KERNEL_TOOLCHAIN_PREFIX = Overrides TARGET_KERNEL_CROSS_COMPILE_PREFIX,
|
||||||
# Set this var in shell to override
|
# Set this var in shell to override
|
||||||
@@ -49,6 +52,10 @@ else
|
|||||||
KERNEL_ARCH := $(TARGET_KERNEL_ARCH)
|
KERNEL_ARCH := $(TARGET_KERNEL_ARCH)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
KERNEL_VERSION := $(shell grep "^VERSION = " $(TARGET_KERNEL_SOURCE)/Makefile | awk '{ print $$3 }')
|
||||||
|
KERNEL_PATCHLEVEL := $(shell grep "^PATCHLEVEL = " $(TARGET_KERNEL_SOURCE)/Makefile | awk '{ print $$3 }')
|
||||||
|
TARGET_KERNEL_VERSION ?= $(shell echo $(KERNEL_VERSION)"."$(KERNEL_PATCHLEVEL))
|
||||||
|
|
||||||
CLANG_PREBUILTS := $(BUILD_TOP)/prebuilts/clang/host/$(HOST_PREBUILT_TAG)/clang-r416183b1
|
CLANG_PREBUILTS := $(BUILD_TOP)/prebuilts/clang/host/$(HOST_PREBUILT_TAG)/clang-r416183b1
|
||||||
GCC_PREBUILTS := $(BUILD_TOP)/prebuilts/gcc/$(HOST_PREBUILT_TAG)
|
GCC_PREBUILTS := $(BUILD_TOP)/prebuilts/gcc/$(HOST_PREBUILT_TAG)
|
||||||
# arm64 toolchain
|
# arm64 toolchain
|
||||||
@@ -147,6 +154,13 @@ KERNEL_MAKE_CMD := $(BUILD_TOP)/prebuilts/build-tools/$(HOST_PREBUILT_TAG)/bin/m
|
|||||||
KERNEL_MAKE_FLAGS += HOSTCC=$(CLANG_PREBUILTS)/bin/clang
|
KERNEL_MAKE_FLAGS += HOSTCC=$(CLANG_PREBUILTS)/bin/clang
|
||||||
KERNEL_MAKE_FLAGS += HOSTCXX=$(CLANG_PREBUILTS)/bin/clang++
|
KERNEL_MAKE_FLAGS += HOSTCXX=$(CLANG_PREBUILTS)/bin/clang++
|
||||||
|
|
||||||
|
# Use LLVM's substitutes for GNU binutils if compatible kernel version.
|
||||||
|
ifneq ($(TARGET_KERNEL_CLANG_COMPILE), false)
|
||||||
|
ifneq (,$(filter 5.4, $(TARGET_KERNEL_VERSION)))
|
||||||
|
KERNEL_MAKE_FLAGS += LLVM=1 LLVM_IAS=1
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
# Since Linux 4.16, flex and bison are required
|
# Since Linux 4.16, flex and bison are required
|
||||||
KERNEL_MAKE_FLAGS += LEX=$(BUILD_TOP)/prebuilts/build-tools/$(HOST_PREBUILT_TAG)/bin/flex
|
KERNEL_MAKE_FLAGS += LEX=$(BUILD_TOP)/prebuilts/build-tools/$(HOST_PREBUILT_TAG)/bin/flex
|
||||||
KERNEL_MAKE_FLAGS += YACC=$(BUILD_TOP)/prebuilts/build-tools/$(HOST_PREBUILT_TAG)/bin/bison
|
KERNEL_MAKE_FLAGS += YACC=$(BUILD_TOP)/prebuilts/build-tools/$(HOST_PREBUILT_TAG)/bin/bison
|
||||||
|
Reference in New Issue
Block a user