Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp1459922rwb; Thu, 19 Jan 2023 10:55:21 -0800 (PST) X-Google-Smtp-Source: AMrXdXtJYwh8cpEK/c6kIrBsHQrOPqUmfbMfJgOWXssneqNYZOIY7FDkzaVOrTmtnaa+LUbEkvBL X-Received: by 2002:a05:6a20:ba11:b0:ad:5a4d:95b5 with SMTP id fa17-20020a056a20ba1100b000ad5a4d95b5mr32357673pzb.40.1674154521676; Thu, 19 Jan 2023 10:55:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674154521; cv=none; d=google.com; s=arc-20160816; b=GjzbH+gUX/pNaFOMn/ajYPO6zIwCU7QUsH51yCWsBvhiPURnOUgrJRIi7qG2owrct4 jJrRwa/WH8xce9rqgamd0yGZnNZAxSzYrBcdgUu1b5B4radrj4/d4VV42vtKWUkrU6XM CFECrKyEHJbPLDzDg9goQeEZGRGUK/Tu4lO9ealtAibUTH4Ayi0SAOZ0W4qpijA+RiDQ yzMlQwwuV6lgKfHxlOZ5EQ0/9QkkzpJUR7mWtuHzx0EIqKDAcC1j527KPXDXHTTfg+kE 7A4rXQ9eNMUrm8JCWx0v6/5if4zWJwFhsJK8KlU437qltfn2ckMRLclwpB9BO42sV1Cr 6CfQ== 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=CTjaq4NJj+o3gOe98XEHdekO9Q0PwCoOsoTblJCwYoc=; b=BHzVXLGWjXJfXNUyg8mlV2b1KkJiQQEZIZ2C8xrcEmYBco0kwQWSvF9CViX5t3MqcN EUCtl1aSBcFFDH/oa9dkcOuMLqG8jM+JSHDMVwSBvRwXmiL47XGBwrlgBp7lJyFGCPjr 0uc9V+3RAOl5gKgKethxQkfzjFkCp40haqQXC7cvF5RRxVnJ8pI61s/6CLApLQYOaW59 AvJ/5bOA5oRMuDfLKG3RwshAdA1thr0WfWslmTHXm/QEb49w9HRGKTzVcisalXCZcyfS E4ea0+UJVQI69vYJvxvLAd2j+W97O2gXk7QmnKxWiQfXSi6+xZ/PjqHXciz2hbS5YrSD X+lw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=grCb9Ts4; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f2-20020a636a02000000b004780e2b6fd6si40346943pgc.362.2023.01.19.10.55.15; Thu, 19 Jan 2023 10:55:21 -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=grCb9Ts4; 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 S229483AbjASSOQ (ORCPT + 47 others); Thu, 19 Jan 2023 13:14:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40834 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230153AbjASSOC (ORCPT ); Thu, 19 Jan 2023 13:14:02 -0500 Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 80CE09085D for ; Thu, 19 Jan 2023 10:14:00 -0800 (PST) Received: by mail-wr1-x431.google.com with SMTP id q10so2706070wrs.2 for ; Thu, 19 Jan 2023 10:14:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=CTjaq4NJj+o3gOe98XEHdekO9Q0PwCoOsoTblJCwYoc=; b=grCb9Ts4cX4YOVle/uQPR+Fc2itoXnMocKb/H9CPEyeXTBZ2TDEGjAxObVMRadq3X0 Ek6950qpjUAGlafb/5ywHJvTRuBI/A6rli031niU+autoHZmBc62UeD65lWw6LTlZw3w cI9J+ES9rTHUZ1Ug6JC6UpQFe9MJ0+FfI/5hlfsocYPy+/+mq/WJhoHhnlmzpUeQ1QIb N6JeDp1zMjmRS/CwaWsNaL4qId86rYcsk1EF8Kv02lQdYwe2NyQt/d5cCgNHVB+0xnJZ pM3NYuLPFf+hfFvXNHjv9N8vSdZXIwIyEmhOIDc6WzyIPcZvVIWU7rgSAcls0pEPr+HQ aEwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=CTjaq4NJj+o3gOe98XEHdekO9Q0PwCoOsoTblJCwYoc=; b=o0c3GTWCj5mMkKgSRYWH9FTwdkqa5jbq4E5eulhf9gTLi+8Zl6IPvTXldMkcVhvn4x XuLOw7ncYk4NJtn88zBF5L0zKaX7v5HqFa/wOT7VBXCR+qLZmejY1N+UCUsEfsLrYJgR Bj2yWUsjgcQRWZPeAxJegnYr4bDlQvOOFnjmtEZYCCMMOrc4d0ovkX8lT+v9ZIvomWax Ici2RCHrWHdMHA2Mnjb5If578DIkYMuTOfqTybRbPssOBwvwCPVTeQvaeOdKpedhS3xg mR9sXFemnAlRQFCiJXbTIqCYHXkvOV7absnzzvu9WVkRqWmD1wGDwGMV7h0z/TsBGP+W kshg== X-Gm-Message-State: AFqh2kpCeJ4EuZ5sQVN7lTJFGeEVje5tv/lhBI+WiwWMuYZgFnV2MMq4 1MPTwPui4m/K1zLYP9GUzIaWb90q7FRNsVUGa5DraQ== X-Received: by 2002:a05:6000:1d9b:b0:2bc:aa47:bf7a with SMTP id bk27-20020a0560001d9b00b002bcaa47bf7amr340047wrb.343.1674152038872; Thu, 19 Jan 2023 10:13:58 -0800 (PST) MIME-Version: 1.0 References: <20230116215751.633675-1-irogers@google.com> <20230116215751.633675-2-irogers@google.com> In-Reply-To: From: Ian Rogers Date: Thu, 19 Jan 2023 10:13:46 -0800 Message-ID: Subject: Re: [PATCH v2 2/2] tools/resolve_btfids: Alter how HOSTCC is forced To: Jiri Olsa 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 Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL 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, Jan 19, 2023 at 6:51 AM Jiri Olsa wrote: > > 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. > > I tested with cross builds for s390/ppc/arm64 and it was ok > > some comments below > > thanks, > jirka > > > > > > 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..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) > > I wonder all the tools should use HOSTCC in the first place? > seems more clear than forcing it from other makefiles > > subcmd even has: > > CC ?= $(CROSS_COMPILE)gcc > LD ?= $(CROSS_COMPILE)ld > AR ?= $(CROSS_COMPILE)ar > > which seems wrong unless I'm missing something.. should be always > the host compiler, right? Hmm.. it seems like a feature to be able to cross compile things like the perf tool. I agree the way this is all done is muddling and we should try to keep the way it is done consistent. The pattern of always early including Makefile.include, that sets flags based on CC, but then overriding CC was what I was after cleaning up here. Let's work on migrating to something better. > > +HOST_OVERRIDES := AR=$(HOSTAR) CC="$(HOSTCC)" LD="$(HOSTLD)" AR="$(HOSTAR)" \ > > + ARCH=$(HOSTARCH) EXTRA_CFLAGS="$(HOSTCFLAGS) $(KBUILD_HOSTCFLAGS)" > > there's extra AR set and ARCH value is not in "" Ack. Will fix in v3. Thanks, Ian > > + > > 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 > >