On Thu, Aug 08, 2002, Muli Ben-Yehuda wrote about "Re: gcc question": > On Thu, Aug 08, 2002 at 06:31:11PM +0300, Orr Dunkelman wrote: >... > > My question is, can I compile in the same command line some files under > > -O1 and some under -O3? > > If they're going to be linked together, that's a very bad > idea. Otherwise, you could probably do it with some Makefile hackery.
It should be perfectly acceptable to link together code where parts of it were compiled with different optimization parameters. In fact, you probably do it all the time when you use libraries - you have no idea which optimization option was used to compile a library (e.g., glibc) and you use the same library regardless of which optimization options you choose for some of your other code. But if you're going to compile some of the code with -O1 and -O3, your Makefile or configure script are going to look realy hairy :( It will look like black magic. A better (but more time consuming) thing to do is to try to find the offending piece of code (which compiles wrong) and send a bug report to gcc and/or try to circumvent the bug. [By the way, one option where it is NOT safe to compile different objects with and without it is the -p (profiling) parameter. But when it comes to -g and -O - it's perfectly safe] I once had a piece of code that used the monstrosity (*(*pc++))(), which was not compiled correctly on IBM AIX 2.3's C compiler. So I put in the code something like: #ifndef COMPILER_BUG_INCR (*(*pc++))(); #else ++pc; (*(pc[-1]))(); #endif where I made the "configure" script automatically test for the existence of this bug for me and set COMPILER_BUG_INCR when necessary. Obviously, I could have left only the split-up code, but I don't like to cave in to buggy compilers ;) -- Nadav Har'El | Friday, Aug 9 2002, 1 Elul 5762 [EMAIL PROTECTED] |----------------------------------------- Phone: +972-53-245868, ICQ 13349191 |Wear short sleeves! Support your right to http://nadav.harel.org.il |bare arms! ================================================================= To unsubscribe, send mail to [EMAIL PROTECTED] with the word "unsubscribe" in the message body, e.g., run the command echo unsubscribe | mail [EMAIL PROTECTED]