blob: 5aa5bc3f56b5c7635697c74b90059c886a9ff7eb [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
Dan Willemsen34fc3b12015-12-07 12:30:44 -080083const (
84 mips64GccVersion = "4.9"
85)
86
Colin Cross3b336c22015-11-23 16:28:31 -080087func init() {
88 common.RegisterArchFeatures(common.Mips64, "mips64r6",
89 "rev6")
90
Dan Willemsen34fc3b12015-12-07 12:30:44 -080091 pctx.StaticVariable("mips64GccVersion", mips64GccVersion)
Colin Cross3b336c22015-11-23 16:28:31 -080092
93 pctx.StaticVariable("mips64GccRoot",
Dan Willemsen34fc3b12015-12-07 12:30:44 -080094 "prebuilts/gcc/${HostPrebuiltTag}/mips/mips64el-linux-android-${mips64GccVersion}")
Colin Cross3b336c22015-11-23 16:28:31 -080095
96 pctx.StaticVariable("mips64GccTriple", "mips64el-linux-android")
97
98 pctx.StaticVariable("mips64Cflags", strings.Join(mips64Cflags, " "))
99 pctx.StaticVariable("mips64Ldflags", strings.Join(mips64Ldflags, " "))
100 pctx.StaticVariable("mips64Cppflags", strings.Join(mips64Cppflags, " "))
101 pctx.StaticVariable("mips64IncludeFlags", strings.Join([]string{
102 "-isystem ${LibcRoot}/arch-mips64/include",
103 "-isystem ${LibcRoot}/include",
104 "-isystem ${LibcRoot}/kernel/uapi",
105 "-isystem ${LibcRoot}/kernel/uapi/asm-mips",
106 "-isystem ${LibmRoot}/include",
107 "-isystem ${LibmRoot}/include/mips",
108 }, " "))
109
110 // Clang cflags
111 pctx.StaticVariable("mips64ClangTriple", "mips64el-linux-android")
112 pctx.StaticVariable("mips64ClangCflags", strings.Join(clangFilterUnknownCflags(mips64Cflags), " "))
113 pctx.StaticVariable("mips64ClangLdflags", strings.Join(clangFilterUnknownCflags(mips64Ldflags), " "))
114 pctx.StaticVariable("mips64ClangCppflags", strings.Join(clangFilterUnknownCflags(mips64Cppflags), " "))
115
116 // Extended cflags
117
118 // Architecture variant cflags
119 for variant, cflags := range mips64ArchVariantCflags {
120 pctx.StaticVariable("mips64"+variant+"VariantCflags", strings.Join(cflags, " "))
121 pctx.StaticVariable("mips64"+variant+"VariantClangCflags",
122 strings.Join(clangFilterUnknownCflags(cflags), " "))
123 }
124}
125
126type toolchainMips64 struct {
127 toolchain64Bit
128 cflags, clangCflags string
129 toolchainCflags, toolchainClangCflags string
130}
131
132func (t *toolchainMips64) Name() string {
133 return "mips64"
134}
135
136func (t *toolchainMips64) GccRoot() string {
137 return "${mips64GccRoot}"
138}
139
140func (t *toolchainMips64) GccTriple() string {
141 return "${mips64GccTriple}"
142}
143
144func (t *toolchainMips64) GccVersion() string {
Dan Willemsen34fc3b12015-12-07 12:30:44 -0800145 return mips64GccVersion
Colin Cross3b336c22015-11-23 16:28:31 -0800146}
147
148func (t *toolchainMips64) ToolchainLdflags() string {
149 return ""
150}
151
152func (t *toolchainMips64) ToolchainCflags() string {
153 return t.toolchainCflags
154}
155
156func (t *toolchainMips64) Cflags() string {
157 return t.cflags
158}
159
160func (t *toolchainMips64) Cppflags() string {
161 return "${mips64Cppflags}"
162}
163
164func (t *toolchainMips64) Ldflags() string {
165 return "${mips64Ldflags}"
166}
167
168func (t *toolchainMips64) IncludeFlags() string {
169 return "${mips64IncludeFlags}"
170}
171
172func (t *toolchainMips64) ClangTriple() string {
173 return "${mips64ClangTriple}"
174}
175
176func (t *toolchainMips64) ToolchainClangCflags() string {
177 return t.toolchainClangCflags
178}
179
180func (t *toolchainMips64) ClangCflags() string {
181 return t.clangCflags
182}
183
184func (t *toolchainMips64) ClangCppflags() string {
185 return "${mips64ClangCppflags}"
186}
187
188func (t *toolchainMips64) ClangLdflags() string {
189 return "${mips64ClangLdflags}"
190}
191
192func mips64ToolchainFactory(arch common.Arch) Toolchain {
193 return &toolchainMips64{
194 cflags: "${mips64Cflags}",
195 clangCflags: "${mips64ClangCflags}",
196 toolchainCflags: "${mips64" + arch.ArchVariant + "VariantCflags}",
197 toolchainClangCflags: "${mips64" + arch.ArchVariant + "VariantClangCflags}",
198 }
199}
200
201func init() {
Dan Willemsen490fd492015-11-24 17:53:15 -0800202 registerDeviceToolchainFactory(common.Mips64, mips64ToolchainFactory)
Colin Cross3b336c22015-11-23 16:28:31 -0800203}