I've been trying to build GCC 4.0.0 on an ordinary Intel PC running Solaris
2.10.  The base compiler is gcc3.4.2 from Sun's Companion CD.  I'm using
binutils-2.16 and fetched bison 2.0 (though that probably wasn't necessary).

GCC 4.0.0 assumes all i386-pc-solaris2.10 boxes have 64-bit processors.  The
problems occur when you try to build libcpp.  First, you get problems because
the new xgcc generates 64-bit opcodes which the assembler can't assemble and a 

Pentium can't execute.  Once you fix that, you have very odd problems in which
the new xgcc thinks all bitfield lengths equal to 0.

This problem arises because uname won't tell you whether the current platform
has a 32-bit or 64-bit processor.  isalist can (sort of) in that it lists
"amd64" as one of the instruction sets supported when running on 64-bit
platforms.  The modifications shown below should probably look for instruction
sets other than "amd64".  I have not tested the fix described below on a real
64-bit platform because I don't have one.  I found out about "amd64" by asking a
friend what happened when he typed "isalist" on his 64-bit Solaris box.

I only compiled gcc-core and gcc-g++.  I don't know if there are similar
problems with the other members of the compiler suite.

I had to make the following changes to make things work:

1. Modify gcc-4.0.0/gcc/config.gcc
 I changed

case ${target} in
        *-*-solaris2.1[0-9]*)
                tm_file="${tm_file} i386/x86-64.h i386/sol2-10.h"
                tm_defines="${tm_defines} TARGET_BI_ARCH=1"
                tmake_file="$tmake_file i386/t-sol2-10"
                need_64bit_hwint=yes
                # Solaris 2.10 provides crt1.o, crti.o, crtn.o, and gcrt1.o as 
                # part of the base system.
                extra_parts="gmon.o crtbegin.o crtend.o"
                ;;
        *)
                extra_parts="crt1.o crti.o crtn.o gcrt1.o gmon.o crtbegin.o 
crtend.o"
                ;;

to

        case ${target} in
        *-*-solaris2.1[0-9]*)
                # If this is a 32-bit platform, i.e. does not execute the
                # amd64 instruction set, do not include the 64-bit extensions.
                case `isalist | grep -c amd64` in
                0)
                        tm_file="${tm_file} i386/sol2-10.h"
                        tmake_file="$tmake_file i386/t-sol2-10-32"
                        ;;
                1)
                        tm_file="${tm_file} i386/x86-64.h i386/sol2-10.h"
                        tm_defines="${tm_defines} TARGET_BI_ARCH=1"
                        tmake_file="$tmake_file i386/t-sol2-10"
                        need_64bit_hwint=yes
                        ;;
                esac
                # Solaris 2.10 provides crt1.o, crti.o, crtn.o, and gcrt1.o as 
                # part of the base system.
                extra_parts="gmon.o crtbegin.o crtend.o"
                ;;
        *)
                extra_parts="crt1.o crti.o crtn.o gcrt1.o gmon.o crtbegin.o 
crtend.o"
                ;;

2, I added gcc-4.0.0/gcc/config/i386/t-sol2-10-32.  It contains

MULTILIB_OPTIONS = m32
MULTILIB_DIRNAMES = 32
MULTILIB_OSDIRNAMES = .

LIBGCC = stmp-multilib
INSTALL_LIBGCC = install-multilib

# GCC contains i386 assembler sources for some of the startfiles
# which aren't appropriate for amd64.  Just use the installed
# versions of: crt1.o crti.o crtn.o gcrt1.o
EXTRA_MULTILIB_PARTS=gmon.o crtbegin.o crtend.o

This may or may not have been necessary, but it seems tidy.

3. Those two changes convinced the new compiler to only emit 32-bit opcodes. 
The next problem was that the new compiler thought all bitfield lengths were 0.
 That's because it thought all constants encountered in source files had a value
of 0.  Boy, was that a lot of fumbling in the dark!  The cause of this was that
HOST_WIDE_INT was set to  "long long" instead of "long".  To fix this, I changed
gcc-4.0.0/libgcc/configure and gcc-4.0.0/libgcc/configure.ac as follows:

---------------------------------------------------------
case $target in
        alpha*-*-* | \
        arm*-*-eabi* | \
        arm*-*-symbianelf* | \
        x86_64-*-* | \
        ia64-*-* | \
        hppa*64*-*-* | parisc*64*-*-* | \
        i[34567]86-*-solaris2.1[0-9]* | \
        mips*-*-* | \
        mmix-*-* | \
        powerpc*-*-* | \
        rs6000*-*-* | \
        s390*-*-* | \
        sparc64*-*-* | ultrasparc-*-freebsd* | \
        sparcv9-*-solaris2* | \
        sparc-*-solaris2.[789] | sparc-*-solaris2.1[0-9]* | \
        sh[123456789l]*-*-*)
                need_64bit_hwint=yes ;;
     *)
                need_64bit_hwint=no ;;
esac
---------------------------------------------------------

becomes

---------------------------------------------------------
need_64bit_hwint=no
case $target in
        alpha*-*-* | \
        arm*-*-eabi* | \
        arm*-*-symbianelf* | \
        x86_64-*-* | \
        ia64-*-* | \
        hppa*64*-*-* | parisc*64*-*-* | \
        mips*-*-* | \
        mmix-*-* | \
        powerpc*-*-* | \
        rs6000*-*-* | \
        s390*-*-* | \
        sparc64*-*-* | ultrasparc-*-freebsd* | \
        sparcv9-*-solaris2* | \
        sparc-*-solaris2.[789] | sparc-*-solaris2.1[0-9]* | \
        sh[123456789l]*-*-*)
                need_64bit_hwint=yes ;;

        i[34567]86-*-solaris2.1[0-9]*)
            case `isalist | grep -c amd64` in
            1)
                need_64bit_hwint=yes ;;
            esac ;;     
esac
---------------------------------------------------------

It would be better to look for all possible 64-bit x86 instruction sets, but
I'll leave that to you!

-- 
           Summary: gcc 4.0.0 assumes all i386-pc-solaris2.10 platforms have
                    64-bit processors
           Product: gcc
           Version: 4.0.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: bootstrap
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: Daniel dot Davies at xerox dot com
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i386-pc-solaris2.10
  GCC host triplet: i386-pc-solaris2.10
GCC target triplet: i386-pc-solaris2.10


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21542

Reply via email to