On Wed, Oct 28, 2020 at 09:00:41PM -0600, David Ahern wrote: > >> nope. you need to be able to handle this. Ubuntu 20.10 was just > >> released, and it has a version of libbpf. If you are going to integrate > >> libbpf into other packages like iproute2, it needs to just work with > >> that version. > > > > OK, I can replace bpf_program__section_name by bpf_program__title(). > > I believe this one can be handled through a compatability check. Looks > the rename / deprecation is fairly recent (78cdb58bdf15f from Sept 2020). Hi David, I just come up with another way. In configure, build a temp program and update the function checking every time is not graceful. How about just check the libbpf version, since libbpf has exported all functions in src/libbpf.map. Currently, only bpf_program__section_name() is added in 0.2.0, all other needed functions are supported in 0.1.0. So in configure, the new check would like: check_force_libbpf() { # if set FORCE_LIBBPF but no libbpf support, just exist the config # process to make sure we don't build without libbpf. if [ -n "$FORCE_LIBBPF" ]; then echo "FORCE_LIBBPF set, but couldn't find a usable libbpf" exit 1 fi } check_libbpf() { if ! ${PKG_CONFIG} libbpf --exists && [ -z "$LIBBPF_DIR" ] ; then echo "no" check_force_libbpf return fi if [ $(uname -m) == x86_64 ]; then local LIBSUBDIR=lib64 else local LIBSUBDIR=lib fi if [ -n "$LIBBPF_DIR" ]; then LIBBPF_CFLAGS="-I${LIBBPF_DIR}/include -L${LIBBPF_DIR}/${LIBSUBDIR}" LIBBPF_LDLIBS="${LIBBPF_DIR}/${LIBSUBDIR}/libbpf.a -lz -lelf" else LIBBPF_CFLAGS=$(${PKG_CONFIG} libbpf --cflags) LIBBPF_LDLIBS=$(${PKG_CONFIG} libbpf --libs) fi if ${PKG_CONFIG} libbpf --atleast-version 0.1.0 || \ PKG_CONFIG_LIBDIR=${LIBBPF_DIR}/${LIBSUBDIR}/pkgconfig \ ${PKG_CONFIG} libbpf --atleast-version 0.1.0; then echo "HAVE_LIBBPF:=y" >>$CONFIG echo 'CFLAGS += -DHAVE_LIBBPF ' $LIBBPF_CFLAGS >> $CONFIG echo 'LDLIBS += ' $LIBBPF_LDLIBS >>$CONFIG echo "yes" else echo "no" check_force_libbpf return fi # bpf_program__title() is deprecated since libbpf 0.2.0, use # bpf_program__section_name() instead if we support if ${PKG_CONFIG} libbpf --atleast-version 0.2.0 || \ PKG_CONFIG_LIBDIR=${LIBBPF_DIR}/${LIBSUBDIR}/pkgconfig \ ${PKG_CONFIG} libbpf --atleast-version 0.2.0; then echo 'CFLAGS += -DHAVE_LIBBPF_SECTION_NAME ' $LIBBPF_CFLAGS >> $CONFIG fi } And in lib/bpf_libbpf.c, we add a new helper like: static const char *get_bpf_program__section_name(const struct bpf_program *prog) { #ifdef HAVE_LIBBPF_SECTION_NAME return bpf_program__section_name(prog); #else return bpf_program__title(prog, false); #endif } Thanks Hangbin