Build configs

This document provides reference to the Bazel equivalent or alternative for the legacy build configs.

For build configs with a Bazel equivalent / alternative, a code snippet and a link to the documentation for all rules is provided. You may look up the relevant macros, rules and attributes in the documentation.

For build configs that should be kept in build.config files, the text “Specify in the build config” is displayed.

For build configs that are set to a fixed value in Bazel, the text “Not customizable in Bazel” is displayed. Contact owners if you need to customize this.

For build configs that are not used in Bazel with alternatives provided, the text “Not used in Bazel.” is displayed.

For build configs that are not supported, the text “Not supported” is displayed. Contact owners if you need support.

Table of contents

BUILD_CONFIG

kernel_build(build_config=...)

See documentation for all rules.

BUILD_CONFIG_FRAGMENTS

kernel_build_config()

See documentation for all rules.

FAST_BUILD

Not used in Bazel. Alternatives:

You may disable LTO or use thin LTO; see LTO.

You may use --config=fast to build faster. See fast.md for details.

You may build just the kernel binary and GKI modules, without headers and installing modules by building the kernel_build target, e.g.

$ bazel build //common:kernel_aarch64

OUT_DIR

Not used in Bazel. Alternatives:

You may customize DIST_DIR. See below.

DIST_DIR

You may specify it statically with

copy_to_dist_dir(dist_dir=...)

You may override it in the command line with --dist_dir:

$ bazel run ..._dist -- --dist_dir=...

See documentation for all rules.

MAKE_GOALS

kernel_build(
  make_goals = ...
)

See documentation for all rules.

EXT_MODULES

ddk_module()

NOTE: Prefer ddk_module over the legacy kernel_module.

See documentation for all rules.

EXT_MODULES_MAKEFILE

Not used in Bazel.

Reason: EXT_MODULES_MAKEFILE supports building external kernel modules in parallel. This is naturally supported in Bazel.

KCONFIG_EXT_PREFIX

kernel_build(kconfig_ext=...)

See documentation for all rules.

UNSTRIPPED_MODULES

kernel_build(collect_unstripped_modules=...)
kernel_filegroup(collect_unstripped_modules=...)

See documentation for all rules.

COMPRESS_UNSTRIPPED_MODULES

kernel_unstripped_modules_archive()

See documentation for all rules.

COMPRESS_MODULES

Not supported. Contact owners if you need support for this config.

LD

Not used in Bazel. Alternatives:

You may customize the clang toolchain version via

kernel_build(toolchain_version=...)

See documentation for all rules.

HERMETIC_TOOLCHAIN

Not customizable in Bazel.

Reason: This is the default for Bazel builds. Its value cannot be changed.

See Ensuring hermeticity for details about ensuring hermeticity.

See documentation for all rules.

ADDITIONAL_HOST_TOOLS

Not customizable in Bazel.

Reason: The list of host tools are fixed and specified in hermetic_tools().

See documentation for all rules.

ABI_DEFINITION

Not used in Bazel. Alternatives:

The XML format of ABI definition is no longer supported. The STG format of ABI definition may be set with the following:

kernel_abi(abi_definition_stg=...)

See documentation for all rules.

See documentation for ABI monitoring.

KMI_SYMBOL_LIST

kernel_build(kmi_symbol_list=...)

See documentation for all rules.

See documentation for ABI monitoring.

ADDITIONAL_KMI_SYMBOL_LISTS

kernel_build(additional_kmi_symbol_lists=...)

See documentation for all rules.

See documentation for ABI monitoring.

KMI_ENFORCED

kernel_abi(kmi_enforced=...)

See documentation for all rules.

See documentation for ABI monitoring.

GENERATE_VMLINUX_BTF

kernel_build(generate_vmlinux_btf=...)

See documentation for all rules.

SKIP_MRPROPER

Not used in Bazel. Alternatives:

  • For sandbox builds, the $OUT_DIR always starts with no contents (as if SKIP_MRPROPER=).
  • For non-sandbox builds, the $OUT_DIR is always cached (as if SKIP_MRPROPER=1). You may clean its contents with bazel clean.

See sandbox.md.

SKIP_DEFCONFIG

Not used in Bazel.

Reason: Bazel automatically rebuild make defconfig when its relevant sources change, as if SKIP_DEFCONFIG is determined automatically.

SKIP_IF_VERSION_MATCHES

Not used in Bazel.

Reason: Incremental builds are supported by default.

PRE_DEFCONFIG_CMDS

Specify in the build config.

Or, remove from the build config, and use kernel_build_config and genrule. This is recommended.

To support --config=local builds, PRE_DEFCONFIG_CMDS must not write to the source tree, including $ROOT_DIR/$KERNEL_DIR. See errors.md#defconfig-readonly for details.

