Message ID | 20230112004024.1934601-1-irogers@google.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp3617588wrt; Wed, 11 Jan 2023 16:48:16 -0800 (PST) X-Google-Smtp-Source: AMrXdXtkTFYNErYESjM7Y+oq+EvknJcfvHtIW7WLhEzb0fLkvG/QZUQ7GrhJrniGsPIPLeqd37KG X-Received: by 2002:a17:907:2113:b0:84d:4b39:1448 with SMTP id qn19-20020a170907211300b0084d4b391448mr11961506ejb.67.1673484496044; Wed, 11 Jan 2023 16:48:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673484496; cv=none; d=google.com; s=arc-20160816; b=PUyUBV9dMF9KT+S6wOgVsCv09xm7JTkVhY/R+pdy3HG1izKbWqv5TuVKB1Y9vL9Tz4 B2i+TY+pyNfnmBfoc06wM/gyOwcYNLBvzV6uVpeh5o41e0svgNrwu6vQhlWpEn7Z1Hv+ VViEmnlzU+J+A6VbanTGZO2BevPcD73HQGxXwcODVnzWAAUV2oxuLmjw3SwHGIMHt1LE ioBQABzMMYdWVGFvAZaSdx5WW+m/k2gpOmDchLOlnPu8hVy/Zgm8UxiB4j5owWAz1hCZ cWV9jW70/1zg3ztPgwczKFzX0ThImHkVALqmPOP3q8ACSqJeBxQY8MyyEdQnoFfEhTZx OcWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:from:subject:mime-version:message-id:date :dkim-signature; bh=h5P/G8QEaO3HyqhOGu82/HAf0R+66PdkPKsQpUDiMlc=; b=h/oWB2k4QPABcXEjptxCzyrh9LK0z5nkOSKLMOID0zy282eLZtKR2qGs7KbPwEhrXA d2n3loFhh6To2xDtJ5jlFOohSkAv82XUCl76/BuVOFGB9AfuLNQRwsfSHr8Tigx8S2N+ rBt0+RqvF3f8XBcEOVBBJ4wYTZUPCkYN9SfOWYA62t8KspjEMTloBRenY572BvzkkiLg 0PSnC+mjCUoNGGolp4suAxMe2CnM3h3x0bWfux64wjNqLtiQWxZRxZtQa2d/GReMOGBw u+hwVT34KS+EYU912FSboogIRjAnTSaGSIUsJzJTQT81yXR7tYmYvG2/A4hiyz60wcke Robw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b="eGF1F/lr"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id xh9-20020a170906da8900b0084d4b90896fsi8493169ejb.245.2023.01.11.16.47.52; Wed, 11 Jan 2023 16:48:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b="eGF1F/lr"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236097AbjALAlY (ORCPT <rfc822;syz17693488234@gmail.com> + 99 others); Wed, 11 Jan 2023 19:41:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57992 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232920AbjALAkp (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 11 Jan 2023 19:40:45 -0500 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 71045AE47 for <linux-kernel@vger.kernel.org>; Wed, 11 Jan 2023 16:40:44 -0800 (PST) Received: by mail-yb1-xb4a.google.com with SMTP id k204-20020a256fd5000000b007b8b040bc50so16193770ybc.1 for <linux-kernel@vger.kernel.org>; Wed, 11 Jan 2023 16:40:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=to:from:subject:mime-version:message-id:date:from:to:cc:subject :date:message-id:reply-to; bh=h5P/G8QEaO3HyqhOGu82/HAf0R+66PdkPKsQpUDiMlc=; b=eGF1F/lrqMAN39cq8nEU49coorNRUqIbHnBryr2InQnzMzIJqVkcu5LPJEwm9N98WX XfQXM1GX3/oQQD7WLmDXjPWDDCmAGtUKDrKG+13dIczddfM9NyrDPOxdTaJ2OiHTy7Ua VS9swDDP9KM29DD1GKHiBd7AONB27uTqkb5q82XGMSidBRLysjYg3uXSbYpvy2juUbUN sW7A3W4icerCbpWSVO1oWTlwIMOejaGAdCDE9GHEg5DWjLyQY0nxgB3zaJCByzx0uRzR jg9mAkaclTKJ4T4oUsjzayw971NIw0wGEB9BJkz+K2Ru3FAJQvWRAygLhr+2LU0pZjef 1gOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:from:subject:mime-version:message-id:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=h5P/G8QEaO3HyqhOGu82/HAf0R+66PdkPKsQpUDiMlc=; b=P2zRloM23CkBjbA5m0CnBP+gvRzIKUfvMemfHg+AqFS2v2FYIyVdkjXkMlgD9TVQv5 zTGEqLDz9GK0PzcuadNXW7hF479J7XWWQVWfLBY23Gi26gRBtjyL9gQbyLOilE/aByAa JYUpXNWGhmZG2tgv4l9RQBL6yPletimkPOahmEeOSq5uo4huis4b7pM3l5yOjv0ecHwQ P6uAj/vLBeXWVgyfIAfP+AAgJrjyH7p6wz02eF48u9pz5blNYDHDW2DOP4wkPom+pkZ2 c6xDTvesNQj4mOx//7+N8HYlZzTkPEsfU0ZMR+uAdErl/pCIZxe+Zm8MAlkB9Vb60ZFM k7Tg== X-Gm-Message-State: AFqh2koZCG5si6jix6/IlHEqReYLASglGihqLMmnNA+GJdkbOjJQx6Hl 7+AefHJ7wW6mQMf0xe86BT83vwJKJnqU X-Received: from irogers.svl.corp.google.com ([2620:15c:2d4:203:16b7:1d88:e27f:db49]) (user=irogers job=sendgmr) by 2002:a81:6f42:0:b0:36f:f251:213b with SMTP id k63-20020a816f42000000b0036ff251213bmr1500569ywc.228.1673484043746; Wed, 11 Jan 2023 16:40:43 -0800 (PST) Date: Wed, 11 Jan 2023 16:40:24 -0800 Message-Id: <20230112004024.1934601-1-irogers@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.39.0.314.g84b9a713c41-goog Subject: [PATCH v1] tools/resolve_btfids: Install subcmd headers From: Ian Rogers <irogers@google.com> To: Alexei Starovoitov <ast@kernel.org>, Daniel Borkmann <daniel@iogearbox.net>, Andrii Nakryiko <andrii@kernel.org>, Martin KaFai Lau <martin.lau@linux.dev>, Song Liu <song@kernel.org>, Yonghong Song <yhs@fb.com>, John Fastabend <john.fastabend@gmail.com>, KP Singh <kpsingh@kernel.org>, Stanislav Fomichev <sdf@google.com>, Hao Luo <haoluo@google.com>, Jiri Olsa <jolsa@kernel.org>, Connor OBrien <connoro@google.com>, Nathan Chancellor <nathan@kernel.org>, Ian Rogers <irogers@google.com>, Kumar Kartikeya Dwivedi <memxor@gmail.com>, bpf@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754775679030952179?= X-GMAIL-MSGID: =?utf-8?q?1754775679030952179?= |
Series |
[v1] tools/resolve_btfids: Install subcmd headers
|
|
Commit Message
Ian Rogers
Jan. 12, 2023, 12:40 a.m. UTC
Previously tools/lib/subcmd was added to the include path, switch to
installing the headers and then including from that directory. This
avoids dependencies on headers internal to tools/lib/subcmd. Add the
missing subcmd directory to the affected #include.
Signed-off-by: Ian Rogers <irogers@google.com>
---
tools/bpf/resolve_btfids/Makefile | 19 ++++++++++++++-----
tools/bpf/resolve_btfids/main.c | 2 +-
2 files changed, 15 insertions(+), 6 deletions(-)
Comments
On Wed, Jan 11, 2023 at 04:40:24PM -0800, Ian Rogers wrote: > Previously tools/lib/subcmd was added to the include path, switch to > installing the headers and then including from that directory. This > avoids dependencies on headers internal to tools/lib/subcmd. Add the > missing subcmd directory to the affected #include. > > Signed-off-by: Ian Rogers <irogers@google.com> > --- > tools/bpf/resolve_btfids/Makefile | 19 ++++++++++++++----- > tools/bpf/resolve_btfids/main.c | 2 +- > 2 files changed, 15 insertions(+), 6 deletions(-) this depends on changes that went to Arnaldo's tree right? I can't apply this on bpf-next/master > > diff --git a/tools/bpf/resolve_btfids/Makefile b/tools/bpf/resolve_btfids/Makefile > index 19a3112e271a..de7d29cf43d6 100644 > --- a/tools/bpf/resolve_btfids/Makefile > +++ b/tools/bpf/resolve_btfids/Makefile > @@ -35,21 +35,29 @@ SUBCMD_SRC := $(srctree)/tools/lib/subcmd/ > BPFOBJ := $(OUTPUT)/libbpf/libbpf.a > LIBBPF_OUT := $(abspath $(dir $(BPFOBJ)))/ > SUBCMDOBJ := $(OUTPUT)/libsubcmd/libsubcmd.a > +SUBCMD_OUT := $(abspath $(dir $(SUBCMDOBJ)))/ > > LIBBPF_DESTDIR := $(LIBBPF_OUT) > LIBBPF_INCLUDE := $(LIBBPF_DESTDIR)include > > +SUBCMD_DESTDIR := $(SUBCMD_OUT) > +SUBCMD_INCLUDE := $(SUBCMD_DESTDIR)include > + > BINARY := $(OUTPUT)/resolve_btfids > BINARY_IN := $(BINARY)-in.o > > all: $(BINARY) > > +prepare: $(SUBCMDOBJ) do we need special target for that? we already have BPFOBJ dependency placed in the BINARY_IN as prereq why not place both as BINARY_IN prereq, or is there some other reason for new 'prepare' target? jirka > + > $(OUTPUT) $(OUTPUT)/libsubcmd $(LIBBPF_OUT): > $(call msg,MKDIR,,$@) > $(Q)mkdir -p $(@) > > $(SUBCMDOBJ): fixdep FORCE | $(OUTPUT)/libsubcmd > - $(Q)$(MAKE) -C $(SUBCMD_SRC) OUTPUT=$(abspath $(dir $@))/ $(abspath $@) > + $(Q)$(MAKE) -C $(SUBCMD_SRC) OUTPUT=$(SUBCMD_OUT) \ > + DESTDIR=$(SUBCMD_DESTDIR) prefix= \ > + $(abspath $@) install_headers > > $(BPFOBJ): $(wildcard $(LIBBPF_SRC)/*.[ch] $(LIBBPF_SRC)/Makefile) | $(LIBBPF_OUT) > $(Q)$(MAKE) $(submake_extras) -C $(LIBBPF_SRC) OUTPUT=$(LIBBPF_OUT) \ > @@ -60,14 +68,14 @@ CFLAGS += -g \ > -I$(srctree)/tools/include \ > -I$(srctree)/tools/include/uapi \ > -I$(LIBBPF_INCLUDE) \ > - -I$(SUBCMD_SRC) > + -I$(SUBCMD_INCLUDE) > > LIBS = -lelf -lz > > export srctree OUTPUT CFLAGS Q > include $(srctree)/tools/build/Makefile.include > > -$(BINARY_IN): $(BPFOBJ) fixdep FORCE | $(OUTPUT) > +$(BINARY_IN): $(BPFOBJ) fixdep FORCE prepare | $(OUTPUT) > $(Q)$(MAKE) $(build)=resolve_btfids > > $(BINARY): $(BPFOBJ) $(SUBCMDOBJ) $(BINARY_IN) > @@ -79,7 +87,8 @@ clean_objects := $(wildcard $(OUTPUT)/*.o \ > $(OUTPUT)/.*.o.d \ > $(LIBBPF_OUT) \ > $(LIBBPF_DESTDIR) \ > - $(OUTPUT)/libsubcmd \ > + $(SUBCMD_OUT) \ > + $(SUBCMD_DESTDIR) \ > $(OUTPUT)/resolve_btfids) > > ifneq ($(clean_objects),) > @@ -96,4 +105,4 @@ tags: > > FORCE: > > -.PHONY: all FORCE clean tags > +.PHONY: all FORCE clean tags prepare > diff --git a/tools/bpf/resolve_btfids/main.c b/tools/bpf/resolve_btfids/main.c > index 80cd7843c677..77058174082d 100644 > --- a/tools/bpf/resolve_btfids/main.c > +++ b/tools/bpf/resolve_btfids/main.c > @@ -75,7 +75,7 @@ > #include <linux/err.h> > #include <bpf/btf.h> > #include <bpf/libbpf.h> > -#include <parse-options.h> > +#include <subcmd/parse-options.h> > > #define BTF_IDS_SECTION ".BTF_ids" > #define BTF_ID "__BTF_ID__" > -- > 2.39.0.314.g84b9a713c41-goog >
On Mon, Jan 16, 2023 at 3:22 AM Jiri Olsa <olsajiri@gmail.com> wrote: > > On Wed, Jan 11, 2023 at 04:40:24PM -0800, Ian Rogers wrote: > > Previously tools/lib/subcmd was added to the include path, switch to > > installing the headers and then including from that directory. This > > avoids dependencies on headers internal to tools/lib/subcmd. Add the > > missing subcmd directory to the affected #include. > > > > Signed-off-by: Ian Rogers <irogers@google.com> > > --- > > tools/bpf/resolve_btfids/Makefile | 19 ++++++++++++++----- > > tools/bpf/resolve_btfids/main.c | 2 +- > > 2 files changed, 15 insertions(+), 6 deletions(-) > > this depends on changes that went to Arnaldo's tree right? > I can't apply this on bpf-next/master Hmm.. sorry for that. I did the work on the master branch of git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git > > > > diff --git a/tools/bpf/resolve_btfids/Makefile b/tools/bpf/resolve_btfids/Makefile > > index 19a3112e271a..de7d29cf43d6 100644 > > --- a/tools/bpf/resolve_btfids/Makefile > > +++ b/tools/bpf/resolve_btfids/Makefile > > @@ -35,21 +35,29 @@ SUBCMD_SRC := $(srctree)/tools/lib/subcmd/ > > BPFOBJ := $(OUTPUT)/libbpf/libbpf.a > > LIBBPF_OUT := $(abspath $(dir $(BPFOBJ)))/ > > SUBCMDOBJ := $(OUTPUT)/libsubcmd/libsubcmd.a > > +SUBCMD_OUT := $(abspath $(dir $(SUBCMDOBJ)))/ > > > > LIBBPF_DESTDIR := $(LIBBPF_OUT) > > LIBBPF_INCLUDE := $(LIBBPF_DESTDIR)include > > > > +SUBCMD_DESTDIR := $(SUBCMD_OUT) > > +SUBCMD_INCLUDE := $(SUBCMD_DESTDIR)include > > + > > BINARY := $(OUTPUT)/resolve_btfids > > BINARY_IN := $(BINARY)-in.o > > > > all: $(BINARY) > > > > +prepare: $(SUBCMDOBJ) > > do we need special target for that? we already have BPFOBJ dependency > placed in the BINARY_IN as prereq BPFOBJ is $(OUTPUT)/libbpf/libbpf.a which is needed at link time. The prepare step is one we have elsewhere and it creates things like the header files necessary to compile the C code, so we need it earlier is the answer. > why not place both as BINARY_IN prereq, or is there some other reason > for new 'prepare' target? I was trying to follow the convention elsewhere in the tree of having a prepare target that does things like get the necessary header files ready. Having prepare is useful because if an additional dependency is added, then it just needs to be added to prepare. It could be tedious to list all the dependencies for every C file, although Makefile.build handles most of that. It isn't clear to me why $(BPFOBJ) is a dependency of $(BINARY_IN) as it is already a dependency of $(BINARY). Thanks, Ian > jirka > > > + > > $(OUTPUT) $(OUTPUT)/libsubcmd $(LIBBPF_OUT): > > $(call msg,MKDIR,,$@) > > $(Q)mkdir -p $(@) > > > > $(SUBCMDOBJ): fixdep FORCE | $(OUTPUT)/libsubcmd > > - $(Q)$(MAKE) -C $(SUBCMD_SRC) OUTPUT=$(abspath $(dir $@))/ $(abspath $@) > > + $(Q)$(MAKE) -C $(SUBCMD_SRC) OUTPUT=$(SUBCMD_OUT) \ > > + DESTDIR=$(SUBCMD_DESTDIR) prefix= \ > > + $(abspath $@) install_headers > > > > $(BPFOBJ): $(wildcard $(LIBBPF_SRC)/*.[ch] $(LIBBPF_SRC)/Makefile) | $(LIBBPF_OUT) > > $(Q)$(MAKE) $(submake_extras) -C $(LIBBPF_SRC) OUTPUT=$(LIBBPF_OUT) \ > > @@ -60,14 +68,14 @@ CFLAGS += -g \ > > -I$(srctree)/tools/include \ > > -I$(srctree)/tools/include/uapi \ > > -I$(LIBBPF_INCLUDE) \ > > - -I$(SUBCMD_SRC) > > + -I$(SUBCMD_INCLUDE) > > > > LIBS = -lelf -lz > > > > export srctree OUTPUT CFLAGS Q > > include $(srctree)/tools/build/Makefile.include > > > > -$(BINARY_IN): $(BPFOBJ) fixdep FORCE | $(OUTPUT) > > +$(BINARY_IN): $(BPFOBJ) fixdep FORCE prepare | $(OUTPUT) > > $(Q)$(MAKE) $(build)=resolve_btfids > > > > $(BINARY): $(BPFOBJ) $(SUBCMDOBJ) $(BINARY_IN) > > @@ -79,7 +87,8 @@ clean_objects := $(wildcard $(OUTPUT)/*.o \ > > $(OUTPUT)/.*.o.d \ > > $(LIBBPF_OUT) \ > > $(LIBBPF_DESTDIR) \ > > - $(OUTPUT)/libsubcmd \ > > + $(SUBCMD_OUT) \ > > + $(SUBCMD_DESTDIR) \ > > $(OUTPUT)/resolve_btfids) > > > > ifneq ($(clean_objects),) > > @@ -96,4 +105,4 @@ tags: > > > > FORCE: > > > > -.PHONY: all FORCE clean tags > > +.PHONY: all FORCE clean tags prepare > > diff --git a/tools/bpf/resolve_btfids/main.c b/tools/bpf/resolve_btfids/main.c > > index 80cd7843c677..77058174082d 100644 > > --- a/tools/bpf/resolve_btfids/main.c > > +++ b/tools/bpf/resolve_btfids/main.c > > @@ -75,7 +75,7 @@ > > #include <linux/err.h> > > #include <bpf/btf.h> > > #include <bpf/libbpf.h> > > -#include <parse-options.h> > > +#include <subcmd/parse-options.h> > > > > #define BTF_IDS_SECTION ".BTF_ids" > > #define BTF_ID "__BTF_ID__" > > -- > > 2.39.0.314.g84b9a713c41-goog > >
On Mon, Jan 16, 2023 at 09:20:39AM -0800, Ian Rogers wrote: > On Mon, Jan 16, 2023 at 3:22 AM Jiri Olsa <olsajiri@gmail.com> wrote: > > > > On Wed, Jan 11, 2023 at 04:40:24PM -0800, Ian Rogers wrote: > > > Previously tools/lib/subcmd was added to the include path, switch to > > > installing the headers and then including from that directory. This > > > avoids dependencies on headers internal to tools/lib/subcmd. Add the > > > missing subcmd directory to the affected #include. > > > > > > Signed-off-by: Ian Rogers <irogers@google.com> > > > --- > > > tools/bpf/resolve_btfids/Makefile | 19 ++++++++++++++----- > > > tools/bpf/resolve_btfids/main.c | 2 +- > > > 2 files changed, 15 insertions(+), 6 deletions(-) > > > > this depends on changes that went to Arnaldo's tree right? > > I can't apply this on bpf-next/master > > Hmm.. sorry for that. I did the work on the master branch of > git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git > > > > > > > diff --git a/tools/bpf/resolve_btfids/Makefile b/tools/bpf/resolve_btfids/Makefile > > > index 19a3112e271a..de7d29cf43d6 100644 > > > --- a/tools/bpf/resolve_btfids/Makefile > > > +++ b/tools/bpf/resolve_btfids/Makefile > > > @@ -35,21 +35,29 @@ SUBCMD_SRC := $(srctree)/tools/lib/subcmd/ > > > BPFOBJ := $(OUTPUT)/libbpf/libbpf.a > > > LIBBPF_OUT := $(abspath $(dir $(BPFOBJ)))/ > > > SUBCMDOBJ := $(OUTPUT)/libsubcmd/libsubcmd.a > > > +SUBCMD_OUT := $(abspath $(dir $(SUBCMDOBJ)))/ > > > > > > LIBBPF_DESTDIR := $(LIBBPF_OUT) > > > LIBBPF_INCLUDE := $(LIBBPF_DESTDIR)include > > > > > > +SUBCMD_DESTDIR := $(SUBCMD_OUT) > > > +SUBCMD_INCLUDE := $(SUBCMD_DESTDIR)include > > > + > > > BINARY := $(OUTPUT)/resolve_btfids > > > BINARY_IN := $(BINARY)-in.o > > > > > > all: $(BINARY) > > > > > > +prepare: $(SUBCMDOBJ) > > > > do we need special target for that? we already have BPFOBJ dependency > > placed in the BINARY_IN as prereq > > BPFOBJ is $(OUTPUT)/libbpf/libbpf.a which is needed at link time. The > prepare step is one we have elsewhere and it creates things like the > header files necessary to compile the C code, so we need it earlier is > the answer. > > > why not place both as BINARY_IN prereq, or is there some other reason > > for new 'prepare' target? > > I was trying to follow the convention elsewhere in the tree of having > a prepare target that does things like get the necessary header files > ready. Having prepare is useful because if an additional dependency is > added, then it just needs to be added to prepare. It could be tedious > to list all the dependencies for every C file, although Makefile.build ok, could we maybe add the BPFOBJ in prepare target as well? > handles most of that. It isn't clear to me why $(BPFOBJ) is a > dependency of $(BINARY_IN) as it is already a dependency of $(BINARY). I think that if you specify OUTPUT then we need the libbpf headers to be created before we go to compile resolve_btfids objects thanks, jirka
On Mon, Jan 16, 2023 at 10:20 AM Jiri Olsa <olsajiri@gmail.com> wrote: > > On Mon, Jan 16, 2023 at 09:20:39AM -0800, Ian Rogers wrote: > > On Mon, Jan 16, 2023 at 3:22 AM Jiri Olsa <olsajiri@gmail.com> wrote: > > > > > > On Wed, Jan 11, 2023 at 04:40:24PM -0800, Ian Rogers wrote: > > > > Previously tools/lib/subcmd was added to the include path, switch to > > > > installing the headers and then including from that directory. This > > > > avoids dependencies on headers internal to tools/lib/subcmd. Add the > > > > missing subcmd directory to the affected #include. > > > > > > > > Signed-off-by: Ian Rogers <irogers@google.com> > > > > --- > > > > tools/bpf/resolve_btfids/Makefile | 19 ++++++++++++++----- > > > > tools/bpf/resolve_btfids/main.c | 2 +- > > > > 2 files changed, 15 insertions(+), 6 deletions(-) > > > > > > this depends on changes that went to Arnaldo's tree right? > > > I can't apply this on bpf-next/master > > > > Hmm.. sorry for that. I did the work on the master branch of > > git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git > > > > > > > > > > diff --git a/tools/bpf/resolve_btfids/Makefile b/tools/bpf/resolve_btfids/Makefile > > > > index 19a3112e271a..de7d29cf43d6 100644 > > > > --- a/tools/bpf/resolve_btfids/Makefile > > > > +++ b/tools/bpf/resolve_btfids/Makefile > > > > @@ -35,21 +35,29 @@ SUBCMD_SRC := $(srctree)/tools/lib/subcmd/ > > > > BPFOBJ := $(OUTPUT)/libbpf/libbpf.a > > > > LIBBPF_OUT := $(abspath $(dir $(BPFOBJ)))/ > > > > SUBCMDOBJ := $(OUTPUT)/libsubcmd/libsubcmd.a > > > > +SUBCMD_OUT := $(abspath $(dir $(SUBCMDOBJ)))/ > > > > > > > > LIBBPF_DESTDIR := $(LIBBPF_OUT) > > > > LIBBPF_INCLUDE := $(LIBBPF_DESTDIR)include > > > > > > > > +SUBCMD_DESTDIR := $(SUBCMD_OUT) > > > > +SUBCMD_INCLUDE := $(SUBCMD_DESTDIR)include > > > > + > > > > BINARY := $(OUTPUT)/resolve_btfids > > > > BINARY_IN := $(BINARY)-in.o > > > > > > > > all: $(BINARY) > > > > > > > > +prepare: $(SUBCMDOBJ) > > > > > > do we need special target for that? we already have BPFOBJ dependency > > > placed in the BINARY_IN as prereq > > > > BPFOBJ is $(OUTPUT)/libbpf/libbpf.a which is needed at link time. The > > prepare step is one we have elsewhere and it creates things like the > > header files necessary to compile the C code, so we need it earlier is > > the answer. > > > > > why not place both as BINARY_IN prereq, or is there some other reason > > > for new 'prepare' target? > > > > I was trying to follow the convention elsewhere in the tree of having > > a prepare target that does things like get the necessary header files > > ready. Having prepare is useful because if an additional dependency is > > added, then it just needs to be added to prepare. It could be tedious > > to list all the dependencies for every C file, although Makefile.build > > ok, could we maybe add the BPFOBJ in prepare target as well? Agreed, added to v2. > > handles most of that. It isn't clear to me why $(BPFOBJ) is a > > dependency of $(BINARY_IN) as it is already a dependency of $(BINARY). > > I think that if you specify OUTPUT then we need the libbpf headers > to be created before we go to compile resolve_btfids objects > > thanks, > jirka Yep. I also noticed that this code is doing the "CC=$(HOSTCC)" thing. The problem with that is Makefile.include (line 2) will set things like CFLAGS based on CC and then you change it. I sent out some objtool build cleanup for this: https://lore.kernel.org/lkml/20230105090155.357604-4-irogers@google.com/ I'll add a patch for this in v2. Thanks, Ian
diff --git a/tools/bpf/resolve_btfids/Makefile b/tools/bpf/resolve_btfids/Makefile index 19a3112e271a..de7d29cf43d6 100644 --- a/tools/bpf/resolve_btfids/Makefile +++ b/tools/bpf/resolve_btfids/Makefile @@ -35,21 +35,29 @@ SUBCMD_SRC := $(srctree)/tools/lib/subcmd/ BPFOBJ := $(OUTPUT)/libbpf/libbpf.a LIBBPF_OUT := $(abspath $(dir $(BPFOBJ)))/ SUBCMDOBJ := $(OUTPUT)/libsubcmd/libsubcmd.a +SUBCMD_OUT := $(abspath $(dir $(SUBCMDOBJ)))/ LIBBPF_DESTDIR := $(LIBBPF_OUT) LIBBPF_INCLUDE := $(LIBBPF_DESTDIR)include +SUBCMD_DESTDIR := $(SUBCMD_OUT) +SUBCMD_INCLUDE := $(SUBCMD_DESTDIR)include + BINARY := $(OUTPUT)/resolve_btfids BINARY_IN := $(BINARY)-in.o all: $(BINARY) +prepare: $(SUBCMDOBJ) + $(OUTPUT) $(OUTPUT)/libsubcmd $(LIBBPF_OUT): $(call msg,MKDIR,,$@) $(Q)mkdir -p $(@) $(SUBCMDOBJ): fixdep FORCE | $(OUTPUT)/libsubcmd - $(Q)$(MAKE) -C $(SUBCMD_SRC) OUTPUT=$(abspath $(dir $@))/ $(abspath $@) + $(Q)$(MAKE) -C $(SUBCMD_SRC) OUTPUT=$(SUBCMD_OUT) \ + DESTDIR=$(SUBCMD_DESTDIR) prefix= \ + $(abspath $@) install_headers $(BPFOBJ): $(wildcard $(LIBBPF_SRC)/*.[ch] $(LIBBPF_SRC)/Makefile) | $(LIBBPF_OUT) $(Q)$(MAKE) $(submake_extras) -C $(LIBBPF_SRC) OUTPUT=$(LIBBPF_OUT) \ @@ -60,14 +68,14 @@ CFLAGS += -g \ -I$(srctree)/tools/include \ -I$(srctree)/tools/include/uapi \ -I$(LIBBPF_INCLUDE) \ - -I$(SUBCMD_SRC) + -I$(SUBCMD_INCLUDE) LIBS = -lelf -lz export srctree OUTPUT CFLAGS Q include $(srctree)/tools/build/Makefile.include -$(BINARY_IN): $(BPFOBJ) fixdep FORCE | $(OUTPUT) +$(BINARY_IN): $(BPFOBJ) fixdep FORCE prepare | $(OUTPUT) $(Q)$(MAKE) $(build)=resolve_btfids $(BINARY): $(BPFOBJ) $(SUBCMDOBJ) $(BINARY_IN) @@ -79,7 +87,8 @@ clean_objects := $(wildcard $(OUTPUT)/*.o \ $(OUTPUT)/.*.o.d \ $(LIBBPF_OUT) \ $(LIBBPF_DESTDIR) \ - $(OUTPUT)/libsubcmd \ + $(SUBCMD_OUT) \ + $(SUBCMD_DESTDIR) \ $(OUTPUT)/resolve_btfids) ifneq ($(clean_objects),) @@ -96,4 +105,4 @@ tags: FORCE: -.PHONY: all FORCE clean tags +.PHONY: all FORCE clean tags prepare diff --git a/tools/bpf/resolve_btfids/main.c b/tools/bpf/resolve_btfids/main.c index 80cd7843c677..77058174082d 100644 --- a/tools/bpf/resolve_btfids/main.c +++ b/tools/bpf/resolve_btfids/main.c @@ -75,7 +75,7 @@ #include <linux/err.h> #include <bpf/btf.h> #include <bpf/libbpf.h> -#include <parse-options.h> +#include <subcmd/parse-options.h> #define BTF_IDS_SECTION ".BTF_ids" #define BTF_ID "__BTF_ID__"