GNU bug report logs - #60747
[PATCH] dirstamp: switch to a pattern rule

Previous Next

Package: automake-patches;

Reported by: Mike Frysinger <vapier <at> gentoo.org>

Date: Thu, 12 Jan 2023 03:23:02 UTC

Severity: normal

Tags: patch

Done: Mike Frysinger <vapier <at> gentoo.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 60747 in the body.
You can then email your comments to 60747 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to automake-patches <at> gnu.org:
bug#60747; Package automake-patches. (Thu, 12 Jan 2023 03:23:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Mike Frysinger <vapier <at> gentoo.org>:
New bug report received and forwarded. Copy sent to automake-patches <at> gnu.org. (Thu, 12 Jan 2023 03:23:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Mike Frysinger <vapier <at> gentoo.org>
To: automake-patches <at> gnu.org
Subject: [PATCH] dirstamp: switch to a pattern rule
Date: Wed, 11 Jan 2023 22:22:38 -0500
We can leverage $(@D) to generate a single pattern rule for all dirstamp
rules.  This saves many lines in the output -- normally we create 2 rules
(or 6 lines) per subdir, and projects that use subdirs tend to use them
quite a bit.

In the most extreme & unlikely case (1 subdir, no depdir support), the
line count is the same.  In every other case, it's always a win.

Looking at a few real world projects, the line deltas:
* GNU libgloss: +3 -66
* GNU newlib:   +3 -714
* GNU sim:      +3 -138

There shouldn't be any concerns about portability with $(@D) because:
(1) We only generate this rule iff we know the dirstamp is in a subdir
    (so we'd never have a case where $(@D) would expand to the cwd)
(2) We already rely on $(@D) in our depdir code, and have since 2014
    (the Automake 1.16 release).
---
 bin/automake.in | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/bin/automake.in b/bin/automake.in
index 1c13a3187f46..139d5ad93a9a 100644
--- a/bin/automake.in
+++ b/bin/automake.in
@@ -7893,6 +7893,14 @@ sub require_build_directory
   $directory_map{$directory} = $dirstamp;
   $directory_map{$cdir} = $dirstamp;
 
+  # Generate the pattern rule only once.
+  if (! vardef ('am__dirstamp', TRUE))
+    {
+      $output_rules .= ("%/\$(am__dirstamp):\n"
+			. "\t\@\$(MKDIR_P) \$(\@D)\n"
+			. "\t\@: >>\$\@\n");
+    }
+
   # Set a variable for the dirstamp basename.
   define_pretty_variable ('am__dirstamp', TRUE, INTERNAL,
 			  '$(am__leading_dot)dirstamp');
@@ -7900,10 +7908,6 @@ sub require_build_directory
   # Directory must be removed by 'make distclean'.
   $clean_files{$dirstamp} = DIST_CLEAN;
 
-  $output_rules .= ("$dirstamp:\n"
-		    . "\t\@\$(MKDIR_P) $directory\n"
-		    . "\t\@: >>$dirstamp\n");
-
   return $dirstamp;
 }
 
-- 
2.39.0





Information forwarded to automake-patches <at> gnu.org:
bug#60747; Package automake-patches. (Thu, 12 Jan 2023 22:51:02 GMT) Full text and rfc822 format available.

Message #8 received at 60747 <at> debbugs.gnu.org (full text, mbox):

From: Karl Berry <karl <at> freefriends.org>
To: vapier <at> gentoo.org
Cc: 60747 <at> debbugs.gnu.org
Subject: Re: [bug#60747] [PATCH] dirstamp: switch to a pattern rule
Date: Thu, 12 Jan 2023 15:50:14 -0700
    There shouldn't be any concerns about portability with $(@D) because:
    (1) We only generate this rule iff we know the dirstamp is in a subdir
        (so we'd never have a case where $(@D) would expand to the cwd)
    (2) We already rely on $(@D) in our depdir code, and have since 2014
        (the Automake 1.16 release).

I can't say I've ever come across, let alone touched, the "dirstamp code",
but your arguments are convincing to me. I assume all tests pass
after the change. Please go ahead and commit. --thanks, karl.





bug closed, send any further explanations to 60747 <at> debbugs.gnu.org and Mike Frysinger <vapier <at> gentoo.org> Request was from Mike Frysinger <vapier <at> gentoo.org> to control <at> debbugs.gnu.org. (Fri, 13 Jan 2023 04:06:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Fri, 10 Feb 2023 12:24:06 GMT) Full text and rfc822 format available.

This bug report was last modified 1 year and 75 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.