From patchwork Mon Jan 16 21:57:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13103702 X-Patchwork-Delegate: bpf@iogearbox.net 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 1EB18C54EBE for ; Mon, 16 Jan 2023 21:58:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233009AbjAPV6L (ORCPT ); Mon, 16 Jan 2023 16:58:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43864 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234743AbjAPV6L (ORCPT ); Mon, 16 Jan 2023 16:58:11 -0500 Received: from mail-pl1-x64a.google.com (mail-pl1-x64a.google.com [IPv6:2607:f8b0:4864:20::64a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 81FD524482 for ; Mon, 16 Jan 2023 13:58:10 -0800 (PST) Received: by mail-pl1-x64a.google.com with SMTP id u2-20020a17090341c200b00192bc565119so20700383ple.16 for ; Mon, 16 Jan 2023 13:58:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=to:from:subject:mime-version:message-id:date:from:to:cc:subject :date:message-id:reply-to; bh=B3Ud16zHjfzs1yDtdBOr0IHKeq4LI90N49HbHwsKBVo=; b=V/jI1wdMtDH79NoMgvZ02I7d05HtyPtxA6BV0pCpSpsdpG2DNlNXj3whT94SF27JCC 4aA9HDu6eubdmaggQcRHm1qL5flQNQG3PyKikqi1azVf7tS4zYU5QYAScaCPqIENtpZN 2GgDi2BtKyE16wMUL1gilrZPBQgEkgYTMfth4nsIjd/YPb5mKTrr78TU4JjM+JxoLr34 FMKXgxbJVbMnWXb84vSFH6DzER4yV3+EfXnQtB/KDVITzGuaOtKSqXusUKGjPw5Oz8m5 4U2KZ6+CVG08+hlgrAenltjQsfd07Kl6BMiWykDAV4tkicm83+slZAuvvqYOiwdn0DWy FX0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:from:subject:mime-version:message-id:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=B3Ud16zHjfzs1yDtdBOr0IHKeq4LI90N49HbHwsKBVo=; b=cz3mnODShzlIbTWha5cBuot9R2OoyfiGKp7Q1SCAwKeGZY3Ysqf3XdD9qV51ak+qKi EZj+DEmGCCvNdpSCMjmfCJQE7ci8Jzxe9RIM1N56gjS+v1yl1ukSvzS4K8dUhCdNEXOL 8PtUuZ8y4nktTGoqYQ5wiW+9JLaJRH/63NlPVb3eugVX8czneNYVbLNFhIeAQxgQkePh pVpxSfSOimvVhLyNCe07YEiKQrTYV59jBpkJ8QACfWoUZWkRaydrE7KJeEfFTUmuNvRj 1C47cFRXs4Uu6BgTz4IFtoB6SaWpiYMZNH5SkQrMXvDNzQ5HWkpZy07+dh1QqFmicQp7 iUlQ== X-Gm-Message-State: AFqh2koM5aYxBQvVwmT0o08bQP2KNalN+Iq0rU+nPzRkd7xfqv9Bi8ao pBTmO2/X+qEbtci0/LdnaLF9M5gA1d1C X-Google-Smtp-Source: AMrXdXvvJvIY2W81/DG4CZ0ccwL+9tOXxprMa7CzsMAqi6D9IlauqUep6nS4wgBJyB5WpcteaNjgU9PddIx2 X-Received: from irogers.svl.corp.google.com ([2620:15c:2d4:203:5088:3695:f3a5:d639]) (user=irogers job=sendgmr) by 2002:a05:6a00:1c9d:b0:58a:f2e5:db46 with SMTP id y29-20020a056a001c9d00b0058af2e5db46mr80189pfw.61.1673906290006; Mon, 16 Jan 2023 13:58:10 -0800 (PST) Date: Mon, 16 Jan 2023 13:57:50 -0800 Message-Id: <20230116215751.633675-1-irogers@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.39.0.314.g84b9a713c41-goog Subject: [PATCH v2 1/2] tools/resolve_btfids: Install subcmd headers 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 Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org X-Patchwork-Delegate: bpf@iogearbox.net Previously tools/lib/subcmd was added to the include path, switch to installing the headers and then including from that directory. This avoids dependencies on headers internal to tools/lib/subcmd. Add the missing subcmd directory to the affected #include. Signed-off-by: Ian Rogers Acked-by: iri Olsa --- tools/bpf/resolve_btfids/Makefile | 19 ++++++++++++++----- tools/bpf/resolve_btfids/main.c | 2 +- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/tools/bpf/resolve_btfids/Makefile b/tools/bpf/resolve_btfids/Makefile index 19a3112e271a..76b737b2560d 100644 --- a/tools/bpf/resolve_btfids/Makefile +++ b/tools/bpf/resolve_btfids/Makefile @@ -35,21 +35,29 @@ SUBCMD_SRC := $(srctree)/tools/lib/subcmd/ BPFOBJ := $(OUTPUT)/libbpf/libbpf.a LIBBPF_OUT := $(abspath $(dir $(BPFOBJ)))/ SUBCMDOBJ := $(OUTPUT)/libsubcmd/libsubcmd.a +SUBCMD_OUT := $(abspath $(dir $(SUBCMDOBJ)))/ LIBBPF_DESTDIR := $(LIBBPF_OUT) LIBBPF_INCLUDE := $(LIBBPF_DESTDIR)include +SUBCMD_DESTDIR := $(SUBCMD_OUT) +SUBCMD_INCLUDE := $(SUBCMD_DESTDIR)include + BINARY := $(OUTPUT)/resolve_btfids BINARY_IN := $(BINARY)-in.o all: $(BINARY) +prepare: $(BPFOBJ) $(SUBCMDOBJ) + $(OUTPUT) $(OUTPUT)/libsubcmd $(LIBBPF_OUT): $(call msg,MKDIR,,$@) $(Q)mkdir -p $(@) $(SUBCMDOBJ): fixdep FORCE | $(OUTPUT)/libsubcmd - $(Q)$(MAKE) -C $(SUBCMD_SRC) OUTPUT=$(abspath $(dir $@))/ $(abspath $@) + $(Q)$(MAKE) -C $(SUBCMD_SRC) OUTPUT=$(SUBCMD_OUT) \ + DESTDIR=$(SUBCMD_DESTDIR) prefix= \ + $(abspath $@) install_headers $(BPFOBJ): $(wildcard $(LIBBPF_SRC)/*.[ch] $(LIBBPF_SRC)/Makefile) | $(LIBBPF_OUT) $(Q)$(MAKE) $(submake_extras) -C $(LIBBPF_SRC) OUTPUT=$(LIBBPF_OUT) \ @@ -60,14 +68,14 @@ CFLAGS += -g \ -I$(srctree)/tools/include \ -I$(srctree)/tools/include/uapi \ -I$(LIBBPF_INCLUDE) \ - -I$(SUBCMD_SRC) + -I$(SUBCMD_INCLUDE) LIBS = -lelf -lz export srctree OUTPUT CFLAGS Q include $(srctree)/tools/build/Makefile.include -$(BINARY_IN): $(BPFOBJ) fixdep FORCE | $(OUTPUT) +$(BINARY_IN): fixdep FORCE prepare | $(OUTPUT) $(Q)$(MAKE) $(build)=resolve_btfids $(BINARY): $(BPFOBJ) $(SUBCMDOBJ) $(BINARY_IN) @@ -79,7 +87,8 @@ clean_objects := $(wildcard $(OUTPUT)/*.o \ $(OUTPUT)/.*.o.d \ $(LIBBPF_OUT) \ $(LIBBPF_DESTDIR) \ - $(OUTPUT)/libsubcmd \ + $(SUBCMD_OUT) \ + $(SUBCMD_DESTDIR) \ $(OUTPUT)/resolve_btfids) ifneq ($(clean_objects),) @@ -96,4 +105,4 @@ tags: FORCE: -.PHONY: all FORCE clean tags +.PHONY: all FORCE clean tags prepare diff --git a/tools/bpf/resolve_btfids/main.c b/tools/bpf/resolve_btfids/main.c index 80cd7843c677..77058174082d 100644 --- a/tools/bpf/resolve_btfids/main.c +++ b/tools/bpf/resolve_btfids/main.c @@ -75,7 +75,7 @@ #include #include #include -#include +#include #define BTF_IDS_SECTION ".BTF_ids" #define BTF_ID "__BTF_ID__" From patchwork Mon Jan 16 21:57:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13103703 X-Patchwork-Delegate: bpf@iogearbox.net 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 0640FC54EBE for ; Mon, 16 Jan 2023 21:58:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234927AbjAPV6U (ORCPT ); Mon, 16 Jan 2023 16:58:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43972 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234743AbjAPV6T (ORCPT ); Mon, 16 Jan 2023 16:58:19 -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 238F1252A8 for ; Mon, 16 Jan 2023 13:58:18 -0800 (PST) Received: by mail-pl1-x649.google.com with SMTP id n1-20020a170902e54100b00192cc6850ffso20694638plf.18 for ; Mon, 16 Jan 2023 13:58:18 -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=im4HZCj7jcJlp9Gtkw1K/6eYSSab6dr0jizMwUKesmY=; b=mFNK+1ILDrtb/vjVJyN/aZBKd7qUO6uZIXxu8LzzcKGw5Ri7j+QgXk9p/PCz4MorJl EVMHWFmDbMz3lnAIez05n6KoU+vt1PA1OFfclqx2r5xJiiiy3D6noqryXHDQK4v1HAt4 VQciOtUsTwLOG3/WtnkGd+t4i4A2JNaA4xf9yK6RHDdCSMpQp0lxB4zgyP0BWz8QuPVl pPvriRmmAX+7PMhRdm7KgJibuKxi4ncRPl+T9e4VrToftfJfa2FTHjSWf00FtXH23slH 1HRnZBQUTZmWlQMGRADtdnzUH31FFhVQDHed3cdHNzAA4vRE/m/50h2bRr8hQ1wrPaU1 YRvA== 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=im4HZCj7jcJlp9Gtkw1K/6eYSSab6dr0jizMwUKesmY=; b=Rhh2Tek5cjPSs6dC1bQm4frVc/sjAYmZEBNe3yE9STTLS2boStAEH3SH/W0QC5JpVj /D5DkV7ny4zXvdkveKdeepq275L3pQHaAbbi3XZex3Zwcw7N5E4xzn3Cp8uw00LALSfY NZBz+iVQJ1HEQWdxTvZCohlFGgi19ympoW3GK8SXVexCXFZ0QdpHL1QvbvSO3vBH7DPH Vw8oEni/aKTcXRPqiJVD+QbvU2D+8iHCLlgxvB3a1+perfqu9a/7W394pzlDIZqIqhl1 zg/AEumaD0RGBgN0Xqqs6tSgadvK5tw7jtZz5k9IU3foKJPp3hprXCFYbl6KVf1B553u fzYA== X-Gm-Message-State: AFqh2kqOKpJ+uHrOKwVWQUVFXHU42lATRHhEXCaoVllpto01FuKYKAuX oeBwnASbN6OcWC+V+C1MAQsj4XzOogRu X-Google-Smtp-Source: AMrXdXv2ow9rG1ZyEcZ7nZsUDooZYfdUMW5ER9m8esbadYNS7siPZ9cymMsCH6dO7VTabRkj27j2EX/o9u00 X-Received: from irogers.svl.corp.google.com ([2620:15c:2d4:203:5088:3695:f3a5:d639]) (user=irogers job=sendgmr) by 2002:a17:90a:408e:b0:229:2296:4be3 with SMTP id l14-20020a17090a408e00b0022922964be3mr81847pjg.5.1673906297579; Mon, 16 Jan 2023 13:58:17 -0800 (PST) Date: Mon, 16 Jan 2023 13:57:51 -0800 In-Reply-To: <20230116215751.633675-1-irogers@google.com> Message-Id: <20230116215751.633675-2-irogers@google.com> Mime-Version: 1.0 References: <20230116215751.633675-1-irogers@google.com> X-Mailer: git-send-email 2.39.0.314.g84b9a713c41-goog Subject: [PATCH v2 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 Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org X-Patchwork-Delegate: bpf@iogearbox.net 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..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 \