From 1ceeb8c64bf2a95bdfc5e5bd221886c6df74f560 Mon Sep 17 00:00:00 2001 From: Paul Smith Date: Tue, 3 Jan 2023 01:57:35 -0500 Subject: [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. --- tests/scripts/features/archives | 36 +++++++++++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) (limited to 'tests') 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; -- cgit v1.2.1