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.
|
|
|
|
|
2016-07-29 22:44:28 +02:00
|
|
|
package config
|
2015-01-31 02:27:36 +01:00
|
|
|
|
|
|
|
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{
|
|
|
|
// Help catch common 32/64-bit errors.
|
2016-05-07 02:13:56 +02:00
|
|
|
"-Werror=implicit-function-declaration",
|
2015-01-31 02:27:36 +01:00
|
|
|
}
|
|
|
|
|
2018-04-24 03:15:25 +02:00
|
|
|
arm64ArchVariantCflags = map[string][]string{
|
|
|
|
"armv8-a": []string{
|
|
|
|
"-march=armv8-a",
|
|
|
|
},
|
2021-01-20 18:56:33 +01:00
|
|
|
"armv8-a-branchprot": []string{
|
|
|
|
"-march=armv8-a",
|
2022-02-02 23:45:41 +01:00
|
|
|
// Disable BTI until drm vendors stop using OS libraries as sources
|
|
|
|
// of gadgets (https://issuetracker.google.com/216395195).
|
|
|
|
"-mbranch-protection=pac-ret",
|
2021-01-20 18:56:33 +01:00
|
|
|
},
|
2018-04-24 03:15:25 +02:00
|
|
|
"armv8-2a": []string{
|
2020-06-16 11:40:40 +02:00
|
|
|
"-march=armv8.2-a",
|
2018-04-24 03:15:25 +02:00
|
|
|
},
|
2020-06-18 11:56:53 +02:00
|
|
|
"armv8-2a-dotprod": []string{
|
|
|
|
"-march=armv8.2-a+dotprod",
|
|
|
|
},
|
2018-04-24 03:15:25 +02:00
|
|
|
}
|
|
|
|
|
2015-01-31 02:27:36 +01:00
|
|
|
arm64Ldflags = []string{
|
|
|
|
"-Wl,--hash-style=gnu",
|
2020-03-02 22:48:15 +01:00
|
|
|
"-Wl,-z,separate-code",
|
2015-01-31 02:27:36 +01:00
|
|
|
}
|
|
|
|
|
2021-07-15 02:03:16 +02:00
|
|
|
arm64Lldflags = append(arm64Ldflags,
|
2018-04-03 20:33:34 +02:00
|
|
|
"-Wl,-z,max-page-size=4096")
|
|
|
|
|
2017-11-06 22:59:48 +01:00
|
|
|
arm64Cppflags = []string{}
|
2016-01-15 00:17:19 +01:00
|
|
|
|
2021-07-15 02:03:16 +02:00
|
|
|
arm64CpuVariantCflags = map[string][]string{
|
2016-01-15 00:17:19 +01:00
|
|
|
"cortex-a53": []string{
|
|
|
|
"-mcpu=cortex-a53",
|
|
|
|
},
|
2018-04-24 03:15:25 +02:00
|
|
|
"cortex-a55": []string{
|
2018-06-16 00:46:11 +02:00
|
|
|
"-mcpu=cortex-a55",
|
2018-04-24 03:15:25 +02:00
|
|
|
},
|
|
|
|
"cortex-a75": []string{
|
2018-06-16 00:46:11 +02:00
|
|
|
// Use the cortex-a55 since it is similar to the little
|
2018-04-24 03:15:25 +02:00
|
|
|
// core (cortex-a55) and is sensitive to ordering.
|
2018-06-16 00:46:11 +02:00
|
|
|
"-mcpu=cortex-a55",
|
2018-04-24 03:15:25 +02:00
|
|
|
},
|
2018-10-09 23:27:28 +02:00
|
|
|
"cortex-a76": []string{
|
|
|
|
// Use the cortex-a55 since it is similar to the little
|
|
|
|
// core (cortex-a55) and is sensitive to ordering.
|
|
|
|
"-mcpu=cortex-a55",
|
|
|
|
},
|
2016-08-30 15:56:33 +02:00
|
|
|
"kryo": []string{
|
2018-10-08 06:06:36 +02:00
|
|
|
"-mcpu=kryo",
|
2016-08-30 15:56:33 +02:00
|
|
|
},
|
2018-11-15 16:21:51 +01:00
|
|
|
"kryo385": []string{
|
|
|
|
// Use cortex-a53 because kryo385 is not supported in GCC/clang.
|
|
|
|
"-mcpu=cortex-a53",
|
|
|
|
},
|
2017-07-24 00:14:55 +02:00
|
|
|
"exynos-m1": []string{
|
|
|
|
"-mcpu=exynos-m1",
|
|
|
|
},
|
2017-07-21 02:07:47 +02:00
|
|
|
"exynos-m2": []string{
|
|
|
|
"-mcpu=exynos-m2",
|
|
|
|
},
|
2016-01-15 00:17:19 +01:00
|
|
|
}
|
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
|
|
|
|
2016-07-29 22:44:28 +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
|
|
|
|
2022-03-25 15:55:40 +01:00
|
|
|
exportedVars.ExportStringListStaticVariable("Arm64Ldflags", arm64Ldflags)
|
|
|
|
exportedVars.ExportStringListStaticVariable("Arm64Lldflags", arm64Lldflags)
|
2015-01-31 02:27:36 +01:00
|
|
|
|
2022-03-25 15:55:40 +01:00
|
|
|
exportedVars.ExportStringListStaticVariable("Arm64Cflags", arm64Cflags)
|
|
|
|
exportedVars.ExportStringListStaticVariable("Arm64Cppflags", arm64Cppflags)
|
2021-08-02 16:41:48 +02:00
|
|
|
|
2022-03-25 15:55:40 +01:00
|
|
|
exportedVars.ExportVariableReferenceDict("Arm64ArchVariantCflags", arm64ArchVariantCflagsVar)
|
|
|
|
exportedVars.ExportVariableReferenceDict("Arm64CpuVariantCflags", arm64CpuVariantCflagsVar)
|
|
|
|
exportedVars.ExportVariableReferenceDict("Arm64CpuVariantLdflags", arm64CpuVariantLdflags)
|
2016-01-15 00:17:19 +01:00
|
|
|
|
2022-03-25 15:55:40 +01:00
|
|
|
exportedVars.ExportStringListStaticVariable("Arm64Armv8ACflags", arm64ArchVariantCflags["armv8-a"])
|
|
|
|
exportedVars.ExportStringListStaticVariable("Arm64Armv8ABranchProtCflags", arm64ArchVariantCflags["armv8-a-branchprot"])
|
|
|
|
exportedVars.ExportStringListStaticVariable("Arm64Armv82ACflags", arm64ArchVariantCflags["armv8-2a"])
|
|
|
|
exportedVars.ExportStringListStaticVariable("Arm64Armv82ADotprodCflags", arm64ArchVariantCflags["armv8-2a-dotprod"])
|
2018-04-24 03:15:25 +02:00
|
|
|
|
2022-03-25 15:55:40 +01:00
|
|
|
exportedVars.ExportStringListStaticVariable("Arm64CortexA53Cflags", arm64CpuVariantCflags["cortex-a53"])
|
|
|
|
exportedVars.ExportStringListStaticVariable("Arm64CortexA55Cflags", arm64CpuVariantCflags["cortex-a55"])
|
|
|
|
exportedVars.ExportStringListStaticVariable("Arm64KryoCflags", arm64CpuVariantCflags["kryo"])
|
|
|
|
exportedVars.ExportStringListStaticVariable("Arm64ExynosM1Cflags", arm64CpuVariantCflags["exynos-m1"])
|
|
|
|
exportedVars.ExportStringListStaticVariable("Arm64ExynosM2Cflags", arm64CpuVariantCflags["exynos-m2"])
|
2022-02-16 15:02:48 +01:00
|
|
|
|
2022-03-25 15:55:40 +01:00
|
|
|
exportedVars.ExportStringListStaticVariable("Arm64FixCortexA53Ldflags", []string{"-Wl,--fix-cortex-a53-843419"})
|
2015-01-31 02:27:36 +01:00
|
|
|
}
|
|
|
|
|
2016-01-15 00:17:19 +01:00
|
|
|
var (
|
2021-07-15 02:03:16 +02:00
|
|
|
arm64ArchVariantCflagsVar = map[string]string{
|
2021-07-15 03:45:05 +02:00
|
|
|
"armv8-a": "${config.Arm64Armv8ACflags}",
|
|
|
|
"armv8-a-branchprot": "${config.Arm64Armv8ABranchProtCflags}",
|
|
|
|
"armv8-2a": "${config.Arm64Armv82ACflags}",
|
|
|
|
"armv8-2a-dotprod": "${config.Arm64Armv82ADotprodCflags}",
|
2018-04-24 03:15:25 +02:00
|
|
|
}
|
|
|
|
|
2021-07-15 02:03:16 +02:00
|
|
|
arm64CpuVariantCflagsVar = map[string]string{
|
2021-07-15 03:45:05 +02:00
|
|
|
"cortex-a53": "${config.Arm64CortexA53Cflags}",
|
|
|
|
"cortex-a55": "${config.Arm64CortexA55Cflags}",
|
|
|
|
"cortex-a72": "${config.Arm64CortexA53Cflags}",
|
|
|
|
"cortex-a73": "${config.Arm64CortexA53Cflags}",
|
|
|
|
"cortex-a75": "${config.Arm64CortexA55Cflags}",
|
|
|
|
"cortex-a76": "${config.Arm64CortexA55Cflags}",
|
|
|
|
"kryo": "${config.Arm64KryoCflags}",
|
|
|
|
"kryo385": "${config.Arm64CortexA53Cflags}",
|
|
|
|
"exynos-m1": "${config.Arm64ExynosM1Cflags}",
|
|
|
|
"exynos-m2": "${config.Arm64ExynosM2Cflags}",
|
2016-01-15 00:17:19 +01:00
|
|
|
}
|
2022-02-16 15:02:48 +01:00
|
|
|
|
|
|
|
arm64CpuVariantLdflags = map[string]string{
|
|
|
|
"cortex-a53": "${config.Arm64FixCortexA53Ldflags}",
|
|
|
|
"cortex-a72": "${config.Arm64FixCortexA53Ldflags}",
|
|
|
|
"cortex-a73": "${config.Arm64FixCortexA53Ldflags}",
|
|
|
|
"kryo": "${config.Arm64FixCortexA53Ldflags}",
|
|
|
|
"exynos-m1": "${config.Arm64FixCortexA53Ldflags}",
|
|
|
|
"exynos-m2": "${config.Arm64FixCortexA53Ldflags}",
|
|
|
|
}
|
2016-01-15 00:17:19 +01:00
|
|
|
)
|
|
|
|
|
2015-01-31 02:27:36 +01:00
|
|
|
type toolchainArm64 struct {
|
2021-06-22 02:28:25 +02:00
|
|
|
toolchainBionic
|
2015-01-31 02:27:36 +01:00
|
|
|
toolchain64Bit
|
|
|
|
|
2021-07-15 02:03:16 +02:00
|
|
|
ldflags string
|
|
|
|
lldflags string
|
|
|
|
toolchainCflags string
|
2016-01-15 00:17:19 +01:00
|
|
|
}
|
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 {
|
2016-07-29 22:44:28 +02:00
|
|
|
return "${config.Arm64GccRoot}"
|
2015-01-31 02:27:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2015-01-31 02:27:36 +01:00
|
|
|
func (t *toolchainArm64) IncludeFlags() string {
|
2020-04-08 02:06:07 +02:00
|
|
|
return ""
|
2015-01-31 02:27:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func (t *toolchainArm64) ClangTriple() string {
|
2016-07-20 23:44:26 +02:00
|
|
|
return t.GccTriple()
|
2015-01-31 02:27:36 +01:00
|
|
|
}
|
|
|
|
|
2021-07-15 02:03:16 +02:00
|
|
|
func (t *toolchainArm64) Cflags() string {
|
2021-07-15 03:45:05 +02:00
|
|
|
return "${config.Arm64Cflags}"
|
2015-01-31 02:27:36 +01:00
|
|
|
}
|
|
|
|
|
2021-07-15 02:03:16 +02:00
|
|
|
func (t *toolchainArm64) Cppflags() string {
|
2021-07-15 03:45:05 +02:00
|
|
|
return "${config.Arm64Cppflags}"
|
2015-01-31 02:27:36 +01:00
|
|
|
}
|
|
|
|
|
2021-07-15 02:03:16 +02:00
|
|
|
func (t *toolchainArm64) Ldflags() string {
|
2018-05-12 03:23:54 +02:00
|
|
|
return t.ldflags
|
2015-01-31 02:27:36 +01:00
|
|
|
}
|
|
|
|
|
2021-07-15 02:03:16 +02:00
|
|
|
func (t *toolchainArm64) Lldflags() string {
|
2018-10-09 23:42:06 +02:00
|
|
|
return t.lldflags
|
2018-04-03 20:33:34 +02:00
|
|
|
}
|
|
|
|
|
2021-07-15 02:03:16 +02:00
|
|
|
func (t *toolchainArm64) ToolchainCflags() string {
|
|
|
|
return t.toolchainCflags
|
2016-01-15 00:17:19 +01:00
|
|
|
}
|
|
|
|
|
2018-08-31 23:27:44 +02:00
|
|
|
func (toolchainArm64) LibclangRuntimeLibraryArch() string {
|
2016-08-15 23:18:24 +02:00
|
|
|
return "aarch64"
|
2016-01-06 23:41:07 +01:00
|
|
|
}
|
|
|
|
|
2016-05-19 00:37:25 +02:00
|
|
|
func arm64ToolchainFactory(arch android.Arch) Toolchain {
|
2018-04-24 03:15:25 +02:00
|
|
|
switch arch.ArchVariant {
|
|
|
|
case "armv8-a":
|
2021-01-20 18:56:33 +01:00
|
|
|
case "armv8-a-branchprot":
|
2018-04-24 03:15:25 +02:00
|
|
|
case "armv8-2a":
|
2020-06-18 11:56:53 +02:00
|
|
|
case "armv8-2a-dotprod":
|
2018-04-24 03:15:25 +02:00
|
|
|
// Nothing extra for armv8-a/armv8-2a
|
|
|
|
default:
|
2016-01-15 00:17:19 +01:00
|
|
|
panic(fmt.Sprintf("Unknown ARM architecture version: %q", arch.ArchVariant))
|
|
|
|
}
|
|
|
|
|
2021-07-15 02:03:16 +02:00
|
|
|
toolchainCflags := []string{arm64ArchVariantCflagsVar[arch.ArchVariant]}
|
|
|
|
toolchainCflags = append(toolchainCflags,
|
|
|
|
variantOrDefault(arm64CpuVariantCflagsVar, arch.CpuVariant))
|
2018-04-24 03:15:25 +02:00
|
|
|
|
2022-02-16 15:02:48 +01:00
|
|
|
extraLdflags := variantOrDefault(arm64CpuVariantLdflags, arch.CpuVariant)
|
2016-01-15 00:17:19 +01:00
|
|
|
return &toolchainArm64{
|
2018-05-12 03:23:54 +02:00
|
|
|
ldflags: strings.Join([]string{
|
|
|
|
"${config.Arm64Ldflags}",
|
|
|
|
extraLdflags,
|
|
|
|
}, " "),
|
2018-10-09 23:42:06 +02:00
|
|
|
lldflags: strings.Join([]string{
|
|
|
|
"${config.Arm64Lldflags}",
|
|
|
|
extraLdflags,
|
|
|
|
}, " "),
|
2021-07-15 02:03:16 +02:00
|
|
|
toolchainCflags: strings.Join(toolchainCflags, " "),
|
2016-01-15 00:17:19 +01:00
|
|
|
}
|
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
|
|
|
}
|