public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Endless "declared 'static' but never defined" warnings with stage 2 & 3 compilers
@ 2012-06-11 19:20 t-rexky
  2012-06-12 12:03 ` Vincent Rivière
  0 siblings, 1 reply; 6+ messages in thread
From: t-rexky @ 2012-06-11 19:20 UTC (permalink / raw)
  To: gcc

Hello,

(please note that this is a modified repost from the gcc-help list - I was told that the gcc list is a better place for my questions)

I have been trying to port a reasonably recent version of gcc to a m68k NeXT running NEXTSTEP 3.3.  After many struggles and lots of help from the m68k debian ports team I was finally able to complete the bootstrap process on gcc-4.2.4.  The stage 2 and stage 3 compiler appear to be working reasonably well and producing good code, but they generate an endless list of warnings that do not occur with the stage 1 compiler.  Here is some sample code and the warnings with various gcc options:

> #include <math.h>
> #include <stdio.h>
> 
> int main() {
>  printf("%lf\n", acos(0.5));
>  return 0;
> }

nextstep[Tests]$xgcc acos_test.c -o acos_test
<built-in>:0: warning: '__builtin_acos' used but never defined
/NextDeveloper/Headers/ansi/math.h:55: warning: 'acos' used but never defined
<built-in>:0: warning: '__builtin_printf' 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 -O 

> #include <math.h>
> #include <stdio.h>
> 
> int main() {
>  printf("%lf\n",  __builtin_acos(0.5));
>  return 0;
> }

nextstep[Tests]$xgcc builtin_acos_test.c -o builtin_acos_test
<built-in>:0: warning: '__builtin_acos' used but never defined
/NextDeveloper/Headers/ansi/math.h:55: warning: 'acos' used but never defined
<built-in>:0: warning: '__builtin_printf' used but never defined
/NextDeveloper/Headers/ansi/stdio.h:123: warning: 'printf' used but never defined

nextstep[Tests]$xgcc builtin_acos_test.c -o builtin_acos_test -O   

nextstep[Tests]$xgcc builtin_acos_test.c -o builtin_acos_test -Wall
<built-in>:0: warning: '__builtin_acos' used but never defined
/NextDeveloper/Headers/ansi/math.h:55: warning: 'acos' used but never defined
<built-in>:0: warning: '__builtin_acosf' declared 'static' but never defined
<built-in>:0: warning: 'acosf' declared 'static' but never defined
<built-in>:0: warning: '__builtin_acosh' declared 'static' but never defined
/NextDeveloper/Headers/ansi/math.h:24: warning: 'acosh' declared 'static' but never defined
<built-in>:0: warning: '__builtin_acoshf' declared 'static' but never defined
<built-in>:0: warning: 'acoshf' declared 'static' but never defined
<built-in>:0: warning: '__builtin_acoshl' declared 'static' but never defined
<built-in>:0: warning: 'acoshl' declared 'static' but never defined
<built-in>:0: warning: '__builtin_acosl' declared 'static' but never defined
<built-in>:0: warning: 'acosl' declared 'static' but never defined
<built-in>:0: warning: '__builtin_asin' declared 'static' but never defined
/NextDeveloper/Headers/ansi/math.h:56: warning: 'asin' declared 'static' but never defined
<built-in>:0: warning: '__builtin_asinf' declared 'static' but never defined
<built-in>:0: warning: 'asinf' declared 'static' but never defined
<built-in>: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)

nextstep[Tests]$xgcc builtin_acos_test.c -o builtin_acos_test -O -Wall
<built-in>:0: warning: '__builtin_acos' declared 'static' but never defined
/NextDeveloper/Headers/ansi/math.h:55: warning: 'acos' declared 'static' but never defined
<built-in>:0: warning: '__builtin_acosf' declared 'static' but never defined
<built-in>:0: warning: 'acosf' declared 'static' but never defined
<built-in>:0: warning: '__builtin_acosh' declared 'static' but never defined
/NextDeveloper/Headers/ansi/math.h:24: warning: 'acosh' declared 'static' but never defined
<built-in>:0: warning: '__builtin_acoshf' declared 'static' but never defined
<built-in>:0: warning: 'acoshf' declared 'static' but never defined
<built-in>:0: warning: '__builtin_acoshl' declared 'static' but never defined
<built-in>:0: warning: 'acoshl' declared 'static' but never defined
<built-in>:0: warning: '__builtin_acosl' declared 'static' but never defined
<built-in>:0: warning: 'acosl' declared 'static' but never defined
<built-in>:0: warning: '__builtin_asin' declared 'static' but never defined
/NextDeveloper/Headers/ansi/math.h:56: warning: 'asin' declared 'static' but never defined
<built-in>:0: warning: '__builtin_asinf' declared 'static' but never defined
<built-in>:0: warning: 'asinf' declared 'static' but never defined
<built-in>: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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Endless "declared 'static' but never defined" warnings with stage 2 & 3 compilers
  2012-06-11 19:20 Endless "declared 'static' but never defined" warnings with stage 2 & 3 compilers t-rexky
@ 2012-06-12 12:03 ` Vincent Rivière
  2012-06-18  3:54   ` t-rexky
  0 siblings, 1 reply; 6+ messages in thread
From: Vincent Rivière @ 2012-06-12 12:03 UTC (permalink / raw)
  To: gcc

On 11/06/2012 21:20, t-rexky wrote:
>> #include<math.h>
>> #include<stdio.h>
>>
>> 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.

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.

> nextstep[Tests]$xgcc acos_test.c -o acos_test
> <built-in>: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.

Good luck.

-- 
Vincent Rivière

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Endless "declared 'static' but never defined" warnings with stage 2 & 3 compilers
  2012-06-12 12:03 ` Vincent Rivière
