diff --git a/cc/arm64_device.go b/cc/arm64_device.go index b951c1a61..583da4497 100644 --- a/cc/arm64_device.go +++ b/cc/arm64_device.go @@ -99,14 +99,7 @@ func init() { pctx.StaticVariable("arm64Cflags", strings.Join(arm64Cflags, " ")) pctx.StaticVariable("arm64Ldflags", strings.Join(arm64Ldflags, " ")) pctx.StaticVariable("arm64Cppflags", strings.Join(arm64Cppflags, " ")) - pctx.StaticVariable("arm64IncludeFlags", strings.Join([]string{ - "-isystem ${LibcRoot}/arch-arm64/include", - "-isystem ${LibcRoot}/include", - "-isystem ${LibcRoot}/kernel/uapi", - "-isystem ${LibcRoot}/kernel/android/uapi", - "-isystem ${LibcRoot}/kernel/common", - "-isystem ${LibcRoot}/kernel/uapi/asm-arm64", - }, " ")) + pctx.StaticVariable("arm64IncludeFlags", bionicHeaders("arm64", "arm64")) pctx.StaticVariable("arm64ClangCflags", strings.Join(clangFilterUnknownCflags(arm64Cflags), " ")) pctx.StaticVariable("arm64ClangLdflags", strings.Join(clangFilterUnknownCflags(arm64Ldflags), " ")) diff --git a/cc/arm_device.go b/cc/arm_device.go index e985a3825..dc8ba8137 100644 --- a/cc/arm_device.go +++ b/cc/arm_device.go @@ -168,14 +168,7 @@ func init() { pctx.StaticVariable("armCflags", strings.Join(armCflags, " ")) pctx.StaticVariable("armLdflags", strings.Join(armLdflags, " ")) pctx.StaticVariable("armCppflags", strings.Join(armCppflags, " ")) - pctx.StaticVariable("armIncludeFlags", strings.Join([]string{ - "-isystem ${LibcRoot}/arch-arm/include", - "-isystem ${LibcRoot}/include", - "-isystem ${LibcRoot}/kernel/uapi", - "-isystem ${LibcRoot}/kernel/android/uapi", - "-isystem ${LibcRoot}/kernel/common", - "-isystem ${LibcRoot}/kernel/uapi/asm-arm", - }, " ")) + pctx.StaticVariable("armIncludeFlags", bionicHeaders("arm", "arm")) // Extended cflags diff --git a/cc/cc.go b/cc/cc.go index b5545fc38..acc807f46 100644 --- a/cc/cc.go +++ b/cc/cc.go @@ -70,8 +70,6 @@ func init() { var ( HostPrebuiltTag = pctx.VariableConfigMethod("HostPrebuiltTag", android.Config.PrebuiltOS) - - LibcRoot = pctx.SourcePathVariable("LibcRoot", "bionic/libc") ) // Flags used by lots of devices. Putting them in package static variables will save bytes in diff --git a/cc/mips64_device.go b/cc/mips64_device.go index 19f9caf72..a1ec3a298 100644 --- a/cc/mips64_device.go +++ b/cc/mips64_device.go @@ -100,14 +100,7 @@ func init() { pctx.StaticVariable("mips64Cflags", strings.Join(mips64Cflags, " ")) pctx.StaticVariable("mips64Ldflags", strings.Join(mips64Ldflags, " ")) pctx.StaticVariable("mips64Cppflags", strings.Join(mips64Cppflags, " ")) - pctx.StaticVariable("mips64IncludeFlags", strings.Join([]string{ - "-isystem ${LibcRoot}/arch-mips64/include", - "-isystem ${LibcRoot}/include", - "-isystem ${LibcRoot}/kernel/uapi", - "-isystem ${LibcRoot}/kernel/android/uapi", - "-isystem ${LibcRoot}/kernel/common", - "-isystem ${LibcRoot}/kernel/uapi/asm-mips", - }, " ")) + pctx.StaticVariable("mips64IncludeFlags", bionicHeaders("mips64", "mips")) // Clang cflags pctx.StaticVariable("mips64ClangTriple", "mips64el-linux-android") diff --git a/cc/mips_device.go b/cc/mips_device.go index ac6f2b1bd..0b23d3789 100644 --- a/cc/mips_device.go +++ b/cc/mips_device.go @@ -137,14 +137,7 @@ func init() { pctx.StaticVariable("mipsCflags", strings.Join(mipsCflags, " ")) pctx.StaticVariable("mipsLdflags", strings.Join(mipsLdflags, " ")) pctx.StaticVariable("mipsCppflags", strings.Join(mipsCppflags, " ")) - pctx.StaticVariable("mipsIncludeFlags", strings.Join([]string{ - "-isystem ${LibcRoot}/arch-mips/include", - "-isystem ${LibcRoot}/include", - "-isystem ${LibcRoot}/kernel/uapi", - "-isystem ${LibcRoot}/kernel/android/uapi", - "-isystem ${LibcRoot}/kernel/common", - "-isystem ${LibcRoot}/kernel/uapi/asm-mips", - }, " ")) + pctx.StaticVariable("mipsIncludeFlags", bionicHeaders("mips", "mips")) // Clang cflags pctx.StaticVariable("mipsClangTriple", "mipsel-linux-android") diff --git a/cc/toolchain.go b/cc/toolchain.go index 2e2ee5a43..89485f8e0 100644 --- a/cc/toolchain.go +++ b/cc/toolchain.go @@ -16,6 +16,7 @@ package cc import ( "fmt" + "strings" "android/soong/android" ) @@ -139,3 +140,14 @@ type toolchain32Bit struct { func (toolchain32Bit) Is64Bit() bool { return false } + +func bionicHeaders(bionicArch, kernelArch string) string { + return strings.Join([]string{ + "-isystem bionic/libc/arch-" + bionicArch + "/include", + "-isystem bionic/libc/include", + "-isystem bionic/libc/kernel/uapi", + "-isystem bionic/libc/kernel/android/uapi", + "-isystem bionic/libc/kernel/common", + "-isystem bionic/libc/kernel/uapi/asm-" + kernelArch, + }, " ") +} diff --git a/cc/x86_64_device.go b/cc/x86_64_device.go index a795ba7d9..6923f5f12 100644 --- a/cc/x86_64_device.go +++ b/cc/x86_64_device.go @@ -148,14 +148,7 @@ func init() { pctx.StaticVariable("x86_64Cflags", strings.Join(x86_64Cflags, " ")) pctx.StaticVariable("x86_64Ldflags", strings.Join(x86_64Ldflags, " ")) pctx.StaticVariable("x86_64Cppflags", strings.Join(x86_64Cppflags, " ")) - pctx.StaticVariable("x86_64IncludeFlags", strings.Join([]string{ - "-isystem ${LibcRoot}/arch-x86_64/include", - "-isystem ${LibcRoot}/include", - "-isystem ${LibcRoot}/kernel/uapi", - "-isystem ${LibcRoot}/kernel/android/uapi", - "-isystem ${LibcRoot}/kernel/common", - "-isystem ${LibcRoot}/kernel/uapi/asm-x86", - }, " ")) + pctx.StaticVariable("x86_64IncludeFlags", bionicHeaders("x86_64", "x86")) // Clang cflags pctx.StaticVariable("x86_64ClangCflags", strings.Join(clangFilterUnknownCflags(x86_64Cflags), " ")) diff --git a/cc/x86_device.go b/cc/x86_device.go index 72689fb33..ba2f23aa7 100644 --- a/cc/x86_device.go +++ b/cc/x86_device.go @@ -167,14 +167,7 @@ func init() { pctx.StaticVariable("x86Cflags", strings.Join(x86Cflags, " ")) pctx.StaticVariable("x86Ldflags", strings.Join(x86Ldflags, " ")) pctx.StaticVariable("x86Cppflags", strings.Join(x86Cppflags, " ")) - pctx.StaticVariable("x86IncludeFlags", strings.Join([]string{ - "-isystem ${LibcRoot}/arch-x86/include", - "-isystem ${LibcRoot}/include", - "-isystem ${LibcRoot}/kernel/uapi", - "-isystem ${LibcRoot}/kernel/android/uapi", - "-isystem ${LibcRoot}/kernel/common", - "-isystem ${LibcRoot}/kernel/uapi/asm-x86", - }, " ")) + pctx.StaticVariable("x86IncludeFlags", bionicHeaders("x86", "x86")) // Clang cflags pctx.StaticVariable("x86ClangCflags", strings.Join(clangFilterUnknownCflags(x86ClangCflags), " "))