This is the mail archive of the gcc@gcc.gnu.org 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]

mkheaders in GCC 4.3.2 seems to break studio.h ?


Chances are that I botched up something .. not sure what exactly.
Nothing fancy here .. just a bootstrapped GCC 4.3.2

I ran mkheaders and I think that managed to really botch up studio.h

/************* first, some sample code ***************/

$ cat hello.c
#include <stdio.h>
int main(int argc, char *argv[]){
    int some_int;
    some_int = 1;
    printf( "Hello World, have an integer. This one = %i\n", some_int );
    return (0);
}

/************* compile with vendor compiler tools ************/

On Solaris 8 Sparc I can use Sun Studio 8 thus :

$ /opt/SUNWspro/bin/cc -V
cc: Sun C 5.5 Patch 112760-19 2007/08/02
usage: cc [ options] files.  Use 'cc -flags' for details

I'm using the local Sun provided assembler and linker :

$ which as
/usr/ccs/bin/as
$ which ld
/usr/ccs/bin/ld

$ /opt/SUNWspro/bin/cc -o hello.s -S -c hello.c

$ cat hello.s

        .section        ".text",#alloc,#execinstr
        .align  8
        .skip   16

        ! block 0

        .global main
        .type   main,#function
main:
        save    %sp,-104,%sp

        ! block 1
.L90:
        st      %i0,[%fp+68]
        st      %i1,[%fp+72]

