mirror of
https://github.com/mirror/make.git
synced 2026-08-23 02:13:28 +08:00
[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.
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user