Merge "Add support for AUTO_*_INITIALIZE to build/soong." am: 7f0560d962 am: b28643b33f am: 9e239e9b85

am: d574f6ff1b

Change-Id: I5554077d9311e636f4ea277965ec34d70727b318
This commit is contained in:
Stephen Hines 2019-08-06 15:10:39 -07:00 committed by android-build-merger
commit 4ebe705827

View file

@ -150,8 +150,22 @@ func init() {
pctx.StaticVariable("HostGlobalLdflags", strings.Join(hostGlobalLdflags, " "))
pctx.StaticVariable("HostGlobalLldflags", strings.Join(hostGlobalLldflags, " "))
pctx.StaticVariable("CommonClangGlobalCflags",
strings.Join(append(ClangFilterUnknownCflags(commonGlobalCflags), "${ClangExtraCflags}"), " "))
pctx.VariableFunc("CommonClangGlobalCflags", func(ctx android.PackageVarContext) string {
flags := ClangFilterUnknownCflags(commonGlobalCflags)
flags = append(flags, "${ClangExtraCflags}")
// http://b/131390872
// Automatically initialize any uninitialized stack variables.
// Prefer zero-init if both options are set.
if ctx.Config().IsEnvTrue("AUTO_ZERO_INITIALIZE") {
flags = append(flags, "-ftrivial-auto-var-init=zero -enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang")
} else if ctx.Config().IsEnvTrue("AUTO_PATTERN_INITIALIZE") {
flags = append(flags, "-ftrivial-auto-var-init=pattern")
}
return strings.Join(flags, " ")
})
pctx.VariableFunc("DeviceClangGlobalCflags", func(ctx android.PackageVarContext) string {
if ctx.Config().Fuchsia() {
return strings.Join(ClangFilterUnknownCflags(deviceGlobalCflags), " ")