diff mbox series

[bpf-next,1/4] tools/resolve_btfids: Build libbpf and libsubcmd in separate directories

Message ID 20210205124020.683286-2-jolsa@kernel.org (mailing list archive)
State Accepted
Delegated to: BPF
Headers show
Series kbuild/resolve_btfids: Invoke resolve_btfids clean in root Makefile | expand

Checks

Context Check Description
netdev/cover_letter success Link
netdev/fixes_present success Link
netdev/patch_count success Link
netdev/tree_selection success Clearly marked for bpf-next
netdev/subject_prefix success Link
netdev/cc_maintainers warning 4 maintainers not CCed: kpsingh@kernel.org toke@redhat.com andrii@kernel.org jean-philippe@linaro.org
netdev/source_inline success Was 0 now: 0
netdev/verify_signedoff success Link
netdev/module_param success Was 0 now: 0
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/verify_fixes success Link
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 60 lines checked
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/header_inline success Link
netdev/stable success Stable not CCed

Commit Message

Jiri Olsa Feb. 5, 2021, 12:40 p.m. UTC
Setting up separate build directories for libbpf and libpsubcmd,
so it's separated from other objects and we don't get them mixed
in the future.

It also simplifies cleaning, which is now simple rm -rf.

Also there's no need for FEATURE-DUMP.libbpf and bpf_helper_defs.h
files in .gitignore anymore.

Acked-by: Song Liu <songliubraving@fb.com>
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 tools/bpf/resolve_btfids/.gitignore |  2 --
 tools/bpf/resolve_btfids/Makefile   | 26 +++++++++++---------------
 2 files changed, 11 insertions(+), 17 deletions(-)

Comments

Andrii Nakryiko Feb. 5, 2021, 10:24 p.m. UTC | #1
On Fri, Feb 5, 2021 at 4:46 AM Jiri Olsa <jolsa@kernel.org> wrote:
>
> Setting up separate build directories for libbpf and libpsubcmd,
> so it's separated from other objects and we don't get them mixed
> in the future.
>
> It also simplifies cleaning, which is now simple rm -rf.
>
> Also there's no need for FEATURE-DUMP.libbpf and bpf_helper_defs.h
> files in .gitignore anymore.
>
> Acked-by: Song Liu <songliubraving@fb.com>
> Signed-off-by: Jiri Olsa <jolsa@kernel.org>
> ---

Acked-by: Andrii Nakryiko <andrii@kernel.org>

