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.

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

KERNEL_DIR

kernel_build(makefile = ...)

If you set KERNEL_DIR=common in your build config, set makefile = "//common:Makefile" instead.

If you did not set KERNEL_DIR in your build config, then set kernel_dir to the Makefile next to the build config file.

If your use case is different from any of the above, or you would like to understand the mechanics of this attribute, see kernel_build.makefile.

OUT_DIR

Not used in Bazel. Alternatives:

You may customize DIST_DIR. See below.

DIST_DIR

You may specify it statically with

pkg_install(destdir=...)

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

$ bazel run ..._dist -- --destdir=...

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 customizable in Bazel. Alternatives: use --user_clang_toolchain to specify a custom clang toolchain.

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.

DEFCONFIG

If this is an actual file below $KERNEL_DIR/arch/$SRCARCH/configs, use

kernel_build(defconfig = ...)

Otherwise, if it is generated by PRE\_DEFCONFIG\_CMDS, see PRE\_DEFCONFIG\_CMDS.

See documentation for all rules.

PRE_DEFCONFIG_CMDS

kernel_build(
    defconfig = ...
    pre_defconfig_fragments = ...
)

defconfig should be set to the base config (e.g. //common:arch/arm64/configs/gki_defconfig). pre_defconfig_fragments should be set to the list of fragments you are applying, usually FRAGMENT_CONFIG.

See documentation for all rules.

FRAGMENT_CONFIG

This is usually applied at PRE_DEFCONFIG_CMDS. If so, use

kernel_build(pre_defconfig_fragments = ...)

See documentation for all rules.

POST_DEFCONFIG_CMDS

kernel_build(post_defconfig_fragments = ...)

If your POST_DEFCONFIG_CMDS contains check_defconfig, you may also set

kernel_build(check_defconfig_minimized = True)

See documentation for all rules.

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 pkg_files macro.

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 pkg_files 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 pkg_files 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

Building a device-specific boot image is not supported.

NOTE: As an implementation detail, GKI targets invoke gki_artifacts() to build the boot images.

BUILD_VENDOR_BOOT_IMG

vendor_boot_image(...)

See documentation for all rules.

SKIP_VENDOR_BOOT

Simply remove the vendor_boot_image() from your dependency graph.

See Default outputs for details.

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 pkg_files macro.

SKIP_UNPACKING_RAMDISK

vendor_boot_image(unpack_ramdisk=...)

See documentation for all rules.

AVB_SIGN_BOOT_IMG

Building a device-specific boot image is not supported.

NOTE: As an implementation detail, GKI targets invoke gki_artifacts() to build the boot images.

AVB_BOOT_PARTITION_SIZE

Building a device-specific boot image is not supported.

NOTE: As an implementation detail, GKI targets invoke gki_artifacts() to build the boot images.

AVB_BOOT_KEY

Building a device-specific boot image is not supported.

NOTE: As an implementation detail, GKI targets invoke gki_artifacts() to build the boot images.

AVB_BOOT_ALGORITHM

Building a device-specific boot image is not supported.

NOTE: As an implementation detail, GKI targets invoke gki_artifacts() to build the boot images.

AVB_BOOT_PARTITION_NAME

Building a device-specific boot image is not supported.

NOTE: As an implementation detail, GKI targets invoke gki_artifacts() to build the boot images.

BUILD_INITRAMFS

initramfs(...)

See documentation for all rules.

MODULES_OPTIONS

initramfs(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

vendor_dlkm_image(fs_type=[ext4, erofs])

See documentation for all rules.

VENDOR_DLKM_ETC_FILES

vendor_dlkm_image(etc_files=[...])

See documentation for all rules.

VENDOR_DLKM_MODULES_LIST

vendor_dlkm_image(modules_list=...)

See documentation for all rules.

VENDOR_DLKM_MODULES_BLOCKLIST

vendor_dlkm_image(modules_blocklist=...)

See documentation for all rules.

VENDOR_DLKM_PROPS

vendor_dlkm_image(props=...)

See documentation for all rules.

SYSTEM_DLKM_FS_TYPE

system_dlkm_image(fs_types=["ext4", "erofs"])

See documentation for all rules.

SYSTEM_DLKM_MODULES_LIST

system_dlkm_image(modules_list=...)

See documentation for all rules.

SYSTEM_DLKM_MODULES_BLOCKLIST

system_dlkm_image(modules_blocklist=...)

See documentation for all rules.

SYSTEM_DLKM_PROPS

system_dlkm_image(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.
initramfs(ramdisk_compression="lz4",...)

See documentation for all rules.

LZ4_RAMDISK_COMPRESS_ARGS

NOTE: Use in combination with LZ4_RAMDISK.

initramfs(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

See Setting up DDK workspace for details on setting up the repository for prebuilts.

BUILD_DTBO_IMG

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 pkg_files() macro invocation.

See build/kernel/BUILD.bazel.

BUILD_VENDOR_KERNEL_BOOT

vendor_boot_image(vendor_boot_name = "vendor_kernel_boot")

See documentation for all rules.

MKBOOTIMG_PATH

vendor_boot_image(mkbootimg=...)
gki_artifacts(mkbootimg=...)

See documentation for all rules for vendor_boot_image.

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.

KCFLAGS

kernel_build(kcflags=[...])

See kernel_build.kcflags.