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 15package config 16 17import ( 18 "strings" 19 20 "android/soong/android" 21) 22 23var ( 24 mips64Cflags = []string{ 25 "-Umips", 26 27 // Help catch common 32/64-bit errors. 28 "-Werror=implicit-function-declaration", 29 } 30 31 mips64ClangCflags = append(mips64Cflags, []string{ 32 "-fintegrated-as", 33 }...) 34 35 mips64Cppflags = []string{} 36 37 mips64Ldflags = []string{ 38 "-Wl,--allow-shlib-undefined", 39 } 40 41 mips64ArchVariantCflags = map[string][]string{ 42 "mips64r2": []string{ 43 "-mips64r2", 44 "-msynci", 45 }, 46 "mips64r6": []string{ 47 "-mips64r6", 48 "-msynci", 49 }, 50 } 51) 52 53const ( 54 mips64GccVersion = "4.9" 55) 56 57func init() { 58 pctx.StaticVariable("mips64GccVersion", mips64GccVersion) 59 60 pctx.SourcePathVariable("Mips64GccRoot", 61 "prebuilts/gcc/${HostPrebuiltTag}/mips/mips64el-linux-android-${mips64GccVersion}") 62 63 pctx.StaticVariable("Mips64IncludeFlags", bionicHeaders("mips")) 64 65 // Clang cflags 66 pctx.StaticVariable("Mips64ClangCflags", strings.Join(ClangFilterUnknownCflags(mips64ClangCflags), " ")) 67 pctx.StaticVariable("Mips64ClangLdflags", strings.Join(ClangFilterUnknownCflags(mips64Ldflags), " ")) 68 pctx.StaticVariable("Mips64ClangCppflags", strings.Join(ClangFilterUnknownCflags(mips64Cppflags), " ")) 69 70 // Extended cflags 71 72 // Architecture variant cflags 73 for variant, cflags := range mips64ArchVariantCflags { 74 pctx.StaticVariable("Mips64"+variant+"VariantClangCflags", 75 strings.Join(ClangFilterUnknownCflags(cflags), " ")) 76 } 77} 78 79type toolchainMips64 struct { 80 toolchain64Bit 81 clangCflags string 82 toolchainClangCflags string 83} 84 85func (t *toolchainMips64) Name() string { 86 return "mips64" 87} 88 89func (t *toolchainMips64) GccRoot() string { 90 return "${config.Mips64GccRoot}" 91} 92 93func (t *toolchainMips64) GccTriple() string { 94 return "mips64el-linux-android" 95} 96 97func (t *toolchainMips64) GccVersion() string { 98 return mips64GccVersion 99} 100 101func (t *toolchainMips64) IncludeFlags() string { 102 return "${config.Mips64IncludeFlags}" 103} 104 105func (t *toolchainMips64) ClangTriple() string { 106 return t.GccTriple() 107} 108 109func (t *toolchainMips64) ToolchainClangCflags() string { 110 return t.toolchainClangCflags 111} 112 113func (t *toolchainMips64) ClangAsflags() string { 114 return "-fno-integrated-as" 115} 116 117func (t *toolchainMips64) ClangCflags() string { 118 return t.clangCflags 119} 120 121func (t *toolchainMips64) ClangCppflags() string { 122 return "${config.Mips64ClangCppflags}" 123} 124 125func (t *toolchainMips64) ClangLdflags() string { 126 return "${config.Mips64ClangLdflags}" 127} 128 129func (t *toolchainMips64) ClangLldflags() string { 130 // TODO: define and use Mips64ClangLldflags 131 return "${config.Mips64ClangLdflags}" 132} 133 134func (toolchainMips64) LibclangRuntimeLibraryArch() string { 135 return "mips64" 136} 137 138func mips64ToolchainFactory(arch android.Arch) Toolchain { 139 return &toolchainMips64{ 140 clangCflags: "${config.Mips64ClangCflags}", 141 toolchainClangCflags: "${config.Mips64" + arch.ArchVariant + "VariantClangCflags}", 142 } 143} 144 145func init() { 146 registerToolchainFactory(android.Android, android.Mips64, mips64ToolchainFactory) 147} 148