diff options
author | Paul Smith <psmith@gnu.org> | 2023-01-03 01:57:35 -0500 |
---|---|---|
committer | Paul Smith <psmith@gnu.org> | 2023-01-03 01:57:35 -0500 |
commit | 1ceeb8c64bf2a95bdfc5e5bd221886c6df74f560 (patch) | |
tree | 134ec02d7f337d65d5d880c6738fdff097068699 /tests | |
parent | 8791d2b38ec916ea4206d5cae3b0036bb440c918 (diff) | |
download | make-git-1ceeb8c64bf2a95bdfc5e5bd221886c6df74f560.tar.gz |
[SV 14927] Allow parallel builds for archives
Compare the timestamp of the object file (if it exists) with the
archived object and if the object file is newer, ensure it's updated
in the archive.
* NEWS: Announce the new capability.
* doc/make.texi (Dangers When Using Archives): Explain how to enable
parallel builds with archives.
* src/remake.c (f_mtime): For archive element files check the mod
time of the object file (if it exists) against the archive object
(if it exists).
* tests/scripts/features/archives: Add tests for this capability.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/scripts/features/archives | 36 |
1 files changed, 33 insertions, 3 deletions
diff --git a/tests/scripts/features/archives b/tests/scripts/features/archives index b0d479b2..2ad34d92 100644 --- a/tests/scripts/features/archives +++ b/tests/scripts/features/archives @@ -20,9 +20,7 @@ if ($osname eq 'VMS') { # objects when the test tampers with the timestamp. 1 while unlink "$afile.c1"; 1 while unlink "$afile.o"; - open (MYFILE, ">$afile.c1"); - print MYFILE "int $afile(void) {return 1;}\n"; - close MYFILE; + create_file("$afile.c1", "int $afile(void) {return 1;}\n"); system("cc $afile.c1 /object=$afile.o"); } } else { @@ -238,5 +236,37 @@ $pre%: ; touch \$\@ unlink($lib); } +# SV 61436 : Allow redefining archive rules to propagate timestamps + +# Find the output when creating an archive from multiple files + +utouch(-10, 'a.o', 'b.o'); +my $create2 = `$ar $arflags mylib.a a.o b.o $redir`; +touch('b.o'); +my $add2 = `$ar $arflags mylib.a b.o $redir`; +unlink('a.o', 'b.o', 'mylib.a'); + +utouch(-20, 'a.c', 'b.c'); + +run_make_test(q! +mylib.a: mylib.a(a.o b.o) +(%): % ; +%.a: ; $(AR) $(ARFLAGS) $@ $? +%.o : %.c ; @echo Compile $<; $(COMPILE.c) -o $@ $< +!, $arvar, "Compile a.c\nCompile b.c\n$ar $arflags mylib.a a.o b.o\n${create2}rm b.o a.o"); + +run_make_test(undef, $arvar, "#MAKE#: 'mylib.a' is up to date."); + +# Now update one of the source files and it should be compiled and archived + +sleep(2); +touch('b.c'); + +run_make_test(undef, $arvar, "Compile b.c\n$ar $arflags mylib.a b.o\n${add2}rm b.o"); + +run_make_test(undef, $arvar, "#MAKE#: 'mylib.a' is up to date."); + +unlink('a.c', 'b.c', 'a.o', 'b.o', 'mylib.a'); + # This tells the test driver that the perl test script executed properly. 1; |