Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Re: How to build GNU toolchain for AMD64?

6 views
Skip to first unread message
Message has been deleted

Bill Marcum

unread,
Jun 22, 2008, 1:06:47 PM6/22/08
to
On 2008-06-22, kh...@yahoo.com <kh...@yahoo.com> wrote:
>
>
> I'm using a Linux distro that doesn't have a 64-bit
> version, and after trying two that do (Ubuntu and
> Fedora) and seeing how incompatible they are
> with my hardware, I've decided to take a minimalist
> approach and build the toolchain and kernel myself.
> However, I've run into snags, and the information
> on the Web seems fragmented and dispersed.
>
> Binutils seem to build without problems:
>
> mkdir /opt64
> tar zxfv binutils-2.18.tar.gz
> cd binutils-2.18
> ./configure --prefix=/opt64 --target=x86_64-pc-linux-gnu
> make
> make install
>
> However gcc builds only the first stage and
> at the end of that, it complains that it cannot
> create the binary, seemingly because it doesn't
> know the name for it (gcc).
>
> export CFLAGS='-Dinhibit_libc'
> export PATH=/opt64/bin:$PATH
> tar jxfv gcc-4.3.1.tar.bz2
> cd gcc-4.3.1
> ./configure --prefix=/opt64 --target=x86_64-pc-linux-gnu --enable-
> languages=c --disable-shared --disable-multilib --enable-
> threads=single --build=x86_64-pc-linux-gnu
> make
>
> Can anyone assist?
> Thanks.

What distro do you use that doesn't have a 64-bit version, and what
hardware do you have that isn't compatible with the most popular
distros? Maybe you could try a minimal installation of Debian.

kh...@yahoo.com

unread,
Jun 22, 2008, 1:56:02 PM6/22/08
to

I'm using Slackware.

Ubuntu was a problem because it refused to let me
specify a root password, and didn't install parts of
the development system.

Fedora insisted on a graphical login but I started the X server
there was constant flickering on my laptop's LCD.
My system has an ATI Radeon X1200.

Thanks.

Nico Kadel-Garcia

unread,
Jun 22, 2008, 2:23:10 PM6/22/08
to Bill Marcum

And what OS and hardware are you building your toolchain on?

Nico Kadel-Garcia

unread,
Jun 22, 2008, 3:19:02 PM6/22/08
to kh...@yahoo.com

When doing the Fedora insall, type 'linux text'. It's described in the 'Help'
options of the installation CD or DVD.

Mark Hobley

unread,
Jun 22, 2008, 5:08:17 PM6/22/08
to
kh...@yahoo.com wrote:

As Bill said, you could try Debian.

> Ubuntu was a problem because it refused to let me
> specify a root password, and didn't install parts of
> the development system.

To set the root password in Ubuntu:

sudo su
passwd

You can then install parts of the development system using:

apt-get install gcc

or whatever else you need.

Regards,

Mark.

--
Mark Hobley,
393 Quinton Road West,
Quinton, BIRMINGHAM.
B32 1QE.

John Hasler

unread,
Jun 22, 2008, 5:38:09 PM6/22/08
to
khapi wrote:
> Ubuntu was a problem because it refused to let me
> specify a root password...

Mark dealt with that.

> ...and didn't install parts of the development system.

What is "the development system"? Ubuntu and Debian offer gigabytes of
packages that are intended for development, but no one would want all of
them at once. That's why you have a package management system. Use it to
install the development packages you need (which will be different from the
ones I need).

Mark Hobley writes:
> You can then install parts of the development system using:

> apt-get install gcc

> or whatever else you need.

I suggest 'apt-get install build-essential'. That gets you gcc, libc6-dev,
make, g++, and dpkg-dev.
--
John Hasler
jo...@dhh.gt.org
Dancing Horse Hill
Elmwood, WI USA

Lionel B

unread,
Jun 23, 2008, 4:57:34 AM6/23/08
to
On Sun, 22 Jun 2008 05:56:51 -0700, khapi wrote:

> I'm using a Linux distro that doesn't have a 64-bit version, and after
> trying two that do (Ubuntu and Fedora) and seeing how incompatible they
> are with my hardware, I've decided to take a minimalist approach and
> build the toolchain and kernel myself. However, I've run into snags, and
> the information on the Web seems fragmented and dispersed.
>
> Binutils seem to build without problems:
>
> mkdir /opt64
> tar zxfv binutils-2.18.tar.gz
> cd binutils-2.18
> ./configure --prefix=/opt64 --target=x86_64-pc-linux-gnu make
> make install
>
> However gcc builds only the first stage and at the end of that, it
> complains that it cannot create the binary, seemingly because it doesn't
> know the name for it (gcc).
>
> export CFLAGS='-Dinhibit_libc'
> export PATH=/opt64/bin:$PATH
> tar jxfv gcc-4.3.1.tar.bz2
> cd gcc-4.3.1
> ./configure --prefix=/opt64 --target=x86_64-pc-linux-gnu --enable-
> languages=c --disable-shared --disable-multilib --enable- threads=single
> --build=x86_64-pc-linux-gnu make

