diff options
author | Dan Willemsen <dwillemsen@google.com> | 2019-01-11 19:02:16 -0800 |
---|---|---|
committer | Ryan Haining <haining@google.com> | 2019-01-30 19:34:34 -0800 |
commit | 2cee4e322d18c85d6a8a2a037fdc8b512fc6b79f (patch) | |
tree | 9d068cc24c0f964d1e2a04e1bdecad2582ca1a5b | |
parent | 25ce2ab6bf2b41dd300236b01c47206f12006b75 (diff) | |
download | soong-pie-cuttlefish-testing.tar.gz |
Configure the default arch variant features per-OSpie-cuttlefish-testing
The minimum set of supported features are different between Android and
Linux with X86_64. So while the list of variants and features are still
technically correct, and may be shared more in the future, the default
needs to be configured differently.
Bug: 120208462
Test: add `host_supported: true` to libopus; m libopus
Change-Id: Ib79707d17b852f77341026085230c026b6386b78
-rw-r--r-- | android/arch.go | 36 | ||||
-rw-r--r-- | android/config.go | 2 | ||||
-rw-r--r-- | cc/config/x86_64_device.go | 2 |
3 files changed, 31 insertions, 9 deletions
diff --git a/android/arch.go b/android/arch.go index 88f9f6595..c853bdc82 100644 --- a/android/arch.go +++ b/android/arch.go @@ -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)) } @@ -831,7 +847,7 @@ func decodeTargetProductVariables(config *config) (map[OsClass][]Target, error) return } - arch, err := decodeArch(archName, archVariant, cpuVariant, abi) + arch, err := decodeArch(os, archName, archVariant, cpuVariant, abi) if err != nil { targetErr = err return @@ -1002,11 +1018,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 @@ -1022,7 +1038,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 @@ -1065,8 +1081,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 diff --git a/android/config.go b/android/config.go index fafed6b0a..d4b8c72e4 100644 --- a/android/config.go +++ b/android/config.go @@ -302,7 +302,7 @@ func NewConfig(srcDir, buildDir string) (Config, error) { } if archConfig != nil { - deviceTargets, err := decodeArchSettings(archConfig) + deviceTargets, err := decodeArchSettings(Android, archConfig) if err != nil { return Config{}, err } diff --git a/cc/config/x86_64_device.go b/cc/config/x86_64_device.go index 12f3e6fa2..700048bcc 100644 --- a/cc/config/x86_64_device.go +++ b/cc/config/x86_64_device.go @@ -79,7 +79,7 @@ func init() { "aes_ni", "avx", "popcnt") - android.RegisterArchVariantFeatures(android.X86_64, "", + android.RegisterDefaultArchVariantFeatures(android.Android, android.X86_64, "ssse3", "sse4", "sse4_1", |