Reorder local and global flags
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. The previous CL split the global and local flags into separate variables. Rearrange the order that the variables are applied to be: global cflags global conlyflags global cppflags local cflags local include dirs local conlyflags local cppflags global include dirs Bug: 143713277 Test: m native Change-Id: I171524ab40096a636a8e549e1e4bc3347ef9f97a
This commit is contained in:
parent
4af21ed26f
commit
6d88dbad0e
3 changed files with 101 additions and 73 deletions
144
cc/builder.go
144
cc/builder.go
|
@ -261,26 +261,37 @@ func init() {
|
|||
}
|
||||
|
||||
type builderFlags struct {
|
||||
commonFlags string
|
||||
asFlags string
|
||||
cFlags string
|
||||
toolingCFlags string // A separate set of cFlags for clang LibTooling tools
|
||||
toolingCppFlags string // A separate set of cppFlags for clang LibTooling tools
|
||||
conlyFlags string
|
||||
cppFlags string
|
||||
ldFlags string
|
||||
libFlags string
|
||||
extraLibFlags string
|
||||
tidyFlags string
|
||||
sAbiFlags string
|
||||
yasmFlags string
|
||||
aidlFlags string
|
||||
rsFlags string
|
||||
toolchain config.Toolchain
|
||||
tidy bool
|
||||
coverage bool
|
||||
sAbiDump bool
|
||||
emitXrefs bool
|
||||
globalCommonFlags string
|
||||
globalAsFlags string
|
||||
globalYasmFlags string
|
||||
globalCFlags string
|
||||
globalToolingCFlags string // A separate set of cFlags for clang LibTooling tools
|
||||
globalToolingCppFlags string // A separate set of cppFlags for clang LibTooling tools
|
||||
globalConlyFlags string
|
||||
globalCppFlags string
|
||||
globalLdFlags string
|
||||
|
||||
localCommonFlags string
|
||||
localAsFlags string
|
||||
localYasmFlags string
|
||||
localCFlags string
|
||||
localToolingCFlags string // A separate set of cFlags for clang LibTooling tools
|
||||
localToolingCppFlags string // A separate set of cppFlags for clang LibTooling tools
|
||||
localConlyFlags string
|
||||
localCppFlags string
|
||||
localLdFlags string
|
||||
|
||||
libFlags string
|
||||
extraLibFlags string
|
||||
tidyFlags string
|
||||
sAbiFlags string
|
||||
aidlFlags string
|
||||
rsFlags string
|
||||
toolchain config.Toolchain
|
||||
tidy bool
|
||||
coverage bool
|
||||
sAbiDump bool
|
||||
emitXrefs bool
|
||||
|
||||
assemblerWithCpp bool
|
||||
|
||||
|
@ -348,39 +359,45 @@ func TransformSourceToObj(ctx android.ModuleContext, subdir string, srcFiles and
|
|||
kytheFiles = make(android.Paths, 0, len(srcFiles))
|
||||
}
|
||||
|
||||
commonFlags := strings.Join([]string{
|
||||
flags.commonFlags,
|
||||
flags.systemIncludeFlags,
|
||||
}, " ")
|
||||
// Produce fully expanded flags for use by C tools, C compiles, C++ tools, C++ compiles, and asm compiles
|
||||
// respectively.
|
||||
toolingCflags := flags.globalCommonFlags + " " +
|
||||
flags.globalToolingCFlags + " " +
|
||||
flags.globalConlyFlags + " " +
|
||||
flags.localCommonFlags + " " +
|
||||
flags.localToolingCFlags + " " +
|
||||
flags.localConlyFlags + " " +
|
||||
flags.systemIncludeFlags
|
||||
|
||||
toolingCflags := strings.Join([]string{
|
||||
commonFlags,
|
||||
flags.toolingCFlags,
|
||||
flags.conlyFlags,
|
||||
}, " ")
|
||||
cflags := flags.globalCommonFlags + " " +
|
||||
flags.globalCFlags + " " +
|
||||
flags.globalConlyFlags + " " +
|
||||
flags.localCommonFlags + " " +
|
||||
flags.localCFlags + " " +
|
||||
flags.localConlyFlags + " " +
|
||||
flags.systemIncludeFlags
|
||||
|
||||
cflags := strings.Join([]string{
|
||||
commonFlags,
|
||||
flags.cFlags,
|
||||
flags.conlyFlags,
|
||||
}, " ")
|
||||
toolingCppflags := flags.globalCommonFlags + " " +
|
||||
flags.globalToolingCFlags + " " +
|
||||
flags.globalToolingCppFlags + " " +
|
||||
flags.localCommonFlags + " " +
|
||||
flags.localToolingCFlags + " " +
|
||||
flags.localToolingCppFlags + " " +
|
||||
flags.systemIncludeFlags
|
||||
|
||||
toolingCppflags := strings.Join([]string{
|
||||
commonFlags,
|
||||
flags.toolingCFlags,
|
||||
flags.toolingCppFlags,
|
||||
}, " ")
|
||||
cppflags := flags.globalCommonFlags + " " +
|
||||
flags.globalCFlags + " " +
|
||||
flags.globalCppFlags + " " +
|
||||
flags.localCommonFlags + " " +
|
||||
flags.localCFlags + " " +
|
||||
flags.localCppFlags + " " +
|
||||
flags.systemIncludeFlags
|
||||
|
||||
cppflags := strings.Join([]string{
|
||||
commonFlags,
|
||||
flags.cFlags,
|
||||
flags.cppFlags,
|
||||
}, " ")
|
||||
|
||||
asflags := strings.Join([]string{
|
||||
commonFlags,
|
||||
flags.asFlags,
|
||||
}, " ")
|
||||
asflags := flags.globalCommonFlags + " " +
|
||||
flags.globalAsFlags + " " +
|
||||
flags.localCommonFlags + " " +
|
||||
flags.localAsFlags + " " +
|
||||
flags.systemIncludeFlags
|
||||
|
||||
var sAbiDumpFiles android.Paths
|
||||
if flags.sAbiDump {
|
||||
|
@ -407,7 +424,7 @@ func TransformSourceToObj(ctx android.ModuleContext, subdir string, srcFiles and
|
|||
Implicits: cFlagsDeps,
|
||||
OrderOnly: pathDeps,
|
||||
Args: map[string]string{
|
||||
"asFlags": flags.yasmFlags,
|
||||
"asFlags": flags.globalYasmFlags + " " + flags.localYasmFlags,
|
||||
},
|
||||
})
|
||||
continue
|
||||
|
@ -430,8 +447,9 @@ func TransformSourceToObj(ctx android.ModuleContext, subdir string, srcFiles and
|
|||
continue
|
||||
}
|
||||
|
||||
var moduleCflags string
|
||||
var moduleToolingCflags string
|
||||
var moduleFlags string
|
||||
var moduleToolingFlags string
|
||||
|
||||
var ccCmd string
|
||||
tidy := flags.tidy
|
||||
coverage := flags.coverage
|
||||
|
@ -447,19 +465,19 @@ func TransformSourceToObj(ctx android.ModuleContext, subdir string, srcFiles and
|
|||
fallthrough
|
||||
case ".S":
|
||||
ccCmd = "clang"
|
||||
moduleCflags = asflags
|
||||
moduleFlags = asflags
|
||||
tidy = false
|
||||
coverage = false
|
||||
dump = false
|
||||
emitXref = false
|
||||
case ".c":
|
||||
ccCmd = "clang"
|
||||
moduleCflags = cflags
|
||||
moduleToolingCflags = toolingCflags
|
||||
moduleFlags = cflags
|
||||
moduleToolingFlags = toolingCflags
|
||||
case ".cpp", ".cc", ".cxx", ".mm":
|
||||
ccCmd = "clang++"
|
||||
moduleCflags = cppflags
|
||||
moduleToolingCflags = toolingCppflags
|
||||
moduleFlags = cppflags
|
||||
moduleToolingFlags = toolingCppflags
|
||||
default:
|
||||
ctx.ModuleErrorf("File %s has unknown extension", srcFile)
|
||||
continue
|
||||
|
@ -485,7 +503,7 @@ func TransformSourceToObj(ctx android.ModuleContext, subdir string, srcFiles and
|
|||
Implicits: cFlagsDeps,
|
||||
OrderOnly: pathDeps,
|
||||
Args: map[string]string{
|
||||
"cFlags": moduleCflags,
|
||||
"cFlags": moduleFlags,
|
||||
"ccCmd": ccCmd,
|
||||
},
|
||||
})
|
||||
|
@ -500,7 +518,7 @@ func TransformSourceToObj(ctx android.ModuleContext, subdir string, srcFiles and
|
|||
Implicits: cFlagsDeps,
|
||||
OrderOnly: pathDeps,
|
||||
Args: map[string]string{
|
||||
"cFlags": moduleCflags,
|
||||
"cFlags": moduleFlags,
|
||||
},
|
||||
})
|
||||
kytheFiles = append(kytheFiles, kytheFile)
|
||||
|
@ -521,7 +539,7 @@ func TransformSourceToObj(ctx android.ModuleContext, subdir string, srcFiles and
|
|||
Implicits: cFlagsDeps,
|
||||
OrderOnly: pathDeps,
|
||||
Args: map[string]string{
|
||||
"cFlags": moduleToolingCflags,
|
||||
"cFlags": moduleToolingFlags,
|
||||
"tidyFlags": flags.tidyFlags,
|
||||
},
|
||||
})
|
||||
|
@ -540,7 +558,7 @@ func TransformSourceToObj(ctx android.ModuleContext, subdir string, srcFiles and
|
|||
Implicits: cFlagsDeps,
|
||||
OrderOnly: pathDeps,
|
||||
Args: map[string]string{
|
||||
"cFlags": moduleToolingCflags,
|
||||
"cFlags": moduleToolingFlags,
|
||||
"exportDirs": flags.sAbiFlags,
|
||||
},
|
||||
})
|
||||
|
@ -647,7 +665,7 @@ func TransformObjToDynamicBinary(ctx android.ModuleContext,
|
|||
"crtBegin": crtBegin.String(),
|
||||
"libFlags": strings.Join(libFlagsList, " "),
|
||||
"extraLibFlags": flags.extraLibFlags,
|
||||
"ldFlags": flags.ldFlags,
|
||||
"ldFlags": flags.globalLdFlags + " " + flags.localLdFlags,
|
||||
"crtEnd": crtEnd.String(),
|
||||
},
|
||||
})
|
||||
|
@ -784,7 +802,7 @@ func TransformObjsToObj(ctx android.ModuleContext, objFiles android.Paths,
|
|||
Implicits: deps,
|
||||
Args: map[string]string{
|
||||
"ldCmd": ldCmd,
|
||||
"ldFlags": flags.ldFlags,
|
||||
"ldFlags": flags.globalLdFlags + " " + flags.localLdFlags,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
|
|
@ -862,7 +862,7 @@ func (library *libraryDecorator) linkShared(ctx ModuleContext,
|
|||
|
||||
symbolOrderingFile := android.PathForModuleOut(ctx, "unsorted", fileName+".symbol_order")
|
||||
symbolOrderingFlag := library.baseLinker.sortBssSymbolsBySize(ctx, unsortedOutputFile, symbolOrderingFile, builderFlags)
|
||||
builderFlags.ldFlags += " " + symbolOrderingFlag
|
||||
builderFlags.localLdFlags += " " + symbolOrderingFlag
|
||||
linkerDeps = append(linkerDeps, symbolOrderingFile)
|
||||
}
|
||||
|
||||
|
|
28
cc/util.go
28
cc/util.go
|
@ -55,15 +55,25 @@ func moduleToLibName(module string) (string, error) {
|
|||
|
||||
func flagsToBuilderFlags(in Flags) builderFlags {
|
||||
return builderFlags{
|
||||
commonFlags: strings.Join(append(android.CopyOf(in.Global.CommonFlags), in.Local.CommonFlags...), " "),
|
||||
asFlags: strings.Join(append(android.CopyOf(in.Global.AsFlags), in.Local.AsFlags...), " "),
|
||||
yasmFlags: strings.Join(append(android.CopyOf(in.Global.YasmFlags), in.Local.YasmFlags...), " "),
|
||||
cFlags: strings.Join(append(android.CopyOf(in.Global.CFlags), in.Local.CFlags...), " "),
|
||||
toolingCFlags: strings.Join(append(android.CopyOf(in.Global.ToolingCFlags), in.Local.ToolingCFlags...), " "),
|
||||
toolingCppFlags: strings.Join(append(android.CopyOf(in.Global.ToolingCppFlags), in.Local.ToolingCppFlags...), " "),
|
||||
conlyFlags: strings.Join(append(android.CopyOf(in.Global.ConlyFlags), in.Local.ConlyFlags...), " "),
|
||||
cppFlags: strings.Join(append(android.CopyOf(in.Global.CppFlags), in.Local.CppFlags...), " "),
|
||||
ldFlags: strings.Join(append(android.CopyOf(in.Global.LdFlags), in.Local.LdFlags...), " "),
|
||||
globalCommonFlags: strings.Join(in.Global.CommonFlags, " "),
|
||||
globalAsFlags: strings.Join(in.Global.AsFlags, " "),
|
||||
globalYasmFlags: strings.Join(in.Global.YasmFlags, " "),
|
||||
globalCFlags: strings.Join(in.Global.CFlags, " "),
|
||||
globalToolingCFlags: strings.Join(in.Global.ToolingCFlags, " "),
|
||||
globalToolingCppFlags: strings.Join(in.Global.ToolingCppFlags, " "),
|
||||
globalConlyFlags: strings.Join(in.Global.ConlyFlags, " "),
|
||||
globalCppFlags: strings.Join(in.Global.CppFlags, " "),
|
||||
globalLdFlags: strings.Join(in.Global.LdFlags, " "),
|
||||
|
||||
localCommonFlags: strings.Join(in.Local.CommonFlags, " "),
|
||||
localAsFlags: strings.Join(in.Local.AsFlags, " "),
|
||||
localYasmFlags: strings.Join(in.Local.YasmFlags, " "),
|
||||
localCFlags: strings.Join(in.Local.CFlags, " "),
|
||||
localToolingCFlags: strings.Join(in.Local.ToolingCFlags, " "),
|
||||
localToolingCppFlags: strings.Join(in.Local.ToolingCppFlags, " "),
|
||||
localConlyFlags: strings.Join(in.Local.ConlyFlags, " "),
|
||||
localCppFlags: strings.Join(in.Local.CppFlags, " "),
|
||||
localLdFlags: strings.Join(in.Local.LdFlags, " "),
|
||||
|
||||
aidlFlags: strings.Join(in.aidlFlags, " "),
|
||||
rsFlags: strings.Join(in.rsFlags, " "),
|
||||
|
|
Loading…
Reference in a new issue