! File hello.c:
!    1  #include <stdio.h>
!    2  int main(int argc, char *argv[]){
!    3      int some_int;
!    4      some_int = 1;

        mov     1,%o1
        st      %o1,[%fp-8]

!    5      printf( "Hello World, have an integer. This one = %i\n",
some_int );

        sethi   %hi(.L92),%o0
        or      %o0,%lo(.L92),%o0
        call    printf
        nop

!    6      return (0);

        st      %g0,[%fp-4]
        mov     %g0,%i0
        jmp     %i7+8
        restore

        ! block 2
.L89:
        mov     %g0,%i0
        jmp     %i7+8
        restore
        .size   main,(.-main)
        .align  8

        .section        ".rodata1",#alloc
        .align  4
.L92:
        .ascii  "Hello World, have an integer. This one = %i\n\000"
        .type   .L92,#object
        .size   .L92,45

        .section        ".bss",#alloc,#write
Bbss.bss:
        .skip   0
        .type   Bbss.bss,#object
        .size   Bbss.bss,0

        .section        ".data",#alloc,#write
Ddata.data:
        .skip   0
        .type   Ddata.data,#object
        .size   Ddata.data,0

        .section        ".rodata",#alloc
Drodata.rodata:
        .skip   0
        .type   Drodata.rodata,#object
        .size   Drodata.rodata,0

        .file   "hello.c"
        .xstabs ".stab.index","V=10.0;DBG_GEN=4.14.14;cd;backend;Xa;R=Sun
C 5.5 Patch 112760-19 2007/08/02",60,0,0,0
        .xstabs ".stab.index","/export/home/dclarke/pgm/mpfr;
/opt/SUNWspro/prod/bin/cc -S -c  hello.c",52,0,0,0
        .xstabs ".stab.index","main",42,0,0,0
        .ident  "@(#)stdio.h    1.78    99/12/08 SMI"
        .ident  "@(#)stdio_iso.h        1.2     99/10/25 SMI"
        .ident  "@(#)feature_tests.h    1.18    99/07/26 SMI"
        .ident  "@(#)isa_defs.h 1.20    99/05/04 SMI"
        .ident  "@(#)va_list.h  1.12    99/05/04 SMI"
        .ident  "@(#)stdio_tag.h        1.3     98/04/20 SMI"
        .ident  "@(#)stdio_impl.h       1.8     99/06/10 SMI"
        .ident  "acomp: Sun C 5.5 Patch 112760-19 2007/08/02"

        .global __fsr_init_value
__fsr_init_value = 0x0

We can compile, link and run that :

$ /opt/SUNWspro/bin/cc -o hello hello.s

Here is what we have from Sun Studio 8 :

$ ls -lap hello*
-rwxr-xr-x   1 dclarke  csw         5372 Aug 30 16:57 hello
-rw-r--r--   1 dclarke  csw          180 Aug 30 16:53 hello.c
-rw-r--r--   1 dclarke  csw         1764 Aug 30 16:56 hello.s

$ ./hello
Hello World, have an integer. This one = 1

Nothing fancy ..

/************** GCC 4.3.2 *******************/

Let's try that with GCC 4.3.2 now :

$ which gcc
/opt/csw/gcc4/bin/gcc
$ gcc -v
Using built-in specs.
Target: sparc-sun-solaris2.8
Configured with: ../gcc-4.3.2/configure --prefix=/opt/csw/gcc4
--with-local-prefix=/opt/csw --with-as=/usr/ccs/bin/as --without-gnu-ld
--with-ld=/usr/ccs/bin/ld --with-cpu=v7 --enable-threads=posix
--enable-nls --enable-shared --enable-languages=c,c++,fortran,objc
--with-gmp=/opt/csw --with-mpfr=/opt/csw --enable-multilib
--with-included-gettext --with-libiconv-prefix=/opt/csw --with-x
--enable-java-awt=xlib --with-system-zlib --enable-bootstrap
Thread model: posix
gcc version 4.3.2 (GCC)

$ gcc -v -o hello_gnu.s -c -S hello.c
Using built-in specs.
Target: sparc-sun-solaris2.8
Configured with: ../gcc-4.3.2/configure --prefix=/opt/csw/gcc4
--with-local-prefix=/opt/csw --with-as=/usr/ccs/bin/as --without-gnu-ld
--with-ld=/usr/ccs/bin/ld --with-cpu=v7 --enable-threads=posix
--enable-nls --enable-shared --enable-languages=c,c++,fortran,objc
--with-gmp=/opt/csw --with-mpfr=/opt/csw --enable-multilib
--with-included-gettext --with-libiconv-prefix=/opt/csw --with-x
--enable-java-awt=xlib --with-system-zlib --enable-bootstrap
Thread model: posix
gcc version 4.3.2 (GCC)
COLLECT_GCC_OPTIONS='-v' '-o' 'hello_gnu.s' '-c' '-S' '-mcpu=v7'
 /opt/csw/gcc4/libexec/gcc/sparc-sun-solaris2.8/4.3.2/cc1 -quiet -v
hello.c -quiet -dumpbase hello.c -mcpu=v7 -auxbase-strip hello_gnu.s
-version -o hello_gnu.s
ignoring nonexistent directory
"/opt/csw/gcc4/lib/gcc/sparc-sun-solaris2.8/4.3.2/../../../../sparc-sun-solaris2.8/include"
#include "..." search starts here:
#include <...> search starts here:
 /opt/csw/include
 /opt/csw/gcc4/include
 /opt/csw/gcc4/lib/gcc/sparc-sun-solaris2.8/4.3.2/include
 /opt/csw/gcc4/lib/gcc/sparc-sun-solaris2.8/4.3.2/include-fixed
 /usr/include
End of search list.
GNU C (GCC) version 4.3.2 (sparc-sun-solaris2.8)
        compiled by GNU C version 4.3.2, GMP version 4.2.2, MPFR version
2.3.1.
GGC heuristics: --param ggc-min-expand=47 --param ggc-min-heapsize=32768
Compiler executable checksum: 1ac791ab3c2b7cc8775dc74d45095fef
In file included from hello.c:1:
/opt/csw/gcc4/lib/gcc/sparc-sun-solaris2.8/4.3.2/include-fixed/stdio.h:241:
error: expected declaration specifiers or '...' before '__gnuc_va_list'

So looks like some damage was done by the mkheaders script. Just what
exactly ?

/*********** Look at stdio.h before and after ***********/

$ wc -l /usr/include/stdio.h
     401 /usr/include/stdio.h
$ wc -l
/opt/csw/gcc4/lib/gcc/sparc-sun-solaris2.8/4.3.2/include-fixed/stdio.h
     417
/opt/csw/gcc4/lib/gcc/sparc-sun-solaris2.8/4.3.2/include-fixed/stdio.h

$ diff /usr/include/stdio.h
/opt/csw/gcc4/lib/gcc/sparc-sun-solaris2.8/4.3.2/include-fixed/stdio.h
0a1,14
> /*  DO NOT EDIT THIS FILE.
>
>     It has been auto-edited by fixincludes from:
>
>       "/usr/include/stdio.h"
>
>     This had to be done to correct non-standard usages in the
>     original, manufacturer supplied header file.  */
>
> #ifndef FIXINC_WRAP_STDIO_H_STDIO_STDARG_H
> #define FIXINC_WRAP_STDIO_H_STDIO_STDARG_H 1
>
> #define __need___va_list
> #include <stdarg.h>
114c128
<  * XPG4 requires that va_list be defined in <stdio.h> "as described in
---
>  * XPG4 requires that __gnuc_va_list be defined in <stdio.h> "as
described in
118,120c132,134
< #if defined(_XOPEN_SOURCE) && (_XOPEN_VERSION - 0 >= 4) &&
!defined(_VA_LIST)
< #define       _VA_LIST
< typedef       __va_list va_list;
---
> #if defined(_XOPEN_SOURCE) && (_XOPEN_VERSION - 0 >= 4) &&
!defined(_DUMMY_VA_LIST)
> #define       _DUMMY_VA_LIST
> typedef       __va_list __not_va_list__;
123c137
< #if defined(__EXTENSIONS__) || __STDC__ - 0 == 0 || \
---
> #if defined(__EXTENSIONS__) ||  !defined(__STRICT_ANSI__) || \
130c144
< #if defined(__EXTENSIONS__) || ((__STDC__ - 0 == 0 && \
---
> #if defined(__EXTENSIONS__) || (( !defined(__STRICT_ANSI__) && \
213c227
< #if defined(__EXTENSIONS__) || (__STDC__ == 0 && \
---
> #if defined(__EXTENSIONS__) || ( !defined(__STRICT_ANSI__) && \
218c232
< #if defined(__EXTENSIONS__) || (__STDC__ == 0 && \
---
> #if defined(__EXTENSIONS__) || ( !defined(__STRICT_ANSI__) && \
224c238
< #if defined(__EXTENSIONS__) || (__STDC__ == 0 && \
---
> #if defined(__EXTENSIONS__) || ( !defined(__STRICT_ANSI__) && \
227c241
< extern int    vsnprintf(char *, size_t, const char *, __va_list);
---
> extern int    vsnprintf(char *, size_t, const char *, __gnuc_va_list);
233c247
< #if defined(__EXTENSIONS__) || __STDC__ == 0 || \
---
> #if defined(__EXTENSIONS__) ||  !defined(__STRICT_ANSI__) || \
260c274
< #if defined(__EXTENSIONS__) || __STDC__ == 0 || defined(_XOPEN_SOURCE)
---
> #if defined(__EXTENSIONS__) ||  !defined(__STRICT_ANSI__) ||
defined(_XOPEN_SOURCE)
401a416,417
>
> #endif  /* FIXINC_WRAP_STDIO_H_STDIO_STDARG_H */

So that looks like some changes have been done there by the mkheaders or
fixincludes script.

/*********** put the original vendor stdio.h in place **********/

I backup the one created by mkheaders and then drop in the original from
/usr/include/stdio.h and try again :

First .. backup that new thing :
# cp -p
/opt/csw/gcc4/lib/gcc/sparc-sun-solaris2.8/4.3.2/include-fixed/stdio.h
/opt/csw/gcc4/lib/gcc/sparc-sun-solaris2.8/4.3.2/include-fixed/stdio.h_gnu_broken

Put in the original from Sun :
# cp /usr/include/stdio.h
/opt/csw/gcc4/lib/gcc/sparc-sun-solaris2.8/4.3.2/include-fixed/stdio.h

Now try again :

$ gcc -v -o hello_gnu.s -c -S hello.c
Using built-in specs.
Target: sparc-sun-solaris2.8
Configured with: ../gcc-4.3.2/configure --prefix=/opt/csw/gcc4
--with-local-prefix=/opt/csw --with-as=/usr/ccs/bin/as --without-gnu-ld
--with-ld=/usr/ccs/bin/ld --with-cpu=v7 --enable-threads=posix
--enable-nls --enable-shared --enable-languages=c,c++,fortran,objc
--with-gmp=/opt/csw --with-mpfr=/opt/csw --enable-multilib
--with-included-gettext --with-libiconv-prefix=/opt/csw --with-x
--enable-java-awt=xlib --with-system-zlib --enable-bootstrap
Thread model: posix
gcc version 4.3.2 (GCC)
COLLECT_GCC_OPTIONS='-v' '-o' 'hello_gnu.s' '-c' '-S' '-mcpu=v7'
 /opt/csw/gcc4/libexec/gcc/sparc-sun-solaris2.8/4.3.2/cc1 -quiet -v
hello.c -quiet -dumpbase hello.c -mcpu=v7 -auxbase-strip hello_gnu.s
-version -o hello_gnu.s
ignoring nonexistent directory
"/opt/csw/gcc4/lib/gcc/sparc-sun-solaris2.8/4.3.2/../../../../sparc-sun-solaris2.8/include"
#include "..." search starts here:
#include <...> search starts here:
 /opt/csw/include
 /opt/csw/gcc4/include
 /opt/csw/gcc4/lib/gcc/sparc-sun-solaris2.8/4.3.2/include
 /opt/csw/gcc4/lib/gcc/sparc-sun-solaris2.8/4.3.2/include-fixed
 /usr/include
End of search list.
GNU C (GCC) version 4.3.2 (sparc-sun-solaris2.8)
        compiled by GNU C version 4.3.2, GMP version 4.2.2, MPFR version
2.3.1.
GGC heuristics: --param ggc-min-expand=47 --param ggc-min-heapsize=32768
Compiler executable checksum: 1ac791ab3c2b7cc8775dc74d45095fef
COMPILER_PATH=/opt/csw/gcc4/libexec/gcc/sparc-sun-solaris2.8/4.3.2/:/opt/csw/gcc4/libexec/gcc/sparc-sun-solaris2.8/4.3.2/:/opt/csw/gcc4/libexec/gcc/sparc-sun-solaris2.8/:/opt/csw/gcc4/lib/gcc/sparc-sun-solaris2.8/4.3.2/:/opt/csw/gcc4/lib/gcc/sparc-sun-solaris2.8/:/usr/ccs/bin/
LIBRARY_PATH=/opt/csw/gcc4/lib/gcc/sparc-sun-solaris2.8/4.3.2/:/usr/ccs/lib/:/opt/csw/gcc4/lib/gcc/sparc-sun-solaris2.8/4.3.2/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-v' '-o' 'hello_gnu.s' '-c' '-S' '-mcpu=v7'

works fine and makes for nice assembly :

$ cat hello_gnu.s
        .file   "hello.c"
        .section        ".rodata"
        .align 8
.LLC0:
        .asciz  "Hello World, have an integer. This one = %i\n"
        .section        ".text"
        .align 4
        .global main
        .type   main, #function
        .proc   04
main:
        save    %sp, -120, %sp
        st      %i0, [%fp+68]
        st      %i1, [%fp+72]
        mov     1, %g1
        st      %g1, [%fp-20]
        sethi   %hi(.LLC0), %g1
        or      %g1, %lo(.LLC0), %o0
        ld      [%fp-20], %o1
        call    printf, 0
         nop
        mov     0, %g1
        mov     %g1, %i0
        restore
        jmp     %o7+8
         nop
        .size   main, .-main
        .ident  "GCC: (GNU) 4.3.2"

$ gcc -o hello_gnu hello_gnu.s
$ ./hello_gnu
Hello World, have an integer. This one = 1

$ ls -lap hello*
-rwxr-xr-x   1 dclarke  csw         5372 Aug 30 16:57 hello
-rw-r--r--   1 dclarke  csw          180 Aug 30 16:53 hello.c
-rw-r--r--   1 dclarke  csw         1764 Aug 30 16:56 hello.s
-rwxr-xr-x   1 dclarke  csw         6424 Aug 30 17:12 hello_gnu
-rw-r--r--   1 dclarke  csw          465 Aug 30 17:08 hello_gnu.s

/*********** My initial thoughts ************/
So it looks like my studio.h is messed up by the mkheaders script and if
we replace the studio.h created by mkheaders ( auto-edited by fixincludes
) with the original vendor provided stdio.h then GCC 4.3.2 works just
fine.

/********** Does binutils 2.18 make a difference ? *********/

What happens if we use GNU binutils 2.18 ?

$ $HOME/local/bin/as --version
GNU assembler (GNU Binutils) 2.18
Copyright 2007 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or later.
This program has absolutely no warranty.
This assembler was configured for a target of `sparc-sun-solaris2.8'.

Let's produce some assembly :
$ gcc -o hello_gnu_take2.s -S -c hello.c

$ ls -lap hello*
-rwxr-xr-x   1 dclarke  csw         5372 Aug 30 16:57 hello
-rw-r--r--   1 dclarke  csw          180 Aug 30 16:53 hello.c
-rw-r--r--   1 dclarke  csw         1764 Aug 30 16:56 hello.s
-rwxr-xr-x   1 dclarke  csw         6424 Aug 30 17:12 hello_gnu
-rw-r--r--   1 dclarke  csw          465 Aug 30 17:08 hello_gnu.s
-rw-r--r--   1 dclarke  csw          465 Aug 30 17:17 hello_gnu_take2.s

Same as before ?
$ diff hello_gnu.s hello_gnu_take2.s

Identical. :-)

So you have to admire the fact that the use of binutils in the path really
makes no difference at all. In fact .. not even involved in the process it
seems.

$ as -o hello_gnu_take2.o -V -Qy -s -xarch=v7 hello_gnu_take2.s
GNU assembler version 2.18 (sparc-sun-solaris2.8) using BFD version (GNU
Binutils) 2.18
$ file hello_gnu_take2.o
hello_gnu_take2.o:      ELF 32-bit MSB relocatable SPARC Version 1

So I think we have a problem with stdio.h *after* mkheaders and
fixincludes gets to it. Not sure what the fix is other than .. don't run
mkheaders? Have I screwed up something in the compiler specs ?

Any thoughts ?

Dennis Clarke


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