This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Controlling the compile within the compiled file?
- From: "Ciaran O'Riordan" <ciaran_o_riordan at hotmail dot com>
- To: dwilliss at microimages dot com
- Cc: gcc-help at gnu dot org
- Date: Fri, 27 Sep 2002 16:16:32 +0000
- Subject: Re: Controlling the compile within the compiled file?
- Bcc:
Shuki says:
> >Can one instruct the gcc compiler to turn option on/off
> >within the compiled code?
[snip: me saying No.]
Dave says:
I don't think that's what Shuki meant by turning optimization
on and off. He doesn't want to reverse an optimization, just
disable it.
You think he wants to disable the option at compile time? Not
within the compiled code. okay. As far as I know the answer
to that question is also no. (solution/suggestion at end...)
Some compilers let you use #pragma directives to disable optimizations
[...]
Gcc is almost totally devoid of #pragmas, at least in 2.95. I
don't know about the current version. I would definitely like to
see some though.
The GCC committee considered #pragmas to be a broken at one time.
#pragmas have now been fixed (they can be contructed in macros and
have a namespace). GCC has gotten used to not having #pragmas and
there are no plans to implement them for any widely used
functionality. You may be looking for "function attributes", these
are generally the GCC replacement for #pragrmas, unfortunatly there
is no ((dont_optimise)) attribute.
A small few platform specifc #pragmas exist, purely for
compatibility with the native compiler for that platform.
I'd like to reiterate my original solution of hand picking the
optimisations you use rather than using the catch all -O1, -O2 or
-O3. When you use 'gcc -O2', GCC enables about 35 optimisations
(all of which are listed and explained at:
http://gcc.gnu.org/onlinedocs/gcc-3.2/gcc/Optimize-Options.html#Optimize%20Options)
By doing a binary search, you should be able to figure out which
optimisation is causing the problem. Use half of the optimisations.
If the program doesn't crash you can mark them as safe. Add half of
the remaining optimisations and so on until you find the problem
causer.
If this brute force method is impractically tedious you could just
pick 5 or 10 optimisations that you think look good and test them
out. Many of the optimisations have only slight effects.
Did any of this help?
_________________________________________________________________
MSN Photos is the easiest way to share and print your photos:
http://photos.msn.com/support/worldwide.aspx