compiling multiple source files at once

Neil Booth neil@daikokuya.demon.co.uk
Tue Feb 6 00:00:00 GMT 2001


Per Bothner wrote:-

> I mention this on the general gcc list because the same idea could also
> be useful for compiling (say) large C++ projects.  Instead of compiling
> A.cc, C.cc, amd C.cc separately, each of which includes large header files
> A.h, B.h, C.h, and X.y, you would compile them also at once:
>         g++ -c -o abc.o A.cc B.cc C.cc
> We could could require "well-behaved" header files for this is, so
> compiling A.cc, B.cc, and C.cc would be treated as essentially the same
> as abc.cc:
>         #include "A.cc"
>         #include "B.cc"
>         #include "C.cc"
> 
> except that some care might be needed to deal with static symbols (and
> namespaces).

I imagine most of this benefit, possibly with less restrictions, could
come from Geoff's precompiled header work (though he's never explained
the details of how they're going to work).

> But doing this should substantially speed up compilations.
> It also creates much small executables, since there would only be a
> *single* copy in abc.o) of the declarations in the header files.

It would provide reasonable performance gains to have the driver
invoked just once like this, and (say) cc1 invoked just once, too,
and to have the single instance compile all the files.

This would be easy to implement for the cpplib part of cc1, but I
imagine being able to reset the state of the compiler proper would be
much harder to guarantee, given all the static variables and other
stuff it uses, and maybe not worth it.

Neil.


More information about the Java mailing list