Skip to content

Commit

Permalink
AndroidKernel: Disable debugfs for user builds
Browse files Browse the repository at this point in the history
Debugfs is not needed on user builds, so disabling
same at compile time for ARM 64.

Change-Id: If6708c9de060584ebcba4cac9bad8e85d6a5ab7f
Signed-off-by: Swetha Chikkaboraiah <schikk@codeaurora.org>
  • Loading branch information
Swetha Chikkaboraiah authored and Gerrit - the friendly Code Review server committed Aug 21, 2020
1 parent 3a91551 commit 1f17430
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 3 deletions.
20 changes: 17 additions & 3 deletions AndroidKernel.mk
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ ifneq ($(TARGET_KERNEL_APPEND_DTB), true)
$(info Using DTB Image)
INSTALLED_DTBIMAGE_TARGET := $(PRODUCT_OUT)/dtb.img
endif
MAKE_ARGS := $(strip $(TARGET_KERNEL_MAKE_ARGS))
KERNEL_DISABLE_DEBUGFS := $(TARGET_KERNEL_DISABLE_DEBUGFS)

TARGET_KERNEL_MAKE_ENV := $(strip $(TARGET_KERNEL_MAKE_ENV))
ifeq ($(TARGET_KERNEL_MAKE_ENV),)
Expand Down Expand Up @@ -138,6 +140,7 @@ $(info Using appended DTB)
TARGET_PREBUILT_INT_KERNEL := $(TARGET_PREBUILT_INT_KERNEL)-dtb
endif

KERNEL_DEBUGFS := $(KERNEL_OUT)/tmp
KERNEL_HEADERS_INSTALL := $(KERNEL_OUT)/usr
KERNEL_MODULES_INSTALL ?= system
KERNEL_MODULES_OUT ?= $(PRODUCT_OUT)/$(KERNEL_MODULES_INSTALL)/lib/modules
Expand All @@ -162,6 +165,9 @@ mpath=`dirname $$mdpath`; rm -rf $$mpath;\
fi
endef

$(KERNEL_OUT): $(KERNEL_DEBUGFS)
mkdir -p $(KERNEL_OUT)

ifneq ($(KERNEL_LEGACY_DIR),true)
$(KERNEL_USR): $(KERNEL_HEADERS_INSTALL)
rm -rf $(KERNEL_SYMLINK)
Expand All @@ -170,9 +176,6 @@ $(KERNEL_USR): $(KERNEL_HEADERS_INSTALL)
$(TARGET_PREBUILT_INT_KERNEL): $(KERNEL_USR)
endif

$(KERNEL_OUT):
mkdir -p $(KERNEL_OUT)

$(KERNEL_CONFIG): $(KERNEL_OUT)
$(MAKE) -C $(TARGET_KERNEL_SOURCE) O=$(BUILD_ROOT_LOC)$(KERNEL_OUT) $(KERNEL_MAKE_ENV) ARCH=$(KERNEL_ARCH) CROSS_COMPILE=$(KERNEL_CROSS_COMPILE) $(real_cc) $(KERNEL_DEFCONFIG)
$(hide) if [ ! -z "$(KERNEL_CONFIG_OVERRIDE)" ]; then \
Expand Down Expand Up @@ -206,6 +209,17 @@ $(TARGET_PREBUILT_INT_KERNEL): $(KERNEL_OUT) $(KERNEL_HEADERS_INSTALL)
$(clean-module-folder)
endif

$(KERNEL_DEBUGFS):
KERNEL_DIR=$(TARGET_KERNEL_SOURCE) \
DEFCONFIG=$(KERNEL_DEFCONFIG) \
OUT_DIR=$(KERNEL_OUT) \
ARCH=$(KERNEL_ARCH) \
CROSS_COMPILE=$(KERNEL_CROSS_COMPILE) \
DISABLE_DEBUGFS=$(KERNEL_DISABLE_DEBUGFS) \
$(TARGET_KERNEL_SOURCE)/disable_dbgfs.sh \
$(real_cc) \
$(TARGET_KERNEL_MAKE_ARGS)

$(KERNEL_HEADERS_INSTALL): $(KERNEL_OUT)
$(hide) if [ ! -z "$(KERNEL_HEADER_DEFCONFIG)" ]; then \
rm -f $(BUILD_ROOT_LOC)$(KERNEL_CONFIG) && \
Expand Down
29 changes: 29 additions & 0 deletions disable_dbgfs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0

# disable debugfs for user builds
export MAKE_ARGS=$@

if [ ${DISABLE_DEBUGFS} == "true" ]; then
echo "build variant ${TARGET_BUILD_VARIANT}"
if [ ${TARGET_BUILD_VARIANT} == "user" ] && \
[ ${ARCH} == "arm64" ]; then
echo "combining fragments for user build"
(cd $KERNEL_DIR && \
ARCH=${ARCH} CROSS_COMPILE=${CROSS_COMPILE}\
./scripts/kconfig/merge_config.sh \
./arch/${ARCH}/configs/$DEFCONFIG \
./arch/${ARCH}/configs/vendor/debugfs.config
make ${MAKE_ARGS} ARCH=${ARCH} \
CROSS_COMPILE=${CROSS_COMPILE} savedefconfig
mv defconfig ./arch/${ARCH}/configs/$DEFCONFIG
rm .config)
else
if [[ ${DEFCONFIG} == *"perf_defconfig" ]] && \
[ ${ARCH} == "arm64" ]; then
echo "resetting perf defconfig"
(cd ${KERNEL_DIR} && \
git checkout arch/$ARCH/configs/$DEFCONFIG)
fi
fi
fi

0 comments on commit 1f17430

Please sign in to comment.