• R/O
  • HTTP
  • SSH
  • HTTPS

提交

標籤
無標籤

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

device/generic/common


Commit MetaInfo

修訂407d4a6049081b9632bd63cd3ef621f0b30040d2 (tree)
時間2019-10-16 00:18:50
作者Chih-Wei Huang <cwhuang@linu...>
CommiterChih-Wei Huang

Log Message

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.

Change Summary

差異

--- a/build/tasks/kernel.mk
+++ b/build/tasks/kernel.mk
@@ -25,9 +25,10 @@ TARGET_KERNEL_CONFIG ?= goldfish_defconfig
2525 KERNEL_CONFIG_DIR := arch/arm/configs
2626 endif
2727
28+KERNEL_CLANG_CLAGS := HOSTCC=$(abspath $(LLVM_PREBUILTS_PATH)/clang)
2829 ifeq ($(BUILD_KERNEL_WITH_CLANG),true)
2930 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-
3132 else
3233 ifeq ($(TARGET_KERNEL_ARCH),x86_64)
3334 ifeq ($(HOST_OS),darwin)
@@ -41,7 +42,13 @@ endif
4142 endif
4243
4344 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)) \
4552 -C $(KERNEL_DIR) O=$(abspath $(KBUILD_OUTPUT)) ARCH=$(TARGET_ARCH) CROSS_COMPILE="$(abspath $(CC_WRAPPER)) $(CROSS_COMPILE)" $(if $(SHOW_COMMANDS),V=1) \
4653 YACC=$(abspath $(BISON)) LEX=$(abspath $(LEX)) \
4754 $(KERNEL_CLANG_CLAGS)
@@ -63,11 +70,16 @@ endif
6370 $(KERNEL_DOTCONFIG_FILE): $(KERNEL_CONFIG_FILE) $(wildcard $(TARGET_KERNEL_DIFFCONFIG)) $(KERNEL_ARCH_CHANGED)
6471 $(hide) mkdir -p $(@D) && cat $(wildcard $^) > $@
6572 $(hide) ln -sf ../../../../../../prebuilts $(@D)
66- $(mk_kernel) olddefconfig
6773 $(hide) rm -f $(KERNEL_ARCH_CHANGED)
6874
6975 BUILT_KERNEL_TARGET := $(KBUILD_OUTPUT)/arch/$(TARGET_ARCH)/boot/$(KERNEL_TARGET)
7076 $(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
7183 $(mk_kernel) $(KERNEL_TARGET) $(if $(MOD_ENABLED),modules)
7284 $(if $(FIRMWARE_ENABLED),$(mk_kernel) INSTALL_MOD_PATH=$(abspath $(TARGET_OUT)) firmware_install)
7385