Split local and global cflags
Native compiler flags are currently applied in approximately:
global cflags
local cflags
local include dirs
global include dirs
global conlyflags
local conlyflags
global cppflags
local cppflags
This means that a flag that is enabled in the global cppflags
cannot be disabled in the local cflags, and an Android.bp author
must know to disable it in the local cppflags. A better order
would be:
global cflags
global conlyflags
global cppflags
local cflags
local conlyflags
local cppflags
local include dirs
global include dirs
We are mixing both the global and local cflags into a single
variable, and similar for conlyflags and cppflags, which
prevents reordering them. This CL prepares to reorder them
by splitting the global and local cflags into separate variables.
Bug: 143713277
Test: m native
Change-Id: Ic55a8c3516c331dc5f2af9d00e59ceca9d3e6c15
diff --git a/cc/pgo.go b/cc/pgo.go
index 4e915ff..4618f4e 100644
--- a/cc/pgo.go
+++ b/cc/pgo.go
@@ -89,18 +89,18 @@
}
func (props *PgoProperties) addProfileGatherFlags(ctx ModuleContext, flags Flags) Flags {
- flags.CFlags = append(flags.CFlags, props.Pgo.Cflags...)
+ flags.Local.CFlags = append(flags.Local.CFlags, props.Pgo.Cflags...)
if props.isInstrumentation() {
- flags.CFlags = append(flags.CFlags, profileInstrumentFlag)
+ flags.Local.CFlags = append(flags.Local.CFlags, profileInstrumentFlag)
// The profile runtime is added below in deps(). Add the below
// flag, which is the only other link-time action performed by
// the Clang driver during link.
- flags.LdFlags = append(flags.LdFlags, "-u__llvm_profile_runtime")
+ flags.Local.LdFlags = append(flags.Local.LdFlags, "-u__llvm_profile_runtime")
}
if props.isSampling() {
- flags.CFlags = append(flags.CFlags, profileSamplingFlag)
- flags.LdFlags = append(flags.LdFlags, profileSamplingFlag)
+ flags.Local.CFlags = append(flags.Local.CFlags, profileSamplingFlag)
+ flags.Local.LdFlags = append(flags.Local.LdFlags, profileSamplingFlag)
}
return flags
}
@@ -170,8 +170,8 @@
profileFilePath := profileFile.Path()
profileUseFlags := props.profileUseFlags(ctx, profileFilePath.String())
- flags.CFlags = append(flags.CFlags, profileUseFlags...)
- flags.LdFlags = append(flags.LdFlags, profileUseFlags...)
+ flags.Local.CFlags = append(flags.Local.CFlags, profileUseFlags...)
+ flags.Local.LdFlags = append(flags.Local.LdFlags, profileUseFlags...)
// Update CFlagsDeps and LdFlagsDeps so the module is rebuilt
// if profileFile gets updated