From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DD9BCC433EF for ; Sat, 9 Jul 2022 07:31:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229490AbiGIHbi (ORCPT ); Sat, 9 Jul 2022 03:31:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34526 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229504AbiGIHbh (ORCPT ); Sat, 9 Jul 2022 03:31:37 -0400 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2A9AE6A9C1; Sat, 9 Jul 2022 00:31:36 -0700 (PDT) Received: from dggpemm500024.china.huawei.com (unknown [172.30.72.57]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4Lg1yp6ZMbzFpyy; Sat, 9 Jul 2022 15:30:42 +0800 (CST) Received: from dggpemm500019.china.huawei.com (7.185.36.180) by dggpemm500024.china.huawei.com (7.185.36.203) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Sat, 9 Jul 2022 15:31:34 +0800 Received: from [10.67.109.184] (10.67.109.184) by dggpemm500019.china.huawei.com (7.185.36.180) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Sat, 9 Jul 2022 15:31:33 +0800 Subject: Re: [PATCH bpf-next] samples: bpf: Fix cross-compiling error about bpftool To: Andrii Nakryiko CC: bpf , Networking , open list , Alexei Starovoitov , "Daniel Borkmann" , Andrii Nakryiko , "Quentin Monnet" , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh References: <20220707140811.603590-1-pulehui@huawei.com> From: Pu Lehui Message-ID: <502e80cc-774e-77c0-e918-3c35a2c5ec17@huawei.com> Date: Sat, 9 Jul 2022 15:31:33 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8"; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-Originating-IP: [10.67.109.184] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggpemm500019.china.huawei.com (7.185.36.180) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org On 2022/7/9 6:42, Andrii Nakryiko wrote: > On Thu, Jul 7, 2022 at 6:37 AM Pu Lehui 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 >> --- > > 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 >> > . >