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
BUILD_CONFIG_FRAGMENTS
FAST_BUILD
KERNEL_DIR
OUT_DIR
DIST_DIR
MAKE_GOALS
EXT_MODULES
EXT_MODULES_MAKEFILE
KCONFIG_EXT_PREFIX
UNSTRIPPED_MODULES
COMPRESS_UNSTRIPPED_MODULES
COMPRESS_MODULES
LD
HERMETIC_TOOLCHAIN
ADDITIONAL_HOST_TOOLS
ABI_DEFINITION
KMI_SYMBOL_LIST
ADDITIONAL_KMI_SYMBOL_LISTS
KMI_ENFORCED
GENERATE_VMLINUX_BTF
SKIP_MRPROPER
SKIP_DEFCONFIG
SKIP_IF_VERSION_MATCHES
DEFCONFIG
PRE_DEFCONFIG_CMDS
POST_DEFCONFIG_CMDS
POST_KERNEL_BUILD_CMDS
LTO
TAGS_CONFIG
IN_KERNEL_MODULES
SKIP_EXT_MODULES
DO_NOT_STRIP_MODULES
EXTRA_CMDS
DIST_CMDS
SKIP_CP_KERNEL_HDR
BUILD_BOOT_IMG
BUILD_VENDOR_BOOT_IMG
SKIP_VENDOR_BOOT
VENDOR_RAMDISK_CMDS
SKIP_UNPACKING_RAMDISK
AVB_SIGN_BOOT_IMG
AVB_BOOT_PARTITION_SIZE
AVB_BOOT_KEY
AVB_BOOT_ALGORITHM
AVB_BOOT_PARTITION_NAME
BUILD_INITRAMFS
MODULES_OPTIONS
MODULES_ORDER
GKI_MODULES_LIST
VENDOR_DLKM_ETC_FILES
VENDOR_DLKM_FS_TYPE
VENDOR_DLKM_MODULES_LIST
VENDOR_DLKM_MODULES_BLOCKLIST
VENDOR_DLKM_PROPS
SYSTEM_DLKM_FS_TYPE
SYSTEM_DLKM_MODULES_LIST
SYSTEM_DLKM_MODULES_BLOCKLIST
SYSTEM_DLKM_PROPS
LZ4_RAMDISK
LZ4_RAMDISK_COMPRESS_ARGS
TRIM_NONLISTED_KMI
KMI_SYMBOL_LIST_STRICT_MODE
KMI_STRICT_MODE_OBJECTS
GKI_DIST_DIR
GKI_BUILD_CONFIG
GKI_PREBUILTS_DIR
BUILD_DTBO_IMG
DTS_EXT_DIR
BUILD_GKI_CERTIFICATION_TOOLS
BUILD_VENDOR_KERNEL_BOOT
MKBOOTIMG_PATH
BUILD_GKI_ARTIFACTS
GKI_KERNEL_CMDLINE
KMI_SYMBOL_LIST_ADD_ONLY
kernel_build(build_config=...)
See documentation for all rules.
kernel_build_config()
See documentation for all rules.
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_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.
Not used in Bazel. Alternatives:
You may customize DIST_DIR
. See below.
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.
kernel_build( make_goals = ... )
See documentation for all rules.
ddk_module()
NOTE: Prefer ddk_module
over the legacy kernel_module
.
See documentation for all rules.
Not used in Bazel.
Reason: EXT_MODULES_MAKEFILE
supports building external kernel modules in parallel. This is naturally supported in Bazel.
kernel_build(kconfig_ext=...)
See documentation for all rules.
kernel_build(collect_unstripped_modules=...) kernel_filegroup(collect_unstripped_modules=...)
See documentation for all rules.
kernel_unstripped_modules_archive()
See documentation for all rules.
Not supported. Contact owners if you need support for this config.
Not customizable in Bazel. Alternatives: use --user_clang_toolchain
to specify a custom clang 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.
Not customizable in Bazel.
Reason: The list of host tools are fixed and specified in hermetic_tools()
.
See documentation for all rules.
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.
kernel_build(kmi_symbol_list=...)
See documentation for all rules.
See documentation for ABI monitoring.
kernel_build(additional_kmi_symbol_lists=...)
See documentation for all rules.
See documentation for ABI monitoring.
kernel_abi(kmi_enforced=...)
See documentation for all rules.
See documentation for ABI monitoring.
kernel_build(generate_vmlinux_btf=...)
See documentation for all rules.
Not used in Bazel. Alternatives:
$OUT_DIR
always starts with no contents (as if SKIP_MRPROPER=
).$OUT_DIR
is always cached (as if SKIP_MRPROPER=1
). You may clean its contents with bazel clean
.See sandbox.md.
Not used in Bazel.
Reason: Bazel automatically rebuild make defconfig
when its relevant sources change, as if SKIP_DEFCONFIG
is determined automatically.
Not used in Bazel.
Reason: Incremental builds are supported by default.
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.
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.
This is usually applied at PRE_DEFCONFIG_CMDS. If so, use
kernel_build(pre_defconfig_fragments = ...)
See documentation for all rules.
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.
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.
$ bazel build --lto={default,none,thin,full} TARGETS $ bazel run --lto={default,none,thin,full} TARGETS
See disable LTO during development.
Not supported. Contact owners if you need support for this config.
Not customizable in Bazel.
Reason: This is set by default in build.config.common
. Its value cannot be changed.
Not used in Bazel. Alternatives:
You may skip building external modules by leaving them out in the bazel build
command.
kernel_build(strip_modules=...)
See documentation for all rules.
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
].
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
].
Not used in Bazel. Alternatives:
You may skip building headers by leaving them out in the bazel build
command.
Building a device-specific boot image is not supported.
NOTE: As an implementation detail, GKI targets invoke gki_artifacts()
to build the boot images.
vendor_boot_image(...)
See documentation for all rules.
Simply remove the vendor_boot_image()
from your dependency graph.
See Default outputs for details.
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.
vendor_boot_image(unpack_ramdisk=...)
See documentation for all rules.
Building a device-specific boot image is not supported.
NOTE: As an implementation detail, GKI targets invoke gki_artifacts()
to build the boot images.
Building a device-specific boot image is not supported.
NOTE: As an implementation detail, GKI targets invoke gki_artifacts()
to build the boot images.
Building a device-specific boot image is not supported.
NOTE: As an implementation detail, GKI targets invoke gki_artifacts()
to build the boot images.
Building a device-specific boot image is not supported.
NOTE: As an implementation detail, GKI targets invoke gki_artifacts()
to build the boot images.
Building a device-specific boot image is not supported.
NOTE: As an implementation detail, GKI targets invoke gki_artifacts()
to build the boot images.
initramfs(...)
See documentation for all rules.
initramfs(modules_options=...)
See documentation for all rules.
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.
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_image(fs_type=[ext4, erofs])
See documentation for all rules.
vendor_dlkm_image(etc_files=[...])
See documentation for all rules.
vendor_dlkm_image(modules_list=...)
See documentation for all rules.
vendor_dlkm_image(modules_blocklist=...)
See documentation for all rules.
vendor_dlkm_image(props=...)
See documentation for all rules.
system_dlkm_image(fs_types=["ext4", "erofs"])
See documentation for all rules.
system_dlkm_image(modules_list=...)
See documentation for all rules.
system_dlkm_image(modules_blocklist=...)
See documentation for all rules.
system_dlkm_image(props=...)
See documentation for all rules.
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
.
ramdisk_compression =
lz4
or gzip
, do not specify LZ4_RAMDISK
in build configs, as the value will be ignored.ramdisk_compression =
None
or unspecified, the value in build configs will be respected.initramfs(ramdisk_compression="lz4",...)
See documentation for all rules.
NOTE: Use in combination with LZ4_RAMDISK
.
initramfs(ramdisk_compression_args=...)
See documentation for all rules.
kernel_build(trim_nonlisted_kmi=...)
See documentation for all rules.
See documentation for ABI monitoring.
kernel_build(kmi_symbol_list_strict_mode=...)
See documentation for all rules.
See documentation for ABI monitoring.
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.
Not used in Bazel. Alternatives:
Mixed builds are supported by
kernel_build(base_build=...)
See documentation for implementing Kleaf.
Not used in Bazel. Alternatives:
Mixed builds are supported by
kernel_build(base_build=...)
See documentation for implementing Kleaf.
See Setting up DDK workspace for details on setting up the repository for prebuilts.
dtbo(...)
See documentation for all rules.
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.
Add //build/kernel:gki_certification_tools
to your pkg_files()
macro invocation.
vendor_boot_image(vendor_boot_name = "vendor_kernel_boot")
See documentation for all rules.
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.
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_artifacts(gki_kernel_cmdline=...)
NOTE: gki_artifacts
is an implementation detail, and it should only be invoked by GKI targets.
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.
kernel_abi(kmi_symbol_list_add_only=...)
See documentation for all rules.
See documentation for ABI monitoring.
kernel_build(kcflags=[...])
See kernel_build.kcflags.