diff --git a/config/BoardConfigKernel.mk b/config/BoardConfigKernel.mk index c8aeb798..9543d09c 100644 --- a/config/BoardConfigKernel.mk +++ b/config/BoardConfigKernel.mk @@ -1,4 +1,4 @@ -# Copyright (C) 2018 The LineageOS Project +# Copyright (C) 2018-2020 The LineageOS Project # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -25,6 +25,7 @@ # TARGET_KERNEL_CROSS_COMPILE_PREFIX = Compiler prefix (e.g. arm-eabi-) # defaults to arm-linux-androidkernel- for arm # aarch64-linux-android- for arm64 +# x86_64-linux-android- for x86 # # TARGET_KERNEL_CLANG_COMPILE = Compile kernel with clang, defaults to false # TARGET_KERNEL_NEW_GCC_COMPILE = Compile kernel with newer version GCC, defaults to false @@ -41,9 +42,6 @@ BUILD_TOP := $(shell pwd) TARGET_AUTO_KDIR := $(shell echo $(TARGET_DEVICE_DIR) | sed -e 's/^device/kernel/g') TARGET_KERNEL_SOURCE ?= $(TARGET_AUTO_KDIR) -ifneq ($(TARGET_PREBUILT_KERNEL),) -TARGET_KERNEL_SOURCE := -endif TARGET_KERNEL_ARCH := $(strip $(TARGET_KERNEL_ARCH)) ifeq ($(TARGET_KERNEL_ARCH),) @@ -52,6 +50,15 @@ else KERNEL_ARCH := $(TARGET_KERNEL_ARCH) endif +CLANG_PREBUILTS := $(BUILD_TOP)/prebuilts/clang/host/$(HOST_PREBUILT_TAG)/clang-r383902b +GCC_PREBUILTS := $(BUILD_TOP)/prebuilts/gcc/$(HOST_PREBUILT_TAG) + +TARGET_KERNEL_HEADERS ?= $(TARGET_KERNEL_SOURCE) + +# x86 toolchain +KERNEL_TOOLCHAIN_x86 := $(GCC_PREBUILTS)/x86/x86_64-linux-android-4.9/bin +KERNEL_TOOLCHAIN_PREFIX_x86 := x86_64-linux-android- + GCC_PREBUILTS := $(BUILD_TOP)/prebuilts/gcc/$(HOST_OS)-x86 ifeq ($(TARGET_KERNEL_NEW_GCC_COMPILE),true) ifeq ($(TARGET_KERNEL_CLANG_COMPILE),true) @@ -71,6 +78,7 @@ else KERNEL_TOOLCHAIN_arm := $(GCC_PREBUILTS)/arm/arm-linux-androideabi-4.9/bin KERNEL_TOOLCHAIN_PREFIX_arm := arm-linux-androidkernel- endif + TARGET_KERNEL_CROSS_COMPILE_PREFIX := $(strip $(TARGET_KERNEL_CROSS_COMPILE_PREFIX)) ifneq ($(TARGET_KERNEL_CROSS_COMPILE_PREFIX),) KERNEL_TOOLCHAIN_PREFIX ?= $(TARGET_KERNEL_CROSS_COMPILE_PREFIX) @@ -90,15 +98,9 @@ endif KERNEL_TOOLCHAIN_PATH_gcc := $(KERNEL_TOOLCHAIN_$(KERNEL_ARCH))/$(KERNEL_TOOLCHAIN_PREFIX_$(KERNEL_ARCH)) ifneq ($(USE_CCACHE),) - # Detect if the system already has ccache installed to use instead of the prebuilt - ifneq (,$(wildcard $(OUT_DIR)/.path_interposer_origpath)) - CCACHE_BIN := $(shell PATH=$(shell cat $(OUT_DIR)/.path_interposer_origpath):$$PATH which ccache) - endif - - ifeq ($(CCACHE_BIN),) - CCACHE_BIN := $(BUILD_TOP)/prebuilts/misc/$(HOST_PREBUILT_TAG)/ccache/ccache - # Check that the executable is here. - CCACHE_BIN := $(strip $(wildcard $(CCACHE_BIN))) + ifneq ($(CCACHE_EXEC),) + # Android 10+ deprecates use of a build ccache. Only system installed ones are now allowed + CCACHE_BIN := $(CCACHE_EXEC) endif endif @@ -117,9 +119,7 @@ endif KERNEL_MAKE_FLAGS := # Add back threads, ninja cuts this to $(nproc)/2 -ifneq (,$(wildcard $(OUT_DIR)/.path_interposer_origpath)) -KERNEL_MAKE_FLAGS += -j$(shell PATH=$(shell cat $(OUT_DIR)/.path_interposer_origpath):$$PATH nproc --all) -endif +KERNEL_MAKE_FLAGS += -j$(shell prebuilts/tools-lineage/$(HOST_PREBUILT_TAG)/bin/nproc --all) ifeq ($(KERNEL_ARCH),arm) # Avoid "Unknown symbol _GLOBAL_OFFSET_TABLE_" errors @@ -132,21 +132,38 @@ ifeq ($(KERNEL_ARCH),arm64) endif ifeq ($(HOST_OS),darwin) - KERNEL_MAKE_FLAGS += C_INCLUDE_PATH=$(BUILD_TOP)/external/elfutils/libelf:/usr/local/opt/openssl/include - KERNEL_MAKE_FLAGS += LIBRARY_PATH=/usr/local/opt/openssl/lib + KERNEL_MAKE_FLAGS += HOSTCFLAGS="-I$(BUILD_TOP)/external/elfutils/libelf -I/usr/local/opt/openssl/include -fuse-ld=lld" HOSTLDFLAGS="-L/usr/local/opt/openssl/lib -fuse-ld=lld" +else + KERNEL_MAKE_FLAGS += CPATH="/usr/include:/usr/include/x86_64-linux-gnu" HOSTCFLAGS="-fuse-ld=lld" HOSTLDFLAGS="-L/usr/lib/x86_64-linux-gnu -L/usr/lib64 -fuse-ld=lld" endif ifneq ($(TARGET_KERNEL_ADDITIONAL_FLAGS),) KERNEL_MAKE_FLAGS += $(TARGET_KERNEL_ADDITIONAL_FLAGS) endif +TOOLS_PATH_OVERRIDE := \ + PATH=$(BUILD_TOP)/prebuilts/tools-lineage/$(HOST_PREBUILT_TAG)/bin:$$PATH \ + LD_LIBRARY_PATH=$(BUILD_TOP)/prebuilts/tools-lineage/$(HOST_PREBUILT_TAG)/lib:$$LD_LIBRARY_PATH \ + PERL5LIB=$(BUILD_TOP)/prebuilts/tools-lineage/common/perl-base + # Set DTBO image locations so the build system knows to build them -ifeq ($(TARGET_NEEDS_DTBOIMAGE),true) -BOARD_PREBUILT_DTBOIMAGE ?= $(PRODUCT_OUT)/dtbo/arch/$(KERNEL_ARCH)/boot/dtbo.img -else ifeq ($(BOARD_KERNEL_SEPARATED_DTBO),true) -BOARD_PREBUILT_DTBOIMAGE ?= $(PRODUCT_OUT)/dtbo-pre.img +ifeq (true,$(filter true, $(TARGET_NEEDS_DTBOIMAGE) $(BOARD_KERNEL_SEPARATED_DTBO))) +BOARD_PREBUILT_DTBOIMAGE ?= $(TARGET_OUT_INTERMEDIATES)/DTBO_OBJ/arch/$(KERNEL_ARCH)/boot/dtbo.img endif +# Set use the full path to the make command +KERNEL_MAKE_CMD := $(BUILD_TOP)/prebuilts/build-tools/$(HOST_PREBUILT_TAG)/bin/make + +# Set the full path to the clang command +KERNEL_MAKE_FLAGS += HOSTCC=$(CLANG_PREBUILTS)/bin/clang +KERNEL_MAKE_FLAGS += HOSTCXX=$(CLANG_PREBUILTS)/bin/clang++ + +# 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 += YACC=$(BUILD_TOP)/prebuilts/build-tools/$(HOST_PREBUILT_TAG)/bin/bison +KERNEL_MAKE_FLAGS += M4=$(BUILD_TOP)/prebuilts/build-tools/$(HOST_PREBUILT_TAG)/bin/m4 +TOOLS_PATH_OVERRIDE += BISON_PKGDATADIR=$(BUILD_TOP)/prebuilts/build-tools/common/bison + # Set the out dir for the kernel's O= arg # This needs to be an absolute path, so only set this if the standard out dir isn't used OUT_DIR_PREFIX := $(shell echo $(OUT_DIR) | sed -e 's|/target/.*$$||g')