Autoreconf race condition?

Petr Pisar ppisar at redhat.com
Tue May 22 12:21:11 UTC 2012


On 2012-05-22, Jan Synacek <jsynacek at redhat.com> wrote:
>
> I've run into a problem when I was trying to build tftp (master
> branch) package locally.
>
> Notice the execution of rm -f aconfig.h *after* make.

That's how the Makefile is written. Unfortunatelly, it does not define
all targets produced by each command. Also the make compares
modification times of targets and prerequisites. And that's the reason,
why make does not re-run configure (needed to generate aconfig.h removed
before explicitly). You can see it by running:

$ make -j5 -n --no-builtin-rules -d
[...]
 No implicit rule found for `all'.
  Considering target file `MCONFIG'.
    Considering target file `configure'.
      Considering target file `configure.in'.
       Looking for an implicit rule for `configure.in'.
       No implicit rule found for `configure.in'.
       Finished prerequisites of target file `configure.in'.
      No need to remake target `configure.in'.
      Considering target file `aclocal.m4'.
       Looking for an implicit rule for `aclocal.m4'.
       No implicit rule found for `aclocal.m4'.
       Finished prerequisites of target file `aclocal.m4'.
      No need to remake target `aclocal.m4'.
     Finished prerequisites of target file `configure'.
     Prerequisite `configure.in' is older than target `configure'.
     Prerequisite `aclocal.m4' is older than target `configure'.
    No need to remake target `configure'.
    Considering target file `MCONFIG.in'.
     Looking for an implicit rule for `MCONFIG.in'.
     No implicit rule found for `MCONFIG.in'.
     Finished prerequisites of target file `MCONFIG.in'.
    No need to remake target `MCONFIG.in'.
    Considering target file `aconfig.h.in'.
      Pruning file `configure.in'.
      Pruning file `configure'.
      Pruning file `aclocal.m4'.
     Finished prerequisites of target file `aconfig.h.in'.
     Prerequisite `configure.in' is older than target `aconfig.h.in'.
→    Prerequisite `configure' is newer than target `aconfig.h.in'.
     Prerequisite `aclocal.m4' is older than target `aconfig.h.in'.
    Must remake target `aconfig.h.in'.
[...]

Which is dragged in by upstream `fix':
> I also noticed a rather weird comment in the Makefile:
>
>     # Adding "configure" to the dependencies serializes this with running
>     # autoconf, because there are apparently race conditions between
>     # autoconf and autoheader.
>     aconfig.h.in: configure.in configure aclocal.m4
>     rm -f aconfig.h.in aconfig.h
>     autoheader

Thus you get rm file removal without re-runing configure. The last
bullet is they remove a file which has been already considered by make
as up-to-date target (and call it side-effect).

> The problem goes away when I add sleep 1 between autoreconf and %configure in
> the spec file.
>
Sound like an issue with modification times granularity.

I would remove the configure prequisite from aconfig.h.in target (that's
really fake dependency) or touch the files to get better ordering.

-- Petr



More information about the devel mailing list