This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

How to handle c99 inline changes? [was RE: -fkeep-inline-functions and broken Cygwin bootstrap (was: Building GCC 4.3.0 on Cygwin...)]

On 25 March 2007 07:37, Andrew Pinski wrote:

> On 3/24/07, Brian Dessent wrote:
>> Dave Korn wrote:
>>> # 405 "/usr/include/stdio.h" 3 4
>> [ Which is from newlib (libc/include/stdio.h) if anyone reading this
>> doesn't have a Cygwin system handy. ]
>>> static __inline__ int __sgetc_r(struct _reent *__ptr, FILE *__p)   {
>>> [...]
>>>   The critical difference is the presence or absence of
>>> -fkeep-inline-functions.  I think I remember there being some change
>>> between gcc-3.x and gcc-4.x in inline handling and I think that's what's
>>> biting us now; I think this may only arise in stage1 where we're trying
>>> to use 3.x to compile 4.x.
>> I too thought that this was related to the c99 inline changes, but I
>> think those only apply to "extern inline" which is not the case here.
>> The real cause seems to be that -fkeep-inline-functions was a no-op up
>> until: <>, which
>> seems to roughly correspond to when bootstrap stopped working on Cygwin.
> Actually it was not a no-op in 3.4, just 4.2 (or was it also broken in
> 4.1) broke -fkeep-inline-functions and nobody noticed until later.
> Cygwin's headers are broken with respect of -fkeep-inline-functions
> and need to be fixed.

  Ok, I can understand this; we compile with -fkeep-inline-functions in order to behave the same as other compilers, so that we spot when bootstrapping with a non-gcc compiler might be broken.[*]  That's because non-gcc compilers can't be relied on to eliminate static inline functions the way gcc does.  So far so good.

  The problem is what to replace the function with.  Converting it to 'extern inline' solves the bootstrap problem vs. -fkeep-inline-functions, because the statically-linked function body is never omitted.

  Unfortunately, 'extern inline' is changing behaviour[**] and is about to start meaning the exact opposite.  Once this happens, cygwin bootstrap will break again.

  So, am I correct to believe that we need to use plain 'inline' for c99 after gcc 4.4, and 'extern inline' before that?  That is, I think I need to write a test that looks like...

#if ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4))) \
    && defined (__STRICT_ANSI__) && (__STRICT_ANSI__ != 0) \
    && defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
#define ELIDABLE_INLINE inline
#define ELIDABLE_INLINE extern inline

  I'm not quite sure if I've got that right, though.  I don't know if I need to test __STRICT_ANSI__ or not.  I'm not sure if I should be testing for gnu99 mode as well as std99 or not.  I want to match the exact conditions that are going to be tested to invoke the new standard behaviour; is this going to do it?


[*]  -
[**] -
Can't think of a witty .sigline today....

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]