platform_build_soong/cc/config/mips64_device.go
Chih-Hung Hsieh 02b4da53a7 Add USE_CLANG_LLD and use_clang_lld.
* USE_CLANG_LLD is unedefined in current builds.
* When USE_CLANG_LLD is defined to 'true' or '1',
  use clang's lld instead of ld or ld.gold.
* When lld is enabled:
  * ld-only flags are not passed to 'lld'.
  * location_packer is disabled.
  * Use new lld's --pack-dyn-relocs=android.
* When lld does not work:
  * In Android.mk files use LOCAL_USE_CLANG_LLD := false.
  * In Android.bp files use use_clang_lld: false.
* Only arm, arm64, x86, and x86_64_devices have LLD flags;
  all other hosts and targets do not call lld yet.

Bug: 73768157
Test: make checkbuild and boot
Change-Id: I06b8a1e868a600997a7e70fe05c299d751d23d5f
2018-04-12 14:37:35 -07:00

178 lines
4.5 KiB
Go

// 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 config
import (
"strings"
"android/soong/android"
)
var (
mips64Cflags = []string{
"-Umips",
// Help catch common 32/64-bit errors.
"-Werror=implicit-function-declaration",
}
mips64ClangCflags = append(mips64Cflags, []string{
"-fintegrated-as",
}...)
mips64Cppflags = []string{}
mips64Ldflags = []string{
"-Wl,--allow-shlib-undefined",
}
mips64ArchVariantCflags = map[string][]string{
"mips64r2": []string{
"-mips64r2",
"-msynci",
},
"mips64r6": []string{
"-mips64r6",
"-msynci",
},
}
)
const (
mips64GccVersion = "4.9"
)
func init() {
android.RegisterArchVariants(android.Mips64,
"mips64r2",
"mips64r6")
android.RegisterArchFeatures(android.Mips64,
"rev6",
"msa")
android.RegisterArchVariantFeatures(android.Mips64, "mips64r6",
"rev6")
pctx.StaticVariable("mips64GccVersion", mips64GccVersion)
pctx.SourcePathVariable("Mips64GccRoot",
"prebuilts/gcc/${HostPrebuiltTag}/mips/mips64el-linux-android-${mips64GccVersion}")
pctx.StaticVariable("Mips64Cflags", strings.Join(mips64Cflags, " "))
pctx.StaticVariable("Mips64Ldflags", strings.Join(mips64Ldflags, " "))
pctx.StaticVariable("Mips64Cppflags", strings.Join(mips64Cppflags, " "))
pctx.StaticVariable("Mips64IncludeFlags", bionicHeaders("mips"))
// Clang cflags
pctx.StaticVariable("Mips64ClangCflags", strings.Join(ClangFilterUnknownCflags(mips64ClangCflags), " "))
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 "${config.Mips64GccRoot}"
}
func (t *toolchainMips64) GccTriple() string {
return "mips64el-linux-android"
}
func (t *toolchainMips64) GccVersion() string {
return mips64GccVersion
}
func (t *toolchainMips64) ToolchainCflags() string {
return t.toolchainCflags
}
func (t *toolchainMips64) Cflags() string {
return t.cflags
}
func (t *toolchainMips64) Cppflags() string {
return "${config.Mips64Cppflags}"
}
func (t *toolchainMips64) Ldflags() string {
return "${config.Mips64Ldflags}"
}
func (t *toolchainMips64) IncludeFlags() string {
return "${config.Mips64IncludeFlags}"
}
func (t *toolchainMips64) ClangTriple() string {
return t.GccTriple()
}
func (t *toolchainMips64) ToolchainClangCflags() string {
return t.toolchainClangCflags
}
func (t *toolchainMips64) ClangAsflags() string {
return "-fno-integrated-as"
}
func (t *toolchainMips64) ClangCflags() string {
return t.clangCflags
}
func (t *toolchainMips64) ClangCppflags() string {
return "${config.Mips64ClangCppflags}"
}
func (t *toolchainMips64) ClangLdflags() string {
return "${config.Mips64ClangLdflags}"
}
func (t *toolchainMips64) ClangLldflags() string {
// TODO: define and use Mips64ClangLldflags
return "${config.Mips64ClangLdflags}"
}
func (toolchainMips64) SanitizerRuntimeLibraryArch() string {
return "mips64"
}
func mips64ToolchainFactory(arch android.Arch) Toolchain {
return &toolchainMips64{
cflags: "${config.Mips64Cflags}",
clangCflags: "${config.Mips64ClangCflags}",
toolchainCflags: "${config.Mips64" + arch.ArchVariant + "VariantCflags}",
toolchainClangCflags: "${config.Mips64" + arch.ArchVariant + "VariantClangCflags}",
}
}
func init() {
registerToolchainFactory(android.Android, android.Mips64, mips64ToolchainFactory)
}