2015-11-21 00:35:26 +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.
|
|
|
|
|
2015-01-31 02:27:36 +01:00
|
|
|
package cc
|
|
|
|
|
|
|
|
import (
|
2016-01-15 00:17:19 +01:00
|
|
|
"fmt"
|
2015-01-31 02:27:36 +01:00
|
|
|
"strings"
|
|
|
|
|
2016-05-19 00:37:25 +02:00
|
|
|
"android/soong/android"
|
2015-01-31 02:27:36 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
arm64Cflags = []string{
|
|
|
|
"-fno-exceptions", // from build/core/combo/select.mk
|
|
|
|
"-Wno-multichar", // from build/core/combo/select.mk
|
|
|
|
"-fno-strict-aliasing",
|
2016-01-13 01:22:40 +01:00
|
|
|
"-fstack-protector-strong",
|
2015-01-31 02:27:36 +01:00
|
|
|
"-ffunction-sections",
|
|
|
|
"-fdata-sections",
|
|
|
|
"-funwind-tables",
|
|
|
|
"-Wa,--noexecstack",
|
|
|
|
"-Werror=format-security",
|
|
|
|
"-D_FORTIFY_SOURCE=2",
|
|
|
|
"-fno-short-enums",
|
|
|
|
"-no-canonical-prefixes",
|
|
|
|
"-fno-canonical-system-headers",
|
|
|
|
|
|
|
|
// Help catch common 32/64-bit errors.
|
|
|
|
"-Werror=pointer-to-int-cast",
|
|
|
|
"-Werror=int-to-pointer-cast",
|
2016-05-07 02:13:56 +02:00
|
|
|
"-Werror=implicit-function-declaration",
|
2015-01-31 02:27:36 +01:00
|
|
|
|
|
|
|
"-fno-strict-volatile-bitfields",
|
|
|
|
|
|
|
|
// TARGET_RELEASE_CFLAGS
|
|
|
|
"-DNDEBUG",
|
|
|
|
"-O2 -g",
|
|
|
|
"-Wstrict-aliasing=2",
|
|
|
|
"-fgcse-after-reload",
|
|
|
|
"-frerun-cse-after-loop",
|
|
|
|
"-frename-registers",
|
|
|
|
}
|
|
|
|
|
|
|
|
arm64Ldflags = []string{
|
|
|
|
"-Wl,-z,noexecstack",
|
|
|
|
"-Wl,-z,relro",
|
|
|
|
"-Wl,-z,now",
|
|
|
|
"-Wl,--build-id=md5",
|
|
|
|
"-Wl,--warn-shared-textrel",
|
|
|
|
"-Wl,--fatal-warnings",
|
|
|
|
"-Wl,-maarch64linux",
|
|
|
|
"-Wl,--hash-style=gnu",
|
2015-09-12 02:41:10 +02:00
|
|
|
"-Wl,--fix-cortex-a53-843419",
|
2016-01-13 01:22:40 +01:00
|
|
|
"-fuse-ld=gold",
|
|
|
|
"-Wl,--icf=safe",
|
2015-12-09 22:05:28 +01:00
|
|
|
"-Wl,--no-undefined-version",
|
2015-01-31 02:27:36 +01:00
|
|
|
|
|
|
|
// Disable transitive dependency library symbol resolving.
|
|
|
|
"-Wl,--allow-shlib-undefined",
|
|
|
|
}
|
|
|
|
|
|
|
|
arm64Cppflags = []string{
|
|
|
|
"-fvisibility-inlines-hidden",
|
|
|
|
}
|
2016-01-15 00:17:19 +01:00
|
|
|
|
|
|
|
arm64CpuVariantCflags = map[string][]string{
|
|
|
|
"cortex-a53": []string{
|
|
|
|
"-mcpu=cortex-a53",
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
arm64ClangCpuVariantCflags = copyVariantFlags(arm64CpuVariantCflags)
|
2015-01-31 02:27:36 +01:00
|
|
|
)
|
|
|
|
|
2015-12-07 21:30:44 +01:00
|
|
|
const (
|
|
|
|
arm64GccVersion = "4.9"
|
|
|
|
)
|
|
|
|
|
2015-01-31 02:27:36 +01:00
|
|
|
func init() {
|
2015-12-07 21:30:44 +01:00
|
|
|
pctx.StaticVariable("arm64GccVersion", arm64GccVersion)
|
2015-01-31 02:27:36 +01:00
|
|
|
|
2015-09-24 00:26:20 +02:00
|
|
|
pctx.SourcePathVariable("arm64GccRoot",
|
2015-07-14 09:39:06 +02:00
|
|
|
"prebuilts/gcc/${HostPrebuiltTag}/aarch64/aarch64-linux-android-${arm64GccVersion}")
|
2015-01-31 02:27:36 +01:00
|
|
|
|
|
|
|
pctx.StaticVariable("arm64Cflags", strings.Join(arm64Cflags, " "))
|
|
|
|
pctx.StaticVariable("arm64Ldflags", strings.Join(arm64Ldflags, " "))
|
|
|
|
pctx.StaticVariable("arm64Cppflags", strings.Join(arm64Cppflags, " "))
|
2016-07-21 20:14:12 +02:00
|
|
|
pctx.StaticVariable("arm64IncludeFlags", bionicHeaders("arm64", "arm64"))
|
2015-01-31 02:27:36 +01:00
|
|
|
|
|
|
|
pctx.StaticVariable("arm64ClangCflags", strings.Join(clangFilterUnknownCflags(arm64Cflags), " "))
|
|
|
|
pctx.StaticVariable("arm64ClangLdflags", strings.Join(clangFilterUnknownCflags(arm64Ldflags), " "))
|
|
|
|
pctx.StaticVariable("arm64ClangCppflags", strings.Join(clangFilterUnknownCflags(arm64Cppflags), " "))
|
2016-01-15 00:17:19 +01:00
|
|
|
|
|
|
|
pctx.StaticVariable("arm64CortexA53Cflags",
|
|
|
|
strings.Join(arm64CpuVariantCflags["cortex-a53"], " "))
|
|
|
|
pctx.StaticVariable("arm64ClangCortexA53Cflags",
|
|
|
|
strings.Join(arm64ClangCpuVariantCflags["cortex-a53"], " "))
|
2015-01-31 02:27:36 +01:00
|
|
|
}
|
|
|
|
|
2016-01-15 00:17:19 +01:00
|
|
|
var (
|
|
|
|
arm64CpuVariantCflagsVar = map[string]string{
|
|
|
|
"": "",
|
|
|
|
"cortex-a53": "${arm64CortexA53Cflags}",
|
|
|
|
}
|
|
|
|
|
|
|
|
arm64ClangCpuVariantCflagsVar = map[string]string{
|
|
|
|
"": "",
|
|
|
|
"cortex-a53": "${arm64ClangCortexA53Cflags}",
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
2015-01-31 02:27:36 +01:00
|
|
|
type toolchainArm64 struct {
|
|
|
|
toolchain64Bit
|
|
|
|
|
2016-01-15 00:17:19 +01:00
|
|
|
toolchainCflags string
|
|
|
|
toolchainClangCflags string
|
|
|
|
}
|
2015-01-31 02:27:36 +01:00
|
|
|
|
2015-03-19 07:38:50 +01:00
|
|
|
func (t *toolchainArm64) Name() string {
|
|
|
|
return "arm64"
|
|
|
|
}
|
|
|
|
|
2015-01-31 02:27:36 +01:00
|
|
|
func (t *toolchainArm64) GccRoot() string {
|
|
|
|
return "${arm64GccRoot}"
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *toolchainArm64) GccTriple() string {
|
2016-07-20 23:44:26 +02:00
|
|
|
return "aarch64-linux-android"
|
2015-01-31 02:27:36 +01:00
|
|
|
}
|
|
|
|
|
2015-03-19 07:38:50 +01:00
|
|
|
func (t *toolchainArm64) GccVersion() string {
|
2015-12-07 21:30:44 +01:00
|
|
|
return arm64GccVersion
|
2015-03-19 07:38:50 +01:00
|
|
|
}
|
|
|
|
|
2016-01-15 00:17:19 +01:00
|
|
|
func (t *toolchainArm64) ToolchainCflags() string {
|
|
|
|
return t.toolchainCflags
|
|
|
|
}
|
|
|
|
|
2015-01-31 02:27:36 +01:00
|
|
|
func (t *toolchainArm64) Cflags() string {
|
2015-04-22 22:07:53 +02:00
|
|
|
return "${arm64Cflags}"
|
2015-01-31 02:27:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func (t *toolchainArm64) Cppflags() string {
|
|
|
|
return "${arm64Cppflags}"
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *toolchainArm64) Ldflags() string {
|
|
|
|
return "${arm64Ldflags}"
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *toolchainArm64) IncludeFlags() string {
|
|
|
|
return "${arm64IncludeFlags}"
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *toolchainArm64) ClangTriple() string {
|
2016-07-20 23:44:26 +02:00
|
|
|
return t.GccTriple()
|
2015-01-31 02:27:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func (t *toolchainArm64) ClangCflags() string {
|
|
|
|
return "${arm64ClangCflags}"
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *toolchainArm64) ClangCppflags() string {
|
|
|
|
return "${arm64ClangCppflags}"
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *toolchainArm64) ClangLdflags() string {
|
|
|
|
return "${arm64Ldflags}"
|
|
|
|
}
|
|
|
|
|
2016-01-15 00:17:19 +01:00
|
|
|
func (t *toolchainArm64) ToolchainClangCflags() string {
|
|
|
|
return t.toolchainClangCflags
|
|
|
|
}
|
|
|
|
|
2016-01-06 23:41:07 +01:00
|
|
|
func (toolchainArm64) AddressSanitizerRuntimeLibrary() string {
|
|
|
|
return "libclang_rt.asan-aarch64-android.so"
|
|
|
|
}
|
|
|
|
|
2016-05-19 00:37:25 +02:00
|
|
|
func arm64ToolchainFactory(arch android.Arch) Toolchain {
|
2016-01-15 00:17:19 +01:00
|
|
|
if arch.ArchVariant != "armv8-a" {
|
|
|
|
panic(fmt.Sprintf("Unknown ARM architecture version: %q", arch.ArchVariant))
|
|
|
|
}
|
|
|
|
|
|
|
|
return &toolchainArm64{
|
|
|
|
toolchainCflags: variantOrDefault(arm64CpuVariantCflagsVar, arch.CpuVariant),
|
|
|
|
toolchainClangCflags: variantOrDefault(arm64ClangCpuVariantCflagsVar, arch.CpuVariant),
|
|
|
|
}
|
2015-01-31 02:27:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func init() {
|
2016-06-02 02:09:44 +02:00
|
|
|
registerToolchainFactory(android.Android, android.Arm64, arm64ToolchainFactory)
|
2015-01-31 02:27:36 +01:00
|
|
|
}
|