@ 2012-06-18  3:54   ` t-rexky
  2012-07-01 14:17     ` t-rexky
  0 siblings, 1 reply; 6+ messages in thread
From: t-rexky @ 2012-06-18  3:54 UTC (permalink / raw)
  To: gcc

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<math.h>
>>> #include<stdio.h>
>>> 
>>> 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:

<built-in>:0: warning: '__builtin_acos' used but never defined
/NextDeveloper/Headers/ansi/math.h:55: warning: 'acos' used but never defined
<built-in>: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:

<built-in>:0: warning: '__builtin_acos' used but never defined
<built-in>: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
>> <built-in>: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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Endless "declared 'static' but never defined" warnings with stage 2 & 3 compilers
  2012-06-18  3:54   ` t-rexky
@ 2012-07-01 14:17     ` t-rexky
  2012-07-01 16:53       ` Vincent Rivière
  0 siblings, 1 reply; 6+ messages in thread
From: t-rexky @ 2012-07-01 14:17 UTC (permalink / raw)
  To: gcc; +Cc: Vincent Rivière


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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Endless "declared 'static' but never defined" warnings with stage 2 & 3 compilers
  2012-07-01 14:17     ` t-rexky
@ 2012-07-01 16:53       ` Vincent Rivière
  2012-07-08 12:32         ` t-rexky
  0 siblings, 1 reply; 6+ messages in thread
From: Vincent Rivière @ 2012-07-01 16:53 UTC (permalink / raw)
  To: gcc

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?

-- 
Vincent Rivière

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Endless "declared 'static' but never defined" warnings with stage 2 & 3 compilers
  2012-07-01 16:53       ` Vincent Rivière
@ 2012-07-08 12:32         ` t-rexky
  0 siblings, 0 replies; 6+ messages in thread
From: t-rexky @ 2012-07-08 12:32 UTC (permalink / raw)
  To: Vincent Rivière; +Cc: gcc

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2012-07-08 12:32 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-11 19:20 Endless "declared 'static' but never defined" warnings with stage 2 & 3 compilers t-rexky
2012-06-12 12:03 ` Vincent Rivière
2012-06-18  3:54   ` t-rexky
2012-07-01 14:17     ` t-rexky
2012-07-01 16:53       ` Vincent Rivière
2012-07-08 12:32         ` t-rexky

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).