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 C2523C433EF for ; Tue, 12 Jul 2022 10:12:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231571AbiGLKMk (ORCPT ); Tue, 12 Jul 2022 06:12:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59206 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232330AbiGLKMV (ORCPT ); Tue, 12 Jul 2022 06:12:21 -0400 Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AB839AB7D8 for ; Tue, 12 Jul 2022 03:11:56 -0700 (PDT) Received: by mail-wm1-x32e.google.com with SMTP id c131-20020a1c3589000000b003a2cc290135so4917800wma.2 for ; Tue, 12 Jul 2022 03:11:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=isovalent-com.20210112.gappssmtp.com; s=20210112; h=message-id:date:mime-version:user-agent:subject:content-language:to :cc:references:from:in-reply-to:content-transfer-encoding; bh=i2XYOzCUtA8Ta1rr8OzoyXDjrIADtZBW93UGTbpRQTs=; b=HuqOXEtE1Aefa8vkyqcUnK8kCIMt6cgP0dnwVak+AjhJ/OJs5cVFYIaPCgtc8AybKr PM1mAszWA+rKfgVfOqv32nx5ok8Q978lXTCZlK3ze46hzvc4YYD60jBe/HLJfP00kLrX bNCjxDultJYZJznYedjsjFfy0/mq/fejVM3zypto8nxiwJZ+IBvAcxf8cpBARlRSuNOA lpK5F/aGSKF9RpEaZSXaWZVDH2vIfnBMoIeaMVJPDOqjwZCBOcPb+IHx7t+E9kzv/q6L ojoJcJ/O5CjA++wuWCKvUpbgaN6WGsuwQgpqQkvkPFC3Qr0ueEfeV/uQw1y/AUvNAdPS DkHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=i2XYOzCUtA8Ta1rr8OzoyXDjrIADtZBW93UGTbpRQTs=; b=vaF9z4ABwPfNZ1qHCNaItJFf1jwJaH6aRF+hJw5leeb5x5jHTrX+6EQTryiVpF7pww byWKKsJD+KjjEJM2NNtQb7bOiYQ4X3tis885pI7ICXG6e1lD1L0TURGr3EJN5u6CztJz aDO2iPwuxQpsdRUw9H8Jg16QmRdibCVKI3YjP9eSkOojGj8PDec46ZrTIt9/BuF2hrDY 0Ct00kK98bvse0tFsRHGmPJcE9TYg3T5ypvUwuEm1a20wgrPanthrUIDOjUt6OKcYkJ8 M5QxqJW2LUaSAGD1tO2Kqq1ewiQoysAHVMeDdntEOnYX97AMKeroc/UL0/tTLJbHR++x +t6w== X-Gm-Message-State: AJIora86NR7DgyQpyGi234cTOb9mip3XqtsfIbUgZDr7ky0ta/8YOqnz Ge4ZPWovj3NhbkHcL1fGYeLpOA== X-Google-Smtp-Source: AGRyM1vDQohmXGbbjMuTB8tna0YftEx/WQsqRgPk4KBe+/NA1T7pca7ljNWjq5QzQB47mumtb7HS6g== X-Received: by 2002:a05:600c:3845:b0:3a2:c04d:5ff9 with SMTP id s5-20020a05600c384500b003a2c04d5ff9mr2997243wmr.74.1657620715194; Tue, 12 Jul 2022 03:11:55 -0700 (PDT) Received: from [192.168.178.32] ([51.155.200.13]) by smtp.gmail.com with ESMTPSA id b2-20020adfde02000000b0021d9591c64fsm7895138wrm.33.2022.07.12.03.11.54 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 12 Jul 2022 03:11:54 -0700 (PDT) Message-ID: Date: Tue, 12 Jul 2022 11:11:53 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.0.1 Subject: Re: [PATCH bpf-next 1/3] samples: bpf: Fix cross-compiling error by using bootstrap bpftool Content-Language: en-GB To: Pu Lehui , bpf@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Jean-Philippe Brucker References: <20220712030813.865410-1-pulehui@huawei.com> <20220712030813.865410-2-pulehui@huawei.com> From: Quentin Monnet In-Reply-To: <20220712030813.865410-2-pulehui@huawei.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org On 12/07/2022 04:08, Pu Lehui wrote: > Currently, when cross compiling bpf samples, the host side cannot > use arch-specific bpftool to generate vmlinux.h or skeleton. Since > samples/bpf use bpftool for vmlinux.h, skeleton, and static linking > only, we can use lightweight bootstrap version of bpftool to handle > these, and it's always host-native. > > Signed-off-by: Pu Lehui > Suggested-by: Andrii Nakryiko > --- > samples/bpf/Makefile | 16 +++++++++++----- > 1 file changed, 11 insertions(+), 5 deletions(-) > > diff --git a/samples/bpf/Makefile b/samples/bpf/Makefile > index 5002a5b9a7da..57012b8259d2 100644 > --- a/samples/bpf/Makefile > +++ b/samples/bpf/Makefile > @@ -282,12 +282,18 @@ $(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 := $(BPFTOOL_OUTPUT)/bootstrap/bpftool > +ifeq ($(CROSS_COMPILE),) > $(BPFTOOL): $(LIBBPF) $(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)/ > + $(MAKE) -C $(BPFTOOLDIR) srctree=$(BPF_SAMPLES_PATH)/../../ \ > + OUTPUT=$(BPFTOOL_OUTPUT)/ \ > + LIBBPF_BOOTSTRAP_OUTPUT=$(LIBBPF_OUTPUT)/ \ > + LIBBPF_BOOTSTRAP_DESTDIR=$(LIBBPF_DESTDIR)/ bootstrap > +else > +$(BPFTOOL): $(wildcard $(BPFTOOLDIR)/*.[ch] $(BPFTOOLDIR)/Makefile) | $(BPFTOOL_OUTPUT) Thanks for this! Just trying to fully understand the details here. When cross-compiling, you leave aside the dependency on target-arch-libbpf, so that "make -C bootstrap" rebuilds its own host-arch libbpf, is this correct? > + $(MAKE) -C $(BPFTOOLDIR) srctree=$(BPF_SAMPLES_PATH)/../../ \ > + OUTPUT=$(BPFTOOL_OUTPUT)/ bootstrap > +endif > > $(LIBBPF_OUTPUT) $(BPFTOOL_OUTPUT): > $(call msg,MKDIR,$@)