How do I prevent a function from being optimized out?
How do I prevent a function from being optimized out?
- Subject: How do I prevent a function from being optimized out?
- From: Andrew Gallatin <email@hidden>
- Date: Wed, 13 Apr 2005 17:24:01 -0400 (EDT)
Hi,
I'm hoping this is the right list for this question... I'm more
of a driver guy.
Is there a supported way to prevent ld from optimizing out an empty
function from a library? Eg:
foo_hack(void)
{
return;
}
The best we've been able to do is to make foo_hack() actually do
something:
extern int dummy_variable;
foo_hack(void)
{
/* do some work to avoid being optimized away */
dummy_variable++;
}
And then call it in another module:
int dummy_variable;
some_other_function(..)
{
<...>
/* call a function in our malloc routine so ld doesn't
optimize it away */
foo_hack();
<...>
}
This works on most supported toolchains on MacOSX, but we recently ran
into one being used by http://g95.org
(ftp://gcc.gnu.org/pub/gcc/infrastructure/cctools-528.5.dmg) where
this doesn't work.
Is there another, better, way?
Thanks,
Drew
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden