From patchwork Tue Nov 22 00:11:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 24067 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp1920505wrr; Mon, 21 Nov 2022 16:42:17 -0800 (PST) X-Google-Smtp-Source: AA0mqf5s0AxQmNSxqnFm2AZQkCQVcbq2Alg7Y+PJARH5LP5M059zaiK2244i33yfi7rU8eOI4cCJ X-Received: by 2002:a17:906:ee2:b0:78d:3f96:b7aa with SMTP id x2-20020a1709060ee200b0078d3f96b7aamr4085006eji.74.1669077736935; Mon, 21 Nov 2022 16:42:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669077736; cv=none; d=google.com; s=arc-20160816; b=Q/PVaEvu4hYlu5ZmPVoXIzO7HH8Ai4Le2xVt11/riItOgEoDUMmG32PYxzZCj7iP6V 7KIzo5ng8vcBVdTGHnsGpk4MpNHJihgRXzKEew3cLJvaTETm5hiFzg4hohmMze2jn7f3 cdIzaAoIFSOp9RGX9qJ4tAmnCaZAhFX+FxgGRJ+VIUovwIXBszOwutHyyZeilXenN4XV 2iiyhtHpDVAoQx5XW6cYsRWaFDc8/FuDFOWTsEnk567V5zByyUQPTkVk3LEwHWHGUcuO 05QaYD5Rq2hlVrx16PtMU+V8Lg7XKkgMd9jRWcgXVuG6/rz82llpuMjHXF0hhhz8nPmJ Mg0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:references:mime-version :message-id:in-reply-to:date:dkim-signature; bh=GoR0XfyfLKOGrF4aZi9U/Y5nI4Wyasyd+UL78gHDN8Q=; b=hU/la4dMxYBKEhrrJXVk3P6Ra0gx3KOhcSXOSpx+ZGlKGLZk9CNat6ay5IGouXUk8M 9VyMLV+AuceUf7k9rL7wzIwvYg0U3sGNZ0QvZ7Cd5rCgI8taRx5aEzYorMuMgnSXX50E MnvAZFInwQgMvkyPuZJUz8DlctmvYjbDVK6JNRwcgwJ4fA/EqiexEXgw+VT0llnyXG90 7NJkR7lgrFarvYM1wBRFaoCwMcDvRsWl2xKQbg5quLIyyrjXtB9nbCwkc58SHp+9RATM 6q2Pwrqvw0tztVctGS/5ysw1wvBIztPWXNg4kd8+4irlhmmMxYstmsy8d+70/n6QCiq2 Ob6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b="lNTU/PzL"; 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 sz15-20020a1709078b0f00b007a4feae7ae7si6875860ejc.575.2022.11.21.16.41.52; Mon, 21 Nov 2022 16:42:16 -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="lNTU/PzL"; 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 S232173AbiKVAMS (ORCPT + 99 others); Mon, 21 Nov 2022 19:12:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40092 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232089AbiKVAMC (ORCPT ); Mon, 21 Nov 2022 19:12:02 -0500 Received: from mail-yw1-x114a.google.com (mail-yw1-x114a.google.com [IPv6:2607:f8b0:4864:20::114a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 01427BA593 for ; Mon, 21 Nov 2022 16:11:58 -0800 (PST) Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-391842a55d6so117595027b3.0 for ; Mon, 21 Nov 2022 16:11:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=GoR0XfyfLKOGrF4aZi9U/Y5nI4Wyasyd+UL78gHDN8Q=; b=lNTU/PzLJsqM2jLMTKBPrA4eAqGQHrDPAkxlfcHQm+r1wj/z9o8rIwqKYDLjoNXHkb YgSSO/lwGMoBnf+CYYg0UW5j5tawIogVOlSJfAAH5Ltv3ED+3MiK5Nq+bjSctz/TRcz8 +3A2cr1oQR77bin4jeqYK33MIxQD/Aamnq8P62owl5JUyRW38kLK8Am6EETziPSZIGhV Xx89fZ76t9YtTJKjTev19Th4JzJ93Q1Ht35I2ESNs3JlEH59PZCxLnrycIA7MjxG6P8X Vpg4uh86bV4ncCmkEPeRQlmid6Jv9G/nGNDqdeGbH9wCt1LUeifTLuFKBwFnlwowNOxl CboA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc: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=GoR0XfyfLKOGrF4aZi9U/Y5nI4Wyasyd+UL78gHDN8Q=; b=YAOIfcMYkod7SKqmH6BxYVykYtIAfxbshLzpMfxEDVN5DljETMxvaXN3/zdueEanSB dOvkzoFJ2BmtwEySjiozCQgTAz3ZZQpQlqS4FTdMuAPUdqb3epxTHG6dOpMWPRReXwXY CfOvsdFRzYdZNYGNSv2yCuJ6ZnnXnBsHUX/JATjlliasMGkuyyRbhl66eAfcslDyP4CF 7Xh+awKeKdQ/YmwXSL4jHLYRe0UgHE0ctLGsFOJknxdNnYGuzo0+gPFoAz3NLqpri7oe JmQO2KvKoynLe/cJi2EAmIh4fepzmRp2EMv/vn753erU0Yiy2cVWn8QaGSlsC/FSJrig D6fA== X-Gm-Message-State: ANoB5pm70pOZy5/aTCJdp88uRknR8qEKGsLJC+gWZ6eivhsrLm6+JOxi IxxMyQnosAYZ7jWNyvDFctR9t1ESZA7C X-Received: from irogers.svl.corp.google.com ([2620:15c:2d4:203:2107:a1f5:8582:5608]) (user=irogers job=sendgmr) by 2002:a25:2e0e:0:b0:6cc:35b9:8525 with SMTP id u14-20020a252e0e000000b006cc35b98525mr5139616ybu.104.1669075917318; Mon, 21 Nov 2022 16:11:57 -0800 (PST) Date: Mon, 21 Nov 2022 16:11:23 -0800 In-Reply-To: <20221122001125.765003-1-irogers@google.com> Message-Id: <20221122001125.765003-3-irogers@google.com> Mime-Version: 1.0 References: <20221122001125.765003-1-irogers@google.com> X-Mailer: git-send-email 2.38.1.584.g0f3c55d4c2-goog Subject: [PATCH v2 2/4] objtool: Install libsubcmd in build From: Ian Rogers To: Josh Poimboeuf , Peter Zijlstra , Nathan Chancellor , Nick Desaulniers , Tom Rix , Masahiro Yamada , Nicolas Schier , linux-kernel@vger.kernel.org, llvm@lists.linux.dev Cc: Stephane Eranian , Andrii Nakryiko , Jiri Olsa , Arnaldo Carvalho de Melo , Namhyung Kim , Ian Rogers 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=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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750154856981350118?= X-GMAIL-MSGID: =?utf-8?q?1750154856981350118?= Including from tools/lib can create inadvertent dependencies. Install libsubcmd in the objtool build and then include the headers from there. Signed-off-by: Ian Rogers --- tools/objtool/Build | 2 -- tools/objtool/Makefile | 33 +++++++++++++++++++++++++-------- 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/tools/objtool/Build b/tools/objtool/Build index 33f2ee5a46d3..a3cdf8af6635 100644 --- a/tools/objtool/Build +++ b/tools/objtool/Build @@ -16,8 +16,6 @@ objtool-y += libctype.o objtool-y += str_error_r.o objtool-y += librbtree.o -CFLAGS += -I$(srctree)/tools/lib - $(OUTPUT)libstring.o: ../lib/string.c FORCE $(call rule_mkdir) $(call if_changed_dep,cc_o_c) diff --git a/tools/objtool/Makefile b/tools/objtool/Makefile index a3a9cc24e0e3..fd9b3e3113c6 100644 --- a/tools/objtool/Makefile +++ b/tools/objtool/Makefile @@ -12,9 +12,15 @@ srctree := $(patsubst %/,%,$(dir $(CURDIR))) srctree := $(patsubst %/,%,$(dir $(srctree))) endif -SUBCMD_SRCDIR = $(srctree)/tools/lib/subcmd/ -LIBSUBCMD_OUTPUT = $(or $(OUTPUT),$(CURDIR)/) -LIBSUBCMD = $(LIBSUBCMD_OUTPUT)libsubcmd.a +LIBSUBCMD_DIR = $(srctree)/tools/lib/subcmd/ +ifneq ($(OUTPUT),) + LIBSUBCMD_OUTPUT = $(abspath $(OUTPUT))/libsubcmd +else + LIBSUBCMD_OUTPUT = $(CURDIR)/libsubcmd +endif +LIBSUBCMD_DESTDIR = $(LIBSUBCMD_OUTPUT) +LIBSUBCMD = $(LIBSUBCMD_OUTPUT)/libsubcmd.a +CFLAGS += -I$(LIBSUBCMD_OUTPUT)/include OBJTOOL := $(OUTPUT)objtool OBJTOOL_IN := $(OBJTOOL)-in.o @@ -28,7 +34,8 @@ INCLUDES := -I$(srctree)/tools/include \ -I$(srctree)/tools/arch/$(HOSTARCH)/include/uapi \ -I$(srctree)/tools/arch/$(SRCARCH)/include \ -I$(srctree)/tools/objtool/include \ - -I$(srctree)/tools/objtool/arch/$(SRCARCH)/include + -I$(srctree)/tools/objtool/arch/$(SRCARCH)/include \ + -I$(LIBSUBCMD_OUTPUT)/include WARNINGS := $(EXTRA_WARNINGS) -Wno-switch-default -Wno-switch-enum -Wno-packed -Wno-nested-externs CFLAGS := -Werror $(WARNINGS) $(KBUILD_HOSTCFLAGS) -g $(INCLUDES) $(LIBELF_FLAGS) LDFLAGS += $(LIBELF_LIBS) $(LIBSUBCMD) $(KBUILD_HOSTLDFLAGS) @@ -38,6 +45,7 @@ elfshdr := $(shell echo '$(pound)include ' | $(CC) $(CFLAGS) -x c -E - CFLAGS += $(if $(elfshdr),,-DLIBELF_USE_DEPRECATED) AWK = awk +MKDIR = mkdir BUILD_ORC := n @@ -57,13 +65,22 @@ $(OBJTOOL): $(LIBSUBCMD) $(OBJTOOL_IN) $(QUIET_LINK)$(CC) $(OBJTOOL_IN) $(LDFLAGS) -o $@ -$(LIBSUBCMD): fixdep FORCE - $(Q)$(MAKE) -C $(SUBCMD_SRCDIR) OUTPUT=$(LIBSUBCMD_OUTPUT) +$(LIBSUBCMD_OUTPUT): + @$(MKDIR) -p $@ + +$(LIBSUBCMD): fixdep FORCE $(LIBSUBCMD_OUTPUT) + @$(MAKE) -C $(LIBSUBCMD_DIR) O=$(LIBSUBCMD_OUTPUT) \ + DESTDIR=$(LIBSUBCMD_DESTDIR) prefix= subdir= \ + $@ install_headers + +$(LIBSUBCMD)-clean: + $(call QUIET_CLEAN, libsubcmd) + $(Q)$(RM) -r -- $(LIBSUBCMD_OUTPUT) -clean: +clean: $(LIBSUBCMD)-clean $(call QUIET_CLEAN, objtool) $(RM) $(OBJTOOL) $(Q)find $(OUTPUT) -name '*.o' -delete -o -name '\.*.cmd' -delete -o -name '\.*.d' -delete - $(Q)$(RM) $(OUTPUT)arch/x86/lib/inat-tables.c $(OUTPUT)fixdep $(LIBSUBCMD) + $(Q)$(RM) $(OUTPUT)arch/x86/lib/inat-tables.c $(OUTPUT)fixdep FORCE: