BPF List
 help / color / mirror / Atom feed
From: Pu Lehui <pulehui@huawei.com>
To: Song Liu <songliubraving@fb.com>
Cc: bpf <bpf@vger.kernel.org>, Networking <netdev@vger.kernel.org>,
	lkml <linux-kernel@vger.kernel.org>,
	Alexei Starovoitov <ast@kernel.org>,
	"Daniel Borkmann" <daniel@iogearbox.net>,
	Andrii Nakryiko <andrii@kernel.org>, "Martin Lau" <kafai@fb.com>,
	Yonghong Song <yhs@fb.com>,
	John Fastabend <john.fastabend@gmail.com>,
	KP Singh <kpsingh@kernel.org>
Subject: Re: [PATCH bpf-next] samples: bpf: Fix cross-compiling error about bpftool
Date: Fri, 8 Jul 2022 11:12:33 +0800	[thread overview]
Message-ID: <d44f8faf-06df-6fdf-0adf-2abbdf9c9a49@huawei.com> (raw)
In-Reply-To: <c357fa1a-5160-ed85-19bf-51f3c188d56e@huawei.com>



On 2022/7/8 10:46, Pu Lehui wrote:
> 
> 
> On 2022/7/8 3:12, Song Liu wrote:
>>
>>
>>> On Jul 7, 2022, at 7:08 AM, Pu Lehui <pulehui@huawei.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@huawei.com>
>>> ---
>>> 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
>>
>> Why do we need the -include here?
>>
> 
> HOSTLD is defined in tools/scripts/Makefile.include, we need to add it.
> 
> And for -include, mainly to resolve some conflicts:
> 1. If workdir is kernel_src, then 'include 
> tools/scripts/Makefile.include' is fine when 'make M=samples/bpf'.
> 2. Since the trick in samples/bpf/Makefile:
> 
> # Trick to allow make to be run from this directory
> all:
>      $(MAKE) -C ../../ M=$(CURDIR) BPF_SAMPLES_PATH=$(CURDIR)
> 
> If workdir is samples/bpf, the compile process will first load the 
> Makefile in samples/bpf, then change workdir to kernel_src and load the 
> kernel_src's Makefile. So if we just add 'include 
> tools/scripts/Makefile.include', then the first load will occur error 
> for not found the file, so we add -include to skip the first load.

sorry, correct the reply, so we add -include to skip the 
'tools/scripts/Makefile.include' file on the fisrt load.

> 
>> Thanks,
>> Song
>>
>>>
>>> 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
>>>
>>
>> .
>>
> .

  reply	other threads:[~2022-07-08  3:12 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-07 14:08 [PATCH bpf-next] samples: bpf: Fix cross-compiling error about bpftool Pu Lehui
2022-07-07 19:12 ` Song Liu
2022-07-08  2:46   ` Pu Lehui
2022-07-08  3:12     ` Pu Lehui [this message]
2022-07-08  4:53       ` Song Liu
2022-07-08 22:42 ` Andrii Nakryiko
2022-07-09  7:31   ` Pu Lehui

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d44f8faf-06df-6fdf-0adf-2abbdf9c9a49@huawei.com \
    --to=pulehui@huawei.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=john.fastabend@gmail.com \
    --cc=kafai@fb.com \
    --cc=kpsingh@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=songliubraving@fb.com \
    --cc=yhs@fb.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox