public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* 64-bit for OS kernel development
@ 2008-02-06 19:28 Frank W. Miller
  2008-02-09  1:49 ` Ian Lance Taylor
  2008-02-14 21:53 ` Building a cross compiler for x86_64 Frank W. Miller
  0 siblings, 2 replies; 10+ messages in thread
From: Frank W. Miller @ 2008-02-06 19:28 UTC (permalink / raw)
  To: gcc-help


Greetings,

I am interested in using gcc to extend the development of an OS kernel
from 32-bit to 64-bit for Intel and AMD processors.

If I use a compiler that is built for a 32-bit Linux distro, and I
change my types in the kernel code from 32 bit (long and unsigned long)
to 64 bit (long long and unsigned long long), will the resulting data
types use the native 64-bit types on the underlying machine?

Thanks,
FM


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

* Re: 64-bit for OS kernel development
  2008-02-06 19:28 64-bit for OS kernel development Frank W. Miller
@ 2008-02-09  1:49 ` Ian Lance Taylor
  2008-02-09  2:54   ` Frank W. Miller
  2008-02-14 21:53 ` Building a cross compiler for x86_64 Frank W. Miller
  1 sibling, 1 reply; 10+ messages in thread
From: Ian Lance Taylor @ 2008-02-09  1:49 UTC (permalink / raw)
  To: Frank W. Miller; +Cc: gcc-help

"Frank W. Miller" <fwmiller@cornfed.com> writes:

> I am interested in using gcc to extend the development of an OS kernel
> from 32-bit to 64-bit for Intel and AMD processors.
> 
> If I use a compiler that is built for a 32-bit Linux distro, and I
> change my types in the kernel code from 32 bit (long and unsigned long)
> to 64 bit (long long and unsigned long long), will the resulting data
> types use the native 64-bit types on the underlying machine?

Only if you compile in 64-bit mode.  A compiler for a 32-bit distro
probably compiles in 32-bit mode by default.  It may support the -m64
option to generate 64-bit code.

Ian

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

* RE: 64-bit for OS kernel development
  2008-02-09  1:49 ` Ian Lance Taylor
@ 2008-02-09  2:54   ` Frank W. Miller
  2008-02-09  4:41     ` Ian Lance Taylor
  0 siblings, 1 reply; 10+ messages in thread
From: Frank W. Miller @ 2008-02-09  2:54 UTC (permalink / raw)
  To: 'Ian Lance Taylor'; +Cc: gcc-help


Thanks, I was able to decipher that from the gcc documentation finally.

Another question, if I want to optimize for core 2 duo, what -mtune should I
use?

Thanks,
FM


-----Original Message-----
From: Ian Lance Taylor [mailto:iant@google.com] 
Sent: Friday, February 08, 2008 6:48 PM
To: Frank W. Miller
Cc: gcc-help@gcc.gnu.org
Subject: Re: 64-bit for OS kernel development

"Frank W. Miller" <fwmiller@cornfed.com> writes:

> I am interested in using gcc to extend the development of an OS kernel
> from 32-bit to 64-bit for Intel and AMD processors.
> 
> If I use a compiler that is built for a 32-bit Linux distro, and I
> change my types in the kernel code from 32 bit (long and unsigned long)
> to 64 bit (long long and unsigned long long), will the resulting data
> types use the native 64-bit types on the underlying machine?

Only if you compile in 64-bit mode.  A compiler for a 32-bit distro
probably compiles in 32-bit mode by default.  It may support the -m64
option to generate 64-bit code.

Ian

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

* Re: 64-bit for OS kernel development
  2008-02-09  2:54   ` Frank W. Miller
@ 2008-02-09  4:41     ` Ian Lance Taylor
  0 siblings, 0 replies; 10+ messages in thread
From: Ian Lance Taylor @ 2008-02-09  4:41 UTC (permalink / raw)
  To: Frank W. Miller; +Cc: gcc-help

"Frank W. Miller" <fwmiller@cornfed.com> writes:

> Another question, if I want to optimize for core 2 duo, what -mtune should I
> use?

-mtune=core2.  But it's not supported in gcc 4.2.x.  It will be
supported in gcc 4.3.0 when it comes out.

In 4.2 it's probably best to use -mtune=generic, which is the default
anyhow.

Ian

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

* Building a cross compiler for x86_64
  2008-02-06 19:28 64-bit for OS kernel development Frank W. Miller
  2008-02-09  1:49 ` Ian Lance Taylor
@ 2008-02-14 21:53 ` Frank W. Miller
  2008-02-15  1:32   ` Brian Dessent
  1 sibling, 1 reply; 10+ messages in thread
From: Frank W. Miller @ 2008-02-14 21:53 UTC (permalink / raw)
  To: gcc-help



I've determined that my gcc build does not support the -w64 compile
option.  (I'm running FC8 and its not compiled in by default apparently)

So, I need to build a cross compiler.  I have binutils-2.18 and
gcc-4.2.3 and I'm ready to do a build.  First question is, what platform
should I target, i.e. what should --target=??? be for both binutils and
gcc?

Thanks,
FM


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

* Re: Building a cross compiler for x86_64
  2008-02-14 21:53 ` Building a cross compiler for x86_64 Frank W. Miller
