summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYifan Hong <elsk@google.com>2022-08-31 22:07:16 -0700
committerYifan Hong <elsk@google.com>2022-09-06 17:16:39 +0000
commitf67eea6aa43b30326960b39fe5f4c99c1519b86a (patch)
treef1b1efbbbb6095367a5988313d1ba196dfbb62d2
parent768b63ea9338b19b36cac04cda22ede69488d74a (diff)
downloadbuild-f67eea6aa43b30326960b39fe5f4c99c1519b86a.tar.gz
kleaf: Do not include GKI modules in default output of //common:kernel_aarch64.
This change adds the `module_implicit_outs` mechanism to kernel_build that acts like `module_outs` but not added to default info (like implicit_outs). This allows us to exclude GKI modules from //common:kernel_aarch64 DefaultInfo. When a device kernel builds their own modules that conflicts with the GKI modules (zram and zsmalloc for android13-5.15), the dist target will produce a warning about conflicting source files. Hence, do not include zram and zsmalloc to the device dist targets by default when they include "//common:kernel_aarch64" only. If they wish to include zram and zsmalloc in the distribution on the android13-5.15 branch, they may add the following to the dist target: "//common:kernel_aarch64_modules", or individual modules: "//common:kernel_aarch64/drivers/block/zram/zram.ko", "//common:kernel_aarch64/mm/zsmalloc.ko", //common:kernel_aarch64_dist continues to include GKI modules defined by the branch. Bug: 244215515 Test: manual Change-Id: Id1c9fd9e603e9b2946cd59c7fde14d11ef7dd8b2
-rw-r--r--kleaf/common_kernels.bzl21
-rw-r--r--kleaf/docs/build_configs.md2
-rw-r--r--kleaf/docs/impl.md9
-rw-r--r--kleaf/impl/common_providers.bzl4
-rw-r--r--kleaf/impl/kernel_build.bzl20
5 files changed, 43 insertions, 13 deletions
diff --git a/kleaf/common_kernels.bzl b/kleaf/common_kernels.bzl
index 8aeb866..719716d 100644
--- a/kleaf/common_kernels.bzl
+++ b/kleaf/common_kernels.bzl
@@ -83,7 +83,7 @@ _KERNEL_BUILD_ABI_VALID_KEYS = [
"kmi_symbol_list_strict_mode",
"abi_definition",
"kmi_enforced",
- "module_outs",
+ "module_implicit_outs",
]
# Valid configs of the value of the target_config argument in
@@ -191,6 +191,7 @@ def define_common_kernels(
- `kernel_aarch64`
- `kernel_aarch64_uapi_headers`
- `kernel_aarch64_additional_artifacts`
+ - `kernel_aarch64_modules`
- `kernel_aarch64_debug_dist`
- `kernel_aarch64_debug`
- `kernel_x86_64_sources`
@@ -290,7 +291,7 @@ def define_common_kernels(
- `ADDITIONAL_KMI_SYMBOL_LISTS`
- `TRIM_NONLISTED_KMI`
- `KMI_SYMBOL_LIST_STRICT_MODE`
- - `GKI_MODULES_LIST` (corresponds to [`kernel_build.module_outs`](#kernel_build-module_outs))
+ - `GKI_MODULES_LIST` (corresponds to [`kernel_build.module_implicit_outs`](#kernel_build-module_implicit_outs))
- `BUILD_GKI_ARTIFACTS`
- `BUILD_GKI_BOOT_IMG_SIZE` and `BUILD_GKI_BOOT_IMG_{COMPRESSION}_SIZE`
@@ -307,7 +308,7 @@ def define_common_kernels(
- `additional_kmi_symbol_lists`
- `trim_nonlisted_kmi`
- `kmi_symbol_list_strict_mode`
- - `module_outs` (corresponds to `GKI_MODULES_LIST`)
+ - `module_implicit_outs` (corresponds to `GKI_MODULES_LIST`)
In addition, the values of `target_configs` may contain the following keys:
- `build_gki_artifacts`
@@ -518,7 +519,7 @@ def define_common_kernels(
kernel_modules_install(
name = name + "_modules_install",
# The GKI target does not have external modules. GKI modules goes
- # into the in-tree kernel module list, aka kernel_build.module_outs.
+ # into the in-tree kernel module list, aka kernel_build.module_implicit_outs.
# Hence, this is empty, and name + "_dist" does NOT include
# name + "_modules_install".
kernel_modules = [],
@@ -560,7 +561,16 @@ def define_common_kernels(
output_group = "modules_staging_archive",
)
- # Everything in name + "_dist", minus UAPI headers & DDK, because
+ # All GKI modules
+ native.filegroup(
+ name = name + "_modules",
+ srcs = [
+ "{}/{}".format(name, module)
+ for module in (kernel_build_abi_kwargs["module_implicit_outs"] or [])
+ ],
+ )
+
+ # Everything in name + "_dist", minus UAPI headers & DDK & modules, because
# device-specific external kernel modules may install different headers.
native.filegroup(
name = name + "_additional_artifacts",
@@ -591,6 +601,7 @@ def define_common_kernels(
name + "_unstripped_modules_archive",
name + "_additional_artifacts",
name + "_ddk_artifacts",
+ name + "_modules",
# BUILD_GKI_CERTIFICATION_TOOLS=1 for all kernel_build defined here.
"//build/kernel:gki_certification_tools",
]
diff --git a/kleaf/docs/build_configs.md b/kleaf/docs/build_configs.md
index f41c8c9..4ec40a1 100644
--- a/kleaf/docs/build_configs.md
+++ b/kleaf/docs/build_configs.md
@@ -494,7 +494,7 @@ Reason: The Bazel build already sets the order of loading modules for you, and
Not customizable in Bazel.
-Reason: This is set to a fixed value in the `module_outs` attribute of
+Reason: This is set to a fixed value in the `module_implicit_outs` attribute of
`//common:kernel_aarch64`.
See [documentation for all rules].
diff --git a/kleaf/docs/impl.md b/kleaf/docs/impl.md
index ef339ba..84aad56 100644
--- a/kleaf/docs/impl.md
+++ b/kleaf/docs/impl.md
@@ -220,6 +220,15 @@ that the outputs are analogous to those produced by `build/build.sh`:
* `//common:kernel_aarch64`
* `//common:kernel_aarch64_additional_artifacts`
* UAPI headers, e.g. `//common:kernel_aarch64_uapi_headers`
+* GKI modules
+ * If you are using all GKI modules, add `//common:kernel_aarch64_modules`.
+ * If you are using part of the GKI modules, add them individually, e.g.:
+ * `//common:kernel_aarch64/drivers/block/zram/zram.ko`
+ * `//common:kernel_aarch64/mm/zsmalloc.ko`
+ * Modules from the device kernel build with the same name as GKI modules
+ (e.g. on android13-5.15, you have `zram.ko` in `kernel_build.module_outs`)
+ does not need to be specified, because `module_outs` are added to
+ distribution.
Example for Pixel 2021 (see the `copy_to_dist_dir` target named `slider_dist`):
diff --git a/kleaf/impl/common_providers.bzl b/kleaf/impl/common_providers.bzl
index 45371f0..5dc7822 100644
--- a/kleaf/impl/common_providers.bzl
+++ b/kleaf/impl/common_providers.bzl
@@ -70,7 +70,7 @@ KernelBuildAbiInfo = provider(
fields = {
"trim_nonlisted_kmi": "Value of `trim_nonlisted_kmi` in [`kernel_build()`](#kernel_build).",
"combined_abi_symbollist": "The **combined** `abi_symbollist` file from the `_kmi_symbol_list` rule, consist of the source `kmi_symbol_list` and `additional_kmi_symbol_lists`.",
- "module_outs_file": "A file containing `[kernel_build.module_outs]`(#kernel_build-module_outs).",
+ "module_outs_file": "A file containing `[kernel_build.module_outs]`(#kernel_build-module_outs) and `[kernel_build.module_implicit_outs]`(#kernel_build-module_implicit_outs).",
},
)
@@ -78,7 +78,7 @@ KernelBuildInTreeModulesInfo = provider(
doc = """A provider that specifies the expectations of a [`kernel_build`](#kernel_build) on its
[`base_kernel`](#kernel_build-base_kernel) or [`base_kernel_for_module_outs`](#kernel_build-base_kernel_for_module_outs).""",
fields = {
- "module_outs_file": "A file containing `[kernel_build.module_outs]`(#kernel_build-module_outs).",
+ "module_outs_file": "A file containing `[kernel_build.module_outs]`(#kernel_build-module_outs) and `[kernel_build.module_implicit_outs]`(#kernel_build-module_implicit_outs).",
},
)
diff --git a/kleaf/impl/kernel_build.bzl b/kleaf/impl/kernel_build.bzl
index eb7e476..2c99b77 100644
--- a/kleaf/impl/kernel_build.bzl
+++ b/kleaf/impl/kernel_build.bzl
@@ -63,6 +63,7 @@ def kernel_build(
srcs = None,
module_outs = None,
implicit_outs = None,
+ module_implicit_outs = None,
generate_vmlinux_btf = None,
deps = None,
base_kernel = None,
@@ -245,6 +246,11 @@ def kernel_build(
implicit_outs: Like `outs`, but not copied to the distribution directory.
Labels are created for each item in `implicit_outs` as in `outs`.
+
+ module_implicit_outs: like `module_outs`, but not copied to the distribution directory.
+
+ Labels are created for each item in `module_implicit_outs` as in `outs`.
+
kmi_symbol_list: A label referring to the main KMI symbol list file. See `additional_kmi_symbol_list`.
This is the Bazel equivalent of `ADDTIONAL_KMI_SYMBOL_LISTS`.
@@ -405,6 +411,7 @@ def kernel_build(
outs = kernel_utils.transform_kernel_build_outs(name, "outs", outs),
module_outs = kernel_utils.transform_kernel_build_outs(name, "module_outs", module_outs),
implicit_outs = kernel_utils.transform_kernel_build_outs(name, "implicit_outs", implicit_outs),
+ module_implicit_outs = kernel_utils.transform_kernel_build_outs(name, "module_implicit_outs", module_implicit_outs),
internal_outs = kernel_utils.transform_kernel_build_outs(name, "internal_outs", _kernel_build_internal_outs),
deps = deps,
base_kernel = base_kernel,
@@ -426,6 +433,7 @@ def kernel_build(
("outs", outs),
("module_outs", module_outs),
("implicit_outs", implicit_outs),
+ ("module_implicit_outs", module_implicit_outs),
# internal_outs are opaque to the user, hence we don't create a alias (filegroup) for them.
):
if out_attr_val == None:
@@ -483,9 +491,10 @@ def kernel_build(
target = name,
**kwargs
)
+
kernel_module_test(
name = name + "_modules_test",
- modules = real_outs.get("module_outs"),
+ modules = (real_outs.get("module_outs") or []) + (real_outs.get("module_implicit_outs") or []),
**kwargs
)
@@ -551,15 +560,15 @@ def _kernel_build_impl(ctx):
# => all_output_names = ["foo", "Module.symvers", ...]
# all_output_files = {"out": {"foo": File(...)}, "internal_outs": {"Module.symvers": File(...)}, ...}
all_output_files = {}
- for attr in ("outs", "module_outs", "implicit_outs", "internal_outs"):
+ for attr in ("outs", "module_outs", "implicit_outs", "module_implicit_outs", "internal_outs"):
all_output_files[attr] = {name: ctx.actions.declare_file("{}/{}".format(ctx.label.name, name)) for name in getattr(ctx.attr, attr)}
all_output_names_minus_modules = []
for attr, d in all_output_files.items():
- if attr != "module_outs":
+ if attr not in ("module_outs", "module_implicit_outs"):
all_output_names_minus_modules += d.keys()
# A file containing all module_outs
- all_module_names = all_output_files["module_outs"].keys()
+ all_module_names = all_output_files["module_outs"].keys() + all_output_files["module_implicit_outs"].keys()
all_module_names_file = ctx.actions.declare_file("{name}_all_module_names/{name}{suffix}".format(name = ctx.label.name, suffix = MODULE_OUTS_FILE_SUFFIX))
ctx.actions.write(
output = all_module_names_file,
@@ -848,6 +857,7 @@ _kernel_build = rule(
"outs": attr.string_list(),
"module_outs": attr.string_list(doc = "output *.ko files"),
"internal_outs": attr.string_list(doc = "Like `outs`, but not in dist"),
+ "module_implicit_outs": attr.string_list(doc = "Like `module_outs`, but not in dist"),
"implicit_outs": attr.string_list(doc = "Like `outs`, but not in dist"),
"_check_declared_output_list": attr.label(
allow_single_file = True,
@@ -867,7 +877,7 @@ _kernel_build = rule(
),
"base_kernel_for_module_outs": attr.label(
providers = [KernelBuildInTreeModulesInfo],
- doc = "If set, use the `module_outs` of this label as an allowlist for modules in the staging directory. Otherwise use `base_kernel`.",
+ doc = "If set, use the `module_outs` and `module_implicit_outs` of this label as an allowlist for modules in the staging directory. Otherwise use `base_kernel`.",
),
"kmi_symbol_list_strict_mode": attr.bool(),
"raw_kmi_symbol_list": attr.label(