2015-11-21 07:35:26 +08: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-30 04:44:28 +08:00
|
|
|
package config
|
2015-01-31 09:27:36 +08:00
|
|
|
|
|
|
|
import (
|
2016-01-15 07:17:19 +08:00
|
|
|
"fmt"
|
2015-01-31 09:27:36 +08:00
|
|
|
"strings"
|
|
|
|
|
2016-05-19 06:37:25 +08:00
|
|
|
"android/soong/android"
|
2015-01-31 09:27:36 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
arm64Cflags = []string{
|
|
|
|
// Help catch common 32/64-bit errors.
|
2016-05-07 08:13:56 +08:00
|
|
|
"-Werror=implicit-function-declaration",
|
2015-01-31 09:27:36 +08:00
|
|
|
}
|
|
|
|
|
2018-04-24 09:15:25 +08:00
|
|
|
arm64ArchVariantCflags = map[string][]string{
|
|
|
|
"armv8-a": []string{
|
|
|
|
"-march=armv8-a",
|
|
|
|
},
|
|
|
|
"armv8-2a": []string{
|
|
|
|
"-march=armv8.2a",
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2015-01-31 09:27:36 +08:00
|
|
|
arm64Ldflags = []string{
|
2017-06-27 10:22:02 +08:00
|
|
|
"-Wl,-m,aarch64_elf64_le_vec",
|
2015-01-31 09:27:36 +08:00
|
|
|
"-Wl,--hash-style=gnu",
|
2016-01-13 08:22:40 +08:00
|
|
|
"-fuse-ld=gold",
|
|
|
|
"-Wl,--icf=safe",
|
2015-01-31 09:27:36 +08:00
|
|
|
}
|
|
|
|
|
2018-04-04 02:33:34 +08:00
|
|
|
arm64Lldflags = append(ClangFilterUnknownLldflags(arm64Ldflags),
|
|
|
|
"-Wl,-z,max-page-size=4096")
|
|
|
|
|
2017-11-07 05:59:48 +08:00
|
|
|
arm64Cppflags = []string{}
|
2016-01-15 07:17:19 +08:00
|
|
|
|
|
|
|
arm64CpuVariantCflags = map[string][]string{
|
|
|
|
"cortex-a53": []string{
|
|
|
|
"-mcpu=cortex-a53",
|
|
|
|
},
|
2018-04-24 09:15:25 +08:00
|
|
|
"cortex-a55": []string{
|
2018-06-16 06:46:11 +08:00
|
|
|
"-mcpu=cortex-a55",
|
2018-04-24 09:15:25 +08:00
|
|
|
},
|
|
|
|
"cortex-a75": []string{
|
2018-06-16 06:46:11 +08:00
|
|
|
// Use the cortex-a55 since it is similar to the little
|
2018-04-24 09:15:25 +08:00
|
|
|
// core (cortex-a55) and is sensitive to ordering.
|
2018-06-16 06:46:11 +08:00
|
|
|
"-mcpu=cortex-a55",
|
2018-04-24 09:15:25 +08:00
|
|
|
},
|
2016-08-30 21:56:33 +08:00
|
|
|
"kryo": []string{
|
2017-04-06 02:08:41 +08:00
|
|
|
// Use the cortex-a57 cpu since some compilers
|
|
|
|
// don't support a Kryo specific target yet.
|
2016-08-30 21:56:33 +08:00
|
|
|
"-mcpu=cortex-a57",
|
|
|
|
},
|
2017-07-24 06:14:55 +08:00
|
|
|
"exynos-m1": []string{
|
|
|
|
"-mcpu=exynos-m1",
|
|
|
|
},
|
2017-07-21 08:07:47 +08:00
|
|
|
"exynos-m2": []string{
|
|
|
|
"-mcpu=exynos-m2",
|
|
|
|
},
|
2016-01-15 07:17:19 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
arm64ClangCpuVariantCflags = copyVariantFlags(arm64CpuVariantCflags)
|
2015-01-31 09:27:36 +08:00
|
|
|
)
|
|
|
|
|
2015-12-08 04:30:44 +08:00
|
|
|
const (
|
|
|
|
arm64GccVersion = "4.9"
|
|
|
|
)
|
|
|
|
|
2015-01-31 09:27:36 +08:00
|
|
|
func init() {
|
2016-06-24 14:44:54 +08:00
|
|
|
android.RegisterArchVariants(android.Arm64,
|
|
|
|
"armv8_a",
|
2018-04-24 09:15:25 +08:00
|
|
|
"armv8_2a",
|
2017-05-09 03:08:40 +08:00
|
|
|
"cortex-a53",
|
2018-04-24 09:15:25 +08:00
|
|
|
"cortex-a55",
|
2017-05-09 03:08:40 +08:00
|
|
|
"cortex-a73",
|
2018-04-24 09:15:25 +08:00
|
|
|
"cortex-a75",
|
2016-08-30 21:56:33 +08:00
|
|
|
"kryo",
|
2017-07-24 06:14:55 +08:00
|
|
|
"exynos-m1",
|
2017-07-21 08:07:47 +08:00
|
|
|
"exynos-m2",
|
2016-06-24 14:44:54 +08:00
|
|
|
"denver64")
|
|
|
|
|
2017-04-06 02:08:41 +08:00
|
|
|
// Clang supports specific Kryo targeting
|
|
|
|
replaceFirst(arm64ClangCpuVariantCflags["kryo"], "-mcpu=cortex-a57", "-mcpu=kryo")
|
|
|
|
|
2015-12-08 04:30:44 +08:00
|
|
|
pctx.StaticVariable("arm64GccVersion", arm64GccVersion)
|
2015-01-31 09:27:36 +08:00
|
|
|
|
2016-07-30 04:44:28 +08:00
|
|
|
pctx.SourcePathVariable("Arm64GccRoot",
|
2015-07-14 15:39:06 +08:00
|
|
|
"prebuilts/gcc/${HostPrebuiltTag}/aarch64/aarch64-linux-android-${arm64GccVersion}")
|
2015-01-31 09:27:36 +08:00
|
|
|
|
2016-07-30 04:44:28 +08:00
|
|
|
pctx.StaticVariable("Arm64Cflags", strings.Join(arm64Cflags, " "))
|
|
|
|
pctx.StaticVariable("Arm64Ldflags", strings.Join(arm64Ldflags, " "))
|
2018-04-04 02:33:34 +08:00
|
|
|
pctx.StaticVariable("Arm64Lldflags", strings.Join(arm64Lldflags, " "))
|
2016-07-30 04:44:28 +08:00
|
|
|
pctx.StaticVariable("Arm64Cppflags", strings.Join(arm64Cppflags, " "))
|
2017-10-13 00:07:53 +08:00
|
|
|
pctx.StaticVariable("Arm64IncludeFlags", bionicHeaders("arm64"))
|
2015-01-31 09:27:36 +08:00
|
|
|
|
2016-07-30 04:44:28 +08:00
|
|
|
pctx.StaticVariable("Arm64ClangCflags", strings.Join(ClangFilterUnknownCflags(arm64Cflags), " "))
|
|
|
|
pctx.StaticVariable("Arm64ClangLdflags", strings.Join(ClangFilterUnknownCflags(arm64Ldflags), " "))
|
2018-04-04 02:33:34 +08:00
|
|
|
pctx.StaticVariable("Arm64ClangLldflags", strings.Join(ClangFilterUnknownCflags(arm64Lldflags), " "))
|
2016-07-30 04:44:28 +08:00
|
|
|
pctx.StaticVariable("Arm64ClangCppflags", strings.Join(ClangFilterUnknownCflags(arm64Cppflags), " "))
|
2016-01-15 07:17:19 +08:00
|
|
|
|
2018-04-24 09:15:25 +08:00
|
|
|
pctx.StaticVariable("Arm64ClangArmv8ACflags", strings.Join(arm64ArchVariantCflags["armv8-a"], " "))
|
|
|
|
pctx.StaticVariable("Arm64ClangArmv82ACflags", strings.Join(arm64ArchVariantCflags["armv8-2a"], " "))
|
|
|
|
|
2016-07-30 04:44:28 +08:00
|
|
|
pctx.StaticVariable("Arm64CortexA53Cflags",
|
2016-01-15 07:17:19 +08:00
|
|
|
strings.Join(arm64CpuVariantCflags["cortex-a53"], " "))
|
2016-07-30 04:44:28 +08:00
|
|
|
pctx.StaticVariable("Arm64ClangCortexA53Cflags",
|
2016-01-15 07:17:19 +08:00
|
|
|
strings.Join(arm64ClangCpuVariantCflags["cortex-a53"], " "))
|
2016-08-30 21:56:33 +08:00
|
|
|
|
2018-04-24 09:15:25 +08:00
|
|
|
pctx.StaticVariable("Arm64CortexA55Cflags",
|
|
|
|
strings.Join(arm64CpuVariantCflags["cortex-a55"], " "))
|
|
|
|
pctx.StaticVariable("Arm64ClangCortexA55Cflags",
|
|
|
|
strings.Join(arm64ClangCpuVariantCflags["cortex-a55"], " "))
|
|
|
|
|
2016-08-30 21:56:33 +08:00
|
|
|
pctx.StaticVariable("Arm64KryoCflags",
|
|
|
|
strings.Join(arm64CpuVariantCflags["kryo"], " "))
|
|
|
|
pctx.StaticVariable("Arm64ClangKryoCflags",
|
|
|
|
strings.Join(arm64ClangCpuVariantCflags["kryo"], " "))
|
2017-07-21 08:07:47 +08:00
|
|
|
|
2017-07-24 06:14:55 +08:00
|
|
|
pctx.StaticVariable("Arm64ExynosM1Cflags",
|
|
|
|
strings.Join(arm64CpuVariantCflags["cortex-a53"], " "))
|
|
|
|
pctx.StaticVariable("Arm64ClangExynosM1Cflags",
|
|
|
|
strings.Join(arm64ClangCpuVariantCflags["exynos-m1"], " "))
|
|
|
|
|
2017-07-21 08:07:47 +08:00
|
|
|
pctx.StaticVariable("Arm64ExynosM2Cflags",
|
|
|
|
strings.Join(arm64CpuVariantCflags["cortex-a53"], " "))
|
|
|
|
pctx.StaticVariable("Arm64ClangExynosM2Cflags",
|
|
|
|
strings.Join(arm64ClangCpuVariantCflags["exynos-m2"], " "))
|
2015-01-31 09:27:36 +08:00
|
|
|
}
|
|
|
|
|
2016-01-15 07:17:19 +08:00
|
|
|
var (
|
|
|
|
arm64CpuVariantCflagsVar = map[string]string{
|
|
|
|
"": "",
|
2016-07-30 04:44:28 +08:00
|
|
|
"cortex-a53": "${config.Arm64CortexA53Cflags}",
|
2018-04-24 09:15:25 +08:00
|
|
|
"cortex-a55": "${config.Arm64CortexA55Cflags}",
|
2017-05-09 03:08:40 +08:00
|
|
|
"cortex-a73": "${config.Arm64CortexA53Cflags}",
|
2018-04-24 09:15:25 +08:00
|
|
|
"cortex-a75": "${config.Arm64CortexA55Cflags}",
|
2016-08-30 21:56:33 +08:00
|
|
|
"kryo": "${config.Arm64KryoCflags}",
|
2017-07-24 06:14:55 +08:00
|
|
|
"exynos-m1": "${config.Arm64ExynosM1Cflags}",
|
2017-07-21 08:07:47 +08:00
|
|
|
"exynos-m2": "${config.Arm64ExynosM2Cflags}",
|
2016-01-15 07:17:19 +08:00
|
|
|
}
|
|
|
|
|
2018-04-24 09:15:25 +08:00
|
|
|
arm64ClangArchVariantCflagsVar = map[string]string{
|
|
|
|
"armv8-a": "${config.Arm64ClangArmv8ACflags}",
|
|
|
|
"armv8-2a": "${config.Arm64ClangArmv82ACflags}",
|
|
|
|
}
|
|
|
|
|
2016-01-15 07:17:19 +08:00
|
|
|
arm64ClangCpuVariantCflagsVar = map[string]string{
|
|
|
|
"": "",
|
2016-07-30 04:44:28 +08:00
|
|
|
"cortex-a53": "${config.Arm64ClangCortexA53Cflags}",
|
2018-04-24 09:15:25 +08:00
|
|
|
"cortex-a55": "${config.Arm64ClangCortexA55Cflags}",
|
2017-05-09 03:08:40 +08:00
|
|
|
"cortex-a73": "${config.Arm64ClangCortexA53Cflags}",
|
2018-04-24 09:15:25 +08:00
|
|
|
"cortex-a75": "${config.Arm64ClangCortexA55Cflags}",
|
2016-08-30 21:56:33 +08:00
|
|
|
"kryo": "${config.Arm64ClangKryoCflags}",
|
2017-07-24 06:14:55 +08:00
|
|
|
"exynos-m1": "${config.Arm64ClangExynosM1Cflags}",
|
2017-07-21 08:07:47 +08:00
|
|
|
"exynos-m2": "${config.Arm64ClangExynosM2Cflags}",
|
2016-01-15 07:17:19 +08:00
|
|
|
}
|
|
|
|
)
|
|
|
|
|
2015-01-31 09:27:36 +08:00
|
|
|
type toolchainArm64 struct {
|
|
|
|
toolchain64Bit
|
|
|
|
|
2018-05-12 09:23:54 +08:00
|
|
|
ldflags string
|
2016-01-15 07:17:19 +08:00
|
|
|
toolchainCflags string
|
|
|
|
toolchainClangCflags string
|
|
|
|
}
|
2015-01-31 09:27:36 +08:00
|
|
|
|
2015-03-19 14:38:50 +08:00
|
|
|
func (t *toolchainArm64) Name() string {
|
|
|
|
return "arm64"
|
|
|
|
}
|
|
|
|
|
2015-01-31 09:27:36 +08:00
|
|
|
func (t *toolchainArm64) GccRoot() string {
|
2016-07-30 04:44:28 +08:00
|
|
|
return "${config.Arm64GccRoot}"
|
2015-01-31 09:27:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (t *toolchainArm64) GccTriple() string {
|
2016-07-21 05:44:26 +08:00
|
|
|
return "aarch64-linux-android"
|
2015-01-31 09:27:36 +08:00
|
|
|
}
|
|
|
|
|
2015-03-19 14:38:50 +08:00
|
|
|
func (t *toolchainArm64) GccVersion() string {
|
2015-12-08 04:30:44 +08:00
|
|
|
return arm64GccVersion
|
2015-03-19 14:38:50 +08:00
|
|
|
}
|
|
|
|
|
2016-01-15 07:17:19 +08:00
|
|
|
func (t *toolchainArm64) ToolchainCflags() string {
|
|
|
|
return t.toolchainCflags
|
|
|
|
}
|
|
|
|
|
2015-01-31 09:27:36 +08:00
|
|
|
func (t *toolchainArm64) Cflags() string {
|
2016-07-30 04:44:28 +08:00
|
|
|
return "${config.Arm64Cflags}"
|
2015-01-31 09:27:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (t *toolchainArm64) Cppflags() string {
|
2016-07-30 04:44:28 +08:00
|
|
|
return "${config.Arm64Cppflags}"
|
2015-01-31 09:27:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (t *toolchainArm64) Ldflags() string {
|
2018-05-12 09:23:54 +08:00
|
|
|
return t.ldflags
|
2015-01-31 09:27:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (t *toolchainArm64) IncludeFlags() string {
|
2016-07-30 04:44:28 +08:00
|
|
|
return "${config.Arm64IncludeFlags}"
|
2015-01-31 09:27:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (t *toolchainArm64) ClangTriple() string {
|
2016-07-21 05:44:26 +08:00
|
|
|
return t.GccTriple()
|
2015-01-31 09:27:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (t *toolchainArm64) ClangCflags() string {
|
2016-07-30 04:44:28 +08:00
|
|
|
return "${config.Arm64ClangCflags}"
|
2015-01-31 09:27:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (t *toolchainArm64) ClangCppflags() string {
|
2016-07-30 04:44:28 +08:00
|
|
|
return "${config.Arm64ClangCppflags}"
|
2015-01-31 09:27:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (t *toolchainArm64) ClangLdflags() string {
|
2018-05-12 09:23:54 +08:00
|
|
|
return t.ldflags
|
2015-01-31 09:27:36 +08:00
|
|
|
}
|
|
|
|
|
2018-04-04 02:33:34 +08:00
|
|
|
func (t *toolchainArm64) ClangLldflags() string {
|
|
|
|
return "${config.Arm64Lldflags}"
|
|
|
|
}
|
|
|
|
|
2016-01-15 07:17:19 +08:00
|
|
|
func (t *toolchainArm64) ToolchainClangCflags() string {
|
|
|
|
return t.toolchainClangCflags
|
|
|
|
}
|
|
|
|
|
2018-09-01 05:27:44 +08:00
|
|
|
func (toolchainArm64) LibclangRuntimeLibraryArch() string {
|
2016-08-16 05:18:24 +08:00
|
|
|
return "aarch64"
|
2016-01-07 06:41:07 +08:00
|
|
|
}
|
|
|
|
|
2016-05-19 06:37:25 +08:00
|
|
|
func arm64ToolchainFactory(arch android.Arch) Toolchain {
|
2018-04-24 09:15:25 +08:00
|
|
|
switch arch.ArchVariant {
|
|
|
|
case "armv8-a":
|
|
|
|
case "armv8-2a":
|
|
|
|
// Nothing extra for armv8-a/armv8-2a
|
|
|
|
default:
|
2016-01-15 07:17:19 +08:00
|
|
|
panic(fmt.Sprintf("Unknown ARM architecture version: %q", arch.ArchVariant))
|
|
|
|
}
|
|
|
|
|
2018-04-24 09:15:25 +08:00
|
|
|
toolchainClangCflags := []string{arm64ClangArchVariantCflagsVar[arch.ArchVariant]}
|
|
|
|
toolchainClangCflags = append(toolchainClangCflags,
|
|
|
|
variantOrDefault(arm64ClangCpuVariantCflagsVar, arch.CpuVariant))
|
|
|
|
|
2018-05-12 09:23:54 +08:00
|
|
|
var extraLdflags string
|
|
|
|
switch arch.CpuVariant {
|
|
|
|
case "cortex-a53", "cortex-a73", "kryo", "exynos-m1", "exynos-m2",
|
|
|
|
// This variant might not need the workaround but leave it
|
|
|
|
// in the list since it has had the workaround on before.
|
|
|
|
"denver64":
|
|
|
|
extraLdflags = "-Wl,--fix-cortex-a53-843419"
|
|
|
|
}
|
|
|
|
|
2016-01-15 07:17:19 +08:00
|
|
|
return &toolchainArm64{
|
2018-05-12 09:23:54 +08:00
|
|
|
ldflags: strings.Join([]string{
|
|
|
|
"${config.Arm64Ldflags}",
|
|
|
|
extraLdflags,
|
|
|
|
}, " "),
|
2016-01-15 07:17:19 +08:00
|
|
|
toolchainCflags: variantOrDefault(arm64CpuVariantCflagsVar, arch.CpuVariant),
|
2018-04-24 09:15:25 +08:00
|
|
|
toolchainClangCflags: strings.Join(toolchainClangCflags, " "),
|
2016-01-15 07:17:19 +08:00
|
|
|
}
|
2015-01-31 09:27:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func init() {
|
2016-06-02 08:09:44 +08:00
|
|
|
registerToolchainFactory(android.Android, android.Arm64, arm64ToolchainFactory)
|
2015-01-31 09:27:36 +08:00
|
|
|
}
|