blob: d792d005929a57466946b73d11373bb4c667de4e [file] [log] [blame]
Colin Cross3b336c22015-11-23 16:28:31 -08001// 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 cc
16
17import (
18 "strings"
19
20 "android/soong/common"
21)
22
23var (
24 mips64Cflags = []string{
25 "-fno-exceptions", // from build/core/combo/select.mk
26 "-Wno-multichar", // from build/core/combo/select.mk
27 "-O2",
28 "-fomit-frame-pointer",
29 "-fno-strict-aliasing",
30 "-funswitch-loops",
31 "-U__unix",
32 "-U__unix__",
33 "-Umips",
34 "-ffunction-sections",
35 "-fdata-sections",
36 "-funwind-tables",
37 "-Wa,--noexecstack",
38 "-Werror=format-security",
39 "-D_FORTIFY_SOURCE=2",
40 "-no-canonical-prefixes",
41 "-fno-canonical-system-headers",
42
43 // Help catch common 32/64-bit errors.
44 "-Werror=pointer-to-int-cast",
45 "-Werror=int-to-pointer-cast",
46 "-Werror=implicit-function-declaration",
47
48 // TARGET_RELEASE_CFLAGS
49 "-DNDEBUG",
50 "-g",
51 "-Wstrict-aliasing=2",
52 "-fgcse-after-reload",
53 "-frerun-cse-after-loop",
54 "-frename-registers",
55 }
56
57 mips64Cppflags = []string{
58 "-fvisibility-inlines-hidden",
59 }
60
61 mips64Ldflags = []string{
62 "-Wl,-z,noexecstack",
63 "-Wl,-z,relro",
64 "-Wl,-z,now",
65 "-Wl,--build-id=md5",
66 "-Wl,--warn-shared-textrel",
67 "-Wl,--fatal-warnings",
68 "-Wl,--allow-shlib-undefined",
69 }
70
71 mips64ArchVariantCflags = map[string][]string{
72 "mips64r2": []string{
73 "-mips64r2",
74 "-msynci",
75 },
76 "mips64r6": []string{
77 "-mips64r6",
78 "-msynci",
79 },
80 }
81)
82
83func init() {
84 common.RegisterArchFeatures(common.Mips64, "mips64r6",
85 "rev6")
86
87 pctx.StaticVariable("mips64GccVersion", "4.9")
88
89 pctx.StaticVariable("mips64GccRoot",
90 "prebuilts/gcc/${HostPrebuiltTag}/mips/mips64el-linux-android-${armGccVersion}")
91
92 pctx.StaticVariable("mips64GccTriple", "mips64el-linux-android")
93
94 pctx.StaticVariable("mips64Cflags", strings.Join(mips64Cflags, " "))
95 pctx.StaticVariable("mips64Ldflags", strings.Join(mips64Ldflags, " "))
96 pctx.StaticVariable("mips64Cppflags", strings.Join(mips64Cppflags, " "))
97 pctx.StaticVariable("mips64IncludeFlags", strings.Join([]string{
98 "-isystem ${LibcRoot}/arch-mips64/include",
99 "-isystem ${LibcRoot}/include",
100 "-isystem ${LibcRoot}/kernel/uapi",
101 "-isystem ${LibcRoot}/kernel/uapi/asm-mips",
102 "-isystem ${LibmRoot}/include",
103 "-isystem ${LibmRoot}/include/mips",
104 }, " "))
105
106 // Clang cflags
107 pctx.StaticVariable("mips64ClangTriple", "mips64el-linux-android")
108 pctx.StaticVariable("mips64ClangCflags", strings.Join(clangFilterUnknownCflags(mips64Cflags), " "))
109 pctx.StaticVariable("mips64ClangLdflags", strings.Join(clangFilterUnknownCflags(mips64Ldflags), " "))
110 pctx.StaticVariable("mips64ClangCppflags", strings.Join(clangFilterUnknownCflags(mips64Cppflags), " "))
111
112 // Extended cflags
113
114 // Architecture variant cflags
115 for variant, cflags := range mips64ArchVariantCflags {
116 pctx.StaticVariable("mips64"+variant+"VariantCflags", strings.Join(cflags, " "))
117 pctx.StaticVariable("mips64"+variant+"VariantClangCflags",
118 strings.Join(clangFilterUnknownCflags(cflags), " "))
119 }
120}
121
122type toolchainMips64 struct {
123 toolchain64Bit
124 cflags, clangCflags string
125 toolchainCflags, toolchainClangCflags string
126}
127
128func (t *toolchainMips64) Name() string {
129 return "mips64"
130}
131
132func (t *toolchainMips64) GccRoot() string {
133 return "${mips64GccRoot}"
134}
135
136func (t *toolchainMips64) GccTriple() string {
137 return "${mips64GccTriple}"
138}
139
140func (t *toolchainMips64) GccVersion() string {
141 return "${mips64GccVersion}"
142}
143
144func (t *toolchainMips64) ToolchainLdflags() string {
145 return ""
146}
147
148func (t *toolchainMips64) ToolchainCflags() string {
149 return t.toolchainCflags
150}
151
152func (t *toolchainMips64) Cflags() string {
153 return t.cflags
154}
155
156func (t *toolchainMips64) Cppflags() string {
157 return "${mips64Cppflags}"
158}
159
160func (t *toolchainMips64) Ldflags() string {
161 return "${mips64Ldflags}"
162}
163
164func (t *toolchainMips64) IncludeFlags() string {
165 return "${mips64IncludeFlags}"
166}
167
168func (t *toolchainMips64) ClangTriple() string {
169 return "${mips64ClangTriple}"
170}
171
172func (t *toolchainMips64) ToolchainClangCflags() string {
173 return t.toolchainClangCflags
174}
175
176func (t *toolchainMips64) ClangCflags() string {
177 return t.clangCflags
178}
179
180func (t *toolchainMips64) ClangCppflags() string {
181 return "${mips64ClangCppflags}"
182}
183
184func (t *toolchainMips64) ClangLdflags() string {
185 return "${mips64ClangLdflags}"
186}
187
188func mips64ToolchainFactory(arch common.Arch) Toolchain {
189 return &toolchainMips64{
190 cflags: "${mips64Cflags}",
191 clangCflags: "${mips64ClangCflags}",
192 toolchainCflags: "${mips64" + arch.ArchVariant + "VariantCflags}",
193 toolchainClangCflags: "${mips64" + arch.ArchVariant + "VariantClangCflags}",
194 }
195}
196
197func init() {
198 registerToolchainFactory(common.Device, common.Mips64, mips64ToolchainFactory)
199}