options for later passes

Andi Hellmund mail@andihellmund.com
Mon Feb 21 23:37:00 GMT 2011


Hey Kevin,

> Is there an easy way to figure out which options need to be passed to
> later compilation passes?

Well, I think it's quite easy: it depends on what you want to build, how 
you want to build it and which library it requires. For example, 
gcc/linker can't know that function xyz() belongs to libabc.

> What should be used for assembly:
>
> gcc -c ??? gcc1test.s

I doubt that you really need to assemble a file directly, but it also 
depends on your needs. I would say that default options (though no 
specific options) could be sufficient.

> I am pretty sure the link will need the -fpic.

-fpic _should_ be used when building a shared library.

> Probably also something like -pthread?

Only, if you are building a multi-threaded application. If not, you 
don't need to specify -lpthread.

 > So as a general rule should it see the cpu (or arch) option?

Sorry, but this also depends. If you for example build an application to 
be used by a Linux distro which might run on a various number of CPUs, 
you would possible use the "generic" option, but if you are building a 
high-performance application, you would specifically tune your 
application for the target processor.

> Does anyone else need the -O2?

No, only the compiler (cc1, cc1plus, ...)

> P.S.:  Do the order of the optimization options matter: '-O2 -mcpu=750
> -mmultiple' the same as '-mmultiple -mcpu=750 -O2'?

No, it shouldn't. GCC firstly reads in the parameter and then does a 
post-processing on the options where necessary.

Best regards,
Andi



More information about the Gcc-help mailing list