cc: Filter out unknown clang cflags from InstructionSetFlags

-funswitch-loops is in the arm instruction set flags, but unsupported by
clang. Make removes clang unknown cflags from the instruction set flags.
This was producing a warning, causing -Werror to fail on libm.

Change-Id: Ibc69c9af04a738aa8adeb5549900e2b53ab754f0
This commit is contained in:
Dan Willemsen 2015-11-03 14:27:00 -08:00
parent 6d27f3428e
commit 6d11dd87c0
3 changed files with 35 additions and 9 deletions

View File

@ -172,6 +172,10 @@ func init() {
pctx.StaticVariable("armClangLdflags", strings.Join(clangFilterUnknownCflags(armLdflags), " "))
pctx.StaticVariable("armClangCppflags", strings.Join(clangFilterUnknownCflags(armCppflags), " "))
// Clang ARM vs. Thumb instruction set cflags
pctx.StaticVariable("armClangArmCflags", strings.Join(clangFilterUnknownCflags(armArmCflags), " "))
pctx.StaticVariable("armClangThumbCflags", strings.Join(clangFilterUnknownCflags(armThumbCflags), " "))
// Clang cpu variant cflags
pctx.StaticVariable("armClangArmv5TECflags",
strings.Join(armClangArchVariantCflags["armv5te"], " "))
@ -291,6 +295,17 @@ func (t *toolchainArm) ClangLdflags() string {
return t.ldflags
}
func (t *toolchainArm) ClangInstructionSetFlags(isa string) (string, error) {
switch isa {
case "arm":
return "${armClangArmCflags}", nil
case "thumb", "":
return "${armClangThumbCflags}", nil
default:
return t.toolchainBase.ClangInstructionSetFlags(isa)
}
}
func armToolchainFactory(archVariant string, cpuVariant string) Toolchain {
var fixCortexA8 string
switch cpuVariant {

View File

@ -488,15 +488,6 @@ func (c *CCBase) collectFlags(ctx common.AndroidModuleContext, toolchain Toolcha
}...)
}
instructionSet := c.Properties.Instruction_set
instructionSetFlags, err := toolchain.InstructionSetFlags(instructionSet)
if err != nil {
ctx.ModuleErrorf("%s", err)
}
// TODO: debug
flags.CFlags = append(flags.CFlags, c.Properties.Release.Cflags...)
if !ctx.ContainsProperty("clang") {
if ctx.Host() {
flags.Clang = true
@ -507,6 +498,18 @@ func (c *CCBase) collectFlags(ctx common.AndroidModuleContext, toolchain Toolcha
}
}
instructionSet := c.Properties.Instruction_set
instructionSetFlags, err := toolchain.InstructionSetFlags(instructionSet)
if flags.Clang {
instructionSetFlags, err = toolchain.ClangInstructionSetFlags(instructionSet)
}
if err != nil {
ctx.ModuleErrorf("%s", err)
}
// TODO: debug
flags.CFlags = append(flags.CFlags, c.Properties.Release.Cflags...)
if flags.Clang {
flags.CFlags = clangFilterUnknownCflags(flags.CFlags)
flags.CFlags = append(flags.CFlags, c.Properties.Clang_cflags...)

View File

@ -49,6 +49,7 @@ type Toolchain interface {
ClangCflags() string
ClangCppflags() string
ClangLdflags() string
ClangInstructionSetFlags(string) (string, error)
Is64Bit() bool
}
@ -63,6 +64,13 @@ func (toolchainBase) InstructionSetFlags(s string) (string, error) {
return "", nil
}
func (toolchainBase) ClangInstructionSetFlags(s string) (string, error) {
if s != "" {
return "", fmt.Errorf("instruction_set: %s is not a supported instruction set", s)
}
return "", nil
}
type toolchain64Bit struct {
toolchainBase
}