Merge "Allow remote execution of link actions."
This commit is contained in:
@@ -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} ${extraLibFlags}",
|
||||
@@ -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", "extraLibFlags")
|
||||
&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", "extraLibFlags"}, nil)
|
||||
|
||||
partialLd = pctx.AndroidStaticRule("partialLd",
|
||||
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 -fuse-ld=lld -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{
|
||||
@@ -262,6 +275,7 @@ func init() {
|
||||
}
|
||||
|
||||
pctx.HostBinToolVariable("SoongZipCmd", "soong_zip")
|
||||
pctx.Import("android/soong/remoteexec")
|
||||
}
|
||||
|
||||
type builderFlags struct {
|
||||
@@ -657,8 +671,13 @@ 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,
|
||||
Rule: rule,
|
||||
Description: "link " + outputFile.Base(),
|
||||
Output: outputFile,
|
||||
ImplicitOutputs: implicitOutputs,
|
||||
@@ -798,16 +817,22 @@ func TransformObjsToObj(ctx android.ModuleContext, objFiles android.Paths,
|
||||
|
||||
ldCmd := "${config.ClangBin}/clang++"
|
||||
|
||||
rule := partialLd
|
||||
args := map[string]string{
|
||||
"ldCmd": ldCmd,
|
||||
"ldFlags": flags.globalLdFlags + " " + flags.localLdFlags,
|
||||
}
|
||||
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,
|
||||
Implicits: deps,
|
||||
Args: map[string]string{
|
||||
"ldCmd": ldCmd,
|
||||
"ldFlags": flags.globalLdFlags + " " + flags.localLdFlags,
|
||||
},
|
||||
Args: args,
|
||||
})
|
||||
}
|
||||
|
||||
|
@@ -18,6 +18,7 @@ import (
|
||||
"strings"
|
||||
|
||||
"android/soong/android"
|
||||
"android/soong/remoteexec"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -255,6 +256,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)
|
||||
@@ -268,3 +272,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
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user