See documentation for all rules.

See documentation for genrule.

POST_DEFCONFIG_CMDS

Specify in the build config.

Or, remove from the build config, and use kernel_build_config and genrule. This is recommended.

See documentation for all rules.

See documentation for genrule.

POST_KERNEL_BUILD_CMDS

Not supported.

Reason: commands are disallowed in general because of unclear dependency.

You may define a genrule target with appropriate inputs (possibly from a kernel_build macro), then add the target to your copy_to_dist_dir macro.

See documentation for genrule.

LTO

$ bazel build --lto={default,none,thin,full} TARGETS
$ bazel run   --lto={default,none,thin,full} TARGETS

See disable LTO during development.

TAGS_CONFIG

Not supported. Contact owners if you need support for this config.

IN_KERNEL_MODULES

Not customizable in Bazel.

Reason: This is set by default in build.config.common. Its value cannot be changed.

SKIP_EXT_MODULES

Not used in Bazel. Alternatives:

You may skip building external modules by leaving them out in the bazel build command.

DO_NOT_STRIP_MODULES

kernel_build(strip_modules=...)

See documentation for all rules.

EXTRA_CMDS

Not used in Bazel.

Reason: commands are disallowed in general because of unclear dependency.

Alternatives: You may define a genrule or exec target with appropriate inputs, then add the target to your copy_to_dist_dir macro.

See documentation for genrule.

DIST_CMDS

Not used in Bazel.

Reason: commands are disallowed in general because of unclear dependency.

Alternatives: You may define a genrule or exec target with appropriate inputs, then add the target to your copy_to_dist_dir macro.

See documentation for genrule.

SKIP_CP_KERNEL_HDR

Not used in Bazel. Alternatives:

You may skip building headers by leaving them out in the bazel build command.

BUILD_BOOT_IMG

kernel_images(build_boot=...)

See documentation for all rules.

BUILD_VENDOR_BOOT_IMG

kernel_images(build_vendor_boot=...)

The flags are rather straightforward. build_boot controls the boot image. build_vendor_boot controls the vendor_boot image. Setting build_vendor_boot = True requires build_boot = True.

See documentation for all rules.

SKIP_VENDOR_BOOT

kernel_images(build_vendor_boot=...)

See BUILD_VENDOR_BOOT_IMG.

See documentation for all rules.

VENDOR_RAMDISK_CMDS

Not used in Bazel.

Reason: Commands are disallowed in general because of unclear dependency.

Alternatives: you may define a genrule or exec target with appropriate inputs, then add the target to your copy_to_dist_dir macro.

SKIP_UNPACKING_RAMDISK

kernel_images(unpack_ramdisk=...)

See documentation for all rules.

AVB_SIGN_BOOT_IMG

kernel_images(avb_sign_boot_img=...)

See documentation for all rules.

AVB_BOOT_PARTITION_SIZE

kernel_images(avb_boot_partition_size=...)

Note: It only has effect when AVB_SIGN_BOOT_IMG is set.

See documentation for all rules.

AVB_BOOT_KEY

kernel_images(avb_boot_key=...)

Note: It only has effect when AVB_SIGN_BOOT_IMG is set.

See documentation for all rules.

AVB_BOOT_ALGORITHM

kernel_images(avb_boot_algorithm=...)

Note: It only has effect when AVB_SIGN_BOOT_IMG is set.

See documentation for all rules.

AVB_BOOT_PARTITION_NAME

kernel_images(avb_boot_partition_name=...)

Note: It only has effect when AVB_SIGN_BOOT_IMG is set.

See documentation for all rules.

BUILD_INITRAMFS

kernel_images(build_initramfs=...)

See documentation for all rules.

MODULES_OPTIONS

kernel_images(modules_options=...)

See documentation for all rules.

MODULES_ORDER

Not customizable in Bazel.

Reason: The Bazel build already sets the order of loading modules for you, and build_utils.sh uses it generate the modules.load files already.

GKI_MODULES_LIST

Note: This config has been deprecated. List is being generated by checking the presence of the signature instead.

Not customizable in Bazel.

Reason: This is set to a fixed value in the module_implicit_outs attribute of //common:kernel_aarch64.

See documentation for all rules.

VENDOR_DLKM_FS_TYPE

kernel_images(vendor_dlkm_fs_type=[ext4, erofs])

See documentation for all rules.

VENDOR_DLKM_ETC_FILES

kernel_images(vendor_dlkm_etc_files=[...])

See documentation for all rules.

VENDOR_DLKM_MODULES_LIST

kernel_images(vendor_dlkm_modules_list=...)

See documentation for all rules.

VENDOR_DLKM_MODULES_BLOCKLIST

