Endless "declared 'static' but never defined" warnings with stage 2 & 3 compilers

2012-06-11 Thread t-rexky
0: warning: '__builtin_asinh' declared 'static' but never defined
/NextDeveloper/Headers/ansi/math.h:23: warning: 'asinh' declared 'static' but 
never defined
^C (I aborted here since xgcc spits out an endless list of similar warnings, 
but the resultant executable works)

Similar warnings occur on every source file for built-in function declarations 
and functions declared in the included header files.   I am completely 
perplexed that the stage1 compiler is working fine with no warning, yet stage2 
and stage3 generate the warnings.  The target configuration for all three 
stages is obviously identical and the build options are almost identical.  And 
all three stages generate executables that appear to work just fine.  I am 
obviously missing something in the target configuration but after reviewing the 
GCC Internals document I could not find anything obvious.

I am struggling to identify the root cause of this issue and would very much 
appreciate any assistance, or even pointers on where to start looking.  
Tinkering with software is only a hobby for me and my knowledge runs out pretty 
rapidly...

t-rexky


Re: Endless "declared 'static' but never defined" warnings with stage 2 & 3 compilers

2012-06-17 Thread t-rexky
Thank you for your response!

On 2012-06-12, at 8:03 AM, Vincent Rivière wrote:

> On 11/06/2012 21:20, t-rexky wrote:
>>> #include
>>> #include
>>> 
>>> int main() {
>>>  printf("%lf\n", acos(0.5));
>>>  return 0;
>>> }
> 
> First, note that acos(0.5) is a "double" expression so its format should be 
> %f. However %lf is tolerated and this should not cause any trouble.

Noted & thank you.

> Second, the acos() call will be internally replaced by __builtin_acos() which 
> may be directly replaced by its result, if it can be computed at compile time 
> (which is the case in your example).
> Try to add -fno-builtin on the command line to see if the same odd things 
> happen.

The order of the warnings is changed with the -fno-builtin flag, but nothing 
else.  Without -fno-builtin I get:

:0: warning: '__builtin_acos' used but never defined
/NextDeveloper/Headers/ansi/math.h:55: warning: 'acos' used but never defined
:0: warning: '__builtin_printf' used but never defined
/NextDeveloper/Headers/ansi/stdio.h:123: warning: 'printf' used but never 
defined

And with -fno-builtin I get:

:0: warning: '__builtin_acos' used but never defined
:0: warning: '__builtin_printf' used but never defined
/NextDeveloper/Headers/ansi/math.h:55: warning: 'acos' used but never defined
/NextDeveloper/Headers/ansi/stdio.h:123: warning: 'printf' used but never 
defined


>> nextstep[Tests]$xgcc acos_test.c -o acos_test
>> :0: warning: '__builtin_acos' used but never defined
>> /NextDeveloper/Headers/ansi/math.h:55: warning: 'acos' used but never defined
> 
> The problem may be in your math.h. This header is not provided by GCC, but by 
> your math library. You should have a look to the indicated line to see what 
> is there.
> 
> Also, looking at the preprocessor output may help.
> Try this:
>  xgcc -E acos_test.c
> Then search for acos to see if there is nothing wierd.

I Inspected the headers and I do not see any "smoking guns" in there.  The line 
in question in math.h and the stage1 and stage2
preprocessor output all read the same:

math.h:  extern double __const__ acos(double x);
stage1:  extern double __const__ acos(double x); 
stage3:  extern double __const__ acos(double x);

I have been thinking about this a bit more and came to a conclusion that this 
has to be related to the way my target configuration
files generate code.  Stage 1 works just fine, but of course it is compiled 
with my existing compiler.  On the other hand both stages
compiled with my target configuration are misbehaving in this same way.  To 
completely bypass the headers I tried compiling
the following code:

extern int foo(); 
int main () { return foo(); }

And I still get this with stage 2 and stage 3 compilers:

foo.c:1: warning: 'foo' used but never defined

I get the exact same warning from my existing gcc if I declare foo() as static 
int, as opposed to extern int.  It almost seems to me
that my stage 2 and stage 3 compilers force all undefined functions to be 
static?

When I have a moment I will check my target configuration once again and if 
this does not help I will spend some time with
a debugger to see if I can figure out where things go wrong.  I'm afraid though 
that I will get completely lost in the complexity
of gcc.

> Good luck.
> 
> -- 
> Vincent Rivière

Thank you,
t-rexky


Re: Endless "declared 'static' but never defined" warnings with stage 2 & 3 compilers

2012-07-01 Thread t-rexky

On 2012-06-17, at 11:54 PM, t-rexky wrote:

> When I have a moment I will check my target configuration once again and if 
> this does not help I will spend some time with
> a debugger to see if I can figure out where things go wrong.  I'm afraid 
> though that I will get completely lost in the complexity
> of gcc.

Unfortunately I am not able to use gdb-4.7 in a sensible way since it is having 
trouble with most of the data types that I need to
inspect.  However, I spent quite a bit more time with the compiler and I was 
able to make a small step in the right direction.

I discovered that if I rebuild stage 3 with BOOT_CFLAGS="-g -O0", the warnings 
in stage 3 compiler all disappear!  This is despite
that fact that the stage 2 compiler was built with -O2 and continues to 
generate the warnings.

I then tried to isolate which specific -O1 optimization flag was responsible 
for the issue.  Unfortunately many recompiles later
I determined that the issue arises from gcc -O1 optimization code that is not 
controlled by any of the flags that -O1 switches on.
Recompiling stage 3 with all the optimization flags equivalent to -O1 produces 
stage 3 compiler that does not generate any
of the warnings.

So I am baffled and stuck yet again...

>> Good luck.
>> 
>> -- 
>> Vincent Rivière
> 
> Thank you,
> t-rexky



Re: Endless "declared 'static' but never defined" warnings with stage 2 & 3 compilers

2012-07-08 Thread t-rexky
On 2012-07-01, at 12:53 PM, Vincent Rivière wrote:

> On 01/07/2012 16:16, t-rexky wrote:
>> I discovered that if I rebuild stage 3 with BOOT_CFLAGS="-g -O0", the
>> warnings in stage 3 compiler all disappear!
> 
> This is extremely wierd!
> 
> So it looks like something is affected by the optimization level. Usually, it 
> is an uninitialized variable, buffer overflow, strict aliasing issue, or 
> maybe a GCC bug...
> 
> Since it is unlikely that this specific bug is in the standard GCC sources 
> (other people would have noticed), maybe it could be somewhere in the C 
> sources added for your NeXT configuration?

I am also certain that this is somehow related to my configuration so I 
reviewed my target config files once again but there
was nothing obvious staring back at me.

At one point I thought that there was an issue with the 
TARGET_ASM_SELECT_SECTION function that I pulled in from gcc-3.2.3,
so I completely rewrote it using the Darwin version from gcc-4.2.4 
(conveniently Darwin is almost identical to NEXTSTEP minus some new features 
like weak support, coalesced sections, etc).  I spent the last week fiddling 
with this due to the length of the
bootstrap process on the 68040, but unfortunately to no avail...

I might have no choice but to get a newer gdb version going if I do not find 
anything else...

t-rexky