How do I prevent a function from being optimized out?
site_archiver@lists.apple.com Delivered-To: darwin-dev@lists.apple.com 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 (Darwin-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-dev/site_archiver%40lists.appl... This email sent to site_archiver@lists.apple.com
participants (1)
-
Andrew Gallatin