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 0E8E9C433EF for ; Wed, 12 Jan 2022 00:25:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343967AbiALAZK (ORCPT ); Tue, 11 Jan 2022 19:25:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55236 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236650AbiALAZI (ORCPT ); Tue, 11 Jan 2022 19:25:08 -0500 Received: from mail-pl1-x649.google.com (mail-pl1-x649.google.com [IPv6:2607:f8b0:4864:20::649]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9DBA5C061751 for ; Tue, 11 Jan 2022 16:25:08 -0800 (PST) Received: by mail-pl1-x649.google.com with SMTP id p5-20020a170902bd0500b00148cb2d29ecso883524pls.4 for ; Tue, 11 Jan 2022 16:25:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:message-id:mime-version:subject:from:to:cc; bh=vlRniYjFJS8GXTiQcavbR3Q+xuXRc84rf1pjpwDnwgg=; b=df+gpApiwun2GvAf38KC9NfFl7J6EAynZgVzNNFQkSADXGenAgGcqOLHLlVcZCeTxl PM13+5GoBj3Xq8UO58xP3qzjtwkVMBGVQHzsQXOe26QheVTOBfaD6nAasM+5+1sm7uHm XY2Oi83aWBGkdAN4Mq/s3CQzkFF5VOkCKCDuCZPcLa+6TSM7YuyEJQUaST3xCns1ea3y UeJzJtk/cUYV3ZZht5PX/iFfjfgJZ5Zpt1nHw1myAnwmJdLjKN7UoLzgP3Q/+K/1+Aod tlN+ggeCtLMSkAgTZT7Xxbz7LpvfU9AX3wjNjaQ2g7Ruyiv90CU2Fs/jARkVbgya+grH t6BQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=vlRniYjFJS8GXTiQcavbR3Q+xuXRc84rf1pjpwDnwgg=; b=u/I1Lc/b8RWRHSLtecAOCcqKsbd2b2YSM1fLomduhvDf58J+oEoeTGtWc/1muIwVxn mlh/oB09bmoSS9GHHEifcBeSVOXf5B/0QqOFWKFjga8YJJkCSpKPs8FifYgd0YlQzuNC eDyrWKWsb6VQttUH9TLAV75vNC9HxWTvsQo7UaGC2aT1SYXebuEZ1WIRr6YBFkzJA/sQ gasHnTtYq5OPguTf2QpFR+kfgfZb26mZkaSeDBLtk0PbgiJFyeH53/olsM8ons9z1K/4 FZU2ZsxL9STpo100c8j+z0DU5515xyd7/bnBznf8ohe3TfvoqvlKzdrK1Hg4A6/fjTpb iSuw== X-Gm-Message-State: AOAM530QZBx+YpZzql1OEIMgogTdUnm6B0WXUMfaAg4UYTLg8tfkGix5 vLiCtn/lmnWdmg8+fT8DcWhK/eyVvZmI X-Google-Smtp-Source: ABdhPJwRSPJ9w2VH9jxXZL7U+jG+KqHxLna8R9IbOO47LvXY9HDELLu9W/eathbshbZ8HlUeiShOF/GHIWd9 X-Received: from connoro.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:a99]) (user=connoro job=sendgmr) by 2002:aa7:85c7:0:b0:4bc:ac23:64a2 with SMTP id z7-20020aa785c7000000b004bcac2364a2mr7007514pfn.20.1641947108064; Tue, 11 Jan 2022 16:25:08 -0800 (PST) Date: Wed, 12 Jan 2022 00:25:03 +0000 Message-Id: <20220112002503.115968-1-connoro@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.34.1.575.g55b058a8bb-goog Subject: [PATCH bpf] tools/resolve_btfids: build with host flags From: "Connor O'Brien" To: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko Cc: Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , netdev@vger.kernel.org, bpf@vger.kernel.org, linux-kernel@vger.kernel.org, "Connor O'Brien" Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org resolve_btfids is built using $(HOSTCC) and $(HOSTLD) but does not pick up the corresponding flags. As a result, host-specific settings (such as a sysroot specified via HOSTCFLAGS=--sysroot=..., or a linker specified via HOSTLDFLAGS=-fuse-ld=...) will not be respected. Fix this by setting CFLAGS to KBUILD_HOSTCFLAGS and LDFLAGS to KBUILD_HOSTLDFLAGS. Also pass the cflags through to libbpf via EXTRA_CFLAGS to ensure that the host libbpf is built with flags consistent with resolve_btfids. Signed-off-by: Connor O'Brien --- tools/bpf/resolve_btfids/Makefile | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tools/bpf/resolve_btfids/Makefile b/tools/bpf/resolve_btfids/Makefile index 9ddeca947..a7f87cdf1 100644 --- a/tools/bpf/resolve_btfids/Makefile +++ b/tools/bpf/resolve_btfids/Makefile @@ -20,6 +20,8 @@ LD = $(HOSTLD) ARCH = $(HOSTARCH) RM ?= rm CROSS_COMPILE = +CFLAGS := $(KBUILD_HOSTCFLAGS) +LDFLAGS := $(KBUILD_HOSTLDFLAGS) OUTPUT ?= $(srctree)/tools/bpf/resolve_btfids/ @@ -47,10 +49,10 @@ $(SUBCMDOBJ): fixdep FORCE | $(OUTPUT)/libsubcmd $(BPFOBJ): $(wildcard $(LIBBPF_SRC)/*.[ch] $(LIBBPF_SRC)/Makefile) | $(LIBBPF_OUT) $(Q)$(MAKE) $(submake_extras) -C $(LIBBPF_SRC) OUTPUT=$(LIBBPF_OUT) \ - DESTDIR=$(LIBBPF_DESTDIR) prefix= \ + DESTDIR=$(LIBBPF_DESTDIR) prefix= EXTRA_CFLAGS="$(CFLAGS)" \ $(abspath $@) install_headers -CFLAGS := -g \ +CFLAGS += -g \ -I$(srctree)/tools/include \ -I$(srctree)/tools/include/uapi \ -I$(LIBBPF_INCLUDE) \ -- 2.34.1.575.g55b058a8bb-goog