Add an instruction_set property to Arch
Used to allow switching between thumb and arm ISAs Change-Id: I94aa83cee7179e83c97eedc32fd216965b626d33
This commit is contained in:
@@ -149,7 +149,7 @@ func init() {
|
|||||||
|
|
||||||
// Extended cflags
|
// Extended cflags
|
||||||
|
|
||||||
// ARM mode vs. Thumb mode
|
// ARM vs. Thumb instruction set flags
|
||||||
pctx.StaticVariable("armArmCflags", strings.Join(armArmCflags, " "))
|
pctx.StaticVariable("armArmCflags", strings.Join(armArmCflags, " "))
|
||||||
pctx.StaticVariable("armThumbCflags", strings.Join(armThumbCflags, " "))
|
pctx.StaticVariable("armThumbCflags", strings.Join(armThumbCflags, " "))
|
||||||
|
|
||||||
@@ -256,6 +256,17 @@ func (t *toolchainArm) IncludeFlags() string {
|
|||||||
return "${armIncludeFlags}"
|
return "${armIncludeFlags}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (t *toolchainArm) InstructionSetFlags(isa string) (string, error) {
|
||||||
|
switch isa {
|
||||||
|
case "arm":
|
||||||
|
return "${armArmCflags}", nil
|
||||||
|
case "thumb", "":
|
||||||
|
return "${armThumbCflags}", nil
|
||||||
|
default:
|
||||||
|
return t.toolchainBase.InstructionSetFlags(isa)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (t *toolchainArm) ClangTriple() string {
|
func (t *toolchainArm) ClangTriple() string {
|
||||||
return "${armGccTriple}"
|
return "${armGccTriple}"
|
||||||
}
|
}
|
||||||
@@ -277,7 +288,6 @@ func armToolchainFactory(archVariant string, cpuVariant string) toolchain {
|
|||||||
cflags: strings.Join([]string{
|
cflags: strings.Join([]string{
|
||||||
"${armCflags}",
|
"${armCflags}",
|
||||||
"${armIncludeFlags}",
|
"${armIncludeFlags}",
|
||||||
"${armThumbCflags}",
|
|
||||||
armArchVariantCflagsVar[archVariant],
|
armArchVariantCflagsVar[archVariant],
|
||||||
armCpuVariantCflagsVar[cpuVariant],
|
armCpuVariantCflagsVar[cpuVariant],
|
||||||
}, " "),
|
}, " "),
|
||||||
@@ -288,7 +298,6 @@ func armToolchainFactory(archVariant string, cpuVariant string) toolchain {
|
|||||||
clangCflags: strings.Join([]string{
|
clangCflags: strings.Join([]string{
|
||||||
"${armClangCflags}",
|
"${armClangCflags}",
|
||||||
"${armIncludeFlags}",
|
"${armIncludeFlags}",
|
||||||
"${armThumbCflags}",
|
|
||||||
armClangArchVariantCflagsVar[archVariant],
|
armClangArchVariantCflagsVar[archVariant],
|
||||||
armClangCpuVariantCflagsVar[cpuVariant],
|
armClangCpuVariantCflagsVar[cpuVariant],
|
||||||
}, " "),
|
}, " "),
|
||||||
|
11
cc/cc.go
11
cc/cc.go
@@ -126,6 +126,10 @@ type ccProperties struct {
|
|||||||
// ldflags: list of module-specific flags that will be used for all link steps
|
// ldflags: list of module-specific flags that will be used for all link steps
|
||||||
Ldflags []string `android:"arch_variant"`
|
Ldflags []string `android:"arch_variant"`
|
||||||
|
|
||||||
|
// instruction_set: the instruction set architecture to use to compile the C/C++
|
||||||
|
// module.
|
||||||
|
Instruction_set string `android:"arch_variant"`
|
||||||
|
|
||||||
// include_dirs: list of directories relative to the root of the source tree that will
|
// include_dirs: list of directories relative to the root of the source tree that will
|
||||||
// be added to the include path using -I.
|
// be added to the include path using -I.
|
||||||
// If possible, don't use this. If adding paths from the current directory use
|
// If possible, don't use this. If adding paths from the current directory use
|
||||||
@@ -353,6 +357,11 @@ func (c *ccBase) flags(ctx common.AndroidModuleContext, toolchain toolchain) ccF
|
|||||||
toolchain: toolchain,
|
toolchain: toolchain,
|
||||||
clang: c.properties.Clang,
|
clang: c.properties.Clang,
|
||||||
}
|
}
|
||||||
|
instructionSet := c.properties.Instruction_set
|
||||||
|
instructionSetFlags, err := toolchain.InstructionSetFlags(instructionSet)
|
||||||
|
if err != nil {
|
||||||
|
ctx.ModuleErrorf("%s", err)
|
||||||
|
}
|
||||||
|
|
||||||
if arch.HostOrDevice.Host() {
|
if arch.HostOrDevice.Host() {
|
||||||
// TODO: allow per-module clang disable for host
|
// TODO: allow per-module clang disable for host
|
||||||
@@ -411,6 +420,7 @@ func (c *ccBase) flags(ctx common.AndroidModuleContext, toolchain toolchain) ccF
|
|||||||
flags.globalFlags = []string{
|
flags.globalFlags = []string{
|
||||||
"${commonGlobalIncludes}",
|
"${commonGlobalIncludes}",
|
||||||
toolchain.IncludeFlags(),
|
toolchain.IncludeFlags(),
|
||||||
|
instructionSetFlags,
|
||||||
toolchain.ClangCflags(),
|
toolchain.ClangCflags(),
|
||||||
"${commonClangGlobalCflags}",
|
"${commonClangGlobalCflags}",
|
||||||
fmt.Sprintf("${%sClangGlobalCflags}", arch.HostOrDevice),
|
fmt.Sprintf("${%sClangGlobalCflags}", arch.HostOrDevice),
|
||||||
@@ -420,6 +430,7 @@ func (c *ccBase) flags(ctx common.AndroidModuleContext, toolchain toolchain) ccF
|
|||||||
flags.globalFlags = []string{
|
flags.globalFlags = []string{
|
||||||
"${commonGlobalIncludes}",
|
"${commonGlobalIncludes}",
|
||||||
toolchain.IncludeFlags(),
|
toolchain.IncludeFlags(),
|
||||||
|
instructionSetFlags,
|
||||||
toolchain.Cflags(),
|
toolchain.Cflags(),
|
||||||
"${commonGlobalCflags}",
|
"${commonGlobalCflags}",
|
||||||
fmt.Sprintf("${%sGlobalCflags}", arch.HostOrDevice),
|
fmt.Sprintf("${%sGlobalCflags}", arch.HostOrDevice),
|
||||||
|
@@ -15,6 +15,8 @@
|
|||||||
package cc
|
package cc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
"android/soong/common"
|
"android/soong/common"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -38,6 +40,7 @@ type toolchain interface {
|
|||||||
Cppflags() string
|
Cppflags() string
|
||||||
Ldflags() string
|
Ldflags() string
|
||||||
IncludeFlags() string
|
IncludeFlags() string
|
||||||
|
InstructionSetFlags(string) (string, error)
|
||||||
|
|
||||||
ClangTriple() string
|
ClangTriple() string
|
||||||
ClangCflags() string
|
ClangCflags() string
|
||||||
@@ -47,7 +50,18 @@ type toolchain interface {
|
|||||||
Is64Bit() bool
|
Is64Bit() bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type toolchainBase struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
func (toolchainBase) InstructionSetFlags(s string) (string, error) {
|
||||||
|
if s != "" {
|
||||||
|
return "", fmt.Errorf("instruction_set: %s is not a supported instruction set", s)
|
||||||
|
}
|
||||||
|
return "", nil
|
||||||
|
}
|
||||||
|
|
||||||
type toolchain64Bit struct {
|
type toolchain64Bit struct {
|
||||||
|
toolchainBase
|
||||||
}
|
}
|
||||||
|
|
||||||
func (toolchain64Bit) Is64Bit() bool {
|
func (toolchain64Bit) Is64Bit() bool {
|
||||||
@@ -55,6 +69,7 @@ func (toolchain64Bit) Is64Bit() bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type toolchain32Bit struct {
|
type toolchain32Bit struct {
|
||||||
|
toolchainBase
|
||||||
}
|
}
|
||||||
|
|
||||||
func (toolchain32Bit) Is64Bit() bool {
|
func (toolchain32Bit) Is64Bit() bool {
|
||||||
|
Reference in New Issue
Block a user