>  tools/bpf/resolve_btfids/.gitignore |  2 --
>  tools/bpf/resolve_btfids/Makefile   | 26 +++++++++++---------------
>  2 files changed, 11 insertions(+), 17 deletions(-)
>
> diff --git a/tools/bpf/resolve_btfids/.gitignore b/tools/bpf/resolve_btfids/.gitignore
> index a026df7dc280..25f308c933cc 100644
> --- a/tools/bpf/resolve_btfids/.gitignore
> +++ b/tools/bpf/resolve_btfids/.gitignore
> @@ -1,4 +1,2 @@
> -/FEATURE-DUMP.libbpf
> -/bpf_helper_defs.h
>  /fixdep
>  /resolve_btfids
> diff --git a/tools/bpf/resolve_btfids/Makefile b/tools/bpf/resolve_btfids/Makefile
> index bf656432ad73..1d46a247ec95 100644
> --- a/tools/bpf/resolve_btfids/Makefile
> +++ b/tools/bpf/resolve_btfids/Makefile
> @@ -28,22 +28,22 @@ OUTPUT ?= $(srctree)/tools/bpf/resolve_btfids/
>  LIBBPF_SRC := $(srctree)/tools/lib/bpf/
>  SUBCMD_SRC := $(srctree)/tools/lib/subcmd/
>
> -BPFOBJ     := $(OUTPUT)/libbpf.a
> -SUBCMDOBJ  := $(OUTPUT)/libsubcmd.a
> +BPFOBJ     := $(OUTPUT)/libbpf/libbpf.a
> +SUBCMDOBJ  := $(OUTPUT)/libsubcmd/libsubcmd.a
>
>  BINARY     := $(OUTPUT)/resolve_btfids
>  BINARY_IN  := $(BINARY)-in.o
>
>  all: $(BINARY)
>
> -$(OUTPUT):
> +$(OUTPUT) $(OUTPUT)/libbpf $(OUTPUT)/libsubcmd:
>         $(call msg,MKDIR,,$@)
> -       $(Q)mkdir -p $(OUTPUT)
> +       $(Q)mkdir -p $(@)
>
> -$(SUBCMDOBJ): fixdep FORCE
> -       $(Q)$(MAKE) -C $(SUBCMD_SRC) OUTPUT=$(OUTPUT)
> +$(SUBCMDOBJ): fixdep FORCE | $(OUTPUT)/libsubcmd
> +       $(Q)$(MAKE) -C $(SUBCMD_SRC) OUTPUT=$(abspath $(dir $@))/ $(abspath $@)
>
> -$(BPFOBJ): $(wildcard $(LIBBPF_SRC)/*.[ch] $(LIBBPF_SRC)/Makefile) | $(OUTPUT)
> +$(BPFOBJ): $(wildcard $(LIBBPF_SRC)/*.[ch] $(LIBBPF_SRC)/Makefile) | $(OUTPUT)/libbpf
>         $(Q)$(MAKE) $(submake_extras) -C $(LIBBPF_SRC)  OUTPUT=$(abspath $(dir $@))/ $(abspath $@)
>
>  CFLAGS := -g \
> @@ -57,23 +57,19 @@ LIBS = -lelf -lz
>  export srctree OUTPUT CFLAGS Q
>  include $(srctree)/tools/build/Makefile.include
>
> -$(BINARY_IN): fixdep FORCE
> +$(BINARY_IN): fixdep FORCE | $(OUTPUT)
>         $(Q)$(MAKE) $(build)=resolve_btfids
>
>  $(BINARY): $(BPFOBJ) $(SUBCMDOBJ) $(BINARY_IN)
>         $(call msg,LINK,$@)
>         $(Q)$(CC) $(BINARY_IN) $(LDFLAGS) -o $@ $(BPFOBJ) $(SUBCMDOBJ) $(LIBS)
>
> -libsubcmd-clean:
> -       $(Q)$(MAKE) -C $(SUBCMD_SRC) OUTPUT=$(OUTPUT) clean
> -
> -libbpf-clean:
> -       $(Q)$(MAKE) -C $(LIBBPF_SRC) OUTPUT=$(OUTPUT) clean
> -
> -clean: libsubcmd-clean libbpf-clean fixdep-clean
> +clean: fixdep-clean
>         $(call msg,CLEAN,$(BINARY))
>         $(Q)$(RM) -f $(BINARY); \
>         $(RM) -rf $(if $(OUTPUT),$(OUTPUT),.)/feature; \
> +       $(RM) -rf $(OUTPUT)/libbpf; \
> +       $(RM) -rf $(OUTPUT)/libsubcmd; \
>         find $(if $(OUTPUT),$(OUTPUT),.) -name \*.o -or -name \*.o.cmd -or -name \*.o.d | xargs $(RM)
>
>  tags:
> --
> 2.26.2
>
Viktor Jägersküpper March 10, 2021, 5:27 p.m. UTC | #2
Hi,

> Setting up separate build directories for libbpf and libpsubcmd,
> so it's separated from other objects and we don't get them mixed
> in the future.
> 
> It also simplifies cleaning, which is now simple rm -rf.
> 
> Also there's no need for FEATURE-DUMP.libbpf and bpf_helper_defs.h
> files in .gitignore anymore.
> 
> Acked-by: Song Liu <songliubraving@fb.com>
> Signed-off-by: Jiri Olsa <jolsa@kernel.org>
> ---

when I invoke 'git status' on the master branch of my local git repository
(cloned from stable/linux.git), which I have used to compile several kernels,
it lists two untracked files:

	tools/bpf/resolve_btfids/FEATURE-DUMP.libbpf
	tools/bpf/resolve_btfids/bpf_helper_defs.h

'git status' doesn't complain about these files with v5.11, and I can't get rid
of them by 'make clean' with v5.11 or v5.12-rc1/rc2. So I used 'git bisect' and
found that this is caused by commit fc6b48f692f89cc48bfb7fd1aa65454dfe9b2d77,
which links to this thread.

Looking at the diff it's obvious because of the change in the .gitignore file,
but I don't know why these files are there and I have never touched anything in
the 'tools' directory.

Can I savely delete the files? Do I even have to delete them before I compile
v5.12-rcX?

Thanks,
Viktor

>  tools/bpf/resolve_btfids/.gitignore |  2 --
>  tools/bpf/resolve_btfids/Makefile   | 26 +++++++++++---------------
>  2 files changed, 11 insertions(+), 17 deletions(-)
> 
> diff --git a/tools/bpf/resolve_btfids/.gitignore b/tools/bpf/resolve_btfids/.gitignore
> index a026df7dc280..25f308c933cc 100644
> --- a/tools/bpf/resolve_btfids/.gitignore
> +++ b/tools/bpf/resolve_btfids/.gitignore
> @@ -1,4 +1,2 @@
> -/FEATURE-DUMP.libbpf
> -/bpf_helper_defs.h
>  /fixdep
>  /resolve_btfids
> diff --git a/tools/bpf/resolve_btfids/Makefile b/tools/bpf/resolve_btfids/Makefile
> index bf656432ad73..1d46a247ec95 100644
> --- a/tools/bpf/resolve_btfids/Makefile
> +++ b/tools/bpf/resolve_btfids/Makefile
> @@ -28,22 +28,22 @@ OUTPUT ?= $(srctree)/tools/bpf/resolve_btfids/
>  LIBBPF_SRC := $(srctree)/tools/lib/bpf/
>  SUBCMD_SRC := $(srctree)/tools/lib/subcmd/
>  
> -BPFOBJ     := $(OUTPUT)/libbpf.a
> -SUBCMDOBJ  := $(OUTPUT)/libsubcmd.a
> +BPFOBJ     := $(OUTPUT)/libbpf/libbpf.a
> +SUBCMDOBJ  := $(OUTPUT)/libsubcmd/libsubcmd.a
>  
>  BINARY     := $(OUTPUT)/resolve_btfids
>  BINARY_IN  := $(BINARY)-in.o
>  
>  all: $(BINARY)
>  
> -$(OUTPUT):
> +$(OUTPUT) $(OUTPUT)/libbpf $(OUTPUT)/libsubcmd:
>  	$(call msg,MKDIR,,$@)
> -	$(Q)mkdir -p $(OUTPUT)
> +	$(Q)mkdir -p $(@)
>  
> -$(SUBCMDOBJ): fixdep FORCE
> -	$(Q)$(MAKE) -C $(SUBCMD_SRC) OUTPUT=$(OUTPUT)
> +$(SUBCMDOBJ): fixdep FORCE | $(OUTPUT)/libsubcmd
> +	$(Q)$(MAKE) -C $(SUBCMD_SRC) OUTPUT=$(abspath $(dir $@))/ $(abspath $@)
>  
> -$(BPFOBJ): $(wildcard $(LIBBPF_SRC)/*.[ch] $(LIBBPF_SRC)/Makefile) | $(OUTPUT)
> +$(BPFOBJ): $(wildcard $(LIBBPF_SRC)/*.[ch] $(LIBBPF_SRC)/Makefile) | $(OUTPUT)/libbpf
>  	$(Q)$(MAKE) $(submake_extras) -C $(LIBBPF_SRC)  OUTPUT=$(abspath $(dir $@))/ $(abspath $@)
>  
>  CFLAGS := -g \
> @@ -57,23 +57,19 @@ LIBS = -lelf -lz
>  export srctree OUTPUT CFLAGS Q
>  include $(srctree)/tools/build/Makefile.include
>  
> -$(BINARY_IN): fixdep FORCE
> +$(BINARY_IN): fixdep FORCE | $(OUTPUT)
>  	$(Q)$(MAKE) $(build)=resolve_btfids
>  
>  $(BINARY): $(BPFOBJ) $(SUBCMDOBJ) $(BINARY_IN)
>  	$(call msg,LINK,$@)
>  	$(Q)$(CC) $(BINARY_IN) $(LDFLAGS) -o $@ $(BPFOBJ) $(SUBCMDOBJ) $(LIBS)
>  
> -libsubcmd-clean:
> -	$(Q)$(MAKE) -C $(SUBCMD_SRC) OUTPUT=$(OUTPUT) clean
> -
> -libbpf-clean:
> -	$(Q)$(MAKE) -C $(LIBBPF_SRC) OUTPUT=$(OUTPUT) clean
> -
> -clean: libsubcmd-clean libbpf-clean fixdep-clean
> +clean: fixdep-clean
>  	$(call msg,CLEAN,$(BINARY))
>  	$(Q)$(RM) -f $(BINARY); \
>  	$(RM) -rf $(if $(OUTPUT),$(OUTPUT),.)/feature; \
> +	$(RM) -rf $(OUTPUT)/libbpf; \
> +	$(RM) -rf $(OUTPUT)/libsubcmd; \
>  	find $(if $(OUTPUT),$(OUTPUT),.) -name \*.o -or -name \*.o.cmd -or -name \*.o.d | xargs $(RM)
>  
>  tags:
>
Andrii Nakryiko March 10, 2021, 7:27 p.m. UTC | #3
On Wed, Mar 10, 2021 at 9:35 AM Viktor Jägersküpper
<viktor_jaegerskuepper@freenet.de> wrote:
>
> Hi,
>
> > Setting up separate build directories for libbpf and libpsubcmd,
> > so it's separated from other objects and we don't get them mixed
> > in the future.
> >
> > It also simplifies cleaning, which is now simple rm -rf.
> >
> > Also there's no need for FEATURE-DUMP.libbpf and bpf_helper_defs.h
> > files in .gitignore anymore.
> >
> > Acked-by: Song Liu <songliubraving@fb.com>
> > Signed-off-by: Jiri Olsa <jolsa@kernel.org>
> > ---
>
> when I invoke 'git status' on the master branch of my local git repository
> (cloned from stable/linux.git), which I have used to compile several kernels,
> it lists two untracked files:
>
>         tools/bpf/resolve_btfids/FEATURE-DUMP.libbpf
>         tools/bpf/resolve_btfids/bpf_helper_defs.h
>
> 'git status' doesn't complain about these files with v5.11, and I can't get rid
> of them by 'make clean' with v5.11 or v5.12-rc1/rc2. So I used 'git bisect' and
> found that this is caused by commit fc6b48f692f89cc48bfb7fd1aa65454dfe9b2d77,
> which links to this thread.
>
> Looking at the diff it's obvious because of the change in the .gitignore file,
> but I don't know why these files are there and I have never touched anything in
> the 'tools' directory.
>
> Can I savely delete the files? Do I even have to delete them before I compile
> v5.12-rcX?

yes, those were auto-generated files. You can safely remove them.

>
> Thanks,
> Viktor
>

[...]
Jiri Olsa March 10, 2021, 10:42 p.m. UTC | #4
On Wed, Mar 10, 2021 at 11:27:19AM -0800, Andrii Nakryiko wrote:
> On Wed, Mar 10, 2021 at 9:35 AM Viktor Jägersküpper
> <viktor_jaegerskuepper@freenet.de> wrote:
> >
> > Hi,
> >
> > > Setting up separate build directories for libbpf and libpsubcmd,
> > > so it's separated from other objects and we don't get them mixed
> > > in the future.
> > >
> > > It also simplifies cleaning, which is now simple rm -rf.
> > >
> > > Also there's no need for FEATURE-DUMP.libbpf and bpf_helper_defs.h
> > > files in .gitignore anymore.
> > >
> > > Acked-by: Song Liu <songliubraving@fb.com>
> > > Signed-off-by: Jiri Olsa <jolsa@kernel.org>
> > > ---
> >
> > when I invoke 'git status' on the master branch of my local git repository
> > (cloned from stable/linux.git), which I have used to compile several kernels,
> > it lists two untracked files:
> >
> >         tools/bpf/resolve_btfids/FEATURE-DUMP.libbpf
> >         tools/bpf/resolve_btfids/bpf_helper_defs.h
> >
> > 'git status' doesn't complain about these files with v5.11, and I can't get rid
> > of them by 'make clean' with v5.11 or v5.12-rc1/rc2. So I used 'git bisect' and
> > found that this is caused by commit fc6b48f692f89cc48bfb7fd1aa65454dfe9b2d77,
> > which links to this thread.
> >
> > Looking at the diff it's obvious because of the change in the .gitignore file,
> > but I don't know why these files are there and I have never touched anything in
> > the 'tools' directory.
> >
> > Can I savely delete the files? Do I even have to delete them before I compile
> > v5.12-rcX?
> 
> yes, those were auto-generated files. You can safely remove them.

hm, I answered this email, but for some reason I can't see it on
lore.. FWIW, trying once more ;-)


hi,
yes, you can delete them, this patch moved libbpf and libsubcmd
into their own build directories, so those 2 files stayed there
from your last build without the patch

jirka
diff mbox series

Patch

diff --git a/tools/bpf/resolve_btfids/.gitignore b/tools/bpf/resolve_btfids/.gitignore
index a026df7dc280..25f308c933cc 100644
--- a/tools/bpf/resolve_btfids/.gitignore
+++ b/tools/bpf/resolve_btfids/.gitignore
@@ -1,4 +1,2 @@ 
-/FEATURE-DUMP.libbpf
-/bpf_helper_defs.h
 /fixdep
 /resolve_btfids
diff --git a/tools/bpf/resolve_btfids/Makefile b/tools/bpf/resolve_btfids/Makefile
index bf656432ad73..1d46a247ec95 100644
--- a/tools/bpf/resolve_btfids/Makefile
+++ b/tools/bpf/resolve_btfids/Makefile
@@ -28,22 +28,22 @@  OUTPUT ?= $(srctree)/tools/bpf/resolve_btfids/
 LIBBPF_SRC := $(srctree)/tools/lib/bpf/
 SUBCMD_SRC := $(srctree)/tools/lib/subcmd/
 
-BPFOBJ     := $(OUTPUT)/libbpf.a
-SUBCMDOBJ  := $(OUTPUT)/libsubcmd.a
+BPFOBJ     := $(OUTPUT)/libbpf/libbpf.a
+SUBCMDOBJ  := $(OUTPUT)/libsubcmd/libsubcmd.a
 
 BINARY     := $(OUTPUT)/resolve_btfids
 BINARY_IN  := $(BINARY)-in.o
 
 all: $(BINARY)
 
-$(OUTPUT):
+$(OUTPUT) $(OUTPUT)/libbpf $(OUTPUT)/libsubcmd:
 	$(call msg,MKDIR,,$@)
-	$(Q)mkdir -p $(OUTPUT)
+	$(Q)mkdir -p $(@)
 
-$(SUBCMDOBJ): fixdep FORCE
-	$(Q)$(MAKE) -C $(SUBCMD_SRC) OUTPUT=$(OUTPUT)
+$(SUBCMDOBJ): fixdep FORCE | $(OUTPUT)/libsubcmd
+	$(Q)$(MAKE) -C $(SUBCMD_SRC) OUTPUT=$(abspath $(dir $@))/ $(abspath $@)
 
-$(BPFOBJ): $(wildcard $(LIBBPF_SRC)/*.[ch] $(LIBBPF_SRC)/Makefile) | $(OUTPUT)
+$(BPFOBJ): $(wildcard $(LIBBPF_SRC)/*.[ch] $(LIBBPF_SRC)/Makefile) | $(OUTPUT)/libbpf
 	$(Q)$(MAKE) $(submake_extras) -C $(LIBBPF_SRC)  OUTPUT=$(abspath $(dir $@))/ $(abspath $@)
 
 CFLAGS := -g \
@@ -57,23 +57,19 @@  LIBS = -lelf -lz
 export srctree OUTPUT CFLAGS Q
 include $(srctree)/tools/build/Makefile.include
 
-$(BINARY_IN): fixdep FORCE
+$(BINARY_IN): fixdep FORCE | $(OUTPUT)
 	$(Q)$(MAKE) $(build)=resolve_btfids
 
 $(BINARY): $(BPFOBJ) $(SUBCMDOBJ) $(BINARY_IN)
 	$(call msg,LINK,$@)
 	$(Q)$(CC) $(BINARY_IN) $(LDFLAGS) -o $@ $(BPFOBJ) $(SUBCMDOBJ) $(LIBS)
 
-libsubcmd-clean:
-	$(Q)$(MAKE) -C $(SUBCMD_SRC) OUTPUT=$(OUTPUT) clean
-
-libbpf-clean:
-	$(Q)$(MAKE) -C $(LIBBPF_SRC) OUTPUT=$(OUTPUT) clean
-
-clean: libsubcmd-clean libbpf-clean fixdep-clean
+clean: fixdep-clean
 	$(call msg,CLEAN,$(BINARY))
 	$(Q)$(RM) -f $(BINARY); \
 	$(RM) -rf $(if $(OUTPUT),$(OUTPUT),.)/feature; \
+	$(RM) -rf $(OUTPUT)/libbpf; \
+	$(RM) -rf $(OUTPUT)/libsubcmd; \
 	find $(if $(OUTPUT),$(OUTPUT),.) -name \*.o -or -name \*.o.cmd -or -name \*.o.d | xargs $(RM)
 
 tags: