summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2023-08-02 03:01:10 +0000
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2023-08-02 03:01:10 +0000
commit1768cc87917ef1327539ce68a3043547a6cac415 (patch)
tree315f5c1ec827604da2a2329e316544c62a518643
parentbd96d6d434ee1aa3281093585c774ed8e76c4166 (diff)
parent58e1c5e48888b2aa71d48a5d4f274334f437f3f7 (diff)
downloadbuild-android-gs-raviole-5.10-u-beta5.tar.gz
Change-Id: Ibed331b49a1ea35170064017c50356cd697661a3
-rwxr-xr-xbuild.sh25
-rw-r--r--kleaf/common_kernels.bzl1
-rw-r--r--kleaf/impl/kernel_env.bzl15
3 files changed, 40 insertions, 1 deletions
diff --git a/build.sh b/build.sh
index f67cbc8..e33f44f 100755
--- a/build.sh
+++ b/build.sh
@@ -530,7 +530,7 @@ if [ -n "${GKI_BUILD_CONFIG}" ]; then
fi
# Inherit SKIP_MRPROPER, LTO, SKIP_DEFCONFIG unless overridden by corresponding GKI_* variables
- GKI_ENVIRON=("SKIP_MRPROPER=${SKIP_MRPROPER}" "LTO=${LTO}" "SKIP_DEFCONFIG=${SKIP_DEFCONFIG}" "SKIP_IF_VERSION_MATCHES=${SKIP_IF_VERSION_MATCHES}")
+ GKI_ENVIRON=("SKIP_MRPROPER=${SKIP_MRPROPER}" "KASAN=${KASAN}" "LTO=${LTO}" "SKIP_DEFCONFIG=${SKIP_DEFCONFIG}" "SKIP_IF_VERSION_MATCHES=${SKIP_IF_VERSION_MATCHES}")
# Explicitly unset EXT_MODULES since they should be compiled against the device kernel
GKI_ENVIRON+=("EXT_MODULES=")
# Explicitly unset GKI_BUILD_CONFIG in case it was set by in the old environment
@@ -657,6 +657,29 @@ if [ "${SKIP_DEFCONFIG}" != "1" ] ; then
fi
fi
+if [ "${KASAN}" = "sw_tags" ]; then
+ echo "====================================================="
+ echo "Enabling KASAN"
+
+ set -x
+ ${KERNEL_DIR}/scripts/config --file ${OUT_DIR}/.config \
+ -e CONFIG_KASAN \
+ -e CONFIG_KASAN_SW_TAGS \
+ -e CONFIG_KASAN_OUTLINE \
+ -e CONFIG_PANIC_ON_WARN_DEFAULT_ENABLE \
+ -d CONFIG_KASAN_HW_TAGS \
+ --set-val CONFIG_FRAME_WARN 0 \
+ -d CFI \
+ -d CFI_PERMISSIVE \
+ -d CFI_CLANG \
+ -d SHADOW_CALL_STACK \
+ -d RANDOMIZE_BASE
+
+ (cd ${OUT_DIR} && make ${TOOL_ARGS} O=${OUT_DIR} "${MAKE_ARGS[@]}" olddefconfig)
+ set +x
+ LTO="none"
+fi
+
if [ "${LTO}" = "none" -o "${LTO}" = "thin" -o "${LTO}" = "full" ]; then
echo "========================================================"
echo " Modifying LTO mode to '${LTO}'"
diff --git a/kleaf/common_kernels.bzl b/kleaf/common_kernels.bzl
index a040f31..bfc1c09 100644
--- a/kleaf/common_kernels.bzl
+++ b/kleaf/common_kernels.bzl
@@ -83,6 +83,7 @@ _KERNEL_BUILD_ABI_VALID_KEYS = [
"abi_definition",
"kmi_enforced",
"module_implicit_outs",
+ "kmi_symbol_list_add_only",
]
# Valid configs of the value of the target_config argument in
diff --git a/kleaf/impl/kernel_env.bzl b/kleaf/impl/kernel_env.bzl
index 6af722a..400510b 100644
--- a/kleaf/impl/kernel_env.bzl
+++ b/kleaf/impl/kernel_env.bzl
@@ -200,6 +200,21 @@ def _kernel_env_impl(ctx):
if [[ "$(realpath ${{ROOT_DIR}}/${{KERNEL_DIR}})" != "${{ROOT_DIR}}/${{KERNEL_DIR}}" ]]; then
export KCPPFLAGS="$KCPPFLAGS -ffile-prefix-map=$(realpath ${{ROOT_DIR}}/${{KERNEL_DIR}})/="
fi
+
+ # HACK: For android13-5.10, the kernel image uses the realpath to stdarg.h
+ # under prebuilts. For sandbox builds, this means the real workspace root appears in the
+ # final artifact, affecting reproducibility and emitting absolute paths to ABI dump XML file.
+ # Determine the real workspace root by using ${{ROOT_DIR}}/${{KERNEL_DIR}}/Makefile as an
+ # anchor. If Makefile does not exist, we are not executing Kbuild, so it is fine that
+ # KCPPFLAGS are not set properly.
+ # See b/287304304 for details.
+ if [[ -L ${{ROOT_DIR}}/${{KERNEL_DIR}}/Makefile ]]; then
+ real_makefile=$(realpath ${{ROOT_DIR}}/${{KERNEL_DIR}}/Makefile)
+ real_kernel_dir=${{real_makefile%/Makefile}}
+ real_root_dir=${{real_kernel_dir%/${{KERNEL_DIR}}}}
+ export KCPPFLAGS="$KCPPFLAGS -ffile-prefix-map=${{real_kernel_dir}}/= -ffile-prefix-map=${{real_root_dir}}/="
+ unset real_makefile real_kernel_dir real_root_dir
+ fi
""".format(
hermetic_tools_additional_setup = ctx.attr._hermetic_tools[HermeticToolsInfo].additional_setup,
env = out_file.path,