@ 2008-02-15  1:32   ` Brian Dessent
  2008-02-15  6:02     ` Frank W. Miller
  0 siblings, 1 reply; 10+ messages in thread
From: Brian Dessent @ 2008-02-15  1:32 UTC (permalink / raw)
  To: Frank W. Miller; +Cc: gcc-help

"Frank W. Miller" wrote:

> I've determined that my gcc build does not support the -w64 compile
> option.  (I'm running FC8 and its not compiled in by default apparently)

I'm assuming you mean -m64 here.

> So, I need to build a cross compiler.  I have binutils-2.18 and

Not necessarily.  The gcc i386 backend is bi-arch, meaning that it
targets both ia32 and x86_64 from a single backend.  So you can simply
build a 32 bit gcc that also supports 64 bit.  This would not
necessarily be a cross compiler, but you of course wouldn't be able to
run the resulting binary on the host.

To make this work, you first need to install a 64 bit libc however. 
This means headers, libs, crt*.o, etc.  You should be able to do this
through your distro.  Once you have that you can configure with
--enable-targets=all and you should get a 32 bit gcc with -m64.

You can still go the cross route but it's more work, you'd need to first
create a sysroot containing full 32 and 64 bit libc-devel's, then
configure with --target=x86_64-pc-linux --with-sysroot=whatever.

Brian

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

* RE: Building a cross compiler for x86_64
  2008-02-15  1:32   ` Brian Dessent
@ 2008-02-15  6:02     ` Frank W. Miller
  2008-02-15  6:31       ` Brian Dessent
  0 siblings, 1 reply; 10+ messages in thread
From: Frank W. Miller @ 2008-02-15  6:02 UTC (permalink / raw)
  To: gcc-help


I should have been more specific.  I'm migrating an existing 32-bit OS
kernel to be 64-bit, ia32e mode, i.e. x86_64.  I have my own libs but the
result is a kernel that is a standalone executable.

I probably want to build the binutils too, its not that much extra work and
I'll know for sure what I've got if I do that.

The development machine is an ia32 pc running fc8.  The target will be a
standalone kernel running in ia32e mode.  It sounds like x86_64-pc-linux
will probably work for me.

What I really want is for the resulting cross tools, gcc, gas, ld, etc. to
be 64-bit only.  Will that be the case with this build or will I still need
to use -m64 in my compile steps?

Thanks,
FM

-----Original Message-----
From: gcc-help-owner@gcc.gnu.org [mailto:gcc-help-owner@gcc.gnu.org] On
Behalf Of Brian Dessent
Sent: Thursday, February 14, 2008 6:32 PM
To: Frank W. Miller
Cc: gcc-help@gcc.gnu.org
Subject: Re: Building a cross compiler for x86_64

"Frank W. Miller" wrote:

> I've determined that my gcc build does not support the -w64 compile
> option.  (I'm running FC8 and its not compiled in by default apparently)

I'm assuming you mean -m64 here.

> So, I need to build a cross compiler.  I have binutils-2.18 and

Not necessarily.  The gcc i386 backend is bi-arch, meaning that it
targets both ia32 and x86_64 from a single backend.  So you can simply
build a 32 bit gcc that also supports 64 bit.  This would not
necessarily be a cross compiler, but you of course wouldn't be able to
run the resulting binary on the host.

To make this work, you first need to install a 64 bit libc however. 
This means headers, libs, crt*.o, etc.  You should be able to do this
through your distro.  Once you have that you can configure with
--enable-targets=all and you should get a 32 bit gcc with -m64.

You can still go the cross route but it's more work, you'd need to first
create a sysroot containing full 32 and 64 bit libc-devel's, then
configure with --target=x86_64-pc-linux --with-sysroot=whatever.

Brian

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

* Re: Building a cross compiler for x86_64
  2008-02-15  6:02     ` Frank W. Miller
@ 2008-02-15  6:31       ` Brian Dessent
  2008-02-15  7:00         ` Frank W. Miller
  0 siblings, 1 reply; 10+ messages in thread
From: Brian Dessent @ 2008-02-15  6:31 UTC (permalink / raw)
  To: Frank W. Miller; +Cc: gcc-help

"Frank W. Miller" wrote:

> I probably want to build the binutils too, its not that much extra work and
> I'll know for sure what I've got if I do that.

That's not optional.  Binutils provides (among other things) the
assembler and linker, without which gcc is just a glorified
C-to-assembler text filter.

> The development machine is an ia32 pc running fc8.  The target will be a
> standalone kernel running in ia32e mode.  It sounds like x86_64-pc-linux
> will probably work for me.
> 
> What I really want is for the resulting cross tools, gcc, gas, ld, etc. to
> be 64-bit only.  Will that be the case with this build or will I still need
> to use -m64 in my compile steps?

Okay, so you probably do want to build a cross.  But since the target is
not running linux you should not use the x86_64-pc-linux triplet.  You
might try the bare metal target x86_64-elf.  You will have to provide
some amount of libc functionality (such as basic headers, startup
objects, and possibly a linker script) before you will be able to build
the cross compiler, as otherwise it will be unable to build libgcc since
it won't be able to link.  Typically people use newlib and libgloss for
this role, but if you are rolling your own libc then you can take care
of that yourself.

Brian

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

* RE: Building a cross compiler for x86_64
  2008-02-15  6:31       ` Brian Dessent
@ 2008-02-15  7:00         ` Frank W. Miller
  2008-02-15  7:17           ` Brian Dessent
  0 siblings, 1 reply; 10+ messages in thread
From: Frank W. Miller @ 2008-02-15  7:00 UTC (permalink / raw)
  To: gcc-help


I'm not sure why I would need to have a different libc.  I'm going to run
the cross compiler and binutils on my Linux box.  I only want to use them to
generate an x86_64 binary kernel that I'll boot on another machine.
Wouldn't the cross compiler just use the fc8 libc to do its work?

May I assume you're talking about providing some libc functionality for the
target?  If that's the case, the kernel is standalone, i.e. its built using
--freestanding.  That way no other libs get linked in except what I specify
exactly.

FM


-----Original Message-----
From: gcc-help-owner@gcc.gnu.org [mailto:gcc-help-owner@gcc.gnu.org] On
Behalf Of Brian Dessent
Sent: Thursday, February 14, 2008 11:31 PM
To: Frank W. Miller
Cc: gcc-help@gcc.gnu.org
Subject: Re: Building a cross compiler for x86_64

"Frank W. Miller" wrote:

> I probably want to build the binutils too, its not that much extra work
and
> I'll know for sure what I've got if I do that.

That's not optional.  Binutils provides (among other things) the
assembler and linker, without which gcc is just a glorified
C-to-assembler text filter.

> The development machine is an ia32 pc running fc8.  The target will be a
> standalone kernel running in ia32e mode.  It sounds like x86_64-pc-linux
> will probably work for me.
> 
> What I really want is for the resulting cross tools, gcc, gas, ld, etc. to
> be 64-bit only.  Will that be the case with this build or will I still
need
> to use -m64 in my compile steps?

Okay, so you probably do want to build a cross.  But since the target is
not running linux you should not use the x86_64-pc-linux triplet.  You
might try the bare metal target x86_64-elf.  You will have to provide
some amount of libc functionality (such as basic headers, startup
objects, and possibly a linker script) before you will be able to build
the cross compiler, as otherwise it will be unable to build libgcc since
it won't be able to link.  Typically people use newlib and libgloss for
this role, but if you are rolling your own libc then you can take care
of that yourself.

Brian

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

* Re: Building a cross compiler for x86_64
  2008-02-15  7:00         ` Frank W. Miller
@ 2008-02-15  7:17           ` Brian Dessent
  0 siblings, 0 replies; 10+ messages in thread
From: Brian Dessent @ 2008-02-15  7:17 UTC (permalink / raw)
  To: Frank W. Miller; +Cc: gcc-help

"Frank W. Miller" wrote:

> I'm not sure why I would need to have a different libc.  I'm going to run
> the cross compiler and binutils on my Linux box.  I only want to use them to
> generate an x86_64 binary kernel that I'll boot on another machine.
> Wouldn't the cross compiler just use the fc8 libc to do its work?

I'm talking about target libs not host libs.

> May I assume you're talking about providing some libc functionality for the
> target?  If that's the case, the kernel is standalone, i.e. its built using
> --freestanding.  That way no other libs get linked in except what I specify
> exactly.

Okay, I thought you were saying you had the kernel and wanted to start
on the userspace.  If it's freestanding then you can skip building
libgcc which eliminates the need for a target libc.  You can either just
do the standard "make all" and let it error at libgcc or you can do
"make all-gcc" which builds just the compiler.

Brian

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

end of thread, other threads:[~2008-02-15  7:17 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-02-06 19:28 64-bit for OS kernel development Frank W. Miller
2008-02-09  1:49 ` Ian Lance Taylor
2008-02-09  2:54   ` Frank W. Miller
2008-02-09  4:41     ` Ian Lance Taylor
2008-02-14 21:53 ` Building a cross compiler for x86_64 Frank W. Miller
2008-02-15  1:32   ` Brian Dessent
2008-02-15  6:02     ` Frank W. Miller
2008-02-15  6:31       ` Brian Dessent
2008-02-15  7:00         ` Frank W. Miller
2008-02-15  7:17           ` 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).