2015-11-24 01:15:10 +01:00
|
|
|
// Copyright 2015 Google Inc. All rights reserved.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
|
2016-07-29 22:44:28 +02:00
|
|
|
package config
|
2015-11-24 01:15:10 +01:00
|
|
|
|
|
|
|
import (
|
|
|
|
"strings"
|
|
|
|
|
2016-05-19 00:37:25 +02:00
|
|
|
"android/soong/android"
|
2015-11-24 01:15:10 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
mipsCflags = []string{
|
|
|
|
"-fno-exceptions", // from build/core/combo/select.mk
|
|
|
|
"-Wno-multichar", // from build/core/combo/select.mk
|
|
|
|
"-O2",
|
|
|
|
"-fomit-frame-pointer",
|
|
|
|
"-fno-strict-aliasing",
|
|
|
|
"-funswitch-loops",
|
|
|
|
"-U__unix",
|
|
|
|
"-U__unix__",
|
|
|
|
"-Umips",
|
|
|
|
"-ffunction-sections",
|
|
|
|
"-fdata-sections",
|
|
|
|
"-funwind-tables",
|
2016-01-13 01:22:40 +01:00
|
|
|
"-fstack-protector-strong",
|
2015-11-24 01:15:10 +01:00
|
|
|
"-Wa,--noexecstack",
|
|
|
|
"-Werror=format-security",
|
|
|
|
"-D_FORTIFY_SOURCE=2",
|
|
|
|
"-no-canonical-prefixes",
|
|
|
|
"-fno-canonical-system-headers",
|
|
|
|
|
|
|
|
// TARGET_RELEASE_CFLAGS
|
|
|
|
"-DNDEBUG",
|
|
|
|
"-g",
|
|
|
|
"-Wstrict-aliasing=2",
|
|
|
|
"-fgcse-after-reload",
|
|
|
|
"-frerun-cse-after-loop",
|
|
|
|
"-frename-registers",
|
|
|
|
}
|
|
|
|
|
2016-05-09 22:34:35 +02:00
|
|
|
mipsClangCflags = append(mipsCflags, []string{
|
|
|
|
"-fPIC",
|
2017-04-21 20:47:16 +02:00
|
|
|
"-fintegrated-as",
|
2016-05-09 22:34:35 +02:00
|
|
|
}...)
|
|
|
|
|
2015-11-24 01:15:10 +01:00
|
|
|
mipsCppflags = []string{
|
|
|
|
"-fvisibility-inlines-hidden",
|
|
|
|
}
|
|
|
|
|
|
|
|
mipsLdflags = []string{
|
|
|
|
"-Wl,-z,noexecstack",
|
|
|
|
"-Wl,-z,relro",
|
|
|
|
"-Wl,-z,now",
|
|
|
|
"-Wl,--build-id=md5",
|
|
|
|
"-Wl,--warn-shared-textrel",
|
|
|
|
"-Wl,--fatal-warnings",
|
|
|
|
"-Wl,--allow-shlib-undefined",
|
2015-12-09 22:05:28 +01:00
|
|
|
"-Wl,--no-undefined-version",
|
2015-11-24 01:15:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
mipsToolchainLdflags = []string{
|
|
|
|
"-Wl,-melf32ltsmip",
|
|
|
|
}
|
|
|
|
|
|
|
|
mipsArchVariantCflags = map[string][]string{
|
|
|
|
"mips32-fp": []string{
|
|
|
|
"-mips32",
|
|
|
|
"-mfp32",
|
|
|
|
"-modd-spreg",
|
|
|
|
"-mno-synci",
|
|
|
|
},
|
|
|
|
"mips32r2-fp": []string{
|
|
|
|
"-mips32r2",
|
|
|
|
"-mfp32",
|
|
|
|
"-modd-spreg",
|
2016-05-09 22:34:35 +02:00
|
|
|
"-msynci",
|
2015-11-24 01:15:10 +01:00
|
|
|
},
|
|
|
|
"mips32r2-fp-xburst": []string{
|
|
|
|
"-mips32r2",
|
|
|
|
"-mfp32",
|
|
|
|
"-modd-spreg",
|
|
|
|
"-mno-fused-madd",
|
|
|
|
"-Wa,-mmxu",
|
|
|
|
"-mno-synci",
|
|
|
|
},
|
|
|
|
"mips32r2dsp-fp": []string{
|
|
|
|
"-mips32r2",
|
|
|
|
"-mfp32",
|
|
|
|
"-modd-spreg",
|
|
|
|
"-mdsp",
|
|
|
|
"-msynci",
|
|
|
|
},
|
|
|
|
"mips32r2dspr2-fp": []string{
|
|
|
|
"-mips32r2",
|
|
|
|
"-mfp32",
|
|
|
|
"-modd-spreg",
|
|
|
|
"-mdspr2",
|
|
|
|
"-msynci",
|
|
|
|
},
|
|
|
|
"mips32r6": []string{
|
|
|
|
"-mips32r6",
|
|
|
|
"-mfp64",
|
|
|
|
"-mno-odd-spreg",
|
|
|
|
"-msynci",
|
2016-08-22 20:03:39 +02:00
|
|
|
|
|
|
|
// revert once clang picks up r278824
|
|
|
|
"-mcompact-branches=never",
|
2015-11-24 01:15:10 +01:00
|
|
|
},
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
2015-12-07 21:30:44 +01:00
|
|
|
const (
|
|
|
|
mipsGccVersion = "4.9"
|
|
|
|
)
|
|
|
|
|
2015-11-24 01:15:10 +01:00
|
|
|
func init() {
|
2016-06-24 08:44:54 +02:00
|
|
|
android.RegisterArchVariants(android.Mips,
|
|
|
|
"mips32_fp",
|
|
|
|
"mips32r2_fp",
|
|
|
|
"mips32r2_fp_xburst",
|
|
|
|
"mips32r2dsp_fp",
|
|
|
|
"mips32r2dspr2_fp",
|
|
|
|
"mips32r6")
|
2017-04-26 23:00:43 +02:00
|
|
|
android.RegisterArchFeatures(android.Mips,
|
|
|
|
"dspr2",
|
|
|
|
"rev6")
|
|
|
|
android.RegisterArchVariantFeatures(android.Mips, "mips32r2dspr2_fp",
|
|
|
|
"dspr2")
|
2016-06-24 08:44:54 +02:00
|
|
|
android.RegisterArchVariantFeatures(android.Mips, "mips32r6",
|
2015-11-24 01:15:10 +01:00
|
|
|
"rev6")
|
|
|
|
|
2015-12-07 21:30:44 +01:00
|
|
|
pctx.StaticVariable("mipsGccVersion", mipsGccVersion)
|
2015-11-24 01:15:10 +01:00
|
|
|
|
2016-07-29 22:44:28 +02:00
|
|
|
pctx.SourcePathVariable("MipsGccRoot",
|
2015-12-07 21:30:44 +01:00
|
|
|
"prebuilts/gcc/${HostPrebuiltTag}/mips/mips64el-linux-android-${mipsGccVersion}")
|
2015-11-24 01:15:10 +01:00
|
|
|
|
2016-07-29 22:44:28 +02:00
|
|
|
pctx.StaticVariable("MipsToolchainLdflags", strings.Join(mipsToolchainLdflags, " "))
|
|
|
|
pctx.StaticVariable("MipsCflags", strings.Join(mipsCflags, " "))
|
|
|
|
pctx.StaticVariable("MipsLdflags", strings.Join(mipsLdflags, " "))
|
|
|
|
pctx.StaticVariable("MipsCppflags", strings.Join(mipsCppflags, " "))
|
|
|
|
pctx.StaticVariable("MipsIncludeFlags", bionicHeaders("mips", "mips"))
|
2015-11-24 01:15:10 +01:00
|
|
|
|
|
|
|
// Clang cflags
|
2016-07-29 22:44:28 +02:00
|
|
|
pctx.StaticVariable("MipsClangCflags", strings.Join(ClangFilterUnknownCflags(mipsClangCflags), " "))
|
|
|
|
pctx.StaticVariable("MipsClangLdflags", strings.Join(ClangFilterUnknownCflags(mipsLdflags), " "))
|
|
|
|
pctx.StaticVariable("MipsClangCppflags", strings.Join(ClangFilterUnknownCflags(mipsCppflags), " "))
|
2015-11-24 01:15:10 +01:00
|
|
|
|
|
|
|
// Extended cflags
|
|
|
|
|
|
|
|
// Architecture variant cflags
|
|
|
|
for variant, cflags := range mipsArchVariantCflags {
|
2016-07-29 22:44:28 +02:00
|
|
|
pctx.StaticVariable("Mips"+variant+"VariantCflags", strings.Join(cflags, " "))
|
|
|
|
pctx.StaticVariable("Mips"+variant+"VariantClangCflags",
|
|
|
|
strings.Join(ClangFilterUnknownCflags(cflags), " "))
|
2015-11-24 01:15:10 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
type toolchainMips struct {
|
|
|
|
toolchain32Bit
|
|
|
|
cflags, clangCflags string
|
|
|
|
toolchainCflags, toolchainClangCflags string
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *toolchainMips) Name() string {
|
|
|
|
return "mips"
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *toolchainMips) GccRoot() string {
|
2016-07-29 22:44:28 +02:00
|
|
|
return "${config.MipsGccRoot}"
|
2015-11-24 01:15:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func (t *toolchainMips) GccTriple() string {
|
2016-07-20 23:44:26 +02:00
|
|
|
return "mips64el-linux-android"
|
2015-11-24 01:15:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func (t *toolchainMips) GccVersion() string {
|
2015-12-07 21:30:44 +01:00
|
|
|
return mipsGccVersion
|
2015-11-24 01:15:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func (t *toolchainMips) ToolchainLdflags() string {
|
2016-07-29 22:44:28 +02:00
|
|
|
return "${config.MipsToolchainLdflags}"
|
2015-11-24 01:15:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func (t *toolchainMips) ToolchainCflags() string {
|
|
|
|
return t.toolchainCflags
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *toolchainMips) Cflags() string {
|
|
|
|
return t.cflags
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *toolchainMips) Cppflags() string {
|
2016-07-29 22:44:28 +02:00
|
|
|
return "${config.MipsCppflags}"
|
2015-11-24 01:15:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func (t *toolchainMips) Ldflags() string {
|
2016-07-29 22:44:28 +02:00
|
|
|
return "${config.MipsLdflags}"
|
2015-11-24 01:15:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func (t *toolchainMips) IncludeFlags() string {
|
2016-07-29 22:44:28 +02:00
|
|
|
return "${config.MipsIncludeFlags}"
|
2015-11-24 01:15:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func (t *toolchainMips) ClangTriple() string {
|
2016-07-20 23:44:26 +02:00
|
|
|
return "mipsel-linux-android"
|
2015-11-24 01:15:10 +01:00
|
|
|
}
|
|
|
|
|
2016-05-09 22:34:35 +02:00
|
|
|
func (t *toolchainMips) ToolchainClangLdflags() string {
|
2016-07-29 22:44:28 +02:00
|
|
|
return "${config.MipsToolchainLdflags}"
|
2016-05-09 22:34:35 +02:00
|
|
|
}
|
|
|
|
|
2015-11-24 01:15:10 +01:00
|
|
|
func (t *toolchainMips) ToolchainClangCflags() string {
|
|
|
|
return t.toolchainClangCflags
|
|
|
|
}
|
|
|
|
|
2016-01-13 07:25:34 +01:00
|
|
|
func (t *toolchainMips) ClangAsflags() string {
|
2016-06-30 02:09:30 +02:00
|
|
|
return "-fPIC -fno-integrated-as"
|
2016-01-13 07:25:34 +01:00
|
|
|
}
|
|
|
|
|
2015-11-24 01:15:10 +01:00
|
|
|
func (t *toolchainMips) ClangCflags() string {
|
|
|
|
return t.clangCflags
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *toolchainMips) ClangCppflags() string {
|
2016-07-29 22:44:28 +02:00
|
|
|
return "${config.MipsClangCppflags}"
|
2015-11-24 01:15:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func (t *toolchainMips) ClangLdflags() string {
|
2016-07-29 22:44:28 +02:00
|
|
|
return "${config.MipsClangLdflags}"
|
2015-11-24 01:15:10 +01:00
|
|
|
}
|
|
|
|
|
2016-08-15 23:18:24 +02:00
|
|
|
func (toolchainMips) SanitizerRuntimeLibraryArch() string {
|
|
|
|
return "mips"
|
2016-05-20 07:43:46 +02:00
|
|
|
}
|
|
|
|
|
2016-05-19 00:37:25 +02:00
|
|
|
func mipsToolchainFactory(arch android.Arch) Toolchain {
|
2015-11-24 01:15:10 +01:00
|
|
|
return &toolchainMips{
|
2016-07-29 22:44:28 +02:00
|
|
|
cflags: "${config.MipsCflags}",
|
|
|
|
clangCflags: "${config.MipsClangCflags}",
|
|
|
|
toolchainCflags: "${config.Mips" + arch.ArchVariant + "VariantCflags}",
|
|
|
|
toolchainClangCflags: "${config.Mips" + arch.ArchVariant + "VariantClangCflags}",
|
2015-11-24 01:15:10 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func init() {
|
2016-06-02 02:09:44 +02:00
|
|
|
registerToolchainFactory(android.Android, android.Mips, mipsToolchainFactory)
|
2015-11-24 01:15:10 +01:00
|
|
|
}
|