Merge changes Ibd19d9a5,Icfc42ad7,Ieafdcceb am: 7b2e5cd134
am: 4a9761befe
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1980449 Change-Id: I42ca2dc2c2411ed878ac55254bab50b138c3492a
This commit is contained in:
commit
14eea8f7d5
4 changed files with 66 additions and 13 deletions
|
@ -917,7 +917,8 @@ func createArchPropTypeDesc(props reflect.Type) []archPropTypeDesc {
|
|||
for _, archType := range osArchTypeMap[os] {
|
||||
targets = append(targets, GetCompoundTargetField(os, archType))
|
||||
|
||||
// Also add the special "linux_<arch>" and "bionic_<arch>" property structs.
|
||||
// Also add the special "linux_<arch>", "bionic_<arch>" , "glibc_<arch>", and
|
||||
// "musl_<arch>" property structs.
|
||||
if os.Linux() {
|
||||
target := "Linux_" + archType.Name
|
||||
if !InList(target, targets) {
|
||||
|
@ -930,6 +931,18 @@ func createArchPropTypeDesc(props reflect.Type) []archPropTypeDesc {
|
|||
targets = append(targets, target)
|
||||
}
|
||||
}
|
||||
if os == Linux {
|
||||
target := "Glibc_" + archType.Name
|
||||
if !InList(target, targets) {
|
||||
targets = append(targets, target)
|
||||
}
|
||||
}
|
||||
if os == LinuxMusl {
|
||||
target := "Musl_" + archType.Name
|
||||
if !InList(target, targets) {
|
||||
targets = append(targets, target)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1379,11 +1392,25 @@ func getArchProperties(ctx BaseMutatorContext, archProperties interface{}, arch
|
|||
result = append(result, osArchProperties)
|
||||
}
|
||||
|
||||
if os == Linux {
|
||||
field := "Glibc_" + archType.Name
|
||||
userFriendlyField := "target.glibc_" + "_" + archType.Name
|
||||
if osArchProperties, ok := getChildPropertyStruct(ctx, targetProp, field, userFriendlyField); ok {
|
||||
result = append(result, osArchProperties)
|
||||
}
|
||||
}
|
||||
|
||||
if os == LinuxMusl {
|
||||
field := "Musl_" + archType.Name
|
||||
userFriendlyField := "target.musl_" + "_" + archType.Name
|
||||
if osArchProperties, ok := getChildPropertyStruct(ctx, targetProp, field, userFriendlyField); ok {
|
||||
result = append(result, osArchProperties)
|
||||
}
|
||||
|
||||
// Special case: to ease the transition from glibc to musl, apply linux_glibc
|
||||
// properties (which has historically mean host linux) to musl variants.
|
||||
field := "Linux_glibc_" + archType.Name
|
||||
userFriendlyField := "target.linux_glibc_" + archType.Name
|
||||
field = "Linux_glibc_" + archType.Name
|
||||
userFriendlyField = "target.linux_glibc_" + archType.Name
|
||||
if osArchProperties, ok := getChildPropertyStruct(ctx, targetProp, field, userFriendlyField); ok {
|
||||
result = append(result, osArchProperties)
|
||||
}
|
||||
|
|
|
@ -1982,3 +1982,8 @@ func (c *config) ApexBootJars() ConfiguredJarList {
|
|||
func (c *config) RBEWrapper() string {
|
||||
return c.GetenvWithDefault("RBE_WRAPPER", remoteexec.DefaultWrapperPath)
|
||||
}
|
||||
|
||||
// UseHostMusl returns true if the host target has been configured to build against musl libc.
|
||||
func (c *config) UseHostMusl() bool {
|
||||
return Bool(c.productVariables.HostMusl)
|
||||
}
|
||||
|
|
|
@ -470,7 +470,7 @@ var _ BuilderContext = SingletonContext(nil)
|
|||
|
||||
func (r *RuleBuilder) depFileMergerCmd(depFiles WritablePaths) *RuleBuilderCommand {
|
||||
return r.Command().
|
||||
BuiltTool("dep_fixer").
|
||||
builtToolWithoutDeps("dep_fixer").
|
||||
Inputs(depFiles.Paths())
|
||||
}
|
||||
|
||||
|
@ -638,7 +638,7 @@ func (r *RuleBuilder) Build(name string, desc string) {
|
|||
}
|
||||
sboxCmd.Text("rm -rf").Output(r.outDir)
|
||||
sboxCmd.Text("&&")
|
||||
sboxCmd.BuiltTool("sbox").
|
||||
sboxCmd.builtToolWithoutDeps("sbox").
|
||||
Flag("--sandbox-path").Text(shared.TempDirForOutDir(PathForOutput(r.ctx).String())).
|
||||
Flag("--manifest").Input(r.sboxManifestPath)
|
||||
|
||||
|
@ -1040,6 +1040,19 @@ func (c *RuleBuilderCommand) ImplicitTools(paths Paths) *RuleBuilderCommand {
|
|||
// It is equivalent to:
|
||||
// cmd.Tool(ctx.Config().HostToolPath(ctx, tool))
|
||||
func (c *RuleBuilderCommand) BuiltTool(tool string) *RuleBuilderCommand {
|
||||
if c.rule.ctx.Config().UseHostMusl() {
|
||||
// If the host is using musl, assume that the tool was built against musl libc and include
|
||||
// libc_musl.so in the sandbox.
|
||||
// TODO(ccross): if we supported adding new dependencies during GenerateAndroidBuildActions
|
||||
// this could be a dependency + TransitivePackagingSpecs.
|
||||
c.ImplicitTool(c.rule.ctx.Config().HostJNIToolPath(c.rule.ctx, "libc_musl"))
|
||||
}
|
||||
return c.builtToolWithoutDeps(tool)
|
||||
}
|
||||
|
||||
// builtToolWithoutDeps is similar to BuiltTool, but doesn't add any dependencies. It is used
|
||||
// internally by RuleBuilder for helper tools that are known to be compiled statically.
|
||||
func (c *RuleBuilderCommand) builtToolWithoutDeps(tool string) *RuleBuilderCommand {
|
||||
return c.Tool(c.rule.ctx.Config().HostToolPath(c.rule.ctx, tool))
|
||||
}
|
||||
|
||||
|
|
|
@ -194,10 +194,6 @@ func (t *toolchainLinux) IncludeFlags() string {
|
|||
return ""
|
||||
}
|
||||
|
||||
func (t *toolchainLinuxX86) ClangTriple() string {
|
||||
return "i686-linux-gnu"
|
||||
}
|
||||
|
||||
func (t *toolchainLinuxX86) Cflags() string {
|
||||
return "${config.LinuxCflags} ${config.LinuxX86Cflags}"
|
||||
}
|
||||
|
@ -206,10 +202,6 @@ func (t *toolchainLinuxX86) Cppflags() string {
|
|||
return ""
|
||||
}
|
||||
|
||||
func (t *toolchainLinuxX8664) ClangTriple() string {
|
||||
return "x86_64-linux-gnu"
|
||||
}
|
||||
|
||||
func (t *toolchainLinuxX8664) Cflags() string {
|
||||
return "${config.LinuxCflags} ${config.LinuxX8664Cflags}"
|
||||
}
|
||||
|
@ -283,6 +275,10 @@ type toolchainLinuxGlibcX8664 struct {
|
|||
toolchainGlibc
|
||||
}
|
||||
|
||||
func (t *toolchainLinuxGlibcX86) ClangTriple() string {
|
||||
return "i686-linux-gnu"
|
||||
}
|
||||
|
||||
func (t *toolchainLinuxGlibcX86) Cflags() string {
|
||||
return t.toolchainLinuxX86.Cflags() + " " + t.toolchainGlibc.Cflags()
|
||||
}
|
||||
|
@ -295,6 +291,10 @@ func (t *toolchainLinuxGlibcX86) Lldflags() string {
|
|||
return t.toolchainLinuxX86.Lldflags() + " " + t.toolchainGlibc.Lldflags()
|
||||
}
|
||||
|
||||
func (t *toolchainLinuxGlibcX8664) ClangTriple() string {
|
||||
return "x86_64-linux-gnu"
|
||||
}
|
||||
|
||||
func (t *toolchainLinuxGlibcX8664) Cflags() string {
|
||||
return t.toolchainLinuxX8664.Cflags() + " " + t.toolchainGlibc.Cflags()
|
||||
}
|
||||
|
@ -356,6 +356,10 @@ type toolchainLinuxMuslX8664 struct {
|
|||
toolchainMusl
|
||||
}
|
||||
|
||||
func (t *toolchainLinuxMuslX86) ClangTriple() string {
|
||||
return "i686-linux-musl"
|
||||
}
|
||||
|
||||
func (t *toolchainLinuxMuslX86) Cflags() string {
|
||||
return t.toolchainLinuxX86.Cflags() + " " + t.toolchainMusl.Cflags()
|
||||
}
|
||||
|
@ -368,6 +372,10 @@ func (t *toolchainLinuxMuslX86) Lldflags() string {
|
|||
return t.toolchainLinuxX86.Lldflags() + " " + t.toolchainMusl.Lldflags()
|
||||
}
|
||||
|
||||
func (t *toolchainLinuxMuslX8664) ClangTriple() string {
|
||||
return "x86_64-linux-musl"
|
||||
}
|
||||
|
||||
func (t *toolchainLinuxMuslX8664) Cflags() string {
|
||||
return t.toolchainLinuxX8664.Cflags() + " " + t.toolchainMusl.Cflags()
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue