From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DE8B9C43215 for ; Sat, 30 Nov 2019 00:13:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BC5BA24650 for ; Sat, 30 Nov 2019 00:13:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727193AbfK3AM6 (ORCPT ); Fri, 29 Nov 2019 19:12:58 -0500 Received: from www62.your-server.de ([213.133.104.62]:43690 "EHLO www62.your-server.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727130AbfK3AM6 (ORCPT ); Fri, 29 Nov 2019 19:12:58 -0500 Received: from sslproxy06.your-server.de ([78.46.172.3]) by www62.your-server.de with esmtpsa (TLSv1.2:DHE-RSA-AES256-GCM-SHA384:256) (Exim 4.89_1) (envelope-from ) id 1iaq82-0002ph-Pq; Sat, 30 Nov 2019 00:56:50 +0100 Received: from [178.197.249.29] (helo=pc-9.home) by sslproxy06.your-server.de with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.89) (envelope-from ) id 1iaq82-000WjV-90; Sat, 30 Nov 2019 00:56:50 +0100 Subject: Re: [PATCH bpf v3] bpftool: Allow to link libbpf dynamically To: =?UTF-8?Q?Toke_H=c3=b8iland-J=c3=b8rgensen?= , Alexei Starovoitov Cc: Jiri Olsa , lkml , netdev@vger.kernel.org, bpf@vger.kernel.org, Ingo Molnar , Namhyung Kim , Alexander Shishkin , Peter Zijlstra , Michael Petlan , Jesper Dangaard Brouer , Martin KaFai Lau , Song Liu , Yonghong Song , Andrii Nakryiko , Arnaldo Carvalho de Melo , kubakici@wp.pl References: <20191128160712.1048793-1-toke@redhat.com> <87a78evl2v.fsf@toke.dk> From: Daniel Borkmann Message-ID: <9853054b-dc1f-35ba-ba3c-4d0ab01c8f14@iogearbox.net> Date: Sat, 30 Nov 2019 00:56:49 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.2 MIME-Version: 1.0 In-Reply-To: <87a78evl2v.fsf@toke.dk> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-Authenticated-Sender: daniel@iogearbox.net X-Virus-Scanned: Clear (ClamAV 0.101.4/25648/Fri Nov 29 10:44:54 2019) Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On 11/29/19 3:00 PM, Toke Høiland-Jørgensen wrote: > Daniel Borkmann writes: >> On 11/28/19 5:07 PM, Toke Høiland-Jørgensen wrote: >>> From: Jiri Olsa [...] >>> 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