• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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	mipsCflags = []string{
25		"-fomit-frame-pointer",
26		"-Umips",
27	}
28
29	mipsClangCflags = append(mipsCflags, []string{
30		"-fPIC",
31		"-fintegrated-as",
32	}...)
33
34	mipsCppflags = []string{}
35
36	mipsLdflags = []string{
37		"-Wl,--allow-shlib-undefined",
38	}
39
40	mipsToolchainLdflags = []string{
41		"-Wl,-melf32ltsmip",
42	}
43
44	mipsArchVariantCflags = map[string][]string{
45		"mips32-fp": []string{
46			"-mips32",
47			"-mfp32",
48			"-modd-spreg",
49			"-mno-synci",
50		},
51		"mips32r2-fp": []string{
52			"-mips32r2",
53			"-mfp32",
54			"-modd-spreg",
55			"-msynci",
56		},
57		"mips32r2-fp-xburst": []string{
58			"-mips32r2",
59			"-mfp32",
60			"-modd-spreg",
61			"-mno-fused-madd",
62			"-mno-synci",
63		},
64		"mips32r2dsp-fp": []string{
65			"-mips32r2",
66			"-mfp32",
67			"-modd-spreg",
68			"-mdsp",
69			"-msynci",
70		},
71		"mips32r2dspr2-fp": []string{
72			"-mips32r2",
73			"-mfp32",
74			"-modd-spreg",
75			"-mdspr2",
76			"-msynci",
77		},
78		"mips32r6": []string{
79			"-mips32r6",
80			"-mfp64",
81			"-mno-odd-spreg",
82			"-msynci",
83		},
84	}
85)
86
87const (
88	mipsGccVersion = "4.9"
89)
90
91func init() {
92	pctx.StaticVariable("mipsGccVersion", mipsGccVersion)
93
94	pctx.SourcePathVariable("MipsGccRoot",
95		"prebuilts/gcc/${HostPrebuiltTag}/mips/mips64el-linux-android-${mipsGccVersion}")
96
97	pctx.StaticVariable("MipsToolchainLdflags", strings.Join(mipsToolchainLdflags, " "))
98	pctx.StaticVariable("MipsIncludeFlags", bionicHeaders("mips"))
99
100	// Clang cflags
101	pctx.StaticVariable("MipsClangCflags", strings.Join(ClangFilterUnknownCflags(mipsClangCflags), " "))
102	pctx.StaticVariable("MipsClangLdflags", strings.Join(ClangFilterUnknownCflags(mipsLdflags), " "))
103	pctx.StaticVariable("MipsClangCppflags", strings.Join(ClangFilterUnknownCflags(mipsCppflags), " "))
104
105	// Extended cflags
106
107	// Architecture variant cflags
108	for variant, cflags := range mipsArchVariantCflags {
109		pctx.StaticVariable("Mips"+variant+"VariantClangCflags",
110			strings.Join(ClangFilterUnknownCflags(cflags), " "))
111	}
112}
113
114type toolchainMips struct {
115	toolchain32Bit
116	clangCflags          string
117	toolchainClangCflags string
118}
119
120func (t *toolchainMips) Name() string {
121	return "mips"
122}
123
124func (t *toolchainMips) GccRoot() string {
125	return "${config.MipsGccRoot}"
126}
127
128func (t *toolchainMips) GccTriple() string {
129	return "mips64el-linux-android"
130}
131
132func (t *toolchainMips) GccVersion() string {
133	return mipsGccVersion
134}
135
136func (t *toolchainMips) IncludeFlags() string {
137	return "${config.MipsIncludeFlags}"
138}
139
140func (t *toolchainMips) ClangTriple() string {
141	return "mipsel-linux-android"
142}
143
144func (t *toolchainMips) ToolchainClangLdflags() string {
145	return "${config.MipsToolchainLdflags}"
146}
147
148func (t *toolchainMips) ToolchainClangCflags() string {
149	return t.toolchainClangCflags
150}
151
152func (t *toolchainMips) ClangAsflags() string {
153	return "-fPIC -fno-integrated-as"
154}
155
156func (t *toolchainMips) ClangCflags() string {
157	return t.clangCflags
158}
159
160func (t *toolchainMips) ClangCppflags() string {
161	return "${config.MipsClangCppflags}"
162}
163
164func (t *toolchainMips) ClangLdflags() string {
165	return "${config.MipsClangLdflags}"
166}
167
168func (t *toolchainMips) ClangLldflags() string {
169	// TODO: define and use MipsClangLldflags
170	return "${config.MipsClangLdflags}"
171}
172
173func (toolchainMips) LibclangRuntimeLibraryArch() string {
174	return "mips"
175}
176
177func mipsToolchainFactory(arch android.Arch) Toolchain {
178	return &toolchainMips{
179		clangCflags:          "${config.MipsClangCflags}",
180		toolchainClangCflags: "${config.Mips" + arch.ArchVariant + "VariantClangCflags}",
181	}
182}
183
184func init() {
185	registerToolchainFactory(android.Android, android.Mips, mipsToolchainFactory)
186}
187