This is the mail archive of the crossgcc@sourceware.org mailing list for the crossgcc project.

See the CrossGCC FAQ for lots more information.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Targetting Sparc/Solaris



Hi There,

I want to thank Nathan for posting these instructions.  They were close
enough
that i was able to successfully build a sparc cross compiler running on
Linux (SuSE 9.2).

There was one step below which caused my build to fail that I had to fix.
I'm honestly not sure how Nathan got it to work, but it caused my build to
gack, so
I thought that I'd post what I had to do to get it to work.

I used binutils-2.17 (it worked fine for me...) and the full gcc-4.1.1
running on SuSE 9.2.

I used it to compile 64 bit kernel drivers, so it seems ok to me...


My changes to Nathan's instructions are below in-line marked with [dg]

________________________________


 * download {{{gcc-core-4.1.1.tar.bz2}}} (and matching {{{.sig}}}) from
http://gcc.gnu.org.
   * Note gcc-core only contains C compiler, which is what we want.
 * download {{{binutils-2.16.1.tar.bz2}}}  (and matching {{{.sig}}})
from http://www.gnu.org/software/binutils/
   * Note: binutils-2.17 fails to build when using {{{--with-sysroot}}}
(becuase of a warning and -Werror) so use 2.16.1.


[dg] I got it to work fine with binutils-2.17 with no warnings... I don't
know
[dg] what happened with Nathan...


== sparc-sun-solaris2.8 ==

 * on Solaris 8 SPARC box get libs and includes by running the following
script
{{{
$ cd /
$ echo /usr/lib/iconv> /tmp/myexclude
$ echo /usr/lib/ab2>>  /tmp/myexclude
$ echo /usr/lib/im>>   /tmp/myexclude
$ tar cfX /tmp/sparc-sun-solaris2.8-lib-include.tar /tmp/myexclude
/usr/include/* /usr/lib/* /usr/ccs/lib/*
}}}
   After several minutes you'll end up with a ~150MB tar file. Don't
give 'h' option to tar because there are many recursive symlinks.

[dg] I also had to tar up /lib to get libc.so which lives in /lib on Solaris
10.
[dg] On my Solaris 8 box it's also in /lib so I don't know how Nathan got
this 
[dg] to work....  Also I used 'solaris2.10' instead of 'solaris2.8' here and
[dg] in all the command below, but I don't think that it matters at all.
[dg] So this command becomes:
$ tar cfX /tmp/sparc-sun-solaris2.8-lib-include.tar /tmp/myexclude
/usr/include/* /usr/lib/* /usr/ccs/lib/* /lib/*
[dg]  I used the libs and headers from Solaris 10 sparc Generic, BTW...

 * copy sparc-sun-solaris2.8-lib-include.tar to local /xgcc-4.1-build/src/

 * unpack libs and includes tar
{{{
$ mkdir -p /xgcc-4.1/sparc-sun-solaris2.8/sparc-sun-solaris2.8
$ cd /xgcc-4.1/sparc-sun-solaris2.8/sparc-sun-solaris2.8
$ tar xf /xgcc-4.1-build/src/sparc-sun-solaris2.8-lib-include.tar
}}}

 * rearrange native libs and includes to make gcc happy
{{{
$ cd /xgcc-4.1/sparc-sun-solaris2.8/sparc-sun-solaris2.8
$ ln -s usr/lib lib

[dg] This did not work for me.  When I tried this I could compile binutils
ok,
[dg] but the gcc compile stopped complaining that it could not find libc.so.
[dg] Since libc.so lives /lib on Solaris, we have to get the real libs from
/lib 
[dg] in the 'tar' step above, not just the symlinks in /usr/lib.
[dg] So just skip this step.  If you got the /lib directory above you
[dg] should already have it populated.

$ ln -s usr/include sys-include

[dg] I don't know if this step is necessary, I included it and it worked,
but
[dg] I didn't try it without it, so....

}}}

 * build binutils
{{{
$
$ cd /xgcc-4.1-build/sparc-sun-solaris2.8/binutils
$ /xgcc-4.1-build/src/binutils-2.16.1/configure
--prefix=/xgcc-4.1/sparc-sun-solaris2.8 --target=sparc-sun-solaris2.8
--with-sysroot=/xgcc-4.1/sparc-sun-solaris2.8/sparc-sun-solaris2.8 >
configure.log 2>&1
$ make > build.log 2>&1
$ make install > install.log 2>&1
}}}

 * help out binutils' ''make install'', for some reason it doesn't copy
{{{objcopy}}}, which is needed to create debug info files
{{{
$ cd /xgcc-4.1/sparc-sun-solaris2.8/bin
$ cp sparc-sun-solaris2.8-objcopy.exe
../sparc-sun-solaris2.8/bin/objcopy.exe
}}}

 * build gcc
{{{
$ mkdir -p /xgcc-4.1-build/sparc-sun-solaris2.8/gcc
$ cd /xgcc-4.1-build/sparc-sun-solaris2.8/gcc
$ export PATH=/xgcc-4.1/sparc-sun-solaris2.8/bin:$PATH
$ /xgcc-4.1-build/src/gcc-4.1.1/configure
--prefix=/xgcc-4.1/sparc-sun-solaris2.8 --target=sparc-sun-solaris2.8
--with-sysroot=/xgcc-4.1/sparc-sun-solaris2.8/sparc-sun-solaris2.8
--with-gnu-as --with-gnu-ld --disable-libssp > configure.log 2>&1

[dg] I added --enable-languages=c since I had the full gcc distro
[dg] rather than the -core version.  I did successfully build everything
[dg] including the c++ stdlib and java, but I don't use either of those,
[dg] so I didn't test them.  Java takes _forever_ to build so skip it if
[dg] you can.

$ make > build.log 2>&1
$ make install > install.log 2>&1
}}}
    Note: {{{--disable-libssp}}} required because of
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25035 which should be fixed
in > gcc 4.1.1


[dg]
This compiler generates 32 bit objects by default.  If you want 64 bit
objects you need to 
specify '-m64' to gcc.

One other thing that I ran into after I got this built was this error
message
when I tried to link 64 bit objects:

sparc-sun-solaris2.10-ld: Relocatable linking with relocations from format
elf64-sparc (XXX) to format elf64-sparc (XXX) is not supported.

I had to add the -melf64_sparc flag to my 'ld' rules in my Makefiles to fix
this.  Thanks google!
[dg]


hope that helps...
thanks-
dan



-- 
View this message in context: http://www.nabble.com/Targetting-Sparc-Solaris-tf4157771.html#a12064380
Sent from the Sourceware - crossgcc list mailing list archive at Nabble.com.


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


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