Mon 12 Mar 2007 02:08:59 AM UTC, original submission:
Hello,
I am having issues with parallel make and archive members. I have a rule which puts all the changed objects in the same archive. However, it doesn't work with the parallel "make -j2" option.
1. Copy this Makefile into a directory and create some files.
mkdir makeprob
cd makeprob
touch foo1.cc
touch foo2.cc
touch foo3.cc
touch foo4.cc
2. Create destination directory:
mkdir /tmp/dest
3. Do a make -j2 and it works fine:
> make -j2
g++ -c -o /tmp/dest/foo1.o foo1.cc
g++ -c -o /tmp/dest/foo2.o foo2.cc
g++ -c -o /tmp/dest/foo3.o foo3.cc
g++ -c -o /tmp/dest/foo4.o foo4.cc
cd /tmp/dest; \
ar rv libfoo.a foo1.o foo2.o foo3.o foo4.o;
ar: creating libfoo.a
a - foo1.o
a - foo2.o
a - foo3.o
a - foo4.o
4. touch all the .cc files and do another make -j2 and it does not load the archive work without doing a second make:
> touch *cc
> make -j2
g++ -c -o /tmp/dest/foo1.o foo1.cc
g++ -c -o /tmp/dest/foo2.o foo2.cc
g++ -c -o /tmp/dest/foo3.o foo3.cc
g++ -c -o /tmp/dest/foo4.o foo4.cc
cd /tmp/dest; \
ar rv libfoo.a ;
> make -j2
cd /tmp/dest; \
ar rv libfoo.a /tmp/dest/foo1.o /tmp/dest/foo2.o /tmp/dest/foo3.o /tmp/dest/foo4.o;
r - /tmp/dest/foo1.o
r - /tmp/dest/foo2.o
r - /tmp/dest/foo3.o
r - /tmp/dest/foo4.o
5. Do the same procedure with single threaded make and it works fine:
> touch *.cc
> make
g++ -c -o /tmp/dest/foo1.o foo1.cc
g++ -c -o /tmp/dest/foo2.o foo2.cc
g++ -c -o /tmp/dest/foo3.o foo3.cc
g++ -c -o /tmp/dest/foo4.o foo4.cc
cd /tmp/dest; \
ar rv libfoo.a foo1.o foo2.o foo3.o foo4.o;
r - foo1.o
r - foo2.o
r - foo3.o
r - foo4.o
It is my suspicion this has something to do with vpath and parallel make. Please let me know if you are able to reproduce this. This was not an issue before I started using VPATH and a destination directory outside of the source area. My temporary fix is to change the $? in the archive rule to $(CXX_OBJS). This is make 3.81 and I am able to reproduce it on both a 32 bit and a 64 bit gentoo system.
I tried the same tests at work and it seems that many of the most recent versions of Make exhibit this issue.
Thanks,
Juan
|