kernel_images(vendor_dlkm_modules_blocklist=...)

See documentation for all rules.

VENDOR_DLKM_PROPS

kernel_images(vendor_dlkm_props=...)

See documentation for all rules.

SYSTEM_DLKM_FS_TYPE

kernel_images(system_dlkm_fs_types=["ext4", "erofs"])

See documentation for all rules.

SYSTEM_DLKM_MODULES_LIST

kernel_images(system_dlkm_modules_list=...)

See documentation for all rules.

SYSTEM_DLKM_MODULES_BLOCKLIST

kernel_images(system_dlkm_modules_blocklist=...)

See documentation for all rules.

SYSTEM_DLKM_PROPS

kernel_images(system_dlkm_props=...)

See documentation for all rules.

LZ4_RAMDISK

NOTE: Rather than specifying if lz4 is used or not, kleaf expects you to specify the value as one of the strings lz4 or gzip.

  • If ramdisk_compression = lz4 or gzip, do not specify LZ4_RAMDISK in build configs, as the value will be ignored.
  • If ramdisk_compression = None or unspecified, the value in build configs will be respected.
kernel_image(ramdisk_compression="lz4",...)

See documentation for all rules.

LZ4_RAMDISK_COMPRESS_ARGS

NOTE: Use in combination with LZ4_RAMDISK.

kernel_image(ramdisk_compression_args=...)

See documentation for all rules.

TRIM_NONLISTED_KMI

kernel_build(trim_nonlisted_kmi=...)

See documentation for all rules.

See documentation for ABI monitoring.

KMI_SYMBOL_LIST_STRICT_MODE

kernel_build(kmi_symbol_list_strict_mode=...)

See documentation for all rules.

See documentation for ABI monitoring.

KMI_STRICT_MODE_OBJECTS

Not customizable in Bazel.

Reason: This is always vmlinux (regardless of whether it is in outs) and the list of module_outs from the kernel_build attribute of the kernel_abi macro invocation.

See documentation for all rules.

See documentation for ABI monitoring.

GKI_DIST_DIR

Not used in Bazel. Alternatives:

Mixed builds are supported by

kernel_build(base_build=...)

See documentation for implementing Kleaf.

GKI_BUILD_CONFIG

Not used in Bazel. Alternatives:

Mixed builds are supported by

kernel_build(base_build=...)

See documentation for implementing Kleaf.

GKI_PREBUILTS_DIR

kernel_filegroup()

Mixed builds are supported by

kernel_build(base_build=...)

You may specify the kernel_filegroup target in the base_build attribute of the kernel_build macro invocation.

See documentation for all rules.

See documentation for implementing Kleaf.

BUILD_DTBO_IMG

kernel_images(build_dtbo=...)

See documentation for all rules.

DTS_EXT_DIR

kernel_dtstree()
kernel_build(dtstree=...)

Define kernel_dtstree() in DTS_EXT_DIR, then set the dtstree argument of the kernel_build() macro invocation to the kernel_dtstree() target.

See documentation for all rules.

BUILD_GKI_CERTIFICATION_TOOLS

Add //build/kernel:gki_certification_tools to your copy_to_dist_dir() macro invocation.

See build/kernel/BUILD.bazel.

BUILD_VENDOR_KERNEL_BOOT

kernel_images(build_vendor_kernel_boot=...)

See documentation for all rules.

MKBOOTIMG_PATH

kernel_images(mkbootimg=...)
gki_artifacts(mkbootimg=...)

See documentation for all rules for kernel_images.

NOTE: gki_artifacts is an implementation detail, and it should only be invoked by GKI targets.

BUILD_GKI_ARTIFACTS

gki_artifacts()

NOTE: gki_artifacts is an implementation detail, and it should only be invoked by GKI targets.

For GKI targets, it may be configured via the following:

define_common_kernels(
  target_configs = {
    "kernel_aarch64": {
      "build_gki_artifacts": True,
      "gki_boot_img_sizes": {
        "": "67108864",
        "lz4": "53477376",
      },
    },
  },
)

See documentation for all rules.

GKI_KERNEL_CMDLINE

gki_artifacts(gki_kernel_cmdline=...)

NOTE: gki_artifacts is an implementation detail, and it should only be invoked by GKI targets.

KBUILD_SYMTYPES

If KBUILD_SYMTYPES=1 is specified in build configs:

kernel_build(kbuild_symtypes="true")

See documentation for all rules.

To specify KBUILD_SYMTYPES=1 at build time:

$ bazel build --kbuild_symtypes ...

See symtypes.md for details.

KMI_SYMBOL_LIST_ADD_ONLY

kernel_abi(kmi_symbol_list_add_only=...)

See documentation for all rules.

See documentation for ABI monitoring.