FWIW, you should not attempt to build GCC from within the source
directory: this is highly likely to fail. See:

http://gcc.gnu.org/install/configure.html

Quote: "First, we highly recommend that GCC be built into a separate
directory than the sources which does not reside within the source tree.
This is how we generally build GCC; building where srcdir == objdir
should still work, but doesn't get extensive testing; building where
objdir is a subdirectory of srcdir is unsupported."

Building GCC manually can be pretty non-trivial. A really good RTFM is
recommended.

--
Lionel B

Michael Meissner

unread,
Jul 26, 2008, 12:30:48 AM7/26/08
to
kh...@yahoo.com writes:

First of all, I rarely get down to gnu.misc.discuss, so I might not see any
replies. Hey, I was somewhat bored.

Second another poster mentioned that you should not build in the source
directory.

Third, you probably need to get and install gmp-4.2.2 and mpfr-2.3.1 in order
to build the compiler.

Now, you really don't want to do this, unless you really know the build
process. I am posting from a 64-bit Fedora 8 system. I have installed 64-bit
Suse, Red Hat, Opensuse, Ubuntu, etc. systems from distributions. They all
work fine.

What you have to do is build a complete cross compilation system from
your 32-bit system to a 64-bit system. It's been awhile since I've built a
complete cross system (probably 2001 or so), so I might be skipping one or two
steps.

First you build a cross compiler, putting the compiler in a directory. You
want an ordinary cross compiler in this step, so eliminate the --build
argument. This will build a compiler that runs on the 32-bit system but
generates code for the 64-bit system. A sample build would be:

$ cd /src
$ tar -xvjf gcc-4.3.1.tar.bz2
$ tar -xvjf gmp-4.2.2.tar.bz2
$ tar -xvjf mpfr-2.3.1.tar.bz2
$ tar -xvfj binutils-2.18.tar.bz2
$ tar -xvfj glibc-2.7.tar.bz2
$ tar -xvfj glibc-ports-2.7.tar.bz2
$ tar -xvfj glibc-linuxthreads-2.7.tar.bz2
$ cd /build
$ mkdir binutils-2.18 gmp-4.2.2 mpfr-2.3.1 gcc-4.3.1 glibc-2.7
$ cd binutils-2.18
$ /src/binutils-2.18/configure --prefix=/install/binutils-2.18 \
--target=x86_64-pc-linux-gnu
$ make all && make install
$ cd ../gmp-4.2.2
$ /src/gmp-4.2.2/configure --disable-shared --prefix=/install/gmp-4.2.2
$ make all && make install
$ cd ../mpfr-2.3.1
$ /src/mpfr-2.3.1/configure --disable-shared --prefix=/install/mpfr-2.3.1 \
--with-gmp=/install/gmp-4.2.2
$ make all && make install
$ cd ../gcc-4.3.1
$ export PATH=/install/binutils-2.18:$PATH
$ /src/gcc-4.3.1/configure --prefix=/install/gcc-4.3.1 \
--with-gmp=/install/gmp-4.2.2 \
--with-mpfr=/install/mpfr-2.3.1 \
--target=x86_64-pc-linux-gnu \
--with-gnu-as=/install/binutils-2.18/bin/x86_64-pc-linux-gnu-as \
--with-gnu-ld=/install/binutils-2.18/bin/x86_64-pc-linux-gnu-ld \
--with-sysroot=/install/glibc
$ make all && install

Assuming everything builds, and I'm not missing a step, you should now have a
cross compiler that generates 64-bit code as:
/install/gcc-4.3.1/bin/x86_64-pc-linux-gnu-gcc

Now using that you have a cross compiler (but no libraries), you need to build
glibc with a cross compiler. I tended to use newlib, but in theory you would
do:

$ cd ../glibc-2.7
$ export PATH=/install/gcc-4.3.1:$PATH
$ CC=/install/gcc-4.3.1/bin/x86_64-pc-linux-gnu-gcc /src/glibc-2.7/configure \
--prefix=/install/glibc-2.7 \
--target=x86_64-pc-linux-gnu
$ make all && make install

Ok, now you have a compiler and basic system library. Now you need to build
your kernel. I don't really remember the steps to build a linux kernel using a
cross compiler, but after some amount of futzing about you manage to do this.

Next you need to build the initial binaries that you need on your system (bash,
init, etc.). All of these have to be build with the cross compiler.

Finally, assemble your disk with all of the binaries stored in their correct
location. Configure grub or lilo to boot to your 64-bit kernel. Unless you
are really lucky, they you will spend the next cycle debugging what went wrong
in the boot process, until eventually you can boot into your new system.

Next you need to rebuild the compiler toolchain so that it runs on your 64-bit
system. This is where you will use the --build=x86_64-pc-linux-gnu option.
You will need the cross compiler in your path to do this second stage build.

Once you have the compiler running in 64-bit mode under your new kernel, then
you need to build everything that you want in your new distribution.

--
Michael Meissner
email: mrm...@the-meissners.org
http://www.the-meissners.org

0 new messages