Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp1660606rwb; Wed, 26 Jul 2023 16:42:17 -0700 (PDT) X-Google-Smtp-Source: APBJJlFANoWRdFDnXxcKW5iyPfTILRuIseaxp1S9gmjtU/hMrZ6IL6fBiKksSOvNoM5MoVyCjOIM X-Received: by 2002:a05:6358:7f04:b0:134:c7ef:406d with SMTP id p4-20020a0563587f0400b00134c7ef406dmr480362rwn.31.1690414937195; Wed, 26 Jul 2023 16:42:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690414937; cv=none; d=google.com; s=arc-20160816; b=ik4K2j15HJ/lz6GSXQU9AT2M4UNHIm4lZN9sBE9gbbvcheChBTPbH3/6iKVV5rDKU5 A9RqK0r6XwCI035gFsaC154U9uOtfndrGH3B0n0lneAjXewAv4fa6yD0q5AWTPtb49Pl 8pBro4/nOy9pl4klCjJrdJvJ0myN+ZlUFYPMHo+GyFfBhGvUUQDXbtiQBrDA1EEDDbU7 fUzDZE8WNkMgZ452F52f1WydVrUbiNlF370qAXbYhZVI97U4LIMMusO44u9Pgb5hVF6o GdsJ3SaO9WCO3MFaaxGDkRrfxeag+XWohLY23XS+scD4gHRIHJDJ2JN0A9U+xFMF3Sfx pj/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version; bh=ILGonx6twQnrrbEWTdPU5lYGGJcjSpZHaouZvNhaHg8=; fh=bC1gRhHcl0yNSdnXf8g3/7eHWBSvo6UFhO9U+rihF18=; b=RELNN8AvpEUIJ9d1BT3/5smRFoKgel3DPTiK0fljLrDycYD74rzH1h8dn8SonmsEJH kG4LvimGWXWLAnf1obQ6QReO3UtfixCNvhBnjBcYY49yk8l9agPML+SG6jWo7uKR9YgF npWWAzuUKuNLWr1EvGoqjQXDBieqbpbQOej6CSn0blXlQVqPw4svP9Qdia0ky2zoVh2k OcdF8kK6VRan8o7w2fpUjOuFZUbWHAmlBOMjPoGgQMsqjc56b2iiDJ3KEczkEMCwV5cy fZoeGJMLPAN1Xhk942Ew+4YMYnKJv461mz5r9pzNWaEqanW7Izo93T9pB0NQyDAFaMok exGQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b75-20020a63344e000000b00563deb65f94si101978pga.192.2023.07.26.16.42.05; Wed, 26 Jul 2023 16:42:17 -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; 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 S230392AbjGZW5R convert rfc822-to-8bit (ORCPT + 99 others); Wed, 26 Jul 2023 18:57:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42348 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230232AbjGZW5P (ORCPT ); Wed, 26 Jul 2023 18:57:15 -0400 Received: from mail-io1-f45.google.com (mail-io1-f45.google.com [209.85.166.45]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D64EE271D; Wed, 26 Jul 2023 15:57:14 -0700 (PDT) Received: by mail-io1-f45.google.com with SMTP id ca18e2360f4ac-7878e573827so11624839f.1; Wed, 26 Jul 2023 15:57:14 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690412234; x=1691017034; h=content-transfer-encoding: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=PCmsUfocE9nW+Ujffe8WMtyaTbfPSG5Ra3w/88GS7Cs=; b=Y1pGY9gxRxZgx8o/K7Q7Wu7fC+AERx1rMm4PQ27QsCE7apgo1FUm2W4WeHFyuUGpRa BLzZc/INEOD7i2RVK78fDDOxM2wuIgvrgsPe8qsF82O59hehZu1vFwxR/GAcoCPiH92u euwATkOHp0R267sxXTPUt2AWzo1dCXWRqX76r70QwdWidDS+0HJuJz5XsHblZIhYqUvd e4A9NMk795NPmUAiLp5ROq1eOT9bRa5nKU+Zrm8OuZGL5oyeghv2HPcTXW/MnCeI8/S2 D9HWEc724L8+LvtuYa7cW9yUfR35wh5AjWBA3Iet/dI5BDsF23qFu0nXcZgLkIslxjYE A6mg== X-Gm-Message-State: ABy/qLY6XjMngTS8ESoermipv85ii0GrHk+TtjW7mi+Ej9i1u91RxQGP fzLiY56GeLeZ3gy0oN9Z6k+3fmoU6swfMv65NvQ= X-Received: by 2002:a05:6602:42ca:b0:783:63ac:25cf with SMTP id ce10-20020a05660242ca00b0078363ac25cfmr3470921iob.7.1690412233786; Wed, 26 Jul 2023 15:57:13 -0700 (PDT) MIME-Version: 1.0 References: <20230726133642.750342-1-namhyung@kernel.org> In-Reply-To: From: Namhyung Kim Date: Wed, 26 Jul 2023 15:57:02 -0700 Message-ID: Subject: Re: [PATCH 1/2] perf build: Update build rule for generated files To: Ian Rogers Cc: Arnaldo Carvalho de Melo , Jiri Olsa , Adrian Hunter , Peter Zijlstra , Ingo Molnar , LKML , linux-perf-users@vger.kernel.org, Anup Sharma , stable@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2,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 Hi Ian, On Wed, Jul 26, 2023 at 8:48 AM Ian Rogers wrote: > > On Wed, Jul 26, 2023 at 6:36 AM Namhyung Kim wrote: > > > > 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 | 8 ++++++++ > > tools/perf/pmu-events/Build | 4 ++++ > > 2 files changed, 12 insertions(+) > > > > diff --git a/tools/build/Makefile.build b/tools/build/Makefile.build > > index 89430338a3d9..f9396696fcbf 100644 > > --- a/tools/build/Makefile.build > > +++ b/tools/build/Makefile.build > > @@ -117,6 +117,14 @@ $(OUTPUT)%.s: %.c FORCE > > $(call rule_mkdir) > > $(call if_changed_dep,cc_s_c) > > > > +$(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) > > + > > Hi Namhyung, > > as we have: > ``` > $(OUTPUT)%.o: %.c FORCE > $(call rule_mkdir) > $(call if_changed_dep,$(host)cc_o_c) > ``` > I'm not sure what the 2 additional rules achieve. The above rule assumes the .c files are in the source directory (without $(OUTPUT) prefix). It caused a trouble when the flex and bison files are generated in the output directory and you have an old version of them in the source directory. > > > # 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..f38a27765604 100644 > > --- a/tools/perf/pmu-events/Build > > +++ b/tools/perf/pmu-events/Build > > @@ -35,3 +35,7 @@ $(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 > > + > > +$(OUTPUT)pmu-events/pmu-events.o: $(PMU_EVENTS_C) > > + $(call rule_mkdir) > > + $(call if_changed_dep,$(host)cc_o_c) > > If we add this, do the Makefile.build changes still need to happen? The Makefile.build changes are specific to flex and bison files. So yes, we need this for pmu-events.c to work properly with O= option. Thanks, Namhyung