bug-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug #14927] Fix for building archive members in parallel


From: Reid Madsen
Subject: [bug #14927] Fix for building archive members in parallel
Date: Thu, 6 Apr 2006 13:00:04 -0500
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.1) Gecko/20060111 Firefox/1.5.0.1

Follow-up Comment #2, bug #14927 (project make):

The crux of the issue here is building objects and adding them to archives IN
PARALLEL.  Up until now, no version of GNUmake has ever supported this
capability. Section 11.3 of the GNUmake manual describes the reasons why it
doesn't work.

This bug, or enhancement, describes a way to fix GNUmake so that you can use
the archive member syntax (e.g., lib(x.o)) in a parallel build environment.
If you've never tried to build an archive in parrallel on a multi-processor
machine using the archive member rules you would never experience the
problem. 

The default archive member rule is as follows:

(%.o): %.c
<TAB> $(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $*.o
<TAB> $(AR) r $@ $*.o
<TAB> $(RM) $*.o

The problem with the above rule is that when you build in parallel, you get
multiple CC, and AR commands running simultaneously.  The CC commands are
okay, because the generate separate .o files.  The AR commands fail because
they are all updating the same library -- and the library is corrupted in the
process.

The solution to this problem requires the following:

1. Disable the built in archive member rule so that the archives DO NOT occur
in parallel. This is done as follows:

lib: lib(%.o): %.o ;

This keeps the AR command from occuring in parallel.  However, since the
default rule for compiles has not been overridden the CC commands still occur
in parallel.

2. Add the AR command to the following rule:

lib: lib($(OBJS))
<TAB> $(AR) r lib $?
<TAB> $(RM) $?

Now the compiles will all occur in parallel follows by a single AR command
that updates all the new objects.

3. And to get #2 to work a bug fix is required so that the modification time
of the newly compiled object is propagated to the archive member.

With these changes in place archives can be built in parallel, and we can
correct a longstanding weakness in GNUmake.

I presently build on a server farm with a few hundred available CPU's.  When
I build an archive with 60 members, the 60 CC commands are launched in
parallel (distcc) across all available cpus.  Once all the compiles complete,
a single AR command is launched to update the library.  Without these fixes
the parallel aspect of this would be impossible -- I would be forced to build
serially.  Yuck.

srmadsen

    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?func=detailitem&item_id=14927>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/





reply via email to

[Prev in Thread] Current Thread [Next in Thread]