From patchwork Thu Jan 19 18:31:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 45901 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp490476wrn; Thu, 19 Jan 2023 10:54:28 -0800 (PST) X-Google-Smtp-Source: AMrXdXsIBfa8df6etPhMaWxrHi5xyVgsiXl/wgoytl0anbp7r5i/mJIKAEhF8zQqUP7ScqEFaBDh X-Received: by 2002:aa7:808a:0:b0:58d:9678:71c9 with SMTP id v10-20020aa7808a000000b0058d967871c9mr13071603pff.6.1674154467733; Thu, 19 Jan 2023 10:54:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674154467; cv=none; d=google.com; s=arc-20160816; b=oIKZb6IF5lubw5Y2ihPetL5ilLOo7GzXURLrtB04y9E7pywqESObJKu5mofscSoQxd kUz7EE7zYhZH80xBHQ1PIDxHCmJ3/aHPhl0V6KxPbLNECKcfA2lHNfFm5/T39FKXZzsI BDyTbwzEid5RYeG1kvxHse6HicrSYWyhQP+gVYQ8DIL1TLfe7jhJqbMR8fZUR8psvXA6 l3l/diiTpSipoY77+q6d9XSFlrjIkqAZe1tVYEMWdil/8Hq1eHAnlzUSzFbHQM8EXpey ByTC8LKSgSRhO7ZksP4i9AarUC42T23hRhs1gxVp9Wi3/fRyxDnWsDYcUv0B6Xox9sMo 2CkQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:from:subject:references:mime-version :message-id:in-reply-to:date:dkim-signature; bh=rSuiBVm55Q80Tk0UPfBL9kzPamY+Qqa2tBQ8WoHmUiI=; b=A1TxUN079z4CubY68bqC3BepgsEATGL9Ae+gB5Rh+fqAjWnfNVLfbIxfhnFpLmMnSt MW9DC5brX8hd7zNKZ0nb8WzOuma2jzN25WYw1++2uvxaG3w/s5YN5EtXVm0eDeQvSmHY 4pMprHcSpTHkfnEf1J4I/1igTl/sQR0GGTmLZbEnEevN7HY/ASJ7/eVnXEW6a60IXAw+ 83TAsXxXtWgrWx/tcafFW6ryOAiayGRpmDRfVziyyyJEyhywC3FdIMBbG0lKUvqQGgqf gjfO/+gaK6bRJGEtxyH1Lz8fCwrPfG+8qSPhJNbhw1gpxjh9x8iTFDOMTNo/P6j7yxuZ ZnqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=PBdaBmAq; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z15-20020aa7888f000000b0058dcade7ea6si9737108pfe.332.2023.01.19.10.54.16; Thu, 19 Jan 2023 10:54:27 -0800 (PST) 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=@google.com header.s=20210112 header.b=PBdaBmAq; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230305AbjASSb5 (ORCPT + 99 others); Thu, 19 Jan 2023 13:31:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54918 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230260AbjASSbt (ORCPT ); Thu, 19 Jan 2023 13:31:49 -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 890D994C8A for ; Thu, 19 Jan 2023 10:31:46 -0800 (PST) Received: by mail-pl1-x649.google.com with SMTP id l15-20020a170902f68f00b001948ddc7cddso1808570plg.2 for ; Thu, 19 Jan 2023 10:31:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=rSuiBVm55Q80Tk0UPfBL9kzPamY+Qqa2tBQ8WoHmUiI=; b=PBdaBmAqFJb9V7fBj1q6ZWOgsj2wnTFqbx3DuY8v+5ZG/7IsnCWzCvJb6ai+Yj4l7T bwLnzbUcBrgx4KXhrOKir9eCFKGiWIAdn426HYOfXoK6biy7c/uZYEbI4uWi/mYdBhHc WzTbUwkWte+V2dtcmbK6YNPfBWYkCRNlCh2Nyq+bm+KlmLAV1Fh/OKPuMS7nTmJ5pmqA T3IfJm/+dWZmfFX6bn5Z/ChMIX9NWV0FdH9GEHCzDvjEVsoNJ3rGhhhAXkrf6HMx4MJb chznyhMZs5cBhS3cMMcahT6zUqQ6XGqDavm4uYJr75s3QBGkHgDSukvkOpAHtrxFEr6r AJbg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=rSuiBVm55Q80Tk0UPfBL9kzPamY+Qqa2tBQ8WoHmUiI=; b=SDhSqtDxiOXCe8OXm6xIL9dSXr18iK2DqI9e/O5lRDXHaU4KcSdtngK7nm577H48j1 DnolrKzNpcPHyZWpgRPp6g3OVno7EeeVawKjKCT2qbH0+yt86NWBnaA2dO7KOVS0rR0t csyuEoHHv4TUxZ23yEmWIqVmFeIAQ8WWgl0PgfnxMqkmLRSQLPe/HpjuPcga4w3FR1F/ sdRog3zCAzqlaK0kasLvGj37QfU5C54HFT4aM7pHxgXgH+55OaLxrvrGHaHiRtrGWgbV bgbL5EeH5rPf1/IXPZ2ZzDOvtxXDMO/PDpUVXJgHlzkRoOJdIvxpfq47s1axSml9QGmt QugA== X-Gm-Message-State: AFqh2koGD46r9n2tviCMc9Gc8cDQX5RZvVUNYVmrtr5sVUch5rL07WY4 lxpPTMTPtedaFTow+6a2raokLlbPvMAz X-Received: from irogers.svl.corp.google.com ([2620:15c:2d4:203:93c6:b65e:5f33:bc6b]) (user=irogers job=sendgmr) by 2002:a63:3381:0:b0:4b4:e491:c331 with SMTP id z123-20020a633381000000b004b4e491c331mr851563pgz.19.1674153105597; Thu, 19 Jan 2023 10:31:45 -0800 (PST) Date: Thu, 19 Jan 2023 10:31:18 -0800 In-Reply-To: <20230119183118.126387-1-irogers@google.com> Message-Id: <20230119183118.126387-3-irogers@google.com> Mime-Version: 1.0 References: <20230119183118.126387-1-irogers@google.com> X-Mailer: git-send-email 2.39.0.246.g2a6d74b583-goog Subject: [PATCH v3 2/2] tools/resolve_btfids: Alter how HOSTCC is forced From: Ian Rogers To: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Connor OBrien , Nathan Chancellor , Ian Rogers , Kumar Kartikeya Dwivedi , bpf@vger.kernel.org, linux-kernel@vger.kernel.org X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=unavailable 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1755478194979241317?= X-GMAIL-MSGID: =?utf-8?q?1755478194979241317?= HOSTCC is always wanted when building. Setting CC to HOSTCC happens after tools/scripts/Makefile.include is included, meaning flags are set assuming say CC is gcc, but then it can be later set to HOSTCC which may be clang. tools/scripts/Makefile.include is needed for host set up and common macros in objtool's Makefile. Rather than override CC to HOSTCC, just pass CC as HOSTCC to Makefile.build, the libsubcmd builds and the linkage step. This means the Makefiles don't see things like CC changing and tool flag determination, and similar, work properly. Also, clear the passed subdir as otherwise an outer build may break by inadvertently passing an inappropriate value. Signed-off-by: Ian Rogers --- tools/bpf/resolve_btfids/Makefile | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/tools/bpf/resolve_btfids/Makefile b/tools/bpf/resolve_btfids/Makefile index 76b737b2560d..ac8e302babc6 100644 --- a/tools/bpf/resolve_btfids/Makefile +++ b/tools/bpf/resolve_btfids/Makefile @@ -18,14 +18,11 @@ else endif # always use the host compiler -AR = $(HOSTAR) -CC = $(HOSTCC) -LD = $(HOSTLD) -ARCH = $(HOSTARCH) +HOST_OVERRIDES := AR="$(HOSTAR)" CC="$(HOSTCC)" LD="$(HOSTLD)" ARCH="$(HOSTARCH)" \ + EXTRA_CFLAGS="$(HOSTCFLAGS) $(KBUILD_HOSTCFLAGS)" + RM ?= rm CROSS_COMPILE = -CFLAGS := $(KBUILD_HOSTCFLAGS) -LDFLAGS := $(KBUILD_HOSTLDFLAGS) OUTPUT ?= $(srctree)/tools/bpf/resolve_btfids/ @@ -56,12 +53,12 @@ $(OUTPUT) $(OUTPUT)/libsubcmd $(LIBBPF_OUT): $(SUBCMDOBJ): fixdep FORCE | $(OUTPUT)/libsubcmd $(Q)$(MAKE) -C $(SUBCMD_SRC) OUTPUT=$(SUBCMD_OUT) \ - DESTDIR=$(SUBCMD_DESTDIR) prefix= \ + DESTDIR=$(SUBCMD_DESTDIR) $(HOST_OVERRIDES) prefix= subdir= \ $(abspath $@) install_headers $(BPFOBJ): $(wildcard $(LIBBPF_SRC)/*.[ch] $(LIBBPF_SRC)/Makefile) | $(LIBBPF_OUT) $(Q)$(MAKE) $(submake_extras) -C $(LIBBPF_SRC) OUTPUT=$(LIBBPF_OUT) \ - DESTDIR=$(LIBBPF_DESTDIR) prefix= EXTRA_CFLAGS="$(CFLAGS)" \ + DESTDIR=$(LIBBPF_DESTDIR) $(HOST_OVERRIDES) prefix= subdir= \ $(abspath $@) install_headers CFLAGS += -g \ @@ -76,11 +73,11 @@ export srctree OUTPUT CFLAGS Q include $(srctree)/tools/build/Makefile.include $(BINARY_IN): fixdep FORCE prepare | $(OUTPUT) - $(Q)$(MAKE) $(build)=resolve_btfids + $(Q)$(MAKE) $(build)=resolve_btfids $(HOST_OVERRIDES) $(BINARY): $(BPFOBJ) $(SUBCMDOBJ) $(BINARY_IN) $(call msg,LINK,$@) - $(Q)$(CC) $(BINARY_IN) $(LDFLAGS) -o $@ $(BPFOBJ) $(SUBCMDOBJ) $(LIBS) + $(Q)$(HOSTCC) $(BINARY_IN) $(KBUILD_HOSTLDFLAGS) -o $@ $(BPFOBJ) $(SUBCMDOBJ) $(LIBS) clean_objects := $(wildcard $(OUTPUT)/*.o \ $(OUTPUT)/.*.o.cmd \