From 34bb032e6e4552d940b4dc43d59a3ad7d6de1c3a Mon Sep 17 00:00:00 2001 From: Connor O'Brien Date: Fri, 14 Jan 2022 21:46:07 -0800 Subject: build libelf-free minimal libbpf for device Add a device build of libbpf that includes only code with no libelf dependency, and which can therefore be used from framework code. bpf.c depends on a few symbols implemented in libbpf.c, so add a new file with stub implementations for those symbols. Also, the local linux/compiler.h and linux/types.h clobber the bionic versions, with the result that __user, __force and __poll_t are undefined. Since other bionic headers expect these to be defined, this causes most of the files under src/ to fail to compile. Add a header under android/ to ensure these are defined, and include it via Android.bp to minimize Android-specific changes to upstream libbpf code. Test: m libbpf_minimal Bug: 203823368 Signed-off-by: Connor O'Brien Change-Id: I326b31cac62bbd58905d25d45483cf968c00b971 --- Android.bp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'Android.bp') diff --git a/Android.bp b/Android.bp index ec55963..809e349 100644 --- a/Android.bp +++ b/Android.bp @@ -64,3 +64,30 @@ cc_library_host_static { ], compile_multilib: "64", } + +cc_library { + name: "libbpf_minimal", + native_bridge_supported: true, + srcs: [ + "android/bpf_stub.c", + "src/bpf.c", + "src/libbpf_errno.c", + "src/netlink.c", + "src/nlattr.c", + "src/ringbuf.c", + ], + local_include_dirs: [ + "android", + "include" + ], + export_include_dirs: [ + "include/uapi" + ], + generated_headers: ["libbpf_headers"], + export_generated_headers: ["libbpf_headers"], + cflags: [ + "-include android/android.h", + "-Wno-pointer-arith", + "-Wno-unused-parameter", + ], +} -- cgit v1.2.3