From patchwork Fri Jul 28 02:24:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Namhyung Kim X-Patchwork-Id: 127284 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:918b:0:b0:3e4:2afc:c1 with SMTP id s11csp153995vqg; Thu, 27 Jul 2023 19:57:24 -0700 (PDT) X-Google-Smtp-Source: APBJJlFmcQWPaPGKoLUJVtuJLZP0/v1laa0SfJQoD3y15xGPZzuwbfOcTottsWmWjsxt39tKhhXj X-Received: by 2002:aca:1a15:0:b0:3a3:7e62:fca2 with SMTP id a21-20020aca1a15000000b003a37e62fca2mr1324866oia.0.1690513044080; Thu, 27 Jul 2023 19:57:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690513044; cv=none; d=google.com; s=arc-20160816; b=D915A/+9NBw5ZEpVxAwRAKFZ1WGcj/QXMyEBYDbRYmIlNDDHo9B1kk9W4xOt++W84s 98TV6angLlhuThZazloKf8E1HgKwu1bSnFMNIvOKgua7Zo/9Ry7UaQwRyu/hC8bH/7zT QNY16meA+NZCh8qFiAXSmsQyQe5cIXyKfQ6OAOTjizchHTfP4s9cR5aD8vCs4egs6zSM n0+XsDnRWe/X4Qm9ekZyiJD7lDPsfIOLhcicmIzRnuVQu8ZMRnZgeyR+HVhbWgOiDA50 H0xIDxWD4lUby+sJfj5h1ONv5G0bsXR1uEjGVshle/gbbzVcTRzXjsFxt0j1sxxgdh46 jCmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:sender:dkim-signature; bh=gkA9T81dJeHltp+yU+ufIxNEM6ta13sa3gzDpx7fjW0=; fh=0+7a5fu/FUeiIqPazwYnsTJzAAsSbc1CLnWMxuTAMQQ=; b=qdihigFkTyKLTFuKJ/tQr3rMrdWcBGlXTCxzmqxATe39OKd6pu1bjU5Zy7zc6Hwyif 5uKWgQOdm7WJrq6hvaEpWODi3w/sSeJz6o6MfEE9gl5UINRLVI0WCa8t5jL3SUYkzLtM tSXzbnXTCDP0yDYuYQJmcROj42ntC5nceipV5eELiswo6omfdSJ0aZWCkiYBj0xSbOT6 H/xNPj+b8FgCeGN1OhmokHZFKI/F5Noc/dTbg+MKS3tEdC28Cdhk6eRq87Me/BsIE8cF vdy4HsZe3MC370PIYykS3WjeTALmBOlUNtmS02eZy0+dn/HLEfVNY7HOWemA+lrgfC81 gs1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=HI66uQED; 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=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i134-20020a639d8c000000b005641315d956si1081203pgd.147.2023.07.27.19.57.11; Thu, 27 Jul 2023 19:57:24 -0700 (PDT) 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=20221208 header.b=HI66uQED; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232155AbjG1CZE (ORCPT + 99 others); Thu, 27 Jul 2023 22:25:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60654 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229731AbjG1CZD (ORCPT ); Thu, 27 Jul 2023 22:25:03 -0400 Received: from mail-pj1-x102e.google.com (mail-pj1-x102e.google.com [IPv6:2607:f8b0:4864:20::102e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8E6D630D7; Thu, 27 Jul 2023 19:24:54 -0700 (PDT) Received: by mail-pj1-x102e.google.com with SMTP id 98e67ed59e1d1-2680eee423aso966997a91.2; Thu, 27 Jul 2023 19:24:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1690511094; x=1691115894; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:sender:from:to:cc:subject:date:message-id:reply-to; bh=gkA9T81dJeHltp+yU+ufIxNEM6ta13sa3gzDpx7fjW0=; b=HI66uQEDmixeLcinjB+jPqbc9qCoNsIcmxIzFAIQKnzlmEmgkcaHNi6kb+ZpeAL/U0 uIiOYzYTFZBYIUVJSGqbWgYbpvbdizazBAdIxrSmUOWtCnLt6rfVOmmhRsoGbYfvPEa6 QRF/a4Mlxj3ygUrn3Um8CMsyW/XX5yUW4mj3fvreODdLh47/NrtBKEJcT/ExB/V/8TZM H5dsrB9ryMODykPl6VM4xRXLOogW4ufkHkF/WMKKRTcDZY0JkKbJm6v4s970lIGImruE ffhgWTJCk/TDacZ/t8TuDfKscKe+OjgpsZVFOCj8070VcD/3v8tBa9bTBLN3YrXoy57a oebA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690511094; x=1691115894; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:sender:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=gkA9T81dJeHltp+yU+ufIxNEM6ta13sa3gzDpx7fjW0=; b=BJjsemPdCO2u+5nap7qVlx1YviLXxWZpF+qTpWdk+Y4BeK2opRhLFE8R1jGTLf/DnH I8S2XS4zm/YGKfH/CnqjoyMuKH8YlNX4jFyIkK8KenpFrItZMaszXF3tlGQgE+MLzuiJ REaqioAL0+2UGtR016n1A3wv8naQ9UCtiW4sQZUidEH/RKWrqWZYREcXswijKDcNShDN JFX9XFF6bJylk94Uvr678cTfACyvo/YvsEJNusYzzqnN/f0Ghc4gPM26UZebDrea+41n Oxxodv3M5YYQWGVu4Ph366VkuAmuKtJkGSwz04v0Z8QFb3XyMmFLOmnPwxxOlHru7185 b/cQ== X-Gm-Message-State: ABy/qLafXa23jVKz0aP3ulFM4/JU3wdKhsjckFfnZn30mIcfhxFteC8l 8c4b+nti+OwXIFBDh5523VA= X-Received: by 2002:a17:90b:1910:b0:268:18d2:3e98 with SMTP id mp16-20020a17090b191000b0026818d23e98mr305495pjb.43.1690511093787; Thu, 27 Jul 2023 19:24:53 -0700 (PDT) Received: from bangji.roam.corp.google.com ([101.235.25.38]) by smtp.gmail.com with ESMTPSA id gz24-20020a17090b0ed800b002677739860fsm1696204pjb.34.2023.07.27.19.24.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Jul 2023 19:24:53 -0700 (PDT) Sender: Namhyung Kim From: Namhyung Kim To: Arnaldo Carvalho de Melo , Jiri Olsa Cc: Ian Rogers , Adrian Hunter , Peter Zijlstra , Ingo Molnar , LKML , linux-perf-users@vger.kernel.org, Anup Sharma , stable@vger.kernel.org Subject: [PATCH v2 1/2] perf build: Update build rule for generated files Date: Thu, 27 Jul 2023 19:24:46 -0700 Message-ID: <20230728022447.1323563-1-namhyung@kernel.org> X-Mailer: git-send-email 2.41.0.487.g6d72f3e995-goog MIME-Version: 1.0 X-Spam-Status: No, score=-1.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=no 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: INBOX X-GMAIL-THRID: 1772492559433017347 X-GMAIL-MSGID: 1772631405829542719 The bison and flex generate C files from the source (.y and .l) files. When O= option is used, they are saved in a separate directory but the default build rule assumes the .C files are in the source directory. So it might read invalid file if there are generated files from an old version. The same is true for the pmu-events files. For example, the following command would cause a build failure: $ git checkout v6.3 $ make -C tools/perf # build in the same directory $ git checkout v6.5-rc2 $ mkdir build # create a build directory $ make -C tools/perf O=build # build in a different directory but it # refers files in the source directory Let's update the build rule to specify those cases explicitly to depend on the files in the output directory. Note that it's not a complete fix and it needs the next patch for the include path too. Fixes: 80eeb67fe577 ("perf jevents: Program to convert JSON file") Cc: stable@vger.kernel.org Signed-off-by: Namhyung Kim --- tools/build/Makefile.build | 10 ++++++++++ tools/perf/pmu-events/Build | 6 ++++++ 2 files changed, 16 insertions(+) diff --git a/tools/build/Makefile.build b/tools/build/Makefile.build index 89430338a3d9..fac42486a8cf 100644 --- a/tools/build/Makefile.build +++ b/tools/build/Makefile.build @@ -117,6 +117,16 @@ $(OUTPUT)%.s: %.c FORCE $(call rule_mkdir) $(call if_changed_dep,cc_s_c) +# bison and flex files are generated in the OUTPUT directory +# so it needs a separate rule to depend on them properly +$(OUTPUT)%-bison.o: $(OUTPUT)%-bison.c FORCE + $(call rule_mkdir) + $(call if_changed_dep,$(host)cc_o_c) + +$(OUTPUT)%-flex.o: $(OUTPUT)%-flex.c FORCE + $(call rule_mkdir) + $(call if_changed_dep,$(host)cc_o_c) + # Gather build data: # obj-y - list of build objects # subdir-y - list of directories to nest diff --git a/tools/perf/pmu-events/Build b/tools/perf/pmu-events/Build index 150765f2baee..1d18bb89402e 100644 --- a/tools/perf/pmu-events/Build +++ b/tools/perf/pmu-events/Build @@ -35,3 +35,9 @@ $(PMU_EVENTS_C): $(JSON) $(JSON_TEST) $(JEVENTS_PY) $(METRIC_PY) $(METRIC_TEST_L $(call rule_mkdir) $(Q)$(call echo-cmd,gen)$(PYTHON) $(JEVENTS_PY) $(JEVENTS_ARCH) $(JEVENTS_MODEL) pmu-events/arch $@ endif + +# pmu-events.c file is generated in the OUTPUT directory so it needs a +# separate rule to depend on it properly +$(OUTPUT)pmu-events/pmu-events.o: $(PMU_EVENTS_C) + $(call rule_mkdir) + $(call if_changed_dep,cc_o_c)