Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When should I use GCC's -pipe option?

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?

like image 209
Rob Kennedy Avatar asked Oct 03 '09 05:10

Rob Kennedy


People also ask

Which GCC option should be used to do only compilation?

Produce only the compiled code using the -C option To produce only the compiled code (without any linking), use the -C option. The command above would produce a file main.o that would contain machine level code or the compiled code.

What is the purpose of the option of the GCC command?

When you invoke GCC, it normally does preprocessing, compilation, assembly and linking. The "overall options" allow you to stop this process at an intermediate stage. For example, the -c option says not to run the linker.

What is option G ++?

The g++ Compiler Without this option, g++ creates an executable file. With this option, it creates an object file. If no output file name is given (by option -o), the object file name for file prog.

Does the order of compiler flags matter?

For the most part, the order you use doesn't matter. Order does matter when you use several options of the same kind; for example, if you specify -L more than once, the directories are searched in the order specified.


2 Answers

It doesn't usually make any difference

It has + and - considerations. Historically, running the compiler and assembler simultaneously would stress RAM resources.

Gcc is small by today's standards and -pipe adds a bit of multi-core accessible parallel execution.

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. And since -pipe was never the default mode, it occasionally acts up a little. A single developer will generally report not noticing the time difference.

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...

like image 53
DigitalRoss Avatar answered Sep 20 '22 15:09

DigitalRoss


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.

like image 25
Josh Kelley Avatar answered Sep 20 '22 15:09

Josh Kelley