Merge changes I92ddea0b,Ice8474ae,If63cc6ce,I1d6f1388,Ic3da07c8, ...

* changes:
  Add Mega_device configuration option
  Toolchain modules use GCC
  Apply ToolchainLdflags to clang builds
  Add Clang Asflags for mips
  Remove libgcov for now to fix X86 devices
  Change clang extra flags behavior
This commit is contained in:
Dan Willemsen
2016-01-14 07:03:10 +00:00
committed by Gerrit Code Review
7 changed files with 110 additions and 24 deletions

View File

@@ -115,13 +115,13 @@ func init() {
pctx.StaticVariable("commonGlobalCppflags", strings.Join(commonGlobalCppflags, " "))
pctx.StaticVariable("commonClangGlobalCflags",
strings.Join(clangFilterUnknownCflags(commonGlobalCflags), " "))
strings.Join(append(clangFilterUnknownCflags(commonGlobalCflags), "${clangExtraCflags}"), " "))
pctx.StaticVariable("deviceClangGlobalCflags",
strings.Join(clangFilterUnknownCflags(deviceGlobalCflags), " "))
strings.Join(append(clangFilterUnknownCflags(deviceGlobalCflags), "${clangExtraTargetCflags}"), " "))
pctx.StaticVariable("hostClangGlobalCflags",
strings.Join(clangFilterUnknownCflags(hostGlobalCflags), " "))
pctx.StaticVariable("commonClangGlobalCppflags",
strings.Join(clangFilterUnknownCflags(commonGlobalCppflags), " "))
strings.Join(append(clangFilterUnknownCflags(commonGlobalCppflags), "${clangExtraCppflags}"), " "))
// Everything in this list is a crime against abstraction and dependency tracking.
// Do not add anything to this list.
@@ -550,12 +550,6 @@ func (c *CCBase) collectFlags(ctx common.AndroidModuleContext, toolchain Toolcha
flags.ConlyFlags = clangFilterUnknownCflags(flags.ConlyFlags)
flags.LdFlags = clangFilterUnknownCflags(flags.LdFlags)
flags.CFlags = append(flags.CFlags, "${clangExtraCflags}")
flags.ConlyFlags = append(flags.ConlyFlags, "${clangExtraConlyflags}")
if ctx.Device() {
flags.CFlags = append(flags.CFlags, "${clangExtraTargetCflags}")
}
target := "-target " + toolchain.ClangTriple()
gccPrefix := "-B" + filepath.Join(toolchain.GccRoot(), toolchain.GccTriple(), "bin")
@@ -572,11 +566,14 @@ func (c *CCBase) collectFlags(ctx common.AndroidModuleContext, toolchain Toolcha
flags.GlobalFlags = append(flags.GlobalFlags, instructionSetFlags)
if flags.Clang {
flags.AsFlags = append(flags.AsFlags, toolchain.ClangAsflags())
flags.CppFlags = append(flags.CppFlags, "${commonClangGlobalCppflags}")
flags.GlobalFlags = append(flags.GlobalFlags,
toolchain.ClangCflags(),
"${commonClangGlobalCflags}",
fmt.Sprintf("${%sClangGlobalCflags}", ctx.HostOrDevice()))
flags.ConlyFlags = append(flags.ConlyFlags, "${clangExtraConlyflags}")
} else {
flags.CppFlags = append(flags.CppFlags, "${commonGlobalCppflags}")
flags.GlobalFlags = append(flags.GlobalFlags,
@@ -616,8 +613,8 @@ func (c *CCBase) collectFlags(ctx common.AndroidModuleContext, toolchain Toolcha
flags.GlobalFlags = append(flags.GlobalFlags, toolchain.ToolchainClangCflags())
} else {
flags.GlobalFlags = append(flags.GlobalFlags, toolchain.ToolchainCflags())
flags.LdFlags = append(flags.LdFlags, toolchain.ToolchainLdflags())
}
flags.LdFlags = append(flags.LdFlags, toolchain.ToolchainLdflags())
flags = c.ccModuleType().flags(ctx, flags)
@@ -1008,7 +1005,7 @@ func (c *CCLinked) depNames(ctx common.AndroidBaseContext, depNames CCDeps) CCDe
if ctx.Device() {
// libgcc and libatomic have to be last on the command line
depNames.LateStaticLibs = append(depNames.LateStaticLibs, "libgcov", "libatomic")
depNames.LateStaticLibs = append(depNames.LateStaticLibs, "libatomic")
if !Bool(c.Properties.No_libgcc) {
depNames.LateStaticLibs = append(depNames.LateStaticLibs, "libgcc")
}
@@ -1885,6 +1882,7 @@ func ToolchainLibraryFactory() (blueprint.Module, []interface{}) {
module := &toolchainLibrary{}
module.LibraryProperties.BuildStatic = true
module.Properties.Clang = proptools.BoolPtr(false)
return newCCBase(&module.CCBase, module, common.DeviceSupported, common.MultilibBoth,
&module.LibraryProperties)
@@ -1896,6 +1894,10 @@ func (c *toolchainLibrary) compileModule(ctx common.AndroidModuleContext,
libName := ctx.ModuleName() + staticLibraryExtension
outputFile := common.PathForModuleOut(ctx, libName)
if flags.Clang {
ctx.ModuleErrorf("toolchain_library must use GCC, not Clang")
}
CopyGccLib(ctx, libName, ccFlagsToBuilderFlags(flags), outputFile)
c.out = outputFile

View File

@@ -84,10 +84,6 @@ func init() {
// See http://petereisentraut.blogspot.com/2011/05/ccache-and-clang.html.
"-Wno-unused-command-line-argument",
// Disable -Winconsistent-missing-override until we can clean up the existing
// codebase for it.
"-Wno-inconsistent-missing-override",
// Force clang to always output color diagnostics. Ninja will strip the ANSI
// color codes if it is not running in a terminal.
"-fcolor-diagnostics",
@@ -97,6 +93,12 @@ func init() {
"-std=gnu99",
}, " "))
pctx.StaticVariable("clangExtraCppflags", strings.Join([]string{
// Disable -Winconsistent-missing-override until we can clean up the existing
// codebase for it.
"-Wno-inconsistent-missing-override",
}, " "))
pctx.StaticVariable("clangExtraTargetCflags", strings.Join([]string{
"-nostdlibinc",
}, " "))

View File

@@ -211,6 +211,10 @@ func (t *toolchainMips) ToolchainClangCflags() string {
return t.toolchainClangCflags
}
func (t *toolchainMips) ClangAsflags() string {
return "-fPIC"
}
func (t *toolchainMips) ClangCflags() string {
return t.clangCflags
}

View File

@@ -60,6 +60,7 @@ type Toolchain interface {
ClangSupported() bool
ClangTriple() string
ToolchainClangCflags() string
ClangAsflags() string
ClangCflags() string
ClangCppflags() string
ClangLdflags() string
@@ -112,6 +113,10 @@ func (toolchainBase) ExecutableSuffix() string {
return ""
}
func (toolchainBase) ClangAsflags() string {
return ""
}
type toolchain64Bit struct {
toolchainBase
}

View File

@@ -901,6 +901,65 @@ func decodeArchProductVariables(variables productVariables) (map[HostType][]Arch
return hostTypeArches, deviceArches, nil
}
func decodeMegaDevice() ([]Arch, error) {
archSettings := []struct {
arch string
archVariant string
cpuVariant string
abi []string
}{
{"arm", "armv7-a-neon", "cortex-a7", []string{"armeabi-v7a"}},
{"arm", "armv7-a-neon", "cortex-a8", []string{"armeabi-v7a"}},
// gtest_all_test.cc fails to build:
// error in backend: Unsupported library call operation!
//{"arm", "armv7-a-neon", "cortex-a9", []string{"armeabi-v7a"}},
{"arm", "armv7-a-neon", "cortex-a15", []string{"armeabi-v7a"}},
{"arm", "armv7-a-neon", "cortex-a53", []string{"armeabi-v7a"}},
{"arm", "armv7-a-neon", "cortex-a53.a57", []string{"armeabi-v7a"}},
{"arm", "armv7-a-neon", "denver", []string{"armeabi-v7a"}},
{"arm", "armv7-a-neon", "krait", []string{"armeabi-v7a"}},
{"arm64", "", "cortex-a53", []string{"arm64-v8a"}},
{"arm64", "", "denver64", []string{"arm64-v8a"}},
// mips is missing __popcountsi2 from libc
//{"mips", "mips32-fp", "", []string{"mips"}},
//{"mips", "mips32r2-fp", "", []string{"mips"}},
//{"mips", "mips32r2-fp-xburst", "", []string{"mips"}},
//{"mips", "mips32r6", "", []string{"mips32r6"}},
// mips32r2dsp[r2]-fp also fails in the assembler for dmisc.c in libc:
// Error: invalid operands `mtlo $ac0,$8'
// Error: invalid operands `mthi $ac0,$3'
//{"mips", "mips32r2dsp-fp", "", []string{"mips"}},
//{"mips", "mips32r2dspr2-fp", "", []string{"mips"}},
// mips64r2 is mismatching 64r2 and 64r6 libraries during linking to libgcc
//{"mips64", "mips64r2", "", []string{"mips64"}},
{"mips64", "mips64r6", "", []string{"mips64"}},
{"x86", "", "", []string{"x86"}},
{"x86", "atom", "", []string{"x86"}},
{"x86", "haswell", "", []string{"x86"}},
{"x86", "ivybridge", "", []string{"x86"}},
{"x86", "sandybridge", "", []string{"x86"}},
{"x86", "silvermont", "", []string{"x86"}},
{"x86_64", "", "", []string{"x86_64"}},
{"x86_64", "haswell", "", []string{"x86_64"}},
{"x86_64", "ivybridge", "", []string{"x86_64"}},
{"x86_64", "sandybridge", "", []string{"x86_64"}},
{"x86_64", "silvermont", "", []string{"x86_64"}},
}
var ret []Arch
for _, config := range archSettings {
arch, err := decodeArch(config.arch, &config.archVariant,
&config.cpuVariant, &config.abi)
if err != nil {
return nil, err
}
ret = append(ret, arch)
}
return ret, nil
}
// Convert a set of strings from product variables into a single Arch struct
func decodeArch(arch string, archVariant, cpuVariant *string, abi *[]string) (Arch, error) {
stringPtr := func(p *string) string {

View File

@@ -35,6 +35,7 @@ const productVariablesFileName = "soong.variables"
// A FileConfigurableOptions contains options which can be configured by the
// config file. These will be included in the config struct.
type FileConfigurableOptions struct {
Mega_device *bool `json:",omitempty"`
}
func (f *FileConfigurableOptions) SetDefaultConfig() {
@@ -179,6 +180,13 @@ func NewConfig(srcDir, buildDir string) (Config, error) {
return Config{}, err
}
if Bool(config.Mega_device) {
deviceArches, err = decodeMegaDevice()
if err != nil {
return Config{}, err
}
}
config.HostArches = hostArches
config.DeviceArches = deviceArches
@@ -295,3 +303,7 @@ func (c *config) DefaultAppCertificate(ctx PathContext) SourcePath {
func (c *config) AllowMissingDependencies() bool {
return Bool(c.ProductVariables.Unbundled_build)
}
func (c *config) SkipInstall() bool {
return c.EmbeddedInMake() || Bool(c.Mega_device)
}

View File

@@ -519,17 +519,19 @@ func (a *androidModuleContext) InstallFileName(installPath OutputPath, name stri
fullInstallPath := installPath.Join(a, name)
deps = append(deps, a.installDeps...)
if !a.AConfig().SkipInstall() {
deps = append(deps, a.installDeps...)
a.ModuleBuild(pctx, ModuleBuildParams{
Rule: Cp,
Output: fullInstallPath,
Input: srcPath,
OrderOnly: Paths(deps),
Default: !a.AConfig().EmbeddedInMake(),
})
a.ModuleBuild(pctx, ModuleBuildParams{
Rule: Cp,
Output: fullInstallPath,
Input: srcPath,
OrderOnly: Paths(deps),
Default: true,
})
a.installFiles = append(a.installFiles, fullInstallPath)
a.installFiles = append(a.installFiles, fullInstallPath)
}
a.checkbuildFiles = append(a.checkbuildFiles, srcPath)
return fullInstallPath
}