Bug 4725

Summary: Linking of funit-scopes.c fails with --coverage -O0 is specified
Product: frysk Reporter: Kris Van Hees <kris.van.hees>
Component: generalAssignee: Kris Van Hees <kris.van.hees>
Severity: normal    
Priority: P2    
Version: unspecified   
Target Milestone: ---   
Host: Target:
Build: Last reconfirmed:
Bug Depends on:    
Bug Blocks: 1839    

Description Kris Van Hees 2007-07-02 21:08:00 UTC
When building frysk without --enable-coverage (compilation and link options
include -g -O), funit-scopes.c compiles and links correctly.

When building frysk with --enable-coverage (compilation and link options include
-g --coverage --O0), funit-scopes.c compiles correctly, but fails to link with
the following error:

-I/home/aedil/build_farm/frysk_gcov/frysk_config/frysk-core -I. -fPIC
-fasynchronous-unwind-tables  -g  --coverage -O0 -Wall -Werror   -o
frysk/pkglibdir/funit-scopes  frysk/pkglibdir/funit-scopes.o  
frysk/pkglibdir/funit-scopes.o: In function `first':
undefined reference to `second'
collect2: ld returned 1 exit status
make[2]: *** [frysk/pkglibdir/funit-scopes] Error 1

This is happening on FC6, both on i386 and x86_64.
Gcc version is gcc version 4.1.1 20070105 (Red Hat 4.1.1-51).

The only change between a previous successful build of frysk and the current
failures (as far as this file is concerned) is the actual content of the source
code file (same GCC versions etc).

Investigating this problem a bit further, but it seems to be a bug in gcc.
Comment 1 Kris Van Hees 2007-07-03 18:03:53 UTC
Working on a workaround for the time being...
Comment 2 Kris Van Hees 2007-07-03 18:10:43 UTC
2007-07-03  Kris Van Hees  <kris.van.hees@oracle.com>

        * funit-scopes.c: Removed 'extern' declaration on second() to work
        around a GCC bug that surfaces when compiling/linking with -O0.
Comment 3 Andrew Cagney 2007-07-03 18:32:17 UTC
Is there an upstream bug number; and a test in frysk-imports/tests/frysk4725/?
Comment 4 Kris Van Hees 2007-07-03 18:36:31 UTC
The GCC bug report was in the process of being filed...

GCC bug report is: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32615
Comment 5 Kris Van Hees 2007-07-03 18:42:19 UTC
There is no test case and there is also no need to add one because it is not
actually a bug in GCC but rather a misinterpretation of 'extern inline' by the
original author of the funit-scopes.c class, as explained by Andrew Pinski:

extern inline is not what you think it is.  The "extern inline" GNU C90
implementes (except for 4.3 with -std=c99/-std=gnu99 which is the standard C99
extern inline) means the function is extern but don't create a definition if
the function was not inlined.  This is different from C99's extern inline.