Skip to content

Commit 1f1cd9b

Browse files
committed
Avoid overwriting unchanged output files in genbki.pl and Gen_fmgrtab.pl.
If a particular output file already exists with the contents it should have, leave it alone, so that its mod timestamp is not advanced. In builds using --enable-depend, this can avoid the need to recompile .c files whose included files didn't actually change. It's not clear whether it saves much of anything for users of ccache; but the cost of doing the file comparisons seems to be negligible, so we might as well do it. For developers using the MSVC toolchain, this will create a regression: msvc/Solution.pm will sometimes run genbki.pl or Gen_fmgrtab.pl unnecessarily. I'll look into fixing that separately. Discussion: https://postgr.es/m/16925.1525376229@sss.pgh.pa.us
1 parent 9bf28f9 commit 1f1cd9b

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

src/backend/catalog/Catalog.pm

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ package Catalog;
1616
use strict;
1717
use warnings;
1818

19+
use File::Compare;
20+
21+
1922
# Parses a catalog header file into a data structure describing the schema
2023
# of the catalog.
2124
sub ParseHeader
@@ -336,15 +339,29 @@ sub AddDefaultValues
336339
}
337340

338341
# Rename temporary files to final names.
339-
# Call this function with the final file name and the .tmp extension
342+
# Call this function with the final file name and the .tmp extension.
343+
#
344+
# If the final file already exists and has identical contents, don't
345+
# overwrite it; this behavior avoids unnecessary recompiles due to
346+
# updating the mod date on unchanged header files.
347+
#
340348
# Note: recommended extension is ".tmp$$", so that parallel make steps
341-
# can't use the same temp files
349+
# can't use the same temp files.
342350
sub RenameTempFile
343351
{
344352
my $final_name = shift;
345353
my $extension = shift;
346354
my $temp_name = $final_name . $extension;
347-
rename($temp_name, $final_name) || die "rename: $temp_name: $!";
355+
356+
if (-f $final_name
357+
&& compare($temp_name, $final_name) == 0)
358+
{
359+
unlink $temp_name || die "unlink: $temp_name: $!";
360+
}
361+
else
362+
{
363+
rename($temp_name, $final_name) || die "rename: $temp_name: $!";
364+
}
348365
}
349366

350367
# Find a symbol defined in a particular header file and extract the value.

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy