From c2346f1c21a31ab45f670e6f100101c60a6857c4 Mon Sep 17 00:00:00 2001 From: Matthias Maennich Date: Thu, 2 Sep 2021 20:45:33 +0100 Subject: [PATCH] ndk_library: separate abidw and abitidy into separate rules Both processes might consume a large amount of memory when analyzing library ABIs. By chaining them via a pipe we keep the same representation twice in memory. That can introduce a problematic peak memory consumption. Hence, split them apart into separate rules that depend on each other. Bug: 191235788 Test: m out/soong/abi-dumps/ndk/28/x86_64/libc/abi.xml Signed-off-by: Matthias Maennich Change-Id: Ia0264a5ede5b2c2a3c2e3fbe968c11d36acf33c2 --- cc/ndk_library.go | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/cc/ndk_library.go b/cc/ndk_library.go index 51cdddfb0..704b03afb 100644 --- a/cc/ndk_library.go +++ b/cc/ndk_library.go @@ -45,11 +45,17 @@ var ( abidw = pctx.AndroidStaticRule("abidw", blueprint.RuleParams{ Command: "$abidw --type-id-style hash --no-corpus-path " + - "--no-show-locs --no-comp-dir-path -w $symbolList $in | " + - "$abitidy --all -o $out", - CommandDeps: []string{"$abitidy", "$abidw"}, + "--no-show-locs --no-comp-dir-path -w $symbolList " + + "$in --out-file $out", + CommandDeps: []string{"$abidw"}, }, "symbolList") + abitidy = pctx.AndroidStaticRule("abitidy", + blueprint.RuleParams{ + Command: "$abitidy --all -i $in -o $out", + CommandDeps: []string{"$abitidy"}, + }) + abidiff = pctx.AndroidStaticRule("abidiff", blueprint.RuleParams{ // Need to create *some* output for ninja. We don't want to use tee @@ -313,19 +319,28 @@ func canDiffAbi() bool { func (this *stubDecorator) dumpAbi(ctx ModuleContext, symbolList android.Path) { implementationLibrary := this.findImplementationLibrary(ctx) - this.abiDumpPath = getNdkAbiDumpInstallBase(ctx).Join(ctx, + abiRawPath := getNdkAbiDumpInstallBase(ctx).Join(ctx, this.apiLevel.String(), ctx.Arch().ArchType.String(), - this.libraryName(ctx), "abi.xml") + this.libraryName(ctx), "abi.raw.xml") ctx.Build(pctx, android.BuildParams{ Rule: abidw, Description: fmt.Sprintf("abidw %s", implementationLibrary), - Output: this.abiDumpPath, Input: implementationLibrary, + Output: abiRawPath, Implicit: symbolList, Args: map[string]string{ "symbolList": symbolList.String(), }, }) + this.abiDumpPath = getNdkAbiDumpInstallBase(ctx).Join(ctx, + this.apiLevel.String(), ctx.Arch().ArchType.String(), + this.libraryName(ctx), "abi.xml") + ctx.Build(pctx, android.BuildParams{ + Rule: abitidy, + Description: fmt.Sprintf("abitidy %s", implementationLibrary), + Input: abiRawPath, + Output: this.abiDumpPath, + }) } func findNextApiLevel(ctx ModuleContext, apiLevel android.ApiLevel) *android.ApiLevel {