summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Neill Kapron <nkapron@google.com> 2024-07-30 22:03:27 +0000
committer Neill Kapron <nkapron@google.com> 2024-07-30 22:03:27 +0000
commit50a7bf8610b3b09ce6600b12985370b6b23a185c (patch)
tree00454d3242ee5b3793e7efcba9e3cb8fd169e3e3
parente1234e51b875f8d174ecc9acc49c17c5fad21aa2 (diff)
Soong: BPF: Cflag and btf defaults
Currently, all bpf programs require a cflags field which defines -Wall and -Werror. This change enables this by default, and also enables -Wextra. This removes boilerplate required for every bpf program, and improves code quality. Additionally, this change enables the default of 'btf: true' further reducing the boilerplate required for most bpf programs in their Android.bp file. BTF should be enabled by default, with only limited mainlined bpf programs requiring BTF being disabled for compatibility with older bpfloader releases. Test: Treehugger Change-Id: I8efd0f63115030d40c0ff7fe81d5345ff3436e5a Signed-off-by: Neill Kapron <nkapron@google.com>
-rw-r--r--bpf/bpf.go8
1 files changed, 6 insertions, 2 deletions
diff --git a/bpf/bpf.go b/bpf/bpf.go
index 09262e507..644539426 100644
--- a/bpf/bpf.go
+++ b/bpf/bpf.go
@@ -148,6 +148,10 @@ func (bpf *bpf) GenerateAndroidBuildActions(ctx android.ModuleContext) {
"-no-canonical-prefixes",
"-O2",
+ "-Wall",
+ "-Werror",
+ "-Wextra",
+
"-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.
@@ -165,7 +169,7 @@ func (bpf *bpf) GenerateAndroidBuildActions(ctx android.ModuleContext) {
cflags = append(cflags, bpf.properties.Cflags...)
- if proptools.Bool(bpf.properties.Btf) {
+ if proptools.BoolDefault(bpf.properties.Btf, true) {
cflags = append(cflags, "-g")
if runtime.GOOS != "darwin" {
cflags = append(cflags, "-fdebug-prefix-map=/proc/self/cwd=")
@@ -190,7 +194,7 @@ func (bpf *bpf) GenerateAndroidBuildActions(ctx android.ModuleContext) {
},
})
- if proptools.Bool(bpf.properties.Btf) {
+ if proptools.BoolDefault(bpf.properties.Btf, true) {
objStripped := android.ObjPathWithExt(ctx, "", src, "o")
ctx.Build(pctx, android.BuildParams{
Rule: stripRule,