summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYifan Hong <elsk@google.com>2023-10-25 14:14:09 -0700
committerIsaac Manjarres <isaacmanjarres@google.com>2024-01-31 17:04:12 +0000
commitb6bd878297634142950d4d6400c5f1f34fda5c4c (patch)
tree20931a7d30993e8f556ec9efbe606f8df62ca7fa
parent840dcd35c0e53cef2acf419b54ac27f637ee72f8 (diff)
downloadbuild-b6bd878297634142950d4d6400c5f1f34fda5c4c.tar.gz
kleaf: kernel_module restores Module.symvers to `COMMON_OUT_DIR`.
When ddk_module is building with --config=local: - OUT_DIR is in out/cache/<hash>/$KERNEL_DIR - Module.symvers of the depended module is restored to out/cache/<hash>/<package>/<name>_Module.symvers - However, the generated makefile expects the file in COMMON_OUT_DIR/<package>/<name>_Module.symvers, where COMMON_OUT_DIR is not changed. This is because cache_dir.bzl only modifies the value of OUT_DIR, not COMMON_OUT_DIR. Hence, let kernel_module's command to restore its Module.symvers to use COMMON_OUT_DIR directly. Bug: 304499217 Change-Id: I28995f30812e7ac2d596982d70e79f9374364787 Signed-off-by: Ulises Mendez Martinez <umendez@google.com> Signed-off-by: Yifan Hong <elsk@google.com> (cherry picked from commit 2f12101856d947353d043aec76ed0bf7c09e1c70)
-rw-r--r--kleaf/impl/common_providers.bzl3
-rw-r--r--kleaf/impl/kernel_module.bzl8
2 files changed, 6 insertions, 5 deletions
diff --git a/kleaf/impl/common_providers.bzl b/kleaf/impl/common_providers.bzl
index fc5173f7..8dd23e52 100644
--- a/kleaf/impl/common_providers.bzl
+++ b/kleaf/impl/common_providers.bzl
@@ -318,8 +318,7 @@ ModuleSymversInfo = provider(
doc = "A provider that provides `Module.symvers` for `modpost`.",
fields = {
"restore_paths": """A [depset](https://bazel.build/extending/depsets) of
- paths relative to <the root of the output directory> (e.g.
- `<sandbox_root>/out/<branch>`) where the `Module.symvers` files will be
+ paths relative to `COMMON_OUT_DIR` where the `Module.symvers` files will be
restored to by `KernelModuleSetupInfo`.""",
},
)
diff --git a/kleaf/impl/kernel_module.bzl b/kleaf/impl/kernel_module.bzl
index 7d1975ce..cbd84df9 100644
--- a/kleaf/impl/kernel_module.bzl
+++ b/kleaf/impl/kernel_module.bzl
@@ -550,6 +550,7 @@ def _kernel_module_impl(ctx):
progress_message = "Copying outputs {}".format(ctx.label),
)
+ module_symvers_restore_path = paths.join(ext_mod, ctx.attr.internal_module_symvers_name)
setup = """
# Use a new shell to avoid polluting variables
(
@@ -559,14 +560,15 @@ def _kernel_module_impl(ctx):
mkdir -p ${{ROOT_DIR}}/{ext_mod}
ext_mod_rel=$(realpath ${{ROOT_DIR}}/{ext_mod} --relative-to ${{KERNEL_DIR}})
# Restore Modules.symvers
- mkdir -p $(dirname ${{OUT_DIR}}/${{ext_mod_rel}}/{internal_module_symvers_name})
- rsync -aL {module_symvers} ${{OUT_DIR}}/${{ext_mod_rel}}/{internal_module_symvers_name}
+ mkdir -p $(dirname ${{COMMON_OUT_DIR}}/{module_symvers_restore_path})
+ rsync -aL {module_symvers} ${{COMMON_OUT_DIR}}/{module_symvers_restore_path}
# New shell ends
)
""".format(
ext_mod = ext_mod,
module_symvers = module_symvers.path,
internal_module_symvers_name = ctx.attr.internal_module_symvers_name,
+ module_symvers_restore_path = module_symvers_restore_path,
)
if ctx.attr.internal_ddk_makefiles_dir:
@@ -615,7 +617,7 @@ def _kernel_module_impl(ctx):
# path/to/package/target_name/target_name_Module.symvers -> path/to/package/target_name_Module.symvers;
# This is similar to ${{OUT_DIR}}/${{ext_mod_rel}}
# It is needed to remove the `target_name` because we declare_file({name}/{internal_module_symvers_name}) above.
- restore_paths = depset([paths.join(ext_mod, ctx.attr.internal_module_symvers_name)]),
+ restore_paths = depset([module_symvers_restore_path]),
),
ddk_headers_info,
ddk_config_info,