[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <502e80cc-774e-77c0-e918-3c35a2c5ec17@huawei.com>
Date: Sat, 9 Jul 2022 15:31:33 +0800
From: Pu Lehui <pulehui@...wei.com>
To: Andrii Nakryiko <andrii.nakryiko@...il.com>
CC: bpf <bpf@...r.kernel.org>, Networking <netdev@...r.kernel.org>,
open list <linux-kernel@...r.kernel.org>,
Alexei Starovoitov <ast@...nel.org>,
"Daniel Borkmann" <daniel@...earbox.net>,
Andrii Nakryiko <andrii@...nel.org>,
"Quentin Monnet" <quentin@...valent.com>,
Martin KaFai Lau <kafai@...com>,
Song Liu <songliubraving@...com>, Yonghong Song <yhs@...com>,
John Fastabend <john.fastabend@...il.com>,
KP Singh <kpsingh@...nel.org>
Subject: Re: [PATCH bpf-next] samples: bpf: Fix cross-compiling error about
bpftool
On 2022/7/9 6:42, Andrii Nakryiko wrote:
> On Thu, Jul 7, 2022 at 6:37 AM Pu Lehui <pulehui@...wei.com> wrote:
>>
>> Currently, when cross compiling bpf samples, the host side
>> cannot use arch-specific bpftool to generate vmlinux.h or
>> skeleton. We need to compile the bpftool with the host
>> compiler.
>>
>> Signed-off-by: Pu Lehui <pulehui@...wei.com>
>> ---
>
> samples/bpf use bpftool for vmlinux.h, skeleton, and static linking
> only. All that is supported by lightweight "bootstrap" bpftool
> version, so we can build just that. It will be faster, and bootstrap
> version should be always host-native even during cross compilation.
> See [0] for what I did in libbpf-bootstrap.
>
> Also please cc Quention for bpftool-related changes. Thanks!
>
> [0] https://github.com/libbpf/libbpf-bootstrap/commit/fc28424eb3f0e39cfb5959296b070389b9a8bd8f
>
so brilliant,we can take it to other places where rely on bpftool.
thanks.
>> samples/bpf/Makefile | 8 ++++----
>> 1 file changed, 4 insertions(+), 4 deletions(-)
>>
>> diff --git a/samples/bpf/Makefile b/samples/bpf/Makefile
>> index 5002a5b9a7da..fe54a8c8f312 100644
>> --- a/samples/bpf/Makefile
>> +++ b/samples/bpf/Makefile
>> @@ -1,4 +1,5 @@
>> # SPDX-License-Identifier: GPL-2.0
>> +-include tools/scripts/Makefile.include
>>
>> BPF_SAMPLES_PATH ?= $(abspath $(srctree)/$(src))
>> TOOLS_PATH := $(BPF_SAMPLES_PATH)/../../tools
>> @@ -283,11 +284,10 @@ $(LIBBPF): $(wildcard $(LIBBPF_SRC)/*.[ch] $(LIBBPF_SRC)/Makefile) | $(LIBBPF_OU
>> BPFTOOLDIR := $(TOOLS_PATH)/bpf/bpftool
>> BPFTOOL_OUTPUT := $(abspath $(BPF_SAMPLES_PATH))/bpftool
>> BPFTOOL := $(BPFTOOL_OUTPUT)/bpftool
>> -$(BPFTOOL): $(LIBBPF) $(wildcard $(BPFTOOLDIR)/*.[ch] $(BPFTOOLDIR)/Makefile) | $(BPFTOOL_OUTPUT)
>> +$(BPFTOOL): $(wildcard $(BPFTOOLDIR)/*.[ch] $(BPFTOOLDIR)/Makefile) | $(BPFTOOL_OUTPUT)
>> $(MAKE) -C $(BPFTOOLDIR) srctree=$(BPF_SAMPLES_PATH)/../../ \
>> - OUTPUT=$(BPFTOOL_OUTPUT)/ \
>> - LIBBPF_OUTPUT=$(LIBBPF_OUTPUT)/ \
>> - LIBBPF_DESTDIR=$(LIBBPF_DESTDIR)/
>> + ARCH= CROSS_COMPILE= CC=$(HOSTCC) LD=$(HOSTLD) \
>> + OUTPUT=$(BPFTOOL_OUTPUT)/
>>
>> $(LIBBPF_OUTPUT) $(BPFTOOL_OUTPUT):
>> $(call msg,MKDIR,$@)
>> --
>> 2.25.1
>>
> .
>
Powered by blists - more mailing lists