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