solaris2.8/solaris 2.9 SPARC for powerpc-elf-linux

David Kahn dmkahn@gmail.com
Thu Jun 29 13:10:00 GMT 2006


I was able to create x-tools for powerpc-elf-linux
on a Solaris/SPARC 2.9 system, but had to resolve several
issues. I'll post the things I had to do here. I started
on a Solaris 2.8 system but finished on a Solaris 2.9
system where I was able to get a bunch of local disk
space. This stuff should apply to both 2.8 and 2.9
and my guess is that it probably also applies if you
are running on Solaris 2.8 or 2.9 on an x86-based
system.

My target was powerpc-elf-linux gcc-3.4.3-glibc-2.3.2
I used crosstools-0.42 from Dan Kegel's site.

The biggest problems involve incompatibilities
with Sun's /bin/sh vs other implementations /bin/sh,
which is typically bash on most linux systems. Sun's
/bin/sh doesn't handle things like "for i in ; do"
(notice the empty list) and tests for file existence
using -e as in "if [ -e <filename> ]".

Also different behaviors in shell/echo pop up from time to time.
Setting SHELL and CONFIG_SHELL to /bin/ksh solves many of these
problems. One would think that setting them to /bin/bash
might solve them as well, but it doesn't. Also, there
are uses of naked "sh" in the crosstools themselves,
that don't work on Solaris.

The other "big" problem is that the build really depends
on "gnu sed" rather than "/bin/sed" which behave differently.
So, make sure gnu sed is in your path before the normal system
sed is and that mostly takes care of that.

Additional patches needed:

1. There's a problem generating glibc/csu/version-info.h
    http://sources.redhat.com/ml/crossgcc/2003-11/msg00111.html

    The patch referenced from the above message isn't enough.
    The first two "echo"s also don't generate a terminating '"'
    (well, they do, but it's after an unintended newline.)
    Lots of patches out there, but none of them included both
    fixes needed for this to correctly work on Solaris 2.9.

    A copy of the patch I used is here:

    http://www.flex.com/~dmk/glibc-2.3.2-allow-solaris.patch

    NB: I found a patch with this name on Kegel's web site,
    but it doesn't have both parts of the patch. It's also not
    included in crosstool's patches. It's possible that you
    may not need the 'sed' fix part of the patch when using
    gnu sed, but you will need the echo -> printf fixes.

2. Because of an incorrect assumption about the behavior
    of "test -z" with an empty string, a header file is
    generated incorrectly, which results in an undefined
    symbol LIBNSS_FILES_SO during the glibc gnbuild.
    See also: http://sourceware.org/ml/crossgcc/2005-12/msg00110.html

    This problem is discussed quite a bit on the boards, but
    the message I referenced above is the only one I found that
    actually suggested a fix that worked for me.

    Ingo's suggested fix as a patch can be found here:

    http://www.flex.com/~dmk/glibc-2.3.2-allow-solaris-Makeconfig.patch

Here's the list of things I needed to do to the crosstool scripts
themselves so they worked on Solaris 2.9:

1. Make sure the first 'sed' in your path is gnu sed. which must
    be spelled "sed". (Not really a crosstool problem, but listed
    here nonetheless.)

2. In your top level script, define and export SHELL and CONFIG_SHELL
    as /bin/ksh.  /bin/bash doesn't work. As a tcsh user, I had to
    make sure I defined SHELL as /bin/ksh as well, since tcsh defines SHELL
    as the path you invoked to run tcsh (/bin/tcsh for me.) Just define
    both, it won't hurt anything.

3. Change crosstool.sh to a /bin/ksh script (change line 1.)
    See #6. This might not be required.

4. In crosstool.sh, add ${CONFIG_SHELL} to the places where
    .../configure is invoked. This will do nothing if CONFIG_SHELL
    is undefined, but if it is defined, it will invoke configure
    using your definition of $CONFIG_SHELL.

5. Change getandpatch.sh to a /bin/ksh script (line 1).
    See #6. This might not be required.

6. Change all naked "sh" uses in all.sh to use ${CONFIG_SHELL-sh}
    (This might eliminate the need for #3 and #5, which may just be
    a leftover attempt to fix things.)

7. mkoveride.sh does an 'install -D ..." that my gnu install doesn't
    understand. It's the last couple of lines in the file. Just comment
    out that 'install -D ..." line. It isn't required. Looks like it was
    an afterthought to install that script anyway.

8. Invoke your top level script using /bin/ksh.

Finally, possibly because of ksh (not sure) I found I had to remove
comment lines from the .dat file that the top level script 'evals' in order
to get the crosstools to work.

Also note, that I used a native gcc 3.4.5 to build the crosstools.
I did not use the Sun compilers.

-David


--
For unsubscribe information see http://sourceware.org/lists.html#faq



More information about the crossgcc mailing list