From 0906f17f7e8bf0e76cb8511669e8fc8d5f6f3794 Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Wed, 26 Apr 2017 14:00:43 -0700 Subject: [PATCH 1/6] Add arm neon and mips dspr2 arch features Current modules must use armv7_a_neon to specify source files that compile only with neon. If a future arch variant also supports neon, all these modules will fall back to non-neon. Support a neon arch feature that modules can use instead. Similarly, support dspr2 for mips. arm_device.go was also mixing armv7-a-neon with armv7_a_neon. Use armv7-a-neon consistently, and fix the - to _ when creating the property structs. Test: m -j checkbuild Change-Id: I24d3764280ab3bcbb9a73c0934edc9b99fc7f6a0 --- android/arch.go | 2 ++ cc/config/arm_device.go | 21 +++++++++++++-------- cc/config/mips_device.go | 6 +++++- 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/android/arch.go b/android/arch.go index 2d0515ffa..e777475f7 100644 --- a/android/arch.go +++ b/android/arch.go @@ -417,9 +417,11 @@ func createArchType(props reflect.Type) reflect.Type { variants := []string{} for _, archVariant := range archVariants[arch] { + archVariant := variantReplacer.Replace(archVariant) variants = append(variants, proptools.FieldNameForProperty(archVariant)) } for _, feature := range archFeatures[arch] { + feature := variantReplacer.Replace(feature) variants = append(variants, proptools.FieldNameForProperty(feature)) } diff --git a/cc/config/arm_device.go b/cc/config/arm_device.go index 5d17d15c1..94627e7dc 100644 --- a/cc/config/arm_device.go +++ b/cc/config/arm_device.go @@ -156,20 +156,25 @@ const ( ) func init() { + android.RegisterArchFeatures(android.Arm, + "neon") + android.RegisterArchVariants(android.Arm, "armv5te", - "armv7_a", - "armv7_a_neon", - "cortex_a7", - "cortex_a8", - "cortex_a9", - "cortex_a15", - "cortex_a53", - "cortex_a53_a57", + "armv7-a", + "armv7-a-neon", + "cortex-a7", + "cortex-a8", + "cortex-a9", + "cortex-a15", + "cortex-a53", + "cortex-a53-a57", "krait", "kryo", "denver") + android.RegisterArchVariantFeatures(android.Arm, "armv7-a-neon", "neon") + // Krait and Kryo targets are not supported by GCC, but are supported by Clang, // so override the definitions when building modules with Clang. replaceFirst(armClangCpuVariantCflags["krait"], "-mcpu=cortex-a15", "-mcpu=krait") diff --git a/cc/config/mips_device.go b/cc/config/mips_device.go index ccd60d618..42025a2fa 100644 --- a/cc/config/mips_device.go +++ b/cc/config/mips_device.go @@ -133,7 +133,11 @@ func init() { "mips32r2dsp_fp", "mips32r2dspr2_fp", "mips32r6") - android.RegisterArchFeatures(android.Mips, "rev6") + android.RegisterArchFeatures(android.Mips, + "dspr2", + "rev6") + android.RegisterArchVariantFeatures(android.Mips, "mips32r2dspr2_fp", + "dspr2") android.RegisterArchVariantFeatures(android.Mips, "mips32r6", "rev6") From dad8c954b20071e51e9d47117b2724ab71205fe3 Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Wed, 26 Apr 2017 14:55:27 -0700 Subject: [PATCH 2/6] Pass -I to yasm external/libvpx needs -I flags to be propagated to yasm, but can't handle all the other global flags (like -no-exceptions). Add -I arguments to YasmFlags as well as GlobalFlags. Test: mega-device build of external/libvpx Change-Id: I1607211c34b031fae8ffc1bd558b26019965a696 --- cc/compiler.go | 9 +++++++-- cc/library.go | 4 +++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/cc/compiler.go b/cc/compiler.go index aed4480e0..a122bbd91 100644 --- a/cc/compiler.go +++ b/cc/compiler.go @@ -198,15 +198,20 @@ func (compiler *baseCompiler) compilerFlags(ctx ModuleContext, flags Flags) Flag // Include dir cflags localIncludeDirs := android.PathsForModuleSrc(ctx, compiler.Properties.Local_include_dirs) if len(localIncludeDirs) > 0 { - flags.GlobalFlags = append(flags.GlobalFlags, includeDirsToFlags(localIncludeDirs)) + f := includeDirsToFlags(localIncludeDirs) + flags.GlobalFlags = append(flags.GlobalFlags, f) + flags.YasmFlags = append(flags.YasmFlags, f) } rootIncludeDirs := android.PathsForSource(ctx, compiler.Properties.Include_dirs) if len(rootIncludeDirs) > 0 { - flags.GlobalFlags = append(flags.GlobalFlags, includeDirsToFlags(rootIncludeDirs)) + f := includeDirsToFlags(rootIncludeDirs) + flags.GlobalFlags = append(flags.GlobalFlags, f) + flags.YasmFlags = append(flags.YasmFlags, f) } if !ctx.noDefaultCompilerFlags() { flags.GlobalFlags = append(flags.GlobalFlags, "-I"+android.PathForModuleSrc(ctx).String()) + flags.YasmFlags = append(flags.YasmFlags, "-I"+android.PathForModuleSrc(ctx).String()) if !(ctx.sdk() || ctx.vndk()) || ctx.Host() { flags.SystemIncludeFlags = append(flags.SystemIncludeFlags, diff --git a/cc/library.go b/cc/library.go index e2ec58492..86e326986 100644 --- a/cc/library.go +++ b/cc/library.go @@ -306,7 +306,9 @@ func (library *libraryDecorator) linkerFlags(ctx ModuleContext, flags Flags) Fla func (library *libraryDecorator) compilerFlags(ctx ModuleContext, flags Flags) Flags { exportIncludeDirs := library.flagExporter.exportedIncludes(ctx) if len(exportIncludeDirs) > 0 { - flags.GlobalFlags = append(flags.GlobalFlags, includeDirsToFlags(exportIncludeDirs)) + f := includeDirsToFlags(exportIncludeDirs) + flags.GlobalFlags = append(flags.GlobalFlags, f) + flags.YasmFlags = append(flags.YasmFlags, f) } return library.baseCompiler.compilerFlags(ctx, flags) From e90bfd157b5b6cd27fcd9f6cf444229d8be0e24c Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Wed, 26 Apr 2017 16:59:26 -0700 Subject: [PATCH 3/6] Make generated_sources act like generated_headers Make generated_sources dependencies honor the exported include directories. Test: m -j checkbuild Change-Id: I6955cf5d985053071c2118f43fa1accdb4cc27ab --- cc/cc.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cc/cc.go b/cc/cc.go index 6e2f6a503..bbdcf6f96 100644 --- a/cc/cc.go +++ b/cc/cc.go @@ -907,6 +907,8 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps { } else { ctx.ModuleErrorf("module %q is not a gensrcs or genrule", name) } + // Support exported headers from a generated_sources dependency + fallthrough case genHeaderDepTag, genHeaderExportDepTag: if genRule, ok := m.(genrule.SourceFileGenerator); ok { depPaths.GeneratedHeaders = append(depPaths.GeneratedHeaders, From ccf01e755eb14b0caab40a58013edf672fde3ab6 Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Wed, 26 Apr 2017 17:01:07 -0700 Subject: [PATCH 4/6] Prepend arch variant include directories Arch variant include directories should override existing include directories, add prepend_variant to the struct tags. Test: m -j checkbuild Change-Id: I4a758b42c19481f9496880d29dffea7836f613c5 --- cc/compiler.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cc/compiler.go b/cc/compiler.go index a122bbd91..eb30767a0 100644 --- a/cc/compiler.go +++ b/cc/compiler.go @@ -69,11 +69,11 @@ type BaseCompilerProperties struct { // If possible, don't use this. If adding paths from the current directory use // local_include_dirs, if adding paths from other modules use export_include_dirs in // that module. - Include_dirs []string `android:"arch_variant"` + Include_dirs []string `android:"arch_variant,variant_prepend"` // list of directories relative to the Blueprints file that will // be added to the include path using -I - Local_include_dirs []string `android:"arch_variant"` + Local_include_dirs []string `android:"arch_variant,variant_prepend",` // list of generated sources to compile. These are the names of gensrcs or // genrule modules. From 893d816a6d808264c2c490229832ce5b9ca7896d Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Wed, 26 Apr 2017 17:34:03 -0700 Subject: [PATCH 5/6] Turn installation on in mega device build Turn on installation in the mega device build, it is necessary for the ndk sysroot installation. Partially fixes mega device builds, they also need to run without -w dupbuild=err on the ninja command line because multiple variants of the same architecture try to install to the same ndk sysroot. Test: mega device build Change-Id: I982d77f9ff19f5bc29fc9fe54a0df8db3579c3e3 --- android/config.go | 7 ++++++- android/module.go | 24 ++++++++++++++++++++---- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/android/config.go b/android/config.go index 8efa642c2..8be16cfde 100644 --- a/android/config.go +++ b/android/config.go @@ -390,7 +390,12 @@ func (c *config) DevicePrefer32BitExecutables() bool { } func (c *config) SkipDeviceInstall() bool { - return c.EmbeddedInMake() || Bool(c.Mega_device) + return c.EmbeddedInMake() +} + +func (c *config) SkipMegaDeviceInstall(path string) bool { + return Bool(c.Mega_device) && + strings.HasPrefix(path, filepath.Join(c.buildDir, "target", "product")) } func (c *config) SanitizeHost() []string { diff --git a/android/module.go b/android/module.go index d485fbc20..a38c6177c 100644 --- a/android/module.go +++ b/android/module.go @@ -647,14 +647,31 @@ func (a *androidModuleContext) InstallInSanitizerDir() bool { return a.module.InstallInSanitizerDir() } +func (a *androidModuleContext) skipInstall(fullInstallPath OutputPath) bool { + if a.module.base().commonProperties.SkipInstall { + return true + } + + if a.Device() { + if a.AConfig().SkipDeviceInstall() { + return true + } + + if a.AConfig().SkipMegaDeviceInstall(fullInstallPath.String()) { + return true + } + } + + return false +} + func (a *androidModuleContext) InstallFileName(installPath OutputPath, name string, srcPath Path, deps ...Path) OutputPath { fullInstallPath := installPath.Join(a, name) a.module.base().hooks.runInstallHooks(a, fullInstallPath, false) - if !a.module.base().commonProperties.SkipInstall && - (!a.Device() || !a.AConfig().SkipDeviceInstall()) { + if !a.skipInstall(fullInstallPath) { deps = append(deps, a.installDeps...) @@ -691,8 +708,7 @@ func (a *androidModuleContext) InstallSymlink(installPath OutputPath, name strin fullInstallPath := installPath.Join(a, name) a.module.base().hooks.runInstallHooks(a, fullInstallPath, true) - if !a.module.base().commonProperties.SkipInstall && - (!a.Device() || !a.AConfig().SkipDeviceInstall()) { + if !a.skipInstall(fullInstallPath) { a.ModuleBuild(pctx, ModuleBuildParams{ Rule: Symlink, From 1837b802e17e08a3a5cd0fdaa96c6577f71d3692 Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Wed, 26 Apr 2017 19:10:34 -0700 Subject: [PATCH 6/6] Enable mips32r2dsp[r2]-fp in mega device build These seem to build now. Test: mega device build Change-Id: If2514258b0c57d6db484aed4c17a3e1f62109429 --- android/arch.go | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/android/arch.go b/android/arch.go index e777475f7..e21a07053 100644 --- a/android/arch.go +++ b/android/arch.go @@ -878,12 +878,8 @@ func getMegaDeviceConfig() []archConfig { {"mips", "mips32r2-fp", "", []string{"mips"}}, {"mips", "mips32r2-fp-xburst", "", []string{"mips"}}, //{"mips", "mips32r6", "", []string{"mips"}}, - // mips32r2dsp[r2]-fp fails in the assembler for divdf3.c in compiler-rt: - // (same errors in make and soong) - // Error: invalid operands `mtlo $ac0,$11' - // Error: invalid operands `mthi $ac0,$12' - //{"mips", "mips32r2dsp-fp", "", []string{"mips"}}, - //{"mips", "mips32r2dspr2-fp", "", []string{"mips"}}, + {"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"}},