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 (
|
|
|
|
"fmt"
|
|
|
|
"strings"
|
|
|
|
|
2016-05-19 06:37:25 +08:00
|
|
|
"android/soong/android"
|
2015-01-31 09:27:36 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
2015-11-24 08:11:30 +08:00
|
|
|
armToolchainCflags = []string{
|
|
|
|
"-mthumb-interwork",
|
2016-05-19 13:52:25 +08:00
|
|
|
"-msoft-float",
|
2015-11-24 08:11:30 +08:00
|
|
|
}
|
|
|
|
|
2015-01-31 09:27:36 +08:00
|
|
|
armCflags = []string{
|
|
|
|
"-fno-exceptions", // from build/core/combo/select.mk
|
|
|
|
"-Wno-multichar", // from build/core/combo/select.mk
|
|
|
|
"-ffunction-sections",
|
|
|
|
"-fdata-sections",
|
|
|
|
"-funwind-tables",
|
2016-01-13 08:22:40 +08:00
|
|
|
"-fstack-protector-strong",
|
2015-01-31 09:27:36 +08:00
|
|
|
"-Wa,--noexecstack",
|
|
|
|
"-Werror=format-security",
|
|
|
|
"-D_FORTIFY_SOURCE=2",
|
|
|
|
"-fno-short-enums",
|
|
|
|
"-no-canonical-prefixes",
|
|
|
|
"-fno-canonical-system-headers",
|
|
|
|
|
|
|
|
"-fno-builtin-sin",
|
|
|
|
"-fno-strict-volatile-bitfields",
|
|
|
|
|
|
|
|
// TARGET_RELEASE_CFLAGS
|
|
|
|
"-DNDEBUG",
|
|
|
|
"-g",
|
|
|
|
"-Wstrict-aliasing=2",
|
|
|
|
"-fgcse-after-reload",
|
|
|
|
"-frerun-cse-after-loop",
|
|
|
|
"-frename-registers",
|
|
|
|
}
|
|
|
|
|
|
|
|
armCppflags = []string{
|
|
|
|
"-fvisibility-inlines-hidden",
|
|
|
|
}
|
|
|
|
|
|
|
|
armLdflags = []string{
|
|
|
|
"-Wl,-z,noexecstack",
|
|
|
|
"-Wl,-z,relro",
|
|
|
|
"-Wl,-z,now",
|
|
|
|
"-Wl,--build-id=md5",
|
|
|
|
"-Wl,--warn-shared-textrel",
|
|
|
|
"-Wl,--fatal-warnings",
|
2015-03-17 07:12:05 +08:00
|
|
|
"-Wl,--icf=safe",
|
2015-01-31 09:27:36 +08:00
|
|
|
"-Wl,--hash-style=gnu",
|
2015-12-10 05:05:28 +08:00
|
|
|
"-Wl,--no-undefined-version",
|
2015-01-31 09:27:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
armArmCflags = []string{
|
|
|
|
"-O2",
|
|
|
|
"-fomit-frame-pointer",
|
|
|
|
"-fstrict-aliasing",
|
|
|
|
"-funswitch-loops",
|
|
|
|
}
|
|
|
|
|
|
|
|
armThumbCflags = []string{
|
|
|
|
"-mthumb",
|
|
|
|
"-Os",
|
|
|
|
"-fomit-frame-pointer",
|
|
|
|
"-fno-strict-aliasing",
|
|
|
|
}
|
|
|
|
|
|
|
|
armArchVariantCflags = map[string][]string{
|
|
|
|
"armv5te": []string{
|
|
|
|
"-march=armv5te",
|
|
|
|
"-mtune=xscale",
|
|
|
|
"-D__ARM_ARCH_5__",
|
|
|
|
"-D__ARM_ARCH_5T__",
|
|
|
|
"-D__ARM_ARCH_5E__",
|
|
|
|
"-D__ARM_ARCH_5TE__",
|
|
|
|
},
|
|
|
|
"armv7-a": []string{
|
|
|
|
"-march=armv7-a",
|
|
|
|
"-mfloat-abi=softfp",
|
|
|
|
"-mfpu=vfpv3-d16",
|
|
|
|
},
|
|
|
|
"armv7-a-neon": []string{
|
|
|
|
"-mfloat-abi=softfp",
|
|
|
|
"-mfpu=neon",
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
armCpuVariantCflags = map[string][]string{
|
2016-01-15 07:17:19 +08:00
|
|
|
"": []string{
|
|
|
|
"-march=armv7-a",
|
|
|
|
},
|
2015-01-31 09:27:36 +08:00
|
|
|
"cortex-a7": []string{
|
|
|
|
"-mcpu=cortex-a7",
|
2016-03-30 06:47:08 +08:00
|
|
|
// Fake an ARM compiler flag as these processors support LPAE which GCC/clang
|
|
|
|
// don't advertise.
|
|
|
|
// TODO This is a hack and we need to add it for each processor that supports LPAE until some
|
|
|
|
// better solution comes around. See Bug 27340895
|
|
|
|
"-D__ARM_FEATURE_LPAE=1",
|
2015-01-31 09:27:36 +08:00
|
|
|
},
|
|
|
|
"cortex-a8": []string{
|
|
|
|
"-mcpu=cortex-a8",
|
|
|
|
},
|
|
|
|
"cortex-a15": []string{
|
|
|
|
"-mcpu=cortex-a15",
|
|
|
|
// Fake an ARM compiler flag as these processors support LPAE which GCC/clang
|
|
|
|
// don't advertise.
|
2016-03-30 06:47:08 +08:00
|
|
|
// TODO This is a hack and we need to add it for each processor that supports LPAE until some
|
|
|
|
// better solution comes around. See Bug 27340895
|
2015-01-31 09:27:36 +08:00
|
|
|
"-D__ARM_FEATURE_LPAE=1",
|
|
|
|
},
|
2016-05-10 04:39:58 +08:00
|
|
|
"krait": []string{
|
|
|
|
"-mcpu=cortex-a15",
|
2017-04-07 08:38:26 +08:00
|
|
|
"-mfpu=neon-vfpv4",
|
2016-05-10 04:39:58 +08:00
|
|
|
// Fake an ARM compiler flag as these processors support LPAE which GCC/clang
|
|
|
|
// don't advertise.
|
|
|
|
// TODO This is a hack and we need to add it for each processor that supports LPAE until some
|
|
|
|
// better solution comes around. See Bug 27340895
|
|
|
|
"-D__ARM_FEATURE_LPAE=1",
|
|
|
|
},
|
2016-08-20 06:14:56 +08:00
|
|
|
"kryo": []string{
|
|
|
|
"-mcpu=cortex-a15",
|
2017-04-07 08:28:05 +08:00
|
|
|
"-mfpu=neon-fp-armv8",
|
2016-08-20 06:14:56 +08:00
|
|
|
// Fake an ARM compiler flag as these processors support LPAE which GCC/clang
|
|
|
|
// don't advertise.
|
|
|
|
// TODO This is a hack and we need to add it for each processor that supports LPAE until some
|
|
|
|
// better solution comes around. See Bug 27340895
|
|
|
|
"-D__ARM_FEATURE_LPAE=1",
|
|
|
|
},
|
2015-01-31 09:27:36 +08:00
|
|
|
}
|
|
|
|
|
2015-07-14 04:28:18 +08:00
|
|
|
armClangCpuVariantCflags = copyVariantFlags(armCpuVariantCflags)
|
|
|
|
armClangArchVariantCflags = copyVariantFlags(armArchVariantCflags)
|
2015-01-31 09:27:36 +08:00
|
|
|
)
|
|
|
|
|
2015-12-08 04:30:44 +08:00
|
|
|
const (
|
|
|
|
armGccVersion = "4.9"
|
|
|
|
)
|
|
|
|
|
2015-01-31 09:27:36 +08:00
|
|
|
func init() {
|
2016-06-24 14:44:54 +08:00
|
|
|
android.RegisterArchVariants(android.Arm,
|
|
|
|
"armv5te",
|
|
|
|
"armv7_a",
|
|
|
|
"armv7_a_neon",
|
|
|
|
"cortex_a7",
|
|
|
|
"cortex_a8",
|
|
|
|
"cortex_a9",
|
|
|
|
"cortex_a15",
|
|
|
|
"cortex_a53",
|
|
|
|
"cortex_a53_a57",
|
|
|
|
"krait",
|
2016-08-20 06:14:56 +08:00
|
|
|
"kryo",
|
2016-06-24 14:44:54 +08:00
|
|
|
"denver")
|
|
|
|
|
2017-04-07 08:38:26 +08:00
|
|
|
// Krait and Kryo targets are not supported by GCC, but are supported by Clang,
|
|
|
|
// so override the definitions when building modules with Clang.
|
2016-05-10 04:39:58 +08:00
|
|
|
replaceFirst(armClangCpuVariantCflags["krait"], "-mcpu=cortex-a15", "-mcpu=krait")
|
2016-08-20 06:14:56 +08:00
|
|
|
replaceFirst(armClangCpuVariantCflags["kryo"], "-mcpu=cortex-a15", "-mcpu=krait")
|
|
|
|
|
2015-12-08 04:30:44 +08:00
|
|
|
pctx.StaticVariable("armGccVersion", armGccVersion)
|
2015-01-31 09:27:36 +08:00
|
|
|
|
2016-07-30 04:44:28 +08:00
|
|
|
pctx.SourcePathVariable("ArmGccRoot",
|
2015-07-14 15:39:06 +08:00
|
|
|
"prebuilts/gcc/${HostPrebuiltTag}/arm/arm-linux-androideabi-${armGccVersion}")
|
2015-01-31 09:27:36 +08:00
|
|
|
|
2016-07-30 04:44:28 +08:00
|
|
|
pctx.StaticVariable("ArmToolchainCflags", strings.Join(armToolchainCflags, " "))
|
|
|
|
pctx.StaticVariable("ArmCflags", strings.Join(armCflags, " "))
|
|
|
|
pctx.StaticVariable("ArmLdflags", strings.Join(armLdflags, " "))
|
|
|
|
pctx.StaticVariable("ArmCppflags", strings.Join(armCppflags, " "))
|
|
|
|
pctx.StaticVariable("ArmIncludeFlags", bionicHeaders("arm", "arm"))
|
2015-01-31 09:27:36 +08:00
|
|
|
|
|
|
|
// Extended cflags
|
|
|
|
|
2015-03-19 03:28:32 +08:00
|
|
|
// ARM vs. Thumb instruction set flags
|
2016-07-30 04:44:28 +08:00
|
|
|
pctx.StaticVariable("ArmArmCflags", strings.Join(armArmCflags, " "))
|
|
|
|
pctx.StaticVariable("ArmThumbCflags", strings.Join(armThumbCflags, " "))
|
2015-01-31 09:27:36 +08:00
|
|
|
|
|
|
|
// Architecture variant cflags
|
2016-07-30 04:44:28 +08:00
|
|
|
pctx.StaticVariable("ArmArmv5TECflags", strings.Join(armArchVariantCflags["armv5te"], " "))
|
|
|
|
pctx.StaticVariable("ArmArmv7ACflags", strings.Join(armArchVariantCflags["armv7-a"], " "))
|
|
|
|
pctx.StaticVariable("ArmArmv7ANeonCflags", strings.Join(armArchVariantCflags["armv7-a-neon"], " "))
|
2015-01-31 09:27:36 +08:00
|
|
|
|
|
|
|
// Cpu variant cflags
|
2016-07-30 04:44:28 +08:00
|
|
|
pctx.StaticVariable("ArmGenericCflags", strings.Join(armCpuVariantCflags[""], " "))
|
|
|
|
pctx.StaticVariable("ArmCortexA7Cflags", strings.Join(armCpuVariantCflags["cortex-a7"], " "))
|
|
|
|
pctx.StaticVariable("ArmCortexA8Cflags", strings.Join(armCpuVariantCflags["cortex-a8"], " "))
|
|
|
|
pctx.StaticVariable("ArmCortexA15Cflags", strings.Join(armCpuVariantCflags["cortex-a15"], " "))
|
|
|
|
pctx.StaticVariable("ArmKraitCflags", strings.Join(armCpuVariantCflags["krait"], " "))
|
2016-08-20 06:14:56 +08:00
|
|
|
pctx.StaticVariable("ArmKryoCflags", strings.Join(armCpuVariantCflags["kryo"], " "))
|
2015-01-31 09:27:36 +08:00
|
|
|
|
|
|
|
// Clang cflags
|
2016-07-30 04:44:28 +08:00
|
|
|
pctx.StaticVariable("ArmToolchainClangCflags", strings.Join(ClangFilterUnknownCflags(armToolchainCflags), " "))
|
|
|
|
pctx.StaticVariable("ArmClangCflags", strings.Join(ClangFilterUnknownCflags(armCflags), " "))
|
|
|
|
pctx.StaticVariable("ArmClangLdflags", strings.Join(ClangFilterUnknownCflags(armLdflags), " "))
|
|
|
|
pctx.StaticVariable("ArmClangCppflags", strings.Join(ClangFilterUnknownCflags(armCppflags), " "))
|
2015-01-31 09:27:36 +08:00
|
|
|
|
2015-11-04 06:27:00 +08:00
|
|
|
// Clang ARM vs. Thumb instruction set cflags
|
2016-07-30 04:44:28 +08:00
|
|
|
pctx.StaticVariable("ArmClangArmCflags", strings.Join(ClangFilterUnknownCflags(armArmCflags), " "))
|
|
|
|
pctx.StaticVariable("ArmClangThumbCflags", strings.Join(ClangFilterUnknownCflags(armThumbCflags), " "))
|
2015-11-04 06:27:00 +08:00
|
|
|
|
2016-01-15 07:17:19 +08:00
|
|
|
// Clang arch variant cflags
|
2016-07-30 04:44:28 +08:00
|
|
|
pctx.StaticVariable("ArmClangArmv5TECflags",
|
2015-01-31 09:27:36 +08:00
|
|
|
strings.Join(armClangArchVariantCflags["armv5te"], " "))
|
2016-07-30 04:44:28 +08:00
|
|
|
pctx.StaticVariable("ArmClangArmv7ACflags",
|
2015-01-31 09:27:36 +08:00
|
|
|
strings.Join(armClangArchVariantCflags["armv7-a"], " "))
|
2016-07-30 04:44:28 +08:00
|
|
|
pctx.StaticVariable("ArmClangArmv7ANeonCflags",
|
2015-01-31 09:27:36 +08:00
|
|
|
strings.Join(armClangArchVariantCflags["armv7-a-neon"], " "))
|
|
|
|
|
|
|
|
// Clang cpu variant cflags
|
2016-07-30 04:44:28 +08:00
|
|
|
pctx.StaticVariable("ArmClangGenericCflags",
|
2016-01-15 07:17:19 +08:00
|
|
|
strings.Join(armClangCpuVariantCflags[""], " "))
|
2016-07-30 04:44:28 +08:00
|
|
|
pctx.StaticVariable("ArmClangCortexA7Cflags",
|
2015-01-31 09:27:36 +08:00
|
|
|
strings.Join(armClangCpuVariantCflags["cortex-a7"], " "))
|
2016-07-30 04:44:28 +08:00
|
|
|
pctx.StaticVariable("ArmClangCortexA8Cflags",
|
2015-01-31 09:27:36 +08:00
|
|
|
strings.Join(armClangCpuVariantCflags["cortex-a8"], " "))
|
2016-07-30 04:44:28 +08:00
|
|
|
pctx.StaticVariable("ArmClangCortexA15Cflags",
|
2015-01-31 09:27:36 +08:00
|
|
|
strings.Join(armClangCpuVariantCflags["cortex-a15"], " "))
|
2016-07-30 04:44:28 +08:00
|
|
|
pctx.StaticVariable("ArmClangKraitCflags",
|
2015-01-31 09:27:36 +08:00
|
|
|
strings.Join(armClangCpuVariantCflags["krait"], " "))
|
2016-08-20 06:14:56 +08:00
|
|
|
pctx.StaticVariable("ArmClangKryoCflags",
|
|
|
|
strings.Join(armClangCpuVariantCflags["kryo"], " "))
|
2015-01-31 09:27:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
var (
|
|
|
|
armArchVariantCflagsVar = map[string]string{
|
2016-07-30 04:44:28 +08:00
|
|
|
"armv5te": "${config.ArmArmv5TECflags}",
|
|
|
|
"armv7-a": "${config.ArmArmv7ACflags}",
|
|
|
|
"armv7-a-neon": "${config.ArmArmv7ANeonCflags}",
|
2015-01-31 09:27:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
armCpuVariantCflagsVar = map[string]string{
|
2016-07-30 04:44:28 +08:00
|
|
|
"": "${config.ArmGenericCflags}",
|
|
|
|
"cortex-a7": "${config.ArmCortexA7Cflags}",
|
|
|
|
"cortex-a8": "${config.ArmCortexA8Cflags}",
|
|
|
|
"cortex-a15": "${config.ArmCortexA15Cflags}",
|
|
|
|
"cortex-a53": "${config.ArmCortexA7Cflags}",
|
|
|
|
"cortex-a53.a57": "${config.ArmCortexA7Cflags}",
|
|
|
|
"krait": "${config.ArmKraitCflags}",
|
2016-08-20 06:14:56 +08:00
|
|
|
"kryo": "${config.ArmKryoCflags}",
|
2016-07-30 04:44:28 +08:00
|
|
|
"denver": "${config.ArmCortexA15Cflags}",
|
2015-01-31 09:27:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
armClangArchVariantCflagsVar = map[string]string{
|
2016-07-30 04:44:28 +08:00
|
|
|
"armv5te": "${config.ArmClangArmv5TECflags}",
|
|
|
|
"armv7-a": "${config.ArmClangArmv7ACflags}",
|
|
|
|
"armv7-a-neon": "${config.ArmClangArmv7ANeonCflags}",
|
2015-01-31 09:27:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
armClangCpuVariantCflagsVar = map[string]string{
|
2016-07-30 04:44:28 +08:00
|
|
|
"": "${config.ArmClangGenericCflags}",
|
|
|
|
"cortex-a7": "${config.ArmClangCortexA7Cflags}",
|
|
|
|
"cortex-a8": "${config.ArmClangCortexA8Cflags}",
|
|
|
|
"cortex-a15": "${config.ArmClangCortexA15Cflags}",
|
|
|
|
"cortex-a53": "${config.ArmClangCortexA7Cflags}",
|
|
|
|
"cortex-a53.a57": "${config.ArmClangCortexA7Cflags}",
|
|
|
|
"krait": "${config.ArmClangKraitCflags}",
|
2016-08-20 06:14:56 +08:00
|
|
|
"kryo": "${config.ArmClangKryoCflags}",
|
2016-07-30 04:44:28 +08:00
|
|
|
"denver": "${config.ArmClangCortexA15Cflags}",
|
2015-01-31 09:27:36 +08:00
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
type toolchainArm struct {
|
|
|
|
toolchain32Bit
|
2015-11-24 08:11:30 +08:00
|
|
|
ldflags string
|
|
|
|
toolchainCflags, toolchainClangCflags string
|
2015-01-31 09:27:36 +08:00
|
|
|
}
|
|
|
|
|
2015-03-19 14:38:50 +08:00
|
|
|
func (t *toolchainArm) Name() string {
|
|
|
|
return "arm"
|
|
|
|
}
|
|
|
|
|
2015-01-31 09:27:36 +08:00
|
|
|
func (t *toolchainArm) GccRoot() string {
|
2016-07-30 04:44:28 +08:00
|
|
|
return "${config.ArmGccRoot}"
|
2015-01-31 09:27:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (t *toolchainArm) GccTriple() string {
|
2016-07-21 05:44:26 +08:00
|
|
|
return "arm-linux-androideabi"
|
2015-01-31 09:27:36 +08:00
|
|
|
}
|
|
|
|
|
2015-03-19 14:38:50 +08:00
|
|
|
func (t *toolchainArm) GccVersion() string {
|
2015-12-08 04:30:44 +08:00
|
|
|
return armGccVersion
|
2015-03-19 14:38:50 +08:00
|
|
|
}
|
|
|
|
|
2015-11-24 08:11:30 +08:00
|
|
|
func (t *toolchainArm) ToolchainCflags() string {
|
|
|
|
return t.toolchainCflags
|
|
|
|
}
|
|
|
|
|
2015-01-31 09:27:36 +08:00
|
|
|
func (t *toolchainArm) Cflags() string {
|
2016-07-30 04:44:28 +08:00
|
|
|
return "${config.ArmCflags}"
|
2015-01-31 09:27:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (t *toolchainArm) Cppflags() string {
|
2016-07-30 04:44:28 +08:00
|
|
|
return "${config.ArmCppflags}"
|
2015-01-31 09:27:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (t *toolchainArm) Ldflags() string {
|
|
|
|
return t.ldflags
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *toolchainArm) IncludeFlags() string {
|
2016-07-30 04:44:28 +08:00
|
|
|
return "${config.ArmIncludeFlags}"
|
2015-01-31 09:27:36 +08:00
|
|
|
}
|
|
|
|
|
2015-03-19 03:28:32 +08:00
|
|
|
func (t *toolchainArm) InstructionSetFlags(isa string) (string, error) {
|
|
|
|
switch isa {
|
|
|
|
case "arm":
|
2016-07-30 04:44:28 +08:00
|
|
|
return "${config.ArmArmCflags}", nil
|
2015-03-19 03:28:32 +08:00
|
|
|
case "thumb", "":
|
2016-07-30 04:44:28 +08:00
|
|
|
return "${config.ArmThumbCflags}", nil
|
2015-03-19 03:28:32 +08:00
|
|
|
default:
|
|
|
|
return t.toolchainBase.InstructionSetFlags(isa)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-01-31 09:27:36 +08:00
|
|
|
func (t *toolchainArm) ClangTriple() string {
|
2016-07-21 05:44:26 +08:00
|
|
|
return t.GccTriple()
|
2015-01-31 09:27:36 +08:00
|
|
|
}
|
|
|
|
|
2015-11-24 08:11:30 +08:00
|
|
|
func (t *toolchainArm) ToolchainClangCflags() string {
|
|
|
|
return t.toolchainClangCflags
|
|
|
|
}
|
|
|
|
|
2015-01-31 09:27:36 +08:00
|
|
|
func (t *toolchainArm) ClangCflags() string {
|
2016-07-30 04:44:28 +08:00
|
|
|
return "${config.ArmClangCflags}"
|
2015-01-31 09:27:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (t *toolchainArm) ClangCppflags() string {
|
2016-07-30 04:44:28 +08:00
|
|
|
return "${config.ArmClangCppflags}"
|
2015-01-31 09:27:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (t *toolchainArm) ClangLdflags() string {
|
|
|
|
return t.ldflags
|
|
|
|
}
|
|
|
|
|
2015-11-04 06:27:00 +08:00
|
|
|
func (t *toolchainArm) ClangInstructionSetFlags(isa string) (string, error) {
|
|
|
|
switch isa {
|
|
|
|
case "arm":
|
2016-07-30 04:44:28 +08:00
|
|
|
return "${config.ArmClangArmCflags}", nil
|
2015-11-04 06:27:00 +08:00
|
|
|
case "thumb", "":
|
2016-07-30 04:44:28 +08:00
|
|
|
return "${config.ArmClangThumbCflags}", nil
|
2015-11-04 06:27:00 +08:00
|
|
|
default:
|
|
|
|
return t.toolchainBase.ClangInstructionSetFlags(isa)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-08-16 05:18:24 +08:00
|
|
|
func (toolchainArm) SanitizerRuntimeLibraryArch() string {
|
|
|
|
return "arm"
|
2016-01-07 06:41:07 +08:00
|
|
|
}
|
|
|
|
|
2016-05-19 06:37:25 +08:00
|
|
|
func armToolchainFactory(arch android.Arch) Toolchain {
|
2015-04-29 04:15:59 +08:00
|
|
|
var fixCortexA8 string
|
2016-01-15 07:17:19 +08:00
|
|
|
toolchainCflags := make([]string, 2, 3)
|
|
|
|
toolchainClangCflags := make([]string, 2, 3)
|
|
|
|
|
2016-07-30 04:44:28 +08:00
|
|
|
toolchainCflags[0] = "${config.ArmToolchainCflags}"
|
2016-01-15 07:17:19 +08:00
|
|
|
toolchainCflags[1] = armArchVariantCflagsVar[arch.ArchVariant]
|
2016-07-30 04:44:28 +08:00
|
|
|
toolchainClangCflags[0] = "${config.ArmToolchainClangCflags}"
|
2016-01-15 07:17:19 +08:00
|
|
|
toolchainClangCflags[1] = armClangArchVariantCflagsVar[arch.ArchVariant]
|
|
|
|
|
|
|
|
switch arch.ArchVariant {
|
|
|
|
case "armv7-a-neon":
|
|
|
|
switch arch.CpuVariant {
|
|
|
|
case "cortex-a8", "":
|
|
|
|
// Generic ARM might be a Cortex A8 -- better safe than sorry
|
|
|
|
fixCortexA8 = "-Wl,--fix-cortex-a8"
|
|
|
|
default:
|
|
|
|
fixCortexA8 = "-Wl,--no-fix-cortex-a8"
|
|
|
|
}
|
|
|
|
|
|
|
|
toolchainCflags = append(toolchainCflags,
|
|
|
|
variantOrDefault(armCpuVariantCflagsVar, arch.CpuVariant))
|
|
|
|
toolchainClangCflags = append(toolchainClangCflags,
|
|
|
|
variantOrDefault(armClangCpuVariantCflagsVar, arch.CpuVariant))
|
|
|
|
case "armv7-a":
|
2015-04-29 04:15:59 +08:00
|
|
|
fixCortexA8 = "-Wl,--fix-cortex-a8"
|
2016-01-15 07:17:19 +08:00
|
|
|
case "armv5te":
|
|
|
|
// Nothing extra for armv5te
|
2015-04-29 04:15:59 +08:00
|
|
|
default:
|
2016-01-15 07:17:19 +08:00
|
|
|
panic(fmt.Sprintf("Unknown ARM architecture version: %q", arch.ArchVariant))
|
2015-04-29 04:15:59 +08:00
|
|
|
}
|
|
|
|
|
2015-01-31 09:27:36 +08:00
|
|
|
return &toolchainArm{
|
2016-01-15 07:17:19 +08:00
|
|
|
toolchainCflags: strings.Join(toolchainCflags, " "),
|
2015-01-31 09:27:36 +08:00
|
|
|
ldflags: strings.Join([]string{
|
2016-07-30 04:44:28 +08:00
|
|
|
"${config.ArmLdflags}",
|
2015-04-29 04:15:59 +08:00
|
|
|
fixCortexA8,
|
2015-01-31 09:27:36 +08:00
|
|
|
}, " "),
|
2016-01-15 07:17:19 +08:00
|
|
|
toolchainClangCflags: strings.Join(toolchainClangCflags, " "),
|
2015-01-31 09:27:36 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func init() {
|
2016-06-02 08:09:44 +08:00
|
|
|
registerToolchainFactory(android.Android, android.Arm, armToolchainFactory)
|
2015-01-31 09:27:36 +08:00
|
|
|
}
|