lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Thu, 18 Jul 2019 11:51:11 -0700
From:   Jakub Kicinski <jakub.kicinski@...ronome.com>
To:     Ilya Leoshkevich <iii@...ux.ibm.com>
Cc:     bpf@...r.kernel.org, netdev@...r.kernel.org, lmb@...udflare.com,
        gor@...ux.ibm.com, heiko.carstens@...ibm.com
Subject: Re: [PATCH bpf] tools/bpf: fix bpftool build with OUTPUT set

On Thu, 18 Jul 2019 16:20:41 +0200, Ilya Leoshkevich wrote:
> Hi Lorenz,
> 
> I've been using the following patch for quite some time now.
> Please let me know if it works for you.
> 
> Best regards,
> Ilya
> 
> ---
> 
> When OUTPUT is set, bpftool and libbpf put their objects into the same
> directory, and since some of them have the same names, the collision
> happens.
> 
> Fix by invoking libbpf build in a manner similar to $(call descend) -
> descend itself cannot be used, since libbpf is a sibling, and not a
> child, of bpftool.
> 
> Also, don't link bpftool with libbpf.a twice.
> 
> Signed-off-by: Ilya Leoshkevich <iii@...ux.ibm.com>
> ---
>  tools/bpf/bpftool/Makefile | 17 ++++++-----------
>  1 file changed, 6 insertions(+), 11 deletions(-)
> 
> diff --git a/tools/bpf/bpftool/Makefile b/tools/bpf/bpftool/Makefile
> index a7afea4dec47..2cbc3c166f44 100644
> --- a/tools/bpf/bpftool/Makefile
> +++ b/tools/bpf/bpftool/Makefile
> @@ -15,23 +15,18 @@ else
>  endif
>  
>  BPF_DIR = $(srctree)/tools/lib/bpf/
> -
> -ifneq ($(OUTPUT),)
> -  BPF_PATH = $(OUTPUT)
> -else
> -  BPF_PATH = $(BPF_DIR)
> -endif
> -
> -LIBBPF = $(BPF_PATH)libbpf.a
> +BPF_PATH = $(objtree)/tools/lib/bpf

objtree won't be set for simple make in the directory. Perhaps we
should stick to using OUTPUT and srctree?

We should probably make a script with all the ways of calling make
should work. Otherwise we can lose track too easily.

# thru kbuild
make tools/bpf

T=$(mktemp -d)
make tools/bpf OUTPUT=$T
rm -rf $T

# from kernel source tree
make -C tools/bpf/bpftool

T=$(mktemp -d)
make -C tools/bpf/bpftool OUTPUT=$T
rm -rf $T

# from tools
cd tools/
make bpf

T=$(mktemp -d)
make bpf OUTPUT=$T
rm -rf $T

# from bpftool's dir
cd bpf/bpftool
make

T=$(mktemp -d)
make OUTPUT=$T
rm -rf $T

.. add your own.

> +LIBBPF = $(BPF_PATH)/libbpf.a
>  
>  BPFTOOL_VERSION := $(shell make --no-print-directory -sC ../../.. kernelversion)
>  
>  $(LIBBPF): FORCE
> -	$(Q)$(MAKE) -C $(BPF_DIR) OUTPUT=$(OUTPUT) $(OUTPUT)libbpf.a
> +	$(Q)mkdir -p $(BPF_PATH)
> +	$(Q)$(MAKE) $(COMMAND_O) subdir=tools/lib/bpf -C $(BPF_DIR) $(LIBBPF)
>  
>  $(LIBBPF)-clean:
>  	$(call QUIET_CLEAN, libbpf)
> -	$(Q)$(MAKE) -C $(BPF_DIR) OUTPUT=$(OUTPUT) clean >/dev/null
> +	$(Q)$(MAKE) $(COMMAND_O) subdir=tools/lib/bpf -C $(BPF_DIR) clean >/dev/null
>  
>  prefix ?= /usr/local
>  bash_compdir ?= /usr/share/bash-completion/completions
> @@ -112,7 +107,7 @@ $(OUTPUT)disasm.o: $(srctree)/kernel/bpf/disasm.c
>  	$(QUIET_CC)$(COMPILE.c) -MMD -o $@ $<
>  
>  $(OUTPUT)bpftool: $(OBJS) $(LIBBPF)
> -	$(QUIET_LINK)$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS)
> +	$(QUIET_LINK)$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(OBJS) $(LIBS)
>  
>  $(OUTPUT)%.o: %.c
>  	$(QUIET_CC)$(COMPILE.c) -MMD -o $@ $<

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