github.com/westcoastroms/westcoastroms-build@v0.0.0-20190928114312-2350e5a73030/build/soong/cc/config/x86_device.go (about) 1 // Copyright 2015 Google Inc. All rights reserved. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package config 16 17 import ( 18 "strings" 19 20 "android/soong/android" 21 ) 22 23 var ( 24 x86Cflags = []string{} 25 26 x86ClangCflags = append(x86Cflags, []string{ 27 "-msse3", 28 29 // -mstackrealign is needed to realign stack in native code 30 // that could be called from JNI, so that movaps instruction 31 // will work on assumed stack aligned local variables. 32 "-mstackrealign", 33 }...) 34 35 x86Cppflags = []string{} 36 37 x86Ldflags = []string{ 38 "-Wl,--hash-style=gnu", 39 } 40 41 x86ArchVariantCflags = map[string][]string{ 42 "": []string{ 43 "-march=prescott", 44 }, 45 "x86_64": []string{ 46 "-march=prescott", 47 }, 48 "atom": []string{ 49 "-march=atom", 50 "-mfpmath=sse", 51 }, 52 "haswell": []string{ 53 "-march=core-avx2", 54 "-mfpmath=sse", 55 }, 56 "ivybridge": []string{ 57 "-march=core-avx-i", 58 "-mfpmath=sse", 59 }, 60 "sandybridge": []string{ 61 "-march=corei7", 62 "-mfpmath=sse", 63 }, 64 "silvermont": []string{ 65 "-march=slm", 66 "-mfpmath=sse", 67 }, 68 } 69 70 x86ArchFeatureCflags = map[string][]string{ 71 "ssse3": []string{"-DUSE_SSSE3", "-mssse3"}, 72 "sse4": []string{"-msse4"}, 73 "sse4_1": []string{"-msse4.1"}, 74 "sse4_2": []string{"-msse4.2"}, 75 "avx": []string{"-mavx"}, 76 "aes_ni": []string{"-maes"}, 77 } 78 ) 79 80 const ( 81 x86GccVersion = "4.9" 82 ) 83 84 func init() { 85 android.RegisterArchVariants(android.X86, 86 "atom", 87 "haswell", 88 "ivybridge", 89 "sandybridge", 90 "silvermont", 91 "x86_64") 92 android.RegisterArchFeatures(android.X86, 93 "ssse3", 94 "sse4", 95 "sse4_1", 96 "sse4_2", 97 "aes_ni", 98 "avx", 99 "popcnt", 100 "movbe") 101 android.RegisterArchVariantFeatures(android.X86, "x86_64", 102 "ssse3", 103 "sse4", 104 "sse4_1", 105 "sse4_2", 106 "popcnt") 107 android.RegisterArchVariantFeatures(android.X86, "atom", 108 "ssse3", 109 "movbe") 110 android.RegisterArchVariantFeatures(android.X86, "haswell", 111 "ssse3", 112 "sse4", 113 "sse4_1", 114 "sse4_2", 115 "aes_ni", 116 "avx", 117 "popcnt", 118 "movbe") 119 android.RegisterArchVariantFeatures(android.X86, "ivybridge", 120 "ssse3", 121 "sse4", 122 "sse4_1", 123 "sse4_2", 124 "aes_ni", 125 "avx", 126 "popcnt") 127 android.RegisterArchVariantFeatures(android.X86, "sandybridge", 128 "ssse3", 129 "sse4", 130 "sse4_1", 131 "sse4_2", 132 "popcnt") 133 android.RegisterArchVariantFeatures(android.X86, "silvermont", 134 "ssse3", 135 "sse4", 136 "sse4_1", 137 "sse4_2", 138 "aes_ni", 139 "popcnt", 140 "movbe") 141 142 pctx.StaticVariable("x86GccVersion", x86GccVersion) 143 144 pctx.SourcePathVariable("X86GccRoot", 145 "prebuilts/gcc/${HostPrebuiltTag}/x86/x86_64-linux-android-${x86GccVersion}") 146 147 pctx.StaticVariable("X86ToolchainCflags", "-m32") 148 pctx.StaticVariable("X86ToolchainLdflags", "-m32") 149 150 pctx.StaticVariable("X86Cflags", strings.Join(x86Cflags, " ")) 151 pctx.StaticVariable("X86Ldflags", strings.Join(x86Ldflags, " ")) 152 pctx.StaticVariable("X86Cppflags", strings.Join(x86Cppflags, " ")) 153 pctx.StaticVariable("X86IncludeFlags", bionicHeaders("x86")) 154 155 // Clang cflags 156 pctx.StaticVariable("X86ClangCflags", strings.Join(ClangFilterUnknownCflags(x86ClangCflags), " ")) 157 pctx.StaticVariable("X86ClangLdflags", strings.Join(ClangFilterUnknownCflags(x86Ldflags), " ")) 158 pctx.StaticVariable("X86ClangCppflags", strings.Join(ClangFilterUnknownCflags(x86Cppflags), " ")) 159 160 // Yasm flags 161 pctx.StaticVariable("X86YasmFlags", "-f elf32 -m x86") 162 163 // Extended cflags 164 165 // Architecture variant cflags 166 for variant, cflags := range x86ArchVariantCflags { 167 pctx.StaticVariable("X86"+variant+"VariantCflags", strings.Join(cflags, " ")) 168 pctx.StaticVariable("X86"+variant+"VariantClangCflags", 169 strings.Join(ClangFilterUnknownCflags(cflags), " ")) 170 } 171 } 172 173 type toolchainX86 struct { 174 toolchain32Bit 175 toolchainCflags, toolchainClangCflags string 176 } 177 178 func (t *toolchainX86) Name() string { 179 return "x86" 180 } 181 182 func (t *toolchainX86) GccRoot() string { 183 return "${config.X86GccRoot}" 184 } 185 186 func (t *toolchainX86) GccTriple() string { 187 return "x86_64-linux-android" 188 } 189 190 func (t *toolchainX86) GccVersion() string { 191 return x86GccVersion 192 } 193 194 func (t *toolchainX86) ToolchainLdflags() string { 195 return "${config.X86ToolchainLdflags}" 196 } 197 198 func (t *toolchainX86) ToolchainCflags() string { 199 return t.toolchainCflags 200 } 201 202 func (t *toolchainX86) Cflags() string { 203 return "${config.X86Cflags}" 204 } 205 206 func (t *toolchainX86) Cppflags() string { 207 return "${config.X86Cppflags}" 208 } 209 210 func (t *toolchainX86) Ldflags() string { 211 return "${config.X86Ldflags}" 212 } 213 214 func (t *toolchainX86) IncludeFlags() string { 215 return "${config.X86IncludeFlags}" 216 } 217 218 func (t *toolchainX86) ClangTriple() string { 219 return "i686-linux-android" 220 } 221 222 func (t *toolchainX86) ToolchainClangLdflags() string { 223 return "${config.X86ToolchainLdflags}" 224 } 225 226 func (t *toolchainX86) ToolchainClangCflags() string { 227 return t.toolchainClangCflags 228 } 229 230 func (t *toolchainX86) ClangCflags() string { 231 return "${config.X86ClangCflags}" 232 } 233 234 func (t *toolchainX86) ClangCppflags() string { 235 return "${config.X86ClangCppflags}" 236 } 237 238 func (t *toolchainX86) ClangLdflags() string { 239 return "${config.X86Ldflags}" 240 } 241 242 func (t *toolchainX86) YasmFlags() string { 243 return "${config.X86YasmFlags}" 244 } 245 246 func (toolchainX86) SanitizerRuntimeLibraryArch() string { 247 return "i686" 248 } 249 250 func x86ToolchainFactory(arch android.Arch) Toolchain { 251 toolchainCflags := []string{ 252 "${config.X86ToolchainCflags}", 253 "${config.X86" + arch.ArchVariant + "VariantCflags}", 254 } 255 256 toolchainClangCflags := []string{ 257 "${config.X86ToolchainCflags}", 258 "${config.X86" + arch.ArchVariant + "VariantClangCflags}", 259 } 260 261 for _, feature := range arch.ArchFeatures { 262 toolchainCflags = append(toolchainCflags, x86ArchFeatureCflags[feature]...) 263 toolchainClangCflags = append(toolchainClangCflags, x86ArchFeatureCflags[feature]...) 264 } 265 266 return &toolchainX86{ 267 toolchainCflags: strings.Join(toolchainCflags, " "), 268 toolchainClangCflags: strings.Join(toolchainClangCflags, " "), 269 } 270 } 271 272 func init() { 273 registerToolchainFactory(android.Android, android.X86, x86ToolchainFactory) 274 }