-fwhole-program and __attribute__((externally_visible))
Ian Lance Taylor
iant@google.com
Thu Dec 3 05:31:00 GMT 2009
Joel Dice <dicej@mailsnare.net> writes:
> I've been playing with -flto and -fwhole-program using an SVN snapshot
> of GCC and I have a couple of questions.
>
> I'm using __attribute__((externally_visible)) to mark the entry points
> in my executable (which is also a shared object). However, said
> attribute is not available with all versions of GCC. What's the best
> way to determine whether it's available or not?
It's always available when -flto is available.
If you want your code to compile with older versions of gcc which
don't support -flto, then the best approach is probably something like
#if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 5)
> Also, I'm curious as to why above attribute is necessary at all. All
> my code is built with -fvisibility=hidden, and the exported functions
> are marked with either __declspec(dllexport) or
> __attribute__((visibility("default"))), depending on the platform. It
> seems redundant to specify an additional attribute that means
> essentially the same thing.
I don't think anybody has really thought through how to best use -flto
-fwhole-program with a shared library. Most likely a different option
should be used, similar to -fwhole-program except meaning that all
hidden functions may be considered static.
Ian
More information about the Gcc-help
mailing list