On 2013-08-07 10:28:43 +0530, vijay nag wrote: > On Wed, Aug 7, 2013 at 7:49 AM, Hei Chan <structurechart@xxxxxxxxx> wrote: > > Is it possible to figure whether -O3 is enabled in a static > > library and an executable? I am using GCC 4.6.x. [...] > If you just have the binary without the source, I guess it is > impossible to figure out optimization level. Some libraries may provide a function with such information. It was considered for MPFR, and it now has several mpfr_buildopt_* functions giving information on some build options, but not yet for things like CC and CFLAGS. > In future, if you would like to know the CFLAGS with which it was > built, you can export those information to a header as #define's and > be included in one of compilation units. It depends at which step such information would be used. A #define in the library's header isn't the best solution as it could become obsolete if the library is modified while the executable hasn't been fully recompiled (such problems can occur even with a static library if the new one is just relinked, e.g. after a rebuild with different compile options). Such information should be provided by a function. -- Vincent Lefèvre <vincent@xxxxxxxxxx> - Web: <http://www.vinc17.net/> 100% accessible validated (X)HTML - Blog: <http://www.vinc17.net/blog/> Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)