Package: make
Version: 3.81-8.2

I have a Makefile where make appears to decide to use the 2nd of a
pair of chained implicit rules to construct a file, despite having
earlier rejected this same pair of rules when deciding whether to
build the necessasry intermediate file.

As a result, make can run the rules for the 2nd implicit rule despite
the fact that one of its prerequisites has not been built.  The
commands for the 2nd rule then fail.


To reproduce:

Firstly, preparation:

 $ git clone git://git.chiark.greenend.org.uk/~ianmdlvl/adns.git
   [ usual output from git clone ]
 $ cd adns
 $ git checkout make-bug.2014-07-26
   [ warning about git about detached HEAD ]
 $ ./configure
 $ make
   [ build should complete successfully ]
 $ cd regress

Now repeat the following steps until you lose the race like this:

 $ touch ../src/addrfam.c 
 $ make -j2
 gcc -g -O2 -Wall -Wmissing-prototypes -Wwrite-strings -Wstrict-prototypes 
-Wcast-qual -Wpointer-arith -Wno-pointer-sign  -I../src -I. -I./../src  
-DADNS_REGRESS_TEST -I. -c -g -o addrfam_d.o ../src/addrfam.c
 gcc    adnstest_c.o hrecord.o hcommon.o types_d.o event_d.o query_d.o 
reply_d.o general_d.o setup_d.o transmit_d.o parse_d.o poll_d.o check_d.o 
addrfam_d.o  -o adnstest_record
 gcc: error: adnstest_c.o: No such file or directory
 make: *** [adnstest_record] Error 1
 $

(If you win the race it rebuilds adnstest_c.o again.)


Detailed consideration of the manual node `Implicit Rule Search'
suggests that the Makefile is correct by virtue of para.6: while the
intermediate file adnstest_c.o does not exist, and is not mentioned as
a target or explicit prerequisite, it can be made.

So make is correct to try to use this rule.  But of course it ought to
construct the file first.

The bug occurs only with nontrivial -j options.  I have reproduced it
with -j4 and (as here) -j2.

I have also, once, seen it do this:

 regress$ touch ../src/addrfam.c; make -j adnstest_record
 gcc -g -O2 -Wall -Wmissing-prototypes -Wwrite-strings -Wstrict-prototypes 
-Wcast-qual -Wpointer-arith -Wno-pointer-sign -I../src -I. -I./../src  
-DADNS_REGRESS_TEST -I. -c -g -o addrfam_d.o ../src/addrfam.c
 regress$

I.e., it built one of the necessary prerequisites and then exited.
(I'm afraid I don't have the exit status.)


I searched the upstream bug database and found this:
  bug #29620: Implicit rule search is still sensitive to random side effects
  http://savannah.gnu.org/bugs/index.php?29620

That seems possibly related but not exactly my problem.


I have found that it is possible to work around this problem by adding
  $(addsuffix _c.o, $(filter-out adnshost,$(CLIENTS))):
or
  .SECONDARY: $(addsuffix _c.o, $(CLIENTS))
to the Makefile.


Thanks,
Ian.


-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Reply via email to