device/generic/common
修訂 | 407d4a6049081b9632bd63cd3ef621f0b30040d2 (tree) |
---|---|
時間 | 2019-10-16 00:18:50 |
作者 | Chih-Wei Huang <cwhuang@linu...> |
Commiter | Chih-Wei Huang |
kernel.mk: fix several issues in Android 10
Android 10 has started restricting the external host tools usable inside
the build. The external tools can only be used with absolute path.
To avoid using host gcc, we build kernel host tools by AOSP's clang.
Note the kernel's makefile has a small issue to be fixed.
@@ -25,9 +25,10 @@ TARGET_KERNEL_CONFIG ?= goldfish_defconfig | ||
25 | 25 | KERNEL_CONFIG_DIR := arch/arm/configs |
26 | 26 | endif |
27 | 27 | |
28 | +KERNEL_CLANG_CLAGS := HOSTCC=$(abspath $(LLVM_PREBUILTS_PATH)/clang) | |
28 | 29 | ifeq ($(BUILD_KERNEL_WITH_CLANG),true) |
29 | 30 | CROSS_COMPILE := x86_64-linux-androidkernel- |
30 | -KERNEL_CLANG_CLAGS := CC=clang HOSTCC=clang CLANG_TRIPLE=x86_64-linux-gnu- PATH=$(abspath $(LLVM_PREBUILTS_BASE)/$(BUILD_OS)-x86/$(LLVM_PREBUILTS_VERSION)/bin):$$PATH | |
31 | +KERNEL_CLANG_CLAGS += CC=$(abspath $(LLVM_PREBUILTS_PATH)/clang) CLANG_TRIPLE=x86_64-linux-gnu- | |
31 | 32 | else |
32 | 33 | ifeq ($(TARGET_KERNEL_ARCH),x86_64) |
33 | 34 | ifeq ($(HOST_OS),darwin) |
@@ -41,7 +42,13 @@ endif | ||
41 | 42 | endif |
42 | 43 | |
43 | 44 | KBUILD_OUTPUT := $(TARGET_OUT_INTERMEDIATES)/kernel |
44 | -mk_kernel := + $(hide) $(MAKE) $(if $(filter darwin,$(HOST_OS)),-j$$(sysctl -n hw.ncpu) -l$$(($$(sysctl -n hw.ncpu)+2)),-j$$(nproc) -l$$(($$(nproc)+2))) \ | |
45 | +ifeq ($(HOST_OS),darwin) | |
46 | +KBUILD_JOBS := $(shell /usr/sbin/sysctl -n hw.ncpu) | |
47 | +else | |
48 | +KBUILD_JOBS := $(shell echo $$((1-(`cat /sys/devices/system/cpu/present`)))) | |
49 | +endif | |
50 | + | |
51 | +mk_kernel := + $(hide) prebuilts/build-tools/$(HOST_PREBUILT_TAG)/bin/make -j$(KBUILD_JOBS) -l$$(($(KBUILD_JOBS)+2)) \ | |
45 | 52 | -C $(KERNEL_DIR) O=$(abspath $(KBUILD_OUTPUT)) ARCH=$(TARGET_ARCH) CROSS_COMPILE="$(abspath $(CC_WRAPPER)) $(CROSS_COMPILE)" $(if $(SHOW_COMMANDS),V=1) \ |
46 | 53 | YACC=$(abspath $(BISON)) LEX=$(abspath $(LEX)) \ |
47 | 54 | $(KERNEL_CLANG_CLAGS) |
@@ -63,11 +70,16 @@ endif | ||
63 | 70 | $(KERNEL_DOTCONFIG_FILE): $(KERNEL_CONFIG_FILE) $(wildcard $(TARGET_KERNEL_DIFFCONFIG)) $(KERNEL_ARCH_CHANGED) |
64 | 71 | $(hide) mkdir -p $(@D) && cat $(wildcard $^) > $@ |
65 | 72 | $(hide) ln -sf ../../../../../../prebuilts $(@D) |
66 | - $(mk_kernel) olddefconfig | |
67 | 73 | $(hide) rm -f $(KERNEL_ARCH_CHANGED) |
68 | 74 | |
69 | 75 | BUILT_KERNEL_TARGET := $(KBUILD_OUTPUT)/arch/$(TARGET_ARCH)/boot/$(KERNEL_TARGET) |
70 | 76 | $(BUILT_KERNEL_TARGET): $(KERNEL_DOTCONFIG_FILE) |
77 | + # A dirty hack to use ar & ld | |
78 | + $(hide) mkdir -p $(OUT_DIR)/.path; ln -sf ../../$(LLVM_PREBUILTS_PATH)/llvm-ar $(OUT_DIR)/.path/ar; ln -sf ../../$(LLVM_PREBUILTS_PATH)/ld.lld $(OUT_DIR)/.path/ld | |
79 | +ifeq ($(BUILD_KERNEL_WITH_CLANG),true) | |
80 | + $(hide) cd $(OUT_DIR)/.path; ln -sf ../../$(dir $(TARGET_TOOLS_PREFIX))x86_64-linux-androidkernel-* .; ln -sf x86_64-linux-androidkernel-as x86_64-linux-gnu-as | |
81 | +endif | |
82 | + $(mk_kernel) olddefconfig | |
71 | 83 | $(mk_kernel) $(KERNEL_TARGET) $(if $(MOD_ENABLED),modules) |
72 | 84 | $(if $(FIRMWARE_ENABLED),$(mk_kernel) INSTALL_MOD_PATH=$(abspath $(TARGET_OUT)) firmware_install) |
73 | 85 |