Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp5520618rwb; Tue, 17 Jan 2023 15:08:28 -0800 (PST) X-Google-Smtp-Source: AMrXdXvsWQW7hpyArQUWfej1N+wV30bp4SKG99um/rZlDUxnzBqG+MYYNXvhZyYNJGRmboUU0Zjw X-Received: by 2002:a17:902:f28a:b0:194:97cd:9c3d with SMTP id k10-20020a170902f28a00b0019497cd9c3dmr4677160plc.20.1673996908389; Tue, 17 Jan 2023 15:08:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673996908; cv=none; d=google.com; s=arc-20160816; b=dui7fCg3f5sKS1b3Hkwg8muK9h9pxo+nmydOcFZxlHcnn/4Ov5gmBcureJ2KQs7LyM wSweqVhwypugMPlVRsLUVz2Cuo6Pv715EIO6fm044r+I8UV2LhMJCHI686pjhialwhaO exGzCu0CKxVxBrmohhUDVPLMTftPhEhAgc+DMt6z+1EFR9KJB+3VyHrcvP9btxN/8EwM REWnLTzljL1eaIyH9JU/AVG/kLUB/oSfjXIU/+x9tteu+9bx/bpGu9FNJP90Nppsa/GS Y/p9VNEB+ZKrVKvdWRjQb4xI1rAnfnT30/l+RMxWB5evQgHKSyPtYzQpfKpL6x5jnLJy KFEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:date:from:dkim-signature; bh=pHpBgzz2TyntaCuelGSjfnrcPlqXNF+vqKQrNZrAODM=; b=Wd1lCGrS3iUobY2UVUffgTMIAoq5832FScIxJ04etWM0IfWxn96XsoWI4DP/kN7G8X suVGcVQrnmJZaVOM5gPq27KlqD/iGWVt+5rJwuRa+cZ8XdcwlCSwgyTW0fD/j2S8ED2E 4KiAqGuL6kFw22l6DKJuB2msgHe3WPQNGH3aTCM+jyFxx+lqdf4uspk93PgDshpZqQqp goNAT3AVY1RnnTLRi/0WgJrG5gJAbdlA58uOcVaJMGk/ce3NDjz7bvEzZeUYRAHZHBNi AZSdzJaaiIHrsB7nebbqJZJTNSbtLQ+//AwZ26w9ttkeD3Kev51Xj4H0z0tnNd+hybov upRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=eRYpAhox; 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 p1-20020a170902b08100b00176e58d4a4esi157771plr.100.2023.01.17.15.08.22; Tue, 17 Jan 2023 15:08:28 -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=@gmail.com header.s=20210112 header.b=eRYpAhox; 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 S229717AbjAQWbB (ORCPT + 46 others); Tue, 17 Jan 2023 17:31:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34760 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229491AbjAQWaT (ORCPT ); Tue, 17 Jan 2023 17:30:19 -0500 Received: from mail-ej1-x631.google.com (mail-ej1-x631.google.com [IPv6:2a00:1450:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A12FB8457B; Tue, 17 Jan 2023 14:07:51 -0800 (PST) Received: by mail-ej1-x631.google.com with SMTP id u19so78732843ejm.8; Tue, 17 Jan 2023 14:07:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:date:from:from:to:cc:subject:date:message-id:reply-to; bh=pHpBgzz2TyntaCuelGSjfnrcPlqXNF+vqKQrNZrAODM=; b=eRYpAhoxDWf5HFXYDDYfknEL3ta3VKqz6SZMs44VMSkSuz5vU5jmKhXCX2ra/aODsg R2L0QWjOP+jH8V/0PJ4Y5kmjj7l4dC+nnejw15x+8OhRzKX+RXmhHUoXwgLPQY3hnLB5 lEOMPKAY3f/fIhbqgSd+w+NEbWiSpIwiSUrfCQz8Ln1r1SdVHLTOlXiScGw77bH+pvND t/d4u5uPK1r8PZuxZCq1lu8YL7ecj9mto/VeHpLVccDIu2iRaGavvX+hhPe06neeQLTv Vdg9EepUvlQGbH8jsc+CVj9ZjI7Fb6kBjJ7cQ1hJBWl7v7ZlOO5CDQOzqu+GsdJ26xWF mkdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:date:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=pHpBgzz2TyntaCuelGSjfnrcPlqXNF+vqKQrNZrAODM=; b=D60pPb9Jxfx7c/KAyFtN+Tlb4uS6OR/epyzIJRdhQTAHtvEUeGJ3sKmBo34noCkePZ p/k0Aga8hKNhu4qnF8gXtPvHLxgn0o/iUB6XltPNpiwa80cSJH5tvQoJyEHyejE8XsuX b16bQj3LEIDqRw7DbkH1YtzIwrGRBYhN2zDGWzg7KttdqjFCW/iCrt0g7Ioip3nc//IU f8Yi1U6N5Voy9829/VjdEzSOzpZi4ZZ+HsJ4HJRGTFsKjaHQiTP+pI2zGPypCbOe2IuB /mV9iiJIOltrNNVgrf0ISpGMgFqPYfM0I4N653LnXWFQGKciq5f2ijx9M3gp5ITc5JVy blsw== X-Gm-Message-State: AFqh2kqbKj7qvXqexLx5i+WVZ+wYp7YVMPeE5shoLaF30vrayX1Yq7fn xwmx4mL3tUXcDehDKdLleKY= X-Received: by 2002:a17:906:1417:b0:86d:f880:5193 with SMTP id p23-20020a170906141700b0086df8805193mr4292822ejc.38.1673993269822; Tue, 17 Jan 2023 14:07:49 -0800 (PST) Received: from krava ([83.240.63.124]) by smtp.gmail.com with ESMTPSA id rf26-20020a1709076a1a00b00871a4ab4736sm2376181ejc.97.2023.01.17.14.07.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 14:07:49 -0800 (PST) From: Jiri Olsa X-Google-Original-From: Jiri Olsa Date: Tue, 17 Jan 2023 23:07:47 +0100 To: Ian Rogers Cc: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Connor OBrien , Nathan Chancellor , Kumar Kartikeya Dwivedi , bpf@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 2/2] tools/resolve_btfids: Alter how HOSTCC is forced Message-ID: References: <20230116215751.633675-1-irogers@google.com> <20230116215751.633675-2-irogers@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230116215751.633675-2-irogers@google.com> 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 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 Mon, Jan 16, 2023 at 01:57:51PM -0800, Ian Rogers wrote: > 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 lgtm did you try cross build and build with clang? jirka > --- > 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..515d87b32fb8 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)" AR="$(HOSTAR)" \ > + 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 \ > -- > 2.39.0.314.g84b9a713c41-goog >