2015-11-24 01:28:31 +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.
|
|
|
|
|
|
|
|
package cc
|
|
|
|
|
|
|
|
import (
|
|
|
|
"strings"
|
|
|
|
|
2016-05-19 00:37:25 +02:00
|
|
|
"android/soong/android"
|
2015-11-24 01:28:31 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
mips64Cflags = []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:28:31 +01:00
|
|
|
"-Wa,--noexecstack",
|
|
|
|
"-Werror=format-security",
|
|
|
|
"-D_FORTIFY_SOURCE=2",
|
|
|
|
"-no-canonical-prefixes",
|
|
|
|
"-fno-canonical-system-headers",
|
|
|
|
|
|
|
|
// Help catch common 32/64-bit errors.
|
|
|
|
"-Werror=pointer-to-int-cast",
|
|
|
|
"-Werror=int-to-pointer-cast",
|
|
|
|
"-Werror=implicit-function-declaration",
|
|
|
|
|
|
|
|
// TARGET_RELEASE_CFLAGS
|
|
|
|
"-DNDEBUG",
|
|
|
|
"-g",
|
|
|
|
"-Wstrict-aliasing=2",
|
|
|
|
"-fgcse-after-reload",
|
|
|
|
"-frerun-cse-after-loop",
|
|
|
|
"-frename-registers",
|
|
|
|
}
|
|
|
|
|
|
|
|
mips64Cppflags = []string{
|
|
|
|
"-fvisibility-inlines-hidden",
|
|
|
|
}
|
|
|
|
|
|
|
|
mips64Ldflags = []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:28:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
mips64ArchVariantCflags = map[string][]string{
|
|
|
|
"mips64r2": []string{
|
|
|
|
"-mips64r2",
|
|
|
|
"-msynci",
|
|
|
|
},
|
|
|
|
"mips64r6": []string{
|
|
|
|
"-mips64r6",
|
|
|
|
"-msynci",
|
|
|
|
},
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
2015-12-07 21:30:44 +01:00
|
|
|
const (
|
|
|
|
mips64GccVersion = "4.9"
|
|
|
|
)
|
|
|
|
|
2015-11-24 01:28:31 +01:00
|
|
|
func init() {
|
2016-05-19 00:37:25 +02:00
|
|
|
android.RegisterArchFeatures(android.Mips64, "mips64r6",
|
2015-11-24 01:28:31 +01:00
|
|
|
"rev6")
|
|
|
|
|
2015-12-07 21:30:44 +01:00
|
|
|
pctx.StaticVariable("mips64GccVersion", mips64GccVersion)
|
2015-11-24 01:28:31 +01:00
|
|
|
|
2015-09-24 00:26:20 +02:00
|
|
|
pctx.SourcePathVariable("mips64GccRoot",
|
2015-12-07 21:30:44 +01:00
|
|
|
"prebuilts/gcc/${HostPrebuiltTag}/mips/mips64el-linux-android-${mips64GccVersion}")
|
2015-11-24 01:28:31 +01:00
|
|
|
|
|
|
|
pctx.StaticVariable("mips64GccTriple", "mips64el-linux-android")
|
|
|
|
|
|
|
|
pctx.StaticVariable("mips64Cflags", strings.Join(mips64Cflags, " "))
|
|
|
|
pctx.StaticVariable("mips64Ldflags", strings.Join(mips64Ldflags, " "))
|
|
|
|
pctx.StaticVariable("mips64Cppflags", strings.Join(mips64Cppflags, " "))
|
|
|
|
pctx.StaticVariable("mips64IncludeFlags", strings.Join([]string{
|
|
|
|
"-isystem ${LibcRoot}/arch-mips64/include",
|
|
|
|
"-isystem ${LibcRoot}/include",
|
|
|
|
"-isystem ${LibcRoot}/kernel/uapi",
|
2016-05-18 23:32:32 +02:00
|
|
|
"-isystem ${LibcRoot}/kernel/common",
|
2015-11-24 01:28:31 +01:00
|
|
|
"-isystem ${LibcRoot}/kernel/uapi/asm-mips",
|
|
|
|
}, " "))
|
|
|
|
|
|
|
|
// Clang cflags
|
|
|
|
pctx.StaticVariable("mips64ClangTriple", "mips64el-linux-android")
|
|
|
|
pctx.StaticVariable("mips64ClangCflags", strings.Join(clangFilterUnknownCflags(mips64Cflags), " "))
|
|
|
|
pctx.StaticVariable("mips64ClangLdflags", strings.Join(clangFilterUnknownCflags(mips64Ldflags), " "))
|
|
|
|
pctx.StaticVariable("mips64ClangCppflags", strings.Join(clangFilterUnknownCflags(mips64Cppflags), " "))
|
|
|
|
|
|
|
|
// Extended cflags
|
|
|
|
|
|
|
|
// Architecture variant cflags
|
|
|
|
for variant, cflags := range mips64ArchVariantCflags {
|
|
|
|
pctx.StaticVariable("mips64"+variant+"VariantCflags", strings.Join(cflags, " "))
|
|
|
|
pctx.StaticVariable("mips64"+variant+"VariantClangCflags",
|
|
|
|
strings.Join(clangFilterUnknownCflags(cflags), " "))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
type toolchainMips64 struct {
|
|
|
|
toolchain64Bit
|
|
|
|
cflags, clangCflags string
|
|
|
|
toolchainCflags, toolchainClangCflags string
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *toolchainMips64) Name() string {
|
|
|
|
return "mips64"
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *toolchainMips64) GccRoot() string {
|
|
|
|
return "${mips64GccRoot}"
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *toolchainMips64) GccTriple() string {
|
|
|
|
return "${mips64GccTriple}"
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *toolchainMips64) GccVersion() string {
|
2015-12-07 21:30:44 +01:00
|
|
|
return mips64GccVersion
|
2015-11-24 01:28:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func (t *toolchainMips64) ToolchainCflags() string {
|
|
|
|
return t.toolchainCflags
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *toolchainMips64) Cflags() string {
|
|
|
|
return t.cflags
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *toolchainMips64) Cppflags() string {
|
|
|
|
return "${mips64Cppflags}"
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *toolchainMips64) Ldflags() string {
|
|
|
|
return "${mips64Ldflags}"
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *toolchainMips64) IncludeFlags() string {
|
|
|
|
return "${mips64IncludeFlags}"
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *toolchainMips64) ClangTriple() string {
|
|
|
|
return "${mips64ClangTriple}"
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *toolchainMips64) ToolchainClangCflags() string {
|
|
|
|
return t.toolchainClangCflags
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *toolchainMips64) ClangCflags() string {
|
|
|
|
return t.clangCflags
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *toolchainMips64) ClangCppflags() string {
|
|
|
|
return "${mips64ClangCppflags}"
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *toolchainMips64) ClangLdflags() string {
|
|
|
|
return "${mips64ClangLdflags}"
|
|
|
|
}
|
|
|
|
|
2016-05-20 07:43:46 +02:00
|
|
|
func (toolchainMips64) AddressSanitizerRuntimeLibrary() string {
|
|
|
|
return "libclang_rt.asan-mips64-android.so"
|
|
|
|
}
|
|
|
|
|
2016-05-19 00:37:25 +02:00
|
|
|
func mips64ToolchainFactory(arch android.Arch) Toolchain {
|
2015-11-24 01:28:31 +01:00
|
|
|
return &toolchainMips64{
|
|
|
|
cflags: "${mips64Cflags}",
|
|
|
|
clangCflags: "${mips64ClangCflags}",
|
|
|
|
toolchainCflags: "${mips64" + arch.ArchVariant + "VariantCflags}",
|
|
|
|
toolchainClangCflags: "${mips64" + arch.ArchVariant + "VariantClangCflags}",
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func init() {
|
2016-06-02 02:09:44 +02:00
|
|
|
registerToolchainFactory(android.Android, android.Mips64, mips64ToolchainFactory)
|
2015-11-24 01:28:31 +01:00
|
|
|
}
|