public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Correct configure magic for building a MIPS cross compiler
@ 2007-12-04 12:11 Alex Bennee
  2007-12-04 13:24 ` Brian Dessent
  2007-12-04 17:20 ` David Daney
  0 siblings, 2 replies; 4+ messages in thread
From: Alex Bennee @ 2007-12-04 12:11 UTC (permalink / raw)
  To: gcc-help

Hi,

I'm trying to build a MIPS compiler for building kernels. Although the
linux-mips.org site specifies 3.4.2 I thought I'd try the latest stable
release. While googling I've seen people that seem to be using it but I
can't seem to get the correct configure magic for it.

Currently it fails building libmudflap which seems a little premature as
I'm guessing it needs a working cross compiler first:

make[2]: Leaving directory `/home/alex/src/mips/gcc/gcc-bootstrap/gcc'
Checking multilib configuration for libmudflap...
mkdir -p -- mips-unknown-linux-gnu/libmudflap
Configuring in mips-unknown-linux-gnu/libmudflap
configure: creating cache ./config.cache
checking build system type... x86_64-unknown-linux-gnu
checking host system type... mips-unknown-linux-gnu

^^^
-- Should this not be my host system, i.e. x86_64-unknown-linux-gnu

checking target system type... mips-unknown-linux-gnu
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking for
mips-unknown-linux-gnu-strip... /home/alex/src/mips/toolchain/mips-unknown-linux-gnu/bin/strip
checking for --enable-version-specific-runtime-libs... no
checking whether to enable maintainer-specific portions of Makefiles...
no
checking for
mips-unknown-linux-gnu-gcc... /home/alex/src/mips/gcc/gcc-bootstrap/./gcc/xgcc -B/home/alex/src/mips/gcc/gcc-bootstrap/./gcc/ -B/home/alex/src/mips/toolchain/mips-unknown-linux-gnu/bin/ -B/home/alex/src/mips/toolchain/mips-unknown-linux-gnu/lib/ -isystem /home/alex/src/mips/toolchain/mips-unknown-linux-gnu/include -isystem /home/alex/src/mips/toolchain/mips-unknown-linux-gnu/sys-include
checking for C compiler default output file name... configure: error: C
compiler cannot create executables
See `config.log' for more details.
make[1]: *** [configure-target-libmudflap] Error 1
make[1]: Leaving directory `/home/alex/src/mips/gcc/gcc-bootstrap'
make: *** [all] Error 2

Also should libmudflap be needed for building kernels?

My configure line is:

export PREFIX=/home/alex/src/mips/toolchain
export TARGET=mips-unknown-linux-gnu
export HOST=x86_64-unknown-linux-gnu
./gcc.4_2/configure --host=$HOST --target=$TARGET --prefix=$PREFIX
--enable-languages=c --with-gnu-ld --with-gnu-as  --without-headers
--disable-shared --disable-threads

I have already build a binutils and it's installed in my toolchain dir.
I'm building from the GCC 4.2 SVN branch.

Any pointers?

-- 
Alex, homepage: http://www.bennee.com/~alex/
Whenever people agree with me I always feel I must be wrong. -- Oscar
Wilde

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Correct configure magic for building a MIPS cross compiler
  2007-12-04 12:11 Correct configure magic for building a MIPS cross compiler Alex Bennee
@ 2007-12-04 13:24 ` Brian Dessent
  2007-12-04 14:12   ` Alex Bennee
  2007-12-04 17:20 ` David Daney
  1 sibling, 1 reply; 4+ messages in thread
From: Brian Dessent @ 2007-12-04 13:24 UTC (permalink / raw)
  To: Alex Bennee; +Cc: gcc-help

Alex Bennee wrote:

> Checking multilib configuration for libmudflap...
> mkdir -p -- mips-unknown-linux-gnu/libmudflap
> Configuring in mips-unknown-linux-gnu/libmudflap
> configure: creating cache ./config.cache
> checking build system type... x86_64-unknown-linux-gnu
> checking host system type... mips-unknown-linux-gnu
> 
> ^^^
> -- Should this not be my host system, i.e. x86_64-unknown-linux-gnu

No.  libmudflap is a target library, meaning it is code that runs on the
target.  So host=$TARGET is correct here.

> checking for
> mips-unknown-linux-gnu-gcc... /home/alex/src/mips/gcc/gcc-bootstrap/./gcc/xgcc -B/home/alex/src/mips/gcc/gcc-bootstrap/./gcc/ -B/home/alex/src/mips/toolchain/mips-unknown-linux-gnu/bin/ -B/home/alex/src/mips/toolchain/mips-unknown-linux-gnu/lib/ -isystem /home/alex/src/mips/toolchain/mips-unknown-linux-gnu/include -isystem /home/alex/src/mips/toolchain/mips-unknown-linux-gnu/sys-include
> checking for C compiler default output file name... configure: error: C
> compiler cannot create executables
> See `config.log' for more details.
> make[1]: *** [configure-target-libmudflap] Error 1
> make[1]: Leaving directory `/home/alex/src/mips/gcc/gcc-bootstrap'
> make: *** [all] Error 2

