Add support for toc optimization in soong
Skip relinking against shared libraries whose interface hasn't changed.
Test: mmma -j frameworks/native/libs/gui
Test: touch frameworks/native/libs/gui/BufferItem.cpp
Test: mmma -j frameworks/native/libs/gui, see nothing relinks past libgui
Bug: 26014946
Change-Id: I4d4b8da6a35c682341ae51869f5c72b51e192053
diff --git a/cc/builder.go b/cc/builder.go
index 42a7f48..b813783 100644
--- a/cc/builder.go
+++ b/cc/builder.go
@@ -138,6 +138,18 @@
Description: "copy gcc $out",
},
"ccCmd", "cFlags", "libName")
+
+ tocPath = pctx.SourcePathVariable("tocPath", "build/soong/scripts/toc.sh")
+
+ toc = pctx.AndroidStaticRule("toc",
+ blueprint.RuleParams{
+ Depfile: "${out}.d",
+ Deps: blueprint.DepsGCC,
+ Command: "CROSS_COMPILE=$crossCompile $tocPath -i ${in} -o ${out} -d ${out}.d",
+ CommandDeps: []string{"$tocPath"},
+ Restat: true,
+ },
+ "crossCompile")
)
func init() {
@@ -380,7 +392,6 @@
libFlagsList = append(libFlagsList, lib.String())
}
- deps = append(deps, sharedLibs...)
deps = append(deps, staticLibs...)
deps = append(deps, lateStaticLibs...)
deps = append(deps, wholeStaticLibs...)
@@ -403,6 +414,22 @@
})
}
+// Generate a rule for extract a table of contents from a shared library (.so)
+func TransformSharedObjectToToc(ctx android.ModuleContext, inputFile android.WritablePath,
+ outputFile android.WritablePath, flags builderFlags) {
+
+ crossCompile := gccCmd(flags.toolchain, "")
+
+ ctx.ModuleBuild(pctx, android.ModuleBuildParams{
+ Rule: toc,
+ Output: outputFile,
+ Input: inputFile,
+ Args: map[string]string{
+ "crossCompile": crossCompile,
+ },
+ })
+}
+
// Generate a rule for compiling multiple .o files to a .o using ld partial linking
func TransformObjsToObj(ctx android.ModuleContext, objFiles android.Paths,
flags builderFlags, outputFile android.WritablePath) {