build.sh
Build configsThis document provides reference to the Bazel equivalent or alternative for build configs that build.sh
and build_abi.sh
supports.
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.
kernel_build()
are also applicable to kernel_build_abi()
.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
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
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_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. Note that this is NOT equivalent to FAST_BUILD=1 build/build.sh
. 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
Not used in Bazel. Alternatives:
You may customize DIST_DIR
. See below.
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.
Specify in the build config.
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 used in Bazel. Alternatives:
You may customize the clang toolchain version via
kernel_build(toolchain_version=...)
See documentation for all rules.
Not customizable in Bazel.
Reason: This is the default for Bazel builds. Its value cannot be changed.
Hermetic toolchain is guaranteed by the hermetic_tools()
rule.
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.
kernel_build_abi(abi_definition=...)
See documentation for all rules.
See documentation for ABI monitoring.
kernel_build(kmi_symbol_list=...) kernel_build_abi(kmi_symbol_list=...)
See documentation for all rules.
See documentation for ABI monitoring.
kernel_build(additional_kmi_symbol_lists=...) kernel_build_abi(additional_kmi_symbol_lists=...)
See documentation for all rules.
See documentation for ABI monitoring.
kernel_build_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.
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
.
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
.
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
.
$ 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 copy_to_dist_dir
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 copy_to_dist_dir
macro.
See documentation for genrule
.
Not used in Bazel. Alternatives:
You may skip building headers by leaving them out in the bazel build
command.
kernel_images(build_boot=...)
See documentation for all rules.
kernel_images(build_vendor_boot=...)
Note: In build.sh
, BUILD_BOOT_IMG
and BUILD_VENDOR_BOOT_IMG
are confusingly the same flag. vendor_boot
is only built if either BUILD_BOOT_IMG
or BUILD_VENDOR_BOOT_IMG
is set, and SKIP_VENDOR_BOOT
is not set.
In Bazel, 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.
kernel_images(build_vendor_boot=...)
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 copy_to_dist_dir
macro.
Specify in the build config.
kernel_images(avb_sign_boot_img=...)
See documentation for all rules.
kernel_images(avb_boot_partition_size=...)
Note: It only has effect when AVB_SIGN_BOOT_IMG
is set.
See documentation for all rules.
kernel_images(avb_boot_key=...)
Note: It only has effect when AVB_SIGN_BOOT_IMG
is set.
See documentation for all rules.
kernel_images(avb_boot_algorithm=...)
Note: It only has effect when AVB_SIGN_BOOT_IMG
is set.
See documentation for all rules.
kernel_images(avb_boot_partition_name=...)
Note: It only has effect when AVB_SIGN_BOOT_IMG
is set.
See documentation for all rules.
kernel_images(build_initramfs=...)
See documentation for all rules.
kernel_images(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.
kernel_images(vendor_dlkm_fs_type=[ext4, erofs])
See documentation for all rules.
kernel_images(vendor_dlkm_modules_list=...)
See documentation for all rules.
kernel_images(vendor_dlkm_modules_blocklist=...)
See documentation for all rules.
kernel_images(vendor_dlkm_props=...)
See documentation for all rules.
kernel_images(system_dlkm_fs_type=[ext4, erofs])
See documentation for all rules.
kernel_images(system_dlkm_modules_list=...)
See documentation for all rules.
kernel_images(system_dlkm_modules_blocklist=...)
See documentation for all rules.
kernel_images(system_dlkm_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.kernel_image(ramdisk_compression="lz4",...)
See documentation for all rules.
NOTE: Use in combination with LZ4_RAMDISK
.
kernel_image(ramdisk_compression_args=...)
See documentation for all rules.
kernel_build(trim_nonlisted_kmi=...) kernel_build_abi(trim_nonlisted_kmi=...)
See documentation for all rules.
See documentation for ABI monitoring.
kernel_build(kmi_symbol_list_strict_mode=...) kernel_build_abi(kmi_symbol_list_strict_mode=...)
See documentation for all rules.
See documentation for ABI monitoring.
Not customizable in Bazel.
Reason: for a kernel_build_abi
macro invocation, this is always vmlinux
(regardless of whether it is in outs
), plus the list of module_outs
.
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.
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.
kernel_images(build_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 copy_to_dist_dir()
macro invocation.
kernel_images(build_vendor_kernel_boot=...)
See documentation for all rules.
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.
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_build_abi(kmi_symbol_list_add_only=...)