Here you seem to have a problem that the libmudflap configure wants to
do a link test to detect features of the target, but you apparently do
not have the files that are necessary to link an executable (like crt*.o
and libc) yet.  

The workaround is to configure with a sysroot that contains the items
necessary to link.  This generally just means copying the libc (headers,
libs, *crt*.o, etc.) from an existing system that you're targeting. 
With linux this is trivial as you can just take them from any distro.

Alternatively you can do it in a two step process, where you first build
a stripped-down featureless C-only compiler (avoiding steps that want to
do link feature tests), then use that to build your libc, then using the
results of that rebuild a full-featured gcc with all desired languages. 
This is sometimes called the crosstool method as it's what's used by the
crosstool script.  It is good for when you really want to completely
bootstrap a system from nothing.

A yet third option is available when your target uses newlib, typically
embedded boards.  You can use --with-newlib and link tests will be
skipped and instead a list of known results for newlib will be used.  Or
you can combine the newlib source in the tree and bootstrap both the
compiler and libc at the same time.  But again these options only apply
to targets that use newlib, not glibc or any other libc; this option
isn't a general purpose crutch to get rid of link tests.

Philosophically there seems to be a divide as to which route to take. 
Personally I think if you're targeting a common system (like linux) then
you're better off taking a sysroot from an existing system (i.e.
unpacking a distro's packages) because they are guaranteed to be tested,
stable, and correct -- even better if you plan to use that distro on
your actual target hardware eventually because you know there won't be
any hidden ABI gotchas.

> Also should libmudflap be needed for building kernels?

If your only intent for this cross compiler is to build linux kernels,
and that is all, then you don't have to worry about any of this.  The
kernel is standalone, so it doesn't matter if you don't have a libc
yet.  You can --disable-libmudflap and any other target libraries that
require link tests.  One thing you may run into is libgcc, which cannot
be disabled as it's always required (except for kernels.)  You can
however bypass building it by using "make all-gcc" instead of "make". 
The all-gcc target means just build the compiler itself, don't build gcc
plus target libraries.  (There are similarly prefixed versions of all
makefile targets.)  

Brian

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Correct configure magic for building a MIPS cross compiler
  2007-12-04 13:24 ` Brian Dessent
@ 2007-12-04 14:12   ` Alex Bennee
  0 siblings, 0 replies; 4+ messages in thread
From: Alex Bennee @ 2007-12-04 14:12 UTC (permalink / raw)
  To: gcc-help

On Tue, 2007-12-04 at 05:24 -0800, Brian Dessent wrote:
> Alex Bennee wrote:
> 
> <snip>
>
> Philosophically there seems to be a divide as to which route to take. 
> Personally I think if you're targeting a common system (like linux) then
> you're better off taking a sysroot from an existing system (i.e.
> unpacking a distro's packages) because they are guaranteed to be tested,
> stable, and correct -- even better if you plan to use that distro on
> your actual target hardware eventually because you know there won't be
> any hidden ABI gotchas.

I'd like to build everything from scratch (and document the process). My
plan was along the lines of:

* Build Cross Binutils
* Build Cross GCC (for kernel building)
* Build a MIPS Linux kernel 
* Build a libc/newlib (TBD) - based on the user space headers of the
kernel
* Build a Cross GCC (for MIPS userspace)
* Build a MIPS userspace

Somewhere in there I'll be building a MIPS emulator as well, probably
QEMU.

> > Also should libmudflap be needed for building kernels?
> 
> If your only intent for this cross compiler is to build linux kernels,
> and that is all, then you don't have to worry about any of this.  The
> kernel is standalone, so it doesn't matter if you don't have a libc
> yet.

I assume I can use the kernel compiler to build the libs so I can build
the full userspace compiler?

>   You can --disable-libmudflap and any other target libraries that
> require link tests.  One thing you may run into is libgcc, which cannot
> be disabled as it's always required (except for kernels.)  You can
> however bypass building it by using "make all-gcc" instead of "make". 
> The all-gcc target means just build the compiler itself, don't build gcc
> plus target libraries.  (There are similarly prefixed versions of all
> makefile targets.)  

Ok, thanks I shall give this approach a go.

-- 
Alex, homepage: http://www.bennee.com/~alex/
Mais espalhado que espirro em farofa.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Correct configure magic for building a MIPS cross compiler
  2007-12-04 12:11 Correct configure magic for building a MIPS cross compiler Alex Bennee
  2007-12-04 13:24 ` Brian Dessent
@ 2007-12-04 17:20 ` David Daney
  1 sibling, 0 replies; 4+ messages in thread
From: David Daney @ 2007-12-04 17:20 UTC (permalink / raw)
  To: Alex Bennee; +Cc: gcc-help

Alex Bennee wrote:
> 
.
.
.
> 
> Any pointers?
> 

http://cross-lfs.org/view/svn/mips/

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2007-12-04 17:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-12-04 12:11 Correct configure magic for building a MIPS cross compiler Alex Bennee
2007-12-04 13:24 ` Brian Dessent
2007-12-04 14:12   ` Alex Bennee
2007-12-04 17:20 ` David Daney

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).