diff options
Diffstat (limited to 'cc')
| -rw-r--r-- | cc/builder.go | 57 | ||||
| -rw-r--r-- | cc/config/global.go | 13 |
2 files changed, 54 insertions, 16 deletions
diff --git a/cc/builder.go b/cc/builder.go index 5641b7d15..3dc9a08c2 100644 --- a/cc/builder.go +++ b/cc/builder.go @@ -29,6 +29,7 @@ import ( "android/soong/android" "android/soong/cc/config" + "android/soong/remoteexec" ) const ( @@ -62,7 +63,7 @@ var ( }, "ccCmd", "cFlags") - ld = pctx.AndroidStaticRule("ld", + ld, ldRE = remoteexec.StaticRules(pctx, "ld", blueprint.RuleParams{ Command: "$ldCmd ${crtBegin} @${out}.rsp " + "${libFlags} ${crtEnd} -o ${out} ${ldFlags}", @@ -72,16 +73,28 @@ var ( // clang -Wl,--out-implib doesn't update its output file if it hasn't changed. Restat: true, }, - "ldCmd", "crtBegin", "libFlags", "crtEnd", "ldFlags") - - partialLd = pctx.AndroidStaticRule("partialLd", + &remoteexec.REParams{Labels: map[string]string{"type": "link", "tool": "clang"}, + ExecStrategy: "${config.RECXXLinksExecStrategy}", + Inputs: []string{"${out}.rsp"}, + RSPFile: "${out}.rsp", + OutputFiles: []string{"${out}"}, + ToolchainInputs: []string{"$ldCmd"}, + Platform: map[string]string{remoteexec.PoolKey: "${config.RECXXLinksPool}"}, + }, []string{"ldCmd", "crtBegin", "libFlags", "crtEnd", "ldFlags"}, nil) + + partialLd, partialLdRE = remoteexec.StaticRules(pctx, "partialLd", blueprint.RuleParams{ // Without -no-pie, clang 7.0 adds -pie to link Android files, // but -r and -pie cannot be used together. Command: "$ldCmd -nostdlib -no-pie -Wl,-r ${in} -o ${out} ${ldFlags}", CommandDeps: []string{"$ldCmd"}, - }, - "ldCmd", "ldFlags") + }, &remoteexec.REParams{ + Labels: map[string]string{"type": "link", "tool": "clang"}, + ExecStrategy: "${config.RECXXLinksExecStrategy}", Inputs: []string{"$inCommaList"}, + OutputFiles: []string{"${out}"}, + ToolchainInputs: []string{"$ldCmd"}, + Platform: map[string]string{remoteexec.PoolKey: "${config.RECXXLinksPool}"}, + }, []string{"ldCmd", "ldFlags"}, []string{"inCommaList"}) ar = pctx.AndroidStaticRule("ar", blueprint.RuleParams{ @@ -249,6 +262,7 @@ func init() { } pctx.HostBinToolVariable("SoongZipCmd", "soong_zip") + pctx.Import("android/soong/remoteexec") } type builderFlags struct { @@ -666,12 +680,17 @@ func TransformObjToDynamicBinary(ctx android.ModuleContext, deps = append(deps, crtBegin.Path(), crtEnd.Path()) } + rule := ld + if ctx.Config().IsEnvTrue("RBE_CXX_LINKS") { + rule = ldRE + } + ctx.Build(pctx, android.BuildParams{ - Rule: ld, - Description: "link " + outputFile.Base(), - Output: outputFile, - Inputs: objFiles, - Implicits: deps, + Rule: rule, + Description: "link " + outputFile.Base(), + Output: outputFile, + Inputs: objFiles, + Implicits: deps, Args: map[string]string{ "ldCmd": ldCmd, "crtBegin": crtBegin.String(), @@ -803,15 +822,21 @@ func TransformObjsToObj(ctx android.ModuleContext, objFiles android.Paths, ldCmd := "${config.ClangBin}/clang++" + rule := partialLd + args := map[string]string{ + "ldCmd": ldCmd, + "ldFlags": flags.ldFlags, + } + if ctx.Config().IsEnvTrue("RBE_CXX_LINKS") { + rule = partialLdRE + args["inCommaList"] = strings.Join(objFiles.Strings(), ",") + } ctx.Build(pctx, android.BuildParams{ - Rule: partialLd, + Rule: rule, Description: "link " + outputFile.Base(), Output: outputFile, Inputs: objFiles, - Args: map[string]string{ - "ldCmd": ldCmd, - "ldFlags": flags.ldFlags, - }, + Args: args, }) } diff --git a/cc/config/global.go b/cc/config/global.go index 7c7b47a51..4af622115 100644 --- a/cc/config/global.go +++ b/cc/config/global.go @@ -18,6 +18,7 @@ import ( "strings" "android/soong/android" + "android/soong/remoteexec" ) var ( @@ -232,6 +233,9 @@ func init() { } return "" }) + + pctx.VariableFunc("RECXXLinksPool", envOverrideFunc("RBE_CXX_LINKS_POOL", remoteexec.DefaultPool)) + pctx.VariableFunc("RECXXLinksExecStrategy", envOverrideFunc("RBE_CXX_LINKS_EXEC_STRATEGY", remoteexec.LocalExecStrategy)) } var HostPrebuiltTag = pctx.VariableConfigMethod("HostPrebuiltTag", android.Config.PrebuiltOS) @@ -245,3 +249,12 @@ func bionicHeaders(kernelArch string) string { "-isystem bionic/libc/kernel/android/uapi", }, " ") } + +func envOverrideFunc(envVar, defaultVal string) func(ctx android.PackageVarContext) string { + return func(ctx android.PackageVarContext) string { + if override := ctx.Config().Getenv(envVar); override != "" { + return override + } + return defaultVal + } +} |