Package: make
Version: 3.81-5
Severity: normal

I stumbled on a problem with make -j2. Here is how to reproduce the problem:

# First create some files:

cat >Makefile <<"EOF"
ALL=foo bar and much more

build-%/lib.so: build-%/rsrc.res build-%/main.o
        cat $^ >$@ || rm $@

# .SECONDARY: $(ALL:%=build-%/rsrc.res)
.SUFFIXES: .rc .res
.rc.res:
        cat $< >$@ || rm $@

$(ALL:%=build-%/rsrc.rc): rsrc.rc.in
        mkdir -p `dirname $...@`
        cat $< >$@ || rm $@

$(ALL:%=build-%/main.o): main.c
        mkdir -p `dirname $...@`
        cat $< >$@ || rm $@
EOF

echo foo >main.c
echo bar >rsrc.rc.in

# But note that the copy/paste may have messed up the tabs in the Makefile.


# Then do a normal build
make -j2 build-foo/lib.so
mkdir -p `dirname build-foo/rsrc.rc`
mkdir -p `dirname build-foo/main.o`
cat rsrc.rc.in >build-foo/rsrc.rc || rm build-foo/rsrc.rc
cat main.c >build-foo/main.o || rm build-foo/main.o
cat build-foo/rsrc.rc >build-foo/rsrc.res || rm build-foo/rsrc.res
cat build-foo/rsrc.res build-foo/main.o >build-foo/lib.so || rm build-foo/lib.so
rm build-foo/rsrc.res

# All good, now trigger a rebuild
touch main.c
make -j2 build-foo/lib.so
mkdir -p `dirname build-foo/main.o`
cat main.c >build-foo/main.o || rm build-foo/main.o
cat build-foo/rsrc.res build-foo/main.o >build-foo/lib.so || rm build-foo/lib.so
cat: build-foo/rsrc.res: Aucun fichier ou dossier de ce type

# -> make forgot to rebuild the build-foo/rsrc.res intermediate file!

# Let's try again
make -j2 build-foo/lib.so
cat build-foo/rsrc.rc >build-foo/rsrc.res || rm build-foo/rsrc.res
cat build-foo/rsrc.res build-foo/main.o >build-foo/lib.so || rm build-foo/lib.so
rm build-foo/rsrc.res

# -> Now that there was only the intermediate file to rebuild it worked fine.

# Let's try again without the -j2
touch main.c
make build-foo/lib.so
mkdir -p `dirname build-foo/main.o`
cat main.c >build-foo/main.o || rm build-foo/main.o
cat build-foo/rsrc.rc >build-foo/rsrc.res || rm build-foo/rsrc.res
cat build-foo/rsrc.res build-foo/main.o >build-foo/lib.so || rm build-foo/lib.so
rm build-foo/rsrc.res

# -> Works fine for non parallel builds


So there are two workarounds:
 * Disable parallel builds
 * Declare the rsrc.res intermediate file as .SECONDARY so that it's not 
necessary to rebuild it in the first place.


-- System Information:
Debian Release: squeeze/sid
  APT prefers testing
  APT policy: (500, 'testing'), (500, 'stable')
Architecture: i386 (i686)

Kernel: Linux 2.6.25.3fg1 (PREEMPT)
Locale: LANG=fr_FR.UTF-8, LC_CTYPE=fr_FR.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash

Versions of packages make depends on:
ii  libc6                         2.9-4      GNU C Library: Shared libraries

make recommends no packages.

Versions of packages make suggests:
ii  make-doc                      3.81-4     Documentation for the GNU version 

-- no debconf information



-- 
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]

Reply via email to