views:

1656

answers:

5

The GCC 4.1.2 documentation has this to say about the -pipe option:

-pipe

Use pipes rather than temporary files for communication between the various stages of compilation. This fails to work on some systems where the assembler is unable to read from a pipe; but the GNU assembler has no trouble.

I assume I'd be able to tell from error message if my systems' assemblers didn't support pipes, so besides that issue, when does it matter whether I use that option? What factors should go into deciding to use it?

+6  A: 

It doesn't usually make any difference

I suppose in the old days, running both a compiler and an assembler at the same time might have started paging and may have bogged down or made interactive performance terrible.

These days, I imagine gcc looks like a fairly small application, never mind the assembler, and we certainly have lots of RAM, so it's harmless and may run a bit faster.

But by the same token the CPU is so fast that it can create that temporary file and read it back without you even noticing...

Now, there are some large projects out there. You can check out a single tree that will build all of Firefox, or NetBSD, or something like that, something that is really big. Something that includes all of X, say, as a minor subsystem component. You may or may not notice a difference when the job involves millions of lines of code in thousands and thousands of C files. As I'm sure you know, people normally work on only a small part of something like this at one time. But if you are a release engineer or working on a build server, or changing something in stdio.h, you may well want to build the whole system to see if you broke anything. And now, every drop of performance probably counts...

DigitalRoss
+2  A: 

Honestly there is very little reason to not use it. -pipe will only use a tad more ram, which if this box is building code, I'd assume has a decent amount. It can significantly improve build time if your system is using a more conservative filesystem that writes and then deletes all the temporary files along the way (ext3, for example.)

Jeff Mc
A: 

From a hardware point of view I guess you would use -pipe to preserve the lifetime of your hard drive.

Troubadour
I strongly believe Linux doesn't actually SAVE the file to the hard-drive, but just puts it in cache in RAM.
LiraNuna
+1  A: 

In our experience with a medium-sized project, adding -pipe made no discernible difference in build times. We ran into a couple of problems with it (sometimes failing to delete intermediate files if an error was encountered, IIRC), and so since it wasn't gaining us anything, we quit using it rather than trying to troubleshoot those problems.

Josh Kelley
A: 

Trying this out now, it looks to be moderately faster to build when the source / build destinations are on NFS (linux network). Memory usage is high though. If you never fill the RAM and have source on NFS, seems like a win with -pipe.

peter karasev