Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp1294119ybl; Mon, 2 Dec 2019 01:01:21 -0800 (PST) X-Google-Smtp-Source: APXvYqyke1EJdeolDyAsbl8IUsJiZJOgzRNVl+EZn5qSv0TJ+f+hY2nDbqK1SaHrjJM/Np2dr9bI X-Received: by 2002:aa7:d842:: with SMTP id f2mr61562715eds.262.1575277281207; Mon, 02 Dec 2019 01:01:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575277281; cv=none; d=google.com; s=arc-20160816; b=NFL+o7WL2FUelbBhvkGfNvXwa5twgD1vUI0cenJFU1nzLAjrUWTEsEk9r8PP+8z8oD J/XLybmqQtpr+brYl/Mqt6aj8MCSDn0KaFvZUjXGNj5Zp72vfGwc/38mdGnder1JxTX6 N3SnOsSQb9y49lgDbD/SlWwASPhAdvNGfmWlyWMV3Olwrez1qUCH5/EweewrYINSZTLM S91Ji+gKZY+UE/GAPY2tvYWow6R3oYCKU8A+E4TlAdOWxVdwgx052WMyRnTR8qJzvgdt b8whecQrevB2OMisXXNNZ9VekKxMLUuljG0NV1EJfVDmZECTYa4m4A+Jp42xflpQAMO/ 7qxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:user-agent:in-reply-to:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=rqUhLYNVakxLZv9wvfIxbDIemSFX/PcA3x0PAcyj2AI=; b=qxAmG1rb/EFOrpilsY4uhsHEyBNH23avjfgh2DMF5TBs3uVG8yap+s48n7Qrnn/t6+ 59v677SETyUd0zRFuBrsF1qELOYWzw7gltqNeGEBJYiNP29whejBT1LlaKDp7uP3zP1s K9V8Ef1fJmOGkVSz8X5LgxWAc2125rHLj5iiESJi3sgYjnT6w8wO0aXMwa7HFRozd8hn wsjLS8nUFBrvGIEveKqOwLVX6NYCKQpiMeM18tghHn8eeSP9bBqorjl/my7U9mivc2SH LfF3ZMQOjQN4xcptEpDM2yqp/CpaB9Fp3t2JS15tRnHyy4P6ZV2FM5of1IEoqGm3WL1s 6Otw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=EQbHYK6R; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q13si328522edw.342.2019.12.02.01.00.57; Mon, 02 Dec 2019 01:01:21 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=EQbHYK6R; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726318AbfLBI7p (ORCPT + 99 others); Mon, 2 Dec 2019 03:59:45 -0500 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:55261 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726057AbfLBI7p (ORCPT ); Mon, 2 Dec 2019 03:59:45 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1575277184; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rqUhLYNVakxLZv9wvfIxbDIemSFX/PcA3x0PAcyj2AI=; b=EQbHYK6RUHsWN2+qhkCpfj3eAyT0+4VaMPuOX1CsmHVSWhoszv9IR94TZ3o2/B2RlbBfLr IFLjYfaKCrHpvc5A/hNuAYWZFcarngMI23yBE4+AXzbSAZbc5TSEdF0fMfl+vRYzCIcUKn yZ4FuY9iMvca7mWtQ6HUA2eHGe9YFhg= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-399-lFiTp444MaORIzOiSLocmw-1; Mon, 02 Dec 2019 03:59:43 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 72A42800D53; Mon, 2 Dec 2019 08:59:40 +0000 (UTC) Received: from krava (unknown [10.43.17.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3C1885D6A0; Mon, 2 Dec 2019 08:59:30 +0000 (UTC) Date: Mon, 2 Dec 2019 09:59:30 +0100 From: Jiri Olsa To: Daniel Borkmann Cc: Toke =?iso-8859-1?Q?H=F8iland-J=F8rgensen?= , Alexei Starovoitov , 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 Subject: Re: [PATCH bpf v3] bpftool: Allow to link libbpf dynamically Message-ID: <20191202085930.GB5849@krava> References: <20191128160712.1048793-1-toke@redhat.com> <87a78evl2v.fsf@toke.dk> <9853054b-dc1f-35ba-ba3c-4d0ab01c8f14@iogearbox.net> MIME-Version: 1.0 In-Reply-To: <9853054b-dc1f-35ba-ba3c-4d0ab01c8f14@iogearbox.net> User-Agent: Mutt/1.12.1 (2019-06-15) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-MC-Unique: lFiTp444MaORIzOiSLocmw-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Nov 30, 2019 at 12:56:49AM +0100, Daniel Borkmann wrote: > On 11/29/19 3:00 PM, Toke H=F8iland-J=F8rgensen wrote: > > Daniel Borkmann writes: > > > On 11/28/19 5:07 PM, Toke H=F8iland-J=F8rgensen wrote: > > > > From: Jiri Olsa > [...] > > > > ifeq ($(srctree),) > > > > srctree :=3D $(patsubst %/,%,$(dir $(CURDIR))) > > > > @@ -63,6 +72,19 @@ RM ?=3D rm -f > > > > FEATURE_USER =3D .bpftool > > > > FEATURE_TESTS =3D libbfd disassembler-four-args reallocarray zli= b > > > > FEATURE_DISPLAY =3D libbfd disassembler-four-args zlib > > > > +ifdef LIBBPF_DYNAMIC > > > > + FEATURE_TESTS +=3D libbpf > > > > + FEATURE_DISPLAY +=3D libbpf > > > > + > > > > + # for linking with debug library run: > > > > + # make LIBBPF_DYNAMIC=3D1 LIBBPF_DIR=3D/opt/libbpf > > >=20 > > > 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. > >=20 > > 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. > >=20 > > Would it be less confusing to overload the LIBBPF_DYNAMIC variable > > instead? I.e., > >=20 > > make LIBBPF_DYNAMIC=3D1 > >=20 > > would dynamically link against the libbpf installed in the system, but > >=20 > > make LIBBPF_DYNAMIC=3D/opt/libbpf > >=20 > > would override that and link against whatever is in /opt/libbpf instead= ? > > WDYT? >=20 > Hm, given perf tool has similar LIB*_DIR vars in place for its libs, it p= robably > 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. ok, will have separate patch for this >=20 > One thing that would be good to do as well for this patch is to: >=20 > i) Document both LIBBPF_DYNAMIC and LIBBPF_DIR in the Makefile comment y= ou > added at the top along with a simple usage example. ok >=20 > ii) Extend tools/testing/selftests/bpf/test_bpftool_build.sh with a dynam= ic > linking test case, e.g. building libbpf into a temp dir and pointing > LIBBPF_DIR to it for bpftool LIBBPF_DYNAMIC=3D1 build. ok, will send new version soon thanks, jirka >=20 > Thanks, > Daniel >=20