Package: make
Version: 4.0-8.2
Severity: minor

Dear maintainer,

It looks like the ar program in the binutils package in debian is now
configured with --enable-deterministic-archives, which is fine (I
guess). However, when dealing with archive members, make needs the
timestamp of the file in order to decide to update it or not. With the
current deterministic behavior of ar, the timestamp is always 0.

The following implicit rule will thus always re-add the member to the
archive as it is considered outdated.

(%): %
#  recipe to execute (built-in):
        $(AR) $(ARFLAGS) $@ $<

An undue update of a file in an archive may have a cascading effect in
both directions. The targets that depend on the archive will have to be
updated; and the archive members (if determined to be intermediate
files) will have to be rebuilt. Thus making a major part of the project
to be rebuilt for no reason.


Steps to reproduce:
1) Create a file foo.c.
int main(void) {
        return 0;
}

2) Create a Makefile.
target: archive.a(foo.o)
        echo doing something

3) Run make twice.
$ make
cc    -c -o foo.o foo.c
ar rv archive.a foo.o
ar: creating archive.a
a - foo.o
echo doing something
doing something
rm foo.o

$ make
cc    -c -o foo.o foo.c
ar rv archive.a foo.o
r - foo.o
echo doing something
doing something
rm foo.o

4) Check that the timestamp of foo.o in archive.a is 0.
$ ar tv archive.a
rw-r--r-- 0/0    848 Jan  1 01:00 1970 foo.o



I think the answer "fix your Makefile" is not appropriate for at least
two reasons:
- Make always rely on the timestamps of the file members, so taking the
  risk of not having them devoid completely the point of having implicit
  rules. And not having valid timestamps can only produce buggy cases
  like the one shown above.
- You cannot always fix the Makefiles because it's not always yours, and
  your Makefiles rely on an archive produced by a Makefile you don't
  have control over.

A workaround may be to add ARFLAGS=rvU as argument or environment
variable to make. This may work in some cases, but it's still a bit
hackish to fix from the outside a broken Makefile when a sensful default
value would fix it once for all.


Best regards,
Celelibi

-- System Information:
Debian Release: stretch/sid
  APT prefers testing
  APT policy: (990, 'testing'), (500, 'unstable'), (500, 'stable'), (1, 
'experimental')
Architecture: i386 (x86_64)

Kernel: Linux 3.10.11 (SMP w/2 CPU cores; PREEMPT)
Locale: LANG=fr_FR.UTF-8, LC_CTYPE=fr_FR.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash
Init: sysvinit (via /sbin/init)

Versions of packages make depends on:
ii  libc6  2.19-19

make recommends no packages.

Versions of packages make suggests:
pn  make-doc  <none>

-- no debconf information

Reply via email to