[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <9853054b-dc1f-35ba-ba3c-4d0ab01c8f14@iogearbox.net>
Date: Sat, 30 Nov 2019 00:56:49 +0100
From: Daniel Borkmann <daniel@...earbox.net>
To: Toke Høiland-Jørgensen <toke@...hat.com>,
Alexei Starovoitov <alexei.starovoitov@...il.com>
Cc: Jiri Olsa <jolsa@...nel.org>, lkml <linux-kernel@...r.kernel.org>,
netdev@...r.kernel.org, bpf@...r.kernel.org,
Ingo Molnar <mingo@...nel.org>,
Namhyung Kim <namhyung@...nel.org>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
Peter Zijlstra <a.p.zijlstra@...llo.nl>,
Michael Petlan <mpetlan@...hat.com>,
Jesper Dangaard Brouer <brouer@...hat.com>,
Martin KaFai Lau <kafai@...com>,
Song Liu <songliubraving@...com>, Yonghong Song <yhs@...com>,
Andrii Nakryiko <andriin@...com>,
Arnaldo Carvalho de Melo <acme@...nel.org>, kubakici@...pl
Subject: Re: [PATCH bpf v3] bpftool: Allow to link libbpf dynamically
On 11/29/19 3:00 PM, Toke Høiland-Jørgensen wrote:
> Daniel Borkmann <daniel@...earbox.net> writes:
>> On 11/28/19 5:07 PM, Toke Høiland-Jørgensen wrote:
>>> From: Jiri Olsa <jolsa@...nel.org>
[...]
>>> ifeq ($(srctree),)
>>> srctree := $(patsubst %/,%,$(dir $(CURDIR)))
>>> @@ -63,6 +72,19 @@ RM ?= rm -f
>>> FEATURE_USER = .bpftool
>>> FEATURE_TESTS = libbfd disassembler-four-args reallocarray zlib
>>> FEATURE_DISPLAY = libbfd disassembler-four-args zlib
>>> +ifdef LIBBPF_DYNAMIC
>>> + FEATURE_TESTS += libbpf
>>> + FEATURE_DISPLAY += libbpf
>>> +
>>> + # for linking with debug library run:
>>> + # make LIBBPF_DYNAMIC=1 LIBBPF_DIR=/opt/libbpf
>>
>> The Makefile already has BPF_DIR which points right now to
>> '$(srctree)/tools/lib/bpf/' and LIBBPF_PATH for the final one and
>> where $(LIBBPF_PATH)libbpf.a is expected to reside. Can't we improve
>> the Makefile to reuse and work with these instead of adding yet
>> another LIBBPF_DIR var which makes future changes in this area more
>> confusing? The libbpf build spills out libbpf.{a,so*} by default
>> anyway.
>
> I see what you mean; however, LIBBPF_DIR is meant to be specifically an
> override for the dynamic library, not just the path to libbpf.
>
> Would it be less confusing to overload the LIBBPF_DYNAMIC variable
> instead? I.e.,
>
> make LIBBPF_DYNAMIC=1
>
> would dynamically link against the libbpf installed in the system, but
>
> make LIBBPF_DYNAMIC=/opt/libbpf
>
> would override that and link against whatever is in /opt/libbpf instead?
> WDYT?
Hm, given perf tool has similar LIB*_DIR vars in place for its libs, it probably
makes sense to stick with this convention as well then. Perhaps better in this
case to just rename s/BPF_DIR/BPF_SRC_DIR/, s/LIBBPF_OUTPUT/LIBBPF_BUILD_OUTPUT/,
and s/LIBBPF_PATH/LIBBPF_BUILD_PATH/ to make their purpose more clear.
One thing that would be good to do as well for this patch is to:
i) Document both LIBBPF_DYNAMIC and LIBBPF_DIR in the Makefile comment you
added at the top along with a simple usage example.
ii) Extend tools/testing/selftests/bpf/test_bpftool_build.sh with a dynamic
linking test case, e.g. building libbpf into a temp dir and pointing
LIBBPF_DIR to it for bpftool LIBBPF_DYNAMIC=1 build.
Thanks,
Daniel
Powered by blists - more mailing lists