Configure the default arch variant features per-OS am: 01a3c25ed7 am: ea53a95e10

am: fc9dff9965

Change-Id: Ice73a2b174b25f0d197621f08bcd2994575c6feb
This commit is contained in:
Dan Willemsen 2019-01-14 17:29:06 -08:00 committed by android-build-merger
commit 1b12302bf4
3 changed files with 31 additions and 9 deletions

View File

@ -106,6 +106,7 @@ module {
var archVariants = map[ArchType][]string{}
var archFeatures = map[ArchType][]string{}
var archFeatureMap = map[ArchType]map[string][]string{}
var defaultArchFeatureMap = map[OsType]map[ArchType][]string{}
func RegisterArchVariants(arch ArchType, variants ...string) {
checkCalledFromInit()
@ -117,9 +118,24 @@ func RegisterArchFeatures(arch ArchType, features ...string) {
archFeatures[arch] = append(archFeatures[arch], features...)
}
func RegisterDefaultArchVariantFeatures(os OsType, arch ArchType, features ...string) {
checkCalledFromInit()
for _, feature := range features {
if !InList(feature, archFeatures[arch]) {
panic(fmt.Errorf("Invalid feature %q for arch %q variant \"\"", feature, arch))
}
}
if defaultArchFeatureMap[os] == nil {
defaultArchFeatureMap[os] = make(map[ArchType][]string)
}
defaultArchFeatureMap[os][arch] = features
}
func RegisterArchVariantFeatures(arch ArchType, variant string, features ...string) {
checkCalledFromInit()
if variant != "" && !InList(variant, archVariants[arch]) {
if !InList(variant, archVariants[arch]) {
panic(fmt.Errorf("Invalid variant %q for arch %q", variant, arch))
}
@ -952,7 +968,7 @@ func decodeTargetProductVariables(config *config) (map[OsType][]Target, error) {
return
}
arch, err := decodeArch(archName, archVariant, cpuVariant, abi)
arch, err := decodeArch(os, archName, archVariant, cpuVariant, abi)
if err != nil {
targetErr = err
return
@ -1127,11 +1143,11 @@ func getNdkAbisConfig() []archConfig {
}
}
func decodeArchSettings(archConfigs []archConfig) ([]Target, error) {
func decodeArchSettings(os OsType, archConfigs []archConfig) ([]Target, error) {
var ret []Target
for _, config := range archConfigs {
arch, err := decodeArch(config.arch, &config.archVariant,
arch, err := decodeArch(os, config.arch, &config.archVariant,
&config.cpuVariant, &config.abi)
if err != nil {
return nil, err
@ -1147,7 +1163,7 @@ func decodeArchSettings(archConfigs []archConfig) ([]Target, error) {
}
// Convert a set of strings from product variables into a single Arch struct
func decodeArch(arch string, archVariant, cpuVariant *string, abi *[]string) (Arch, error) {
func decodeArch(os OsType, arch string, archVariant, cpuVariant *string, abi *[]string) (Arch, error) {
stringPtr := func(p *string) string {
if p != nil {
return *p
@ -1190,8 +1206,14 @@ func decodeArch(arch string, archVariant, cpuVariant *string, abi *[]string) (Ar
}
}
if featureMap, ok := archFeatureMap[archType]; ok {
a.ArchFeatures = featureMap[a.ArchVariant]
if a.ArchVariant == "" {
if featureMap, ok := defaultArchFeatureMap[os]; ok {
a.ArchFeatures = featureMap[archType]
}
} else {
if featureMap, ok := archFeatureMap[archType]; ok {
a.ArchFeatures = featureMap[a.ArchVariant]
}
}
return a, nil

View File

@ -303,7 +303,7 @@ func NewConfig(srcDir, buildDir string) (Config, error) {
}
if archConfig != nil {
androidTargets, err := decodeArchSettings(archConfig)
androidTargets, err := decodeArchSettings(Android, archConfig)
if err != nil {
return Config{}, err
}

View File

@ -81,7 +81,7 @@ func init() {
"aes_ni",
"avx",
"popcnt")
android.RegisterArchVariantFeatures(android.X86_64, "",
android.RegisterDefaultArchVariantFeatures(android.Android, android.X86_64,
"ssse3",
"sse4",
"sse4_1",