1 2package { 3 default_applicable_licenses: ["external_bpftool_license"], 4} 5 6// See: http://go/android-license-faq 7license { 8 name: "external_bpftool_license", 9 visibility: [":__subpackages__"], 10 license_kinds: [ 11 "SPDX-license-identifier-BSD-2-Clause", 12 "SPDX-license-identifier-GPL-2.0-only", 13 ], 14 license_text: [ 15 "LICENSE.BSD-2-Clause", 16 "LICENSE.GPL-2.0", 17 ], 18} 19 20cc_binary { 21 name: "bpftool", 22 defaults: ["elfutils_transitive_defaults"], 23 host_supported: true, 24 srcs: [ 25 "src/*.c", 26 "src/kernel/bpf/disasm.c", 27 ], 28 exclude_srcs: [ 29 "src/jit_disasm.c", 30 ], 31 local_include_dirs: [ 32 "include", 33 "include/uapi", 34 "src/kernel/bpf" 35 ], 36 target: { 37 // There is an unfortunate interaction between the bionic uapi headers 38 // (also used by musl) and the kernel headers distributed with bpftool. 39 // The bionic uapi headers include <linux/compiler_types.h>, which they 40 // expect to be resolved to their own copy of compiler_types.h that 41 // includes compiler.h. It instead resolves to the bpftool copy, 42 // which includes compiler-gcc.h directly, triggering an error if 43 // the _LINUX_COMPILER_H_ header guard is not already defined. Hack 44 // around it by always including linux/compiler.h from the command line. 45 musl: { 46 47 cflags: ["-include linux/compiler.h"], 48 }, 49 bionic: { 50 cflags: ["-include linux/compiler.h"], 51 }, 52 }, 53 static_libs: [ 54 "libbpf", 55 "libcap", 56 "libelf", 57 "libz", 58 ], 59 cflags: [ 60 "-DBPFTOOL_WITHOUT_SKELETONS", 61 "-DBPFTOOL_VERSION=\"5.16.0-c446fdacb10d\"", 62 "-DUSE_LIBCAP", 63 "-Wno-missing-field-initializers", 64 "-Wno-pointer-arith", 65 "-Wno-unused-parameter", 66 ] 67} 68