Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp990233imw; Fri, 8 Jul 2022 16:02:38 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vNB4shggk0Mg07ge5+UNh1PRSiMoa3Lr75ITzB6ejBqqy5Bo4hHABJ9I9BdzpZPDWXpmNo X-Received: by 2002:a17:906:cc15:b0:72b:3390:5cb9 with SMTP id ml21-20020a170906cc1500b0072b33905cb9mr1073685ejb.87.1657321358594; Fri, 08 Jul 2022 16:02:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657321358; cv=none; d=google.com; s=arc-20160816; b=nj5sg9Jsu1Dtbg3rZ2qDvsCJPfXs3wg6FeDGSiClYYARKoBx5lI0M0yzrDR292/CLa Ibx2rMpCGJIamX7UYVdAQqdjRBgnvZmOjwKt9Wk7HlNpg2bdXR5Duqe9wC7usguw7i47 xKcxoGDR08e+hSZ6nw0tJhViITo3562qE5RJS6kMBP+l36AMRsrpb2rNXLhIa9fh3fuS BA2l56e7EZpJSIvr1SJzT98xXx+F2VMFxZaTQHuNnRFvuvsTbVzkciotOXqRvfVwwqn0 opdx75ZskvgI8/DM95KDKUMdrPwSG0/t/P9l54G2s72CaC29w9+Owc3lI+9M1XBO5IuF 80yw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=rGYZvcYf47sP+55Vs4UvXXryFfFplfq5QIu85G/+xro=; b=Xn5whlMuP51Yu9kBQXZ5PaRoQaKzUuAX5SOizB/jSBwZFg2vbDOq+3HNGEEswlDpn6 LbWhcm13uzY6mrE2GWmSrDckK77onomwWJHxvFgE5lcclxndI2Z/EmwcHrSCcYTgpnTi ysYhJJegZpjOsgh2FhdgttV/ZmA4FiAR1SQKCDDfuz65uLlfcWl/kDLN7XGxIkWANAIo 5DKz3xsio4vOQPRQouB3T2uIbShjGGN/340PBRm1f3El0CfCdM6KoW/jBZWKwmyzUpjT jsuzMU0qAot79mpXIgw5ks1TECfOBQu7ezUCeDGbwaIEpVD6HXuvyejp9dIbYMhuYJT6 8DRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=UmCsFRzo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ji3-20020a170907980300b0072a5947090csi19603991ejc.216.2022.07.08.16.02.12; Fri, 08 Jul 2022 16:02:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=UmCsFRzo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237339AbiGHWnJ (ORCPT + 99 others); Fri, 8 Jul 2022 18:43:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59210 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229448AbiGHWnH (ORCPT ); Fri, 8 Jul 2022 18:43:07 -0400 Received: from mail-ed1-x536.google.com (mail-ed1-x536.google.com [IPv6:2a00:1450:4864:20::536]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C1CEF13B471; Fri, 8 Jul 2022 15:43:06 -0700 (PDT) Received: by mail-ed1-x536.google.com with SMTP id r6so184654edd.7; Fri, 08 Jul 2022 15:43:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=rGYZvcYf47sP+55Vs4UvXXryFfFplfq5QIu85G/+xro=; b=UmCsFRzomqWag60HiSO6s7F26oEj/FqCk7eX3SaKMoZj1Owl4dXDJrDU7HgSYmYFBG ppkR5X7cbgoKHqK6YkALQdM6mrKQEYZFC12cINZJBgbn+NImcC/yC7qoNoiT/emc4veL jt1DZln7jjseWzByF0ub40nUIlUirQWpFSecjApXl7Xm4ZHvy9LAsRc3LIdcoGrl7dkS iCgCDUWgla6BwhNlZ9g0u5HdE7DjTthX4R5WNAKRjo2n23oHMoxc6CjcrDTkE0IwTP9e 2RIfYhAfHYzg2Mmiyqw8CM98caAAZ9WTZfTvl5mrx8wz5NDC0t0c3QCqkdP6j7Dk0Rjw nWSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=rGYZvcYf47sP+55Vs4UvXXryFfFplfq5QIu85G/+xro=; b=CXFZIUtfyR3fEcUypqf8uhC8HlK25gTQOrhYgMB8pXIxN82PiS/KKN7OeV1TLNQd8b XCf1sUH1DJVcQt0Q+scGe7qy3LIqTuSPqd+gN/nn2Ums/wI8kUkFJ1aLw3TrnYYQITKQ dnJCZhuuDz8CXuUeKTUn4EHR33SftE4hx5YDPmlJTDWee4TFeE9EkhRnObFs2H1DwPyn 0OhxgRw0Dbb4rJ8cWgnVNtCeSnHqvvoUu/3m64HWFpOJB/CJBwzUfB7HFEO+UEbG1QwG Q+Rn58XSvKuSsnkcD5Wpd5X7+XaNQSfTlVytCC9se6HWI8/ZQBRTNrdfOFuj4rfSfSph Uqyg== X-Gm-Message-State: AJIora8h6y3dwiPSD1bvgHqsqhXqUo+RXbr1hb3k+p8qm4VQrcVSO90X A5wYFNG0ZyKbomj9Ix8IlKpvC+Zvqle68iTUUz8ANtHMkHQSkw== X-Received: by 2002:a05:6402:5309:b0:435:6431:f9dc with SMTP id eo9-20020a056402530900b004356431f9dcmr7718578edb.14.1657320185368; Fri, 08 Jul 2022 15:43:05 -0700 (PDT) MIME-Version: 1.0 References: <20220707140811.603590-1-pulehui@huawei.com> In-Reply-To: <20220707140811.603590-1-pulehui@huawei.com> From: Andrii Nakryiko Date: Fri, 8 Jul 2022 15:42:54 -0700 Message-ID: Subject: Re: [PATCH bpf-next] samples: bpf: Fix cross-compiling error about bpftool To: Pu Lehui , Quentin Monnet Cc: bpf , Networking , open list , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > 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 >