public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Help building gcc with x86-64 support
@ 2007-06-11  7:12 Willow Schlanger
  2007-06-11  7:21 ` Rupert Wood
  2007-06-11 11:05 ` Brian Dessent
  0 siblings, 2 replies; 3+ messages in thread
From: Willow Schlanger @ 2007-06-11  7:12 UTC (permalink / raw)
  To: gcc-help

Hello,
Sorry I am not subscribed to this list so if you have any help please 
write directly to me via email. Thanks very much.
---
I am trying to build gcc 3.3.3 from the source code under coLinux 
(debian). It should work the same as under real Linux.

I am trying to build it so that it can produce 64-bit code for OS 
development (or 32-bit code with the -m32 option).

I have a version of BOCHS (PC emulator) with 64-bit amd64 emulation, and 
I want to play around with developing a 64-bit operating system, 
especially to try out memory management ideas etc.

To do this I need a gcc cross-compiler from Linux i686 to Linux ELF x86_64.

I tried ./configure --target=x86_64-blah-blah and it all works until it 
tries to compile a C run-time library file, then it generates an 
assembler error.

The assembler error is on a .s file in a temporary directory, e.g. this 
is part of the compiler process itself.

The host is i686. The target is 64-bit ELF on x86-64.

The problem is, this C runtime library file has inline assembly code, 
and the code is 64-bit code. The assembler complains

Do you understand what is going on here?

It looks to me like I already need a 64-bit compiler in order to build a 
64-bit compiler, because the C runtime library

Now truthfully, if you can tell me what to use in 'configure' -- e.g. 
what blah should be (e.g. --target=x86_64-linux-elf), to DISABLE 
building the C runtime library I will be greatful.

That is because for OS development I don't need a 64-bit C runtime 
library built in any case.

But truthfully, it SHOULD work -- what 'configure' target should I use 
in order to make the C runtime library code use the C version not the 
64-bit assembly version?

Your help would be greatly appreciated. I want to design a 64-bit 
operating system for fun, I already have lots of ideas regarding memory 
management.

Willow

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

* RE: Help building gcc with x86-64 support
  2007-06-11  7:12 Help building gcc with x86-64 support Willow Schlanger
@ 2007-06-11  7:21 ` Rupert Wood
  2007-06-11 11:05 ` Brian Dessent
  1 sibling, 0 replies; 3+ messages in thread
From: Rupert Wood @ 2007-06-11  7:21 UTC (permalink / raw)
  To: 'Willow Schlanger'; +Cc: gcc-help

Willow Schlanger wrote:

> To do this I need a gcc cross-compiler from Linux i686 to Linux ELF
> x86_64.
:
> That is because for OS development I don't need a 64-bit C runtime
> library built in any case.

To build a complete GCC toolchain you do need a C library; you need all of:

  - GCC
  - binutils (assembler and linker)
  - a C library, e.g. newlib or glibc

built for your target platform. The C library is at least required to help build GCC's own runtime libraries such as libgcc. At that point you could then either take the partial GCC build you have and use that to build a C library and then rebuild GCC, or you might already have enough of GCC built for what you need.

If you want to build a complete cross-compiler toolchain for a Linux target a good place to start is Crosstool,

    http://kegel.com/crosstool/

although it might not support very recent GCC versions.

Good luck!
Rup.


______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
______________________________________________________________________

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

* Re: Help building gcc with x86-64 support
  2007-06-11  7:12 Help building gcc with x86-64 support Willow Schlanger
  2007-06-11  7:21 ` Rupert Wood
@ 2007-06-11 11:05 ` Brian Dessent
  1 sibling, 0 replies; 3+ messages in thread
From: Brian Dessent @ 2007-06-11 11:05 UTC (permalink / raw)
  To: Willow Schlanger; +Cc: gcc-help

Willow Schlanger wrote:

> I am trying to build gcc 3.3.3 from the source code under coLinux
> (debian). It should work the same as under real Linux.

Why such an old version?

> I am trying to build it so that it can produce 64-bit code for OS
> development (or 32-bit code with the -m32 option).

In order to build gcc in the normal way you need an existing functional
libc (headers and libs) before starting.

> To do this I need a gcc cross-compiler from Linux i686 to Linux ELF x86_64.

You also need a working cross assembler, i.e. cross-binutils, before you
can build a cross-compiler.

> I tried ./configure --target=x86_64-blah-blah and it all works until it
> tries to compile a C run-time library file, then it generates an
> assembler error.

Because you're trying to use a 32 bit gas to assemble 64 bit code, which
won't work.

> It looks to me like I already need a 64-bit compiler in order to build a
> 64-bit compiler, because the C runtime library

That is a separate issue.

> Now truthfully, if you can tell me what to use in 'configure' -- e.g.
> what blah should be (e.g. --target=x86_64-linux-elf), to DISABLE
> building the C runtime library I will be greatful.
> 
> That is because for OS development I don't need a 64-bit C runtime
> library built in any case.

"C runtime library" is not the right word.  gcc doesn't provide a C
library.  It does provide various libraries that run on the target
(libgcc, libstdc++, libsupc++, libgfortran, libmudflap, libjava, libada,
...) all of which have a prerequisite of an existing, functioning libc.

To build just the compiler and no target libraries, you can use the
"all-gcc" make target.  This is essentially just a glorified way of
stopping the build after gcc is done but before trying to build any
target libraries.  It won't really accomplish anything different than
what you already have now, which is a build that fails at first target
library step.

The compiler in this state will hardly be functional at all.  You might
be able to use it to compile simple preprocessed source, but for example
gcc generates calls to libgcc for many standard operations like wide
integer math, vector ops, exception handling, and so on.  So you can't
just say "oh I won't be calling any C library functions so I don't need
libgcc", because gcc expects to rely on libgcc for many things.

> But truthfully, it SHOULD work -- what 'configure' target should I use
> in order to make the C runtime library code use the C version not the
> 64-bit assembly version?

What you seem to be seeking here is a bare-metal target.  These are
where the target has no operating system and no libc.  They are
typically just "foo-elf", e.g. m68k-elf, arm-elf, i386-elf, ...  I'm not
sure if x86_64-elf is a valid target, but you can try it.  Generally
bare metal targets are small embedded devices, not PCs.  If you really
are trying to build something that doesn't use anything from linux or
glibc then configuring for x86_64-pc-linux (or any other
variants/aliases of that target like x86_64-linux, x86_64-unknown-linux,
x86_64-pc-linux-gnu, etc.) is wrong.

Brian

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

end of thread, other threads:[~2007-06-11  7:21 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-06-11  7:12 Help building gcc with x86-64 support Willow Schlanger
2007-06-11  7:21 ` Rupert Wood
2007-06-11 11:05 ` Brian Dessent

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