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


Sam Brightman wrote:
> Nathan Kidd wrote:
> Very glad to hear it's possible. I guess then the more appropriate
> question would be, how easy is it relative to buying a SPARC box given
> that knowledge of the toolchain build process is quite minimal.
> Basically, currently just using crosstool as is - the biggest pain has
> been setting up the environment.

After managing builds both ways for many years, I very strongly
recommend you go the cross-compiler route.  Your individual
circumstances may vary, but for me there is no way I want to be relying
on a single old machine, 3 years down the road, to build a critical
patch for a customer.

>> It sounds like your cross compiler is picking up Linux (headers?/)libs.

> Well, the current output from the end of the build is shown below. Isn't
> it possible just to use -I or -isystem to redirect to the Solaris
> headers, and also use the crt*.o from Solaris with ld via flags? I think
> I read there is no specific dynamic loader on Solaris, so it should be
> blank instead of ld-linux... or does the whole toolchain need rebuilding
> without any linux-y stuff, hence lots of fiddling with crosstool scripts?

I suppose it should be possible to do as you said, but I think building
clean would be a much easier if you don't have intimate knowledge of the
whole process (i.e. know how to completely clean your specs file).

> GNU C++ version 4.1.0 (sparc-unknown-linux-gnu)
> GNU assembler version 2.16.1 (sparc-unknown-linux-gnu) using BFD version
> 2.16.1
<snip>
> /opt/crosstool/gcc-4.1.0-glibc-2.3.6/sparc-unknown-linux-gnu/libexec/gcc/sparc-unknown-linux-gnu/4.1.0/collect2
> --eh-frame-hdr -m elf32_sparc -Y P,/usr/lib -relax -dynamic-linker
> /lib/ld-linux.so.2 -o cross_sm
> /prefix/../../../../sparc-unknown-linux-gnu/lib/crt1.o
> /prefix/../../../../sparc-unknown-linux-gnu/lib/crti.o

Your current compiler believes it is building for Linux OS hosted on
SPARC CPU.  This isn't going to work for Solaris OS on SPARC CPU (at
least without some magic of a Linux compatability layer on Solaris, of
which I'm ignorant).

I've pasted below my (wiki markup) notes from the last time I built a
Cygwin-hosted sparc-sun-solaris2.8 cross compiler.  They probably are
not 100% correct, but "work for me".

-Nathan

______________________________________________________________________


 * 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.

== 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.

 * 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
$ ln -s usr/include sys-include
}}}

 * 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
$ 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



--
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]