Remove clang indirection without affecting build.ninja

Remove cflags that are not handled by clang from the global defaults,
and remove calls to ClangFilterUnknownCflags.

Squash lists of clang-specific default flags into the main default
flags lists.

Rename Toolchain.Clang*flags to Toolchain.*flags.

Rename Go variables with Clang in the name that have no non-Clang
equivalent.

Remove unused ninja variables.

Bug: 68947919
Test: no change to build.ninja for aosp_cf_x86_64_phone-userdebug or aosp_crosshatch-userdebug
Change-Id: Id287945315d53e5eaef197adbbb4f1302f2e3680
This commit is contained in:
Colin Cross
2021-07-14 17:03:16 -07:00
parent 1c19b81e3d
commit 33bac24bb9
19 changed files with 234 additions and 355 deletions

View File

@@ -15,14 +15,15 @@
package config
import (
"android/soong/android"
"strings"
"android/soong/android"
)
var (
// This is a host toolchain but flags for device toolchain are required
// as the flags are actually for Bionic-based builds.
linuxCrossCflags = ClangFilterUnknownCflags(append(deviceGlobalCflags,
linuxCrossCflags = append(deviceGlobalCflags,
// clang by default enables PIC when the clang triple is set to *-android.
// See toolchain/llvm-project/clang/lib/Driver/ToolChains/CommonArgs.cpp#920.
// However, for this host target, we don't set "-android" to avoid __ANDROID__ macro
@@ -33,9 +34,9 @@ var (
// This is normally in ClangExtraTargetCflags, but that's for device and we need
// the same for host
"-nostdlibinc",
))
)
linuxCrossLdflags = ClangFilterUnknownCflags([]string{
linuxCrossLdflags = []string{
"-Wl,-z,noexecstack",
"-Wl,-z,relro",
"-Wl,-z,now",
@@ -44,7 +45,7 @@ var (
"-Wl,--fatal-warnings",
"-Wl,--hash-style=gnu",
"-Wl,--no-undefined-version",
})
}
// Embed the linker into host bionic binaries. This is needed to support host bionic,
// as the linux kernel requires that the ELF interpreter referenced by PT_INTERP be
@@ -73,7 +74,7 @@ func (toolchainLinuxArm64) ClangTriple() string {
return "aarch64-linux"
}
func (toolchainLinuxArm64) ClangCflags() string {
func (toolchainLinuxArm64) Cflags() string {
// The inherited flags + extra flags
return "${config.Arm64ClangCflags} ${config.LinuxBionicArm64Cflags}"
}
@@ -84,7 +85,7 @@ func (toolchainLinuxArm64) CrtBeginSharedBinary() []string {
func linuxArm64ToolchainFactory(arch android.Arch) Toolchain {
archVariant := "armv8-a" // for host, default to armv8-a
toolchainClangCflags := []string{arm64ClangArchVariantCflagsVar[archVariant]}
toolchainCflags := []string{arm64ArchVariantCflagsVar[archVariant]}
// We don't specify CPU architecture for host. Conservatively assume
// the host CPU needs the fix
@@ -103,7 +104,7 @@ func linuxArm64ToolchainFactory(arch android.Arch) Toolchain {
"${config.LinuxBionicArm64Ldflags}",
extraLdflags,
}, " ")
ret.toolchainArm64.toolchainClangCflags = strings.Join(toolchainClangCflags, " ")
ret.toolchainArm64.toolchainCflags = strings.Join(toolchainCflags, " ")
return &ret
}