From 26d82910150270e29e4032149e87ed6e7662ffbb Mon Sep 17 00:00:00 2001 From: Spandan Das Date: Tue, 10 Dec 2024 20:33:15 +0000 Subject: Add a `prebuilt_kernel_modules` prop to skip debug symbol strip `Strip_debug_symbols` will default to true. If this property is set to false explicitly, the .ko files will be installed without running llvm-strip. The use case for this is (system|vendor|odm)_dlkm filesystems, which package the source *.ko files without stripping debug symbols. This CL also fixes a bug where the output of `addLeadingSlashToPaths` was getting ignored, since it assigned its output to a variable that was scoped locally (via :=) instead of updating the variable in its outer scope (via =) Bug: 383357338 Test: mounted system_dlkm, vendor_dlkm, odm_dlkm image files built by make and soong (top of CL stack). NOTICE is the last diff. Change-Id: Ie5ecef0c3f6d024fe413106e17f22dee3fb18d61 --- kernel/prebuilt_kernel_modules.go | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'kernel/prebuilt_kernel_modules.go') diff --git a/kernel/prebuilt_kernel_modules.go b/kernel/prebuilt_kernel_modules.go index 001a1e732..ec7a9714b 100644 --- a/kernel/prebuilt_kernel_modules.go +++ b/kernel/prebuilt_kernel_modules.go @@ -67,6 +67,10 @@ type prebuiltKernelModulesProperties struct { // Whether this module is directly installable to one of the partitions. Default is true Installable *bool + + // Whether debug symbols should be stripped from the *.ko files. + // Defaults to true. + Strip_debug_symbols *bool } // prebuilt_kernel_modules installs a set of prebuilt kernel module files to the correct directory. @@ -100,7 +104,9 @@ func (pkm *prebuiltKernelModules) GenerateAndroidBuildActions(ctx android.Module systemModules := android.PathsForModuleSrc(ctx, pkm.properties.System_deps) depmodOut := pkm.runDepmod(ctx, modules, systemModules) - strippedModules := stripDebugSymbols(ctx, modules) + if proptools.BoolDefault(pkm.properties.Strip_debug_symbols, true) { + modules = stripDebugSymbols(ctx, modules) + } installDir := android.PathForModuleInstall(ctx, "lib", "modules") // Kernel module is installed to vendor_ramdisk/lib/modules regardless of product @@ -114,7 +120,7 @@ func (pkm *prebuiltKernelModules) GenerateAndroidBuildActions(ctx android.Module installDir = installDir.Join(ctx, pkm.KernelVersion()) } - for _, m := range strippedModules { + for _, m := range modules { ctx.InstallFile(installDir, filepath.Base(m.String()), m) } ctx.InstallFile(installDir, "modules.load", depmodOut.modulesLoad) @@ -165,9 +171,9 @@ var ( }, "stripCmd") ) -func stripDebugSymbols(ctx android.ModuleContext, modules android.Paths) android.OutputPaths { +func stripDebugSymbols(ctx android.ModuleContext, modules android.Paths) android.Paths { dir := android.PathForModuleOut(ctx, "stripped").OutputPath - var outputs android.OutputPaths + var outputs android.Paths for _, m := range modules { stripped := dir.Join(ctx, filepath.Base(m.String())) @@ -305,7 +311,7 @@ func (pkm *prebuiltKernelModules) runDepmod(ctx android.ModuleContext, modules a finalModulesDep := modulesDep // Add a leading slash to paths in modules.dep of android dlkm if ctx.InstallInSystemDlkm() || ctx.InstallInVendorDlkm() || ctx.InstallInOdmDlkm() { - finalModulesDep := modulesDep.ReplaceExtension(ctx, "intermediates") + finalModulesDep = modulesDep.ReplaceExtension(ctx, "intermediates") ctx.Build(pctx, android.BuildParams{ Rule: addLeadingSlashToPaths, Input: modulesDep, -- cgit v1.2.3-59-g8ed1b