aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bpf/Android.bp30
-rw-r--r--bpf/bpf.go135
-rw-r--r--cc/builder.go4
-rw-r--r--cc/config/arm64_device.go19
-rw-r--r--cc/sanitize.go5
-rw-r--r--ui/build/cleanbuild.go1
6 files changed, 188 insertions, 6 deletions
diff --git a/bpf/Android.bp b/bpf/Android.bp
new file mode 100644
index 00000000..7bd4d443
--- /dev/null
+++ b/bpf/Android.bp
@@ -0,0 +1,30 @@
+//
+// Copyright (C) 2018 The Android Open Source Project
+//
+// 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.
+//
+
+bootstrap_go_package {
+ name: "soong-bpf",
+ pkgPath: "android/soong/bpf",
+ deps: [
+ "blueprint",
+ "blueprint-proptools",
+ "soong-android",
+ "soong-cc-config",
+ ],
+ srcs: [
+ "bpf.go",
+ ],
+ pluginFor: ["soong_build"],
+}
diff --git a/bpf/bpf.go b/bpf/bpf.go
new file mode 100644
index 00000000..fa1f3ff9
--- /dev/null
+++ b/bpf/bpf.go
@@ -0,0 +1,135 @@
+// Copyright (C) 2018 The Android Open Source Project
+//
+// 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.
+
+package bpf
+
+import (
+ "fmt"
+ "io"
+ "strings"
+
+ "android/soong/android"
+ _ "android/soong/cc/config"
+
+ "github.com/google/blueprint"
+)
+
+func init() {
+ android.RegisterModuleType("bpf", bpfFactory)
+ pctx.Import("android/soong/cc/config")
+}
+
+var (
+ pctx = android.NewPackageContext("android/soong/bpf")
+
+ cc = pctx.AndroidGomaStaticRule("cc",
+ blueprint.RuleParams{
+ Depfile: "${out}.d",
+ Deps: blueprint.DepsGCC,
+ Command: "$ccCmd --target=bpf -c $cFlags -MD -MF ${out}.d -o $out $in",
+ CommandDeps: []string{"$ccCmd"},
+ },
+ "ccCmd", "cFlags")
+)
+
+type BpfProperties struct {
+ Srcs []string
+ Cflags []string
+ Include_dirs []string
+}
+
+type bpf struct {
+ android.ModuleBase
+
+ properties BpfProperties
+
+ objs android.Paths
+}
+
+func (bpf *bpf) GenerateAndroidBuildActions(ctx android.ModuleContext) {
+ cflags := []string{
+ "-nostdlibinc",
+ "-O2",
+ "-isystem bionic/libc/include",
+ "-isystem bionic/libc/kernel/uapi",
+ // The architecture doesn't matter here, but asm/types.h is included by linux/types.h.
+ "-isystem bionic/libc/kernel/uapi/asm-arm64",
+ "-isystem bionic/libc/kernel/android/uapi",
+ "-I " + ctx.ModuleDir(),
+ }
+
+ for _, dir := range android.PathsForSource(ctx, bpf.properties.Include_dirs) {
+ cflags = append(cflags, "-I "+dir.String())
+ }
+
+ cflags = append(cflags, bpf.properties.Cflags...)
+
+ srcs := ctx.ExpandSources(bpf.properties.Srcs, nil)
+
+ for _, src := range srcs {
+ obj := android.ObjPathWithExt(ctx, "", src, "o")
+
+ ctx.Build(pctx, android.BuildParams{
+ Rule: cc,
+ Input: src,
+ Output: obj,
+ Args: map[string]string{
+ "cFlags": strings.Join(cflags, " "),
+ "ccCmd": "${config.ClangBin}/clang",
+ },
+ })
+
+ bpf.objs = append(bpf.objs, obj)
+ }
+}
+
+func (bpf *bpf) DepsMutator(ctx android.BottomUpMutatorContext) {
+ android.ExtractSourcesDeps(ctx, bpf.properties.Srcs)
+}
+
+func (bpf *bpf) AndroidMk() android.AndroidMkData {
+ return android.AndroidMkData{
+ Custom: func(w io.Writer, name, prefix, moduleDir string, data android.AndroidMkData) {
+ var names []string
+ fmt.Fprintln(w)
+ fmt.Fprintln(w, "LOCAL_PATH :=", moduleDir)
+ fmt.Fprintln(w)
+ for _, obj := range bpf.objs {
+ objName := name + "_" + obj.Base()
+ names = append(names, objName)
+ fmt.Fprintln(w, "include $(CLEAR_VARS)")
+ fmt.Fprintln(w, "LOCAL_MODULE := ", objName)
+ fmt.Fprintln(w, "LOCAL_PREBUILT_MODULE_FILE :=", obj.String())
+ fmt.Fprintln(w, "LOCAL_MODULE_STEM :=", obj.Base())
+ fmt.Fprintln(w, "LOCAL_MODULE_CLASS := ETC")
+ fmt.Fprintln(w, "LOCAL_MODULE_PATH := $(TARGET_OUT_ETC)/bpf")
+ fmt.Fprintln(w, "include $(BUILD_PREBUILT)")
+ fmt.Fprintln(w)
+ }
+ fmt.Fprintln(w, "include $(CLEAR_VARS)")
+ fmt.Fprintln(w, "LOCAL_MODULE := ", name)
+ fmt.Fprintln(w, "LOCAL_REQUIRED_MODULES :=", strings.Join(names, " "))
+ fmt.Fprintln(w, "include $(BUILD_PHONY_PACKAGE)")
+ },
+ }
+}
+
+func bpfFactory() android.Module {
+ module := &bpf{}
+
+ module.AddProperties(&module.properties)
+
+ android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
+ return module
+}
diff --git a/cc/builder.go b/cc/builder.go
index 73a91682..eac24490 100644
--- a/cc/builder.go
+++ b/cc/builder.go
@@ -197,8 +197,8 @@ var (
sAbiDiff = pctx.AndroidRuleFunc("sAbiDiff",
func(ctx android.PackageRuleContext) blueprint.RuleParams {
-
- commandStr := "($sAbiDiffer $allowFlags -lib $libName -arch $arch -check-all-apis -o ${out} -new $in -old $referenceDump)"
+ // TODO(b/78139997): Add -check-all-apis back
+ commandStr := "($sAbiDiffer $allowFlags -lib $libName -arch $arch -o ${out} -new $in -old $referenceDump)"
distAbiDiffDir := android.PathForDist(ctx, "abidiffs")
commandStr += "|| (echo ' ---- Please update abi references by running platform/development/vndk/tools/header-checker/utils/create_reference_dumps.py -l ${libName} ----'"
if distAbiDiffDir.Valid() {
diff --git a/cc/config/arm64_device.go b/cc/config/arm64_device.go
index c4426e31..b2b07648 100644
--- a/cc/config/arm64_device.go
+++ b/cc/config/arm64_device.go
@@ -39,7 +39,6 @@ var (
arm64Ldflags = []string{
"-Wl,-m,aarch64_elf64_le_vec",
"-Wl,--hash-style=gnu",
- "-Wl,--fix-cortex-a53-843419",
"-fuse-ld=gold",
"-Wl,--icf=safe",
}
@@ -172,6 +171,7 @@ var (
type toolchainArm64 struct {
toolchain64Bit
+ ldflags string
toolchainCflags string
toolchainClangCflags string
}
@@ -205,7 +205,7 @@ func (t *toolchainArm64) Cppflags() string {
}
func (t *toolchainArm64) Ldflags() string {
- return "${config.Arm64Ldflags}"
+ return t.ldflags
}
func (t *toolchainArm64) IncludeFlags() string {
@@ -225,7 +225,7 @@ func (t *toolchainArm64) ClangCppflags() string {
}
func (t *toolchainArm64) ClangLdflags() string {
- return "${config.Arm64Ldflags}"
+ return t.ldflags
}
func (t *toolchainArm64) ToolchainClangCflags() string {
@@ -249,7 +249,20 @@ func arm64ToolchainFactory(arch android.Arch) Toolchain {
toolchainClangCflags = append(toolchainClangCflags,
variantOrDefault(arm64ClangCpuVariantCflagsVar, arch.CpuVariant))
+ var extraLdflags string
+ switch arch.CpuVariant {
+ case "cortex-a53", "cortex-a73", "kryo", "exynos-m1", "exynos-m2",
+ // This variant might not need the workaround but leave it
+ // in the list since it has had the workaround on before.
+ "denver64":
+ extraLdflags = "-Wl,--fix-cortex-a53-843419"
+ }
+
return &toolchainArm64{
+ ldflags: strings.Join([]string{
+ "${config.Arm64Ldflags}",
+ extraLdflags,
+ }, " "),
toolchainCflags: variantOrDefault(arm64CpuVariantCflagsVar, arch.CpuVariant),
toolchainClangCflags: strings.Join(toolchainClangCflags, " "),
}
diff --git a/cc/sanitize.go b/cc/sanitize.go
index 86537347..fc44eaf1 100644
--- a/cc/sanitize.go
+++ b/cc/sanitize.go
@@ -300,10 +300,12 @@ func (sanitize *sanitize) deps(ctx BaseModuleContext, deps Deps) Deps {
}
func (sanitize *sanitize) flags(ctx ModuleContext, flags Flags) Flags {
- minimalRuntimePath := "${config.ClangAsanLibDir}/" + config.UndefinedBehaviorSanitizerMinimalRuntimeLibrary(ctx.toolchain()) + ".a"
+ minimalRuntimeLib := config.UndefinedBehaviorSanitizerMinimalRuntimeLibrary(ctx.toolchain()) + ".a"
+ minimalRuntimePath := "${config.ClangAsanLibDir}/" + minimalRuntimeLib
if ctx.Device() && sanitize.Properties.MinimalRuntimeDep {
flags.LdFlags = append(flags.LdFlags, minimalRuntimePath)
+ flags.LdFlags = append(flags.LdFlags, "-Wl,--exclude-libs,"+minimalRuntimeLib)
}
if !sanitize.Properties.SanitizerEnabled {
return flags
@@ -449,6 +451,7 @@ func (sanitize *sanitize) flags(ctx ModuleContext, flags Flags) Flags {
if enableMinimalRuntime(sanitize) {
flags.CFlags = append(flags.CFlags, strings.Join(minimalRuntimeFlags, " "))
flags.libFlags = append([]string{minimalRuntimePath}, flags.libFlags...)
+ flags.LdFlags = append(flags.LdFlags, "-Wl,--exclude-libs,"+minimalRuntimeLib)
}
}
}
diff --git a/ui/build/cleanbuild.go b/ui/build/cleanbuild.go
index f2de2cda..24a8c7a8 100644
--- a/ui/build/cleanbuild.go
+++ b/ui/build/cleanbuild.go
@@ -107,6 +107,7 @@ func installClean(ctx Context, config Config, what int) {
productOut("system"),
productOut("system_other"),
productOut("vendor"),
+ productOut("product"),
productOut("oem"),
productOut("obj/FAKE"),
productOut("breakpad"),